Files
SaaS-lib/hx-ai-intelligent/src/view/organizationManage/usermanage/index.vue

560 lines
16 KiB
Vue
Raw Normal View History

2024-05-22 16:31:55 +08:00
<!-- @format -->
<template>
2024-05-23 14:34:26 +08:00
<div class="main">
<div class="left">
<div class="top">
<div class="ns-table-title">关联企业</div>
<div>
<a-input-search
v-model:value="searchValue"
style="margin-bottom: 8px"
placeholder="请输入关联企业"
@search="onSearch" />
2024-05-28 11:08:57 +08:00
<a-tree :tree-data="treeData" defaultExpandAll @select="handleSelect">
2024-05-23 14:34:26 +08:00
<template #title="{ title }">
{{ title }}
<!-- <span v-if="title.indexOf(searchValue) > -1">
{{ title.substring(0, title.indexOf(searchValue)) }}
</span>
<span v-else>{{ title }}</span> -->
</template>
</a-tree>
</div>
</div>
<div class="ns-table-title">关联部门</div>
<div>
<a-input-search
v-model:value="searchValue2"
style="margin-bottom: 8px"
placeholder="请输入关联部门"
@search="onSearch2" />
2024-05-28 11:08:57 +08:00
<a-tree :tree-data="treeData2" defaultExpandAll @select="handleSelect2">
2024-05-23 14:34:26 +08:00
<template #title="{ title }">
{{ title }}
<!-- <span v-if="title.indexOf(searchValue) > -1">
{{ title.substring(0, title.indexOf(searchValue)) }}
</span>
<span v-else>{{ title }}</span> -->
</template>
</a-tree>
</div>
</div>
<div class="right">
2024-05-24 09:44:08 +08:00
<ns-view-list-table v-bind="tableConfig" :model="data" ref="mainRef" />
2024-05-23 14:34:26 +08:00
</div>
2024-05-23 16:17:12 +08:00
<a-drawer
:width="1200"
:visible="visible"
:body-style="{ paddingBottom: '80px' }"
:footer-style="{ textAlign: 'right' }"
2024-05-28 11:08:57 +08:00
destroyOnClose
2024-05-23 16:17:12 +08:00
@close="onClose">
2024-05-28 11:08:57 +08:00
<ns-form ref="formRef" :schemas="formSchema" :model="formData" class="form" />
2024-05-23 16:17:12 +08:00
<span class="admin">用户权限</span>
<ns-view-list-table v-bind="tableConfig2" :model="data" ref="mainRef" rowKey="uuid" />
<a-button style="margin-right: 8px" @click="onClose">取消</a-button>
<a-button type="primary" @click="onEdit">确定</a-button>
</a-drawer>
2024-05-23 14:34:26 +08:00
2024-05-23 16:17:12 +08:00
<a-modal
title="用户信息"
:width="600"
:visible="addformvisible"
cancelText="取消"
@ok="handleOk"
@cancel="handleClose">
2024-05-24 13:13:24 +08:00
<ns-form :schemas="formSchema2" :model="formData2" formLayout="vertical" />
2024-05-23 16:17:12 +08:00
</a-modal>
</div>
2024-05-22 16:31:55 +08:00
</template>
<script lang="ts">
import { Modal } from 'ant-design-vue';
import { createVNode, defineComponent, reactive, ref } from 'vue';
import { http } from '/nerv-lib/util/http';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
2024-05-23 14:34:26 +08:00
import { cloneDeep } from 'lodash-es';
import { NsMessage } from '/nerv-lib/component';
2024-05-28 11:08:57 +08:00
import { formConfig, formConfig2 } from './config';
import { mockData, mockData2, treeData, treeData2 } from './mock';
2024-05-28 18:00:25 +08:00
import { origanizemanage } from '/@/api/origanizemanage';
2024-05-22 16:31:55 +08:00
export default defineComponent({
name: 'OrderListIndex',
setup() {
const mainRef = ref();
const data = reactive({});
2024-05-23 14:34:26 +08:00
let formData = ref({});
let formData2 = ref({});
2024-05-28 11:08:57 +08:00
const formRef = ref();
2024-05-22 16:31:55 +08:00
const visible = ref(false);
2024-05-23 14:34:26 +08:00
const addformvisible = ref(false);
2024-05-22 16:31:55 +08:00
const searchValue = ref<string>('');
const searchValue2 = ref<string>('');
2024-05-28 11:08:57 +08:00
const formSchema = formConfig;
const casData = ref([]);
const formSchema2 = formConfig2(casData);
2024-05-23 14:34:26 +08:00
const opMap: any = {
type: 'add',
fuc: () => {},
record: {},
};
2024-05-22 16:31:55 +08:00
const onSearch = () => {
console.log(searchValue.value);
};
const onSearch2 = () => {
console.log(searchValue2.value);
};
const handleSelect = (selectedKeys: any, info: any) => {
console.log(selectedKeys, 'selectedKeys');
console.log(info, 'info');
};
const handleSelect2 = (selectedKeys: any, info: any) => {
console.log(selectedKeys, 'selectedKeys');
console.log(info, 'info');
};
const onClose = () => {
visible.value = false;
};
2024-05-23 14:34:26 +08:00
2024-05-22 16:31:55 +08:00
const onEdit = () => {
2024-05-28 11:08:57 +08:00
formRef.value?.triggerSubmit().then(() => {
console.log(formData.value, 'formData.value');
opMap.fuc && opMap.fuc(formData.value);
visible.value = false;
});
2024-05-22 16:31:55 +08:00
};
const handleOk = () => {
2024-05-24 13:13:24 +08:00
console.log(formData2.value, 'formData2.value');
console.log(opMap.type, 'type');
if (opMap.type === 'add') {
mockData2.value.push({ information: casData.value.join('/') });
} else {
}
2024-05-22 16:31:55 +08:00
addformvisible.value = false;
};
const handleClose = () => {
addformvisible.value = false;
};
const tableConfig = {
2024-05-28 18:00:25 +08:00
title: '用户管理',
api: origanizemanage.userList,
params: {
orgId: JSON.parse(sessionStorage.getItem('userInfo')).orgId,
},
2024-05-22 16:31:55 +08:00
listField: 'data.records',
headerActions: [
{
label: '新增',
name: 'RoleTypeAdd',
type: 'primary',
handle: () => {
2024-05-23 14:34:26 +08:00
opMap.type = 'add';
opMap.fuc = (formData: any) => {
console.log(formData, 'formData');
2024-05-28 18:00:25 +08:00
// origanizemanage.addUser
// mockData.value.push({
// id: Math.random().toString().slice(2, 6),
// ...cloneDeep(formData),
// });
2024-05-23 14:34:26 +08:00
};
2024-05-22 16:31:55 +08:00
visible.value = true;
},
},
{
label: '导入',
type: 'primary',
name: 'RoleTypeAdd',
handle: () => {},
},
{
label: '模板下载',
type: 'primary',
name: 'RoleTypeAdd',
handle: () => {},
},
{
label: '导出',
type: 'primary',
2024-05-23 14:34:26 +08:00
name: 'exports',
2024-05-22 16:31:55 +08:00
},
{
label: '批量删除',
type: 'primary',
name: 'RoleTypeAdd',
dynamicDisabled: (data: any) => {
return data.list.length === 0;
},
confirm: true,
isReload: true,
2024-05-24 13:13:24 +08:00
handle: (data: any) => {
2024-05-28 11:08:57 +08:00
console.log('object :>> ', data.list);
const idList = data.list.map((item) => item.id);
mockData.value.splice(0);
return;
const copyData = cloneDeep(mockData.value);
mockData.value = copyData.filter((tar) => {
return !idList.includes(tar.id);
});
console.log(mockData.value);
return;
copyData.map((item, index) => {
if (idList.includes(item.id)) {
mockData.value.filter((tar) => {
return !idList.includes(tar.id);
});
}
});
2024-05-24 13:13:24 +08:00
},
2024-05-22 16:31:55 +08:00
},
],
columns: [
{
title: '序号',
dataIndex: 'address',
customRender: (text: any) => {
return text.index + 1;
},
sorter: {
compare: (a, b) => a.address - b.address,
},
},
{
title: '账号',
2024-05-28 18:00:25 +08:00
dataIndex: 'accountNo',
2024-05-22 16:31:55 +08:00
sorter: {
2024-05-28 18:00:25 +08:00
compare: (a, b) => a.accountNo - b.accountNo,
2024-05-22 16:31:55 +08:00
},
},
{
title: '姓名',
2024-05-28 18:00:25 +08:00
dataIndex: 'realName',
2024-05-22 16:31:55 +08:00
sorter: {
2024-05-28 18:00:25 +08:00
compare: (a, b) => a.realName - b.realName,
2024-05-22 16:31:55 +08:00
},
},
{
title: '性别',
dataIndex: 'sex',
sorter: {
compare: (a, b) => a.name - b.name,
},
},
{
title: '手机号',
2024-05-28 18:00:25 +08:00
dataIndex: 'telephone',
2024-05-22 16:31:55 +08:00
},
{
title: '邮箱',
dataIndex: 'email',
},
{
title: '组织关系',
2024-05-28 18:00:25 +08:00
dataIndex: 'deptInfo',
customRender: (value) => {
return value.record.deptInfo.orgName;
},
2024-05-22 16:31:55 +08:00
},
{
2024-05-28 18:00:25 +08:00
title: '部门/角色',
dataIndex: 'orgInfo',
customRender: (value) => {
// // console.log(value.record.orgInfo.orgName, 'ss');
// console.log(
// value.record.userRoleList.map((item) => {
// return `${value.record.orgInfo.orgName}/${item.roleName}`;
// }),
// );
// value.record.userRoleList.map((item) => {
// return `${value.record.orgInfo.orgName}/${item.roleName}`;
// });
// return `${value.record.orgInfo.orgName}/`;
},
2024-05-22 16:31:55 +08:00
},
{
title: '状态',
2024-05-28 18:00:25 +08:00
dataIndex: 'userStatus',
2024-05-22 16:31:55 +08:00
},
],
columnActions: {
title: '操作',
actions: [
{
label: '编辑',
name: 'RoleTypeEdit',
// dynamicParams: 'uuid',
handle: (record: any) => {
console.log(record, 'record');
2024-05-23 14:34:26 +08:00
formData.value = record;
opMap.type = 'edit';
opMap.fuc = (formData: any) => {
Object.assign(
mockData.value.filter((item) => item.id === record.id)[0],
formData,
);
};
2024-05-22 16:31:55 +08:00
visible.value = true;
},
},
{
label: '冻结',
name: 'RoleTypeEdit',
handle: (record: any) => {
console.log(record, 'record');
Modal.confirm({
title: '是否冻结该账户',
icon: createVNode(ExclamationCircleOutlined),
content: createVNode('div', { style: 'color:red;' }, ''),
2024-05-23 17:09:08 +08:00
2024-05-22 16:31:55 +08:00
onOk() {
// http
// .post('/api/parking_merchant/objs/gateInfo/delete', {
// uuid: record.uuid,
// })
// .then((res) => {
// mainRef.value.nsTableRef.reload();
// });
2024-05-24 13:13:24 +08:00
NsMessage.success('冻结成功');
2024-05-22 16:31:55 +08:00
},
class: 'test',
});
},
},
{
label: '重置密码',
name: 'RoleTypeEdit',
handle: (record: any) => {
console.log(record, 'record');
Modal.confirm({
title: '是否重置密码',
icon: createVNode(ExclamationCircleOutlined),
content: createVNode('div', { style: 'color:red;' }, ''),
onOk() {
2024-05-23 14:34:26 +08:00
// Modal.success({
// title: '密码重置成功,初始密码123456',
// });
NsMessage.success('密码重置成功,初始密码123456');
2024-05-22 16:31:55 +08:00
},
onCancel() {
console.log('Cancel');
},
class: 'test',
});
},
},
{
label: '删除',
name: 'RoleTypeEdit',
dynamicParams: {
uuid: 'uuid',
},
2024-05-23 14:34:26 +08:00
confirm: true,
2024-05-24 13:13:24 +08:00
handle: (record: any, name: any, reload: any) => {
2024-05-23 14:34:26 +08:00
console.log(record, name, reload, 'record');
mockData.value.splice(0, 1);
2024-05-22 16:31:55 +08:00
},
},
],
},
formConfig: {
schemas: [
{
2024-05-28 18:00:25 +08:00
field: 'accountNo',
2024-05-22 16:31:55 +08:00
label: '账号名',
component: 'NsInput',
componentProps: {
placeholder: '请输入账号名',
2024-05-28 11:08:57 +08:00
maxLength: 30,
2024-05-22 16:31:55 +08:00
},
},
{
2024-05-28 18:00:25 +08:00
field: 'realName',
2024-05-22 16:31:55 +08:00
label: '姓名',
component: 'NsInput',
componentProps: {
placeholder: '请输入姓名',
2024-05-28 11:08:57 +08:00
maxLength: 30,
2024-05-22 16:31:55 +08:00
},
},
{
2024-05-28 18:00:25 +08:00
field: 'telephone',
2024-05-22 16:31:55 +08:00
label: '手机号',
component: 'NsInput',
componentProps: {
placeholder: '请输入手机号',
2024-05-28 11:08:57 +08:00
maxLength: 11,
2024-05-22 16:31:55 +08:00
},
},
{
field: 'email',
label: '邮箱',
component: 'NsInput',
componentProps: {
placeholder: '请输入邮箱',
2024-05-28 11:08:57 +08:00
maxLength: 30,
2024-05-22 16:31:55 +08:00
},
},
{
2024-05-28 18:00:25 +08:00
field: 'userStatus',
2024-05-22 16:31:55 +08:00
label: '用户状态',
component: 'NsSelect',
componentProps: {
placeholder: '请选择',
2024-05-28 11:08:57 +08:00
disabled: true,
2024-05-22 16:31:55 +08:00
options: [
{
label: '正常',
value: 1,
},
{
label: '冻结',
value: 2,
},
],
},
},
],
params: {},
},
// pagination: { defaultPageSize: 10 },
2024-05-23 14:34:26 +08:00
rowKey: 'id',
2024-05-22 16:31:55 +08:00
};
const tableConfig2 = {
2024-05-23 14:34:26 +08:00
// api: {
// url: '/carbon_emission/device/getGatewayList',
// method: 'post',
// },
value: mockData2.value,
2024-05-22 16:31:55 +08:00
listField: 'data.records',
rowSelection: null,
headerActions: [
{
label: '新增',
name: 'RoleTypeAdd',
type: 'primary',
handle: () => {
2024-05-23 14:34:26 +08:00
opMap.type = 'add';
opMap.fuc = (formData2: any) => {
console.log(formData2, 'formData2');
mockData2.value.push(cloneDeep(formData2));
};
2024-05-22 16:31:55 +08:00
addformvisible.value = true;
},
},
],
columns: [
{
title: '角色信息',
2024-05-23 14:34:26 +08:00
dataIndex: 'information',
2024-05-22 16:31:55 +08:00
},
],
columnActions: {
title: '操作',
actions: [
{
label: '编辑',
name: 'RoleTypeEdit',
// dynamicParams: 'uuid',
handle: (record: any) => {
console.log(record, 'record');
2024-05-23 14:34:26 +08:00
formData2.value = record;
opMap.type = 'edit';
opMap.fuc = (formData2: any) => {
Object.assign(
mockData.value.filter((item) => item.id === record.id)[0],
formData2,
);
};
2024-05-22 16:31:55 +08:00
addformvisible.value = true;
},
},
{
label: '删除',
name: 'RoleTypeEdit',
2024-05-23 14:34:26 +08:00
confirm: true,
2024-05-24 13:13:24 +08:00
handle: (record: any, name: any, reload: any) => {
2024-05-23 14:34:26 +08:00
console.log(record, name, reload, 'record');
mockData2.value.splice(0, 1);
2024-05-22 16:31:55 +08:00
},
},
],
},
};
return {
2024-05-28 11:08:57 +08:00
formRef,
2024-05-22 16:31:55 +08:00
tableConfig,
tableConfig2,
data,
mainRef,
visible,
2024-05-23 14:34:26 +08:00
addformvisible,
2024-05-22 16:31:55 +08:00
formSchema,
2024-05-23 14:34:26 +08:00
formSchema2,
2024-05-22 16:31:55 +08:00
formData,
2024-05-23 14:34:26 +08:00
formData2,
2024-05-22 16:31:55 +08:00
treeData,
treeData2,
searchValue,
searchValue2,
2024-05-23 14:34:26 +08:00
handleSelect,
handleSelect2,
onClose,
onEdit,
2024-05-22 16:31:55 +08:00
onSearch,
onSearch2,
handleOk,
handleClose,
};
},
});
</script>
2024-05-23 15:50:47 +08:00
<style lang="less" scoped>
2024-05-22 16:31:55 +08:00
.main {
display: flex;
}
.left {
width: 400px;
border-right: 5px solid rgb(229, 235, 240);
2024-05-23 15:50:47 +08:00
min-width: fit-content;
2024-05-22 16:31:55 +08:00
}
2024-05-23 16:17:12 +08:00
.right {
flex: 1;
overflow: auto;
}
2024-05-22 16:31:55 +08:00
.top {
2024-05-23 14:34:26 +08:00
height: 46vh;
2024-05-22 16:31:55 +08:00
border-bottom: 5px solid rgb(229, 235, 240);
}
2024-05-23 16:18:18 +08:00
.ns-table-title {
2024-05-22 16:31:55 +08:00
text-align: left;
2024-05-24 09:44:08 +08:00
// height: 46px;
2024-05-22 16:31:55 +08:00
line-height: 46px;
font-size: 18px;
font-weight: bold;
padding-left: 16px;
}
.admin {
text-align: left;
height: 42px;
line-height: 42px;
font-size: 16px;
font-weight: bold;
user-select: text;
padding-left: 16px;
width: calc(100% + 32px);
}
.form {
margin-left: 10px;
}
</style>