|
|
|
@ -8,8 +8,11 @@
@@ -8,8 +8,11 @@
|
|
|
|
|
import { BasicColumn } from '/@/components/Table'; |
|
|
|
|
import { FormSchema } from '/@/components/Table'; |
|
|
|
|
import { h } from 'vue'; |
|
|
|
|
import { Tag } from 'ant-design-vue'; |
|
|
|
|
import { Switch } from 'ant-design-vue'; |
|
|
|
|
import { listRole } from '/@/api/system/role'; |
|
|
|
|
import { changeStatus } from '/@/api/system/user'; |
|
|
|
|
import { useMessage } from "/@/hooks/web/useMessage"; |
|
|
|
|
const { createConfirm } = useMessage(); |
|
|
|
|
|
|
|
|
|
export const columns: BasicColumn[] = [ |
|
|
|
|
{ |
|
|
|
@ -35,14 +38,38 @@ export const columns: BasicColumn[] = [
@@ -35,14 +38,38 @@ export const columns: BasicColumn[] = [
|
|
|
|
|
{ |
|
|
|
|
title: '状态', |
|
|
|
|
dataIndex: 'status', |
|
|
|
|
width: 100, |
|
|
|
|
width: 120, |
|
|
|
|
customRender: ({ record }) => { |
|
|
|
|
const status = record.status; |
|
|
|
|
const enable = status === '0'; |
|
|
|
|
const color = enable ? 'green' : 'red'; |
|
|
|
|
const text = enable ? '启动' : '停用'; |
|
|
|
|
return h(Tag, { color: color }, () => text); |
|
|
|
|
}, |
|
|
|
|
// 设置请求加载状态标识
|
|
|
|
|
if (!Reflect.has(record, 'pendingStatus')) { |
|
|
|
|
record.pendingStatus = false; |
|
|
|
|
} |
|
|
|
|
return h(Switch, { |
|
|
|
|
checked: record.status === '0', |
|
|
|
|
checkedChildren: '已启用', |
|
|
|
|
unCheckedChildren: '已禁用', |
|
|
|
|
loading: record.pendingStatus, |
|
|
|
|
onChange(checked: boolean) { |
|
|
|
|
const text = checked ? "启用" : "停用"; |
|
|
|
|
createConfirm({ |
|
|
|
|
iconType: 'warning', |
|
|
|
|
title: '警告', |
|
|
|
|
content: `确认要"${text}${record.userName}用户吗?`, |
|
|
|
|
onOk: async () => { |
|
|
|
|
record.pendingStatus = true; |
|
|
|
|
const newStatus = checked ? '0' : '1'; |
|
|
|
|
const { createMessage } = useMessage(); |
|
|
|
|
changeStatus(record.id, newStatus).then(() => { |
|
|
|
|
record.status = newStatus; |
|
|
|
|
createMessage.success(`${text}成功`); |
|
|
|
|
}).catch(() => { |
|
|
|
|
createMessage.error(`${text}失败`); |
|
|
|
|
}).finally(() => record.pendingStatus = false); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: '创建时间', |
|
|
|
|