港口、LNG气源地调试

This commit is contained in:
2025-10-24 17:19:02 +08:00
parent bd17824058
commit 112a34944d
9 changed files with 2801 additions and 3112 deletions

View File

@ -3,137 +3,132 @@ import { defHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/#/axios'; import { ErrorMessageMode } from '/#/axios';
enum Api { enum Api {
Page = '/mdm/lngStation/page', Page = '/mdm/lNGStation/page',
List = '/mdm/lngStation/list', List = '/mdm/lNGStation/list',
Info = '/mdm/lngStation/info', Info = '/mdm/lNGStation/info',
LngBStationLng = '/mdm/lngStation', LngBStationLng = '/mdm/lNGStation',
Enable = '/mdm/lNGStation/enable',
Disable = '/mdm/lNGStation/disable',
DataLog = '/mdm/lNGStation/datalog'
Enable = '/mdm/lngStation/enable',
Disable= '/mdm/lngStation/disable',
DataLog = '/mdm/lngStation/datalog',
} }
/** /**
* @description: 查询LngBStationLng分页列表 * @description: 查询LngBStationLng分页列表
*/ */
export async function getLngBStationLngPage(params: LngBStationLngPageParams, mode: ErrorMessageMode = 'modal') { export async function getLngBStationLngPage(params: LngBStationLngPageParams, mode: ErrorMessageMode = 'modal') {
return defHttp.get<LngBStationLngPageResult>( return defHttp.get<LngBStationLngPageResult>(
{ {
url: Api.Page, url: Api.Page,
params, params
}, },
{ {
errorMessageMode: mode, errorMessageMode: mode
}, }
); );
} }
/** /**
* @description: 获取LngBStationLng信息 * @description: 获取LngBStationLng信息
*/ */
export async function getLngBStationLng(id: String, mode: ErrorMessageMode = 'modal') { export async function getLngBStationLng(id: String, mode: ErrorMessageMode = 'modal') {
return defHttp.get<LngBStationLngPageModel>( return defHttp.get<LngBStationLngPageModel>(
{ {
url: Api.Info, url: Api.Info,
params: { id }, params: { id }
}, },
{ {
errorMessageMode: mode, errorMessageMode: mode
}, }
); );
} }
/** /**
* @description: 新增LngBStationLng * @description: 新增LngBStationLng
*/ */
export async function addLngBStationLng(lngBStationLng: Recordable, mode: ErrorMessageMode = 'modal') { export async function addLngBStationLng(lngBStationLng: Recordable, mode: ErrorMessageMode = 'modal') {
return defHttp.post<boolean>( return defHttp.post<boolean>(
{ {
url: Api.LngBStationLng, url: Api.LngBStationLng,
params: lngBStationLng, params: lngBStationLng
}, },
{ {
errorMessageMode: mode, errorMessageMode: mode
}, }
); );
} }
/** /**
* @description: 更新LngBStationLng * @description: 更新LngBStationLng
*/ */
export async function updateLngBStationLng(lngBStationLng: Recordable, mode: ErrorMessageMode = 'modal') { export async function updateLngBStationLng(lngBStationLng: Recordable, mode: ErrorMessageMode = 'modal') {
return defHttp.put<boolean>( return defHttp.put<boolean>(
{ {
url: Api.LngBStationLng, url: Api.LngBStationLng,
params: lngBStationLng, params: lngBStationLng
}, },
{ {
errorMessageMode: mode, errorMessageMode: mode
}, }
); );
} }
/** /**
* @description: 删除LngBStationLng批量删除 * @description: 删除LngBStationLng批量删除
*/ */
export async function deleteLngBStationLng(ids: string[], mode: ErrorMessageMode = 'modal') { export async function deleteLngBStationLng(ids: string[], mode: ErrorMessageMode = 'modal') {
return defHttp.delete<boolean>( return defHttp.delete<boolean>(
{ {
url: Api.LngBStationLng, url: Api.LngBStationLng,
data: ids, data: ids
}, },
{ {
errorMessageMode: mode, errorMessageMode: mode
}, }
); );
} }
/** /**
* @description: 启用数据LngBStationLng * @description: 启用数据LngBStationLng
*/ */
export async function enableLngBStationLng(ids: string[], mode: ErrorMessageMode = 'modal') { export async function enableLngBStationLng(ids: string[], mode: ErrorMessageMode = 'modal') {
return defHttp.post<boolean>( return defHttp.post<boolean>(
{ {
url: Api.Enable, url: Api.Enable,
data: ids, data: ids
}, },
{ {
errorMessageMode: mode, errorMessageMode: mode
}, }
); );
} }
/** /**
* @description: 作废数据LngBStationLng * @description: 作废数据LngBStationLng
*/ */
export async function disableLngBStationLng(ids: string[], mode: ErrorMessageMode = 'modal') { export async function disableLngBStationLng(ids: string[], mode: ErrorMessageMode = 'modal') {
return defHttp.post<boolean>( return defHttp.post<boolean>(
{ {
url: Api.Disable, url: Api.Disable,
data: ids, data: ids
}, },
{ {
errorMessageMode: mode, errorMessageMode: mode
}, }
); );
} }
/**
* @description: 获取数据日志LngBStationLng
/** */
* @description: 获取数据日志LngBStationLng export async function getDataLogLngBStationLng(id: string, mode: ErrorMessageMode = 'modal') {
*/
export async function getDataLogLngBStationLng(id: string, mode: ErrorMessageMode = 'modal') {
return defHttp.post<boolean>( return defHttp.post<boolean>(
{ {
url: Api.Datalog, url: Api.Datalog,
data: id, data: id
}, },
{ {
errorMessageMode: mode, errorMessageMode: mode
}, }
); );
} }

View File

@ -2,457 +2,457 @@ import { FormProps, FormSchema } from '/@/components/Form';
import { BasicColumn } from '/@/components/Table'; import { BasicColumn } from '/@/components/Table';
export const formConfig = { export const formConfig = {
useCustomConfig: false, useCustomConfig: false
}; };
export const searchFormSchema: FormSchema[] = [ export const searchFormSchema: FormSchema[] = [
{ {
field: 'fullName', field: 'fullName',
label: '名称', label: '名称',
component: 'Input', component: 'Input'
}, },
{ {
field: 'valid', field: 'valid',
label: '有效标志', label: '有效标志',
component: 'XjrSelect', component: 'XjrSelect',
componentProps: { componentProps: {
datasourceType: 'dic', datasourceType: 'dic',
params: { itemId: '1978057078528327681' }, params: { itemId: '1978057078528327681' },
labelField: 'name', labelField: 'name',
valueField: 'value', valueField: 'value',
getPopupContainer: () => document.body, getPopupContainer: () => document.body
}
}, },
}, {
{ field: 'code',
field: 'code', label: '编码',
label: '编码', component: 'Input'
component: 'Input', },
}, {
{ field: 'unitCode',
field: 'unitCode', label: '数量单位',
label: '数量单位', component: 'XjrSelect',
component: 'XjrSelect', componentProps: {
componentProps: { datasourceType: 'dic',
datasourceType: 'dic', params: { itemId: '1980562721538633730' },
params: { itemId: '1980562721538633730' }, labelField: 'name',
labelField: 'name', valueField: 'value',
valueField: 'value',
getPopupContainer: () => document.body, getPopupContainer: () => document.body
}
}, },
}, {
{ field: 'coefficient',
field: 'coefficient', label: '车/数量单位',
label: '车/数量单位', component: 'Input'
component: 'Input',
},
{
field: 'sort',
label: '显示顺序',
component: 'InputNumber',
componentProps: {
style: { width: '100%' },
}, },
}, {
{ field: 'sort',
field: 'note', label: '显示顺序',
label: '备注', component: 'InputNumber',
component: 'Input', componentProps: {
}, style: { width: '100%' }
}
},
{
field: 'note',
label: '备注',
component: 'Input'
}
]; ];
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [
{ {
dataIndex: 'code', dataIndex: 'code',
title: '编码', title: '编码',
componentType: 'input', componentType: 'input',
align: 'left', align: 'left',
sorter: true, sorter: true
}, },
{ {
dataIndex: 'fullName', dataIndex: 'fullName',
title: '名称', title: '名称',
componentType: 'input', componentType: 'input',
align: 'left', align: 'left',
sorter: true, sorter: true
}, },
{ {
dataIndex: 'unitCode', dataIndex: 'unitCode',
title: '数量单位', title: '数量单位',
componentType: 'select', componentType: 'select',
align: 'left', align: 'left',
sorter: true, sorter: true
}, },
{ {
dataIndex: 'coefficient', dataIndex: 'coefficient',
title: '车/数量单位', title: '车/数量单位',
componentType: 'input', componentType: 'input',
align: 'left', align: 'left',
sorter: true, sorter: true
}, },
{ {
dataIndex: 'sort', dataIndex: 'sort',
title: '显示顺序', title: '显示顺序',
componentType: 'number', componentType: 'number',
align: 'left', align: 'left',
sorter: true, sorter: true
}, },
{ {
dataIndex: 'valid', dataIndex: 'valid',
title: '有效标志', title: '有效标志',
componentType: 'select', componentType: 'select',
align: 'left', align: 'left',
sorter: true, sorter: true
}, },
{ {
dataIndex: 'note', dataIndex: 'note',
title: '备注', title: '备注',
componentType: 'textarea', componentType: 'textarea',
align: 'left', align: 'left',
sorter: true, sorter: true
}, }
]; ];
//表单事件 //表单事件
export const formEventConfigs = { export const formEventConfigs = {
0: [ 0: [
{ {
type: 'circle', type: 'circle',
color: '#2774ff', color: '#2774ff',
text: '开始节点', text: '开始节点',
icon: '#icon-kaishi', icon: '#icon-kaishi',
bgcColor: '#D8E5FF', bgcColor: '#D8E5FF',
isUserDefined: false, isUserDefined: false
}, },
{ {
color: '#F6AB01', color: '#F6AB01',
icon: '#icon-chushihua', icon: '#icon-chushihua',
text: '初始化表单', text: '初始化表单',
bgcColor: '#f9f5ea', bgcColor: '#f9f5ea',
isUserDefined: false, isUserDefined: false,
nodeInfo: { processEvent: [] }, nodeInfo: { processEvent: [] }
}, }
], ],
1: [ 1: [
{ {
color: '#B36EDB', color: '#B36EDB',
icon: '#icon-shujufenxi', icon: '#icon-shujufenxi',
text: '获取表单数据', text: '获取表单数据',
detail: '(新增无此操作)', detail: '(新增无此操作)',
bgcColor: '#F8F2FC', bgcColor: '#F8F2FC',
isUserDefined: false, isUserDefined: false,
nodeInfo: { processEvent: [] }, nodeInfo: { processEvent: [] }
}, }
], ],
2: [ 2: [
{ {
color: '#F8625C', color: '#F8625C',
icon: '#icon-jiazai', icon: '#icon-jiazai',
text: '加载表单', text: '加载表单',
bgcColor: '#FFF1F1', bgcColor: '#FFF1F1',
isUserDefined: false, isUserDefined: false,
nodeInfo: { processEvent: [] }, nodeInfo: { processEvent: [] }
}, }
], ],
3: [ 3: [
{ {
color: '#6C6AE0', color: '#6C6AE0',
icon: '#icon-jsontijiao', icon: '#icon-jsontijiao',
text: '提交表单', text: '提交表单',
bgcColor: '#F5F4FF', bgcColor: '#F5F4FF',
isUserDefined: false, isUserDefined: false,
nodeInfo: { processEvent: [] }, nodeInfo: { processEvent: [] }
}, }
], ],
4: [ 4: [
{ {
type: 'circle', type: 'circle',
color: '#F8625C', color: '#F8625C',
text: '结束节点', text: '结束节点',
icon: '#icon-jieshuzhiliao', icon: '#icon-jieshuzhiliao',
bgcColor: '#FFD6D6', bgcColor: '#FFD6D6',
isLast: true, isLast: true,
isUserDefined: false, isUserDefined: false
}, }
], ]
}; };
export const formProps: FormProps = { export const formProps: FormProps = {
labelCol: { span: 3, offset: 0 }, labelCol: { span: 3, offset: 0 },
labelAlign: 'right', labelAlign: 'right',
layout: 'horizontal', layout: 'horizontal',
size: 'default', size: 'default',
schemas: [ schemas: [
{ {
key: '1ac3ffe5d4f54caa890a13d4c9624c4f', key: '1ac3ffe5d4f54caa890a13d4c9624c4f',
field: 'code', field: 'code',
label: '编码', label: '编码',
type: 'input', type: 'input',
component: 'Input', component: 'Input',
colProps: { span: 24 }, colProps: { span: 24 },
defaultValue: '', defaultValue: '',
componentProps: { componentProps: {
width: '100%', width: '100%',
span: '', span: '',
defaultValue: '', defaultValue: '',
labelWidthMode: 'fix', labelWidthMode: 'fix',
labelFixWidth: 120, labelFixWidth: 120,
responsive: false, responsive: false,
respNewRow: false, respNewRow: false,
placeholder: '请输入编码', placeholder: '请输入编码',
maxlength: null, maxlength: null,
prefix: '', prefix: '',
suffix: '', suffix: '',
addonBefore: '', addonBefore: '',
addonAfter: '', addonAfter: '',
disabled: false, disabled: false,
allowClear: true, allowClear: true,
showLabel: true, showLabel: true,
required: true, required: true,
rules: [], rules: [],
events: {}, events: {},
isSave: false, isSave: false,
isShow: true, isShow: true,
scan: false, scan: false,
style: { width: '100%' }, style: { width: '100%' }
}, }
},
{
key: 'bf017ce23394455689757955a23d7b72',
field: 'fullName',
label: '名称',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
labelWidthMode: 'fix',
labelFixWidth: 120,
responsive: false,
respNewRow: false,
placeholder: '请输入名称',
maxlength: null,
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: true,
showLabel: true,
required: true,
rules: [],
events: {},
isSave: false,
isShow: true,
scan: false,
style: { width: '100%' },
},
},
{
key: '533dcfe1e679462e830091588c1cb9fd',
field: 'unitCode',
label: '数量单位',
type: 'select',
component: 'XjrSelect',
colProps: { span: 24 },
componentProps: {
width: '100%',
span: '',
labelWidthMode: 'fix',
labelFixWidth: 120,
responsive: false,
respNewRow: false,
placeholder: '请选择数量单位',
sepTextField: '',
showLabel: true,
showSearch: false,
clearable: false,
disabled: false,
mode: 'multiple',
staticOptions: [
{ key: 1, label: 'Option 1', value: 'Option 1' },
{ key: 2, label: 'Option 2', value: 'Option 2' },
{ key: 3, label: 'Option 3', value: 'Option 3' },
],
defaultSelect: null,
datasourceType: 'dic',
params: { itemId: '1980562721538633730' },
labelField: 'name',
valueField: 'value',
apiConfig: {
path: 'CodeGeneration/selection',
method: 'GET',
apiId: '93d735dcb7364a0f8102188ec4d77ac7',
}, },
dicOptions: [], {
required: true, key: 'bf017ce23394455689757955a23d7b72',
rules: [], field: 'fullName',
events: {}, label: '名称',
isShow: true, type: 'input',
itemId: '1980562721538633730', component: 'Input',
style: { width: '100%' }, colProps: { span: 24 },
}, defaultValue: '',
}, componentProps: {
{ width: '100%',
key: '57d85cbf34fa475298997f5a7427bf8d', span: '',
field: 'coefficient', defaultValue: '',
label: '车/数量单位', labelWidthMode: 'fix',
type: 'input', labelFixWidth: 120,
component: 'Input', responsive: false,
colProps: { span: 24 }, respNewRow: false,
defaultValue: '', placeholder: '请输入名称',
componentProps: { maxlength: null,
width: '100%', prefix: '',
span: '', suffix: '',
defaultValue: '', addonBefore: '',
labelWidthMode: 'fix', addonAfter: '',
labelFixWidth: 120, disabled: false,
responsive: false, allowClear: true,
respNewRow: false, showLabel: true,
placeholder: '请输入车/数量单位', required: true,
maxlength: null, rules: [],
prefix: '', events: {},
suffix: '', isSave: false,
addonBefore: '', isShow: true,
addonAfter: '', scan: false,
disabled: false, style: { width: '100%' }
allowClear: false, }
showLabel: true,
required: false,
rules: [],
events: {},
isSave: false,
isShow: true,
scan: false,
style: { width: '100%' },
},
},
{
key: '870650303cf54491b476233e6d5d9b6b',
field: 'sort',
label: '显示顺序',
type: 'number',
component: 'InputNumber',
colProps: { span: 24 },
defaultValue: null,
componentProps: {
labelWidthMode: 'fix',
labelFixWidth: 120,
responsive: false,
width: '100%',
span: '',
defaultValue: null,
min: 0,
max: null,
step: 1,
maxlength: null,
disabled: false,
showLabel: true,
controls: true,
required: false,
subTotal: false,
isShow: true,
rules: [],
events: {},
style: { width: '100%' },
},
},
{
key: '17bbaf11ddb0454d854f2082abd7b191',
field: 'valid',
label: '有效标志',
type: 'select',
component: 'XjrSelect',
colProps: { span: 24 },
componentProps: {
width: '100%',
span: '',
labelWidthMode: 'fix',
labelFixWidth: 120,
responsive: false,
respNewRow: false,
placeholder: '请选择有效标志',
sepTextField: '',
showLabel: true,
showSearch: false,
clearable: false,
disabled: false,
mode: 'multiple',
staticOptions: [
{ key: 1, label: 'Option 1', value: 'Option 1' },
{ key: 2, label: 'Option 2', value: 'Option 2' },
{ key: 3, label: 'Option 3', value: 'Option 3' },
],
defaultSelect: null,
datasourceType: 'dic',
params: { itemId: '1978057078528327681' },
labelField: 'name',
valueField: 'value',
apiConfig: {
path: 'CodeGeneration/selection',
method: 'GET',
apiId: '93d735dcb7364a0f8102188ec4d77ac7',
}, },
dicOptions: [], {
required: false, key: '533dcfe1e679462e830091588c1cb9fd',
rules: [], field: 'unitCode',
events: {}, label: '数量单位',
isShow: true, type: 'select',
itemId: '1978057078528327681', component: 'XjrSelect',
style: { width: '100%' }, colProps: { span: 24 },
}, componentProps: {
}, width: '100%',
{ span: '',
key: '7e8014fe939e4ca88ebe986dd91c555c', labelWidthMode: 'fix',
field: 'note', labelFixWidth: 120,
label: '备注', responsive: false,
type: 'textarea', respNewRow: false,
component: 'InputTextArea', placeholder: '请选择数量单位',
colProps: { span: 24 }, sepTextField: '',
defaultValue: '', showLabel: true,
componentProps: { showSearch: false,
width: '100%', clearable: false,
span: '', disabled: false,
defaultValue: '', mode: 'multiple',
labelWidthMode: 'fix', staticOptions: [
labelFixWidth: 120, { key: 1, label: 'Option 1', value: 'Option 1' },
responsive: false, { key: 2, label: 'Option 2', value: 'Option 2' },
respNewRow: true, { key: 3, label: 'Option 3', value: 'Option 3' }
placeholder: '请输入备注', ],
maxlength: null, defaultSelect: null,
rows: 4, datasourceType: 'dic',
autoSize: false, params: { itemId: '1980562721538633730' },
showCount: false, labelField: 'name',
disabled: false, valueField: 'value',
showLabel: true, apiConfig: {
allowClear: false, path: 'CodeGeneration/selection',
required: false, method: 'GET',
isShow: true, apiId: '93d735dcb7364a0f8102188ec4d77ac7'
rules: [], },
events: {}, dicOptions: [],
style: { width: '100%' }, required: true,
}, rules: [],
}, events: {},
], isShow: true,
showActionButtonGroup: false, itemId: '1980562721538633730',
buttonLocation: 'center', style: { width: '100%' }
actionColOptions: { span: 24 }, }
showResetButton: false, },
showSubmitButton: false, {
hiddenComponent: [], key: '57d85cbf34fa475298997f5a7427bf8d',
field: 'coefficient',
label: '车/数量单位',
type: 'input',
component: 'Input',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
labelWidthMode: 'fix',
labelFixWidth: 120,
responsive: false,
respNewRow: false,
placeholder: '请输入车/数量单位',
maxlength: null,
prefix: '',
suffix: '',
addonBefore: '',
addonAfter: '',
disabled: false,
allowClear: false,
showLabel: true,
required: false,
rules: [],
events: {},
isSave: false,
isShow: true,
scan: false,
style: { width: '100%' }
}
},
{
key: '870650303cf54491b476233e6d5d9b6b',
field: 'sort',
label: '显示顺序',
type: 'number',
component: 'InputNumber',
colProps: { span: 24 },
defaultValue: null,
componentProps: {
labelWidthMode: 'fix',
labelFixWidth: 120,
responsive: false,
width: '100%',
span: '',
defaultValue: null,
min: 0,
max: null,
step: 1,
maxlength: null,
disabled: false,
showLabel: true,
controls: true,
required: false,
subTotal: false,
isShow: true,
rules: [],
events: {},
style: { width: '100%' }
}
},
{
key: '17bbaf11ddb0454d854f2082abd7b191',
field: 'valid',
label: '有效标志',
type: 'select',
component: 'XjrSelect',
colProps: { span: 24 },
componentProps: {
width: '100%',
span: '',
labelWidthMode: 'fix',
labelFixWidth: 120,
responsive: false,
respNewRow: false,
placeholder: '请选择有效标志',
sepTextField: '',
showLabel: true,
showSearch: false,
clearable: false,
disabled: false,
mode: 'multiple',
staticOptions: [
{ key: 1, label: 'Option 1', value: 'Option 1' },
{ key: 2, label: 'Option 2', value: 'Option 2' },
{ key: 3, label: 'Option 3', value: 'Option 3' }
],
defaultSelect: null,
datasourceType: 'dic',
params: { itemId: '1978057078528327681' },
labelField: 'name',
valueField: 'value',
apiConfig: {
path: 'CodeGeneration/selection',
method: 'GET',
apiId: '93d735dcb7364a0f8102188ec4d77ac7'
},
dicOptions: [],
required: false,
rules: [],
events: {},
isShow: true,
itemId: '1978057078528327681',
style: { width: '100%' }
}
},
{
key: '7e8014fe939e4ca88ebe986dd91c555c',
field: 'note',
label: '备注',
type: 'textarea',
component: 'InputTextArea',
colProps: { span: 24 },
defaultValue: '',
componentProps: {
width: '100%',
span: '',
defaultValue: '',
labelWidthMode: 'fix',
labelFixWidth: 120,
responsive: false,
respNewRow: true,
placeholder: '请输入备注',
maxlength: null,
rows: 4,
autoSize: false,
showCount: false,
disabled: false,
showLabel: true,
allowClear: false,
required: false,
isShow: true,
rules: [],
events: {},
style: { width: '100%' }
}
}
],
showActionButtonGroup: false,
buttonLocation: 'center',
actionColOptions: { span: 24 },
showResetButton: false,
showSubmitButton: false,
hiddenComponent: []
}; };

