const baseUrl = '/api/upcloud-base-wh-control-mysql-eistest'
const area = function (labelname = '区域', span = 24, required = true, name = 'startRegion') {
  return {
    span: span,
    type: 'searchModal',
    name: name,
    label: labelname,
    required: required,
    targetClick: true,
    targetValueKey: 'areaNo',
    value: '',
    remoteUrl: {
      url: '/api/upcloud-base-wh-dev-mysql-eistest/storeArea/getAll-storeArea',
    },
    //   doneBefore: function(res) {
    //     console.log(res)
    //     res.data.list = res.data.list.filter(item => item.areaType == 20)
    //     return res
    //   },
    toolBar: {
      rowId: 'id',
      items: [
        {
          type: 'input',
          name: 'areaNo',
          label: '区域编号',
          value: '',
        },
        // {
        //   type: 'select',
        //   name: 'areaType',
        //   label: '区域类别',
        //   value: '',
        //   options: [
        //     { value: 10, label: '区域' },
        //     { value: 20, label: '接驳口' }
        //   ]
        // }
      ],
    },
    on: {
      search: () => {
        //   this.params = { name: 'hdwss' }
      },
      change: (event, value, rowData, form) => {},
    },

    tableConfig: {
      rowKey: 'areaNo',
      remoteBefore: function (vnode, remoteUrl) {
        console.log(remoteUrl)
        remoteUrl.params.areaType = 20
        return remoteUrl
      },
      columns: [
        {
          dataIndex: 'areaNo',
          title: '区域编号',
        },
        {
          title: '区域类别',
          dataIndex: 'areaType',
          align: 'center',
          key: 'areaType',
          customRender(text) {
            text == 10 && (text = '区域')
            text == 20 && (text = '接驳口')
            return text
          },
        },
      ],
    },
  }
}
let layer
const config = {
  remoteUrl: {
    url: baseUrl + '/eisSxCarAcrossConfigService/layer/page',
    headers: {
      'Content-Type': 'application/JSON',
    },
    method: 'post',
  },
  items: [
    {
      span: 8,
      type: 'input',
      name: 'areaNo',
      label: '区域',
      value: '',
    },
    // {
    //   // labelname = '区域', span = 24, required = true, name = 'startRegion'
    //   ...area('区域', 6, false, 'areaNo')
    // },
    {
      span: 8,
      type: 'input',
      name: 'number',
      label: '层',
      value: '',
    },

    {
      span: 24,
      type: 'buttonGroup',
      style: { textAlign: 'right' },
      options: [
        {
          value: '查询',
          icon: 'search',
          btnType: 'primary',
          style: 'margin-right:10px',
          htmlType: 'submit',
        },
        {
          value: '重置',
          icon: 'redo',
          style: 'margin-right:50px',
          on: {
            click: (event, form) => {
              console.log(form)
              form.resetFields()
            },
          },
        },
      ],
    },
  ],
  columns: [
    {
      dataIndex: 'areaNo',
      key: 'areaNo',
      align: 'center',
      title: '区域',
    },
    {
      title: '层',
      dataIndex: 'layer',
      align: 'center',
      key: 'layer',
    },
    {
      title: '最少小车数量',
      dataIndex: 'leastCars',
      align: 'center',
      key: 'leastCars',
    },
    {
      title: '最多小车数量',
      key: 'mostCars',
      dataIndex: 'mostCars',
      align: 'center',
    },
    {
      title: '默认小车数量',
      dataIndex: 'layerDefaultCars',
      align: 'center',
      key: 'layerDefaultCars',
      //   customRender(text) {
      //     text == 1 && (text = '任务容器口')
      //     text == 2 && (text = '空容器口')
      //     return text
      //   }
    },

    {
      title: '操作',
      key: 'operation',
      scopedSlots: { customRender: 'operation' },
      fixed: 'right',
      width: 150,
      align: 'center',
    },
  ],
  Modelitems: [
    // {
    //   span: 24,
    //   type: 'input',
    //   name: 'areaNo',
    //   required: true,
    //   label: '区域',
    //   value: ''
    // },

    {
      span: 24,
      type: 'searchModal',
      name: 'areaNo',
      label: '区域编号',
      required: true,
      targetClick: true,
      targetValueKey: 'areaNo',
      value: '',
      remoteUrl: {
        url: '/api/upcloud-base-wh-dev-mysql-eistest/storeArea/getAll-storeArea',
      },
      //   doneBefore: function(res) {
      //     console.log(res)
      //     res.data.list = res.data.list.filter(item => item.areaType == 20)
      //     return res
      //   },

      on: {
        search: () => {
          //   this.params = { name: 'hdwss' }
        },
        change: (event, value, rowData, form) => {
          //   console.log(args)
          if (rowData[0]) {
            console.log(rowData[0])
            layer = rowData[0].layer
            form.setFieldsValue({
              layer: layer,
            })
          } else {
            form.setFieldsValue({
              layer: '',
            })
          }
        },
      },

      tableConfig: {
        rowKey: 'areaNo',
        remoteBefore: function (vnode, remoteUrl) {
          console.log(remoteUrl)
          remoteUrl.params.areaType = 10
          return remoteUrl
        },
        columns: [
          {
            dataIndex: 'areaNo',
            title: '区域编号',
          },
          {
            title: '区域类别',
            dataIndex: 'areaType',
            align: 'center',
            key: 'areaType',
            customRender(text) {
              text == 10 && (text = '区域')
              text == 20 && (text = '接驳口')
              return text
            },
          },
        ],
      },
    },
    {
      span: 24,
      type: 'input',
      name: 'id',
      hidden: true,
      label: 'id',
      value: '',
    },
    {
      span: 24,
      type: 'number',
      //   required: true,
      disabled: true,
      name: 'layer',
      label: '层',
      value: '',
    },
    {
      span: 24,
      type: 'number',
      name: 'leastCars',
      required: true,
      label: '最少小车数量',
      value: '',
    },
    {
      span: 24,
      type: 'number',
      name: 'mostCars',
      required: true,
      label: '最多小车数量',
      value: '',
    },
    {
      span: 24,
      type: 'number',
      name: 'layerDefaultCars',
      required: true,
      label: '默认小车数量',
      value: '',
    },
  ],
  details: {
    currentArea: '当前节点区域',
    nextArea: '下个节点区域',
    routeTaskState: '任务状态',
    routeExecuteState: '执行状态',
    currentLocation: '当前节点点位',
    nextLocation: '下个节点点位',
    deviceTask_id: '设备任务ID',
    deviceNo: '执行设备编号',
    arriveTime: '到位时间',
    errorMsg: '错误消息',
    updateTime: '修改时间',
  },
}
export default config
