import { setFormItems as consignorFormItems } from '@/views/TMS/basic/consignor/model/formDetails/config.js'
import { mainGetFormList as carriersFormItems } from '@/views/TMS/basic/provider/model/formDetails/config.js'
function divider(self, value) {
  return {
    label: '',
    span: 24,
    itemHeight: '60px',
    labelCol: { span: 0 },
    wrapperCol: { span: 24 },
    type: () => {
      return self._c('a-divider', { attrs: { orientation: 'left' } }, [self._v(value)])
    },
  }
}
//因为承运商表单是老版jq的，只能用供应商改配置改
const _carriersFormItems = (self) => {
  let obj = { ...self }

  Object.setPrototypeOf(obj, self)

  // if (self.st === 1) {
  //   obj.st = 3
  // } else {
  //   obj.st = 2
  // }
  let roadPermit = {
    label: '道路许可证',
    type: 'input',
    name: 'roadPermit',
    value: '',
  }
  let arr = carriersFormItems.main.formItems(obj)
          /**0=不显示,1=查看,2=新建,3=修改,4=复制 */
          // /**0=不显示, 1=新建，2=修改 ，3=查看 ，4=复制  */
  if (obj.st === 1) {
    roadPermit.type = 'txt'
  }

  arr[2].label = '承运商编码'
  arr[3].label = '承运商名称'
  arr[4].label = '承运商简称'
  arr.splice(14, 0, roadPermit)
  //去掉货主相关字段
  arr.filter((item, index, arrs) => {
    if (item?.name?.includes('cargoOwner')) {
      arrs.splice(index, 1)
    }
  })
  return arr
}


const formItems =(self,expData=[]) => {
  let e=[]
  if (expData.length > 0) {
    expData.forEach((item) => {
      let type = item.type;
      Object.defineProperty(item, 'type', {
        get() {
          return self.st === 1 ? 'txt' : type
        }
      })
    })
    e=[divider(self, '扩展信息'),...expData]

  }
  return [
    divider(self, '基本信息'),
    {
      name: 'code',
      label: '承运商编码',
      type: 'txt',

    },
    {
      name: 'name',
      label: '承运商名称',
      value: '',

      type: 'txt',

    },
    {
      name: 'shortName',
      label: '承运商简称',
      type: 'txt',

    },
    {
      name: 'cargoOwnerName',
      value: '',
      label: '所属货主',
      type: 'txt',
    },

    {
      name: 'departmentName',
      label: '部门',
      type: 'txt',
    },
    {
      name: 'contractNatureName',
      label: '合作性质',
      type: 'txt',

    },
    {
      name: 'taxRegisterNumber',
      label: '税务登记号',
      type: 'txt',

    },
    {
      name: 'businessLicenseNumber',
      label: '营业执照号',
      type: 'txt',

      span: 6,
    },
    {
      name: 'memo',
      label: '备注',
      type: 'txt',

      span: 12,
      labelCol: { span: 3 },
      wrapperCol: { span: 20 },
    },
    divider(self, '联系信息'),
    {
      name: 'contact',
      label: '联系人',
      type: 'txt',

    },
    {
      name: 'phoneNumber',
      label: '手机号',
      type: 'txt',

    },
    {
      name: 'landlineNumber',
      label: '座机号',
      type: 'txt',

    },
    {
      name: 'email',
      label: '邮箱',

      type: 'txt',

      value: '',
    },
    {
      name: 'postCode',
      label: '邮编',
      type: 'txt',

      value: '',
    },
    {
      name: 'provinceCityDistrict',
      value: '',
      label: '省市区',
      type: 'txt',
    },


    {
      type: 'row',
      label: '详细地址',
      span: 12,
      wrapperCol: { span: 21 },
      labelCol: { span: 3 },
      list: [
        {
          name: 'address',
          type:'txt',

          value: '',
          span: 20,
          style: 'padding-right: 5px',
        },

      ],
    },

    {
      name: 'longitude',
      label: '经度',
      type:'txt',

    },
    {
      name: 'latitude',
      label: '纬度',
      type:'txt',

    },
    divider(self, '开户信息'),
    {
      name: 'legalman',
      label: '法人代表',
      type:'txt',

    },
    {
      name: 'invoice',
      label: '发票抬头',
      type:'txt',

    },
    {
      name: 'invoiceTaxNumber',
      label: '税号',
      type:'txt',

    },
    {
      name: 'established',
      label: '成立时间',
      type:'txt',

    },
    {
      name: 'registeredCapital',
      label: '注册资金',
      type:'txt',
      value: 0,

    },
    {
      name: 'bankName',
      label: '开户行',
      type:'txt',

    },
    {
      name: 'bankAccount',
      label: '银行账号',
      type:'txt',

      value: '',
    },
    {
      name: 'registeredAddress',
      label: '注册地址',
      type:'txt',
    },
    ...e
  ]
}
export const setFormItems = (self, type) => {
  console.log(self.st)
  let consignor = consignorFormItems(self)
  let carriers = formItems(self)
  let _type = [null, consignor, carriers]

  return _type[+type]
}