View File

@ -1,110 +1,108 @@
<template> <template>
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit" @cancel="handleClose" :paddingRight="15" :bodyStyle="{ minHeight: '400px !important' }"> <BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit" @cancel="handleClose" :paddingRight="15" :bodyStyle="{ minHeight: '400px !important' }">
<ModalForm ref="formRef" :fromPage="FromPageType.MENU" /> <ModalForm ref="formRef" :fromPage="FromPageType.MENU" />
</BasicModal> </BasicModal>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, computed, reactive } from 'vue'; import { ref, computed, reactive } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal'; import { BasicModal, useModalInner } from '/@/components/Modal';
import { useMessage } from '/@/hooks/web/useMessage'; import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import { formProps } from './config'; import { formProps } from './config';
import ModalForm from './Form.vue'; import ModalForm from './Form.vue';
import { FromPageType } from '/@/enums/workflowEnum'; import { FromPageType } from '/@/enums/workflowEnum';
const emit = defineEmits(['success', 'register']); const emit = defineEmits(['success', 'register']);
const { notification } = useMessage(); const { notification } = useMessage();
const formRef = ref(); const formRef = ref();
const state = reactive({ const state = reactive({
formModel: {}, formModel: {},
isUpdate: true, isUpdate: true,
isView: false, isView: false,
isCopy: false, isCopy: false,
rowId: '', rowId: ''
});
const { t } = useI18n();
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
state.isUpdate = !!data?.isUpdate;
state.isView = !!data?.isView;
state.isCopy = !!data?.isCopy;
setModalProps({
destroyOnClose: true,
maskClosable: false,
showCancelBtn: !state.isView,
showOkBtn: !state.isView,
canFullscreen: true,
width: 900,
}); });
if (state.isUpdate || state.isView || state.isCopy) {
state.rowId = data.id;
if (state.isView) {
await formRef.value.setDisabledForm();
}
await formRef.value.setFormDataFromId(state.rowId);
} else {
formRef.value.resetFields();
}
});
const getTitle = computed(() => (state.isView ? '查看' : !state.isUpdate ? '新增' : '编辑')); const { t } = useI18n();
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
state.isUpdate = !!data?.isUpdate;
state.isView = !!data?.isView;
state.isCopy = !!data?.isCopy;
async function saveModal() { setModalProps({
let saveSuccess = false; destroyOnClose: true,
try { maskClosable: false,
const values = await formRef.value?.validate(); showCancelBtn: !state.isView,
//添加隐藏组件 showOkBtn: !state.isView,
if (formProps.hiddenComponent?.length) { canFullscreen: true,
formProps.hiddenComponent.forEach((component) => { width: 900
values[component.bindField] = component.value;
}); });
} if (state.isUpdate || state.isView || state.isCopy) {
if (values !== false) { state.rowId = data.id;
try { if (state.isView) {
if (!state.isUpdate || state.isCopy) { await formRef.value.setDisabledForm();
saveSuccess = await formRef.value.add(values); }
} else { await formRef.value.setFormDataFromId(state.rowId);
saveSuccess = await formRef.value.update({ values, rowId: state.rowId });
}
return saveSuccess;
} catch (error) {}
}
} catch (error) {
return saveSuccess;
}
}
async function handleSubmit() {
try {
const saveSuccess = await saveModal();
setModalProps({ confirmLoading: true });
if (saveSuccess) {
if (!state.isUpdate || state.isCopy) {
//false 新增
notification.success({
message: 'Tip',
description: t('新增成功!'),
}); //提示消息
} else { } else {
notification.success({ formRef.value.resetFields();
message: 'Tip',
description: t('修改成功!'),
}); //提示消息
} }
closeModal(); });
formRef.value.resetFields();
emit('success');
}
} finally {
setModalProps({ confirmLoading: false });
}
}
function handleClose() { const getTitle = computed(() => (state.isView ? '查看' : !state.isUpdate ? '新增' : '编辑'));
formRef.value.resetFields();
} async function saveModal() {
let saveSuccess = false;
try {
const values = await formRef.value?.validate();
//添加隐藏组件
if (formProps.hiddenComponent?.length) {
formProps.hiddenComponent.forEach((component) => {
values[component.bindField] = component.value;
});
}
if (values !== false) {
try {
if (!state.isUpdate || state.isCopy) {
saveSuccess = await formRef.value.add(values);
} else {
saveSuccess = await formRef.value.update({ values, rowId: state.rowId });
}
return saveSuccess;
} catch (error) {}
}
} catch (error) {
return saveSuccess;
}
}
async function handleSubmit() {
try {
const saveSuccess = await saveModal();
setModalProps({ confirmLoading: true });
if (saveSuccess) {
if (!state.isUpdate || state.isCopy) {
//false 新增
notification.success({
message: 'Tip',
description: t('新增成功!')
}); //提示消息
} else {
notification.success({
message: 'Tip',
description: t('修改成功!')
}); //提示消息
}
closeModal();
formRef.value.resetFields();
emit('success');
}
} finally {
setModalProps({ confirmLoading: false });
}
}
function handleClose() {
formRef.value.resetFields();
}
</script> </script>

