
import departmenTree from '@/blocks/components/formConfig/departmenTree.js'
import { stationAttr } from '@/blocks/components/searchModalConfig'
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)])
    },
  }
}
let inputType = (self) => (self.st === 1 ? 'txt' : 'input')


// administrativeAreas:"[string] 站点-行政区域"
// areas:"[string] 站点区域"
// code:"[string] 站点编号"
// deliveryOrder:"[number] 配送顺序"
// departmentCode:"[string] 所属部门编码"
// departmentId:"[string] 所属部门ID,多个部门逗号分割"
// departmentName:"[string] 所属部门名称"
// extDate1:"[string] 日期属性扩展1"
// extDate2:"[string] 日期属性扩展2"
// extDate3:"[string] 日期属性扩展3"
// extDate4:"[string] 日期属性扩展4"
// extDate5:"[string] 日期属性扩展5"
// extNum1:"[number] 数值属性扩展1"
// extNum2:"[number] 数值属性扩展2"
// extNum3:"[number] 数值属性扩展3"
// extNum4:"[number] 数值属性扩展4"
// extNum5:"[number] 数值属性扩展5"
// extStr1:"[string] 字符扩展1"
// extStr2:"[string] 字符扩展2"
// extStr3:"[string] 字符扩展3"
// extStr4:"[string] 字符扩展4"
// extStr5:"[string] 字符扩展5"
// higherLevelStationCode:"[string] 上级站点编号"
// higherLevelStationId:"[integer] 上级站点ID"
// higherLevelStationName:"[string] 上级站点名称"
// level:"[integer] 站点级别 数据字典STATION_LEVEL:1,2,3,4,5"
// memo:"[string] 备注"
// name:"[string] 站点名称"
// startingStationDTOList:[
// {
// distance:"[number] 距离"
// memo:"[string] 备注"
// startingStationCode:"[string] 始发站点编号"
// startingStationId:"[integer] 始发站点ID"
// startingStationName:"[string] 始发站点名称"
// stationCode:"[string] 站点编号"
// stationId:"[integer] 站点ID"
// stationName:"[string] 站点名称"
// }
// ]
// type:"[integer] 站点类型 数据字典STATION_TYPE:10.实际 20.虚拟"



export const setFormList = (self, expData = []) => {
  let selectedRowKeys = []
  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: 'id', label: 'id', hidden: true },
    {
      name: 'code',
      target: 'blur',
      label: '站点编码',
      value: '',
      get readOnly() {
        return self.st === 3 ? true : false
      },

      required: true,
      get type() {
        return inputType(self)
      },
    },
    {
      name: 'name',
      label: '站点名称',
      value: '',
      get readOnly() {
        return self.st === 3 ? true : false
      },
      required: true,
      get type() {
        return inputType(self)
      },
    },

    {
      name: 'deliveryOrder',
      label: '配送顺序',
      placeholder: '请输入整数和小数',
      min: -99999,
      get type() {
        return self.st == 1 ? 'txt' : 'number'
      },
    },
    {
      name: 'type',
      label: '站点类型',
      allowClear: false,
      required: true, //STATION_TYPE
      get mode() {
        return self.st === 1 ? 'txt' : ''
      },
      type: 'select',
      value: undefined,
      get options() {
        return self.options.STATION_TYPE
      },
    },

    {
      ...stationAttr,
      name: 'higherLevelStationCode',
      label: '上级站点编码',
      get type() {
        return  self.st === 1 ? 'txt' : 'searchModal'
      },
      tableConfig: {
        ...stationAttr.tableConfig,
        remoteBefore: (vNode, reposts) => {
          if (self.record?.id) {
            reposts.data.excludeId =[self.record.id]
          }
        },
        getCheckboxProps: (record) => ({
          props: {
            disabled:self.record?.id==record.id ?? false
          },
        })
      },
      targetValueKey: 'code',
      on: {
        change(event, value, dataArr, form) {
          let data = dataArr[0];
          let obj = { higherLevelStationCode: '', higherLevelStationName: '', higherLevelStationId: '' }
          if (!value) {
            return form.setFieldsValue(obj)
          }
          obj = { higherLevelStationCode: data.code, higherLevelStationId: data.id, higherLevelStationName: data.name }
          form.setFieldsValue(obj)
        },

      }

    },
    {
      name: 'higherLevelStationName',
      label: '上级站点名称',
      readOnly: true,
      get type() {
        return inputType(self)
      },
    },
    {
      name: 'higherLevelStationId',
      label: '上级站点Id',
      hidden: true,
    },
    {
      name: 'level',
      label: '站点级别',
      placeholder: '请输入整数',
      allowClear: false,
      required: true, //STATION_TYPE
      get mode() {
        return self.st === 1 ? 'txt' : ''
      },
      type: 'select',
      value: 1,
      get options() {
        return self.options.STATION_LEVEL
      }
    },
    ...departmenTree(self),

    {
      name: 'areas',
      label: '区域',

        get mode() {
        return self.st === 1 ? 'txt' : ''
      },
      get options() {
        return self.options.STATION_AREAS
      },
      type: 'select',
      span: 6,
    },
    {
      name: 'memo',
      label: '备注',
      get type() {
        return inputType(self)
      },
      span: 12,
      labelCol: { span: 3 },
      wrapperCol: { span: 20 },
    },
    ...e
  ]
}
