From 5a813f3b28f3cbf1db3a3657ccf83267c6e0d315 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期四, 24 十月 2024 11:22:02 +0800 Subject: [PATCH] 工艺路线相关优化 --- src/views/tigerprojects/system/lowcode/normal/mainTable.vue | 151 ++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 120 insertions(+), 31 deletions(-) diff --git a/src/views/tigerprojects/system/lowcode/normal/mainTable.vue b/src/views/tigerprojects/system/lowcode/normal/mainTable.vue index 3df755c..ac407e2 100644 --- a/src/views/tigerprojects/system/lowcode/normal/mainTable.vue +++ b/src/views/tigerprojects/system/lowcode/normal/mainTable.vue @@ -2,11 +2,12 @@ <div> <BasicTable @register="registerTable"> <template #toolbar> + <!-- 鏍规嵁鑿滃崟璁剧疆鐨勬寜閽紝鑷姩鐢熸垚 --> <a-button type="primary" + v-for="item in buttons.filter((m) => m['BUTTON_TYPE'] == 0)" @click="handleCreate(item['DO_METHOD'])" :preIcon="item['ICON_URL']" - v-for="item in buttons.filter((m) => m['BUTTON_TYPE'] == 0)" :key="item" > {{ item['FUNC_NAME'] }} @@ -25,7 +26,7 @@ preIcon="search|svg" /> <GeneralModal - @register="registerItemAdd" + @register="useModalInTableForm[item]" @success="(d, u) => handleItemSuccess(d, u, item)" /> </template> @@ -34,6 +35,7 @@ <CustModal @register="registerCust" @success="custSuccess" + @cancel="custCancel" :type="cType" :entityName="entityName" @modalInner="getdtlSlots" @@ -79,23 +81,28 @@ import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is'; import { useModal } from '/@/components/Modal'; import { useGo } from '/@/hooks/web/usePage'; - import { DeleteEntity, getEntity, getListByPage } from '/@/api/tigerapi/system'; + import { getListByPage } from '/@/api/tigerapi/system'; import { useI18n } from '/@/hooks/web/useI18n'; import { EntityCustFunctionType } from '/@/api/tigerapi/model/basModel'; import { getRoleButtons } from '/@/api/sys/menu'; import { useUserStore } from '/@/store/modules/user'; import { useRouter } from 'vue-router'; - import { GenerateActionButton, initRoute, OpenCustModal } from '../data'; + import { afterFetchFn, GenerateActionButton, initRoute, SearchInfoFn } from '../data'; import LogicFlow from '@logicflow/core'; import { isFunction } from 'xe-utils'; + import { CustModalParams } from '/@/api/tigerapi/model/systemModel'; + import { useQueryStore } from '/@/store/modules/queryInpage'; const { t } = useI18n(); const { currentRoute } = useRouter(); + const route = unref(currentRoute); + const useQuery = useQueryStore(); const props = defineProps({ useTableData: { type: Object as PropType<{}>, default: { table: [] } }, crudColSlots: { type: Object as PropType<any> }, }); const objParams = inject('objParams') as Ref<any>; + const savedParams = inject('savedParams') as Ref<any>; const colSlots = ref(objParams.value['colSlots']); const _columns = inject('_columns') as Ref<any[]>; const _searchFormSchema = inject('_searchFormSchema') as Ref<any[]>; @@ -107,9 +114,9 @@ const entityName = ref(objParams.value['ID']); const go = useGo(); const [registerDrawer, { openDrawer }] = useDrawer(); - const [registerItemAdd, { openModal: openItemModal }] = useModal(); const [registerRv, { openModal: openRvModal, closeModal: RvcloseModal }] = useModal(); const [registerCust, { openModal: openCustModal }] = useModal(); + const [registerCrud, { openModal: openCrudModal }] = useModal(); const cType = ref(''); const formSchemas = ref({}); //寮瑰嚭妗嗗琛ㄥ崟缁撴瀯 const routeData = ref({ @@ -125,12 +132,15 @@ OpenSelectItem(openItemModal: Fn, ...args) {}, GetSelectSuccess(d, u, ...args) {}, GetUseForm(...args) {}, + CustFunc(param: CustModalParams) {}, } as EntityCustFunctionType, ]); /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ try { custImport.value = await import(`../entityts/${objParams.value['ID']}.ts`); - } catch (e) {} + } catch (e) { + console.log(e) + } const [ { ActionItem: nActionItem, @@ -140,6 +150,7 @@ GetCustData, OpenSelectItem: OpenSelectCust, GetSelectSuccess, + CustFunc, }, ActionColumn, ] = isNullOrUnDef(custImport.value['default']) @@ -152,9 +163,14 @@ const dtlSlots = ref<any[]>([]); const useformdata = GetUseForm && isFunction(GetUseForm) ? GetUseForm() : {}; const useFormData = ref<any>(useformdata); - /* 琛ㄥ崟涓彃妲芥覆鏌撴寜閽墦寮�妯℃�佹useModal鏂规硶 */ + /* 鑷畾涔夋ā鎬佺獥鍙d腑琛ㄥ崟涓彃妲芥覆鏌撴寜閽墦寮�妯℃�佹useModal鏂规硶 */ const modals = GetUseModals && isFunction(GetUseModals) ? GetUseModals() : { useModalData: {} }; const useModalData = ref(modals['useModalData']); + /* 琛ㄦ牸鍐呯殑鎻掓Ы娓叉煋鐨勫脊鍑洪�夋嫨妗嗗垪琛� */ + const useModalInTableForm = ref<any>({}); + colSlots.value.map((x) => { + useModalInTableForm.value[x] = useModal(); + }); /* 鑾峰彇鑷畾涔夋暟鎹� */ const custData = GetCustData && isFunction(GetCustData) ? GetCustData() : { isCustEl: {} }; const isCustEl = ref(custData['isCustEl']); @@ -173,24 +189,37 @@ } : '', }, + beforeFetch: (t) => SearchInfoFn(t, route.name, AuthOption.value['BY_ORG'] == 'Y'), + afterFetch: afterFetch, columns: _columns as unknown as BasicColumn[], formConfig: { labelWidth: 140, schemas: _searchFormSchema as unknown as FormSchema[], + submitFunc: () => Search(), //鑷畾涔夋煡璇㈡彁浜ゆ寜閽殑鏂规硶锛岃Е鍙戞煡璇㈡彁浜や簨浠� + resetFunc: () => useQuery.resetFunc(route.name, getForm(), AuthOption.value['BY_ORG'] == 'Y'), }, useSearchForm: true, showTableSetting: true, bordered: true, canResize: true, showIndexColumn: false, - actionColumn: ActionColumn, //鑷畾涔夋搷浣滃垪 + actionColumn: ActionColumn + ? ActionColumn + : { + width: 120, + title: '鎿嶄綔', + dataIndex: 'action', + slots: { customRender: 'action' }, + fixed: 'right', + }, //鑷畾涔夋搷浣滃垪 }); watch( () => AuthOption.value, (newVal, oldVal) => { nextTick(() => { - if (!isNullOrEmpty(newVal.BY_ORG)) { + if (!isNullOrEmpty(newVal.BY_ORG) && !isNullOrUnDef(savedParams.value['params'])) { + getForm().setFieldsValue(savedParams.value['params']); setProps({ searchInfo: { TABLE_NAME: objParams.value['ID'], @@ -212,7 +241,39 @@ { deep: true, immediate: true }, ); - onMounted(() => {}); + onMounted(async () => { + if (!isNullOrUnDef(savedParams) && !isNullOrUnDef(savedParams.value['params'])) { + getForm().setFieldsValue(savedParams.value['params']); + reload(); + } + // if ( + // !isNullOrUnDef(useQuery.getCurSearchInfo['searchInfo']) && + // useQuery.getCurSearchInfo['name'] == route.name + // ) { + // getForm().resetFields(); + // const searchInfo = useQuery.getCurSearchInfo['searchInfo']; + // await getForm().setFieldsValue(searchInfo); + // } + }); + + /** + * @description: 鏌ヨ鎻愪氦 + * @return {*} + */ + async function Search() { + useQuery.submitFunc(route.name, getForm(), AuthOption.value['BY_ORG'] == 'Y').then(() => { + reload(); + }); + } + + /** + * @description: 璇锋眰涔嬪悗瀵硅繑鍥炲�艰繘琛屽鐞� + * @param {*} t + * @return {*} + */ + function afterFetch(t) { + afterFetchFn(t,route.name, getForm()) + } const currlf = ref(null) as Ref<LogicFlow | null>; /** @@ -221,7 +282,7 @@ * @return {*} */ async function init(lf, rotId) { - initRoute(lf, rotId, routeData, currlf); + initRoute(lf, rotId, routeData, currlf, null); } /** @@ -245,12 +306,16 @@ currlf, selectVals, colSlots, + ifSave: true, + sName: objParams.value['sName'], }; + /* 鏍规嵁鑿滃崟璁剧疆鐨勬寜閽嚜鍔ㄧ敓鎴愭搷浣滃垪涓殑鎸夐挳 */ const actionItem = GenerateActionButton(params, buttons, openDrawer, reload); if (isNullOrUnDef(custImport.value['default'])) { return actionItem; } + /* 鏍规嵁鍔ㄦ�佸姞杞界殑瀹炰綋绫诲悕.ts涓殑ActionItem鏂规硶锛屾覆鏌撴搷浣滃垪涓殑鎸夐挳鏂规硶 */ return nActionItem( params, actionItem, @@ -262,6 +327,7 @@ go, setProps, openCustModal, + openCrudModal, ); } @@ -284,18 +350,21 @@ */ function handleCreate(fnName: string) { if (isNullOrUnDef(custImport.value['default'])) { + /* 濡傛灉鍔ㄦ�佸姞杞界殑瀹炰綋绫�.ts涓嶅瓨鍦紝鍒欑洿鎺ユ墦寮�渚ц竟妗� */ openDrawer(true, { - isUpdate: false, - entityName: entityName.value, - formJson: _crudFormSchema.value, - crudColSlots: objParams.value['crudColSlots'], - isExistSql: isExistSql.value, + isUpdate: false, //鏄柊澧炶繕鏄紪杈戯紝false-鏂板|true-缂栬緫 + entityName: entityName.value, //瀹炰綋绫诲悕 + formJson: _crudFormSchema.value, //鏂板缂栬緫鐨勮〃鍗曠粨鏋� + crudColSlots: objParams.value['crudColSlots'], //鏂板缂栬緫鐨勮〃鍗曚腑鐨勬彃妲藉垪琛� + isExistSql: isExistSql.value, //鏄惁瀛樺湪妫�鏌ql锛屾瘮濡�: XXX_CODE = '12345' + ifSave: true, //鏄惁鎻愪氦琛ㄥ崟鏃朵繚瀛樺埌鏁版嵁搴擄紝鍚�-鏆傚瓨|鏄�-淇濆瓨 }); } else { + /* 濡傛灉鍔ㄦ�佸姞杞界殑瀹炰綋绫�.ts瀛樺湪锛屾牴鎹�.ts鏂囦欢涓殑鏂规硶鏉ユ墽琛屾搷浣� */ const [{ CreateAction }] = custImport.value['default'](); - const result = CreateAction(fnName); + const result = CreateAction(entityName.value, colSlots.value); switch (result.action) { - case 'go': + case 'go' /* 璺宠浆椤甸潰 */: // 灏嗗璞¤浆鎹负JSON瀛楃涓插苟淇濆瓨鍒皊essionStorage sessionStorage.setItem( `${result.params.Name}_params`, @@ -305,13 +374,14 @@ `/${result.url}/${encodeURI(JSON.stringify({ sName: result.params.Name, Name: result.params.Name }))}`, ); break; - case 'drawer': + case 'drawer' /* 鎵撳紑渚ц竟妗� */: openDrawer(true, { - isUpdate: false, - entityName: entityName.value, - formJson: _crudFormSchema.value, - crudColSlots: objParams.value['crudColSlots'], - isExistSql: isExistSql.value, + isUpdate: false, //鏄柊澧炶繕鏄紪杈戯紝false-鏂板|true-缂栬緫 + entityName: entityName.value, //瀹炰綋绫诲悕 + formJson: _crudFormSchema.value, //鏂板缂栬緫鐨勮〃鍗曠粨鏋� + crudColSlots: objParams.value['crudColSlots'], //鏂板缂栬緫鐨勮〃鍗曚腑鐨勬彃妲藉垪琛� + isExistSql: isExistSql.value, //鏄惁瀛樺湪妫�鏌ql锛屾瘮濡�: XXX_CODE = '12345' + ifSave: true, //鏄惁鎻愪氦琛ㄥ崟鏃朵繚瀛樺埌鏁版嵁搴擄紝鍚�-鏆傚瓨|鏄�-淇濆瓨 }); break; } @@ -325,6 +395,11 @@ * @return {*} */ function handleSuccess(d, u) { + if (CustFunc && isFunction(CustFunc)) { + CustFunc({ + values: d, + }); + } reload(); } @@ -343,7 +418,7 @@ ) .then((m) => { const [{ GetSelectSuccess: GetSelectSuccess2 }] = m.default(); - getForm().setFieldsValue(GetSelectSuccess2(d, u)); + getForm().setFieldsValue(GetSelectSuccess2(d, u, objParams.value['ID'])); }) .catch(() => { getForm().setFieldsValue({ @@ -366,10 +441,10 @@ ) .then((m) => { const [{ OpenSelectItem }] = m.default(); - OpenSelectItem(openItemModal); + OpenSelectItem(useModalInTableForm.value[item][1].openModal); }) .catch(() => { - openItemModal(true, { + useModalInTableForm.value[item][1].openModal(true, { title: '鐗╂枡鍒楄〃', schemas: [ { @@ -404,8 +479,22 @@ }); } catch (e) {} } - //寮瑰嚭妗嗙‘瀹氳繑鍥� + + /** + * @description: 寮瑰嚭妗嗙‘瀹氳繑鍥� + * @param {*} d + * @return {*} + */ function custSuccess(d) { + reload(); + } + + /** + * @description: 寮瑰嚭妗嗗彇娑堣繑鍥� + * @param {*} reload + * @return {*} + */ + function custCancel() { reload(); } @@ -423,11 +512,11 @@ selectVals.value = values; //淇濆瓨寮瑰嚭妗嗛�夋嫨鐨勭粨鏋� let _val = {}; d.returnFieldName.map((x) => { - _val[x] = values[x]; - }); + _val[x] = values[x]; + }); useFormData.value[item][1].setFieldsValue(_val); /* 閽堝宸ュ崟鐨勬柟娉� */ - if (d.returnFieldName.filter((x) => x == 'ROUTE_CODE') && item == 'prodinfo' ) { + if (d.returnFieldName.filter((x) => x == 'ROUTE_CODE') && item == 'prodinfo') { routeData.value = { nodes: [], edges: [], -- Gitblit v1.9.3