2024-06-07 15:11:04 +08:00
|
|
|
import { mockData } from './mock';
|
|
|
|
|
import { cloneDeep } from 'lodash-es';
|
2024-06-11 13:37:10 +08:00
|
|
|
import { Modal, message } from 'ant-design-vue';
|
2024-06-12 16:41:30 +08:00
|
|
|
import { createVNode, nextTick, ref } from 'vue';
|
|
|
|
|
import { NsMessage, NsModal } from '/nerv-lib/component';
|
2024-06-07 15:11:04 +08:00
|
|
|
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
|
|
|
|
import { enterPrise } from '/@/api/origanizemanage';
|
2024-06-12 16:41:30 +08:00
|
|
|
import { http } from '/nerv-lib/util/http';
|
|
|
|
|
import { generateRandomString } from '/@/util/generateRandomString';
|
2024-06-07 15:11:04 +08:00
|
|
|
|
2024-06-11 13:37:10 +08:00
|
|
|
type status = 'NORMAL' | 'FREEZE';
|
2024-06-07 15:11:04 +08:00
|
|
|
export const formConfig = [
|
|
|
|
|
{
|
2024-06-11 16:13:51 +08:00
|
|
|
field: 'orgId',
|
2024-06-12 16:41:30 +08:00
|
|
|
label: '组织ID',
|
2024-06-11 16:13:51 +08:00
|
|
|
component: 'NsInput',
|
|
|
|
|
show: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'orgCode',
|
2024-06-07 15:11:04 +08:00
|
|
|
label: '组织ID',
|
|
|
|
|
component: 'NsInput',
|
|
|
|
|
componentProps: {
|
2024-06-11 13:37:10 +08:00
|
|
|
disabled: true,
|
2024-06-07 15:11:04 +08:00
|
|
|
},
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-06-11 16:13:51 +08:00
|
|
|
field: 'orgName',
|
2024-06-12 16:41:30 +08:00
|
|
|
label: '组织名称',
|
2024-06-07 15:11:04 +08:00
|
|
|
component: 'NsInput',
|
|
|
|
|
componentProps: {
|
2024-06-11 16:13:51 +08:00
|
|
|
placeholder: '请输入',
|
2024-06-07 15:11:04 +08:00
|
|
|
maxLength: 20,
|
|
|
|
|
},
|
2024-06-11 16:13:51 +08:00
|
|
|
rules: [{ required: true }],
|
2024-06-07 15:11:04 +08:00
|
|
|
},
|
|
|
|
|
{
|
2024-06-11 16:13:51 +08:00
|
|
|
field: 'cliqueName',
|
2024-06-07 15:11:04 +08:00
|
|
|
label: '集团名称',
|
|
|
|
|
component: 'NsInput',
|
|
|
|
|
componentProps: {
|
|
|
|
|
placeholder: '请输入集团名称',
|
|
|
|
|
maxLength: 20,
|
|
|
|
|
},
|
2024-06-18 18:16:23 +08:00
|
|
|
rules: [{ required: true }],
|
2024-06-07 15:11:04 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'cityName',
|
|
|
|
|
label: '省市区',
|
2024-06-11 13:37:10 +08:00
|
|
|
component: 'NsCascader',
|
2024-06-11 16:13:51 +08:00
|
|
|
fieldMap: ['province', 'city', 'county'],
|
2024-06-07 15:11:04 +08:00
|
|
|
componentProps: {
|
|
|
|
|
placeholder: '请选择',
|
2024-06-11 13:37:10 +08:00
|
|
|
api: enterPrise.getArea,
|
2024-06-11 16:13:51 +08:00
|
|
|
fieldNames: { label: 'regionName', value: 'regionName' },
|
2024-06-11 13:37:10 +08:00
|
|
|
showSearch: true,
|
2024-06-07 15:11:04 +08:00
|
|
|
},
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
2024-06-11 13:37:10 +08:00
|
|
|
message: '请选择省市区',
|
2024-06-07 15:11:04 +08:00
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'address',
|
|
|
|
|
label: '地址',
|
|
|
|
|
component: 'NsInput',
|
|
|
|
|
componentProps: {
|
|
|
|
|
placeholder: '请输入地址',
|
|
|
|
|
maxLength: 50,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-06-11 13:37:10 +08:00
|
|
|
field: 'contacts',
|
2024-06-07 15:11:04 +08:00
|
|
|
label: '联系人',
|
|
|
|
|
component: 'NsInput',
|
|
|
|
|
componentProps: {
|
|
|
|
|
placeholder: '请输入联系人',
|
|
|
|
|
maxLength: 10,
|
|
|
|
|
},
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: '请输入联系人',
|
|
|
|
|
trigger: 'blur',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-06-11 13:37:10 +08:00
|
|
|
field: 'phoneNumber',
|
2024-06-07 15:11:04 +08:00
|
|
|
label: '联系电话',
|
|
|
|
|
component: 'NsInput',
|
|
|
|
|
componentProps: {
|
|
|
|
|
placeholder: '请输入联系电话',
|
|
|
|
|
maxLength: 11,
|
|
|
|
|
},
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: '请输入联系电话',
|
|
|
|
|
trigger: 'blur',
|
|
|
|
|
},
|
2024-06-11 16:13:51 +08:00
|
|
|
{
|
|
|
|
|
pattern: /^1[3-9]\d{9}$/,
|
|
|
|
|
message: '请输入正确的联系电话',
|
|
|
|
|
trigger: 'blur',
|
|
|
|
|
},
|
2024-06-07 15:11:04 +08:00
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
2024-06-12 16:41:30 +08:00
|
|
|
const handle = async (record: any) => {
|
|
|
|
|
const { orgName, orgId } = record;
|
|
|
|
|
const res = await http.post(enterPrise.queryRootAc, {
|
|
|
|
|
orgId,
|
|
|
|
|
});
|
|
|
|
|
const { accountNo, userId } = res.data[0];
|
|
|
|
|
|
|
|
|
|
NsModal.confirm({
|
|
|
|
|
title: '重置密码',
|
|
|
|
|
icon: createVNode(ExclamationCircleOutlined),
|
|
|
|
|
okText: '重置',
|
|
|
|
|
content: createVNode('div', {}, [
|
|
|
|
|
createVNode('p', {}, `组织名称: ${orgName}`),
|
|
|
|
|
createVNode('p', {}, `管理员账号: ${accountNo}`),
|
|
|
|
|
]),
|
|
|
|
|
onOk() {
|
|
|
|
|
NsModal.confirm({
|
|
|
|
|
title: '重置密码',
|
|
|
|
|
icon: createVNode(ExclamationCircleOutlined),
|
|
|
|
|
content: '是否确认重置该组织管理员密码',
|
|
|
|
|
onOk() {
|
|
|
|
|
const password = generateRandomString(6);
|
|
|
|
|
http.post(enterPrise.resetPwd, { userId, password }).then(() => {
|
|
|
|
|
NsModal.success({
|
|
|
|
|
okText: '确认',
|
|
|
|
|
content: createVNode('div', {}, [
|
|
|
|
|
createVNode('p', {}, '重置成功'),
|
|
|
|
|
createVNode('p', {}, '点击【确认】后自动复制密码并离开'),
|
|
|
|
|
]),
|
|
|
|
|
onOk: () => {
|
|
|
|
|
try {
|
|
|
|
|
navigator.clipboard.writeText(password);
|
|
|
|
|
NsMessage.success('复制成功');
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error('复制失败', err);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onCancel() {
|
|
|
|
|
console.log('Cancel');
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2024-06-11 16:13:51 +08:00
|
|
|
export const tableConfig = ({
|
|
|
|
|
visible,
|
|
|
|
|
formData,
|
|
|
|
|
opType,
|
|
|
|
|
getOrgRandomCode,
|
|
|
|
|
borderVisible,
|
|
|
|
|
serviceVisible,
|
2024-06-12 16:41:30 +08:00
|
|
|
server: { getTree, currentServerRecord, getPermissionData },
|
|
|
|
|
boundary: { getBoundaryTree, currentBoundaryRecord },
|
2024-06-11 16:13:51 +08:00
|
|
|
}: any) => {
|
2024-06-07 15:11:04 +08:00
|
|
|
return {
|
2024-06-12 16:41:30 +08:00
|
|
|
// title: '组织管理',
|
2024-06-07 15:11:04 +08:00
|
|
|
api: enterPrise.list,
|
|
|
|
|
headerActions: [
|
|
|
|
|
{
|
|
|
|
|
label: '新增',
|
|
|
|
|
name: 'RoleTypeAdd',
|
|
|
|
|
type: 'primary',
|
|
|
|
|
handle: () => {
|
2024-06-11 16:13:51 +08:00
|
|
|
formData.value = {};
|
|
|
|
|
opType.value = 'add';
|
|
|
|
|
getOrgRandomCode && getOrgRandomCode();
|
2024-06-07 15:11:04 +08:00
|
|
|
visible.value = true;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
rowSelection: null,
|
|
|
|
|
columns: [
|
|
|
|
|
{
|
|
|
|
|
title: '序号',
|
|
|
|
|
dataIndex: 'address',
|
|
|
|
|
width: 80,
|
|
|
|
|
customRender: (text: any) => {
|
|
|
|
|
return text.index + 1;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '组织ID',
|
2024-06-11 16:13:51 +08:00
|
|
|
dataIndex: 'orgCode',
|
2024-06-07 15:11:04 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '集团名称',
|
2024-06-11 13:37:10 +08:00
|
|
|
dataIndex: 'cliqueName',
|
2024-06-11 16:13:51 +08:00
|
|
|
textNumber: 8,
|
|
|
|
|
textEllipsis: true,
|
2024-06-07 15:11:04 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '组织名称',
|
|
|
|
|
dataIndex: 'orgName',
|
2024-06-11 16:13:51 +08:00
|
|
|
textNumber: 8,
|
|
|
|
|
textEllipsis: true,
|
2024-06-07 15:11:04 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '状态',
|
|
|
|
|
dataIndex: 'status',
|
2024-06-11 13:37:10 +08:00
|
|
|
customRender: ({ value }) => {
|
|
|
|
|
return { NORMAL: '正常', FREEZE: '冻结' }[value as status];
|
|
|
|
|
},
|
2024-06-07 15:11:04 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '省市区',
|
|
|
|
|
dataIndex: 'area',
|
|
|
|
|
customRender: ({ record }) => {
|
|
|
|
|
const { province = '', city = '', county = '' } = record;
|
2024-06-11 16:13:51 +08:00
|
|
|
const result = [province, city];
|
|
|
|
|
county && result.push(county);
|
|
|
|
|
return result.join('/');
|
2024-06-07 15:11:04 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '地址',
|
|
|
|
|
dataIndex: 'address',
|
2024-06-11 16:13:51 +08:00
|
|
|
textNumber: 8,
|
|
|
|
|
textEllipsis: true,
|
2024-06-07 15:11:04 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '联系人',
|
2024-06-11 13:37:10 +08:00
|
|
|
dataIndex: 'contacts',
|
2024-06-07 15:11:04 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '联系电话',
|
2024-06-11 13:37:10 +08:00
|
|
|
dataIndex: 'phoneNumber',
|
2024-06-07 15:11:04 +08:00
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
columnActions: {
|
|
|
|
|
title: '操作',
|
2024-06-11 13:37:10 +08:00
|
|
|
autoMergeAction: false,
|
2024-06-12 18:15:49 +08:00
|
|
|
actionNumber: 1,
|
2024-06-07 15:11:04 +08:00
|
|
|
actions: [
|
|
|
|
|
{
|
|
|
|
|
label: '编辑',
|
|
|
|
|
name: 'RoleTypeEdit',
|
|
|
|
|
handle: (record: any) => {
|
2024-06-11 16:13:51 +08:00
|
|
|
const { province, city, county } = record;
|
2024-06-07 15:11:04 +08:00
|
|
|
formData.value = record;
|
2024-06-11 16:13:51 +08:00
|
|
|
formData.value.cityName = [province, city];
|
|
|
|
|
county && formData.value.cityName.push(county);
|
|
|
|
|
opType.value = 'edit';
|
2024-06-07 15:11:04 +08:00
|
|
|
visible.value = true;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '组织边界',
|
|
|
|
|
handle: (record: any) => {
|
|
|
|
|
console.log(record, 'record');
|
2024-06-12 16:41:30 +08:00
|
|
|
const { orgId, orgName } = (currentBoundaryRecord.value = record);
|
|
|
|
|
getBoundaryTree({ orgId, orgName });
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
borderVisible.value = true;
|
|
|
|
|
});
|
2024-06-07 15:11:04 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '服务',
|
|
|
|
|
handle: (record: any) => {
|
2024-06-12 16:41:30 +08:00
|
|
|
const { orgId } = (currentServerRecord.value = record);
|
|
|
|
|
opType.value = 'serverAdd';
|
|
|
|
|
// getTree({});
|
|
|
|
|
getPermissionData({ orgId });
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
serviceVisible.value = true;
|
|
|
|
|
});
|
2024-06-07 15:11:04 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '冻结',
|
2024-06-11 13:37:10 +08:00
|
|
|
name: 'enterPriseFreeze',
|
|
|
|
|
confirm: true,
|
|
|
|
|
isReload: true,
|
|
|
|
|
ifShow: ({ status }) => status === 'NORMAL',
|
|
|
|
|
api: enterPrise.freeze,
|
|
|
|
|
dynamicParams: 'orgId',
|
|
|
|
|
defaultParams: {
|
|
|
|
|
isFreeze: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '解冻',
|
|
|
|
|
name: 'enterPriseUnFreeze',
|
|
|
|
|
confirm: true,
|
|
|
|
|
isReload: true,
|
|
|
|
|
ifShow: ({ status }) => status === 'FREEZE',
|
|
|
|
|
dynamicParams: 'orgId',
|
|
|
|
|
api: enterPrise.freeze,
|
|
|
|
|
defaultParams: {
|
|
|
|
|
isFreeze: false,
|
2024-06-07 15:11:04 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '重置密码',
|
|
|
|
|
name: 'RoleTypeEdit',
|
2024-06-12 16:41:30 +08:00
|
|
|
handle,
|
2024-06-07 15:11:04 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '删除',
|
|
|
|
|
name: 'RoleTypeEdit',
|
|
|
|
|
dynamicParams: 'orgId',
|
|
|
|
|
confirm: true,
|
|
|
|
|
isReload: true,
|
|
|
|
|
api: enterPrise.del,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
formConfig: {
|
|
|
|
|
schemas: [
|
|
|
|
|
{
|
2024-06-11 16:13:51 +08:00
|
|
|
field: 'orgCode',
|
2024-06-07 15:11:04 +08:00
|
|
|
label: '组织ID',
|
|
|
|
|
component: 'NsInput',
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-06-11 16:13:51 +08:00
|
|
|
field: 'cliqueName',
|
2024-06-07 15:11:04 +08:00
|
|
|
label: '集团名称',
|
|
|
|
|
component: 'NsInput',
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-06-11 16:13:51 +08:00
|
|
|
field: 'orgName',
|
2024-06-07 15:11:04 +08:00
|
|
|
label: '组织名称',
|
|
|
|
|
component: 'NsInput',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'status',
|
|
|
|
|
label: '状态',
|
|
|
|
|
component: 'NsSelect',
|
|
|
|
|
componentProps: {
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
label: '正常',
|
2024-06-12 18:15:49 +08:00
|
|
|
value: 'NORMAL',
|
2024-06-07 15:11:04 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '冻结',
|
2024-06-12 18:15:49 +08:00
|
|
|
value: 'FREEZE',
|
2024-06-07 15:11:04 +08:00
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
field: 'cityName',
|
2024-06-12 18:15:49 +08:00
|
|
|
label: '省市区',
|
|
|
|
|
component: 'NsCascader',
|
|
|
|
|
fieldMap: ['province', 'city', 'county'],
|
2024-06-07 15:11:04 +08:00
|
|
|
componentProps: {
|
2024-06-12 18:15:49 +08:00
|
|
|
placeholder: '请选择',
|
|
|
|
|
api: enterPrise.getArea,
|
|
|
|
|
fieldNames: { label: 'regionName', value: 'regionName' },
|
|
|
|
|
showSearch: true,
|
2024-06-07 15:11:04 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
params: {},
|
|
|
|
|
},
|
|
|
|
|
// pagination: { defaultPageSize: 10 },
|
|
|
|
|
rowKey: 'id',
|
|
|
|
|
};
|
|
|
|
|
};
|