From 6e6fec028ffc9a27b3c8d30eb484cd361a119d76 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期一, 25 十一月 2024 23:53:12 +0800 Subject: [PATCH] 入库单更新 --- src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts | 458 +++++++++++++++++++++++++++++++------------------------- 1 files changed, 253 insertions(+), 205 deletions(-) diff --git a/src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts b/src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts index 53c0ee9..b38697d 100644 --- a/src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts +++ b/src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts @@ -4,18 +4,20 @@ * @version: * @Date: 2024-06-19 20:34:27 * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-26 03:13:41 + * @LastEditTime: 2024-07-04 11:21:28 */ import { Ref, h, unref } from 'vue'; import { DeleteEntity, GetEnum, getEntity } from '/@/api/tigerapi/system'; -import { ActionItem, BasicColumn } from '/@/components/Table'; +import { ActionItem, BasicColumn, FormSchema, useTable } from '/@/components/Table'; import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is'; import { buildUUID } from '/@/utils/uuid'; import { useUserStore } from '/@/store/modules/user'; import { formatToDateTime } from '/@/utils/dateUtil'; import { Tag } from 'ant-design-vue'; import { useLocale } from '/@/locales/useLocale'; +import { useDrawer } from '/@/components/Drawer'; +import { EditOperation, Search, custDel } from '../data'; const { getLocale } = useLocale(); function _default() { @@ -26,13 +28,17 @@ slots: { customRender: 'action' }, fixed: undefined, }; - + + /** + * @description: 浜涜嚜瀹氫箟鏂规硶 + * @return {*} + */ const methods = { /** * @description: 鑾峰彇鏂板鎸夐挳鐨勮涓� * @return {*} */ - CreateAction: (fnName: string) => { + CreateAction: (type: string) => { return { action: 'drawer', //drawer(鎵撳紑宸︿晶鎶藉眽妗�) | go(璺宠浆鍒版柊鐨勯〉闈�) }; @@ -43,7 +49,7 @@ */ ActionItem: (params: Recordable<any>, data, ...args): ActionItem[] => { if (!isNullOrUnDef(data[1])) { - data[1].popConfirm.confirm = DftGrpDel.bind(null, args, params); + data[1].popConfirm.confirm = custDel.bind(null, args, params); } return data; }, @@ -55,151 +61,14 @@ const param = { ID: 'BAS_DEFECT_GRP', colSlots: [], crudColSlots: [] }; return `/BAS_DEFECT_GRP/LC/${encodeURI(JSON.stringify(param))}`; }, - GetBaseColumns: () => { - return [ - { - title: '涓嶈壇浠g爜缂栫爜', - dataIndex: 'DFT_CODE', - // ifShow: false, - width: 180, - }, - { - title: '涓嶈壇浠g爜鍚嶇О', - dataIndex: 'DFT_NAME', - }, - { - title: '缂洪櫡绛夌骇', - dataIndex: 'DFT_LEVEL', - customRender: ({ record }) => { - const type = record.DFT_LEVEL; - var text = ''; - var color = 'green'; - switch (type) { - case 0: - text = '杞诲井缂洪櫡'; - break; - case 1: - color = 'blue'; - text = '涓ラ噸缂洪櫡'; - break; - case 2: - color = 'red'; - text = '鑷村懡缂洪櫡'; - break; - } - return h(Tag, { color: color }, () => text); - }, - }, - { - title: '涓嶈壇浠g爜缁勭紪鐮�', - dataIndex: 'DFTG_CODE', - }, - { - title: '澶囨敞', - dataIndex: 'REMARK', - }, - { - title: '鏇存柊鏃堕棿', - dataIndex: 'UPDATE_TIME', - }, - { - title: '鏇存柊浜�', - dataIndex: 'UPDATE_USER', - }, - ]; + GetBaseColumns: (type: string) => { + return baseColumns[type]; }, - GetSearchForm: () => { - return [ - { - field: 'DFT_CODE', - label: '涓嶈壇浠g爜缂栫爜', - component: 'Input', - colProps: { - span: 8, - }, - }, - { - label: '涓嶈壇浠g爜鍚嶇О', - field: 'DFT_NAME', - component: 'Input', - colProps: { - span: 8, - }, - }, - ]; + GetSearchForm: (type: string) => { + return searchForms[type]; }, - GetCrudForm: () => { - return [ - { - field: 'DFT_CODE', - label: '涓嶈壇浠g爜缂栫爜', - component: 'Input', - required: true, - colProps: { - span: 24, - }, - }, - { - label: '涓嶈壇浠g爜鍚嶇О', - field: 'DFT_NAME', - component: 'Input', - required: true, - colProps: { - span: 24, - }, - }, - { - label: '涓嶈壇浠g爜缁勭紪鐮�', - field: 'DFTG_CODE', - component: 'ApiSelect', - colProps: { - span: 24, - }, - componentProps: { - api: getEntity, - params: { entityName: 'BAS_DEFECT_GRP', sqlcmd: ' 1=1 ' }, - resultField: 'Data.Items', - labelField: 'DFTG_NAME', - valueField: 'DFTG_CODE', - }, - dynamicDisabled: ({ values }) => { - return true; - }, - }, - { - label: '缂洪櫡绛夌骇', - field: 'DFT_LEVEL', - component: 'ApiSelect', - required: true, - colProps: { - span: 24, - }, - componentProps: { - api: GetEnum, - params: { name: 'BAS_DEFECT+DFT_LEVELs' }, - resultField: 'Data', - labelField: unref(getLocale) == 'zh_CN' ? 'Desc' : 'Name', - valueField: 'Value', - }, - }, - { - label: '澶囨敞', - field: 'REMARK', - component: 'Input', - colProps: { - span: 24, - }, - }, - { - label: 'ID', - field: 'ID', - component: 'Input', - colProps: { - span: 24, - }, - show: false, - }, - ]; + GetCrudForm: (type: string) => { + return crudForms[type]; }, GetBaseForm: () => { return [ @@ -240,7 +109,11 @@ }, ]; }, - GetBaseCards: () => { + /** + * @description: 鑾峰彇鍗$墖鍐呴厤缃垪琛紝浠ュ惊鐜樉绀哄涓崱鐗囧苟閰嶇疆澶氫釜鎻掓Ы + * @return {*} + */ + GetBaseCards: (type: string) => { return [ { name: 'BaseForm', @@ -258,7 +131,68 @@ // { name: 'rotinfo', slots: ['add'], preIcons: { add: 'search|svg' }, title: '宸ヨ壓淇℃伅' }, ]; }, - OthersValues: (val: string, id: string) => { + /** + * @description: 鑾峰彇鍙充晶杈规use鏂规硶 + * @return {*} + */ + GetUseDrawers: () => { + return [{ + 'BAS_DEFECT': useDrawer(), + }]; + }, + /** + * @description: 鑾峰彇琛ㄦ牸use鍒楄〃 + * @param {string} type + * @param {array} args + * @return {*} + */ + GetUseTables: (data: Ref<{}>, ...args) => { + return { + BAS_DEFECT: useTable({ + title: '鍒楄〃淇℃伅', + dataSource: data.value['BAS_DEFECT'], + columns: baseColumns['BAS_DEFECT'], + formConfig: { + labelWidth: 140, + schemas: searchForms['BAS_DEFECT'], + submitFunc: () => Search('BAS_DEFECT', data, args[0]), //鑷畾涔夋煡璇㈡彁浜ゆ寜閽殑鏂规硶锛岃Е鍙戞煡璇㈡彁浜や簨浠� + }, + useSearchForm: true, + showTableSetting: false, + bordered: true, + canResize: true, + showIndexColumn: false, + actionColumn: { + width: 130, + title: '鎿嶄綔', + dataIndex: 'action', + slots: { customRender: 'action' }, + fixed: 'right', + }, //鑷畾涔夋搷浣滃垪 + }) + }; + }, + /** + * @description: 琛ㄦ牸鏌ヨ鍥炶皟锛岀埗缁勪欢涓�氳繃瀛愮粍浠惰Е鍙戠殑浜嬩欢鑾峰彇浼犲叆鐨勫�硷紝鍋氬叿浣撶殑鏌ヨ閫昏緫瀹炵幇 + * @param {*} d + * @return {*} + */ + FormSearch: (d) => { + let data = {} as any; + switch (d.type) { + case 'BAS_DEFECT': + data = d.data.value[d.type].filter( + (item) => + item.DFT_CODE.includes(d.values.DFT_CODE) || item.DFT_NAME == d.values.DFT_NAME, + ); + if (isNullOrEmpty(d.values.DFT_CODE) && isNullOrEmpty(d.values.DFT_NAME)) { + data = d.data.value[d.type]; + } + break; + } + return data; + }, + KeyFieldValues: (val: string, id: string) => { return { DFTG_CODE: val }; } /** * @description: 鑷畾涔夋槑缁嗚〃涓紪杈戣繑鍥炴柟娉� @@ -267,36 +201,20 @@ * @param {*} u * @return {*} */, - EditOperation: (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; - } + EditOperation: (data: Ref<any[]>, d, u, item) => { + //鏇存柊 + var _data = data.value[item].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; + }); + EditOperation(data,d, u, item, _data); }, /** * @description: 鑾峰彇鏍囬淇℃伅 @@ -307,35 +225,165 @@ return { pageTitle: '涓嶈壇浠g爜缁勭鐞�', pageContent: '杩欓噷鍙互娣诲姞鍜屼慨鏀逛笉鑹唬鐮佺粍鍜屼笉鑹唬鐮併��', - baseTableTitle: '涓嶈壇浠g爜绠$悊', + tableTitle: { + BAS_DEFECT: '涓嶈壇浠g爜绠$悊', + } }; + }, + GetUseForm: () => { + return {}; }, }; - /** - * @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](); - } - }); - } + /* 浠ヤ笅鏄唴閮ㄦ柟娉曪紝涓峞xport锛屼緵涓婇潰鐨勬柟娉曡皟鐢� */ + + const baseColumns = { + BAS_DEFECT: [ + { + title: '涓嶈壇浠g爜缂栫爜', + dataIndex: 'DFT_CODE', + // ifShow: false, + width: 180, + }, + { + title: '涓嶈壇浠g爜鍚嶇О', + dataIndex: 'DFT_NAME', + }, + { + title: '缂洪櫡绛夌骇', + dataIndex: 'DFT_LEVEL', + customRender: ({ record }) => { + const type = record.DFT_LEVEL; + var text = ''; + var color = 'green'; + switch (type) { + case 0: + text = '杞诲井缂洪櫡'; + break; + case 1: + color = 'blue'; + text = '涓ラ噸缂洪櫡'; + break; + case 2: + color = 'red'; + text = '鑷村懡缂洪櫡'; + break; + } + return h(Tag, { color: color }, () => text); + }, + }, + { + title: '涓嶈壇浠g爜缁勭紪鐮�', + dataIndex: 'DFTG_CODE', + }, + { + title: '澶囨敞', + dataIndex: 'REMARK', + }, + { + title: '鏇存柊鏃堕棿', + dataIndex: 'UPDATE_TIME', + }, + { + title: '鏇存柊浜�', + dataIndex: 'UPDATE_USER', + }, + ] + } + + const searchForms = { + BAS_DEFECT: [ + { + field: 'DFT_CODE', + label: '涓嶈壇浠g爜缂栫爜', + component: 'Input', + colProps: { + span: 8, + }, + }, + { + label: '涓嶈壇浠g爜鍚嶇О', + field: 'DFT_NAME', + component: 'Input', + colProps: { + span: 8, + }, + }, + ] as FormSchema[], + } + + const crudForms = { + BAS_DEFECT: [ + { + field: 'DFT_CODE', + label: '涓嶈壇浠g爜缂栫爜', + component: 'Input', + required: true, + colProps: { + span: 24, + }, + }, + { + label: '涓嶈壇浠g爜鍚嶇О', + field: 'DFT_NAME', + component: 'Input', + required: true, + colProps: { + span: 24, + }, + }, + { + label: '涓嶈壇浠g爜缁勭紪鐮�', + field: 'DFTG_CODE', + component: 'ApiSelect', + colProps: { + span: 24, + }, + componentProps: { + api: getEntity, + params: { entityName: 'BAS_DEFECT_GRP', sqlcmd: ' 1=1 ' }, + resultField: 'Data.Items', + labelField: 'DFTG_NAME', + valueField: 'DFTG_CODE', + }, + dynamicDisabled: ({ values }) => { + return true; + }, + }, + { + label: '缂洪櫡绛夌骇', + field: 'DFT_LEVEL', + component: 'ApiSelect', + required: true, + colProps: { + span: 24, + }, + componentProps: { + api: GetEnum, + params: { name: 'BAS_DEFECT+DFT_LEVELs' }, + resultField: 'Data', + labelField: unref(getLocale) == 'zh_CN' ? 'Desc' : 'Name', + valueField: 'Value', + }, + }, + { + label: '澶囨敞', + field: 'REMARK', + component: 'Input', + colProps: { + span: 24, + }, + }, + { + label: 'ID', + field: 'ID', + component: 'Input', + colProps: { + span: 24, + }, + show: false, + }, + ] as FormSchema[], } return [methods, ActionColumn]; -- Gitblit v1.9.3