From 697c405ac874da346e74df40266763370355154d Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期六, 08 三月 2025 15:40:25 +0800 Subject: [PATCH] ASN单 --- src/views/tigerprojects/system/lowcode/detail/detail.vue | 364 ++++++++++++++++++++++++++++++++------------------- 1 files changed, 228 insertions(+), 136 deletions(-) diff --git a/src/views/tigerprojects/system/lowcode/detail/detail.vue b/src/views/tigerprojects/system/lowcode/detail/detail.vue index 5898fb3..4518d72 100644 --- a/src/views/tigerprojects/system/lowcode/detail/detail.vue +++ b/src/views/tigerprojects/system/lowcode/detail/detail.vue @@ -2,7 +2,15 @@ <div> <BasicTable @register="registerTable"> <template #toolbar> - <a-button type="primary" @click="handleCreate" preIcon="add_02|svg"> 鏂板 </a-button> + <a-button + type="primary" + v-for="item in buttons.filter((m) => m['BUTTON_TYPE'] == 0)" + @click="handleCreate(item['DO_METHOD'])" + :preIcon="item['ICON_URL']" + :key="item" + > + {{ item['FUNC_NAME'] }} + </a-button> </template> <template #action="{ record }"> <TableAction :actions="createActions(record)" /> @@ -22,64 +30,147 @@ /> </template> </BasicTable> + <Suspense> + <CustModal + @register="registerCust" + @success="custSuccess" + @cancel="custCancel" + :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> + <!-- 鑷畾涔夊唴瀹� --> + </template> + </CustModal> + </Suspense> <normalDrawer @register="registerDrawer" @success="handleSuccess" /> </div> </template> <script lang="ts" setup> import { Ref, inject, onMounted, ref } from 'vue'; - import { BasicTable, useTable, TableAction } from '/@/components/Table'; - import { useForm } from '/@/components/Form/index'; + import { BasicTable, useTable, TableAction, ActionItem } 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 { isNullOrUnDef } from '/@/utils/is'; + import CustModal from '/@/views/components/CustModal.vue'; + import { isFunction, isNullOrUnDef } from '/@/utils/is'; import { useModal } from '/@/components/Modal'; import { useGo } from '/@/hooks/web/usePage'; import { DeleteEntity, getListByPage } from '/@/api/tigerapi/system'; import { useI18n } from '/@/hooks/web/useI18n'; + import { EntityCustFunctionType } from '/@/api/tigerapi/model/basModel'; + import { GenerateActionButton } from '../data'; + import { getRoleButtons } from '/@/api/sys/menu'; + import { useRouter } from 'vue-router'; const { t } = useI18n(); - + const { currentRoute } = useRouter(); const props = defineProps({ useTableData: { type: Object as PropType<{}>, default: { table: [] } }, entityName: { type: String }, }); const objParams = inject('objParams') as Ref<any>; const data = inject('data') as Ref<Recordable[]>; - const others = inject('others') as Ref<Recordable[]>; + const keyFieldValues = inject('keyFieldValues') as Ref<Recordable[]>; const go = useGo(); const [registerDrawer, { openDrawer }] = useDrawer(); const [registerItemAdd, { openModal: openItemModal }] = useModal(); + const [registerCust, { openModal: openCustModal }] = useModal(); const cType = ref(''); + const selectVals = ref({}); const colSlots = ref<any>(objParams['colSlots']); //鎸夐挳鎻掓Ы const dtlSlots = 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 custImport = ref<any[]>([]); + const EntityCustFunction = ref([ + { + ActionItem(params, data, ...args) {}, + EditOperation(data, d, u, item) {}, + GetBaseColumns(type: string | undefined) {}, + GetSearchForm(type: string | undefined) {}, + GetCrudForm(type: string | undefined, ...args) {}, + KeyFieldValues(val, id) {}, + GetSelectSuccess(d, u, ...args) {}, + OpenSelectItem(openItemModal: Fn, ...args) {}, + } as EntityCustFunctionType, + ]); + /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ + try { + custImport.value = await import(`../entityts/${objParams['Name']}.ts`); + } catch (e) {} + const [ + { + ActionItem: nActionItem, + EditOperation, + GetBaseColumns, + GetSearchForm, + GetCrudForm, + KeyFieldValues, + GetSelectSuccess, + OpenSelectItem, + GetUseForm, + GetUseModals, + }, + ActionColumn, + ] = isNullOrUnDef(custImport.value['default']) + ? EntityCustFunction.value + : custImport.value['default'](); + const buttons = ref<[]>(await getRoleButtons(currentRoute.value.meta.menuCode as string)); + keyFieldValues.value = + KeyFieldValues && isFunction(KeyFieldValues) + ? KeyFieldValues(objParams['CODE'], objParams['ID']) + : []; + 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 CurrTabInfo = objParams['Tabs'].filter((q) => q.entityName == props.entityName)[0]; const [registerTable, { getForm, reload, setProps }] = useTable({ - title: `${objParams['firstTitle']}鍒楄〃`, - api: getListByPage, - searchInfo: { TABLE_NAME: objParams['Name'], ...objParams['others'] }, - columns: GetBaseColumns(), + title: `${CurrTabInfo.tableTitle}鍒楄〃`, + api: getListByPage, //閫氱敤鏌ヨ鏂规硶 + searchInfo: { + TABLE_NAME: CurrTabInfo.entityName, + NeedInclude: CurrTabInfo.NeedInclude, + ...objParams['keyFieldValues'], + }, //鏌ヨ鏉′欢涓殑TABLE_NAME浼犲叆椤电淇℃伅涓搴旂殑瀹炰綋鍚岰urrTabInfo.entityName + columns: GetBaseColumns(CurrTabInfo.entityName), //浼犲叆椤电淇℃伅涓搴旂殑瀹炰綋鍚岰urrTabInfo.entityName鑾峰彇琛ㄦ牸瀛楁淇℃伅 formConfig: { labelWidth: 140, - schemas: GetSearchForm(), + schemas: GetSearchForm(CurrTabInfo.entityName), //浼犲叆椤电淇℃伅涓搴旂殑瀹炰綋鍚岰urrTabInfo.entityName鑾峰彇鏌ヨ琛ㄥ崟鐨勫瓧娈典俊鎭� }, useSearchForm: true, showTableSetting: true, bordered: true, canResize: true, showIndexColumn: false, - actionColumn: { - width: 130, - title: '鎿嶄綔', - dataIndex: 'action', - slots: { customRender: 'action' }, - fixed: undefined, - }, //鑷畾涔夋搷浣滃垪 + actionColumn: ActionColumn + ? ActionColumn + : { + width: 120, + title: '鎿嶄綔', + dataIndex: 'action', + slots: { customRender: 'action' }, + fixed: 'right', + }, //鑷畾涔夋搷浣滃垪 }); onMounted(() => {}); @@ -88,12 +179,12 @@ * @description: 鐢熸垚鍒楄〃涓搷浣滈」鐨勬寜閽� * @param {*} record * @return {*} - */ + */ function createActions(record) { const params = { record, isUpdate: true, - ifSave: false, + ifSave: objParams['ifSave'], entityName: props.entityName, formJson: GetCrudForm(), //getFormSchema(`${entityName.value}_Crud`), cType, @@ -102,27 +193,15 @@ useFormData, crudColSlots: colSlots.value, data, + selectVals, + colSlots, }; - 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)) { + const _actionItem: ActionItem[] = []; + const actionItem = GenerateActionButton(params, buttons, openDrawer, reload, _actionItem); + if (isNullOrUnDef(custImport.value['default'])) { return actionItem; } - const [{ ActionItem }] = custImport.value['default'](); - return ActionItem( + return nActionItem( params, actionItem, openDrawer, @@ -132,36 +211,11 @@ useModal, go, setProps, + openCustModal, ); } - /** - * @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() { + function handleCreate(fnName: string) { const _cruds = GetCrudForm(); let isExistSql = ''; for (const i in _cruds) { @@ -169,15 +223,45 @@ isExistSql = _cruds[i].field; } } - openDrawer(true, { - isUpdate: false, - ifSave: false, - entityName: props.entityName, - formJson: GetCrudForm(), //getFormSchema(`${entityName.value}_Crud`), - crudColSlots: colSlots.value, - others: others.value, - isExistSql: isExistSql, - }); + + if (isNullOrUnDef(custImport.value['default'])) { + openDrawer(true, { + isUpdate: false, + ifSave: objParams.value['ifSave'], + entityName: props.entityName, + formJson: _cruds, //getFormSchema(`${entityName.value}_Crud`), + crudColSlots: colSlots.value, + keyFieldValues: keyFieldValues.value, + isExistSql: isExistSql, + }); + } else { + const [{ CreateAction }] = custImport.value['default'](); + const result = CreateAction(props.entityName); + switch (result.action) { + case 'go': + sessionStorage.removeItem(`${result.params.Name}_update_params`); + // 灏嗗璞¤浆鎹负JSON瀛楃涓插苟淇濆瓨鍒皊essionStorage + sessionStorage.setItem( + `${result.params.Name}_update_params`, + encodeURI(JSON.stringify(result.params)), + ); + go( + `/${result.url}/${encodeURI(JSON.stringify({ sName: `${result.params.Name}_update`, Name: result.params.Name }))}`, + ); + break; + case 'drawer': + openDrawer(true, { + isUpdate: false, + ifSave: objParams.value['ifSave'], + entityName: props.entityName, + formJson: _cruds, //getFormSchema(`${entityName.value}_Crud`), + crudColSlots: colSlots.value, + keyFieldValues: keyFieldValues.value, + isExistSql: isExistSql, + }); + break; + } + } } /** @@ -198,21 +282,7 @@ * @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) {} + getForm().setFieldsValue(GetSelectSuccess(d, u)); } /** @@ -221,49 +291,71 @@ * @return {*} */ function handleSelectItem(item) { + OpenSelectItem(openItemModal); + } + + /** + * @description: 寮瑰嚭妗嗙‘瀹氳繑鍥� + * @param {*} d + * @return {*} + */ + function custSuccess(d) { + reload(); + } + + /** + * @description: 寮瑰嚭妗嗗彇娑堣繑鍥� + * @param {*} reload + * @return {*} + */ + function custCancel() { + reload(); + } + + /** + * @description: 鍚勮〃鍗曞唴寮瑰嚭閫夋嫨妗嗛�夋嫨鎴愬姛鍚庢柟娉� + * @param {*} d + * @param {*} u + * @param {*} item + * @return {*} + */ + function handleEntSuccess(d, u, 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' }, - }); - }); + var values = GetSelectSuccess(d, u); + selectVals.value = values; //淇濆瓨寮瑰嚭妗嗛�夋嫨鐨勭粨鏋� + let _val = {}; + d.returnFieldName.map((x) => { + _val[x] = values[x]; + }); + useFormData.value[item][1].setFieldsValue(_val); } catch (e) {} } + + /** + * @description: 鎵撳紑琛ㄥ崟涓殑妯℃�佹 + * @param {*} item + * @return {*} + */ + function handleCustClick(item) { + OpenSelectItem( + useModalData.value[item][1].openModal, //甯﹀叆openModal鏂规硶 + item, + null, + selectVals, + ); + } + + /** + * @description: 鑾峰彇澶氳〃鍗曟彃妲藉垪琛� + * @param {*} d + * @return {*} + */ + function getdtlSlots(d, callback) { + dtlSlots.value = d; + callback(); + // setTimeout(() => { + // callback(); + // }, 100); + } </script> -- Gitblit v1.9.3