Ben Lin
2024-07-24 50111114eb8254fe4d6fc15e9781f2c47e3db74a
src/views/tigerprojects/system/lowcode/composition/Config.vue
@@ -4,10 +4,10 @@
 * @version: 
 * @Date: 2024-06-24 23:44:31
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-06-27 16:28:34
 * @LastEditTime: 2024-07-23 20:48:29
-->
<template>
  <Card :title="GetTitle()['configTitle']">
  <Card :title="GetTitle(props.configType)['configTitle']">
    <BasicForm @register="registerForm">
      <template #[item]="{ field }" v-for="item in GetCrudColSlots()" :key="item">
        <a-button
@@ -27,7 +27,7 @@
</template>
<script lang="ts" setup>
  import { Ref, inject, nextTick, onMounted, ref, unref, watch } from 'vue';
  import { BasicForm, useForm } from '/@/components/Form/index';
  import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
  import { Card } from 'ant-design-vue';
  import { useModal } from '/@/components/Modal';
  import GeneralModal from '/@/views/components/GeneralModal.vue';
@@ -37,37 +37,50 @@
  const { t } = useI18n();
  const emit = defineEmits(['success', 'register']);
  const props = defineProps({
    configType: { type: String },
  });
  const [registerItemAdd, { openModal: openItemModal }] = useModal();
  const objParams = inject('objParams') as Ref<any>;
  const custImport = ref<any[]>([]);
  const EntityCustFunction = ref([
    {
      GetCrudForm() {},
      GetCrudForm(type: string | undefined) {},
      GetCrudColSlots(val, id) {},
      OpenSelectItem(openItemModal: Fn, ...args) {},
      GetSelectSuccess(d, u, ...args) {},
      GetTitle() {},
      GetTitle(type: string | undefined) {},
      nodeChange(params: {
        resetFields: any;
        setFieldsValue: any;
        objParams: Ref<any>;
        selectedNodes: Ref<any[]>;
      }) {},
      SubmitFunc(values: Recordable<any>, emit) {},
      SubmitFunc(values: Recordable<any>, type: string, emit) {},
    } as EntityCustFunctionType,
  ]);
  /* 动态import实体名.ts的自定义方法 */
  try {
    custImport.value = await import(`../entityts/${objParams.value['Name']}.ts`);
  } catch (e) {}
  const [{ GetCrudForm, GetCrudColSlots, nodeChange, OpenSelectItem, GetSelectSuccess, GetTitle, SubmitFunc }] =
    isNullOrUnDef(custImport.value['default'])
      ? EntityCustFunction.value
      : custImport.value['default']();
  const [
    {
      GetCrudForm,
      GetCrudColSlots,
      nodeChange,
      OpenSelectItem,
      GetSelectSuccess,
      GetTitle,
      SubmitFunc,
    },
  ] = isNullOrUnDef(custImport.value['default'])
    ? EntityCustFunction.value
    : custImport.value['default']();
  const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
  let formSchema: FormSchema[] = GetCrudForm(props.configType);
  const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useForm({
    labelWidth: 120,
    schemas: GetCrudForm(),
    schemas: formSchema,
    actionColOptions: {
      offset: 8,
      span: 24,
@@ -77,7 +90,7 @@
    },
    showActionButtonGroup: true,
    submitButtonOptions: {
      text: '提交',
      text: '保存',
    },
    submitFunc: customSubmitFunc,
  });
@@ -90,6 +103,13 @@
      nextTick(() => {
        /* 节点切换事件 */
        nodeChange({ resetFields, setFieldsValue, objParams, selectedNodes });
        formSchema = GetCrudForm(selectedNodes.value[0].type);
        setProps({
          schemas: []
        });
        setProps({
          schemas: formSchema
        });
      });
    },
    { deep: true, immediate: true },
@@ -103,7 +123,7 @@
  async function customSubmitFunc() {
    try {
      const values = await validate();
      SubmitFunc(values, emit);
      SubmitFunc(values,props.configType, emit);
      // values.AUTH_PROD = useUserStore().getUserInfo.prodCode;
      // values.FACTORY = useUserStore().getUserInfo.prodCode;
      // const apiAction = SaveEntity(values, true, 'MES_PROD_ACTION');
@@ -112,7 +132,7 @@
      //     emit('success');
      //   }
      // });
    }catch(e) {}
    } catch (e) {}
  }
  /**