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_REASON.ts | 5 src/views/tigerprojects/system/lowcode/detail/basLabelVar.ts | 51 -- src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts | 6 src/views/tigerprojects/system/lowcode/data.ts | 134 ------- src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT_GRP.ts | 38 + src/views/tigerprojects/system/lowcode/high/index.vue | 74 +++ src/views/tigerprojects/system/lowcode/detail/index.vue | 87 +++ src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_VAR.ts | 45 ++ src/views/tigerprojects/system/lowcode/normalDrawer.vue | 277 +++++++++----- src/views/tigerprojects/system/lowcode/entityts/BAS_REASON_GRP.ts | 39 ++ src/views/tigerprojects/system/lowcode/normal/basDefectGrp.ts | 35 - src/views/tigerprojects/system/lowcode/entityts/ProdRouteBinding.ts | 77 ++- src/views/tigerprojects/system/lowcode/normal/basReasonGrp.ts | 35 - src/views/tigerprojects/system/lowcode/composition/index.vue | 53 +- src/views/tigerprojects/system/lowcode/normal/index.vue | 70 +++ src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_PV.ts | 51 ++ src/views/tigerprojects/system/lowcode/entityts/BAS_PKG_DTL.ts | 5 17 files changed, 630 insertions(+), 452 deletions(-) diff --git a/src/views/tigerprojects/system/lowcode/composition/index.vue b/src/views/tigerprojects/system/lowcode/composition/index.vue index 1e75a9c..ca58307 100644 --- a/src/views/tigerprojects/system/lowcode/composition/index.vue +++ b/src/views/tigerprojects/system/lowcode/composition/index.vue @@ -21,7 +21,7 @@ add @handle-add="handleAdd" --> <div class="w-3/4 xl:w-4/5 p-5"> - <RouteAction v-if="entityName == 'ProdRouteBinding' && rotType=='Product'" /> + <RouteAction v-if="entityName == 'ProdRouteBinding' && rotType == 'Product'" /> </div> <!-- <BasicTable class="w-3/4 xl:w-4/5" @register="registerTable"> <template #toolbar> @@ -69,19 +69,12 @@ import GeneralModal from '/@/views/components/GeneralModal.vue'; import RouteAction from './RouteAction.vue'; import CustModal from '/@/views/components/CustModal.vue'; - import { - GetSelectSuccess, - OpenCustModal, - fetchTreeData, - getHomeUrl, - getOthersValues, - } from '../data'; + import { OpenCustModal, getOthersValues } from '../data'; import { Ref, onMounted, provide, reactive, ref } from 'vue'; import { useRoute } from 'vue-router'; import { useDrawer } from '/@/components/Drawer'; import { BasicForm, useForm } from '/@/components/Form/index'; import { TreeItem } from '/@/components/TigerTree'; - import { createIconByType } from '../data'; import { useTabs } from '/@/hooks/web/useTabs'; import { isNullOrUnDef } from '/@/utils/is'; import { useGo } from '/@/hooks/web/usePage'; @@ -150,19 +143,26 @@ * @return {*} */ async function fetch(type: string) { + if (!isNullOrUnDef(custImport.value)) { + const [{ fetchTreeData }] = custImport.value.default(); //鏍规嵁type鑾峰彇鏍戝舰鏁版嵁 const data = await fetchTreeData(type, objParams.value.CODE); title.value = data.title; treeData.value = data.treeData; fieldNames.value = data.fieldNames; + } } /** * @description: 椤甸潰宸︿晶鐐瑰嚮杩斿洖閾炬帴鏃剁殑鎿嶄綔 * @return {*} - */ + */ function goBack() { - go(getHomeUrl(entityName.value)); + if (!isNullOrUnDef(custImport.value)) { + const [{ GetHomeUrl }] = custImport.value.default(); + // 鏈緥鐨勬晥鏋滄椂鐐瑰嚮杩斿洖濮嬬粓璺宠浆鍒拌处鍙峰垪琛ㄩ〉锛屽疄闄呭簲鐢ㄦ椂鍙繑鍥炰笂涓�椤� + go(GetHomeUrl(entityName.value)); + } } // function handleAdd(){ @@ -176,19 +176,22 @@ * @return {*} */ function createIcon(params: Recordable<any>) { - const [CreateIcon] = custImport.value.default(); - return CreateIcon(params); + if (isNullOrUnDef(custImport.value)) { + return ''; + } else { + const [{CreateIcon}] = custImport.value.default(); + return CreateIcon(params); + } } onMounted(async () => { isMounted.value = false; /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ try { - custImport.value = await import(/* @vite-ignore */`../entityts/${entityName.value}`); + custImport.value = await import(/* @vite-ignore */ `../entityts/${entityName.value}`); await fetch(entityName.value); isMounted.value = true; - } catch (e) { - } + } catch (e) {} }); /** @@ -254,7 +257,7 @@ * @description: 鍙栨秷閫夋嫨鏃朵簨浠惰繑鍥炴柟娉� * @param {*} node * @return {*} - */ + */ function UnSelect(node) { prodCode.value = ''; rotType.value = ''; @@ -282,11 +285,17 @@ * @return {*} */ function handleEntSuccess(d, u, item) { - var values = GetSelectSuccess(d, u, cType.value); - selectVals.value = values; //淇濆瓨寮瑰嚭妗嗛�夋嫨鐨勭粨鏋� - let _val = {}; - _val[d.returnFieldName] = values[d.returnFieldName]; - useFormData.value[item][1].setFieldsValue(_val); + /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ + try { + import(/* @vite-ignore */ `../entityts/${cType.value}`).then((m) => { + const [{ GetSelectSuccess }] = m.default(); + var values = GetSelectSuccess(d, u); + selectVals.value = values; //淇濆瓨寮瑰嚭妗嗛�夋嫨鐨勭粨鏋� + let _val = {}; + _val[d.returnFieldName] = values[d.returnFieldName]; + useFormData.value[item][1].setFieldsValue(_val); + }); + } catch (e) {} } /** diff --git a/src/views/tigerprojects/system/lowcode/data.ts b/src/views/tigerprojects/system/lowcode/data.ts index f3d2c92..d3863c8 100644 --- a/src/views/tigerprojects/system/lowcode/data.ts +++ b/src/views/tigerprojects/system/lowcode/data.ts @@ -32,7 +32,6 @@ */ import { - dftGrpOpenSelectItem, baseSchema, searchSchema, defectBaseColumn, @@ -40,7 +39,6 @@ } from './normal/basDefectGrp'; import { onChangeFns, - rsGrpOpenSelectItem, rsnBaseSchema, rsnCrudSchema, rsnSearchSchema, @@ -52,10 +50,6 @@ import { isNullOrEmpty } from '/@/utils/is'; import { woCustFn, woformSchema } from '/@/views/components/bizMesWo'; import { useModal } from '/@/components/Modal'; -import { - labelGetSelectSuccess, - labelOpenSelectItem, -} from './detail/basLabelVar'; import { pkgBaseColumn, pkgBaseSchema, @@ -100,82 +94,6 @@ break; } return data; -} - -/** - * @description: 鎵撳紑寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庤繑鍥炴柟娉� - * @param {*} d - * @param {*} u - * @param {string} entityName - * @return {*} - */ -export function GetSelectSuccess(d, u, entityName: string) { - let data = {}; - switch (entityName) { - case 'BAS_LABEL_PV': - data = labelGetSelectSuccess(d, u); - break; - default: - data = { - ITEM_CODE: d.values['val'], - }; - break; - } - return data; -} - -/** - * @description: 鎵撳紑寮瑰嚭閫夋嫨妗� - * @param {Fn} openItemModal - * @param {string} entityName - * @return {*} - */ -export function OpenSelectItem(openItemModal: Fn, entityName: string) { - switch (entityName) { - case 'BAS_DEFECT_GRP': - dftGrpOpenSelectItem(openItemModal); - break; - case 'BAS_REASON_GRP': - rsGrpOpenSelectItem(openItemModal); - break; - case 'BAS_LABEL_PV': - labelOpenSelectItem(openItemModal); - break; - default: - 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' }, - }); - break; - } } /** @@ -389,36 +307,6 @@ } /** - * @description: 鑾峰彇goback鐨剈rl - * @param {string} type - * @return {*} - */ -export function getHomeUrl(type: string) { - let url = ''; - switch (type) { - case 'BAS_DEFECT': - const param = { ID: 'BAS_DEFECT_GRP', colSlots: [], crudColSlots: [] }; - url = `/BAS_DEFECT_GRP/LC/${encodeURI(JSON.stringify(param))}`; - break; - case 'BAS_REASON': - url = `/BAS_REASON_GRP/LC/${encodeURI(JSON.stringify({ ID: 'BAS_REASON_GRP', colSlots: [], crudColSlots: [] }))}`; - break; - case 'BAS_PKG_DTL': - url = `/BAS_PKG_RULE/LC/${encodeURI(JSON.stringify({ ID: 'BAS_PKG_RULE', colSlots: [], crudColSlots: [] }))}`; - break; - case 'BAS_LABEL_VAR': - url = `/BAS_LABEL_TEMP/LC/${encodeURI(JSON.stringify({ ID: 'BAS_LABEL_TEMP', colSlots: [], crudColSlots: [] }))}`; - break; - case 'ProdRouteBinding': - url = `/V_BAS_PROD/LC/${encodeURI(JSON.stringify({ ID: 'V_BAS_PROD', colSlots: [], crudColSlots: [] }))}`; - break; - default: - break; - } - return url; -} - -/** * @description: 鑾峰彇鏍囬淇℃伅 * @param {string} type * @return {*} @@ -475,26 +363,4 @@ break; } return Values; -} - -/** - * @description: 鑾峰彇鏍戝舰鏁版嵁 - * @param {string} type - * @return {*} - */ -export async function fetchTreeData(type: string, itemCode: string) { - let data = { title: '', treeData: [] as any[], fieldNames: {} }; - switch (type) { - case 'ProdRouteBinding': - let prodTreeData = await GetRoutePTree(itemCode); - data.treeData = convertToTree(prodTreeData, 'pid', 'id', 'root'); - data.title = '宸ヨ壓璺嚎'; - data.fieldNames = { key: 'id', title: 'name' }; - break; - case 'BAS_PKG_DTL': - break; - default: - break; - } - return data; } diff --git a/src/views/tigerprojects/system/lowcode/detail/basLabelVar.ts b/src/views/tigerprojects/system/lowcode/detail/basLabelVar.ts index 3916a8b..f3f37ae 100644 --- a/src/views/tigerprojects/system/lowcode/detail/basLabelVar.ts +++ b/src/views/tigerprojects/system/lowcode/detail/basLabelVar.ts @@ -4,7 +4,7 @@ * @version: * @Date: 2024-06-13 16:18:39 * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-22 00:09:13 + * @LastEditTime: 2024-06-22 23:39:08 */ import { h, unref } from "vue"; import { BasicColumn, FormSchema } from "/@/components/Table"; @@ -164,51 +164,4 @@ colProps: { span: 8 }, component: 'Input', }, -]; - -export function labelOpenSelectItem(openItemModal: Fn) { - openItemModal(true, { - 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'} - }); - } - - /** - * @description: 閫夋嫨杩囩▼鍙橀噺寮瑰嚭閫夋嫨妗嗘垚鍔熻繑鍥炶祴鍊兼柟娉� - * @param {*} d - * @param {*} u - * @return {*} - */ - export function labelGetSelectSuccess(d, u) { - return { - VAR_VALUE: d.values['val'], - }; - } \ No newline at end of file +]; \ No newline at end of file diff --git a/src/views/tigerprojects/system/lowcode/detail/index.vue b/src/views/tigerprojects/system/lowcode/detail/index.vue index efc08db..35bf287 100644 --- a/src/views/tigerprojects/system/lowcode/detail/index.vue +++ b/src/views/tigerprojects/system/lowcode/detail/index.vue @@ -4,7 +4,7 @@ * @version: * @Date: 2024-06-18 15:09:48 * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-22 22:54:16 + * @LastEditTime: 2024-06-23 00:31:33 --> <!-- * @Description: 浣庝唬鐮佽鎯呭憟鐜伴〉闈� @@ -122,12 +122,7 @@ import { useGo } from '/@/hooks/web/usePage'; //璇︽儏鍒楄〃 import { BasicTable, useTable, TableAction } from '/@/components/Table'; - import { - OpenCustModal, - OpenSelectItem, - custOnChange, - getHomeUrl, - } from '../data'; + import { OpenCustModal, custOnChange } from '../data'; import { useI18n } from '/@/hooks/web/useI18n'; import { useMessage } from '/@/hooks/web/useMessage'; import { DeleteEntity, getListByPage } from '/@/api/tigerapi/system'; @@ -139,6 +134,9 @@ import { useGlobSetting } from '/@/hooks/setting'; import { useModal } from '/@/components/Modal'; import { GetBaseColumns, GetFormColumns, GetSearchFormColumns } from './data'; + import { isNullOrUnDef } from '/@/utils/is'; + + const { t } = useI18n(); const { t: bt } = useI18n(''); const { createMessage } = useMessage(); @@ -189,7 +187,7 @@ schemas: GetSearchFormColumns(entityName.value, 'detailfirst'), }, actionColumn: { - width: 80, + width: 130, title: '鎿嶄綔', dataIndex: 'action', slots: { customRender: 'action' }, @@ -245,7 +243,16 @@ // 椤甸潰宸︿晶鐐瑰嚮杩斿洖閾炬帴鏃剁殑鎿嶄綔 function goBack() { - go(getHomeUrl(entityName.value)); + /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ + try { + import(/* @vite-ignore */ `../entityts/${entityName.value}`) + .then((m) => { + const [{ GetHomeUrl }] = m.default(); + // 鏈緥鐨勬晥鏋滄椂鐐瑰嚮杩斿洖濮嬬粓璺宠浆鍒拌处鍙峰垪琛ㄩ〉锛屽疄闄呭簲鐢ㄦ椂鍙繑鍥炰笂涓�椤� + go(GetHomeUrl(entityName.value)); + }) + .catch(() => {}); + } catch (e) {} } const tabClkcallback = (val: string) => { if (val == 'detailfirst') { @@ -303,10 +310,16 @@ 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)); - }); + ) + .then((m) => { + const [{ GetSelectSuccess }] = m.default(); + getForm().setFieldsValue(GetSelectSuccess(d, u)); + }) + .catch(() => { + getForm().setFieldsValue({ + ITEM_CODE: d.values['val'], + }); + }); } catch (e) {} } @@ -316,10 +329,50 @@ * @return {*} */ function handleSelectItem(item) { - OpenSelectItem( - openItemModal, - getForm().getFieldsValue()[`${item.replace(/form-/, '').replace(/add/, '')}PSelect_0`], - ); + /* 鍔ㄦ�乮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) {} } /** diff --git a/src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts b/src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts index ba31cf7..a303273 100644 --- a/src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts +++ b/src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT.ts @@ -4,7 +4,7 @@ * @version: * @Date: 2024-06-19 20:34:27 * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-22 20:31:44 + * @LastEditTime: 2024-06-23 00:16:36 */ import { Ref } from 'vue'; @@ -73,6 +73,10 @@ 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))}`; + } }; /** diff --git a/src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT_GRP.ts b/src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT_GRP.ts index c09ebad..9ab7013 100644 --- a/src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT_GRP.ts +++ b/src/views/tigerprojects/system/lowcode/entityts/BAS_DEFECT_GRP.ts @@ -4,12 +4,14 @@ * @version: * @Date: 2024-06-19 20:34:27 * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-22 22:33:52 + * @LastEditTime: 2024-06-22 23:30:54 */ import { ActionItem, BasicColumn } from '/@/components/Table'; import { buildUUID } from '/@/utils/uuid'; +import { useI18n } from '/@/hooks/web/useI18n'; +const { t } = useI18n(); function _default() { /** * @description: 鑷畾涔夌紪杈戞柟娉� @@ -68,6 +70,40 @@ return { ITEM_CODE: d.values['val'], }; + }, + OpenSelectItem:(openItemModal: Fn) => { + 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'} + }); } }; diff --git a/src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_PV.ts b/src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_PV.ts index 7b9334a..ea64a9b 100644 --- a/src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_PV.ts +++ b/src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_PV.ts @@ -4,10 +4,13 @@ * @version: * @Date: 2024-06-19 20:34:27 * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-22 23:00:34 + * @LastEditTime: 2024-06-22 23:40:02 */ import { ActionItem, BasicColumn } from '/@/components/Table'; +import { useI18n } from '/@/hooks/web/useI18n'; + +const { t } = useI18n(); function _default() { const ActionColumn: BasicColumn = { @@ -35,11 +38,51 @@ ActionItem: (params: Recordable<any>, data, ...args): ActionItem[] => { return data; }, - GetSelectSuccess:(d, u) => { + /** + * @description: 閫夋嫨杩囩▼鍙橀噺寮瑰嚭閫夋嫨妗嗘垚鍔熻繑鍥炶祴鍊兼柟娉� + * @param {*} d + * @param {*} u + * @return {*} + */ + GetSelectSuccess: (d, u) => { return { - ITEM_CODE: d.values['val'], + VAR_VALUE: d.values['val'], }; - } + }, + OpenSelectItem:(openItemModal: Fn) => { + openItemModal(true, { + 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'} + }); + } }; return [methods, ActionColumn]; diff --git a/src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_VAR.ts b/src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_VAR.ts new file mode 100644 index 0000000..9b096df --- /dev/null +++ b/src/views/tigerprojects/system/lowcode/entityts/BAS_LABEL_VAR.ts @@ -0,0 +1,45 @@ +/* + * @Description: 浜у搧宸ヨ壓璺嚎鐩稿叧 + * @Author: Ben Lin + * @version: + * @Date: 2024-06-19 20:34:27 + * @LastEditors: Ben Lin + * @LastEditTime: 2024-06-23 00:28:56 + */ + +import { ActionItem, BasicColumn } from "/@/components/Table"; + +function _default() { + const ActionColumn: BasicColumn = { + width: 80, + title: '鎿嶄綔', + dataIndex: 'action', + slots: { customRender: 'action' }, + fixed: undefined, + }; + const methods = { + /** + * @description: 鑾峰彇鏂板鎸夐挳鐨勮涓猴紝蹇呴渶瑕佹湁鐨勬柟娉� + * @return {*} + */ + CreateAction: () => { + return { + action: 'drawer', //drawer(鎵撳紑宸︿晶鎶藉眽妗�) | go(璺宠浆鍒版柊鐨勯〉闈�) + }; + }, + /** + * @description: 浜у搧缁戝畾宸ヨ壓璺嚎鎿嶄綔瀛楁鑷畾涔夋寜閽紝蹇呴渶瑕佹湁鐨勬柟娉� + * @return {*} + */ + ActionItem: (params: Recordable<any>, data, ...args): ActionItem[] => { + return data; + }, + GetHomeUrl: () => { + return `/BAS_LABEL_TEMP/LC/${encodeURI(JSON.stringify({ ID: 'BAS_LABEL_TEMP', colSlots: [], crudColSlots: [] }))}`; + } + }; + + return [methods, ActionColumn]; +} + +export default _default; 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 2183840..8dd0f38 100644 --- a/src/views/tigerprojects/system/lowcode/entityts/BAS_PKG_DTL.ts +++ b/src/views/tigerprojects/system/lowcode/entityts/BAS_PKG_DTL.ts @@ -4,7 +4,7 @@ * @version: * @Date: 2024-06-19 20:34:27 * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-22 22:29:28 + * @LastEditTime: 2024-06-23 00:22:36 */ import { Ref } from 'vue'; @@ -107,6 +107,9 @@ data.value = _data2; } }, + GetHomeUrl: () => { + return `/BAS_PKG_RULE/LC/${encodeURI(JSON.stringify({ ID: 'BAS_PKG_RULE', colSlots: [], crudColSlots: [] }))}`; + } }; 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 25471aa..bb4dcce 100644 --- a/src/views/tigerprojects/system/lowcode/entityts/BAS_REASON.ts +++ b/src/views/tigerprojects/system/lowcode/entityts/BAS_REASON.ts @@ -4,7 +4,7 @@ * @version: * @Date: 2024-06-19 20:34:27 * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-22 22:28:08 + * @LastEditTime: 2024-06-23 00:21:58 */ import { Ref } from 'vue'; @@ -105,6 +105,9 @@ _data2.push(d); data.value = _data2; } + }, + GetHomeUrl: () => { + return `/BAS_REASON_GRP/LC/${encodeURI(JSON.stringify({ ID: 'BAS_REASON_GRP', colSlots: [], crudColSlots: [] }))}`; } }; diff --git a/src/views/tigerprojects/system/lowcode/entityts/BAS_REASON_GRP.ts b/src/views/tigerprojects/system/lowcode/entityts/BAS_REASON_GRP.ts index e5d89da..09da874 100644 --- a/src/views/tigerprojects/system/lowcode/entityts/BAS_REASON_GRP.ts +++ b/src/views/tigerprojects/system/lowcode/entityts/BAS_REASON_GRP.ts @@ -4,11 +4,14 @@ * @version: * @Date: 2024-06-19 20:34:27 * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-22 22:39:11 + * @LastEditTime: 2024-06-22 23:33:08 */ import { ActionItem, BasicColumn } from '/@/components/Table'; import { buildUUID } from '/@/utils/uuid'; +import { useI18n } from '/@/hooks/web/useI18n'; + +const { t } = useI18n(); function _default() { /** @@ -69,6 +72,40 @@ RSNG_CODE: d.values['val'], }; }, + OpenSelectItem:(openItemModal: Fn) => { + openItemModal(true, { + title: '涓嶈壇鍘熷洜缁勫垪琛�', + schemas: [ + { + field: 'RSNG_CODE', + component: 'Input', + label: '涓嶈壇鍘熷洜缁勪唬鐮�', + colProps: { + span: 12, + }, + }, + ], + ItemColumns: [ + { + title: t('涓嶈壇鍘熷洜缁勪唬鐮�'), + dataIndex: 'RSNG_CODE', + resizable: true, + sorter: true, + width: 200, + }, + { + title: t('涓嶈壇鍘熷洜缁勫悕绉�'), + dataIndex: 'RSNG_NAME', + resizable: true, + sorter: true, + width: 180, + }, + ], + tableName: 'BAS_REASON_GRP', + rowKey: 'RSNG_CODE', + searchInfo: {TABLE_NAME: 'BAS_REASON_GRP'} + }); + } }; return [methods, ActionColumn]; diff --git a/src/views/tigerprojects/system/lowcode/entityts/ProdRouteBinding.ts b/src/views/tigerprojects/system/lowcode/entityts/ProdRouteBinding.ts index c68938f..c1b3f1f 100644 --- a/src/views/tigerprojects/system/lowcode/entityts/ProdRouteBinding.ts +++ b/src/views/tigerprojects/system/lowcode/entityts/ProdRouteBinding.ts @@ -4,38 +4,59 @@ * @version: * @Date: 2024-06-19 20:34:27 * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-22 00:04:06 + * @LastEditTime: 2024-06-23 00:38:02 */ + +import { GetRoutePTree } from '/@/api/tigerapi/mes/router'; +import { convertToTree } from '/@/api/tigerapi/system'; function _default() { - /** - * @description: 鑾峰彇鏍戝舰鍥炬爣 - * @param {Recordable} params - * @return {*} - */ -function CreateIcon(params: Recordable<any>) { - let icon = ''; - switch (params['type']) { - case 'Product': - icon = 'similar-product|svg'; - break; - case 'Route': - icon = 'route|svg'; - break; - case 'Node': - icon = 'node|svg'; - break; - case 'Action': - icon = 'rot_action|svg'; - break; - case 'Customer': - icon = 'customer|svg'; - break; - } - return icon; -} + const methods = { + /** + * @description: 鑾峰彇鏍戝舰鍥炬爣 + * @param {Recordable} params + * @return {*} + */ + CreateIcon: (params: Recordable<any>) => { + let icon = ''; + switch (params['type']) { + case 'Product': + icon = 'similar-product|svg'; + break; + case 'Route': + icon = 'route|svg'; + break; + case 'Node': + icon = 'node|svg'; + break; + case 'Action': + icon = 'rot_action|svg'; + break; + case 'Customer': + icon = 'customer|svg'; + break; + } + return icon; + }, + GetHomeUrl: () => { + return `/V_BAS_PROD/LC/${encodeURI(JSON.stringify({ ID: 'V_BAS_PROD', colSlots: [], crudColSlots: [] }))}`; + }, + /** + * @description: 鑾峰彇鏍戝舰鏁版嵁 + * @param {string} type + * @return {*} + */ + fetchTreeData: async (type: string, itemCode: string) => { + let data = { title: '', treeData: [] as any[], fieldNames: {} }; + let prodTreeData = await GetRoutePTree(itemCode); + data.treeData = convertToTree(prodTreeData, 'pid', 'id', 'root'); + data.title = '宸ヨ壓璺嚎'; + data.fieldNames = { key: 'id', title: 'name' }; + return data; + }, + }; -return [CreateIcon] + return [methods]; } export default _default; diff --git a/src/views/tigerprojects/system/lowcode/high/index.vue b/src/views/tigerprojects/system/lowcode/high/index.vue index d804b58..3f12464 100644 --- a/src/views/tigerprojects/system/lowcode/high/index.vue +++ b/src/views/tigerprojects/system/lowcode/high/index.vue @@ -145,12 +145,10 @@ import CustModal from '/@/views/components/CustModal.vue'; import { BasicForm, useForm } from '/@/components/Form/index'; import { - OpenSelectItem, custOnChange, getFormSchema, OpenCustModal, GetBasicColumnAndInit, - getHomeUrl, getTitle, getOthersValues, } from '../data'; @@ -161,6 +159,9 @@ import { useTabs } from '/@/hooks/web/useTabs'; import { buildUUID } from '/@/utils/uuid'; import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is'; + import { useI18n } from '/@/hooks/web/useI18n'; + + const { t } = useI18n(); const ACard = Card; const { getLocale } = useLocale(); @@ -370,8 +371,11 @@ } function goBack() { - // 鏈緥鐨勬晥鏋滄椂鐐瑰嚮杩斿洖濮嬬粓璺宠浆鍒拌处鍙峰垪琛ㄩ〉锛屽疄闄呭簲鐢ㄦ椂鍙繑鍥炰笂涓�椤� - go(getHomeUrl(entityName.value)); + if (!isNullOrUnDef(custImport.value)) { + const [{ GetHomeUrl }] = custImport.value.default(); + // 鏈緥鐨勬晥鏋滄椂鐐瑰嚮杩斿洖濮嬬粓璺宠浆鍒拌处鍙峰垪琛ㄩ〉锛屽疄闄呭簲鐢ㄦ椂鍙繑鍥炰笂涓�椤� + go(GetHomeUrl(entityName.value)); + } } onMounted(async () => { @@ -475,10 +479,16 @@ 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)); - }); + ) + .then((m) => { + const [{ GetSelectSuccess }] = m.default(); + getForm().setFieldsValue(GetSelectSuccess(d, u)); + }) + .catch(() => { + getForm().setFieldsValue({ + ITEM_CODE: d.values['val'], + }); + }); } catch (e) {} } @@ -488,10 +498,50 @@ * @return {*} */ function handleSelectItem(item) { - OpenSelectItem( - openItemModal, - getForm().getFieldsValue()[`${item.replace(/form-/, '').replace(/add/, '')}PSelect_0`], - ); + /* 鍔ㄦ�乮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) {} } /** diff --git a/src/views/tigerprojects/system/lowcode/normal/basDefectGrp.ts b/src/views/tigerprojects/system/lowcode/normal/basDefectGrp.ts index 63e2cec..c7e570f 100644 --- a/src/views/tigerprojects/system/lowcode/normal/basDefectGrp.ts +++ b/src/views/tigerprojects/system/lowcode/normal/basDefectGrp.ts @@ -96,41 +96,6 @@ } } -export function dftGrpOpenSelectItem(openItemModal: Fn) { - 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'} - }); -} - /** * @description: 涓嶈壇浠g爜鍩烘湰淇℃伅 * @return {*} diff --git a/src/views/tigerprojects/system/lowcode/normal/basReasonGrp.ts b/src/views/tigerprojects/system/lowcode/normal/basReasonGrp.ts index 8aeac93..37c7549 100644 --- a/src/views/tigerprojects/system/lowcode/normal/basReasonGrp.ts +++ b/src/views/tigerprojects/system/lowcode/normal/basReasonGrp.ts @@ -39,41 +39,6 @@ }, ]; -export function rsGrpOpenSelectItem(openItemModal: Fn) { - openItemModal(true, { - title: '涓嶈壇鍘熷洜缁勫垪琛�', - schemas: [ - { - field: 'RSNG_CODE', - component: 'Input', - label: '涓嶈壇鍘熷洜缁勪唬鐮�', - colProps: { - span: 12, - }, - }, - ], - ItemColumns: [ - { - title: t('涓嶈壇鍘熷洜缁勪唬鐮�'), - dataIndex: 'RSNG_CODE', - resizable: true, - sorter: true, - width: 200, - }, - { - title: t('涓嶈壇鍘熷洜缁勫悕绉�'), - dataIndex: 'RSNG_NAME', - resizable: true, - sorter: true, - width: 180, - }, - ], - tableName: 'BAS_REASON_GRP', - rowKey: 'RSNG_CODE', - searchInfo: {TABLE_NAME: 'BAS_REASON_GRP'} - }); -} - /* Select onChange 鏂规硶瀛楀吀 */ export const onChangeFns: Record<string, FunctionType> = { ABC: (e) => { diff --git a/src/views/tigerprojects/system/lowcode/normal/index.vue b/src/views/tigerprojects/system/lowcode/normal/index.vue index 794ea73..5ea5e10 100644 --- a/src/views/tigerprojects/system/lowcode/normal/index.vue +++ b/src/views/tigerprojects/system/lowcode/normal/index.vue @@ -4,7 +4,7 @@ * @version: * @Date: 2024-05-30 13:28:20 * @LastEditors: Ben Lin - * @LastEditTime: 2024-06-22 23:11:47 + * @LastEditTime: 2024-06-23 00:03:51 --> <template> <div> @@ -72,13 +72,15 @@ import CustModal from '/@/views/components/CustModal.vue'; import { BasicForm, useForm } from '/@/components/Form/index'; import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is'; - import { OpenSelectItem, custOnChange, OpenCustModal, GetUseModalData } from '../data'; + import { custOnChange, OpenCustModal, GetUseModalData } from '../data'; import { useModal } from '/@/components/Modal'; import { useLocale } from '/@/locales/useLocale'; import { uploadApi } from '/@/api/sys/upload'; import { useGo } from '/@/hooks/web/usePage'; + import { useI18n } from '/@/hooks/web/useI18n'; const { getLocale } = useLocale(); + const { t } = useI18n(); const route = useRoute(); const go = useGo(); const objParams = ref(JSON.parse(decodeURI(route.params?.id as string))); @@ -117,7 +119,7 @@ canResize: true, showIndexColumn: false, actionColumn: { - width: 80, + width: 130, title: '鎿嶄綔', dataIndex: 'action', slots: { customRender: 'action' }, @@ -354,10 +356,16 @@ 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)); - }); + ) + .then((m) => { + const [{ GetSelectSuccess }] = m.default(); + getForm().setFieldsValue(GetSelectSuccess(d, u)); + }) + .catch(() => { + getForm().setFieldsValue({ + ITEM_CODE: d.values['val'], + }); + }); } catch (e) {} } @@ -367,10 +375,50 @@ * @return {*} */ function handleSelectItem(item) { - OpenSelectItem( - openItemModal, - getForm().getFieldsValue()[`${item.replace(/form-/, '').replace(/add/, '')}PSelect_0`], - ); + /* 鍔ㄦ�乮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) {} } /** diff --git a/src/views/tigerprojects/system/lowcode/normalDrawer.vue b/src/views/tigerprojects/system/lowcode/normalDrawer.vue index b8cdb53..7a430d7 100644 --- a/src/views/tigerprojects/system/lowcode/normalDrawer.vue +++ b/src/views/tigerprojects/system/lowcode/normalDrawer.vue @@ -31,120 +31,197 @@ * @LastEditTime: 2024-06-14 09:14:35 --> <template> - <BasicDrawer v-bind="$attrs" @register="registerDrawer" showFooter :title="getTitle" width="600px" @ok="handleSubmit"> + <BasicDrawer + v-bind="$attrs" + @register="registerDrawer" + showFooter + :title="getTitle" + width="600px" + @ok="handleSubmit" + > <BasicForm @register="registerForm"> <template #[item]="{ field }" v-for="item in crudColSlots" :key="item"> - <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)" /> + <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> </BasicForm> </BasicDrawer> </template> <script lang="ts" setup> -import { ref, computed, unref, onMounted } from 'vue'; -import { BasicForm, FormSchema, useForm } from '/@/components/Form/index'; -import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; -import { useGlobSetting } from '/@/hooks/setting'; -import GeneralModal from '/@/views/components/GeneralModal.vue'; -import { SaveEntity, fetchJson, formatValues } from '/@/api/tigerapi/system'; -import { useModal } from '/@/components/Modal'; -import { GetSelectSuccess, OpenSelectItem } from './data'; -import { isNullOrUnDef } from '/@/utils/is'; -import { useMessage } from '/@/hooks/web/useMessage'; -import { useI18n } from '/@/hooks/web/useI18n'; + import { ref, computed, unref, onMounted } from 'vue'; + import { BasicForm, FormSchema, useForm } from '/@/components/Form/index'; + import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; + import { useGlobSetting } from '/@/hooks/setting'; + import GeneralModal from '/@/views/components/GeneralModal.vue'; + import { SaveEntity, fetchJson, formatValues } from '/@/api/tigerapi/system'; + import { useModal } from '/@/components/Modal'; + import { isNullOrUnDef } from '/@/utils/is'; + import { useMessage } from '/@/hooks/web/useMessage'; + import { useI18n } from '/@/hooks/web/useI18n'; -const emit = defineEmits(['success', 'register']); -const { t } = useI18n(); -const {createErrorModal} = useMessage(); -const globSetting = useGlobSetting(); -const isUpdate = ref(true); -const ifSave = ref(true); -const entityName = ref(''); -const formSchema = ref([]); -const crudColSlots = ref<any>([]); -const isExistSql = ref(''); -const [registerItemAdd, { openModal: openItemModal }] = useModal(); -const [registerForm, { resetFields, setFieldsValue, getFieldsValue, validate }] = useForm({ - labelWidth: 140, - schemas: formSchema as unknown as FormSchema[], - actionColOptions: { - span: 24, - }, - showActionButtonGroup: false, -}); + const emit = defineEmits(['success', 'register']); + const { t } = useI18n(); + const { createErrorModal } = useMessage(); + const globSetting = useGlobSetting(); + const isUpdate = ref(true); + const ifSave = ref(true); + const entityName = ref(''); + const formSchema = ref([]); + const crudColSlots = ref<any>([]); + const isExistSql = ref(''); + const [registerItemAdd, { openModal: openItemModal }] = useModal(); + const [registerForm, { resetFields, setFieldsValue, getFieldsValue, validate }] = useForm({ + labelWidth: 140, + schemas: formSchema as unknown as FormSchema[], + actionColOptions: { + span: 24, + }, + showActionButtonGroup: false, + }); -const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { - isUpdate.value = !!data?.isUpdate; - ifSave.value = !!data?.ifSave; - entityName.value = data?.entityName; - // formSchema.value = await fetchJson( - // `${globSetting.downloadUrl}/LowCode/${unref(entityName)}/${ - // entityName.value - // }_addEditform.json`, - // ); - formSchema.value = data?.formJson; - crudColSlots.value = data?.crudColSlots; - isExistSql.value = data?.isExistSql - resetFields(); - setDrawerProps({ confirmLoading: false }); + const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { + isUpdate.value = !!data?.isUpdate; + ifSave.value = !!data?.ifSave; + entityName.value = data?.entityName; + // formSchema.value = await fetchJson( + // `${globSetting.downloadUrl}/LowCode/${unref(entityName)}/${ + // entityName.value + // }_addEditform.json`, + // ); + formSchema.value = data?.formJson; + crudColSlots.value = data?.crudColSlots; + isExistSql.value = data?.isExistSql; + resetFields(); + setDrawerProps({ confirmLoading: false }); - if (unref(isUpdate)) { - setFieldsValue({ - ...data.record, - }); - } else { - if (!isNullOrUnDef(data?.others)) { - setFieldsValue(data?.others); - } - } -}); - -const getTitle = computed(() => (!unref(isUpdate) ? '鏂板' : '缂栬緫')); - -onMounted(async () => { }); -async function handleSubmit() { - try { - let values = await validate(); - //鍒ゆ柇淇濆瓨鐨勫�煎鏋滄槸[]鏁扮粍鐨勶紝灏辩洿鎺ュ彇[0]绗竴涓�硷紝涓�鑸拡瀵逛笂浼犳ā鏉跨殑鍦板潃 - values = formatValues(values); - setDrawerProps({ confirmLoading: true }); - // TODO custom api - if (!unref(ifSave)) { - //淇濆瓨 - SaveEntity(values, unref(isUpdate), unref(entityName), `${isExistSql.value}='${values[isExistSql.value]}'`).then((action) => { - if (action.IsSuccessed) { - closeDrawer(); - emit('success'); - }else{ - createErrorModal({ title: t('sys.api.errorTip'), content: action.Message }); - } + if (unref(isUpdate)) { + setFieldsValue({ + ...data.record, }); } else { - closeDrawer(); - emit('success', values, { isUpdate: isUpdate.value }); + if (!isNullOrUnDef(data?.others)) { + setFieldsValue(data?.others); + } } - } finally { - setDrawerProps({ confirmLoading: false }); + }); + + const getTitle = computed(() => (!unref(isUpdate) ? '鏂板' : '缂栬緫')); + + onMounted(async () => {}); + async function handleSubmit() { + try { + let values = await validate(); + //鍒ゆ柇淇濆瓨鐨勫�煎鏋滄槸[]鏁扮粍鐨勶紝灏辩洿鎺ュ彇[0]绗竴涓�硷紝涓�鑸拡瀵逛笂浼犳ā鏉跨殑鍦板潃 + values = formatValues(values); + setDrawerProps({ confirmLoading: true }); + // TODO custom api + if (!unref(ifSave)) { + //淇濆瓨 + SaveEntity( + values, + unref(isUpdate), + unref(entityName), + `${isExistSql.value}='${values[isExistSql.value]}'`, + ).then((action) => { + if (action.IsSuccessed) { + closeDrawer(); + emit('success'); + } else { + createErrorModal({ title: t('sys.api.errorTip'), content: action.Message }); + } + }); + } else { + closeDrawer(); + emit('success', values, { isUpdate: isUpdate.value }); + } + } finally { + setDrawerProps({ confirmLoading: false }); + } } -} -/** - * @description: 寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庝簨浠� - * @param {*} d - * @param {*} u - * @param {*} item - * @return {*} - */ -function handleItemSuccess(d, u, item) { - setFieldsValue(GetSelectSuccess(d, u, getFieldsValue()[`${item.replace(/add/, '')}PSelect_0`])); -} + /** + * @description: 寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庝簨浠� + * @param {*} d + * @param {*} u + * @param {*} item + * @return {*} + */ + function handleItemSuccess(d, u, item) { + /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ + try { + import( + /* @vite-ignore */ `./entityts/${getFieldsValue()[`${item.replace(/add/, '')}PSelect_0`]}` + ) + .then((m) => { + const [{ GetSelectSuccess }] = m.default(); + setFieldsValue(GetSelectSuccess(d, u)); + }) + .catch(() => { + setFieldsValue({ + ITEM_CODE: d.values['val'], + }); + }); + } catch (e) {} + } -/** - * @description: 寮瑰嚭閫夋嫨妗� - * @param {*} item - * @return {*} - */ -function handleSelectItem(item) { - OpenSelectItem(openItemModal, getFieldsValue()[`${item.replace(/add/, '')}PSelect_0`]); -} + /** + * @description: 寮瑰嚭閫夋嫨妗� + * @param {*} item + * @return {*} + */ + function handleSelectItem(item) { + /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ + try { + import( + /* @vite-ignore */ `./entityts/${getFieldsValue()[`${item.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> -- Gitblit v1.9.3