enterPriseInfo.config.ts 5.93 KB
import type { FormSchema } from '/@/components/Form/index';
import { getTownList, getTownChild } from '/@/api/oem/index';

export const schemas: FormSchema[] = [
  {
    field: 'name',
    component: 'Input',
    label: '公司名称',
    colProps: {
      span: 24,
    },
    componentProps: {
      placeholder: '请输入公司名称',
    },
  },
  {
    field: 'abbreviation',
    component: 'Input',
    label: '公司简称',
    colProps: {
      span: 24,
    },
    componentProps: {
      placeholder: '请输入公司简称',
    },
  },
  {
    field: 'officialWebsite',
    component: 'Input',
    label: '公司官网',
    colProps: {
      span: 24,
    },
    componentProps: {
      placeholder: '请输入公司官网',
    },
  },
  {
    field: 'email',
    component: 'Input',
    label: '公司邮箱',
    colProps: {
      span: 24,
    },

    componentProps: {
      placeholder: '请输入公司邮箱',
    },
  },
  {
    field: 'synopsis',
    component: 'InputTextArea',
    label: '公司简介',
    colProps: {
      span: 24,
    },
    componentProps: {
      placeholder: '请输入公司简介',
      autoSize: { minRows: 8, maxRows: 12 },
      showCount: true,
    },
  },
  {
    field: 'country',
    component: 'Select',
    label: '国家/地区',
    colProps: {
      span: 24,
    },
    defaultValue: '1',
    componentProps: {
      placeholder: '请选择国家/地区',
      options: [
        {
          label: '中国',
          value: '1',
        },
      ],
    },
  },
  {
    field: 'nameProv',
    component: 'ApiSelect',
    label: '所在城市',
    colProps: {
      span: 5,
    },
    componentProps: ({ formModel, formActionType }) => {
      return {
        api: getTownList,
        labelField: 'nameProv',
        valueField: 'codeProv',
        placeholder: '请选择省份',
        async onChange(value) {
          let nameCity = await getTownChild('codeProv', value);
          nameCity.forEach((item) => {
            item.label = item.nameCity;
            item.value = item.codeCity;
          });
          const { updateSchema } = formActionType;
          if (value === undefined) {
            formModel.nameCity = undefined; //  reset city value
            formModel.nameCoun = undefined;
            formModel.nameTown = undefined;
            nameCity = [];
            updateSchema({
              field: 'nameCoun',
              componentProps: {
                options: [],
              },
            });
            updateSchema({
              field: 'nameTown',
              componentProps: {
                options: [],
              },
            });
          }
          updateSchema({
            field: 'nameCity',
            componentProps: () => {
              return {
                options: nameCity,
                placeholder: '请选择城市',
                async onChange(value) {
                  // 获取区数据
                  let nameCoun = await getTownChild('codeCity', value);
                  nameCoun.forEach((item) => {
                    item.label = item.nameCoun;
                    item.value = item.codeCoun;
                  });
                  if (value === undefined) {
                    formModel.nameCoun = undefined; //  reset city value
                    formModel.nameTown = undefined;
                    nameCoun = [];
                    updateSchema({
                      field: 'nameTown',
                      componentProps: {
                        options: [],
                      },
                    });
                  }
                  updateSchema({
                    field: 'nameCoun',
                    componentProps: {
                      // 请选择区
                      options: nameCoun,
                      async onChange(value) {
                        let nameTown = await getTownChild('codeCoun', value);
                        nameTown.forEach((item) => {
                          item.label = item.nameTown;
                          item.value = item.codeTown;
                        });
                        if (value === undefined) {
                          formModel.nameTown = undefined;
                          nameTown = [];
                        }
                        updateSchema({
                          field: 'nameTown',
                          componentProps: {
                            placeholder: '请选择街道/城镇',
                            options: nameTown,
                          },
                        });
                      },
                    },
                  });
                },
              };
            },
          });
        },
      };
    },
  },
  {
    field: 'nameCity',
    component: 'Select',
    label: '',

    colProps: {
      span: 5,
      style: {
        marginLeft: '-80px',
      },
    },
  },
  {
    field: 'nameCoun',
    component: 'Select',
    label: '',
    colProps: {
      span: 5,
      style: {
        marginLeft: '-160px',
      },
    },
    componentProps: {
      placeholder: '请选择区/县',
    },
  },
  {
    field: 'nameTown',
    component: 'Select',
    label: '',
    colProps: {
      span: 6,
      style: {
        marginLeft: '-160px',
      },
    },
    componentProps: {
      placeholder: '请选择街道/城镇',
    },
  },

  // {
  //   field: 'nameProv',
  //   label: '所在城市',
  //   component: 'Cascader',
  // },

  {
    field: 'address',
    component: 'Input',
    label: '详细地址',
    colProps: {
      span: 24,
    },
    componentProps: {
      placeholder: '请输入详细地址',
    },
  },

  {
    field: 'contacts',
    component: 'Input',
    label: '联系人',
    colProps: {
      span: 24,
    },
    componentProps: {
      placeholder: '请输入联系人',
    },
  },
  {
    field: 'tel',
    component: 'Input',
    label: '联系电话',
    colProps: {
      span: 24,
    },
    componentProps: {
      placeholder: '请输入联系电话',
    },
  },
];