File diff suppressed because it is too large Load Diff

View File

@ -1,356 +1,353 @@
<template> <template>
<PageWrapper dense fixedHeight contentFullHeight contentClass="flex"> <PageWrapper dense fixedHeight contentFullHeight contentClass="flex">
<BasicTable @register="registerTable" ref="tableRef" @row-dbClick="dbClickRow"> <BasicTable @register="registerTable" ref="tableRef" @row-db-click="dbClickRow">
<template #toolbar>
<template #toolbar> <template v-for="button in tableButtonConfig" :key="button.code">
<template v-for="button in tableButtonConfig" :key="button.code"> <a-button v-if="button.isDefault" :type="button.type" @click="buttonClick(button.code)">
<a-button v-if="button.isDefault" :type="button.type" @click="buttonClick(button.code)"> <template #icon><Icon :icon="button.icon" /></template>
<template #icon><Icon :icon="button.icon" /></template> {{ button.name }}
{{ button.name }} </a-button>
</a-button> <a-button v-else :type="button.type">
<a-button v-else :type="button.type"> <template #icon><Icon :icon="button.icon" /></template>
<template #icon><Icon :icon="button.icon" /></template> {{ button.name }}
{{ button.name }} </a-button>
</a-button> </template>
</template> </template>
</template> <template #bodyCell="{ column, record }">
<template #bodyCell="{ column, record }"> <template v-if="column.dataIndex === 'action'">
<template v-if="column.dataIndex === 'action'"> <TableAction :actions="getActions(record)" />
<TableAction :actions="getActions(record)" /> </template>
</template> </template>
</template> </BasicTable>
</BasicTable> <LngStationModal @register="registerModal" @success="handleSuccess" />
<LngStationModal @register="registerModal" @success="handleSuccess" /> </PageWrapper>
</PageWrapper>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, computed, onMounted, onUnmounted, createVNode, import { ref, computed, onMounted, onUnmounted, createVNode } from 'vue';
} from 'vue'; import { Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
import { getLngBStationLngPage, deleteLngBStationLng } from '/@/api/mdm/LNGStation';
import { PageWrapper } from '/@/components/Page';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { usePermission } from '/@/hooks/web/usePermission';
import { useFormConfig } from '/@/hooks/web/useFormConfig';
import { useRouter } from 'vue-router';
import { setIndexFlowStatus } from '/@/utils/flow/index';
import { getLngBStationLng } from '/@/api/mdm/LNGStation';
import { useModal } from '/@/components/Modal';
import LngStationModal from './components/LngStationModal.vue';
import { formConfig, searchFormSchema, columns } from './components/config';
import Icon from '/@/components/Icon/index';
import useEventBus from '/@/hooks/event/useEventBus';
import { cloneDeep } from 'lodash-es';
import { Modal } from 'ant-design-vue'; const { bus, CREATE_FLOW, FLOW_PROCESSED, FORM_LIST_MODIFIED } = useEventBus();
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
import { getLngBStationLngPage, deleteLngBStationLng} from '/@/api/mdm/LNGStation';
import { PageWrapper } from '/@/components/Page';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { usePermission } from '/@/hooks/web/usePermission';
import { useFormConfig } from '/@/hooks/web/useFormConfig';
import { useRouter } from 'vue-router';
import { setIndexFlowStatus } from '/@/utils/flow/index'
import { getLngBStationLng } from '/@/api/mdm/LNGStation';
import { useModal } from '/@/components/Modal';
import LngStationModal from './components/LngStationModal.vue';
import {formConfig, searchFormSchema, columns } from './components/config';
import Icon from '/@/components/Icon/index';
import useEventBus from '/@/hooks/event/useEventBus';
import { cloneDeep } from 'lodash-es';
const { bus, CREATE_FLOW, FLOW_PROCESSED, FORM_LIST_MODIFIED } = useEventBus(); const { notification } = useMessage();
const { t } = useI18n();
defineEmits(['register']);
const { filterColumnAuth, filterButtonAuth } = usePermission();
const { mergeColumns, mergeSearchFormSchema, mergeButtons } = useFormConfig();
const { notification } = useMessage(); const filterColumns = cloneDeep(filterColumnAuth(columns));
const { t } = useI18n(); const customConfigColums = ref(filterColumns);
defineEmits(['register']); const customSearchFormSchema = ref(searchFormSchema);
const { filterColumnAuth, filterButtonAuth } = usePermission();
const { mergeColumns,mergeSearchFormSchema,mergeButtons } = useFormConfig();
const filterColumns = cloneDeep(filterColumnAuth(columns)); const tableRef = ref();
const customConfigColums =ref(filterColumns); //所有按钮
const customSearchFormSchema =ref(searchFormSchema); const buttons = ref([
{ isUse: true, name: '新增', code: 'add', icon: 'ant-design:plus-outlined', isDefault: true, type: 'primary' },
const tableRef = ref(); { isUse: true, name: '编辑', code: 'edit', icon: 'ant-design:form-outlined', isDefault: true },
//所有按钮 { isUse: true, name: '启用', code: 'enable', icon: 'ant-design:form-outlined', isDefault: true, type: 'primary' },
const buttons = ref([{"isUse":true,"name":"新增","code":"add","icon":"ant-design:plus-outlined","isDefault":true,"type":"primary"},{"isUse":true,"name":"编辑","code":"edit","icon":"ant-design:form-outlined","isDefault":true},{"isUse":true,"name":"启用","code":"enable","icon":"ant-design:form-outlined","isDefault":true,"type":"primary"},{"isUse":true,"name":"作废","code":"disable","icon":"ant-design:stop-outlined","isDefault":true,"type":"dashed"},{"isUse":true,"name":"刷新","code":"refresh","icon":"ant-design:reload-outlined","isDefault":true},{"isUse":true,"name":"查看","code":"view","icon":"ant-design:eye-outlined","isDefault":true},{"isUse":true,"name":"数据日志","code":"datalog","icon":"ant-design:profile-outlined","isDefault":true},{"isUse":true,"name":"删除","code":"delete","icon":"ant-design:delete-outlined","isDefault":true}]); { isUse: true, name: '作废', code: 'disable', icon: 'ant-design:stop-outlined', isDefault: true, type: 'dashed' },
//展示在列表内的按钮 { isUse: true, name: '刷新', code: 'refresh', icon: 'ant-design:reload-outlined', isDefault: true },
const actionButtons = ref<string[]>(['view', 'edit','datalog', 'copyData', 'delete', 'startwork','flowRecord']); { isUse: true, name: '查看', code: 'view', icon: 'ant-design:eye-outlined', isDefault: true },
const buttonConfigs = computed(()=>{ { isUse: true, name: '数据日志', code: 'datalog', icon: 'ant-design:profile-outlined', isDefault: true },
return filterButtonAuth(buttons.value); { isUse: true, name: '删除', code: 'delete', icon: 'ant-design:delete-outlined', isDefault: true }
}) ]);
//展示在列表内的按钮
const tableButtonConfig = computed(() => { const actionButtons = ref<string[]>(['view', 'edit', 'datalog', 'copyData', 'delete', 'startwork', 'flowRecord']);
return buttonConfigs.value?.filter((x) => !actionButtons.value.includes(x.code)); const buttonConfigs = computed(() => {
}); return filterButtonAuth(buttons.value);
const actionButtonConfig = computed(() => {
return buttonConfigs.value?.filter((x) => actionButtons.value.includes(x.code));
});
const btnEvent = {add : handleAdd,edit : handleEdit,enable : handleEnable,disable : handleDisable,refresh : handleRefresh,view : handleView,datalog : handleDatalog,delete : handleDelete,}
const { currentRoute } = useRouter();
const router = useRouter();
const formIdComputedRef = ref();
formIdComputedRef.value = currentRoute.value.meta.formId
const schemaIdComputedRef = ref();
schemaIdComputedRef.value = currentRoute.value.meta.schemaId
const [registerModal, { openModal }] = useModal();
const formName='LNG气源地';
const [registerTable, { reload, }] = useTable({
title: '' || (formName + '列表'),
api: getLngBStationLngPage,
rowKey: 'id',
columns: customConfigColums,
formConfig: {
rowProps: {
gutter: 16,
},
schemas: customSearchFormSchema,
fieldMapToTime: [],
showResetButton: false,
},
beforeFetch: (params) => {
return { ...params, FormId: formIdComputedRef.value, PK: 'id' };
},
afterFetch: (res) => {
tableRef.value.setToolBarWidth();
},
useSearchForm: true,
showTableSetting: true,
striped: false,
actionColumn: {
width: 160,
title: '操作',
dataIndex: 'action',
slots: { customRender: 'action' },
},
tableSetting: {
size: false,
setting: false,
},
});
function dbClickRow(record) {
if (!actionButtonConfig?.value.some(element => element.code == 'view')) {
return;
}
const { processId, taskIds, schemaId } = record.workflowData || {};
if (taskIds && taskIds.length) {
router.push({
path: '/flow/' + schemaId + '/' + (processId || '') + '/approveFlow',
query: {
taskId: taskIds[0],
formName: formName,
formId:currentRoute.value.meta.formId
}
});
} else if (schemaId && !taskIds && processId) {
router.push({
path: '/flow/' + schemaId + '/' + processId + '/approveFlow',
query: {
readonly: 1,
taskId: '',
formName: formName,
formId:currentRoute.value.meta.formId
}
});
} else {
router.push({
path: '/form/LNGStation/' + record.id + '/viewForm',
query: {
formPath: 'mdm/LNGStation',
formName: formName,
formId:currentRoute.value.meta.formId
}
});
}
}
function buttonClick(code) {
btnEvent[code]();
}
function handleAdd() {
if (schemaIdComputedRef.value) {
router.push({
path: '/flow/' + schemaIdComputedRef.value + '/0/createFlow'
});
} else {
router.push({
path: '/form/LNGStation/0/createForm',
query: {
formPath: 'mdm/LNGStation',
formName: formName,
formId:currentRoute.value.meta.formId
}
});
}
}
function handleEdit(record: Recordable) {
router.push({
path: '/form/LNGStation/' + record.id + '/updateForm',
query: {
formPath: 'mdm/LNGStation',
formName: formName,
formId:currentRoute.value.meta.formId
}
}); });
}
function handleDelete(record: Recordable) {
deleteList([record.id]);
}
function handleEnable() { const tableButtonConfig = computed(() => {
if (!selectedKeys.value.length) { return buttonConfigs.value?.filter((x) => !actionButtons.value.includes(x.code));
notification.warning({
message: 'Tip',
description: t('请选择需要启用的数据'),
});
return;
}
let ids = selectedKeys.value;
Modal.confirm({
title: '提示信息',
icon: createVNode(ExclamationCircleOutlined),
content: '是否确认启用?',
okText: '确认',
cancelText: '取消',
onOk() {
enableLngBStationLng(ids).then((_) => {
handleSuccess();
notification.success({
message: 'Tip',
description: t('启用成功!'),
});
});
},
onCancel() {},
});
}
function handleDisable() {
if (!selectedKeys.value.length) {
notification.warning({
message: 'Tip',
description: t('请选择需要禁用的数据'),
});
return;
}
let ids = selectedKeys.value;
Modal.confirm({
title: '提示信息',
icon: createVNode(ExclamationCircleOutlined),
content: '是否确认禁用?',
okText: '确认',
cancelText: '取消',
onOk() {
disableLngBStationLng(ids).then((_) => {
handleSuccess();
notification.success({
message: 'Tip',
description: t('禁用成功!'),
});
});
},
onCancel() {},
});
}
function deleteList(ids) {
Modal.confirm({
title: '提示信息',
icon: createVNode(ExclamationCircleOutlined),
content: '是否确认删除?',
okText: '确认',
cancelText: '取消',
onOk() {
deleteLngBStationLng(ids).then((_) => {
handleSuccess();
notification.success({
message: 'Tip',
description: t('删除成功!'),
});
});
},
onCancel() {},
}); });
}
function handleRefresh() {
reload();
}
function handleSuccess() {
reload(); const actionButtonConfig = computed(() => {
} return buttonConfigs.value?.filter((x) => actionButtons.value.includes(x.code));
});
function handleView(record: Recordable) { const btnEvent = { add: handleAdd, edit: handleEdit, enable: handleEnable, disable: handleDisable, refresh: handleRefresh, view: handleView, datalog: handleDatalog, delete: handleDelete };
dbClickRow(record); const { currentRoute } = useRouter();
const router = useRouter();
const formIdComputedRef = ref();
formIdComputedRef.value = currentRoute.value.meta.formId;
const schemaIdComputedRef = ref();
schemaIdComputedRef.value = currentRoute.value.meta.schemaId;
const [registerModal, { openModal }] = useModal();
const formName = 'LNG气源地';
const [registerTable, { reload }] = useTable({
title: '' || formName + '列表',
api: getLngBStationLngPage,
rowKey: 'id',
columns: customConfigColums,
formConfig: {
rowProps: {
gutter: 16
},
schemas: customSearchFormSchema,
fieldMapToTime: [],
showResetButton: false
},
beforeFetch: (params) => {
return { ...params, FormId: formIdComputedRef.value, PK: 'id' };
},
afterFetch: (res) => {
tableRef.value.setToolBarWidth();
},
useSearchForm: true,
showTableSetting: true,
} striped: false,
onMounted(() => { actionColumn: {
width: 160,
title: '操作',
dataIndex: 'action',
slots: { customRender: 'action' }
},
tableSetting: {
size: false,
setting: false
}
});
if (schemaIdComputedRef.value) { function dbClickRow(record) {
bus.on(FLOW_PROCESSED, handleRefresh); if (!actionButtonConfig?.value.some((element) => element.code == 'view')) {
bus.on(CREATE_FLOW, handleRefresh); return;
} else { }
bus.on(FORM_LIST_MODIFIED, handleRefresh); const { processId, taskIds, schemaId } = record.workflowData || {};
} if (taskIds && taskIds.length) {
router.push({
// 合并渲染覆盖配置中的列表配置,包括展示字段配置、搜索字段配置、按钮配置 path: '/flow/' + schemaId + '/' + (processId || '') + '/approveFlow',
mergeCustomListRenderConfig(); query: {
}); taskId: taskIds[0],
onUnmounted(() => { formName: formName,
if (schemaIdComputedRef.value) { formId: currentRoute.value.meta.formId
bus.off(FLOW_PROCESSED, handleRefresh); }
bus.off(CREATE_FLOW, handleRefresh); });
} else { } else if (schemaId && !taskIds && processId) {
bus.off(FORM_LIST_MODIFIED, handleRefresh); router.push({
} path: '/flow/' + schemaId + '/' + processId + '/approveFlow',
}); query: {
function getActions(record: Recordable):ActionItem[] { readonly: 1,
taskId: '',
const actionsList: ActionItem[] = actionButtonConfig.value?.map((button) => { formName: formName,
if (!record.workflowData?.processId) { formId: currentRoute.value.meta.formId
return { }
icon: button?.icon, });
tooltip: button?.name,
color: button.code === 'delete' ? 'error' : undefined,
onClick: btnEvent[button.code].bind(null, record),
};
} else {
if (button.code === 'view') {
return {
icon: button?.icon,
tooltip: button?.name,
onClick: btnEvent[button.code].bind(null, record),
};
} else { } else {
return {}; router.push({
path: '/form/LNGStation/' + record.id + '/viewForm',
query: {
formPath: 'mdm/LNGStation',
formName: formName,
formId: currentRoute.value.meta.formId
}
});
}
}
function buttonClick(code) {
btnEvent[code]();
}
function handleAdd() {
if (schemaIdComputedRef.value) {
router.push({
path: '/flow/' + schemaIdComputedRef.value + '/0/createFlow'
});
} else {
router.push({
path: '/form/LNGStation/0/createForm',
query: {
formPath: 'mdm/LNGStation',
formName: formName,
formId: currentRoute.value.meta.formId
}
});
}
}
function handleEdit(record: Recordable) {
router.push({
path: '/form/LNGStation/' + record.id + '/updateForm',
query: {
formPath: 'mdm/LNGStation',
formName: formName,
formId: currentRoute.value.meta.formId
}
});
}
function handleDelete(record: Recordable) {
deleteList([record.id]);
}
function handleEnable() {
if (!selectedKeys.value.length) {
notification.warning({
message: 'Tip',
description: t('请选择需要启用的数据')
});
return;
}
let ids = selectedKeys.value;
Modal.confirm({
title: '提示信息',
icon: createVNode(ExclamationCircleOutlined),
content: '是否确认启用?',
okText: '确认',
cancelText: '取消',
onOk() {
enableLngBStationLng(ids).then((_) => {
handleSuccess();
notification.success({
message: 'Tip',
description: t('启用成功!')
});
});
},
onCancel() {}
});
}
function handleDisable() {
if (!selectedKeys.value.length) {
notification.warning({
message: 'Tip',
description: t('请选择需要禁用的数据')
});
return;
}
let ids = selectedKeys.value;
Modal.confirm({
title: '提示信息',
icon: createVNode(ExclamationCircleOutlined),
content: '是否确认禁用?',
okText: '确认',
cancelText: '取消',
onOk() {
disableLngBStationLng(ids).then((_) => {
handleSuccess();
notification.success({
message: 'Tip',
description: t('禁用成功!')
});
});
},
onCancel() {}
});
}
function handleDatalog() {}
function deleteList(ids) {
Modal.confirm({
title: '提示信息',
icon: createVNode(ExclamationCircleOutlined),
content: '是否确认删除?',
okText: '确认',
cancelText: '取消',
onOk() {
deleteLngBStationLng(ids).then((_) => {
handleSuccess();
notification.success({
message: 'Tip',
description: t('删除成功!')
});
});
},
onCancel() {}
});
}
function handleRefresh() {
reload();
}
function handleSuccess() {
reload();
}
function handleView(record: Recordable) {
dbClickRow(record);
}
onMounted(() => {
if (schemaIdComputedRef.value) {
bus.on(FLOW_PROCESSED, handleRefresh);
bus.on(CREATE_FLOW, handleRefresh);
} else {
bus.on(FORM_LIST_MODIFIED, handleRefresh);
}
// 合并渲染覆盖配置中的列表配置,包括展示字段配置、搜索字段配置、按钮配置
mergeCustomListRenderConfig();
});
onUnmounted(() => {
if (schemaIdComputedRef.value) {
bus.off(FLOW_PROCESSED, handleRefresh);
bus.off(CREATE_FLOW, handleRefresh);
} else {
bus.off(FORM_LIST_MODIFIED, handleRefresh);
}
});
function getActions(record: Recordable): ActionItem[] {
const actionsList: ActionItem[] = actionButtonConfig.value?.map((button) => {
if (!record.workflowData?.processId) {
return {
icon: button?.icon,
tooltip: button?.name,
color: button.code === 'delete' ? 'error' : undefined,
onClick: btnEvent[button.code].bind(null, record)
};
} else {
if (button.code === 'view') {
return {
icon: button?.icon,
tooltip: button?.name,
onClick: btnEvent[button.code].bind(null, record)
};
} else {
return {};
}
}
});
return actionsList;
}
async function mergeCustomListRenderConfig() {
if (formConfig.useCustomConfig) {
let formId = currentRoute.value.meta.formId;
//1.合并展示字段配置
let cols = await mergeColumns(customConfigColums.value, formId);
customConfigColums.value = cols;
//2.合并搜索字段配置
let sFormSchema = await mergeSearchFormSchema(customSearchFormSchema.value, formId);
customSearchFormSchema.value = sFormSchema;
//3.合并按钮配置
let btns = await mergeButtons(buttons.value, formId);
buttons.value = btns;
} }
}
});
return actionsList;
}
async function mergeCustomListRenderConfig(){
if (formConfig.useCustomConfig) {
let formId=currentRoute.value.meta.formId;
//1.合并展示字段配置
let cols= await mergeColumns(customConfigColums.value,formId);
customConfigColums.value=cols;
//2.合并搜索字段配置
let sFormSchema= await mergeSearchFormSchema(customSearchFormSchema.value,formId);
customSearchFormSchema.value=sFormSchema;
//3.合并按钮配置
let btns= await mergeButtons(buttons.value,formId);
buttons.value=btns;
} }
};
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
:deep(.ant-table-selection-col) { :deep(.ant-table-selection-col) {
width: 50px; width: 50px;
} }
.show{ .show {
display: flex; display: flex;
} }
.hide{ .hide {
display: none !important; display: none !important;
} }
</style> </style>

View File

@ -1,224 +1,206 @@
<template> <template>
<SimpleForm <SimpleForm ref="systemFormRef" :formProps="data.formDataProps" :formModel="{}" :isWorkFlow="props.fromPage != FromPageType.MENU" />
ref="systemFormRef"
:formProps="data.formDataProps"
:formModel="{}"
:isWorkFlow="props.fromPage!=FromPageType.MENU"
/>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { reactive, ref,onBeforeMount,onMounted } from 'vue'; import { reactive, ref, onBeforeMount, onMounted } from 'vue';
import { formProps, formEventConfigs ,formConfig} from './config'; import { formProps, formEventConfigs, formConfig } from './config';
import SimpleForm from '/@/components/SimpleForm/src/SimpleForm.vue'; import SimpleForm from '/@/components/SimpleForm/src/SimpleForm.vue';
import { addLngBPort, getLngBPort, updateLngBPort, deleteLngBPort } from '/@/api/mdm/Port'; import { addLngBPort, getLngBPort, updateLngBPort, deleteLngBPort } from '/@/api/mdm/Port';
import { cloneDeep } from 'lodash-es'; import { cloneDeep } from 'lodash-es';
import { FormDataProps } from '/@/components/Designer/src/types'; import { FormDataProps } from '/@/components/Designer/src/types';
import { usePermission } from '/@/hooks/web/usePermission'; import { usePermission } from '/@/hooks/web/usePermission';
import { useFormConfig } from '/@/hooks/web/useFormConfig'; import { useFormConfig } from '/@/hooks/web/useFormConfig';
import { FromPageType } from '/@/enums/workflowEnum'; import { FromPageType } from '/@/enums/workflowEnum';
import { createFormEvent, getFormDataEvent, loadFormEvent, submitFormEvent,} from '/@/hooks/web/useFormEvent'; import { createFormEvent, getFormDataEvent, loadFormEvent, submitFormEvent } from '/@/hooks/web/useFormEvent';
import { changeWorkFlowForm, changeSchemaDisabled } from '/@/hooks/web/useWorkFlowForm'; import { changeWorkFlowForm, changeSchemaDisabled } from '/@/hooks/web/useWorkFlowForm';
import { WorkFlowFormParams } from '/@/model/workflow/bpmnConfig'; import { WorkFlowFormParams } from '/@/model/workflow/bpmnConfig';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { getTreeData } from '/@/api/mdm/CountryRegion';
const { filterFormSchemaAuth } = usePermission(); const { filterFormSchemaAuth } = usePermission();
const { mergeFormSchemas,mergeFormEventConfigs } = useFormConfig(); const { mergeFormSchemas, mergeFormEventConfigs } = useFormConfig();
const { currentRoute } = useRouter(); const { currentRoute } = useRouter();
const RowKey = 'id'; const RowKey = 'id';
const emits = defineEmits(['changeUploadComponentIds','loadingCompleted', 'form-mounted']); const emits = defineEmits(['changeUploadComponentIds', 'loadingCompleted', 'form-mounted']);
const props = defineProps({ const props = defineProps({
fromPage: { fromPage: {
type: Number, type: Number,
default: FromPageType.MENU, default: FromPageType.MENU
}, }
}); });
const systemFormRef = ref(); const systemFormRef = ref();
const data: { formDataProps: FormDataProps } = reactive({ const data: { formDataProps: FormDataProps } = reactive({
formDataProps: {schemas:[]} as FormDataProps, formDataProps: { schemas: [] } as FormDataProps
}); });
const state = reactive({ const state = reactive({
formModel: {}, formModel: {}
}); });
let customFormEventConfigs=[]; let customFormEventConfigs = [];
onMounted(async () => { onMounted(async () => {
try { try {
// 合并渲染覆盖配置中的字段配置、表单事件配置 const treeData = await getTreeData({});
await mergeCustomFormRenderConfig(); formProps.schemas?.forEach((v) => {
if (v.field == 'regionCode') {
v.componentProps.options = treeData;
}
});
if (props.fromPage == FromPageType.MENU) { // 合并渲染覆盖配置中的字段配置、表单事件配置
setMenuPermission(); await mergeCustomFormRenderConfig();
await createFormEvent(customFormEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:初始化表单
await loadFormEvent(customFormEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:加载表单
} else if (props.fromPage == FromPageType.FLOW) {
emits('loadingCompleted'); //告诉系统表单已经加载完毕
// loadingCompleted后 工作流页面直接利用Ref调用setWorkFlowForm方法
} else if (props.fromPage == FromPageType.PREVIEW) {
// 预览 无需权限,表单事件也无需执行
} else if (props.fromPage == FromPageType.DESKTOP) {
// 桌面设计 表单事件需要执行
emits('loadingCompleted'); //告诉系统表单已经加载完毕
await createFormEvent(customFormEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:初始化表单
await loadFormEvent(customFormEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas); //表单事件:加载表单
}
emits('form-mounted', formProps);
} catch (error) {
if (props.fromPage == FromPageType.MENU) {
setMenuPermission();
await createFormEvent(customFormEventConfigs, state.formModel, systemFormRef.value, formProps.schemas); //表单事件:初始化表单
await loadFormEvent(customFormEventConfigs, state.formModel, systemFormRef.value, formProps.schemas); //表单事件:加载表单
} else if (props.fromPage == FromPageType.FLOW) {
emits('loadingCompleted'); //告诉系统表单已经加载完毕
// loadingCompleted后 工作流页面直接利用Ref调用setWorkFlowForm方法
} else if (props.fromPage == FromPageType.PREVIEW) {
// 预览 无需权限,表单事件也无需执行
} else if (props.fromPage == FromPageType.DESKTOP) {
// 桌面设计 表单事件需要执行
emits('loadingCompleted'); //告诉系统表单已经加载完毕
await createFormEvent(customFormEventConfigs, state.formModel, systemFormRef.value, formProps.schemas); //表单事件:初始化表单
await loadFormEvent(customFormEventConfigs, state.formModel, systemFormRef.value, formProps.schemas); //表单事件:加载表单
}
emits('form-mounted', formProps);
} catch (error) {}
});
async function mergeCustomFormRenderConfig() {
let cloneProps = cloneDeep(formProps);
let fEventConfigs = cloneDeep(formEventConfigs);
if (formConfig.useCustomConfig) {
if (props.fromPage !== FromPageType.FLOW) {
let formPath = currentRoute.value.query.formPath;
//1.合并字段配置
cloneProps.schemas = await mergeFormSchemas({ formSchema: cloneProps.schemas!, formPath: formPath });
//2.合并表单事件配置
fEventConfigs = await mergeFormEventConfigs({ formEventConfigs: fEventConfigs, formPath: formPath });
}
}
data.formDataProps = cloneProps;
customFormEventConfigs = fEventConfigs;
} }
});
// 根据菜单页面权限,设置表单属性(必填,禁用,显示)
async function mergeCustomFormRenderConfig() { function setMenuPermission() {
let cloneProps=cloneDeep(formProps); data.formDataProps.schemas = filterFormSchemaAuth(data.formDataProps.schemas!);
let fEventConfigs=cloneDeep(formEventConfigs);
if (formConfig.useCustomConfig) {
if(props.fromPage !== FromPageType.FLOW){
let formPath=currentRoute.value.query.formPath;
//1.合并字段配置
cloneProps.schemas=await mergeFormSchemas({formSchema:cloneProps.schemas!,formPath:formPath});
//2.合并表单事件配置
fEventConfigs=await mergeFormEventConfigs({formEventConfigs:fEventConfigs,formPath:formPath});
}
}
data.formDataProps=cloneProps;
customFormEventConfigs=fEventConfigs;
}
// 根据菜单页面权限,设置表单属性(必填,禁用,显示)
function setMenuPermission() {
data.formDataProps.schemas = filterFormSchemaAuth(data.formDataProps.schemas!);
}
// 校验form 通过返回表单数据
async function validate() {
let values = [];
try {
values = await systemFormRef.value?.validate();
//添加隐藏组件
if (data.formDataProps.hiddenComponent?.length) {
data.formDataProps.hiddenComponent.forEach((component) => {
values[component.bindField] = component.value;
});
}
} finally {
} }
return values;
}
// 根据行唯一ID查询行数据并设置表单数据 【编辑】
async function setFormDataFromId(rowId, skipUpdate) {
try {
const record = await getLngBPort(rowId);
if (skipUpdate) {
return record;
}
setFieldsValue(record);
state.formModel = record;
await getFormDataEvent(customFormEventConfigs, state.formModel, systemFormRef.value, formProps.schemas); //表单事件:获取表单数据
return record;
} catch (error) {
// 校验form 通过返回表单数据
async function validate() {
let values = [];
try {
values = await systemFormRef.value?.validate();
//添加隐藏组件
if (data.formDataProps.hiddenComponent?.length) {
data.formDataProps.hiddenComponent.forEach((component) => {
values[component.bindField] = component.value;
});
}
} finally {
}
return values;
} }
} // 根据行唯一ID查询行数据并设置表单数据 【编辑】
// 辅助设置表单数据 async function setFormDataFromId(rowId, skipUpdate) {
function setFieldsValue(record) { try {
systemFormRef.value.setFieldsValue(record); const record = await getLngBPort(rowId);
} if (skipUpdate) {
// 重置表单数据 return record;
async function resetFields() { }
await systemFormRef.value.resetFields(); setFieldsValue(record);
} state.formModel = record;
// 设置表单数据全部为Disabled 【查看】 await getFormDataEvent(customFormEventConfigs, state.formModel, systemFormRef.value, formProps.schemas); //表单事件:获取表单数据
async function setDisabledForm(isDisabled) { return record;
data.formDataProps.schemas = changeSchemaDisabled(cloneDeep(data.formDataProps.schemas),isDisabled); } catch (error) {}
} }
// 获取行键值 // 辅助设置表单数据
function getRowKey() { function setFieldsValue(record) {
return RowKey; systemFormRef.value.setFieldsValue(record);
} }
// 更新api表单数据 // 重置表单数据
async function update({ values, rowId }) { async function resetFields() {
try { await systemFormRef.value.resetFields();
values[RowKey] = rowId; }
state.formModel = values; // 设置表单数据全部为Disabled 【查看】
let saveVal = await updateLngBPort(values); async function setDisabledForm(isDisabled) {
await submitFormEvent(customFormEventConfigs, state.formModel, data.formDataProps.schemas = changeSchemaDisabled(cloneDeep(data.formDataProps.schemas), isDisabled);
systemFormRef.value, }
formProps.schemas); //表单事件:提交表单 // 获取行键值
return saveVal; function getRowKey() {
} catch (error) {} return RowKey;
} }
// 新api表单数据 // 新api表单数据
async function add(values) { async function update({ values, rowId }) {
try { try {
state.formModel = values; values[RowKey] = rowId;
let saveVal = await addLngBPort(values); state.formModel = values;
await submitFormEvent(customFormEventConfigs, state.formModel, let saveVal = await updateLngBPort(values);
systemFormRef.value, await submitFormEvent(customFormEventConfigs, state.formModel, systemFormRef.value, formProps.schemas); //表单事件:提交表单
formProps.schemas); //表单事件:提交表单 return saveVal;
return saveVal; } catch (error) {}
} catch (error) {} }
} // 新增api表单数据
// 根据工作流页面权限,设置表单属性(必填,禁用,显示) async function add(values) {
async function setWorkFlowForm(obj: WorkFlowFormParams) { try {
try { state.formModel = values;
const cloneProps=cloneDeep(formProps); let saveVal = await addLngBPort(values);
customFormEventConfigs=cloneDeep(formEventConfigs); await submitFormEvent(customFormEventConfigs, state.formModel, systemFormRef.value, formProps.schemas); //表单事件:提交表单
if (formConfig.useCustomConfig) { return saveVal;
const parts = obj.formConfigKey.split('_'); } catch (error) {}
const formId=parts[1]; }
cloneProps.schemas=await mergeFormSchemas({formSchema:cloneProps.schemas!,formId:formId}); // 根据工作流页面权限,设置表单属性(必填,禁用,显示)
customFormEventConfigs=await mergeFormEventConfigs({formEventConfigs:customFormEventConfigs,formId:formId}); async function setWorkFlowForm(obj: WorkFlowFormParams) {
} try {
const cloneProps = cloneDeep(formProps);
customFormEventConfigs = cloneDeep(formEventConfigs);
if (formConfig.useCustomConfig) {
const parts = obj.formConfigKey.split('_');
const formId = parts[1];
cloneProps.schemas = await mergeFormSchemas({ formSchema: cloneProps.schemas!, formId: formId });
customFormEventConfigs = await mergeFormEventConfigs({ formEventConfigs: customFormEventConfigs, formId: formId });
}
let flowData = changeWorkFlowForm(cloneProps, obj); let flowData = changeWorkFlowForm(cloneProps, obj);
let { buildOptionJson, uploadComponentIds, formModels, isViewProcess } = flowData; let { buildOptionJson, uploadComponentIds, formModels, isViewProcess } = flowData;
data.formDataProps = buildOptionJson; data.formDataProps = buildOptionJson;
emits('changeUploadComponentIds', uploadComponentIds); //工作流中必须保存上传组件id【附件汇总需要】 emits('changeUploadComponentIds', uploadComponentIds); //工作流中必须保存上传组件id【附件汇总需要】
if (isViewProcess) { if (isViewProcess) {
setDisabledForm(); //查看 setDisabledForm(); //查看
} }
state.formModel = formModels; state.formModel = formModels;
if(formModels[RowKey]) { if (formModels[RowKey]) {
setFormDataFromId(formModels[RowKey], false) setFormDataFromId(formModels[RowKey], false);
} else { } else {
setFieldsValue(formModels) setFieldsValue(formModels);
} }
} catch (error) {} } catch (error) {}
await createFormEvent(customFormEventConfigs, state.formModel, await createFormEvent(customFormEventConfigs, state.formModel, systemFormRef.value, formProps.schemas); //表单事件:初始化表单
systemFormRef.value, await loadFormEvent(customFormEventConfigs, state.formModel, systemFormRef.value, formProps.schemas); //表单事件:加载表单
formProps.schemas); //表单事件:初始化表单 }
await loadFormEvent(customFormEventConfigs, state.formModel, function getFormModel() {
systemFormRef.value, return systemFormRef.value.formModel;
formProps.schemas); //表单事件:加载表单 }
} async function handleDelete(id) {
function getFormModel() { return await deleteLngBPort([id]);
return systemFormRef.value.formModel }
} defineExpose({
async function handleDelete(id) { setFieldsValue,
return await deleteLngBPort([id]); resetFields,
} validate,
defineExpose({ add,
setFieldsValue, update,
resetFields, setFormDataFromId,
validate, setDisabledForm,
add, setMenuPermission,
update, setWorkFlowForm,
setFormDataFromId, getRowKey,
setDisabledForm, getFormModel,
setMenuPermission, handleDelete
setWorkFlowForm, });
getRowKey,
getFormModel,
handleDelete
});
</script> </script>

View File

@ -1,110 +1,108 @@
<template> <template>
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit" @cancel="handleClose" :paddingRight="15" :bodyStyle="{ minHeight: '400px !important' }"> <BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit" @cancel="handleClose" :paddingRight="15" :bodyStyle="{ minHeight: '400px !important' }">
<ModalForm ref="formRef" :fromPage="FromPageType.MENU" /> <ModalForm ref="formRef" :fromPage="FromPageType.MENU" />
</BasicModal> </BasicModal>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, computed, reactive } from 'vue'; import { ref, computed, reactive } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal'; import { BasicModal, useModalInner } from '/@/components/Modal';
import { useMessage } from '/@/hooks/web/useMessage'; import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import { formProps } from './config'; import { formProps } from './config';
import ModalForm from './Form.vue'; import ModalForm from './Form.vue';
import { FromPageType } from '/@/enums/workflowEnum'; import { FromPageType } from '/@/enums/workflowEnum';
const emit = defineEmits(['success', 'register']); const emit = defineEmits(['success', 'register']);
const { notification } = useMessage(); const { notification } = useMessage();
const formRef = ref(); const formRef = ref();
const state = reactive({ const state = reactive({
formModel: {}, formModel: {},
isUpdate: true, isUpdate: true,
isView: false, isView: false,
isCopy: false, isCopy: false,
rowId: '', rowId: ''
});
const { t } = useI18n();
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
state.isUpdate = !!data?.isUpdate;
state.isView = !!data?.isView;
state.isCopy = !!data?.isCopy;
setModalProps({
destroyOnClose: true,
maskClosable: false,
showCancelBtn: !state.isView,
showOkBtn: !state.isView,
canFullscreen: true,
width: 900,
}); });
if (state.isUpdate || state.isView || state.isCopy) {
state.rowId = data.id;
if (state.isView) {
await formRef.value.setDisabledForm();
}
await formRef.value.setFormDataFromId(state.rowId);
} else {
formRef.value.resetFields();
}
});
const getTitle = computed(() => (state.isView ? '查看' : !state.isUpdate ? '新增' : '编辑')); const { t } = useI18n();
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
state.isUpdate = !!data?.isUpdate;
state.isView = !!data?.isView;
state.isCopy = !!data?.isCopy;
async function saveModal() { setModalProps({
let saveSuccess = false; destroyOnClose: true,
try { maskClosable: false,
const values = await formRef.value?.validate(); showCancelBtn: !state.isView,
//添加隐藏组件 showOkBtn: !state.isView,
if (formProps.hiddenComponent?.length) { canFullscreen: true,
formProps.hiddenComponent.forEach((component) => { width: 900
values[component.bindField] = component.value;
}); });
} if (state.isUpdate || state.isView || state.isCopy) {
if (values !== false) { state.rowId = data.id;
try { if (state.isView) {
if (!state.isUpdate || state.isCopy) { await formRef.value.setDisabledForm();
saveSuccess = await formRef.value.add(values); }
} else { await formRef.value.setFormDataFromId(state.rowId);
saveSuccess = await formRef.value.update({ values, rowId: state.rowId });
}
return saveSuccess;
} catch (error) {}
}
} catch (error) {
return saveSuccess;
}
}
async function handleSubmit() {
try {
const saveSuccess = await saveModal();
setModalProps({ confirmLoading: true });
if (saveSuccess) {
if (!state.isUpdate || state.isCopy) {
//false 新增
notification.success({
message: 'Tip',
description: t('新增成功!'),
}); //提示消息
} else { } else {
notification.success({ formRef.value.resetFields();
message: 'Tip',
description: t('修改成功!'),
}); //提示消息
} }
closeModal(); });
formRef.value.resetFields();
emit('success');
}
} finally {
setModalProps({ confirmLoading: false });
}
}
function handleClose() { const getTitle = computed(() => (state.isView ? '查看' : !state.isUpdate ? '新增' : '编辑'));
formRef.value.resetFields();
} async function saveModal() {
let saveSuccess = false;
try {
const values = await formRef.value?.validate();
//添加隐藏组件
if (formProps.hiddenComponent?.length) {
formProps.hiddenComponent.forEach((component) => {
values[component.bindField] = component.value;
});
}
if (values !== false) {
try {
if (!state.isUpdate || state.isCopy) {
saveSuccess = await formRef.value.add(values);
} else {
saveSuccess = await formRef.value.update({ values, rowId: state.rowId });
}
return saveSuccess;
} catch (error) {}
}
} catch (error) {
return saveSuccess;
}
}
async function handleSubmit() {
try {
const saveSuccess = await saveModal();
setModalProps({ confirmLoading: true });
if (saveSuccess) {
if (!state.isUpdate || state.isCopy) {
//false 新增
notification.success({
message: 'Tip',
description: t('新增成功!')
}); //提示消息
} else {
notification.success({
message: 'Tip',
description: t('修改成功!')
}); //提示消息
}
closeModal();
formRef.value.resetFields();
emit('success');
}
} finally {
setModalProps({ confirmLoading: false });
}
}
function handleClose() {
formRef.value.resetFields();
}
</script> </script>

