From cc88111d61a350a4d24cf339b526d4357f934ddf Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期二, 30 七月 2024 00:31:12 +0800 Subject: [PATCH] 标签模板维护变量更新 --- src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_VAR.ts | 510 ++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 366 insertions(+), 144 deletions(-) diff --git a/src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_VAR.ts b/src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_VAR.ts index c3d087d..3622424 100644 --- a/src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_VAR.ts +++ b/src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_VAR.ts @@ -4,7 +4,7 @@ * @version: * @Date: 2024-06-19 20:34:27 * @LastEditors: Ben Lin - * @LastEditTime: 2024-07-27 13:22:30 + * @LastEditTime: 2024-07-29 23:10:18 */ import { Tag, Tooltip } from 'ant-design-vue'; @@ -15,8 +15,13 @@ import { useLocale } from '/@/locales/useLocale'; import { useDrawer } from '/@/components/Drawer'; import { formatTime } from '/@/utils/dateUtil'; -import { Search } from '../data'; +import { custDel, EditOperation, Search } from '../data'; import { buildUUID } from '/@/utils/uuid'; +import { CustModalParams, FunctionType } from '/@/api/tigerapi/model/systemModel'; +import { useModal } from '/@/components/Modal'; +import { SaveLabelTemplate } from '/@/api/tigerapi/mes/label'; +import { BAS_LABEL_TEMP, BAS_LABEL_VAR, BAS_LABEL_VAR_WO, BasLabelTempInput } from '/@/api/tigerapi/model/mesModel'; +import { useUserStore } from '/@/store/modules/user'; const { getLocale } = useLocale(); @@ -40,16 +45,29 @@ * @description: 鑾峰彇鏂板鎸夐挳鐨勮涓猴紝蹇呴渶瑕佹湁鐨勬柟娉� * @return {*} */ - CreateAction: (fnName: string) => { - return { - action: 'drawer', //drawer(鎵撳紑宸︿晶鎶藉眽妗�) | go(璺宠浆鍒版柊鐨勯〉闈�) - }; + CreateAction: (type: string) => { + let action = {} as any; + switch (type) { + case 'BAS_LABEL_VAR': + case 'BAS_LABEL_VAR_WO': + action = { + action: 'edit', //drawer(鎵撳紑宸︿晶鎶藉眽妗�) | go(璺宠浆鍒版柊鐨勯〉闈�) | edit(濡傛灉鏄〃鏍煎彲缂栬緫椤甸潰灏辨槸鑷畾涔夋柟娉�) + }; + break; + } + return action; }, /** - * @description: 浜у搧缁戝畾宸ヨ壓璺嚎鎿嶄綔瀛楁鑷畾涔夋寜閽紝蹇呴渶瑕佹湁鐨勬柟娉� + * @description: 鎿嶄綔瀛楁鑷畾涔夋寜閽紝蹇呴渶瑕佹湁鐨勬柟娉� * @return {*} */ ActionItem: (params: Recordable<any>, data, ...args): ActionItem[] => { + data.map((x) => { + if (x.name == 'Delete') { + x.popConfirm.confirm = custDel.bind(null, args, params); + x.tooltip = '鍒犻櫎'; + } + }); return data; }, /** @@ -70,6 +88,7 @@ label: '鏍囩妯℃澘缂栫爜', component: 'Input', required: true, + isexist: 'Y', colProps: { span: 8, }, @@ -111,11 +130,49 @@ }, }, { + field: 'PROD_CODE', + label: '浜у搧缂栫爜', + component: 'Input', + isexist: 'N', + show: true, + required: true, + colProps: { + span: 7, + }, + }, + { + field: 'BAS_LABEL_VAR1PSelect_0', //鎸変綆浠g爜閰嶇疆鐨勮鍒欙紝瀹炰綋鍚�+搴忓彿+PSelect_0锛屽簭鍙风敤鏉ュ尯鍒嗗涓殑鏃跺�欙紝PSelect_0杩欐槸涓浐瀹氬悗缂� + label: '1', + defaultValue: 'BAS_LABEL_VAR', + component: 'Input', + colProps: { span: 1 }, + colSlot: 'BAS_LABEL_VAR1add', //鎸変綆浠g爜閰嶇疆鐨勮鍒欙紝瀹炰綋鍚�+搴忓彿+add锛屽簭鍙风敤鏉ュ尯鍒嗗涓殑鏃跺�欙紝add杩欐槸涓浐瀹氬悗缂� + }, + { + field: 'CUST_CODE', + label: '瀹㈡埛缂栫爜', + component: 'Input', + isexist: 'N', + show: true, + // required: true, + colProps: { + span: 7, + }, + }, + { + field: 'BAS_LABEL_VAR2PSelect_0', //鎸変綆浠g爜閰嶇疆鐨勮鍒欙紝瀹炰綋鍚�+搴忓彿+PSelect_0锛屽簭鍙风敤鏉ュ尯鍒嗗涓殑鏃跺�欙紝PSelect_0杩欐槸涓浐瀹氬悗缂� + label: '1', + defaultValue: 'BAS_CUSTOMER', + component: 'Input', + colProps: { span: 1 }, + colSlot: 'BAS_LABEL_VAR2add', //鎸変綆浠g爜閰嶇疆鐨勮鍒欙紝瀹炰綋鍚�+搴忓彿+add锛屽簭鍙风敤鏉ュ尯鍒嗗涓殑鏃跺�欙紝add杩欐槸涓浐瀹氬悗缂� + }, + { label: '澶囨敞', field: 'REMARK', component: 'Input', colProps: { - span: 16, + span: 24, }, }, { @@ -129,8 +186,26 @@ }, ]; }, - GetBaseColumns: () => { - return []; + /** + * @description: 寮瑰嚭閫夋嫨妗嗘垚鍔熻繑鍥炶祴鍊兼柟娉� + * @param {*} d + * @param {*} u + * @return {*} + */ + GetSelectSuccess: (d, u) => { + return { + PROD_CODE: d.values['val'], + }; + }, + /** + * @description: 鑾峰彇妯℃�佹搴旂敤鍒楄〃 + * @return {*} + */ + GetUseModals: () => { + return { + BAS_LABEL_VAR1add: useModal(), + BAS_LABEL_VAR2add: useModal(), + }; }, GetSearchForm: () => { return [ @@ -223,6 +298,27 @@ }, ]; }, + /** + * @description: 鑾峰彇鏂板琛岀殑鏁版嵁 + * @param {string} type + * @return {*} + */ + GetNewRow: (type: string) => { + let values = {}; + switch (type) { + case 'BAS_LABEL_VAR_WO': + values = { + ID: buildUUID(), + LABEL_ID: '', + VAR_NAME: '', + VAR_TYPE: '', + VAR_VALUE: '', + REMARK: '', + }; + break; + } + return values; + }, KeyFieldValues: (val: string, id: string) => { return { LABEL_ID: id }; }, @@ -240,7 +336,7 @@ pageContent: '杩欓噷鍙互娣诲姞鍜屼慨鏀规ā鏉垮拰妯℃澘鍙橀噺鍙婂伐鍗曟ā鏉垮彉閲忋��', tableTitle: { BAS_LABEL_VAR: '妯℃澘鍙橀噺绠$悊', - MES_SHIFT_PRD: '鏃舵绠$悊', + BAS_LABEL_VAR_WO: '宸ュ崟妯℃澘鍙橀噺绠$悊', }, }; }, @@ -268,7 +364,7 @@ { BAS_LABEL_VAR: useDrawer(), }, - // { MES_SHIFT_PRD: useDrawer() }, + { BAS_LABEL_VAR_WO: useDrawer() }, ]; } /** * @description: 鑾峰彇琛ㄦ牸use鍒楄〃 @@ -282,8 +378,8 @@ BAS_LABEL_VAR: useTable({ title: '鍒楄〃淇℃伅', dataSource: data.value['BAS_LABEL_VAR'], - columns: baseColumns['BAS_LABEL_VAR'], - maxHeight: 560, + columns: GetBaseColumns('BAS_LABEL_VAR', args[0]), + maxHeight: 520, formConfig: { labelWidth: 140, schemas: searchForms['BAS_LABEL_VAR'], @@ -294,6 +390,32 @@ bordered: true, canResize: true, showIndexColumn: false, + // rowSelection: { + // type: 'radio', //'checkbox' + // }, + // actionColumn: { + // width: 130, + // title: '鎿嶄綔', + // dataIndex: 'action', + // slots: { customRender: 'action' }, + // fixed: 'right', + // }, //鑷畾涔夋搷浣滃垪 + }), + BAS_LABEL_VAR_WO: useTable({ + title: '鍒楄〃淇℃伅', + dataSource: data.value['BAS_LABEL_VAR_WO'], + columns: baseColumns['BAS_LABEL_VAR_WO'], + maxHeight: 550, + formConfig: { + labelWidth: 140, + schemas: searchForms['BAS_LABEL_VAR_WO'], + submitFunc: () => Search('BAS_LABEL_VAR_WO', data, args[0]), //鑷畾涔夋煡璇㈡彁浜ゆ寜閽殑鏂规硶锛岃Е鍙戞煡璇㈡彁浜や簨浠� + }, + useSearchForm: false, + showTableSetting: false, + bordered: true, + canResize: false, + showIndexColumn: false, actionColumn: { width: 130, title: '鎿嶄綔', @@ -302,29 +424,6 @@ fixed: 'right', }, //鑷畾涔夋搷浣滃垪 }), - // MES_SHIFT_PRD: useTable({ - // title: '鍒楄〃淇℃伅', - // dataSource: data.value['MES_SHIFT_PRD'], - // columns: baseColumns['MES_SHIFT_PRD'], - // maxHeight: 550, - // formConfig: { - // labelWidth: 140, - // schemas: searchForms['MES_SHIFT_PRD'], - // submitFunc: () => Search('MES_SHIFT_PRD', data, args[0]), //鑷畾涔夋煡璇㈡彁浜ゆ寜閽殑鏂规硶锛岃Е鍙戞煡璇㈡彁浜や簨浠� - // }, - // useSearchForm: false, - // showTableSetting: false, - // bordered: true, - // canResize: false, - // showIndexColumn: false, - // actionColumn: { - // width: 130, - // title: '鎿嶄綔', - // dataIndex: 'action', - // slots: { customRender: 'action' }, - // fixed: 'right', - // }, //鑷畾涔夋搷浣滃垪 - // }), }; }, /** @@ -332,10 +431,34 @@ * @return {*} */ SubmitAll: (data: Ref<any[]>, keyFieldValues: Ref<{}>, ...args) => { - const drawers = [ - { name: 'BAS_LABEL_VAR', code: 'LABEL_ID', type: 'one', keyName: 'BAS_LABEL_VAR', order: 'VAR_NAME' }, - // { name: 'MES_SHIFT_PRD', code: 'SFT_CODE', type: 'all', keyName: 'MES_SHIFT', order: '' }, - ]; + const cancel = args[0]; + const drawers = args[1]; + const label = args[2]['BaseForm']; + // const input: BasLabelTempInput ={ + // Label: undefined, + // LabelVar: undefined, + // LabelVarWo: undefined + // }; + const input: BasLabelTempInput = { + Label: { + ID: buildUUID(), + CREATE_USER: useUserStore().getUserInfo.userId as string, + UPDATE_USER: useUserStore().getUserInfo.userId as string, + GHOST_ROW: false, + AUTH_ORG: useUserStore().getUserInfo.orgCode, + AUTH_PROD: useUserStore().getUserInfo.prodCode, + AUTH_WH: '', + LABEL_CODE: label.LABEL_CODE, + LABEL_NAME: label.LABEL_NAME, + TEMP_TYPE: label.TEMP_TYPE, + TEMP_PATH: label.TEMP_PATH[0], + CUST_CODE: label.CUST_CODE, + PROD_CODE: label.PROD_CODE, + REMARK: '' + } as unknown as BAS_LABEL_TEMP, + LabelVars: {} as unknown as BAS_LABEL_VAR[], + LabelVarWos: {} as unknown as BAS_LABEL_VAR_WO[], + }; drawers.forEach((d) => { let where = `${d['code']} = '${keyFieldValues.value[d['code']]}'`; /* type: all-琛ㄧず闇�瑕乧ode鐨勬墍鏈夌殑鍊� */ @@ -344,32 +467,87 @@ } data.value[d['name']].map((item) => { item.ID = buildUUID(); - // if (d['name'] == 'MES_SHIFT') { - // item.SFT_BEGIN = tsToHHmm(item.SFT_BEGIN); - // item.SFT_END = tsToHHmm(item.SFT_END); - // } - // if (d['name'] == 'MES_SHIFT_PRD') { - // item.PRD_BEGIN = tsToHHmm(item.PRD_BEGIN); - // item.PRD_END = tsToHHmm(item.PRD_END); - // } }); - AddAfterDelete(d['name'], data.value[d['name']], where).then((action) => { - if (action.IsSuccessed) { - args[0](); - } - }); + if(d.name == 'BAS_LABEL_VAR'){ + input.LabelVars = data.value[d['name']]; + } + if(d.name == 'BAS_LABEL_VAR_WO'){ + input.LabelVarWos = data.value[d['name']]; + } }); + SaveLabelTemplate(input).then((action) => { + if (action.IsSuccessed) { + cancel(); + } + }); + }, + /** + * @description: 鑷畾涔夋柟娉� + * @param {string} type + * @param {array} args + * @return {*} + */ + CustFunc: (param: CustModalParams) => { + switch (param.cType) { + case 'BAS_LABEL_VAR': + case 'BAS_LABEL_VAR_WO': + return getFns[param.FnName](param) as Promise<any>; + // break; + default: + return new Promise((resolve, reject) => { + try { + (e) => {}; + resolve(true); + } catch { + reject(false); + } finally { + // args[0][0]({ confirmLoading: false }); + } + }); + // break; + } }, }; /* 浠ヤ笅鏄唴閮ㄦ柟娉曪紝涓峞xport */ /** - * @description: 琛ㄦ牸鍩烘湰瀛楁 + * @description: 鑷畾涔夋柟娉� * @return {*} */ - const baseColumns = { - BAS_LABEL_VAR: [ + const getFns: Record<string, FunctionType> = { + /** + * @description: 鏂板琛屾柟娉� + * @param {*} e + * @param {array} args + * @return {*} + */ + AddRow: (param: CustModalParams) => { + return new Promise((resolve, reject) => { + try { + console.log('AddRow'); + EditOperation( + param.data, + { ...param.values, ...param.others }, + { isUpdate: false }, + param.cType, + {}, + ); + } catch { + reject(false); + } + }); + }, + }; + + let columns: BasicColumn[] = []; + /** + * @description: 鑾峰彇琛ㄦ牸瀛楁Json + * @param {string} type + * @return {*} + */ + function GetBaseColumns(type: string, emit) { + columns = [ { dataIndex: 'LABEL_ID', title: '鏍囩妯℃澘ID', @@ -388,10 +566,62 @@ { dataIndex: 'VAR_TYPE', title: '鍙橀噺绫诲瀷', + edit: true, + editRule: true, ifShow: true, sorter: true, resizable: true, - customRender: ({ record }) => { + editComponent: 'ApiSelect', + editComponentProps: (column) => { + return { + api: GetEnum, + params: { name: 'BAS_LABEL_VAR+VAR_TYPEs' }, + resultField: 'Data', + labelField: unref(getLocale) == 'zh_CN' ? 'Desc' : 'Name', + valueField: 'Value', + onChange: (e, v) => { + if (e == 1) { + emit('opencust', { + data: column.record, + name: 'BAS_LABEL_VAR', + modalSchema: { + title: '杩囩▼鍙橀噺鍒楄〃', + schemas: [ + { + field: 'VAR_CODE', + component: 'Input', + label: '杩囩▼鍙橀噺缂栫爜', + colProps: { + span: 12, + }, + }, + ], + ItemColumns: [ + { + title: t('杩囩▼鍙橀噺缂栫爜'), + dataIndex: 'VAR_CODE', + resizable: true, + sorter: true, + width: 200, + }, + { + title: t('杩囩▼鍙橀噺鍚嶇О'), + dataIndex: 'VAR_NAME', + resizable: true, + sorter: true, + width: 180, + }, + ], + tableName: 'BAS_LABEL_PV', + rowKey: 'VAR_CODE', + searchInfo: { TABLE_NAME: 'BAS_LABEL_PV' }, + }, + }); + } + }, + }; + }, + editRender: ({ record }) => { let color = ''; let text = ''; switch (record.VAR_TYPE) { @@ -415,105 +645,97 @@ return h(Tooltip, { title: text }, () => h(Tag, { color: color }, () => text)); }, }, + ]; + switch (type) { + case 'BAS_LABEL_VAR': + columns = [ + ...columns, + ...[ + { + dataIndex: 'VAR_VALUE', + title: '鍙橀噺鍊�', + edit: true, + // editable: true, + editRule: true, + ifShow: (column) => true, + sorter: true, + resizable: true, + }, + { + dataIndex: 'REMARK', + title: '澶囨敞', + ifShow: true, + sorter: true, + resizable: true, + }, + ], + ] as BasicColumn[]; + break; + } + return columns; + } + + /** + * @description: 琛ㄦ牸鍩烘湰瀛楁 + * @return {*} + */ + const baseColumns = { + BAS_LABEL_VAR: [], + BAS_LABEL_VAR_WO: [ + { + dataIndex: 'LABEL_ID', + title: '鏍囩妯℃澘ID', + ifShow: false, + sorter: true, + resizable: true, + }, + { + title: '宸ュ崟鍙�', + dataIndex: 'WORK_ORDER', + edit: true, + editRule: true, + editable: true, + ifShow: true, + }, + { + dataIndex: 'VAR_NAME', + title: '鍙橀噺鍚嶇О', + edit: true, + editRule: true, + editable: true, + ifShow: true, + sorter: true, + resizable: true, + customRender: () => {}, + }, { dataIndex: 'VAR_VALUE', title: '鍙橀噺鍊�', + edit: true, + editRule: true, + editable: true, ifShow: true, sorter: true, resizable: true, }, { - dataIndex: 'REMARK', - title: '澶囨敞', - ifShow: true, - sorter: true, - resizable: true, - }, - ], - MES_SHIFT_PRD: [ - { - title: '鏃舵缂栫爜', - dataIndex: 'PRD_CODE', - // ifShow: false, - width: 180, - }, - { - title: '鏃舵鍚嶇О', - dataIndex: 'PRD_NAME', - }, - { - title: '鐝缂栫爜', - dataIndex: 'SFT_CODE', - }, - { - title: '鏃舵寮�濮嬫椂闂�', - dataIndex: 'PRD_BEGIN', - customRender: ({ record }) => { - return formatTime(new Date(record.PRD_BEGIN)); - }, - }, - { - title: '鏃舵缁撴潫鏃堕棿', - dataIndex: 'PRD_END', - customRender: ({ record }) => { - return formatTime(new Date(record.PRD_END)); - }, - }, - { - title: '鏄惁璺ㄥぉ', - dataIndex: 'IS_ACROSS', - customRender: ({ record }) => { - const type = record.IS_ACROSS; - var text = ''; - var color = 'green'; - switch (type) { - case 'Y': - text = '鏄�'; - break; - case 'N': - color = 'blue'; - text = '鍚�'; - break; - } - return h(Tag, { color: color }, () => text); - }, - }, - { - title: '鏄惁浼戞伅鏃舵', - dataIndex: 'IS_REST', - customRender: ({ record }) => { - const type = record.IS_REST; - var text = ''; - var color = 'green'; - switch (type) { - case 'Y': - text = '鏄�'; - break; - case 'N': - color = 'blue'; - text = '鍚�'; - break; - } - return h(Tag, { color: color }, () => text); - }, - }, - { - title: '鏃舵鎺掑簭', - dataIndex: 'SEQ', + title: '鏍囩妯℃澘棰勮鍦板潃', + dataIndex: 'LABEL_VIEW_PATH', + ifShow: false, }, { title: '澶囨敞', dataIndex: 'REMARK', }, - { - title: '鏇存柊鏃堕棿', - dataIndex: 'UPDATE_TIME', - }, - { - title: '鏇存柊浜�', - dataIndex: 'UPDATE_USER', - }, - ], + // { + // title: '鏇存柊鏃堕棿', + // dataIndex: 'UPDATE_TIME', + // }, + // { + // title: '鏇存柊浜�', + // dataIndex: 'UPDATE_USER', + // }, + ] as BasicColumn[], }; /** -- Gitblit v1.9.3