Ben Lin
2024-11-12 a42c6f16bbb177dfcc754d53d925afddead38eba
src/views/tigerprojects/system/lowcode/high/dtl.vue
@@ -49,6 +49,7 @@
  import { useI18n } from '/@/hooks/web/useI18n';
  import { Card } from 'ant-design-vue';
  import { EntityCustFunctionType } from '/@/api/tigerapi/model/basModel';
  import { useMessage } from '/@/hooks/web/useMessage';
  const { t } = useI18n();
  const ACard = Card;
@@ -67,6 +68,7 @@
  const keyFieldValues = inject('keyFieldValues') as Ref<Recordable[]>;
  const go = useGo();
  const { createErrorModal } = useMessage();
  const [registerItemAdd, { openModal: openItemModal }] = useModal();
  const cType = ref('');
  const dtlSlots = ref([] as any[]);
@@ -173,20 +175,20 @@
  function createActions(record, index, item) {
    const params = {
      record,
      isUpdate: true,
      ifSave: objParams.value['ifSave'],
      entityName: props.entityName,
      formJson: [], //getFormSchema(`${entityName.value}_Crud`),
      cType,
      isUpdate: true, //是更新还是新增
      ifSave: objParams.value['ifSave'], //是否直接保存表单到数据库,false的话要最后一起提交
      entityName: props.entityName, //实体名称
      formJson: [], //getFormSchema(`${entityName.value}_Crud`), //表单结构
      cType, //类型,以此来确定是哪种方法或者结构,根据实际情况而定
      dtlSlots,
      useModalData,
      useFormData,
      crudColSlots: isNullOrUnDef(objParams.value['crudColSlots'])
        ? {}
        : objParams.value['crudColSlots'][item['name']],
        ? []
        : objParams.value['crudColSlots'][item['name']], //插槽列表
      data,
      name: item.name, //drawers列表里面的name,表示是哪一个实体,也就是高级表单中表格的名字
      keyName: item.keyName,
      keyName: item.keyName, //实际用来确定动态引入实体.ts的实体名称
    };
    const actionItem = [
      {
@@ -268,9 +270,16 @@
    validate().then((res) => {
      const Keys = Object.getOwnPropertyNames(useFormData.value);
      for (const i in Keys) {
        keyFieldValues.value[item['code']] = objParams.value['IsID']
          ? res[Keys[i]]['ID']
          : res[Keys[i]][item['code']];
        const _Keys = Object.getOwnPropertyNames(res[Keys[i]]);
        for (const j in _Keys) {
          if (_Keys[j] == item['code']) {
            keyFieldValues.value[item['code']] = objParams.value['IsID']
              ? res[Keys[i]]['ID']
              : res[Keys[i]][item['code']];
          } else if (_Keys[j] != 'ID') {
            keyFieldValues.value[_Keys[j]] = res[Keys[i]][_Keys[j]];
          }
        }
      }
      useDrawers[index][item['name']][1].openDrawer(true, {
        isUpdate: false,
@@ -278,7 +287,7 @@
        entityName: item['name'], //props.entityName,
        // formJson: GetCrudForm(item, data), //获取增删改表单字段
        crudColSlots: isNullOrUnDef(objParams.value['crudColSlots'])
          ? {}
          ? []
          : objParams.value['crudColSlots'][item['name']],
        keyFieldValues: keyFieldValues.value,
        data,
@@ -298,14 +307,21 @@
  function handleSuccess(d, u, item) {
    if (!isNullOrUnDef(custImport.value)) {
      /* 自定义编辑方法,根据实体名去调用 */
      EditOperation(data, d, u, item);
      useTables[item][1].setProps({
        dataSource: [],
      });
      useTables[item][1].setProps({
        dataSource: data.value[item],
      });
      useTables[item][1].reload();
      if (data.value[item].some((q) => q.ITEM_CODE == d.ITEM_CODE)) {
        createErrorModal({
          title: t('sys.api.errorTip'),
          content: t(`料号[${d.ITEM_CODE}]已经存在`),
        });
      } else {
        EditOperation(data, d, u, item);
        useTables[item][1].setProps({
          dataSource: [],
        });
        useTables[item][1].setProps({
          dataSource: data.value[item],
        });
        useTables[item][1].reload();
      }
    }
  }