Files
SaaS-lib/hx-op/src/view/organizationManage/enterpriseManage/config.ts

339 lines
7.9 KiB
TypeScript
Raw Normal View History

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-07 15:11:04 +08:00
import { createVNode, ref } from 'vue';
import { NsMessage } from '/nerv-lib/component';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { enterPrise } from '/@/api/origanizemanage';
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 13:37:10 +08:00
field: 'projectId',
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,
message: '请输入组织编号',
trigger: 'blur',
},
],
},
{
field: 'jituanname',
label: '企业名称',
component: 'NsInput',
componentProps: {
placeholder: '请输入企业名称',
maxLength: 20,
},
rules: [
{
required: true,
message: '请输入企业名称',
trigger: 'blur',
},
],
},
{
field: 'jituanname',
label: '集团名称',
component: 'NsInput',
componentProps: {
placeholder: '请输入集团名称',
maxLength: 20,
},
},
{
field: 'cityName',
label: '省市区',
2024-06-11 13:37:10 +08:00
component: 'NsCascader',
2024-06-07 15:11:04 +08:00
componentProps: {
placeholder: '请选择',
2024-06-11 13:37:10 +08:00
api: enterPrise.getArea,
fieldNames: { label: 'regionName', value: 'regionCode' },
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',
},
],
},
];
export const tableConfig = (visible) => {
return {
// title: '企业管理',
api: enterPrise.list,
headerActions: [
{
label: '新增',
name: 'RoleTypeAdd',
type: 'primary',
handle: () => {
visible.value = true;
},
},
],
rowSelection: null,
columns: [
{
title: '序号',
dataIndex: 'address',
width: 80,
customRender: (text: any) => {
return text.index + 1;
},
},
{
title: '组织ID',
2024-06-11 13:37:10 +08:00
dataIndex: 'projectId',
2024-06-07 15:11:04 +08:00
},
{
title: '集团名称',
2024-06-11 13:37:10 +08:00
dataIndex: 'cliqueName',
2024-06-07 15:11:04 +08:00
},
{
title: '组织名称',
dataIndex: 'orgName',
},
{
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;
return `${province}/${city}/${county}`;
},
},
{
title: '地址',
dataIndex: 'address',
},
{
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-07 15:11:04 +08:00
actions: [
{
label: '编辑',
name: 'RoleTypeEdit',
handle: (record: any) => {
console.log(record, 'record');
formData.value = record;
opMap.type = 'edit';
opMap.fuc = (formData: any) => {
Object.assign(mockData.value.filter((item) => item.id === record.id)[0], formData);
};
visible.value = true;
},
},
{
label: '组织边界',
handle: (record: any) => {
console.log(record, 'record');
borderVisible.value = true;
},
},
{
label: '服务',
handle: (record: any) => {
console.log(record, 'record');
serviceVisible.value = true;
},
},
{
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',
handle: (record: any) => {
console.log(record, 'record');
Modal.confirm({
title: '重置密码',
icon: createVNode(ExclamationCircleOutlined),
okText: '重置',
content: h('div', {}, [
h('p', `企业名称: ${record.jituanname}`),
h('p', '管理员账号: hxdtadmin'),
]),
onOk() {
Modal.confirm({
icon: createVNode(ExclamationCircleOutlined),
content: '是否确认重置该企业管理员密码',
onOk() {
Modal.success({
okText: '确认',
content: h('div', {}, [
h('p', '重置成功'),
h('p', '点击【确认】后自动复制密码并离开'),
]),
});
},
});
},
onCancel() {
console.log('Cancel');
},
class: 'test',
});
},
},
{
label: '删除',
name: 'RoleTypeEdit',
dynamicParams: 'orgId',
confirm: true,
isReload: true,
api: enterPrise.del,
},
],
},
formConfig: {
schemas: [
{
field: 'zuzhibianhao',
label: '组织ID',
component: 'NsInput',
componentProps: {
maxLength: 20,
},
},
{
field: 'jituanname',
label: '集团名称',
component: 'NsInput',
componentProps: {
maxLength: 20,
},
},
{
field: 'zuzhiname',
label: '组织名称',
component: 'NsInput',
componentProps: {
maxLength: 20,
},
},
{
field: 'status',
label: '状态',
component: 'NsSelect',
componentProps: {
options: [
{
label: '正常',
value: 1,
},
{
label: '冻结',
value: 2,
},
],
},
},
{
field: 'cityName',
label: '城市地区',
component: 'NsInputCity',
defaultValue: '',
fieldMap: ['provinceName', 'cityName', 'areaName', 'province', 'city', 'area'],
componentProps: {
api: '/api/parking_merchant/objs/BaseArea',
isSeparate: true,
},
},
],
params: {},
},
// pagination: { defaultPageSize: 10 },
rowKey: 'id',
};
};