From eed29804d3973801f8eac3ad9bead1e608f05b6a Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期六, 20 七月 2024 22:31:56 +0800 Subject: [PATCH] 工单及自定义弹出窗口更新 --- src/views/tigerprojects/system/lowcode/normal/mainTable.vue | 310 ++++++++++++++++++++++++++++++++++----------------- 1 files changed, 204 insertions(+), 106 deletions(-) diff --git a/src/views/tigerprojects/system/lowcode/normal/mainTable.vue b/src/views/tigerprojects/system/lowcode/normal/mainTable.vue index 22e76eb..4f4a1b9 100644 --- a/src/views/tigerprojects/system/lowcode/normal/mainTable.vue +++ b/src/views/tigerprojects/system/lowcode/normal/mainTable.vue @@ -30,24 +30,52 @@ /> </template> </BasicTable> + <Suspense> + <CustModal + @register="registerCust" + @success="custSuccess" + :type="cType" + :entityName="entityName" + @modalInner="getdtlSlots" + > + <!-- 鐢ㄦ彃妲借嚜瀹氫箟澶氳〃鍗� --> + <template #[item.name] v-for="item in dtlSlots" :key="item.name"> + <BasicForm @register="useFormData[item.name][0]" v-if="useFormData[item.name]"> + <!-- 鐢ㄦ彃妲借嚜瀹氫箟寮瑰嚭閫夋嫨妗� --> + <template #[name]="{ field }" v-for="name in item.slots" :key="name"> + <a-button + class="mt-1 ml-1" + size="small" + @click="handleCustClick(field)" + :preIcon="item.preIcons[name]" + /> + <GeneralModal + @register="useModalData[name][0]" + @success="(d, u) => handleEntSuccess(d, u, item.name)" + /> + </template> + </BasicForm> + <!-- 鑷畾涔夊唴瀹� --> + <div class="h-full" style="height: 380px" v-if="isCustEl[item.name]"> + <FlowChartView :data="routeData" @init="init" /> + <RouteViewModal @register="registerRv" @success="RvItemSuccess" /> + </div> + </template> + </CustModal> + </Suspense> <normalDrawer @register="registerDrawer" @success="handleSuccess" /> </div> </template> <script lang="ts" setup> - import { Ref, inject, nextTick, onMounted, ref, watch } from 'vue'; - import { - BasicTable, - useTable, - TableAction, - BasicColumn, - FormSchema, - ActionItem, - PopConfirm, - } from '/@/components/Table'; + import { Ref, inject, nextTick, onMounted, ref, unref, watch } from 'vue'; + import { BasicTable, useTable, TableAction, BasicColumn, FormSchema } 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 CustModal from '/@/views/components/CustModal.vue'; + import RouteViewModal from '/@/views/components/RouteViewModal.vue'; + import { FlowChartView } from '/@/components/FlowChart'; import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is'; import { useModal } from '/@/components/Modal'; import { useGo } from '/@/hooks/web/usePage'; @@ -55,65 +83,96 @@ 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 LogicFlow from '@logicflow/core'; + import { isFunction } from 'xe-utils'; const { t } = useI18n(); const { currentRoute } = useRouter(); const props = defineProps({ - colSlots: { type: Array as PropType<any[]> }, useTableData: { type: Object as PropType<{}>, default: { table: [] } }, crudColSlots: { type: Object as PropType<any> }, }); const objParams = inject('objParams') as Ref<any>; + const colSlots = ref(objParams.value['colSlots']); const _columns = inject('_columns') as Ref<any[]>; const _searchFormSchema = inject('_searchFormSchema') as Ref<any[]>; const _crudFormSchema = inject('_crudFormSchema') as Ref<any[]>; const buttons = ref<[]>(await getRoleButtons(currentRoute.value.meta.menuCode as string)); const isExistSql = inject('isExistSql') as Ref<string>; - const others = inject('others') as Ref<Recordable[]>; - const entityName = ref(objParams['ID']); + const keyFieldValues = inject('keyFieldValues') as Ref<Recordable[]>; + const AuthOption = inject('AuthOption') as Ref<{}>; + 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 cType = ref(''); - const dtlSlots = ref([] as any[]); const formSchemas = ref({}); //寮瑰嚭妗嗗琛ㄥ崟缁撴瀯 - const useModalData = ref({}); //琛ㄥ崟涓彃妲芥覆鏌撴寜閽墦寮�妯℃�佹useModal鏂规硶 - const useFormData = ref({}); + const routeData = ref({ + nodes: [], + edges: [], + }); + const selectVals = ref({}); const custImport = ref<any[]>([]); const EntityCustFunction = ref([ { ActionItem(params, data, ...args) {}, - EditOperation(data, d, u) {}, - GetBaseColumns(type: string | undefined) {}, - GetSearchForm(type: string | undefined) {}, - GetCrudForm(type: string | undefined, ...args) {}, - OthersValues(val, id) {}, + KeyFieldValues(val, id) {}, + OpenSelectItem(openItemModal: Fn, ...args) {}, + GetSelectSuccess(d, u, ...args) {}, + GetUseForm(...args) {}, } as EntityCustFunctionType, ]); /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ try { - custImport.value = await import(`../entityts/${objParams['ID']}.ts`); + custImport.value = await import(`../entityts/${objParams.value['ID']}.ts`); } catch (e) {} const [ { ActionItem: nActionItem, - EditOperation, - GetBaseColumns, - GetSearchForm, - GetCrudForm, - OthersValues, + KeyFieldValues, + GetUseForm, + GetUseModals, + GetCustData, + OpenSelectItem: OpenSelectCust, + GetSelectSuccess, }, + ActionColumn, ] = isNullOrUnDef(custImport.value['default']) ? EntityCustFunction.value : custImport.value['default'](); - others.value = isNullOrUnDef(OthersValues) + + keyFieldValues.value = isNullOrUnDef(KeyFieldValues) ? {} - : OthersValues(objParams['CODE'], objParams['ID']); + : KeyFieldValues(objParams.value['CODE'], objParams.value['ID']); + const dtlSlots = ref<any[]>([]); + const useformdata = GetUseForm && isFunction(GetUseForm) ? GetUseForm() : {}; + const useFormData = ref<any>(useformdata); + /* 琛ㄥ崟涓彃妲芥覆鏌撴寜閽墦寮�妯℃�佹useModal鏂规硶 */ + const modals = GetUseModals && isFunction(GetUseModals) ? GetUseModals() : { useModalData: {} }; + const useModalData = ref(modals['useModalData']); + /* 鑾峰彇鑷畾涔夋暟鎹� */ + const custData = GetCustData && isFunction(GetCustData) ? GetCustData() : { isCustEl: {} }; + const isCustEl = ref(custData['isCustEl']); const [registerTable, { getForm, reload, setProps }] = useTable({ title: '鍒楄〃淇℃伅', api: getListByPage, - searchInfo: { TABLE_NAME: objParams['ID'] }, + searchInfo: { + TABLE_NAME: objParams.value['ID'], + option: + AuthOption.value['BY_ORG'] == 'Y' + ? { + //鏍规嵁鎹偣鏌ヨ锛屽繀闇�甯﹁繖涓弬鏁� + UserId: useUserStore().getUserInfo.userId, + ByOrg: true, + CurOrg: useUserStore().getUserInfo.orgCode, + } + : '', + }, columns: _columns as unknown as BasicColumn[], formConfig: { labelWidth: 140, @@ -124,16 +183,46 @@ bordered: true, canResize: true, showIndexColumn: false, - actionColumn: { - width: 130, - title: '鎿嶄綔', - dataIndex: 'action', - slots: { customRender: 'action' }, - fixed: undefined, - }, //鑷畾涔夋搷浣滃垪 + actionColumn: ActionColumn, //鑷畾涔夋搷浣滃垪 }); + watch( + () => AuthOption.value, + (newVal, oldVal) => { + nextTick(() => { + if (!isNullOrEmpty(newVal.BY_ORG)) { + setProps({ + searchInfo: { + TABLE_NAME: objParams.value['ID'], + option: + AuthOption.value['BY_ORG'] == 'Y' + ? { + //鏍规嵁鎹偣鏌ヨ锛屽繀闇�甯﹁繖涓弬鏁� + UserId: useUserStore().getUserInfo.userId, + ByOrg: true, + CurOrg: useUserStore().getUserInfo.orgCode, + } + : '', + }, + }); + reload(); + } + }); + }, + { deep: true, immediate: true }, + ); + onMounted(() => {}); + + const currlf = ref(null) as Ref<LogicFlow | null>; + /** + * @description: 宸ヨ壓璺嚎鍒濆鍖� + * @param {*} lf + * @return {*} + */ + async function init(lf, rotId) { + initRoute(lf, rotId, routeData, currlf); + } /** * @description: 鐢熸垚鍒楄〃涓搷浣滈」鐨勬寜閽� @@ -144,17 +233,21 @@ const params = { record, isUpdate: true, - entityName: objParams['ID'], + entityName: objParams.value['ID'], formJson: _crudFormSchema.value, cType, dtlSlots, formSchemas, useModalData, useFormData, - crudColSlots: objParams['crudColSlots'], + crudColSlots: objParams.value['crudColSlots'], + routeData, + currlf, + selectVals, + colSlots, }; - const actionItem = GenerateActionButton(params); + const actionItem = GenerateActionButton(params, buttons, openDrawer, reload); if (isNullOrUnDef(custImport.value['default'])) { return actionItem; } @@ -168,72 +261,21 @@ useModal, go, setProps, + openCustModal, ); } /** - * @description: 鑾峰彇鏉冮檺鎸夐挳鍒楄〃 - * @param {*} params + * @description: 鑾峰彇澶氳〃鍗曟彃妲藉垪琛� + * @param {*} d * @return {*} */ - function GenerateActionButton(params: any) { - let actionItem = [] as ActionItem[]; - buttons.value.map((x) => { - if (x['BUTTON_TYPE'] == 1) { - let url = ''; - let color = undefined as 'success' | 'error' | 'warning' | undefined; - let _click = null as any; - let _popConfirm = undefined as PopConfirm | undefined; - if (x['DO_METHOD'] == 'Edit') { - url = 'clarity:note-edit-line'; - _click = editRecord.bind(null, openDrawer, params); - } else { - _click = x['ICON_URL']; - if (x['DO_METHOD'] == 'Delete') { - url = 'ant-design:delete-outlined'; - color = 'error'; - _popConfirm = { - title: '鏄惁纭鍒犻櫎?', - placement: 'left', - confirm: deleteRecord.bind(null, reload, params), - }; - } - } - actionItem.push({ - icon: isNullOrEmpty(x['ICON_URL']) ? url : x['ICON_URL'], - onClick: _click, - color: color, - popConfirm: _popConfirm, - }); - } - }); - return actionItem; - } - - /** - * @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 getdtlSlots(d, callback) { + dtlSlots.value = d; + callback(); + // setTimeout(() => { + // callback(); + // }, 100); } /** @@ -246,7 +288,7 @@ isUpdate: false, entityName: entityName.value, formJson: _crudFormSchema.value, - crudColSlots: objParams['crudColSlots'], + crudColSlots: objParams.value['crudColSlots'], isExistSql: isExistSql.value, }); } else { @@ -255,15 +297,20 @@ switch (result.action) { case 'go': // 灏嗗璞¤浆鎹负JSON瀛楃涓插苟淇濆瓨鍒皊essionStorage - sessionStorage.setItem(`${result.params.Name}_params`, encodeURI(JSON.stringify(result.params))); - go(`/${result.url}/${encodeURI(JSON.stringify({ sName: result.params.Name, Name: result.params.Name }))}`); + sessionStorage.setItem( + `${result.params.Name}_params`, + encodeURI(JSON.stringify(result.params)), + ); + go( + `/${result.url}/${encodeURI(JSON.stringify({ sName: result.params.Name, Name: result.params.Name }))}`, + ); break; case 'drawer': openDrawer(true, { isUpdate: false, entityName: entityName.value, formJson: _crudFormSchema.value, - crudColSlots: objParams['crudColSlots'], + crudColSlots: objParams.value['crudColSlots'], isExistSql: isExistSql.value, }); break; @@ -295,8 +342,8 @@ `../entityts/${getForm().getFieldsValue()[`${item.replace(/form-/, '').replace(/add/, '')}PSelect_0`]}.ts` ) .then((m) => { - const [{ GetSelectSuccess }] = m.default(); - getForm().setFieldsValue(GetSelectSuccess(d, u)); + const [{ GetSelectSuccess: GetSelectSuccess2 }] = m.default(); + getForm().setFieldsValue(GetSelectSuccess2(d, u)); }) .catch(() => { getForm().setFieldsValue({ @@ -357,4 +404,55 @@ }); } catch (e) {} } + //寮瑰嚭妗嗙‘瀹氳繑鍥� + function custSuccess(d) { + // reload(); + } + + /** + * @description: 鍚勮〃鍗曞唴寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庢柟娉� + * @param {*} d + * @param {*} u + * @param {*} item + * @return {*} + */ + function handleEntSuccess(d, u, item) { + /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ + try { + var values = GetSelectSuccess(d, u); + selectVals.value = values; //淇濆瓨寮瑰嚭妗嗛�夋嫨鐨勭粨鏋� + let _val = {}; + _val[d.returnFieldName] = values[d.returnFieldName]; + useFormData.value[item][1].setFieldsValue(_val); + /* 閽堝宸ュ崟鐨勬柟娉� */ + if (d.returnFieldName == 'ROUTE_CODE') { + routeData.value = { + nodes: [], + edges: [], + }; + + init(currlf, selectVals.value['ROUTE_CODE']); + const { transformModel, width, height } = unref(currlf).graphModel; + transformModel.focusOn(565, 200, width, height); + } + } catch (e) {} + } + + /** + * @description: 鎵撳紑琛ㄥ崟涓殑妯℃�佹 + * @param {*} item + * @return {*} + */ + function handleCustClick(item) { + OpenSelectCust( + useModalData.value[item][1].openModal, //甯﹀叆openModal鏂规硶 + item, + openRvModal, + selectVals, + ); + } + + function RvItemSuccess(d, u) { + RvcloseModal(); + } </script> -- Gitblit v1.9.3