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

354 lines
8.3 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 16:13:51 +08:00
field: 'orgId',
label: '企业ID',
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-07 15:11:04 +08:00
label: '企业名称',
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,
},
},
{
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-11 16:13:51 +08:00
export const tableConfig = ({
visible,
formData,
opType,
getOrgRandomCode,
borderVisible,
serviceVisible,
server: { getTree },
}: any) => {
2024-06-07 15:11:04 +08:00
return {
// title: '企业管理',
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-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');
borderVisible.value = true;
},
},
{
label: '服务',
handle: (record: any) => {
console.log(record, 'record');
2024-06-11 16:13:51 +08:00
const { projectId } = record;
getTree({ projectId: 'beijingDQ' });
2024-06-07 15:11:04 +08:00
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: [
{
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: '正常',
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',
};
};