|
@@ -1,15 +1,22 @@
|
|
|
<template>
|
|
|
<v-card class="pa-5 card-box">
|
|
|
+ <div class="mb-3">
|
|
|
+ <v-btn color="primary" variant="tonal" :disabled="!selected.length" @click="handleAction('all', 0, {})">{{ $t('enterprise.userManagement.enable') }}</v-btn>
|
|
|
+ <v-btn class="ml-3" color="primary" variant="tonal" :disabled="!selected.length" @click="handleAction('all', 1, {})">{{ $t('enterprise.userManagement.disable') }}</v-btn>
|
|
|
+ </div>
|
|
|
<v-data-table
|
|
|
+ v-model="selected"
|
|
|
:headers="headers"
|
|
|
:items="items"
|
|
|
+ show-select
|
|
|
hide-default-header
|
|
|
height="70vh"
|
|
|
+ item-value="id"
|
|
|
>
|
|
|
<template #bottom></template>
|
|
|
<template v-slot:item.actions="{ item }">
|
|
|
- <v-btn v-if="item.status === '1'" color="primary" variant="text" @click="handleEnable(item)">启用</v-btn>
|
|
|
- <v-btn v-if="item.status === '0'" color="primary" variant="text" @click="handleDisabled(item)">禁用</v-btn>
|
|
|
+ <v-btn v-if="item.status === '1' && item.userType !== '1'" color="primary" variant="text" @click="handleAction('', 0, item)">{{ $t('enterprise.userManagement.enable') }}</v-btn>
|
|
|
+ <v-btn v-if="item.status === '0' && item.userType !== '1'" color="primary" variant="text" @click="handleAction('', 1, item)">{{ $t('enterprise.userManagement.disable') }}</v-btn>
|
|
|
</template>
|
|
|
</v-data-table>
|
|
|
<CtPagination
|
|
@@ -25,38 +32,29 @@
|
|
|
defineOptions({ name: 'system-management-user'})
|
|
|
import { ref } from 'vue'
|
|
|
import { timesTampChange } from '@/utils/date'
|
|
|
-import { getEnterpriseUserList } from '@/api/enterprise'
|
|
|
+import { useI18n } from '@/hooks/web/useI18n'
|
|
|
+import { getEnterpriseUserList, systemUserEnable, systemUserDisable } from '@/api/enterprise'
|
|
|
+import Confirm from '@/plugins/confirm'
|
|
|
+import Snackbar from '@/plugins/snackbar'
|
|
|
|
|
|
+const { t } = useI18n()
|
|
|
const total = ref(10)
|
|
|
+const items = ref([])
|
|
|
+const selected = ref([])
|
|
|
const query = ref({
|
|
|
pageNo: 1,
|
|
|
pageSize: 10,
|
|
|
status: 0
|
|
|
})
|
|
|
-const items = ref([
|
|
|
- // {
|
|
|
- // "id": "1",
|
|
|
- // "enterpriseId": "1",
|
|
|
- // "enterpriseName": "门墩儿信息科技有限公司",
|
|
|
- // "name": "史迪奇",
|
|
|
- // "sex": "2",
|
|
|
- // "avatar": "http://menduner.citupro.com:6868/admin-api/infra/file/24/get/2b64902c7e0ca60347fe5f23d63b0d620a03eed298b8bb2fd3b80ad1fa27f00f.jpg",
|
|
|
- // "status": "0",
|
|
|
- // "loginDate": 1718354706000,
|
|
|
- // "phone": "13229740091",
|
|
|
- // "email": "1687584225@qq.com",
|
|
|
- // "logoUrl": "https://www.menduner.com/static/img/loginlogo2.7924c12.png",
|
|
|
- // "userType": "1",
|
|
|
- // "updateTime": 1718354706000
|
|
|
- // }
|
|
|
-])
|
|
|
+
|
|
|
const headers = [
|
|
|
- { title: '用户名', key: 'name' },
|
|
|
- { title: '所属企业', key: 'enterpriseName' },
|
|
|
- { title: '手机号', key: 'phone' },
|
|
|
- { title: '邮箱', key: 'email' },
|
|
|
- { title: '最后登录时间', key: 'loginDate', value: item => timesTampChange(item.loginDate) },
|
|
|
- { title: '操作', key: 'actions' }
|
|
|
+ { title: t('login.username'), key: 'name' },
|
|
|
+ { title: t('enterprise.userManagement.affiliatedEnterprise'), key: 'enterpriseName' },
|
|
|
+ { title: t('enterprise.userManagement.phone'), key: 'phone' },
|
|
|
+ { title: t('enterprise.userManagement.email'), key: 'email' },
|
|
|
+ { title: t('enterprise.userManagement.accountType'), key: 'userType', value: item => item.userType === '1' ? t('enterprise.userManagement.administrators') : t('enterprise.userManagement.regularUser')},
|
|
|
+ { title: t('enterprise.userManagement.lastLoginTime'), key: 'loginDate', value: item => timesTampChange(item.loginDate) },
|
|
|
+ { title: t('common.actions'), key: 'actions' }
|
|
|
]
|
|
|
|
|
|
// 获取企业用户列表
|
|
@@ -72,12 +70,21 @@ const handleChangePage = (e) => {
|
|
|
getData()
|
|
|
}
|
|
|
|
|
|
-const handleEnable = (item) => {
|
|
|
- console.log(item, '启用')
|
|
|
-}
|
|
|
+const apiList = [
|
|
|
+ { api: systemUserEnable, desc: t('enterprise.userManagement.enableAccount') },
|
|
|
+ { api: systemUserDisable, desc: t('enterprise.userManagement.disableAccount') }
|
|
|
+]
|
|
|
|
|
|
-const handleDisabled = (item) => {
|
|
|
- console.log(item, '禁用')
|
|
|
+// 启用、禁用账户
|
|
|
+const handleAction = (type, index, item) => {
|
|
|
+ const ids = type ? selected.value : [item.id]
|
|
|
+ Confirm(t('common.confirmTitle'), apiList[index].desc).then(async () => {
|
|
|
+ await apiList[index].api(ids)
|
|
|
+ Snackbar.success(t('common.operationSuccessful'))
|
|
|
+ selected.value = []
|
|
|
+ query.value.pageNo = 1
|
|
|
+ getData()
|
|
|
+ })
|
|
|
}
|
|
|
</script>
|
|
|
|