Ben Lin
2024-06-25 f73947395184fd635df3d74c1c4b2701d0c708c1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!--
 * @Description: 高级表单页请表信息组件,需要支持setup async
 * @Author: Ben Lin
 * @version: 
 * @Date: 2024-06-23 17:21:29
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-06-23 18:08:08
-->
<template>
  <a-card
    :title="item.title"
    :bordered="false"
    v-for="(item, index) in _baseCards"
    :key="item.name"
  >
    <BasicForm @register="useFormData[item.name][0]" />
  </a-card>
</template>
<script lang="ts" setup>
  import { Ref, inject, nextTick, onMounted, ref, watch } from 'vue';
  import { BasicForm, useForm } from '/@/components/Form/index';
  import { Card } from 'ant-design-vue';
  import { getEntity } from '/@/api/tigerapi/system';
  import { isNullOrEmpty } from '/@/utils/is';
 
  const ACard = Card;
  const objParams = inject('objParams') as Ref<any>;
  const useFormData = inject('useFormData') as Ref<{}>;
  const baseCards = inject('baseCards') as Ref<any>;
  const custImport = ref<any[]>(
    await import(`../entityts/${objParams['Name']}.ts`),
  );
  const [
    {
      GetBaseForm,
      GetBaseCards,
    },
  ] = custImport.value['default']();
  const formSchemas = ref({
    BaseForm: GetBaseForm(),
  }); //弹出框或高级页面多表单结构
  useFormData.value = {
    BaseForm: useForm({
      labelWidth: 120,
      schemas: formSchemas.value['BaseForm'],
      actionColOptions: {
        span: 24,
      },
      showActionButtonGroup: false,
    }),
  };
  const _baseCards = ref(GetBaseCards());
  baseCards.value = _baseCards.value;
 
  onMounted(() => {
    useFormData.value[_baseCards.value[0]['name']][1].resetFields();
    getEntity({
      sqlcmd: ` ID = '${objParams['ID']}'`,
      entityName: _baseCards.value[0]['entityName'],
    }).then((res) => {
      if (!isNullOrEmpty(res.Data.Items)) {
        useFormData.value[_baseCards.value[0]['name']][1].setFieldsValue(res.Data.Items[0]);
      }
    });
  });
</script>