From 8cfe56d782e4f8cddf0fa8f0cff84a5b4034aa3d Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期日, 23 六月 2024 00:40:40 +0800 Subject: [PATCH] 一些优化 --- src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts | 124 ++++++++++++++++++++++++++++++----------- 1 files changed, 91 insertions(+), 33 deletions(-) diff --git a/src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts b/src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts index 28eb9f4..a303273 100644 --- a/src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts +++ b/src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts @@ -4,50 +4,108 @@ * @version: * @Date: 2024-06-19 20:34:27 * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-22 00:54:23 + * @LastEditTime: 2024-06-23 00:16:36 */ +import { Ref } from 'vue'; import { DeleteEntity } from '/@/api/tigerapi/system'; -import { ActionItem } from '/@/components/Table'; +import { ActionItem, BasicColumn } from '/@/components/Table'; import { isNullOrEmpty } from '/@/utils/is'; +import { buildUUID } from '/@/utils/uuid'; +import { useUserStore } from '/@/store/modules/user'; +import { formatToDateTime } from '/@/utils/dateUtil'; function _default() { + const ActionColumn: BasicColumn = { + width: 80, + title: '鎿嶄綔', + dataIndex: 'action', + slots: { customRender: 'action' }, + fixed: undefined, + }; + + const methods = { + EditOperation: (type: string, data: Ref<any[]>, d, u) => { + if (u.isUpdate) { + //鏇存柊 + var _data = data.value.map((item) => { + if (item['ID'] == d.ID) + return { + ...item, + DFT_CODE: d.DFT_CODE, + DFT_NAME: d.DFT_NAME, + DFT_LEVEL: d.DFT_LEVEL, + REMARK: d.REMARK, + }; + return item; + }); + data.value = _data; + } else { + //鏂板 + d.ID = buildUUID(); + d.CREATE_USER = useUserStore().getUserInfo.userId as string; + d.UPDATE_TIME = formatToDateTime(new Date()); + d.UPDATE_USER = useUserStore().getUserInfo.userId as string; + var _data2: any[] = []; + if (!isNullOrEmpty(data.value)) { + _data2 = data.value.map((item) => { + return item; + }); + } + _data2.push(d); + data.value = _data2; + } + }, + /** + * @description: 鑾峰彇鏂板鎸夐挳鐨勮涓� + * @return {*} + */ + CreateAction: () => { + return { + action: 'drawer', //drawer(鎵撳紑宸︿晶鎶藉眽妗�) | go(璺宠浆鍒版柊鐨勯〉闈�) + }; + }, + /** + * @description: 浜у搧缁戝畾宸ヨ壓璺嚎鎿嶄綔瀛楁鑷畾涔夋寜閽� + * @return {*} + */ + ActionItem: (params: Recordable<any>, data, ...args): ActionItem[] => { + data[1].popConfirm.confirm = DftGrpDel.bind(null, args, params); + return data; + }, + GetHomeUrl: () => { + const param = { ID: 'BAS_DEFECT_GRP', colSlots: [], crudColSlots: [] }; + return `/BAS_DEFECT_GRP/LC/${encodeURI(JSON.stringify(param))}`; + } + }; + /** - * @description: 浜у搧缁戝畾宸ヨ壓璺嚎鎿嶄綔瀛楁鑷畾涔夋寜閽� + * @description: 鑷畾涔夊垹闄ゆ柟娉� + * @param {Fn} args + * @param {*} params * @return {*} */ - function ActionItem(params: Recordable<any>, data, ...args): ActionItem[] { - data[1].popConfirm.confirm = DftGrpDel.bind(null, args, params); - return data; + function DftGrpDel(args: Fn[], params: {}) { + if (!isNullOrEmpty(params['data'])) { + var _data = params['data'].value.filter((item) => item['ID'] != params['record']['ID']); + params['data'].value = _data; + args[6]({ + dataSource: [], + }); + args[6]({ + dataSource: params['data'], + }); + args[1](); + } else { + DeleteEntity(params['record'], params['entityName']).then((action) => { + if (action.IsSuccessed) { + args[1](); + } + }); + } } -/** - * @description: 鑷畾涔夊垹闄ゆ柟娉� - * @param {Fn} args - * @param {*} params - * @return {*} - */ -function DftGrpDel(args: Fn[], params: {}) { - if (!isNullOrEmpty(params['data'])) { - var _data = params['data'].value.filter((item) => item['ID'] != params['record']['ID']); - params['data'].value = _data; - args[6]({ - dataSource: [], - }); - args[6]({ - dataSource: params['data'], - }); - args[1](); - } else { - DeleteEntity(params['record'], params['entityName']).then((action) => { - if (action.IsSuccessed) { - args[1](); - } - }); - } -} - - return [ActionItem]; + return [methods, ActionColumn]; } export default _default; -- Gitblit v1.9.3