| | |
| | | * @Author: Ben Lin |
| | | * @version: |
| | | * @Date: 2024-06-05 15:46:07 |
| | | * @LastEditors: your name |
| | | * @LastEditTime: 2024-06-10 23:48:05 |
| | | * @LastEditors: Ben Lin |
| | | * @LastEditTime: 2024-07-18 15:42:20 |
| | | --> |
| | | <template> |
| | | <BasicModal |
| | |
| | | </BasicModal> |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import { ref, unref, nextTick, watch } from 'vue'; |
| | | import { ref, unref, nextTick, watch, Ref } from 'vue'; |
| | | import { BasicModal, useModalInner } from '/@/components/Modal'; |
| | | import { FormSchema } from '/@/components/Form/index'; |
| | | import { custFunction } from './data'; |
| | | import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is'; |
| | | import { Layout, LayoutContent, Card } from 'ant-design-vue'; |
| | | import { useMessage } from '/@/hooks/web/useMessage'; |
| | | import { useI18n } from '/@/hooks/web/useI18n'; |
| | | import { EntityCustFunctionType } from '/@/api/tigerapi/model/basModel'; |
| | | import { CustModalParams } from '/@/api/tigerapi/model/systemModel'; |
| | | |
| | | const { t } = useI18n(); |
| | | const { notification, createErrorModal } = useMessage(); |
| | |
| | | const cType = ref(''); |
| | | const title = ref(''); |
| | | const width = ref(''); |
| | | const FnName = ref({}); |
| | | const FnName = ref(''); |
| | | const mValues = ref<Recordable>({}); |
| | | const initFnName = ref({}); |
| | | const dtlSlots = ref([] as any[]); |
| | | const formSchema = ref([] as FormSchema[]); |
| | | const formElName = ref([]); |
| | | const useFormData = ref({}); |
| | | const useFormData = ref<any>({}); |
| | | const props = defineProps({ |
| | | detailSlots: { type: Array, default: [] }, |
| | | entityName: { type: String }, |
| | | }); |
| | | |
| | | const custImport = ref<any[]>([]); |
| | | const EntityCustFunction = ref([ |
| | | { |
| | | CustFunc(param: CustModalParams) {}, |
| | | } as EntityCustFunctionType, |
| | | ]); |
| | | /* 动态import实体名.ts的自定义方法 */ |
| | | try { |
| | | custImport.value = await import(`../tigerprojects/system/lowcode/entityts/${props.entityName}.ts`); |
| | | } catch (e) {} |
| | | const [{ CustFunc }] = isNullOrUnDef(custImport.value['default']) |
| | | ? EntityCustFunction.value |
| | | : custImport.value['default'](); |
| | | |
| | | watch( |
| | | () => props.detailSlots, |
| | | (v) => { |
| | |
| | | //循环表单名数组,操作各表单字段 |
| | | formElName.value.forEach((name) => { |
| | | if (!isNullOrUnDef(useFormData.value[name])) { |
| | | useFormData.value[name][1].resetFields(); |
| | | useFormData.value[name][1]['resetFields'](); |
| | | if (unref(isUpdate)) { |
| | | useFormData.value[name][1].setFieldsValue({ |
| | | useFormData.value[name][1]['setFieldsValue']({ |
| | | ...mValues.value, |
| | | }); |
| | | } |
| | |
| | | //初始化方法自定义 |
| | | if (!isNullOrEmpty(data?.initFnName)) { |
| | | initFnName.value = data?.initFnName; |
| | | custFunction( |
| | | unref(isUpdate.value), |
| | | initFnName.value[cType.value], |
| | | cType.value, |
| | | mValues.value, |
| | | data?.others, |
| | | ); |
| | | let param: CustModalParams = { |
| | | cType: cType.value, |
| | | values: unref(isUpdate.value), |
| | | mValues: mValues.value, |
| | | others: data?.others, |
| | | FnName: initFnName.value[cType.value], |
| | | }; |
| | | CustFunc(param); |
| | | } |
| | | }); |
| | | |
| | |
| | | /** |
| | | * @description: 弹框确定按钮方法 |
| | | * @return {*} |
| | | */ |
| | | */ |
| | | async function handleSuccess() { |
| | | try { |
| | | var values = {} as any; |
| | |
| | | setModalProps({ confirmLoading: true }); |
| | | //调用自定义保存方法保存数据 |
| | | values['mValues'] = mValues.value; |
| | | const action = await custFunction(values, FnName.value[cType.value], cType.value); |
| | | if (action as boolean) { |
| | | const action = await CustFunc({ |
| | | cType: cType.value, |
| | | values: values, |
| | | FnName: FnName.value, |
| | | } as unknown as CustModalParams); |
| | | if (action.IsSuccessed) { |
| | | closeModal(); |
| | | //成功事件,将数据返回原页面 |
| | | emit('success', { |
| | |
| | | } else { |
| | | createErrorModal({ |
| | | title: t('警告'), |
| | | content: t('保存数据失败'), |
| | | content: t(action.LocaleMsg), |
| | | getContainer: () => document.body, |
| | | }); |
| | | } |