干燥机配套车间生产管理系统/云平台服务端
baoshiwei
2023-03-10 1fb197352b6a263646e4ccd3ed1c7854ede031dd
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
67
<template>
  <BasicForm @register="registerForm"></BasicForm>
</template>
 
<script>
  import { BasicForm, useForm } from '/@/components/Form/index';
  import { computed, defineComponent, toRaw } from 'vue';
  import { defHttp } from '/@/utils/http/axios';
  import { propTypes } from '/@/utils/propTypes';
  import { getOrderCustomerFormSchema } from '../data';
 
  export default defineComponent({
    name: 'JeecgOrderCustomerForm',
    components: {
      BasicForm,
    },
    props: {
      formData: propTypes.object.def({}),
    },
    setup(props) {
      const [registerForm, { setFieldsValue, setProps, getFieldsValue, updateSchema }] = useForm({
        labelWidth: 150,
        schemas: getOrderCustomerFormSchema(props.formData),
        showActionButtonGroup: false,
        baseColProps: { span: 8 },
      });
 
      const formDisabled = computed(() => {
        if (props.formData.disabled === false) {
          return false;
        }
        return true;
      });
 
      let orderCustomerFormData = {};
      const queryByIdUrl = '/test/jeecgOrderMain/queryOrderCustomerListByMainId';
      async function initFormData(mainId) {
        let params = { id: mainId };
        const data = await defHttp.get({ url: queryByIdUrl, params });
        console.log('data', data);
        if (data && data.length > 0) {
          let temp = data[0];
          orderCustomerFormData = { ...temp };
          //设置表单的值
          await setFieldsValue(orderCustomerFormData);
          await setProps({ disabled: formDisabled.value });
        }
      }
      async function getFormData() {
        let subFormData = { ...orderCustomerFormData };
        if (Object.keys(subFormData).length > 0) {
          return subFormData;
        }
        return false;
      }
 
      return {
        registerForm,
        formDisabled,
        initFormData,
        getFormData,
      };
    },
  });
</script>
 
<style scoped></style>