Ben Lin
2024-07-24 50111114eb8254fe4d6fc15e9781f2c47e3db74a
src/views/tigerprojects/system/lowcode/composition/Config.vue
@@ -4,12 +4,12 @@
 * @version: 
 * @Date: 2024-06-24 23:44:31
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-06-26 18:45:42
 * @LastEditTime: 2024-07-23 20:48:29
-->
<template>
  <Card title="行为配置">
  <Card :title="GetTitle(props.configType)['configTitle']">
    <BasicForm @register="registerForm">
      <template #[item]="{ field }" v-for="item in crudColSlots" :key="item">
      <template #[item]="{ field }" v-for="item in GetCrudColSlots()" :key="item">
        <a-button
          v-if="field"
          class="mt-1 ml-1"
@@ -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,40 +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([
    {
      ActionItem(params, data, ...args) {},
      EditOperation(data, d, u) {},
      GetBaseColumns() {},
      GetSearchForm() {},
      GetCrudForm() {},
      GetCrudForm(type: string | undefined) {},
      GetCrudColSlots(val, id) {},
      OpenSelectItem(openItemModal: Fn, ...args) {},
      GetSelectSuccess(d, u, ...args) {},
      GetTitle(type: string | undefined) {},
      nodeChange(params: {
        resetFields: any;
        setFieldsValue: any;
        objParams: Ref<any>;
        selectedNodes: Ref<any[]>;
      }) {},
      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 }] =
    isNullOrUnDef(custImport.value['default'])
      ? EntityCustFunction.value
      : custImport.value['default']();
  const crudColSlots = ref<any>(GetCrudColSlots());
  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,
@@ -80,7 +90,7 @@
    },
    showActionButtonGroup: true,
    submitButtonOptions: {
      text: '提交',
      text: '保存',
    },
    submitFunc: customSubmitFunc,
  });
@@ -93,6 +103,13 @@
      nextTick(() => {
        /* 节点切换事件 */
        nodeChange({ resetFields, setFieldsValue, objParams, selectedNodes });
        formSchema = GetCrudForm(selectedNodes.value[0].type);
        setProps({
          schemas: []
        });
        setProps({
          schemas: formSchema
        });
      });
    },
    { deep: true, immediate: true },
@@ -104,26 +121,18 @@
  });
  async function customSubmitFunc() {
    // try {
    //   const values = await validate();
    //   setDrawerProps({ confirmLoading: true });
    //   // TODO custom api
    //   //保存工单
    //   if (!unref(isUpdate)) {
    //     values.STATUS = 0;
    //   }
    //   values.AUTH_PROD = useUserStore().getUserInfo.prodCode;
    //   values.FACTORY = useUserStore().getUserInfo.prodCode;
    //   const apiAction = SaveEntity(values, unref(isUpdate), 'BIZ_MES_WO');
    //   apiAction.then((action) => {
    //     if (action.IsSuccessed) {
    //       closeDrawer();
    //       emit('success');
    //     }
    //   });
    // } finally {
    //   setDrawerProps({ confirmLoading: false });
    // }
    try {
      const values = await validate();
      SubmitFunc(values,props.configType, emit);
      // values.AUTH_PROD = useUserStore().getUserInfo.prodCode;
      // values.FACTORY = useUserStore().getUserInfo.prodCode;
      // const apiAction = SaveEntity(values, true, 'MES_PROD_ACTION');
      // apiAction.then((action) => {
      //   if (action.IsSuccessed) {
      //     emit('success');
      //   }
      // });
    } catch (e) {}
  }
  /**