|
|
|
@ -1,7 +1,7 @@ |
|
|
|
<script setup lang="ts"> |
|
|
|
import { reactive } from "vue"; |
|
|
|
import { createVNode, reactive } from "vue"; |
|
|
|
import { ElButton } from "element-plus"; |
|
|
|
import { Delete, Plus, Search } from "@element-plus/icons-vue"; |
|
|
|
import { Delete, EditPen, Plus, Search } from "@element-plus/icons-vue"; |
|
|
|
import DataForm from "@/components/data-form/DataForm.vue"; |
|
|
|
import type { FormField } from "@/components/data-form/DataFormTypes.ts"; |
|
|
|
import { AgGridVue } from "ag-grid-vue3"; |
|
|
|
@ -113,14 +113,109 @@ function serverSideDatasource(params: IServerSideGetRowsParams) { |
|
|
|
params.success({ rowData: page.records, rowCount: page.total }) |
|
|
|
}).finally(() => state.loading = false); |
|
|
|
} |
|
|
|
|
|
|
|
function addOrUpdate(add: boolean = true) { |
|
|
|
let row = {}; |
|
|
|
let ref; |
|
|
|
if (!add) { |
|
|
|
const select = data.api?.getSelectedRows()?.[0]; |
|
|
|
if (!select) { |
|
|
|
system.msg("未选择数据行"); |
|
|
|
return; |
|
|
|
} |
|
|
|
row = select; |
|
|
|
} |
|
|
|
system.showDialog(createVNode(DataForm, { |
|
|
|
refCallback: v => ref = v, |
|
|
|
data: row, |
|
|
|
formFields: [ |
|
|
|
{ |
|
|
|
dataPath: 'loginName', label: '登录名', input: 'Input', |
|
|
|
inputProps: { |
|
|
|
placeholder: '登录名', |
|
|
|
disabled: !add, |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
dataPath: 'password', label: '密码', input: 'Input', |
|
|
|
inputProps: { |
|
|
|
placeholder: '密码', |
|
|
|
type: "password", |
|
|
|
showPassword: true, |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
dataPath: 'userName', label: '姓名', input: 'Input', |
|
|
|
inputProps: { |
|
|
|
placeholder: '姓名' |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
dataPath: 'isEnable', label: '启用', input: 'Switch', |
|
|
|
inputProps: { |
|
|
|
inactiveValue: 0, |
|
|
|
activeValue: 1, |
|
|
|
inlinePrompt: true, |
|
|
|
inactiveText: "禁用", |
|
|
|
activeText: "启用", |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
rules: { |
|
|
|
loginName: [ |
|
|
|
{ required: true, message: "登录名必填", trigger: "blur" }, |
|
|
|
], |
|
|
|
password: [ |
|
|
|
{ required: true, message: "密码必填", trigger: "blur" }, |
|
|
|
], |
|
|
|
userName: [ |
|
|
|
{ required: true, message: "姓名必填", trigger: "blur" }, |
|
|
|
], |
|
|
|
}, |
|
|
|
showMessage: true, |
|
|
|
columnCount: 1, |
|
|
|
labelWidth: '70px' |
|
|
|
}), { |
|
|
|
title: `${add ? "新增" : "编辑"}用户`, |
|
|
|
width: 480, |
|
|
|
height: 300, |
|
|
|
showClose: true, |
|
|
|
showMax: false, |
|
|
|
showCancelButton: true, |
|
|
|
showOkButton: true, |
|
|
|
okButtonText: '确定', |
|
|
|
cancelButtonText: '取消', |
|
|
|
manualClose: async (close) => { |
|
|
|
await ref.data.formRef.validate(); |
|
|
|
Request.request.post(`/api/workbench/UserPermissions@${add ? "addUser" : "updateUser"}`, row).then(() => { |
|
|
|
close(); |
|
|
|
reload(); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}).then().finally() |
|
|
|
} |
|
|
|
|
|
|
|
function delUser() { |
|
|
|
const select = data.api?.getSelectedRows()?.[0]; |
|
|
|
if (!select) { |
|
|
|
system.msg("未选择数据行"); |
|
|
|
return; |
|
|
|
} |
|
|
|
system.confirm(`是否删除用户: ${select.loginName}?`).then(() => { |
|
|
|
Request.request.post(`/api/workbench/UserPermissions@delUser?id=${select.id}`).then(() => { |
|
|
|
reload(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<template> |
|
|
|
<div class="dashboard flex-column-container"> |
|
|
|
<div class="tools flex-item-fixed"> |
|
|
|
<ElButton :icon="Search" :loading="state.loading" @click="reload">查询</ElButton> |
|
|
|
<ElButton :icon="Plus">新增</ElButton> |
|
|
|
<ElButton :icon="Delete" type="danger" :plain="true">删除</ElButton> |
|
|
|
<ElButton :icon="Plus" @click="addOrUpdate(true)">新增</ElButton> |
|
|
|
<ElButton :icon="EditPen" @click="addOrUpdate(false)">编辑</ElButton> |
|
|
|
<ElButton :icon="Delete" type="danger" :plain="true" @click="delUser">删除</ElButton> |
|
|
|
</div> |
|
|
|
<DataForm |
|
|
|
class="query-form flex-item-fixed" |
|
|
|
|