| | |
| | | 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'; |
| | | |
| | | const { t } = useI18n(); |
| | | |
| | |
| | | }); |
| | | 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 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, |
| | | ]); |
| | | /* 动态import实体名.ts的自定义方法 */ |
| | | try { |
| | | custImport.value = await import(`../entityts/${objParams['Name']}.ts`); |
| | | } catch (e) {} |
| | | const [ |
| | | { |
| | | ActionItem: nActionItem, |
| | | EditOperation, |
| | | GetBaseColumns, |
| | | GetSearchForm, |
| | | GetCrudForm, |
| | | KeyFieldValues, |
| | | GetSelectSuccess, |
| | | OpenSelectItem, |
| | | }, |
| | | ] = isNullOrUnDef(custImport.value['default']) |
| | | ? EntityCustFunction.value |
| | | : custImport.value['default'](); |
| | | keyFieldValues.value = KeyFieldValues(objParams['CODE'], objParams['ID']); |
| | | const [registerTable, { getForm, reload, setProps }] = useTable({ |
| | | title: `${objParams['firstTitle']}列表`, |
| | | api: getListByPage, |
| | | searchInfo: { TABLE_NAME: objParams['Name'], ...objParams['others'] }, |
| | | searchInfo: { TABLE_NAME: objParams['Name'], ...objParams['keyFieldValues'] }, |
| | | columns: GetBaseColumns(), |
| | | formConfig: { |
| | | labelWidth: 140, |
| | |
| | | * @description: 生成列表中操作项的按钮 |
| | | * @param {*} record |
| | | * @return {*} |
| | | */ |
| | | */ |
| | | function createActions(record) { |
| | | const params = { |
| | | record, |
| | |
| | | if (isNullOrUnDef(custImport.value)) { |
| | | return actionItem; |
| | | } |
| | | const [{ ActionItem }] = custImport.value['default'](); |
| | | return ActionItem( |
| | | return nActionItem( |
| | | params, |
| | | actionItem, |
| | | openDrawer, |
| | |
| | | entityName: props.entityName, |
| | | formJson: GetCrudForm(), //getFormSchema(`${entityName.value}_Crud`), |
| | | crudColSlots: colSlots.value, |
| | | others: others.value, |
| | | keyFieldValues: keyFieldValues.value, |
| | | isExistSql: isExistSql, |
| | | }); |
| | | } |
| | |
| | | * @return {*} |
| | | */ |
| | | function handleItemSuccess(d, u, item) { |
| | | /* 动态import实体名.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)); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return {*} |
| | | */ |
| | | function handleSelectItem(item) { |
| | | /* 动态import实体名.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) {} |
| | | OpenSelectItem(openItemModal); |
| | | } |
| | | </script> |