2024-09-13 16:34:15 +08:00
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<el-card class="list-query" shadow="hover">
|
2024-09-25 22:24:16 +08:00
|
|
|
<el-form inline label-width="80px">
|
|
|
|
|
<el-form-item :label="T('Username')">
|
2024-09-13 16:34:15 +08:00
|
|
|
<el-input v-model="listQuery.username"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
2024-09-25 22:24:16 +08:00
|
|
|
<el-button type="primary" @click="handlerQuery">{{ T('Filter') }}</el-button>
|
|
|
|
|
<el-button type="danger" @click="toAdd">{{ T('Add') }}</el-button>
|
2025-06-15 17:16:27 +08:00
|
|
|
<el-button type="success" @click="toExport">{{ T('Export') }}</el-button>
|
2024-09-13 16:34:15 +08:00
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
</el-card>
|
|
|
|
|
<el-card class="list-body" shadow="hover">
|
|
|
|
|
<el-table :data="listRes.list" v-loading="listRes.loading" border>
|
2024-10-31 15:31:15 +08:00
|
|
|
<el-table-column prop="id" label="ID" align="center"></el-table-column>
|
2024-09-25 22:24:16 +08:00
|
|
|
<el-table-column prop="username" :label="T('Username')" align="center"/>
|
2024-11-02 04:02:38 +08:00
|
|
|
<el-table-column prop="email" :label="T('Email')" align="center"/>
|
2024-09-25 22:24:16 +08:00
|
|
|
<el-table-column prop="nickname" :label="T('Nickname')" align="center"/>
|
|
|
|
|
<el-table-column :label="T('Group')" align="center">
|
2024-09-13 16:34:15 +08:00
|
|
|
<template #default="{row}">
|
|
|
|
|
<span v-if="row.group_id"> <el-tag>{{ listRes.groups?.find(g => g.id === row.group_id)?.name }} </el-tag> </span>
|
2024-09-25 22:24:16 +08:00
|
|
|
<span v-else> - </span>
|
2024-09-13 16:34:15 +08:00
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
2025-05-25 16:33:12 +08:00
|
|
|
<el-table-column :label="T('Status')" align="center">
|
|
|
|
|
<template #default="{row}">
|
|
|
|
|
<el-switch v-model="row.status"
|
|
|
|
|
:active-value="ENABLE_STATUS"
|
|
|
|
|
:inactive-value="DISABLE_STATUS"
|
|
|
|
|
@change="changeStatus(row)"
|
|
|
|
|
></el-switch>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
2025-07-08 12:18:25 +08:00
|
|
|
<el-table-column prop="remark" :label="T('Remark')" align="center"/>
|
2024-09-25 22:24:16 +08:00
|
|
|
<el-table-column prop="created_at" :label="T('CreatedAt')" align="center"/>
|
|
|
|
|
<el-table-column prop="updated_at" :label="T('UpdatedAt')" align="center"/>
|
|
|
|
|
<el-table-column :label="T('Actions')" align="center" width="650">
|
2024-09-13 16:34:15 +08:00
|
|
|
<template #default="{row}">
|
2024-09-25 22:24:16 +08:00
|
|
|
<el-button @click="toTag(row)">{{ T('UserTags') }}</el-button>
|
|
|
|
|
<el-button @click="toAddressBook(row)">{{ T('UserAddressBook') }}</el-button>
|
|
|
|
|
<el-button @click="toEdit(row)">{{ T('Edit') }}</el-button>
|
|
|
|
|
<el-button type="warning" @click="changePass(row)">{{ T('ResetPassword') }}</el-button>
|
|
|
|
|
<el-button type="danger" @click="remove(row)">{{ T('Delete') }}</el-button>
|
2024-09-13 16:34:15 +08:00
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
</el-card>
|
|
|
|
|
<el-card class="list-page" shadow="hover">
|
|
|
|
|
<el-pagination background
|
|
|
|
|
layout="prev, pager, next, sizes, jumper"
|
|
|
|
|
:page-sizes="[10,20,50,100]"
|
|
|
|
|
v-model:page-size="listQuery.page_size"
|
|
|
|
|
v-model:current-page="listQuery.page"
|
|
|
|
|
:total="listRes.total">
|
|
|
|
|
</el-pagination>
|
|
|
|
|
</el-card>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import { useRepositories, useDel, useToEditOrAdd, useChangePwd } from '@/views/user/composables'
|
2024-09-25 22:24:16 +08:00
|
|
|
import { T } from '@/utils/i18n'
|
2025-05-25 16:33:12 +08:00
|
|
|
import { DISABLE_STATUS, ENABLE_STATUS } from '@/utils/common_options'
|
|
|
|
|
import { update } from '@/api/user'
|
|
|
|
|
import { ElMessageBox, ElMessage } from 'element-plus'
|
2025-06-15 17:16:27 +08:00
|
|
|
import { onMounted, watch } from 'vue'
|
2024-09-13 16:34:15 +08:00
|
|
|
//列表
|
|
|
|
|
const {
|
|
|
|
|
listRes,
|
|
|
|
|
listQuery,
|
|
|
|
|
handlerQuery,
|
|
|
|
|
getList,
|
2025-06-15 17:16:27 +08:00
|
|
|
getGroups,
|
|
|
|
|
toExport,
|
2024-09-13 16:34:15 +08:00
|
|
|
} = useRepositories()
|
|
|
|
|
|
2025-06-15 17:16:27 +08:00
|
|
|
onMounted(getGroups)
|
|
|
|
|
|
|
|
|
|
onMounted(getList)
|
|
|
|
|
|
|
|
|
|
watch(() => listQuery.page, getList)
|
|
|
|
|
watch(() => listQuery.page_size, handlerQuery)
|
|
|
|
|
|
2024-09-13 16:34:15 +08:00
|
|
|
const { toEdit, toAdd, toAddressBook, toTag } = useToEditOrAdd()
|
|
|
|
|
|
|
|
|
|
const { changePass } = useChangePwd()
|
|
|
|
|
|
|
|
|
|
//删除
|
|
|
|
|
const { del } = useDel()
|
|
|
|
|
const remove = async (row) => {
|
|
|
|
|
const res = await del(row.id)
|
|
|
|
|
if (res) {
|
|
|
|
|
getList(listQuery)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-25 16:33:12 +08:00
|
|
|
const changeStatus = async (row) => {
|
|
|
|
|
/*const confirm = await ElMessageBox.confirm(T('Confirm?', { param: T('Update') }), {
|
|
|
|
|
confirmButtonText: T('Confirm'),
|
|
|
|
|
cancelButtonText: T('Cancel'),
|
|
|
|
|
}).catch(_ => false)
|
|
|
|
|
if (!confirm) {
|
|
|
|
|
return false
|
|
|
|
|
}*/
|
|
|
|
|
const res = await update(row).catch(_ => false)
|
|
|
|
|
if (res) {
|
|
|
|
|
ElMessage.success(T('OperationSuccess'))
|
|
|
|
|
getList(listQuery)
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-09-13 16:34:15 +08:00
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
</style>
|