2021-10-20 14:32:09 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<!--引用表格-->
|
|
|
|
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
|
|
|
<!--插槽:table标题-->
|
|
|
|
<template #tableTitle>
|
2022-09-25 09:55:29 +08:00
|
|
|
<a-button type="primary" preIcon="ant-design:plus-outlined" v-auth="'system:user:add'" @click="handleCreate"> 新增</a-button>
|
2022-06-10 10:44:44 +08:00
|
|
|
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
|
|
|
|
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
|
|
|
<a-button type="primary" @click="handleSyncUser" preIcon="ant-design:sync-outlined"> 同步流程</a-button>
|
|
|
|
<a-button type="primary" @click="openModal(true, {})" preIcon="ant-design:hdd-outlined"> 回收站</a-button>
|
|
|
|
<JThirdAppButton biz-type="user" :selected-row-keys="selectedRowKeys" syncToApp syncToLocal @sync-finally="onSyncFinally" />
|
|
|
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
2021-10-20 14:32:09 +08:00
|
|
|
<template #overlay>
|
|
|
|
<a-menu>
|
|
|
|
<a-menu-item key="1" @click="batchHandleDelete">
|
|
|
|
<Icon icon="ant-design:delete-outlined"></Icon>
|
|
|
|
删除
|
|
|
|
</a-menu-item>
|
2022-03-10 09:47:29 +08:00
|
|
|
<a-menu-item key="2" @click="batchFrozen(2)">
|
|
|
|
<Icon icon="ant-design:lock-outlined"></Icon>
|
|
|
|
冻结
|
|
|
|
</a-menu-item>
|
|
|
|
<a-menu-item key="3" @click="batchFrozen(1)">
|
|
|
|
<Icon icon="ant-design:unlock-outlined"></Icon>
|
|
|
|
解冻
|
|
|
|
</a-menu-item>
|
2021-10-20 14:32:09 +08:00
|
|
|
</a-menu>
|
|
|
|
</template>
|
2022-06-10 10:44:44 +08:00
|
|
|
<a-button
|
|
|
|
>批量操作
|
2022-03-10 09:47:29 +08:00
|
|
|
<Icon icon="mdi:chevron-down"></Icon>
|
2021-10-20 14:32:09 +08:00
|
|
|
</a-button>
|
|
|
|
</a-dropdown>
|
|
|
|
</template>
|
|
|
|
<!--操作栏-->
|
|
|
|
<template #action="{ record }">
|
2022-06-10 10:44:44 +08:00
|
|
|
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
2021-10-20 14:32:09 +08:00
|
|
|
</template>
|
|
|
|
</BasicTable>
|
|
|
|
<!--用户抽屉-->
|
2022-06-10 10:44:44 +08:00
|
|
|
<UserDrawer @register="registerDrawer" @success="handleSuccess" />
|
2022-03-10 09:47:29 +08:00
|
|
|
<!--修改密码-->
|
2022-06-10 10:44:44 +08:00
|
|
|
<PasswordModal @register="registerPasswordModal" @success="reload" />
|
2022-03-10 09:47:29 +08:00
|
|
|
<!--用户代理-->
|
2022-06-10 10:44:44 +08:00
|
|
|
<UserAgentModal @register="registerAgentModal" @success="reload" />
|
2021-10-20 14:32:09 +08:00
|
|
|
<!--回收站-->
|
2022-06-10 10:44:44 +08:00
|
|
|
<UserRecycleBinModal @register="registerModal" @success="reload" />
|
2021-10-20 14:32:09 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-03-10 09:47:29 +08:00
|
|
|
<script lang="ts" name="system-user" setup>
|
2021-10-20 14:32:09 +08:00
|
|
|
//ts语法
|
2022-06-10 10:44:44 +08:00
|
|
|
import { ref, computed, unref } from 'vue';
|
|
|
|
import { BasicTable, TableAction, ActionItem } from '/@/components/Table';
|
2021-10-20 14:32:09 +08:00
|
|
|
import UserDrawer from './UserDrawer.vue';
|
|
|
|
import UserRecycleBinModal from './UserRecycleBinModal.vue';
|
2022-03-10 09:47:29 +08:00
|
|
|
import PasswordModal from './PasswordModal.vue';
|
|
|
|
import UserAgentModal from './UserAgentModal.vue';
|
2022-06-10 10:44:44 +08:00
|
|
|
import JThirdAppButton from '/@/components/jeecg/thirdApp/JThirdAppButton.vue';
|
|
|
|
import { useDrawer } from '/@/components/Drawer';
|
|
|
|
import { useListPage } from '/@/hooks/system/useListPage';
|
|
|
|
import { useModal } from '/@/components/Modal';
|
|
|
|
import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
|
import { columns, searchFormSchema } from './user.data';
|
|
|
|
import { list, deleteUser, batchDeleteUser, getImportUrl, getExportUrl, frozenBatch, syncUser } from './user.api';
|
2022-03-10 09:47:29 +08:00
|
|
|
// import { usePermission } from '/@/hooks/web/usePermission'
|
|
|
|
// const { hasPermission } = usePermission();
|
|
|
|
|
2022-06-10 10:44:44 +08:00
|
|
|
const { createMessage, createConfirm } = useMessage();
|
2022-03-10 09:47:29 +08:00
|
|
|
|
2021-10-20 14:32:09 +08:00
|
|
|
//注册drawer
|
2022-06-10 10:44:44 +08:00
|
|
|
const [registerDrawer, { openDrawer }] = useDrawer();
|
2022-03-10 09:47:29 +08:00
|
|
|
//回收站model
|
2022-06-10 10:44:44 +08:00
|
|
|
const [registerModal, { openModal }] = useModal();
|
2022-03-10 09:47:29 +08:00
|
|
|
//密码model
|
2022-06-10 10:44:44 +08:00
|
|
|
const [registerPasswordModal, { openModal: openPasswordModal }] = useModal();
|
2022-03-10 09:47:29 +08:00
|
|
|
//代理人model
|
2022-06-10 10:44:44 +08:00
|
|
|
const [registerAgentModal, { openModal: openAgentModal }] = useModal();
|
2022-03-10 09:47:29 +08:00
|
|
|
|
|
|
|
// 列表页面公共参数、方法
|
2022-06-10 10:44:44 +08:00
|
|
|
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
2022-03-10 09:47:29 +08:00
|
|
|
designScope: 'user-list',
|
|
|
|
tableProps: {
|
|
|
|
title: '用户列表',
|
|
|
|
api: list,
|
|
|
|
columns: columns,
|
|
|
|
size: 'small',
|
|
|
|
formConfig: {
|
2022-09-25 09:55:29 +08:00
|
|
|
// labelWidth: 200,
|
2022-03-10 09:47:29 +08:00
|
|
|
schemas: searchFormSchema,
|
|
|
|
},
|
|
|
|
actionColumn: {
|
|
|
|
width: 120,
|
|
|
|
},
|
2022-06-10 10:44:44 +08:00
|
|
|
beforeFetch: (params) => {
|
|
|
|
return Object.assign({ column: 'createTime', order: 'desc' }, params);
|
2022-03-10 09:47:29 +08:00
|
|
|
},
|
2021-10-20 14:32:09 +08:00
|
|
|
},
|
2022-03-10 09:47:29 +08:00
|
|
|
exportConfig: {
|
2022-06-10 10:44:44 +08:00
|
|
|
name: '用户列表',
|
2022-03-10 09:47:29 +08:00
|
|
|
url: getExportUrl,
|
|
|
|
},
|
|
|
|
importConfig: {
|
2022-06-10 10:44:44 +08:00
|
|
|
url: getImportUrl,
|
2021-10-20 14:32:09 +08:00
|
|
|
},
|
2022-06-10 10:44:44 +08:00
|
|
|
});
|
2022-03-10 09:47:29 +08:00
|
|
|
|
|
|
|
//注册table数据
|
2022-09-22 14:06:18 +08:00
|
|
|
const [registerTable, { reload, updateTableDataRecord }, { rowSelection, selectedRows, selectedRowKeys }] = tableContext;
|
2022-03-10 09:47:29 +08:00
|
|
|
|
2021-10-20 14:32:09 +08:00
|
|
|
/**
|
|
|
|
* 新增事件
|
|
|
|
*/
|
|
|
|
function handleCreate() {
|
|
|
|
openDrawer(true, {
|
|
|
|
isUpdate: false,
|
2022-03-10 09:47:29 +08:00
|
|
|
showFooter: true,
|
2021-10-20 14:32:09 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 编辑事件
|
|
|
|
*/
|
|
|
|
async function handleEdit(record: Recordable) {
|
|
|
|
openDrawer(true, {
|
|
|
|
record,
|
|
|
|
isUpdate: true,
|
2022-03-10 09:47:29 +08:00
|
|
|
showFooter: true,
|
2021-10-20 14:32:09 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 详情
|
2022-06-10 10:44:44 +08:00
|
|
|
*/
|
2021-10-20 14:32:09 +08:00
|
|
|
async function handleDetail(record: Recordable) {
|
|
|
|
openDrawer(true, {
|
|
|
|
record,
|
|
|
|
isUpdate: true,
|
2022-03-10 09:47:29 +08:00
|
|
|
showFooter: false,
|
2021-10-20 14:32:09 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 删除事件
|
|
|
|
*/
|
|
|
|
async function handleDelete(record) {
|
2022-03-10 09:47:29 +08:00
|
|
|
if ('admin' == record.username) {
|
|
|
|
createMessage.warning('管理员账号不允许此操作!');
|
|
|
|
return;
|
|
|
|
}
|
2022-06-10 10:44:44 +08:00
|
|
|
await deleteUser({ id: record.id }, reload);
|
2021-10-20 14:32:09 +08:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 批量删除事件
|
|
|
|
*/
|
|
|
|
async function batchHandleDelete() {
|
2022-09-22 14:06:18 +08:00
|
|
|
let hasAdmin = unref(selectedRows).filter((item) => item.username == 'admin');
|
2022-03-10 09:47:29 +08:00
|
|
|
if (unref(hasAdmin).length > 0) {
|
|
|
|
createMessage.warning('管理员账号不允许此操作!');
|
|
|
|
return;
|
2021-10-20 14:32:09 +08:00
|
|
|
}
|
2022-03-10 09:47:29 +08:00
|
|
|
await batchDeleteUser({ ids: selectedRowKeys.value }, () => {
|
2022-06-10 10:44:44 +08:00
|
|
|
selectedRowKeys.value = [];
|
|
|
|
reload();
|
|
|
|
});
|
2021-10-20 14:32:09 +08:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 成功回调
|
|
|
|
*/
|
2022-06-21 17:53:49 +08:00
|
|
|
function handleSuccess() {
|
|
|
|
reload();
|
2021-10-20 14:32:09 +08:00
|
|
|
}
|
2022-03-10 09:47:29 +08:00
|
|
|
|
2021-10-20 14:32:09 +08:00
|
|
|
/**
|
2022-03-10 09:47:29 +08:00
|
|
|
* 打开修改密码弹窗
|
2021-10-20 14:32:09 +08:00
|
|
|
*/
|
2022-06-10 10:44:44 +08:00
|
|
|
function handleChangePassword(username) {
|
|
|
|
openPasswordModal(true, { username });
|
2022-03-10 09:47:29 +08:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 打开代理人弹窗
|
|
|
|
*/
|
2022-06-10 10:44:44 +08:00
|
|
|
function handleAgentSettings(userName) {
|
|
|
|
openAgentModal(true, { userName });
|
2022-03-10 09:47:29 +08:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 冻结解冻
|
|
|
|
*/
|
2022-06-10 10:44:44 +08:00
|
|
|
async function handleFrozen(record, status) {
|
2022-03-10 09:47:29 +08:00
|
|
|
if ('admin' == record.username) {
|
|
|
|
createMessage.warning('管理员账号不允许此操作!');
|
|
|
|
return;
|
2021-10-20 14:32:09 +08:00
|
|
|
}
|
2022-06-10 10:44:44 +08:00
|
|
|
await frozenBatch({ ids: record.id, status: status }, reload);
|
2021-10-20 14:32:09 +08:00
|
|
|
}
|
2022-06-10 10:44:44 +08:00
|
|
|
/**
|
2022-03-10 09:47:29 +08:00
|
|
|
* 批量冻结解冻
|
|
|
|
*/
|
|
|
|
function batchFrozen(status) {
|
2022-09-22 14:06:18 +08:00
|
|
|
let hasAdmin = selectedRows.value.filter((item) => item.username == 'admin');
|
2022-03-10 09:47:29 +08:00
|
|
|
if (unref(hasAdmin).length > 0) {
|
|
|
|
createMessage.warning('管理员账号不允许此操作!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
createConfirm({
|
|
|
|
iconType: 'warning',
|
|
|
|
title: '确认操作',
|
2022-06-10 10:44:44 +08:00
|
|
|
content: '是否' + (status == 1 ? '解冻' : '冻结') + '选中账号?',
|
2022-03-10 09:47:29 +08:00
|
|
|
onOk: async () => {
|
2022-06-10 10:44:44 +08:00
|
|
|
await frozenBatch({ ids: unref(selectedRowKeys).join(','), status: status }, reload);
|
|
|
|
},
|
|
|
|
});
|
2022-03-10 09:47:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*同步流程
|
|
|
|
*/
|
|
|
|
function handleSyncUser() {
|
2022-06-10 10:44:44 +08:00
|
|
|
syncUser();
|
2022-03-10 09:47:29 +08:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
*同步钉钉和微信回调
|
|
|
|
*/
|
2022-06-10 10:44:44 +08:00
|
|
|
function onSyncFinally({ isToLocal }) {
|
|
|
|
// 同步到本地时刷新下数据
|
|
|
|
if (isToLocal) {
|
|
|
|
reload();
|
|
|
|
}
|
2022-03-10 09:47:29 +08:00
|
|
|
}
|
|
|
|
|
2021-10-20 14:32:09 +08:00
|
|
|
/**
|
|
|
|
* 操作栏
|
|
|
|
*/
|
2022-03-10 09:47:29 +08:00
|
|
|
function getTableAction(record): ActionItem[] {
|
2021-10-20 14:32:09 +08:00
|
|
|
return [
|
|
|
|
{
|
2022-03-10 09:47:29 +08:00
|
|
|
label: '编辑',
|
2021-10-20 14:32:09 +08:00
|
|
|
onClick: handleEdit.bind(null, record),
|
2022-07-20 18:01:08 +08:00
|
|
|
// ifShow: () => hasPermission('system:user:edit'),
|
2022-06-10 10:44:44 +08:00
|
|
|
},
|
|
|
|
];
|
2021-10-20 14:32:09 +08:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 下拉操作栏
|
|
|
|
*/
|
2022-03-10 09:47:29 +08:00
|
|
|
function getDropDownAction(record): ActionItem[] {
|
2021-10-20 14:32:09 +08:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
label: '详情',
|
|
|
|
onClick: handleDetail.bind(null, record),
|
2022-06-10 10:44:44 +08:00
|
|
|
},
|
|
|
|
{
|
2022-03-10 09:47:29 +08:00
|
|
|
label: '密码',
|
|
|
|
onClick: handleChangePassword.bind(null, record.username),
|
2022-06-10 10:44:44 +08:00
|
|
|
},
|
|
|
|
{
|
2021-10-20 14:32:09 +08:00
|
|
|
label: '删除',
|
|
|
|
popConfirm: {
|
|
|
|
title: '是否确认删除',
|
|
|
|
confirm: handleDelete.bind(null, record),
|
|
|
|
},
|
2022-06-10 10:44:44 +08:00
|
|
|
},
|
|
|
|
{
|
2022-03-10 09:47:29 +08:00
|
|
|
label: '冻结',
|
2022-06-10 10:44:44 +08:00
|
|
|
ifShow: record.status == 1,
|
2022-03-10 09:47:29 +08:00
|
|
|
popConfirm: {
|
|
|
|
title: '确定冻结吗?',
|
2022-06-10 10:44:44 +08:00
|
|
|
confirm: handleFrozen.bind(null, record, 2),
|
2022-03-10 09:47:29 +08:00
|
|
|
},
|
2022-06-10 10:44:44 +08:00
|
|
|
},
|
|
|
|
{
|
2022-03-10 09:47:29 +08:00
|
|
|
label: '解冻',
|
2022-06-10 10:44:44 +08:00
|
|
|
ifShow: record.status == 2,
|
2022-03-10 09:47:29 +08:00
|
|
|
popConfirm: {
|
|
|
|
title: '确定解冻吗?',
|
2022-06-10 10:44:44 +08:00
|
|
|
confirm: handleFrozen.bind(null, record, 1),
|
2022-03-10 09:47:29 +08:00
|
|
|
},
|
2022-06-10 10:44:44 +08:00
|
|
|
},
|
|
|
|
{
|
2022-03-10 09:47:29 +08:00
|
|
|
label: '代理人',
|
|
|
|
onClick: handleAgentSettings.bind(null, record.username),
|
2022-06-10 10:44:44 +08:00
|
|
|
},
|
|
|
|
];
|
2021-10-20 14:32:09 +08:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2022-06-10 10:44:44 +08:00
|
|
|
<style scoped></style>
|