File diff suppressed because it is too large Load Diff

View File

@ -1,356 +1,353 @@
<template> <template>
<PageWrapper dense fixedHeight contentFullHeight contentClass="flex"> <PageWrapper dense fixedHeight contentFullHeight contentClass="flex">
<BasicTable @register="registerTable" ref="tableRef" @row-dbClick="dbClickRow"> <BasicTable @register="registerTable" ref="tableRef" @row-db-click="dbClickRow">
<template #toolbar>
<template #toolbar> <template v-for="button in tableButtonConfig" :key="button.code">
<template v-for="button in tableButtonConfig" :key="button.code"> <a-button v-if="button.isDefault" :type="button.type" @click="buttonClick(button.code)">
<a-button v-if="button.isDefault" :type="button.type" @click="buttonClick(button.code)"> <template #icon><Icon :icon="button.icon" /></template>
<template #icon><Icon :icon="button.icon" /></template> {{ button.name }}
{{ button.name }} </a-button>
</a-button> <a-button v-else :type="button.type">
<a-button v-else :type="button.type"> <template #icon><Icon :icon="button.icon" /></template>
<template #icon><Icon :icon="button.icon" /></template> {{ button.name }}
{{ button.name }} </a-button>
</a-button> </template>
</template> </template>
</template> <template #bodyCell="{ column, record }">
<template #bodyCell="{ column, record }"> <template v-if="column.dataIndex === 'action'">
<template v-if="column.dataIndex === 'action'"> <TableAction :actions="getActions(record)" />
<TableAction :actions="getActions(record)" /> </template>
</template> </template>
</template> </BasicTable>
</BasicTable> <PortModal @register="registerModal" @success="handleSuccess" />
<PortModal @register="registerModal" @success="handleSuccess" /> </PageWrapper>
</PageWrapper>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, computed, onMounted, onUnmounted, createVNode, import { ref, computed, onMounted, onUnmounted, createVNode } from 'vue';
} from 'vue'; import { Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
import { getLngBPortPage, deleteLngBPort } from '/@/api/mdm/Port';
import { PageWrapper } from '/@/components/Page';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { usePermission } from '/@/hooks/web/usePermission';
import { useFormConfig } from '/@/hooks/web/useFormConfig';
import { useRouter } from 'vue-router';
import { setIndexFlowStatus } from '/@/utils/flow/index';
import { getLngBPort } from '/@/api/mdm/Port';
import { useModal } from '/@/components/Modal';
import PortModal from './components/PortModal.vue';
import { formConfig, searchFormSchema, columns } from './components/config';
import Icon from '/@/components/Icon/index';
import useEventBus from '/@/hooks/event/useEventBus';
import { cloneDeep } from 'lodash-es';
import { Modal } from 'ant-design-vue'; const { bus, CREATE_FLOW, FLOW_PROCESSED, FORM_LIST_MODIFIED } = useEventBus();
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { BasicTable, useTable, TableAction, ActionItem } from '/@/components/Table';
import { getLngBPortPage, deleteLngBPort} from '/@/api/mdm/Port';
import { PageWrapper } from '/@/components/Page';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { usePermission } from '/@/hooks/web/usePermission';
import { useFormConfig } from '/@/hooks/web/useFormConfig';
import { useRouter } from 'vue-router';
import { setIndexFlowStatus } from '/@/utils/flow/index'
import { getLngBPort } from '/@/api/mdm/Port';
import { useModal } from '/@/components/Modal';
import PortModal from './components/PortModal.vue';
import {formConfig, searchFormSchema, columns } from './components/config';
import Icon from '/@/components/Icon/index';
import useEventBus from '/@/hooks/event/useEventBus';
import { cloneDeep } from 'lodash-es';
const { bus, CREATE_FLOW, FLOW_PROCESSED, FORM_LIST_MODIFIED } = useEventBus(); const { notification } = useMessage();
const { t } = useI18n();
defineEmits(['register']);
const { filterColumnAuth, filterButtonAuth } = usePermission();
const { mergeColumns, mergeSearchFormSchema, mergeButtons } = useFormConfig();
const { notification } = useMessage(); const filterColumns = cloneDeep(filterColumnAuth(columns));
const { t } = useI18n(); const customConfigColums = ref(filterColumns);
defineEmits(['register']); const customSearchFormSchema = ref(searchFormSchema);
const { filterColumnAuth, filterButtonAuth } = usePermission();
const { mergeColumns,mergeSearchFormSchema,mergeButtons } = useFormConfig();
const filterColumns = cloneDeep(filterColumnAuth(columns)); const tableRef = ref();
const customConfigColums =ref(filterColumns); //所有按钮
const customSearchFormSchema =ref(searchFormSchema); const buttons = ref([
{ isUse: true, name: '新增', code: 'add', icon: 'ant-design:plus-outlined', isDefault: true, type: 'primary' },
const tableRef = ref(); { isUse: true, name: '编辑', code: 'edit', icon: 'ant-design:form-outlined', isDefault: true },
//所有按钮 { isUse: true, name: '启用', code: 'enable', icon: 'ant-design:form-outlined', isDefault: true, type: 'primary' },
const buttons = ref([{"isUse":true,"name":"新增","code":"add","icon":"ant-design:plus-outlined","isDefault":true,"type":"primary"},{"isUse":true,"name":"编辑","code":"edit","icon":"ant-design:form-outlined","isDefault":true},{"isUse":true,"name":"启用","code":"enable","icon":"ant-design:form-outlined","isDefault":true,"type":"primary"},{"isUse":true,"name":"作废","code":"disable","icon":"ant-design:stop-outlined","isDefault":true,"type":"dashed"},{"isUse":true,"name":"刷新","code":"refresh","icon":"ant-design:reload-outlined","isDefault":true},{"isUse":true,"name":"查看","code":"view","icon":"ant-design:eye-outlined","isDefault":true},{"isUse":true,"name":"数据日志","code":"datalog","icon":"ant-design:profile-outlined","isDefault":true},{"isUse":true,"name":"删除","code":"delete","icon":"ant-design:delete-outlined","isDefault":true}]); { isUse: true, name: '作废', code: 'disable', icon: 'ant-design:stop-outlined', isDefault: true, type: 'dashed' },
//展示在列表内的按钮 { isUse: true, name: '刷新', code: 'refresh', icon: 'ant-design:reload-outlined', isDefault: true },
const actionButtons = ref<string[]>(['view', 'edit','datalog', 'copyData', 'delete', 'startwork','flowRecord']); { isUse: true, name: '查看', code: 'view', icon: 'ant-design:eye-outlined', isDefault: true },
const buttonConfigs = computed(()=>{ { isUse: true, name: '数据日志', code: 'datalog', icon: 'ant-design:profile-outlined', isDefault: true },
return filterButtonAuth(buttons.value); { isUse: true, name: '删除', code: 'delete', icon: 'ant-design:delete-outlined', isDefault: true }
}) ]);
//展示在列表内的按钮
const tableButtonConfig = computed(() => { const actionButtons = ref<string[]>(['view', 'edit', 'datalog', 'copyData', 'delete', 'startwork', 'flowRecord']);
return buttonConfigs.value?.filter((x) => !actionButtons.value.includes(x.code)); const buttonConfigs = computed(() => {
}); return filterButtonAuth(buttons.value);
const actionButtonConfig = computed(() => {
return buttonConfigs.value?.filter((x) => actionButtons.value.includes(x.code));
});
const btnEvent = {add : handleAdd,edit : handleEdit,enable : handleEnable,disable : handleDisable,refresh : handleRefresh,view : handleView,datalog : handleDatalog,delete : handleDelete,}
const { currentRoute } = useRouter();
const router = useRouter();
const formIdComputedRef = ref();
formIdComputedRef.value = currentRoute.value.meta.formId
const schemaIdComputedRef = ref();
schemaIdComputedRef.value = currentRoute.value.meta.schemaId
const [registerModal, { openModal }] = useModal();
const formName='港口';
const [registerTable, { reload, }] = useTable({
title: '' || (formName + '列表'),
api: getLngBPortPage,
rowKey: 'id',
columns: customConfigColums,
formConfig: {
rowProps: {
gutter: 16,
},
schemas: customSearchFormSchema,
fieldMapToTime: [],
showResetButton: false,
},
beforeFetch: (params) => {
return { ...params, FormId: formIdComputedRef.value, PK: 'id' };
},
afterFetch: (res) => {
tableRef.value.setToolBarWidth();
},
useSearchForm: true,
showTableSetting: true,
striped: false,
actionColumn: {
width: 160,
title: '操作',
dataIndex: 'action',
slots: { customRender: 'action' },
},
tableSetting: {
size: false,
setting: false,
},
});
function dbClickRow(record) {
if (!actionButtonConfig?.value.some(element => element.code == 'view')) {
return;
}
const { processId, taskIds, schemaId } = record.workflowData || {};
if (taskIds && taskIds.length) {
router.push({
path: '/flow/' + schemaId + '/' + (processId || '') + '/approveFlow',
query: {
taskId: taskIds[0],
formName: formName,
formId:currentRoute.value.meta.formId
}
});
} else if (schemaId && !taskIds && processId) {
router.push({
path: '/flow/' + schemaId + '/' + processId + '/approveFlow',
query: {
readonly: 1,
taskId: '',
formName: formName,
formId:currentRoute.value.meta.formId
}
});
} else {
router.push({
path: '/form/Port/' + record.id + '/viewForm',
query: {
formPath: 'mdm/Port',
formName: formName,
formId:currentRoute.value.meta.formId
}
});
}
}
function buttonClick(code) {
btnEvent[code]();
}
function handleAdd() {
if (schemaIdComputedRef.value) {
router.push({
path: '/flow/' + schemaIdComputedRef.value + '/0/createFlow'
});
} else {
router.push({
path: '/form/Port/0/createForm',
query: {
formPath: 'mdm/Port',
formName: formName,
formId:currentRoute.value.meta.formId
}
});
}
}
function handleEdit(record: Recordable) {
router.push({
path: '/form/Port/' + record.id + '/updateForm',
query: {
formPath: 'mdm/Port',
formName: formName,
formId:currentRoute.value.meta.formId
}
}); });
}
function handleDelete(record: Recordable) {
deleteList([record.id]);
}
function handleEnable() { const tableButtonConfig = computed(() => {
if (!selectedKeys.value.length) { return buttonConfigs.value?.filter((x) => !actionButtons.value.includes(x.code));
notification.warning({
message: 'Tip',
description: t('请选择需要启用的数据'),
});
return;
}
let ids = selectedKeys.value;
Modal.confirm({
title: '提示信息',
icon: createVNode(ExclamationCircleOutlined),
content: '是否确认启用?',
okText: '确认',
cancelText: '取消',
onOk() {
enableLngBPort(ids).then((_) => {
handleSuccess();
notification.success({
message: 'Tip',
description: t('启用成功!'),
});
});
},
onCancel() {},
});
}
function handleDisable() {
if (!selectedKeys.value.length) {
notification.warning({
message: 'Tip',
description: t('请选择需要禁用的数据'),
});
return;
}
let ids = selectedKeys.value;
Modal.confirm({
title: '提示信息',
icon: createVNode(ExclamationCircleOutlined),
content: '是否确认禁用?',
okText: '确认',
cancelText: '取消',
onOk() {
disableLngBPort(ids).then((_) => {
handleSuccess();
notification.success({
message: 'Tip',
description: t('禁用成功!'),
});
});
},
onCancel() {},
});
}
function deleteList(ids) {
Modal.confirm({
title: '提示信息',
icon: createVNode(ExclamationCircleOutlined),
content: '是否确认删除?',
okText: '确认',
cancelText: '取消',
onOk() {
deleteLngBPort(ids).then((_) => {
handleSuccess();
notification.success({
message: 'Tip',
description: t('删除成功!'),
});
});
},
onCancel() {},
}); });
}
function handleRefresh() {
reload();
}
function handleSuccess() {
reload(); const actionButtonConfig = computed(() => {
} return buttonConfigs.value?.filter((x) => actionButtons.value.includes(x.code));
});
function handleView(record: Recordable) { const btnEvent = { add: handleAdd, edit: handleEdit, enable: handleEnable, disable: handleDisable, refresh: handleRefresh, view: handleView, datalog: handleDatalog, delete: handleDelete };
dbClickRow(record); const { currentRoute } = useRouter();
const router = useRouter();
const formIdComputedRef = ref();
formIdComputedRef.value = currentRoute.value.meta.formId;
const schemaIdComputedRef = ref();
schemaIdComputedRef.value = currentRoute.value.meta.schemaId;
const [registerModal, { openModal }] = useModal();
const formName = '港口';
const [registerTable, { reload }] = useTable({
title: '' || formName + '列表',
api: getLngBPortPage,
rowKey: 'id',
columns: customConfigColums,
formConfig: {
rowProps: {
gutter: 16
},
schemas: customSearchFormSchema,
fieldMapToTime: [],
showResetButton: false
},
beforeFetch: (params) => {
return { ...params, FormId: formIdComputedRef.value, PK: 'id' };
},
afterFetch: (res) => {
tableRef.value.setToolBarWidth();
},
useSearchForm: true,
showTableSetting: true,
} striped: false,
onMounted(() => { actionColumn: {
width: 160,
title: '操作',
dataIndex: 'action',
slots: { customRender: 'action' }
},
tableSetting: {
size: false,
setting: false
}
});
if (schemaIdComputedRef.value) { function dbClickRow(record) {
bus.on(FLOW_PROCESSED, handleRefresh); if (!actionButtonConfig?.value.some((element) => element.code == 'view')) {
bus.on(CREATE_FLOW, handleRefresh); return;
} else { }
bus.on(FORM_LIST_MODIFIED, handleRefresh); const { processId, taskIds, schemaId } = record.workflowData || {};
} if (taskIds && taskIds.length) {
router.push({
// 合并渲染覆盖配置中的列表配置,包括展示字段配置、搜索字段配置、按钮配置 path: '/flow/' + schemaId + '/' + (processId || '') + '/approveFlow',
mergeCustomListRenderConfig(); query: {
}); taskId: taskIds[0],
onUnmounted(() => { formName: formName,
if (schemaIdComputedRef.value) { formId: currentRoute.value.meta.formId
bus.off(FLOW_PROCESSED, handleRefresh); }
bus.off(CREATE_FLOW, handleRefresh); });
} else { } else if (schemaId && !taskIds && processId) {
bus.off(FORM_LIST_MODIFIED, handleRefresh); router.push({
} path: '/flow/' + schemaId + '/' + processId + '/approveFlow',
}); query: {
function getActions(record: Recordable):ActionItem[] { readonly: 1,
taskId: '',
const actionsList: ActionItem[] = actionButtonConfig.value?.map((button) => { formName: formName,
if (!record.workflowData?.processId) { formId: currentRoute.value.meta.formId
return { }
icon: button?.icon, });
tooltip: button?.name,
color: button.code === 'delete' ? 'error' : undefined,
onClick: btnEvent[button.code].bind(null, record),
};
} else {
if (button.code === 'view') {
return {
icon: button?.icon,
tooltip: button?.name,
onClick: btnEvent[button.code].bind(null, record),
};
} else { } else {
return {}; router.push({
path: '/form/Port/' + record.id + '/viewForm',
query: {
formPath: 'mdm/Port',
formName: formName,
formId: currentRoute.value.meta.formId
}
});
}
}
function buttonClick(code) {
btnEvent[code]();
}
function handleAdd() {
if (schemaIdComputedRef.value) {
router.push({
path: '/flow/' + schemaIdComputedRef.value + '/0/createFlow'
});
} else {
router.push({
path: '/form/Port/0/createForm',
query: {
formPath: 'mdm/Port',
formName: formName,
formId: currentRoute.value.meta.formId
}
});
}
}
function handleEdit(record: Recordable) {
router.push({
path: '/form/Port/' + record.id + '/updateForm',
query: {
formPath: 'mdm/Port',
formName: formName,
formId: currentRoute.value.meta.formId
}
});
}
function handleDelete(record: Recordable) {
deleteList([record.id]);
}
function handleEnable() {
if (!selectedKeys.value.length) {
notification.warning({
message: 'Tip',
description: t('请选择需要启用的数据')
});
return;
}
let ids = selectedKeys.value;
Modal.confirm({
title: '提示信息',
icon: createVNode(ExclamationCircleOutlined),
content: '是否确认启用?',
okText: '确认',
cancelText: '取消',
onOk() {
enableLngBPort(ids).then((_) => {
handleSuccess();
notification.success({
message: 'Tip',
description: t('启用成功!')
});
});
},
onCancel() {}
});
}
function handleDisable() {
if (!selectedKeys.value.length) {
notification.warning({
message: 'Tip',
description: t('请选择需要禁用的数据')
});
return;
}
let ids = selectedKeys.value;
Modal.confirm({
title: '提示信息',
icon: createVNode(ExclamationCircleOutlined),
content: '是否确认禁用?',
okText: '确认',
cancelText: '取消',
onOk() {
disableLngBPort(ids).then((_) => {
handleSuccess();
notification.success({
message: 'Tip',
description: t('禁用成功!')
});
});
},
onCancel() {}
});
}
function deleteList(ids) {
Modal.confirm({
title: '提示信息',
icon: createVNode(ExclamationCircleOutlined),
content: '是否确认删除?',
okText: '确认',
cancelText: '取消',
onOk() {
deleteLngBPort(ids).then((_) => {
handleSuccess();
notification.success({
message: 'Tip',
description: t('删除成功!')
});
});
},
onCancel() {}
});
}
function handleRefresh() {
reload();
}
function handleSuccess() {
reload();
}
function handleDatalog() {}
function handleView(record: Recordable) {
dbClickRow(record);
}
onMounted(() => {
if (schemaIdComputedRef.value) {
bus.on(FLOW_PROCESSED, handleRefresh);
bus.on(CREATE_FLOW, handleRefresh);
} else {
bus.on(FORM_LIST_MODIFIED, handleRefresh);
}
// 合并渲染覆盖配置中的列表配置,包括展示字段配置、搜索字段配置、按钮配置
mergeCustomListRenderConfig();
});
onUnmounted(() => {
if (schemaIdComputedRef.value) {
bus.off(FLOW_PROCESSED, handleRefresh);
bus.off(CREATE_FLOW, handleRefresh);
} else {
bus.off(FORM_LIST_MODIFIED, handleRefresh);
}
});
function getActions(record: Recordable): ActionItem[] {
const actionsList: ActionItem[] = actionButtonConfig.value?.map((button) => {
if (!record.workflowData?.processId) {
return {
icon: button?.icon,
tooltip: button?.name,
color: button.code === 'delete' ? 'error' : undefined,
onClick: btnEvent[button.code].bind(null, record)
};
} else {
if (button.code === 'view') {
return {
icon: button?.icon,
tooltip: button?.name,
onClick: btnEvent[button.code].bind(null, record)
};
} else {
return {};
}
}
});
return actionsList;
}
async function mergeCustomListRenderConfig() {
if (formConfig.useCustomConfig) {
let formId = currentRoute.value.meta.formId;
//1.合并展示字段配置
let cols = await mergeColumns(customConfigColums.value, formId);
customConfigColums.value = cols;
//2.合并搜索字段配置
let sFormSchema = await mergeSearchFormSchema(customSearchFormSchema.value, formId);
customSearchFormSchema.value = sFormSchema;
//3.合并按钮配置
let btns = await mergeButtons(buttons.value, formId);
buttons.value = btns;
} }
}
});
return actionsList;
}
async function mergeCustomListRenderConfig(){
if (formConfig.useCustomConfig) {
let formId=currentRoute.value.meta.formId;
//1.合并展示字段配置
let cols= await mergeColumns(customConfigColums.value,formId);
customConfigColums.value=cols;
//2.合并搜索字段配置
let sFormSchema= await mergeSearchFormSchema(customSearchFormSchema.value,formId);
customSearchFormSchema.value=sFormSchema;
//3.合并按钮配置
let btns= await mergeButtons(buttons.value,formId);
buttons.value=btns;
} }
};
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
:deep(.ant-table-selection-col) { :deep(.ant-table-selection-col) {
width: 50px; width: 50px;
} }
.show{ .show {
display: flex; display: flex;
} }
.hide{ .hide {
display: none !important; display: none !important;
} }
</style> </style>