From 200eb764e83c7a77defeaf98130801d300dbee5d Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期日, 23 六月 2024 18:42:33 +0800 Subject: [PATCH] 高级表单优化 --- /dev/null | 252 -------- src/views/tigerprojects/system/lowcode/high/baseForm.vue | 66 ++ src/views/tigerprojects/system/lowcode/high/dtl.vue | 323 ++++++++++ src/views/tigerprojects/system/lowcode/entityts/BAS_REASON.ts | 221 ++++++ src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts | 254 ++++++++ src/views/tigerprojects/system/lowcode/data.ts | 167 ----- src/views/tigerprojects/system/lowcode/high/index.vue | 362 +---------- src/views/tigerprojects/system/lowcode/entityts/BAS_PKG_DTL.ts | 214 ++++++ 8 files changed, 1,102 insertions(+), 757 deletions(-) diff --git a/src/views/tigerprojects/system/lowcode/basPkgrule.ts b/src/views/tigerprojects/system/lowcode/basPkgrule.ts deleted file mode 100644 index 09dff12..0000000 --- a/src/views/tigerprojects/system/lowcode/basPkgrule.ts +++ /dev/null @@ -1,200 +0,0 @@ -import { ActionItem, BasicColumn, FormSchema } from '/@/components/Table'; -import { useMessage } from '/@/hooks/web/useMessage'; -import { useI18n } from '/@/hooks/web/useI18n'; -import { getEntity } from '/@/api/tigerapi/system'; -import { Ref } from 'vue'; -import { buildUUID } from '/@/utils/uuid'; -import { useUserStore } from '/@/store/modules/user'; -import { formatToDateTime } from '/@/utils/dateUtil'; -import { isNullOrEmpty } from '/@/utils/is'; - -const { t } = useI18n(); -const { notification } = useMessage(); - -/** - * @description: 鍖呰瑙勫垯涓诲熀鏈俊鎭〃鍗曞瓧娈� - * @return {*} - */ -export const pkgBaseSchema: FormSchema[] = [ - { - field: 'RULE_CODE', - label: '鍖呰瑙勫垯缂栫爜', - component: 'Input', - required: true, - colProps: { - span: 8, - }, - }, - { - label: '鍖呰瑙勫垯鍚嶇О', - field: 'RULE_NAME', - required: true, - component: 'Input', - colProps: { - span: 8, - }, - }, - { - label: '鏄惁鍚敤', - field: 'IS_ACTIVE', - required: true, - component: 'Select', - colProps: { - span: 8, - }, - componentProps: { - options: [ - { - label: '鍚敤', - value: 'Y', - key: 'Y', - }, - { - label: '绂佺敤', - value: 'N', - key: 'N', - }, - ], - }, - }, - { - label: '澶囨敞', - field: 'REMARK', - component: 'Input', - colProps: { - span: 8, - }, - }, - { - label: 'ID', - field: 'ID', - component: 'Input', - colProps: { - span: 8, - }, - show: false, - }, - ]; - - /** - * @description: 鍖呰瑙勫垯鏄庣粏鏌ヨ瀛楁 - * @return {*} - */ -export const pkgSearchSchema: FormSchema[] = [ - { - field: 'PKG_CODE', - label: '鍖呰瑙勫垯缂栫爜', - component: 'Input', - colProps: { - span: 8, - }, - }, - ]; - -/** - * @description: 鍖呰瑙勫垯澧炲垹鏀瑰瓧娈� - * @return {*} - */ -export const pkgCrudSchema: FormSchema[] = [ - { - field: 'PKG_CODE', - label: '鍖呰/杞藉叿缂栫爜', - component: 'ApiSelect', - required: true, - colProps: { - span: 24, - }, - componentProps: { - api: getEntity, - params: { entityName: 'BAS_PKG_TYPE', sqlcmd: ' 1=1 ' }, - resultField: 'Data.Items', - labelField: 'PKG_NAME', - valueField: 'PKG_CODE', - }, - }, - { - label: '鍖呰灞傜骇', - field: 'PKG_LEVEL', - component: 'Input', - required: true, - colProps: { - span: 24, - }, - }, - { - label: '鍖呰瑙勫垯ID', - field: 'PKG_RULE_ID', - component: 'Input', - colProps: { - span: 24, - }, - dynamicDisabled: ({ values }) => { - return true; - }, - }, - { - label: '鍖呰鏁伴噺', - field: 'PKG_QTY', - component: 'Input', - colProps: { - span: 24, - }, - }, - { - label: '澶囨敞', - field: 'REMARK', - component: 'Input', - colProps: { - span: 24, - }, - }, - { - label: 'ID', - field: 'ID', - component: 'Input', - colProps: { - span: 24, - }, - show: false, - }, - ]; - - /** - * @description: 鍖呰瑙勫垯鏄庣粏琛ㄦ牸鍒� - * @return {*} - */ - export const pkgBaseColumn: BasicColumn[] = [ - { - title: '鍖呰/杞藉叿缂栫爜', - dataIndex: 'PKG_CODE', - // ifShow: false, - width: 180, - }, - { - title: '鍖呰灞傜骇', - dataIndex: 'PKG_LEVEL', - }, - { - title: '鍖呰鏁伴噺', - dataIndex: 'PKG_QTY', - }, - { - title: '鍖呰瑙勫垯ID', - dataIndex: 'PKG_RULE_ID', - ifShow: false, - }, - { - title: '澶囨敞', - dataIndex: 'REMARK', - }, - { - title: '鏇存柊鏃堕棿', - dataIndex: 'UPDATE_TIME', - }, - { - title: '鏇存柊浜�', - dataIndex: 'UPDATE_USER', - }, - ]; - - diff --git a/src/views/tigerprojects/system/lowcode/data.ts b/src/views/tigerprojects/system/lowcode/data.ts index d3863c8..c9ff488 100644 --- a/src/views/tigerprojects/system/lowcode/data.ts +++ b/src/views/tigerprojects/system/lowcode/data.ts @@ -31,38 +31,17 @@ * @LastEditTime: 2024-06-14 09:08:11 */ -import { - baseSchema, - searchSchema, - defectBaseColumn, - crudSchema, -} from './normal/basDefectGrp'; -import { - onChangeFns, - rsnBaseSchema, - rsnCrudSchema, - rsnSearchSchema, - rsnBaseColumn, -} from './normal/basReasonGrp'; -import { DeleteEntity, convertToTree, getEntity } from '/@/api/tigerapi/system'; import { ActionItem, BasicColumn, FormSchema } from '/@/components/Table'; import { useI18n } from '/@/hooks/web/useI18n'; import { isNullOrEmpty } from '/@/utils/is'; import { woCustFn, woformSchema } from '/@/views/components/bizMesWo'; import { useModal } from '/@/components/Modal'; -import { - pkgBaseColumn, - pkgBaseSchema, - pkgCrudSchema, - pkgSearchSchema, -} from './basPkgrule'; -import { GetRoutePTree } from '/@/api/tigerapi/mes/router'; const { t } = useI18n(); /** * @description: 浣庝唬鐮侀〉闈㈣幏鍙栨搷浣滃瓧娈电粨鏋凧son锛屽澧炲姞鎸夐挳鍙婃柟娉� * 鏀荤暐: - * 1. 鍙︽柊寤洪┘宄板疄浣撳悕.ts鐨勬枃浠讹紝濡傦細basDefectGrp.ts銆備互渚垮尯鍒笉鍚岄〉闈㈢殑鏂规硶 + * 1. 鍙︽柊寤洪┘宄板疄浣撳悕.ts鐨勬枃浠讹紝濡傦細BAS_REASON.ts銆備互渚垮尯鍒笉鍚岄〉闈㈢殑鏂规硶 * 2. 鏇挎崲涓婚〉闈㈢紪杈戞寜閽柟娉曞彉涓鸿烦杞埌楂樼骇椤甸潰锛屾柟娉曚腑浼犲叆 { CODE: 涓昏〃璁板綍鐨勫叧閿瓧娈靛�硷紝涓�鑸槸XXX_CODE鐨勫��, ID: 褰撳墠璁板綍鐨処D, Name: 'BAS_DEFECT'锛堣烦杞繃鍘婚渶瑕佹柊澧炵紪杈戠殑瀹炰綋鍚嶏級, Title: `缂栬緫涓嶈壇浠g爜缁勶細${params['record']['DFTG_CODE']}`锛堝畾涔塼ab椤电鐨勬爣棰橈級, pCode: 'DFTG_CODE'锛堜富琛ㄧ殑鍏抽敭瀛楁浠g爜锛� } * 鏇挎崲涓婚〉闈㈡柊澧炴寜閽柟娉曞悓涓� * 3. 鍦ㄨ彍鍗曠鐞嗘柊寤轰竴涓珮绾ч〉闈€�� @@ -107,7 +86,7 @@ if (!isNullOrEmpty(fnName)) { switch (entityName) { case 'BAS_REASON': - onChangeFns[fnName](e); + // onChangeFns[fnName](e); break; default: break; @@ -182,128 +161,10 @@ case 'BIZ_MES_WO': _formSchema = woformSchema; break; - case 'BAS_DEFECT_BaseForm': - _formSchema = baseSchema; - break; - case 'BAS_DEFECT_Search': - _formSchema = searchSchema; - break; - case 'BAS_DEFECT_Crud': - _formSchema = crudSchema; - break; - case 'BAS_REASON_BaseForm': - _formSchema = rsnBaseSchema; - break; - case 'BAS_REASON_Search': - _formSchema = rsnSearchSchema; - break; - case 'BAS_REASON_Crud': - _formSchema = rsnCrudSchema; - break; - case 'BAS_PKG_DTL_BaseForm': - _formSchema = pkgBaseSchema; - break; - case 'BAS_PKG_DTL_Search': - _formSchema = pkgSearchSchema; - break; - case 'BAS_PKG_DTL_Crud': - _formSchema = pkgCrudSchema; - break; default: break; } return _formSchema; -} - -/** - * @description: 鑾峰彇琛ㄦ牸鍒� - * @param {string} entityName - * @return {*} - */ -export function GetBasicColumnAndInit(entityName: string, ...args) { - let data: BasicColumn[] = []; - switch (entityName) { - case 'BAS_DEFECT': - data = defectBaseColumn; - args[0].value[entityName] = getFormSchema(entityName); - args[0].value['BaseForm'] = getFormSchema('BAS_DEFECT_BaseForm'); - args[1].value = { - BaseForm: args[4]({ - labelWidth: 120, - schemas: args[0].value['BaseForm'], - actionColOptions: { - span: 24, - }, - showActionButtonGroup: false, - }), - }; - args[2].value = [ - { - name: 'BaseForm', - slots: [], - preIcons: {}, - title: '涓嶈壇浠g爜缁勪俊鎭�', - entityName: 'BAS_DEFECT_GRP', - }, - // { - // name: 'prodinfo', - // slots: ['addRot', 'setRot'], - // preIcons: { addRot: 'search|svg', setRot: 'config|svg' }, - // title: '浜у搧淇℃伅', - // }, - // { name: 'rotinfo', slots: ['add'], preIcons: { add: 'search|svg' }, title: '宸ヨ壓淇℃伅' }, - ]; - break; - case 'BAS_REASON': - data = rsnBaseColumn; - args[0].value['BaseForm'] = getFormSchema('BAS_REASON_BaseForm'); - args[1].value = { - BaseForm: args[4]({ - labelWidth: 120, - schemas: args[0].value['BaseForm'], - actionColOptions: { - span: 24, - }, - showActionButtonGroup: false, - }), - }; - args[2].value = [ - { - name: 'BaseForm', - slots: [], - preIcons: {}, - title: '涓嶈壇鍘熷洜缁勪俊鎭�', - entityName: 'BAS_REASON_GRP', - }, - ]; - break; - case 'BAS_PKG_DTL': - data = pkgBaseColumn; - args[0].value['BaseForm'] = getFormSchema('BAS_PKG_DTL_BaseForm'); - args[1].value = { - BaseForm: args[4]({ - labelWidth: 120, - schemas: args[0].value['BaseForm'], - actionColOptions: { - span: 24, - }, - showActionButtonGroup: false, - }), - }; - args[2].value = [ - { - name: 'BaseForm', - slots: [], - preIcons: {}, - title: '鍖呰淇℃伅', - entityName: 'BAS_PKG_RULE', - }, - ]; - break; - default: - break; - } - return data; } /** @@ -339,28 +200,4 @@ break; } return title; -} - -/** - * @description: 鑾峰彇闇�瑕佹柊澧炴椂灏遍粯璁ょ殑鍊硷紝涓�鑸槸涓昏〃淇℃伅 - * @param {string} type - * @param {string} val - * @return {*} - */ -export function getOthersValues(type: string, val: string, id: string) { - let Values = {}; - switch (type) { - case 'BAS_DEFECT': - Values = { DFTG_CODE: val }; - break; - case 'BAS_REASON': - Values = { RSNG_CODE: val }; - break; - case 'BAS_PKG_DTL': - Values = { PKG_RULE_ID: id }; - break; - default: - break; - } - return Values; } diff --git a/src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts b/src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts index a303273..0af4dc8 100644 --- a/src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts +++ b/src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts @@ -4,17 +4,20 @@ * @version: * @Date: 2024-06-19 20:34:27 * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-23 00:16:36 + * @LastEditTime: 2024-06-23 18:41:06 */ -import { Ref } from 'vue'; -import { DeleteEntity } from '/@/api/tigerapi/system'; +import { Ref, h, unref } from 'vue'; +import { DeleteEntity, GetEnum, getEntity } from '/@/api/tigerapi/system'; 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'; +import { Tag } from 'ant-design-vue'; +import { useLocale } from '/@/locales/useLocale'; +const { getLocale } = useLocale(); function _default() { const ActionColumn: BasicColumn = { width: 80, @@ -76,7 +79,250 @@ GetHomeUrl: () => { 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', + }, + ]; + }, + GetSearchForm: () => { + return [ + { + field: 'DFT_CODE', + label: '涓嶈壇浠g爜缂栫爜', + component: 'Input', + colProps: { + span: 8, + }, + }, + { + label: '涓嶈壇浠g爜鍚嶇О', + field: 'DFT_NAME', + component: 'Input', + colProps: { + span: 8, + }, + }, + ]; + }, + 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, + }, + ]; + }, + GetBaseForm: () => { + return [ + { + field: 'DFTG_CODE', + label: '涓嶈壇浠g爜缁勭紪鐮�', + component: 'Input', + required: true, + colProps: { + span: 8, + }, + }, + { + label: '涓嶈壇浠g爜缁勫悕绉�', + field: 'DFTG_NAME', + required: true, + component: 'Input', + colProps: { + span: 8, + }, + }, + { + label: '澶囨敞', + field: 'REMARK', + component: 'Input', + colProps: { + span: 8, + }, + }, + { + label: 'ID', + field: 'ID', + component: 'Input', + colProps: { + span: 8, + }, + show: false, + }, + ]; + }, + GetBaseCards: () => { + return [ + { + name: 'BaseForm', + slots: [], + preIcons: {}, + title: '涓嶈壇浠g爜缁勪俊鎭�', + entityName: 'BAS_DEFECT_GRP', + }, + // { + // name: 'prodinfo', + // slots: ['addRot', 'setRot'], + // preIcons: { addRot: 'search|svg', setRot: 'config|svg' }, + // title: '浜у搧淇℃伅', + // }, + // { name: 'rotinfo', slots: ['add'], preIcons: { add: 'search|svg' }, title: '宸ヨ壓淇℃伅' }, + ]; + }, + OthersValues: (val: string, id: string) => { + return { DFTG_CODE: val }; + },/** + * @description: 鑷畾涔夋槑缁嗚〃涓紪杈戣繑鍥炴柟娉� + * @param {string} type + * @param {*} d + * @param {*} u + * @return {*} + */ + EditeOperation:(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; + } + } }; /** diff --git a/src/views/tigerprojects/system/lowcode/entityts/BAS_PKG_DTL.ts b/src/views/tigerprojects/system/lowcode/entityts/BAS_PKG_DTL.ts index 8dd0f38..b039ce2 100644 --- a/src/views/tigerprojects/system/lowcode/entityts/BAS_PKG_DTL.ts +++ b/src/views/tigerprojects/system/lowcode/entityts/BAS_PKG_DTL.ts @@ -4,18 +4,18 @@ * @version: * @Date: 2024-06-19 20:34:27 * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-23 00:22:36 + * @LastEditTime: 2024-06-23 18:28:00 */ import { Ref } from 'vue'; -import { DeleteEntity } from '/@/api/tigerapi/system'; +import { DeleteEntity, getEntity } from '/@/api/tigerapi/system'; 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() { +function _default(): any[] { /** * @description: 鑷畾涔夊垹闄ゆ柟娉� * @param {Fn} args @@ -65,7 +65,7 @@ * @return {*} */ ActionItem: (params: Recordable<any>, data, ...args): ActionItem[] => { - data[1].popConfirm.confirm = custDel.bind(null, args[1], params); + data[1].popConfirm.confirm = custDel.bind(null, args, params); return data; }, /** @@ -109,7 +109,211 @@ }, GetHomeUrl: () => { return `/BAS_PKG_RULE/LC/${encodeURI(JSON.stringify({ ID: 'BAS_PKG_RULE', colSlots: [], crudColSlots: [] }))}`; - } + }, + /** + * @description: 楂樼骇琛ㄥ崟鏄庣粏琛ㄦ牸瀛楁 + * @return {*} + */ + GetBaseColumns: () => { + return [ + { + title: '鍖呰/杞藉叿缂栫爜', + dataIndex: 'PKG_CODE', + // ifShow: false, + width: 180, + }, + { + title: '鍖呰灞傜骇', + dataIndex: 'PKG_LEVEL', + }, + { + title: '鍖呰鏁伴噺', + dataIndex: 'PKG_QTY', + }, + { + title: '鍖呰瑙勫垯ID', + dataIndex: 'PKG_RULE_ID', + ifShow: false, + }, + { + title: '澶囨敞', + dataIndex: 'REMARK', + }, + { + title: '鏇存柊鏃堕棿', + dataIndex: 'UPDATE_TIME', + }, + { + title: '鏇存柊浜�', + dataIndex: 'UPDATE_USER', + }, + ]; + }, + /** + * @description: 楂樼骇琛ㄥ崟鏌ヨ鏉′欢瀛楁 + * @return {*} + */ + GetSearchForm: () => { + return [ + { + field: 'PKG_CODE', + label: '鍖呰瑙勫垯缂栫爜', + component: 'Input', + colProps: { + span: 8, + }, + }, + ]; + }, + /** + * @description: 楂樼骇琛ㄥ崟澧炲垹鏀硅〃鍗曞瓧娈� + * @return {*} + */ + GetCrudForm: () => { + return [ + { + field: 'PKG_CODE', + label: '鍖呰/杞藉叿缂栫爜', + component: 'ApiSelect', + required: true, + colProps: { + span: 24, + }, + componentProps: { + api: getEntity, + params: { entityName: 'BAS_PKG_TYPE', sqlcmd: ' 1=1 ' }, + resultField: 'Data.Items', + labelField: 'PKG_NAME', + valueField: 'PKG_CODE', + }, + }, + { + label: '鍖呰灞傜骇', + field: 'PKG_LEVEL', + component: 'Input', + required: true, + colProps: { + span: 24, + }, + }, + { + label: '鍖呰瑙勫垯ID', + field: 'PKG_RULE_ID', + component: 'Input', + colProps: { + span: 24, + }, + dynamicDisabled: ({ values }) => { + return true; + }, + }, + { + label: '鍖呰鏁伴噺', + field: 'PKG_QTY', + component: 'Input', + colProps: { + span: 24, + }, + }, + { + label: '澶囨敞', + field: 'REMARK', + component: 'Input', + colProps: { + span: 24, + }, + }, + { + label: 'ID', + field: 'ID', + component: 'Input', + colProps: { + span: 24, + }, + show: false, + }, + ]; + }, + OthersValues: (val: string, id: string) => { + return { PKG_RULE_ID: id }; + }, + /** + * @description: 楂樼骇琛ㄥ崟涓诲熀鏈俊鎭瓧娈� + * @return {*} + */ + GetBaseForm: () => { + return [ + { + field: 'RULE_CODE', + label: '鍖呰瑙勫垯缂栫爜', + component: 'Input', + required: true, + colProps: { + span: 8, + }, + }, + { + label: '鍖呰瑙勫垯鍚嶇О', + field: 'RULE_NAME', + required: true, + component: 'Input', + colProps: { + span: 8, + }, + }, + { + label: '鏄惁鍚敤', + field: 'IS_ACTIVE', + required: true, + component: 'Select', + colProps: { + span: 8, + }, + componentProps: { + options: [ + { + label: '鍚敤', + value: 'Y', + key: 'Y', + }, + { + label: '绂佺敤', + value: 'N', + key: 'N', + }, + ], + }, + }, + { + label: '澶囨敞', + field: 'REMARK', + component: 'Input', + colProps: { + span: 8, + }, + }, + { + label: 'ID', + field: 'ID', + component: 'Input', + colProps: { + span: 8, + }, + show: false, + }, + ]; + }, + GetBaseCards: () => { + return [ + { + name: 'BaseForm', + slots: [], + preIcons: {}, + title: '鍖呰淇℃伅', + entityName: 'BAS_PKG_RULE', + }, + ]; + }, }; return [methods, ActionColumn]; diff --git a/src/views/tigerprojects/system/lowcode/entityts/BAS_REASON.ts b/src/views/tigerprojects/system/lowcode/entityts/BAS_REASON.ts index bb4dcce..39a3456 100644 --- a/src/views/tigerprojects/system/lowcode/entityts/BAS_REASON.ts +++ b/src/views/tigerprojects/system/lowcode/entityts/BAS_REASON.ts @@ -1,19 +1,28 @@ /* + * @Description: file content + * @Author: Ben Lin + * @version: + * @Date: 2024-06-22 00:58:43 + * @LastEditors: Ben Lin + * @LastEditTime: 2024-06-23 18:28:55 + */ +/* * @Description: 涓嶈壇鍘熷洜鐩稿叧 * @Author: Ben Lin * @version: * @Date: 2024-06-19 20:34:27 * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-23 00:21:58 + * @LastEditTime: 2024-06-23 18:12:40 */ -import { Ref } from 'vue'; -import { DeleteEntity } from '/@/api/tigerapi/system'; +import { Ref, h } from 'vue'; +import { DeleteEntity, getEntity } from '/@/api/tigerapi/system'; 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'; +import { Tag } from 'ant-design-vue'; function _default() { /** @@ -75,7 +84,7 @@ * @param {*} u * @return {*} */ - EditeOperation:( data: Ref<any[]>, d, u) => { + EditeOperation: (data: Ref<any[]>, d, u) => { if (u.isUpdate) { //鏇存柊 var _data = data.value.map((item) => { @@ -108,7 +117,209 @@ }, GetHomeUrl: () => { return `/BAS_REASON_GRP/LC/${encodeURI(JSON.stringify({ ID: 'BAS_REASON_GRP', colSlots: [], crudColSlots: [] }))}`; - } + }, + GetBaseColumns: () => { + return [ + { + title: '涓嶈壇鍘熷洜缂栫爜', + dataIndex: 'RSN_CODE', + // ifShow: false, + width: 180, + }, + { + title: '涓嶈壇鍘熷洜鍚嶇О', + dataIndex: 'RSN_NAME', + }, + { + title: '鏄惁蹇呴』鏇存崲闆朵欢', + dataIndex: 'NEED_REPLACE', + customRender: ({ record }) => { + const type = record.NEED_REPLACE; + 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: 'RSNG_CODE', + }, + { + title: '澶囨敞', + dataIndex: 'REMARK', + }, + { + title: '鏇存柊鏃堕棿', + dataIndex: 'UPDATE_TIME', + }, + { + title: '鏇存柊浜�', + dataIndex: 'UPDATE_USER', + }, + ]; + }, + GetSearchForm: () => { + return [ + { + field: 'RSN_CODE', + label: '涓嶈壇鍘熷洜缂栫爜', + component: 'Input', + colProps: { + span: 8, + }, + }, + { + label: '涓嶈壇鍘熷洜鍚嶇О', + field: 'RSN_NAME', + component: 'Input', + colProps: { + span: 8, + }, + }, + ]; + }, + GetCrudForm: () => { + return [ + { + field: 'RSN_CODE', + label: '涓嶈壇鍘熷洜缂栫爜', + component: 'Input', + required: true, + colProps: { + span: 24, + }, + }, + { + label: '涓嶈壇鍘熷洜鍚嶇О', + field: 'RSN_NAME', + component: 'Input', + required: true, + colProps: { + span: 24, + }, + }, + { + label: '涓嶈壇鍘熷洜缁勭紪鐮�', + field: 'RSNG_CODE', + component: 'ApiSelect', + colProps: { + span: 24, + }, + componentProps: { + api: getEntity, + params: { entityName: 'BAS_REASON_GRP', sqlcmd: ' 1=1 ' }, + resultField: 'Data.Items', + labelField: 'RSNG_NAME', + valueField: 'RSNG_CODE', + }, + dynamicDisabled: ({ values }) => { + return true; + }, + }, + { + label: '鏄惁蹇呴』鏇存崲闆朵欢', + field: 'NEED_REPLACE', + component: 'Select', + required: true, + colProps: { + span: 24, + }, + componentProps: { + options: [ + { + label: '鏇存崲', + value: 'Y', + key: 'Y', + }, + { + label: '涓嶆洿鎹�', + value: 'N', + key: 'N', + }, + ], + }, + }, + { + label: '澶囨敞', + field: 'REMARK', + component: 'Input', + colProps: { + span: 24, + }, + }, + { + label: 'ID', + field: 'ID', + component: 'Input', + colProps: { + span: 24, + }, + show: false, + }, + ]; + }, + GetBaseForm: () => { + return [ + { + field: 'RSNG_CODE', + label: '涓嶈壇鍘熷洜缁勭紪鐮�', + component: 'Input', + required: true, + colProps: { + span: 8, + }, + }, + { + label: '涓嶈壇鍘熷洜缁勫悕绉�', + field: 'RSNG_NAME', + required: true, + component: 'Input', + colProps: { + span: 8, + }, + }, + { + label: '澶囨敞', + field: 'REMARK', + component: 'Input', + colProps: { + span: 8, + }, + }, + { + label: 'ID', + field: 'ID', + component: 'Input', + colProps: { + span: 8, + }, + show: false, + }, + ]; + }, + GetBaseCards: () => { + return [ + { + name: 'BaseForm', + slots: [], + preIcons: {}, + title: '涓嶈壇鍘熷洜缁勪俊鎭�', + entityName: 'BAS_REASON_GRP', + }, + ]; + }, + OthersValues: (val: string, id: string) => { + return { RSNG_CODE: val }; + }, }; return [methods, ActionColumn]; diff --git a/src/views/tigerprojects/system/lowcode/high/baseForm.vue b/src/views/tigerprojects/system/lowcode/high/baseForm.vue new file mode 100644 index 0000000..100ec07 --- /dev/null +++ b/src/views/tigerprojects/system/lowcode/high/baseForm.vue @@ -0,0 +1,66 @@ +<!-- + * @Description: 楂樼骇琛ㄥ崟椤佃琛ㄤ俊鎭粍浠讹紝闇�瑕佹敮鎸乻etup async + * @Author: Ben Lin + * @version: + * @Date: 2024-06-23 17:21:29 + * @LastEditors: Ben Lin + * @LastEditTime: 2024-06-23 18:08:08 +--> +<template> + <a-card + :title="item.title" + :bordered="false" + v-for="(item, index) in _baseCards" + :key="item.name" + > + <BasicForm @register="useFormData[item.name][0]" /> + </a-card> +</template> +<script lang="ts" setup> + import { Ref, inject, nextTick, onMounted, ref, watch } from 'vue'; + import { BasicForm, useForm } from '/@/components/Form/index'; + import { Card } from 'ant-design-vue'; + import { getEntity } from '/@/api/tigerapi/system'; + import { isNullOrEmpty } from '/@/utils/is'; + + const ACard = Card; + const objParams = inject('objParams') as Ref<any>; + const useFormData = inject('useFormData') as Ref<{}>; + const baseCards = inject('baseCards') as Ref<any>; + const custImport = ref<any[]>( + await import(/* @vite-ignore */ `../entityts/${objParams['Name']}`), + ); + const [ + { + GetBaseForm, + GetBaseCards, + }, + ] = custImport.value['default'](); + const formSchemas = ref({ + BaseForm: GetBaseForm(), + }); //寮瑰嚭妗嗘垨楂樼骇椤甸潰澶氳〃鍗曠粨鏋� + useFormData.value = { + BaseForm: useForm({ + labelWidth: 120, + schemas: formSchemas.value['BaseForm'], + actionColOptions: { + span: 24, + }, + showActionButtonGroup: false, + }), + }; + const _baseCards = ref(GetBaseCards()); + baseCards.value = _baseCards.value; + + onMounted(() => { + useFormData.value[_baseCards.value[0]['name']][1].resetFields(); + getEntity({ + sqlcmd: ` ID = '${objParams['ID']}'`, + entityName: _baseCards.value[0]['entityName'], + }).then((res) => { + if (!isNullOrEmpty(res.Data.Items)) { + useFormData.value[_baseCards.value[0]['name']][1].setFieldsValue(res.Data.Items[0]); + } + }); + }); +</script> diff --git a/src/views/tigerprojects/system/lowcode/high/dtl.vue b/src/views/tigerprojects/system/lowcode/high/dtl.vue new file mode 100644 index 0000000..f5ee227 --- /dev/null +++ b/src/views/tigerprojects/system/lowcode/high/dtl.vue @@ -0,0 +1,323 @@ +<template> + <div> + <BasicTable @register="registerTable"> + <template #toolbar> + <a-button type="primary" @click="handleCreate" preIcon="add_02|svg"> 鏂板 </a-button> + </template> + <template #action="{ record }"> + <TableAction :actions="createActions(record)" /> + </template> + <template #[item]="{ field }" v-for="item in colSlots" :key="item"> + <!-- <template #form-BAS_REASON3aadd="{ field }"> --> + <a-button + v-if="field" + class="mt-1 ml-1" + size="small" + @click="handleSelectItem(item)" + preIcon="search|svg" + /> + <GeneralModal + @register="registerItemAdd" + @success="(d, u) => handleItemSuccess(d, u, item)" + /> + </template> + </BasicTable> + <normalDrawer @register="registerDrawer" @success="handleSuccess" /> + </div> +</template> +<script lang="ts" setup> + import { Ref, inject, nextTick, onMounted, ref, watch } from 'vue'; + import { BasicTable, useTable, TableAction } from '/@/components/Table'; + import { BasicForm, useForm } from '/@/components/Form/index'; + import { useDrawer } from '/@/components/Drawer'; + import GeneralModal from '/@/views/components/GeneralModal.vue'; + import normalDrawer from '../normalDrawer.vue'; + import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is'; + import { useModal } from '/@/components/Modal'; + import { useGo } from '/@/hooks/web/usePage'; + import { DeleteEntity, getEntity } from '/@/api/tigerapi/system'; + import { useI18n } from '/@/hooks/web/useI18n'; + + const { t } = useI18n(); + + const props = defineProps({ + colSlots: { type: Array as PropType<any[]> }, + useTableData: { type: Object as PropType<{}>, default: { table: [] } }, + entityName: { type: String }, + crudColSlots: { type: Object as PropType<any> }, + }); + const objParams = inject('objParams') as Ref<any>; + const data = inject('data') as Ref<Recordable[]>; + const others = inject('others') as Ref<Recordable[]>; + const go = useGo(); + const [registerDrawer, { openDrawer }] = useDrawer(); + const [registerItemAdd, { openModal: openItemModal }] = useModal(); + const cType = ref(''); + const dtlSlots = ref([] as any[]); + const selectVals = ref({}); + const baseCards = ref([] as any[]); + const otherCards = ref([] as any[]); + const useModalData = ref({}); //琛ㄥ崟涓彃妲芥覆鏌撴寜閽墦寮�妯℃�佹useModal鏂规硶 + const useFormData = ref({}); + const custImport = ref<any[]>(await import(/* @vite-ignore */ `../entityts/${props.entityName}`)); + const [ + { + EditeOperation, + GetBaseColumns, + GetSearchForm, + GetCrudForm, + OthersValues, + }, + ] = custImport.value['default'](); + others.value = OthersValues(objParams['CODE'], objParams['ID']); + const [registerTable, { getForm, reload, setProps }] = useTable({ + title: '鍒楄〃淇℃伅', + dataSource: data, + columns: GetBaseColumns(), + formConfig: { + labelWidth: 140, + schemas: GetSearchForm(), + }, + useSearchForm: true, + showTableSetting: true, + bordered: true, + canResize: true, + showIndexColumn: false, + actionColumn: { + width: 130, + title: '鎿嶄綔', + dataIndex: 'action', + slots: { customRender: 'action' }, + fixed: undefined, + }, //鑷畾涔夋搷浣滃垪 + }); + // watch( + // () => props.dataSource, + // (newVal, oldVal) => { + // nextTick(() => { + // setProps({ + // dataSource: [], + // }); + // data.value = newVal; + // setProps({ + // dataSource: data, + // }); + // }); + // }, + // { deep: true, immediate: true }, + // ); + + onMounted(() => { + getEntity({ + sqlcmd: ` ${objParams['pCode']} = '${others.value[objParams['pCode']]}'`, + entityName: props.entityName as string, + }).then((res) => { + if (!isNullOrEmpty(res.Data.Items)) { + data.value = res.Data.Items; + } + }); + }); + + function createActions(record) { + const params = { + record, + isUpdate: true, + ifSave: true, + entityName: props.entityName, + formJson: GetCrudForm(), //getFormSchema(`${entityName.value}_Crud`), + cType, + dtlSlots, + useModalData, + useFormData, + crudColSlots: props.crudColSlots, + data, + }; + const actionItem = [ + { + icon: 'clarity:note-edit-line', + onClick: editRecord.bind(null, openDrawer, params), + }, + { + icon: 'ant-design:delete-outlined', + color: 'error', + popConfirm: { + title: '鏄惁纭鍒犻櫎?', + placement: 'left', + confirm: deleteRecord.bind(null, reload, params), + }, + }, + ]; + if (isNullOrUnDef(custImport.value)) { + return actionItem; + } + const [{ ActionItem }] = custImport.value['default'](); + return ActionItem( + params, + actionItem, + openDrawer, + reload, + null, + useForm, + useModal, + go, + setProps, + ); + } + + /** + * @description: 鍏敤缂栬緫鏂规硶 + * @param {Fn} fn + * @param {*} params + * @return {*} + */ + function editRecord(fn: Fn, params: {}) { + fn(true, params); + } + + /** + * @description: 鍏敤鍒犻櫎鏂规硶 + * @param {Fn} fn + * @param {*} params + * @return {*} + */ + function deleteRecord(fn: Fn, params: {}) { + console.log(params['record']); + //鍒犻櫎 + DeleteEntity(params['record'], params['entityName']).then((action) => { + if (action.IsSuccessed) { + fn(); + } + }); + } + + /** + * @description: 楠岃瘉琛ㄥ崟 + * @return {*} + */ + async function validate() { + let validates = {}; + const Keys = Object.getOwnPropertyNames(useFormData.value); + let i; + for (i = 0; i < Keys.length; i++) { + validates[Keys[i]] = await useFormData.value[Keys[i]][1].validate(); + } + return validates; + } + + function handleCreate() { + validate().then((res) => { + const Keys = Object.getOwnPropertyNames(useFormData.value); + let i; + for (i = 0; i < Keys.length; i++) { + others.value[objParams['pCode']] = objParams['IsID'] + ? res[Keys[i]]['ID'] + : res[Keys[i]][objParams['pCode']]; + } + openDrawer(true, { + isUpdate: false, + ifSave: true, + entityName: props.entityName, + formJson: GetCrudForm(), //getFormSchema(`${entityName.value}_Crud`), + crudColSlots: props.crudColSlots, + others: others.value, + }); + }); + } + + /** + * @description: 鏂板缂栬緫杩斿洖鎴愬姛鏂规硶 + * @param {*} d + * @param {*} u + * @return {*} + */ + function handleSuccess(d, u) { + if (!isNullOrUnDef(custImport.value)) { + /* 鑷畾涔夌紪杈戞柟娉曪紝鏍规嵁瀹炰綋鍚嶅幓璋冪敤 */ + EditeOperation(data, d, u); + setProps({ + dataSource: [], + }); + setProps({ + dataSource: data, + }); + reload(); + } + } + + /** + * @description: 寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庝簨浠� + * @param {*} d + * @param {*} u + * @param {*} item + * @return {*} + */ + function handleItemSuccess(d, u, item) { + /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ + try { + import( + /* @vite-ignore */ `../entityts/${getForm().getFieldsValue()[`${item.replace(/form-/, '').replace(/add/, '')}PSelect_0`]}` + ) + .then((m) => { + const [{ GetSelectSuccess }] = m.default(); + getForm().setFieldsValue(GetSelectSuccess(d, u)); + }) + .catch(() => { + getForm().setFieldsValue({ + ITEM_CODE: d.values['val'], + }); + }); + } catch (e) {} + } + + /** + * @description: 寮瑰嚭閫夋嫨妗� + * @param {*} item + * @return {*} + */ + function handleSelectItem(item) { + /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ + try { + import( + /* @vite-ignore */ `../entityts/${props.useTableData['table'][1].getForm().getFieldsValue()[`${item.replace(/form-/, '').replace(/add/, '')}PSelect_0`]}` + ) + .then((m) => { + const [{ OpenSelectItem }] = m.default(); + OpenSelectItem(openItemModal); + }) + .catch(() => { + openItemModal(true, { + title: '鐗╂枡鍒楄〃', + schemas: [ + { + field: 'ITEM_CODE', + component: 'Input', + label: '鐗╂枡缂栫爜', + colProps: { + span: 12, + }, + }, + ], + ItemColumns: [ + { + title: t('鐗╂枡缂栫爜'), + dataIndex: 'ITEM_CODE', + resizable: true, + sorter: true, + width: 200, + }, + { + title: t('鐗╂枡鍚嶇О'), + dataIndex: 'ITEM_NAME', + resizable: true, + sorter: true, + width: 180, + }, + ], + tableName: 'BAS_ITEM', + rowKey: 'ITEM_CODE', + searchInfo: { TABLE_NAME: 'BAS_ITEM' }, + }); + }); + } catch (e) {} + } +</script> diff --git a/src/views/tigerprojects/system/lowcode/high/index.vue b/src/views/tigerprojects/system/lowcode/high/index.vue index 3f12464..671e7e7 100644 --- a/src/views/tigerprojects/system/lowcode/high/index.vue +++ b/src/views/tigerprojects/system/lowcode/high/index.vue @@ -1,4 +1,12 @@ <!-- + * @Description: 浣庝唬鐮侀珮绾у憟鐜伴〉闈� + * @Author: Ben Lin + * @version: + * @Date: 2024-06-18 15:09:48 + * @LastEditors: Ben Lin + * @LastEditTime: 2024-06-23 18:03:27 +--> +<!-- * _oo0oo_ * o8888888o * 88" . "88 @@ -33,14 +41,6 @@ * 鍒汉绗戞垜蹇掔柉鐧紝鎴戠瑧鑷繁鍛藉お璐憋紱 * 涓嶈婊¤婕備寒濡癸紝鍝釜褰掑緱绋嬪簭鍛橈紵 --> -<!-- - * @Description: 浣庝唬鐮侀珮绾у憟鐜伴〉闈� - * @Author: Ben Lin - * @version: - * @Date: 2024-05-30 13:28:20 - * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-14 09:19:23 ---> <template> <PageWrapper class="high-form" @@ -48,39 +48,13 @@ :content="titleInfo['pageContent']" @back="goBack" > - <a-card - :title="item.title" - :bordered="false" - v-for="(item, index) in baseCards" - :key="item.name" - > - <BasicForm @register="useFormData[item.name][0]" /> - </a-card> + <Suspense> + <baseForm /> + </Suspense> <a-card :title="titleInfo['baseTableTitle']" :bordered="false" class="!mt-5"> - <div> - <BasicTable @register="registerTable" v-if="isMounted"> - <template #toolbar> - <a-button type="primary" @click="handleCreate" preIcon="add_02|svg"> 鏂板 </a-button> - </template> - <template #action="{ record }"> - <TableAction :actions="createActions(record)" /> - </template> - <template #[item]="{ field }" v-for="item in colSlots" :key="item"> - <!-- <template #form-BAS_REASON3aadd="{ field }"> --> - <a-button - v-if="field" - class="mt-1 ml-1" - size="small" - @click="handleSelectItem(item)" - preIcon="search|svg" - /> - <GeneralModal - @register="registerItemAdd" - @success="(d, u) => handleItemSuccess(d, u, item)" - /> - </template> - </BasicTable> - </div> + <Suspense> + <dtl :entityName="entityName" /> + </Suspense> </a-card> <a-card :title="item.title" @@ -96,7 +70,6 @@ <a-button class="mr-4" type="info" @click="cancel"> 鍙栨秷 </a-button> <a-button type="primary" @click="submitAll"> 鎻愪氦 </a-button> </template> - <normalDrawer @register="registerDrawer" @success="handleSuccess" /> <CustModal @register="registerCust" @success="custSuccess" @@ -126,32 +99,19 @@ </PageWrapper> </template> <script lang="ts" setup> - import { h, onMounted, ref, unref } from 'vue'; - import { Tag, Tooltip, Card } from 'ant-design-vue'; - import { BasicTable, useTable, TableAction } from '/@/components/Table'; - import { useDrawer } from '/@/components/Drawer'; + import { Ref, h, nextTick, onMounted, provide, ref, unref } from 'vue'; + import { Card } from 'ant-design-vue'; + import { useTable } from '/@/components/Table'; import { PageWrapper } from '/@/components/Page'; - import normalDrawer from '../normalDrawer.vue'; + import dtl from './dtl.vue'; + import baseForm from './baseForm.vue'; import GeneralModal from '/@/views/components/GeneralModal.vue'; - import { - AddListEntity, - DeleteEntity, - DeleteWhere, - SaveEntity, - getEntity, - } from '/@/api/tigerapi/system'; + import { AddListEntity, DeleteWhere, SaveEntity, getEntity } from '/@/api/tigerapi/system'; import { useGlobSetting } from '/@/hooks/setting'; import { useRoute, useRouter } from 'vue-router'; import CustModal from '/@/views/components/CustModal.vue'; import { BasicForm, useForm } from '/@/components/Form/index'; - import { - custOnChange, - getFormSchema, - OpenCustModal, - GetBasicColumnAndInit, - getTitle, - getOthersValues, - } from '../data'; + import { custOnChange, OpenCustModal, GetBasicColumnAndInit, getTitle } from '../data'; import { useModal } from '/@/components/Modal'; import { useLocale } from '/@/locales/useLocale'; import { useGo } from '/@/hooks/web/usePage'; @@ -183,16 +143,21 @@ const formSchemas = ref({}); //寮瑰嚭妗嗘垨楂樼骇椤甸潰澶氳〃鍗曠粨鏋� const useModalData = ref({}); //琛ㄥ崟涓彃妲芥覆鏌撴寜閽墦寮�妯℃�佹useModal鏂规硶 const useFormData = ref({}); - const colSlots = ref<any>(objParams.value.colSlots); //鎸夐挳鎻掓Ы - const crudColSlots = ref<any>(objParams.value.crudColSlots); + const useTableData = ref({}); const cType = ref(''); const dtlSlots = ref([] as any[]); const selectVals = ref({}); const baseCards = ref([] as any[]); const otherCards = ref([] as any[]); const isMounted = ref(false); - const custImport = ref(null); - const others = ref(getOthersValues(entityName.value, objParams.value.CODE, objParams.value.ID)); + const custImport = ref<any[]>([]); + const others = ref<any>(null); + const data = ref<Recordable[]>([]); + provide<Ref<any>>('objParams', objParams.value); + provide<Ref<Recordable[]>>('data', data); + provide<Ref<any>>('others', others); + provide<Ref<{}>>('useFormData', useFormData); + provide<Ref<any>>('baseCards', baseCards); //鑾峰彇琛ㄦ牸鍒椾俊鎭苟鍒濆鍖栦竴浜涙暟鎹紝濡傦細formSchemas(寮瑰嚭妗嗘垨楂樼骇椤甸潰澶氳〃鍗曠粨鏋�), useFormData(琛ㄥ崟涓彃妲芥覆鏌撴寜閽墦寮�妯℃�佹useModal鏂规硶)...绛� const _columns = GetBasicColumnAndInit( entityName.value, @@ -201,178 +166,17 @@ baseCards, otherCards, useForm, + useTableData, + useTable, + data, ); - const data = ref([]); const [registerCust, { openModal: openCustomModal, closeModal }] = useModal(); - const [registerItemAdd, { openModal: openItemModal }] = useModal(); - const [registerDrawer, { openDrawer }] = useDrawer(); const { setTitle } = useTabs(); - const [registerTable, { getForm, reload, setProps }] = useTable({ - title: '鍒楄〃淇℃伅', - dataSource: data, - columns: _columns, - formConfig: { - labelWidth: 140, - schemas: getFormSchema(`${entityName.value}_Search`), - }, - useSearchForm: true, - showTableSetting: true, - bordered: true, - canResize: true, - showIndexColumn: false, - actionColumn: { - width: 130, - title: '鎿嶄綔', - dataIndex: 'action', - slots: { customRender: 'action' }, - fixed: undefined, - }, //鑷畾涔夋搷浣滃垪 - }); setTitle(objParams.value.Title); //璁剧疆鏍囩椤垫爣棰� - - /** - * @description: 鐢熸垚鍒楄〃涓搷浣滈」鐨勬寜閽� - * @param {*} record - * @return {*} - */ - function createActions(record) { - // return GetActionsData( - // { - // record, - // isUpdate: true, - // ifSave: true, - // entityName: entityName.value, - // formJson: getFormSchema(`${entityName.value}_Crud`), - // cType, - // dtlSlots, - // useModalData, - // useFormData, - // crudColSlots, - // data, - // }, - // openDrawer, - // reload, - // openCustomModal, - // useForm, - // useModal, - // go, - // setProps, - // ); - const params = { - record, - isUpdate: true, - ifSave: true, - entityName: entityName.value, - formJson: getFormSchema(`${entityName.value}_Crud`), - cType, - dtlSlots, - useModalData, - useFormData, - crudColSlots, - data, - }; - const actionItem = [ - { - icon: 'clarity:note-edit-line', - onClick: editRecord.bind(null, openDrawer, params), - }, - { - icon: 'ant-design:delete-outlined', - color: 'error', - popConfirm: { - title: '鏄惁纭鍒犻櫎?', - placement: 'left', - confirm: deleteRecord.bind(null, reload, params), - }, - }, - ]; - if (isNullOrUnDef(custImport.value)) { - return actionItem; - } - const [{ ActionItem }] = custImport.value.default(); - return ActionItem( - params, - actionItem, - openDrawer, - reload, - openCustomModal, - useForm, - useModal, - go, - setProps, - ); - } - - /** - * @description: 鍏敤缂栬緫鏂规硶 - * @param {Fn} fn - * @param {*} params - * @return {*} - */ - function editRecord(fn: Fn, params: {}) { - fn(true, params); - } - - /** - * @description: 鍏敤鍒犻櫎鏂规硶 - * @param {Fn} fn - * @param {*} params - * @return {*} - */ - function deleteRecord(fn: Fn, params: {}) { - console.log(params['record']); - //鍒犻櫎 - DeleteEntity(params['record'], params['entityName']).then((action) => { - if (action.IsSuccessed) { - fn(); - } - }); - } - - function handleCreate() { - validate().then((res) => { - const Keys = Object.getOwnPropertyNames(useFormData.value); - let i; - for (i = 0; i < Keys.length; i++) { - others.value[objParams.value.pCode] = objParams.value.IsID - ? res[Keys[i]]['ID'] - : res[Keys[i]][objParams.value.pCode]; - } - openDrawer(true, { - isUpdate: false, - ifSave: true, - entityName: entityName.value, - formJson: getFormSchema(`${entityName.value}_Crud`), - crudColSlots, - others: others.value, - }); - }); - } - - /** - * @description: 鏂板缂栬緫杩斿洖鎴愬姛鏂规硶 - * @param {*} d - * @param {*} u - * @return {*} - */ - function handleSuccess(d, u) { - if (!isNullOrUnDef(custImport.value)) { - const [{ EditOperation }] = custImport.value.default(); - /* 鑷畾涔夌紪杈戞柟娉曪紝鏍规嵁瀹炰綋鍚嶅幓璋冪敤 */ - EditOperation(entityName.value, data, d, u); - setProps({ - dataSource: [], - }); - setProps({ - dataSource: data, - }); - reload(); - } - } function goBack() { if (!isNullOrUnDef(custImport.value)) { - const [{ GetHomeUrl }] = custImport.value.default(); + const [{ GetHomeUrl }] = custImport.value['default'](); // 鏈緥鐨勬晥鏋滄椂鐐瑰嚮杩斿洖濮嬬粓璺宠浆鍒拌处鍙峰垪琛ㄩ〉锛屽疄闄呭簲鐢ㄦ椂鍙繑鍥炰笂涓�椤� go(GetHomeUrl(entityName.value)); } @@ -380,28 +184,11 @@ onMounted(async () => { isMounted.value = false; + await nextTick(); /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ try { custImport.value = await import(/* @vite-ignore */ `../entityts/${entityName.value}`); } catch (e) {} - useFormData.value[baseCards.value[0]['name']][1].resetFields(); - Promise.all([ - getEntity({ - sqlcmd: ` ID = '${objParams.value.ID}'`, - entityName: baseCards.value[0]['entityName'], - }), - getEntity({ - sqlcmd: ` ${objParams.value.pCode} = '${others.value[objParams.value.pCode]}'`, - entityName: entityName.value, - }), - ]).then((res) => { - if (!isNullOrEmpty(res[0].Data.Items)) { - useFormData.value[baseCards.value[0]['name']][1].setFieldsValue(res[0].Data.Items[0]); - } - if (!isNullOrEmpty(res[1].Data.Items)) { - data.value = res[1].Data.Items; - } - }); isMounted.value = true; }); @@ -468,83 +255,6 @@ } /** - * @description: 寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庝簨浠� - * @param {*} d - * @param {*} u - * @param {*} item - * @return {*} - */ - function handleItemSuccess(d, u, item) { - /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ - try { - import( - /* @vite-ignore */ `../entityts/${getForm().getFieldsValue()[`${item.replace(/form-/, '').replace(/add/, '')}PSelect_0`]}` - ) - .then((m) => { - const [{ GetSelectSuccess }] = m.default(); - getForm().setFieldsValue(GetSelectSuccess(d, u)); - }) - .catch(() => { - getForm().setFieldsValue({ - ITEM_CODE: d.values['val'], - }); - }); - } catch (e) {} - } - - /** - * @description: 寮瑰嚭閫夋嫨妗� - * @param {*} item - * @return {*} - */ - function handleSelectItem(item) { - /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ - try { - import( - /* @vite-ignore */ `../entityts/${getForm().getFieldsValue()[`${item.replace(/form-/, '').replace(/add/, '')}PSelect_0`]}` - ) - .then((m) => { - const [{ OpenSelectItem }] = m.default(); - OpenSelectItem(openItemModal); - }) - .catch(() => { - openItemModal(true, { - title: '鐗╂枡鍒楄〃', - schemas: [ - { - field: 'ITEM_CODE', - component: 'Input', - label: '鐗╂枡缂栫爜', - colProps: { - span: 12, - }, - }, - ], - ItemColumns: [ - { - title: t('鐗╂枡缂栫爜'), - dataIndex: 'ITEM_CODE', - resizable: true, - sorter: true, - width: 200, - }, - { - title: t('鐗╂枡鍚嶇О'), - dataIndex: 'ITEM_NAME', - resizable: true, - sorter: true, - width: 180, - }, - ], - tableName: 'BAS_ITEM', - rowKey: 'ITEM_CODE', - searchInfo: { TABLE_NAME: 'BAS_ITEM' }, - }); - }); - } catch (e) {} - } - - /** * @description: Select 鑷畾涔塷nChange鏂规硶 * @param {*} obj * @return {*} @@ -568,7 +278,7 @@ * @return {*} */ function custSuccess(d) { - reload(); + useTableData.value['table'][1].reload(); } /** diff --git a/src/views/tigerprojects/system/lowcode/normal/basDefectGrp.ts b/src/views/tigerprojects/system/lowcode/normal/basDefectGrp.ts deleted file mode 100644 index c7e570f..0000000 --- a/src/views/tigerprojects/system/lowcode/normal/basDefectGrp.ts +++ /dev/null @@ -1,290 +0,0 @@ -import { Ref, h, unref } from 'vue'; -import { ActionItem, BasicColumn, FormSchema } from '/@/components/Table'; -import { useI18n } from '/@/hooks/web/useI18n'; -import { useLocale } from '/@/locales/useLocale'; -import { Tag } from 'ant-design-vue'; -import { DeleteEntity, GetEnum, getEntity } from '/@/api/tigerapi/system'; -import { isNullOrEmpty } from '/@/utils/is'; -import { buildUUID } from '/@/utils/uuid'; -import { useUserStore } from '/@/store/modules/user'; -import { formatToDateTime } from '/@/utils/dateUtil'; - -const { t } = useI18n(); -const { getLocale } = useLocale(); - -/** - * @description: 鑷畾涔夋寜閽柟娉� - * @param {Fn} args - * @param {*} params - * @return {*} - */ -export function DftGrpRelease(args: Fn[], params: {}) { - console.log('鐐瑰嚮浜嗕笅鍙戞寜閽�'); - // notification.success({ - // message: '鐐瑰嚮浜嗕笅鍙戞寜閽�', - // description: `${params.entityName}`, - // duration: 3, - // }); - // reload(); - // if (params.STATUS == 2) { - // createErrorModal({ - // title: t('璀﹀憡'), - // content: t('宸ュ崟宸茬粡涓嬪彂锛屼笉鑳藉啀涓嬪彂锛�'), - // getContainer: () => document.body, - // }); - // return; - // } - params['dtlSlots'].value = [ - { - name: 'forminfo', - slots: ['add', 'set'], - preIcons: { add: 'search|svg', set: 'config|svg' }, //濡傛灉鏄涓〃鍗曪紝澧炲姞澶氫釜鎻掓Ы銆俿lots鏄脊鍑烘鎸夐挳鐨勬彃妲斤紝preIcons鏄彃妲藉搴旂殑鎸夐挳鍥炬爣 - title: '涓嬪彂閰嶇疆', - }, - ]; - - args[2](true, { - isUpdate: true, //鏄惁鏇存柊鎿嶄綔 - ctype: params['cType'].value, //鏄摢涓〉闈� - title: '宸ュ崟涓嬪彂', //鏍囬 - width: '900px', //寮瑰嚭妗嗗搴� - formEl: params['useFormData'].value, - formElName: ['forminfo'], //琛ㄥ崟鎻掓Ы鍚嶇О - RowKeys: { add: 'ROUTE_CODE', set: 'ROUTE_CODE' }, //鎻掓Ы鐨勫脊鍑烘閫夋嫨鐨刢ode - fnName: { BIZ_MES_WO: 'SaveWoBatch' }, //淇濆瓨鏂规硶鍚� - initFnName: {}, //鍒濆鍖栨柟娉曞悕 - values: params['record'], //琛ㄥ崟璁板綍 - }); -} - -/** - * @description: 鑷畾涔夋槑缁嗚〃涓紪杈戣繑鍥炴柟娉� - * @param {string} type - * @param {*} d - * @param {*} u - * @return {*} - */ -export function dftEditeOperation(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: 涓嶈壇浠g爜鍩烘湰淇℃伅 - * @return {*} - */ -export const baseSchema: FormSchema[] = [ - { - field: 'DFTG_CODE', - label: '涓嶈壇浠g爜缁勭紪鐮�', - component: 'Input', - required: true, - colProps: { - span: 8, - }, - }, - { - label: '涓嶈壇浠g爜缁勫悕绉�', - field: 'DFTG_NAME', - required: true, - component: 'Input', - colProps: { - span: 8, - }, - }, - { - label: '澶囨敞', - field: 'REMARK', - component: 'Input', - colProps: { - span: 8, - }, - }, - { - label: 'ID', - field: 'ID', - component: 'Input', - colProps: { - span: 8, - }, - show: false, - }, -]; - -export const searchSchema: FormSchema[] = [ - { - field: 'DFT_CODE', - label: '涓嶈壇浠g爜缂栫爜', - component: 'Input', - colProps: { - span: 8, - }, - }, - { - label: '涓嶈壇浠g爜鍚嶇О', - field: 'DFT_NAME', - component: 'Input', - colProps: { - span: 8, - }, - }, -]; - -/** - * @description: 鑾峰彇涓嶈壇浠g爜澧炲垹鏀硅〃鍗� - * @return {*} - */ -export const crudSchema: FormSchema[] = [ - { - 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, - }, -]; - -/** - * @description: 涓嶈壇浠g爜琛ㄦ牸鍒� - * @return {*} - */ -export const defectBaseColumn: BasicColumn[] = [ - { - 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', - }, -]; diff --git a/src/views/tigerprojects/system/lowcode/normal/basReasonGrp.ts b/src/views/tigerprojects/system/lowcode/normal/basReasonGrp.ts deleted file mode 100644 index 37c7549..0000000 --- a/src/views/tigerprojects/system/lowcode/normal/basReasonGrp.ts +++ /dev/null @@ -1,252 +0,0 @@ -import { ActionItem, BasicColumn, FormSchema } from '/@/components/Table'; -import { useMessage } from '/@/hooks/web/useMessage'; -import { useI18n } from '/@/hooks/web/useI18n'; -import { FunctionType } from '/@/api/tigerapi/model/systemModel'; -import { DeleteEntity, getEntity } from '/@/api/tigerapi/system'; -import { Tag } from 'ant-design-vue'; -import { Ref, h } from 'vue'; -import { isNullOrEmpty } from '/@/utils/is'; -import { buildUUID } from '/@/utils/uuid'; -import { useUserStore } from '/@/store/modules/user'; -import { formatToDateTime } from '/@/utils/dateUtil'; - -const { t } = useI18n(); -const { notification } = useMessage(); -/* 鑷畾涔夋寜閽柟娉� */ -export function RsGrpRelease(reload: Fn, params: {}) { - console.log('鐐瑰嚮浜嗕笅鍙戞寜閽�'); - notification.success({ - message: '鐐瑰嚮浜嗕笅鍙戞寜閽�', - description: `${params.entityName}`, - duration: 3, - }); - reload(); -} - -export const rsGrpactionColumn: BasicColumn = { - width: 180, - title: '鎿嶄綔', - dataIndex: 'action', - slots: { customRender: 'action' }, - fixed: undefined, -}; - -export const rsGrpActionItem: ActionItem[] = [ - { - icon: 'release|svg', - tooltip: '涓嬪彂', - onClick: () => {}, - }, -]; - -/* Select onChange 鏂规硶瀛楀吀 */ -export const onChangeFns: Record<string, FunctionType> = { - ABC: (e) => { - notification.success({ - message: '杩涘叆浜唎nChange鍑芥暟', - description: `${e}`, - duration: 3, - }); - }, - XXX: (e) => {}, -}; - -/** - * @description: 涓嶈壇鍘熷洜涓诲熀鏈俊鎭〃鍗曞瓧娈� - * @return {*} - */ -export const rsnBaseSchema: FormSchema[] = [ - { - field: 'RSNG_CODE', - label: '涓嶈壇鍘熷洜缁勭紪鐮�', - component: 'Input', - required: true, - colProps: { - span: 8, - }, - }, - { - label: '涓嶈壇鍘熷洜缁勫悕绉�', - field: 'RSNG_NAME', - required: true, - component: 'Input', - colProps: { - span: 8, - }, - }, - { - label: '澶囨敞', - field: 'REMARK', - component: 'Input', - colProps: { - span: 8, - }, - }, - { - label: 'ID', - field: 'ID', - component: 'Input', - colProps: { - span: 8, - }, - show: false, - }, -]; - -/** - * @description: 涓嶈壇鍘熷洜澧炲垹鏀瑰瓧娈� - * @return {*} - */ -export const rsnCrudSchema: FormSchema[] = [ - { - field: 'RSN_CODE', - label: '涓嶈壇鍘熷洜缂栫爜', - component: 'Input', - required: true, - colProps: { - span: 24, - }, - }, - { - label: '涓嶈壇鍘熷洜鍚嶇О', - field: 'RSN_NAME', - component: 'Input', - required: true, - colProps: { - span: 24, - }, - }, - { - label: '涓嶈壇鍘熷洜缁勭紪鐮�', - field: 'RSNG_CODE', - component: 'ApiSelect', - colProps: { - span: 24, - }, - componentProps: { - api: getEntity, - params: { entityName: 'BAS_REASON_GRP', sqlcmd: ' 1=1 ' }, - resultField: 'Data.Items', - labelField: 'RSNG_NAME', - valueField: 'RSNG_CODE', - }, - dynamicDisabled: ({ values }) => { - return true; - }, - }, - { - label: '鏄惁蹇呴』鏇存崲闆朵欢', - field: 'NEED_REPLACE', - component: 'Select', - required: true, - colProps: { - span: 24, - }, - componentProps: { - options: [ - { - label: '鏇存崲', - value: 'Y', - key: 'Y', - }, - { - label: '涓嶆洿鎹�', - value: 'N', - key: 'N', - }, - ], - }, - }, - { - label: '澶囨敞', - field: 'REMARK', - component: 'Input', - colProps: { - span: 24, - }, - }, - { - label: 'ID', - field: 'ID', - component: 'Input', - colProps: { - span: 24, - }, - show: false, - }, -]; - -/** - * @description: 涓嶈壇鍘熷洜鏌ヨ瀛楁 - * @return {*} - */ -export const rsnSearchSchema: FormSchema[] = [ - { - field: 'RSN_CODE', - label: '涓嶈壇鍘熷洜缂栫爜', - component: 'Input', - colProps: { - span: 8, - }, - }, - { - label: '涓嶈壇鍘熷洜鍚嶇О', - field: 'RSN_NAME', - component: 'Input', - colProps: { - span: 8, - }, - }, -]; - -/** - * @description: 涓嶈壇鍘熷洜琛ㄦ牸鍒� - * @return {*} - */ -export const rsnBaseColumn: BasicColumn[] = [ - { - title: '涓嶈壇鍘熷洜缂栫爜', - dataIndex: 'RSN_CODE', - // ifShow: false, - width: 180, - }, - { - title: '涓嶈壇鍘熷洜鍚嶇О', - dataIndex: 'RSN_NAME', - }, - { - title: '鏄惁蹇呴』鏇存崲闆朵欢', - dataIndex: 'NEED_REPLACE', - customRender: ({ record }) => { - const type = record.NEED_REPLACE; - 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: 'RSNG_CODE', - }, - { - title: '澶囨敞', - dataIndex: 'REMARK', - }, - { - title: '鏇存柊鏃堕棿', - dataIndex: 'UPDATE_TIME', - }, - { - title: '鏇存柊浜�', - dataIndex: 'UPDATE_USER', - }, -]; -- Gitblit v1.9.3