//区域编号SearchModel
import { remote } from '@/views/EIS/remote/index.js'
const baseUrl = '/api/upcloud-base-wh-dev-mysql'
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
          },
        },
      ],
    },
  }
}

// remoteUrl: {
//     url: baseUrl + '/eisLocator/goods/page',
//     headers: {
//       'Content-Type': 'application/JSON'
//     },
//     method: 'post'
//   },

const locationNo = function (labelname = '点位编号', span = 24, required = true, name = 'locationNo') {
  return {
    span: span,
    type: 'searchModal',
    name: name,
    label: labelname,
    required: required,
    targetClick: true,
    targetValueKey: 'locationNo',
    value: '',
    remoteUrl: {
      url: '/api/upcloud-base-wh-dev-mysql-eistest' + '/eisLocator/goods/page',
      headers: {
        'Content-Type': 'application/JSON',
      },
      method: 'post',
    },
    //   doneBefore: function(res) {
    //     console.log(res)
    //     res.data.list = res.data.list.filter(item => item.areaType == 20)
    //     return res
    //   },
    toolBar: {
      rowId: 'id',
      items: [
        {
          span: 8,
          type: 'input',
          name: 'locationNo',
          label: '货位编号',
          value: '',
        },
        {
          span: 8,
          type: 'input',
          name: 'groupNo',
          label: '货位组编号',
          value: '',
        },
        {
          span: 8,
          type: 'input',
          name: 'areaNo',
          label: '区域',
          value: '',
        },

        {
          span: 8,
          type: 'input',
          name: 'limitHeight',
          label: '限高',
          value: '',
        },
      ],
    },
    on: {
      search: () => {
        //   this.params = { name: 'hdwss' }
      },
      change: (event, value, rowData, form) => {},
    },

    tableConfig: {
      rowKey: 'id',
      remoteBefore: function (vnode, remoteUrl) {
        console.log(remoteUrl)
        // remoteUrl.params.areaType = 20
        return remoteUrl
      },
      columns: [
        {
          dataIndex: 'locationNo',
          key: 'locationNo',
          align: 'center',
          ellipsis: true,
          title: '货位编号',
        },
        {
          title: '货位组编号',
          dataIndex: 'groupNo',
          ellipsis: true,
          //   scopedSlots: { customRender: 'groupNo' },
          align: 'center',
          key: 'groupNo',
        },
        {
          title: '区域编号',
          dataIndex: 'areaNo',
          ellipsis: true,
          align: 'center',
          key: 'areaNo',
          customRender(text) {
            text == 1 && (text = '出库口')
            text == 2 && (text = '在线拣选')
            return text
          },
        },
        {
          title: '位置类型',
          ellipsis: true,
          key: 'locationType',
          dataIndex: 'locationType',
          align: 'center',
          customRender(text) {
            text == 1 && (text = '存储位')
            text == 2 && (text = '工作位')
            text == 3 && (text = '输送线点位')
            return text
          },
        },
        {
          title: '位置锁',
          dataIndex: 'locationLock',
          align: 'center',
          ellipsis: true,
          key: 'locationLock',
          customRender(text) {
            text == 0 && (text = '否')
            text == 1 && (text = '是')
            return text
          },
        },
        // {
        //   title: '货位组锁',
        //   dataIndex: 'isLock',
        //   ellipsis: true,
        //   align: 'center',
        //   key: 'isLock',
        //   customRender(text) {
        //     text == 0 && (text = '否')
        //     text == 1 && (text = '是')
        //     return text
        //   }
        // },
        // {
        //   title: '货位组深位锁',
        //   dataIndex: 'ascentLockState',
        //   align: 'center',
        //   ellipsis: true,
        //   key: 'ascentLockState',
        //   customRender(text) {
        //     text == 0 && (text = '否')
        //     text == 1 && (text = '是')
        //     return text
        //   }
        // },
        // {
        //   title: '设备锁',
        //   dataIndex: 'equipmentLock',
        //   align: 'center',
        //   ellipsis: true,
        //   key: 'equipmentLock',
        //   customRender(text) {
        //     text == 0 && (text = '否')
        //     text == 1 && (text = '是')
        //     return text
        //   }
        // },
        // {
        //   title: '货位组位置索引',
        //   dataIndex: 'locationIndex',
        //   align: 'center',
        //   key: 'locationIndex'
        // },
        // {
        //   title: '货位深度',
        //   dataIndex: 'depth',
        //   align: 'center',
        //   key: 'depth'
        // },
        // // {
        // //   title: '限高',
        // //   dataIndex: 'limitHeight',
        // //   align: 'center',
        // //   key: 'limitHeight'
        // // },

        // {
        //   title: '移位数',
        //   dataIndex: 'deptNum',
        //   align: 'center',
        //   key: 'deptNum'
        // },
        // {
        //   title: '是否入库货位',
        //   dataIndex: 'isInBoundLocation',
        //   align: 'center',
        //   key: 'isInBoundLocation',
        //   customRender(text) {
        //     text == 0 && (text = '否')
        //     text == 1 && (text = '是')
        //     return text
        //   }
        // }
      ],
    },
  }
}

const config = function (that) {
  return {
    remoteUrl: {
      url: baseUrl + '/eisAreaAndLocatorDataCheck/areaDataCheck',
      headers: {
        'Content-Type': 'application/JSON',
      },
      method: 'post',
    },
    items: [
      {
        // labelname = '区域', span = 24, required = true, name = 'startRegion'
        ...area('起始区域', 6, false, 'sourceArea'),
      },
      {
        // labelname = '区域', span = 24, required = true, name = 'startRegion'
        ...area('目标区域', 6, false, 'targetArea'),
      },
      // {
      //   span: 8,
      //   type: 'select',
      //   name: 'taskType',
      //   label: '任务类型',
      //   value: '',
      // //   eis_route_carry_task_type
      //   options: [
      //     { label: '出库', value: 10 },
      //     { label: '入库', value: 20 },
      //     { label: '移库', value: 30 }
      //   ]
      // },
      {
        span: 8,
        type: 'select',
        name: 'taskType',
        label: '任务类型',
        value: '',
        ...remote('eis_route_carry_task_type'),
      },
      {
        span: 8,
        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: 'sourceArea',
        key: 'sourceArea',
        align: 'center',
        title: '起始区域',
      },
      {
        title: '目标区域',
        dataIndex: 'targetArea',
        align: 'center',
        key: 'targetArea',
      },

      {
        title: '任务类型',
        key: 'taskType',
        dataIndex: 'taskType',
        align: 'center',
        ...remote('eis_route_carry_task_type'),
        //   customRender(text) {
        //     text == 10 && (text = '入库')
        //     text == 20 && (text = '出库')
        //     text == 30 && (text = '移库')
        //     return text
        //   }
      },
      {
        title: '任务数',
        key: 'taskCount',
        dataIndex: 'taskCount',
        align: 'center',
      },
      {
        title: '终点点位',
        key: 'endLocation',
        dataIndex: 'endLocation',
        align: 'center',
        customRender(text) {
          text == 0 && (text = '否')
          text == 1 && (text = '是')
          return text
        },
      },

      {
        title: '是否开启',
        dataIndex: 'isAvailable',
        align: 'center',
        key: 'isAvailable',
        customRender(text) {
          text == 0 && (text = '否')
          text == 1 && (text = '是')
          return text
        },
      },

      {
        title: '操作',
        key: 'operation',
        scopedSlots: { customRender: 'operation' },
        // fixed: 'right',
        align: 'center',
      },
    ],
    Modelitems: [
      {
        // labelname = '区域', span = 24, required = true, name = 'startRegion'
        ...area('起始区域', 24, true, 'sourceArea'),
      },
      {
        // labelname = '区域', span = 24, required = true, name = 'startRegion'
        ...area('目标区域', 24, true, 'targetArea'),
      },
      {
        span: 24,
        type: 'input',
        name: 'id',
        hidden: true,
        label: 'id',
        value: '',
      },
      {
        span: 24,
        type: 'select',
        name: 'taskType',
        required: true,
        label: '任务类型',
        value: '',
        ...remote('eis_route_carry_task_type'),
      },
      {
        span: 24,
        type: 'input',
        name: 'taskCount',
        required: true,
        label: '任务数',
        value: '',
      },

      {
        span: 24,
        type: 'radio',
        required: true,
        name: 'isAvailable',
        label: '是否开启',
        value: 1,
        options: [
          { label: '是', value: 1 },
          { label: '否', value: 0 },
        ],
      },
    ],
    ContainerOnModelitems: [
      {
        span: 24,
        type: 'input',
        name: 'containerNo',
        label: '容器编号',
        required: true,
        value: '',
      },
      //   {
      //     span: 24,
      //     type: 'input',
      //     name: 'locationNo',
      //     label: '点位编号',
      //     required: true,
      //     value: ''
      //   },
      { ...locationNo() },
      {
        span: 24,
        type: 'input',
        name: 'containerType',
        label: '业务属性',
        required: true,
        value: '',
      },
      {
        span: 24,
        type: 'radio',
        name: 'isEmpty',
        label: '是否空托',
        required: true,
        value: true,
        options: [
          { label: '是', value: true },
          { label: '否', value: false },
        ],
      },
      {
        span: 24,
        type: 'radio',
        name: 'upDown',
        label: '上/下架',
        required: true,
        value: 0,
        options: [
          { label: '上架', value: 0 },
          { label: '下架', value: 1 },
        ],
      },
    ],
    initiatorTaskModelitems: [
      {
        span: 24,
        type: 'input',
        name: 'id',
        required: false,
        label: '任务号',
        value: '',
      },
      {
        span: 24,
        type: 'select',
        name: 'taskType',
        required: true,
        label: '任务类型',
        ...remote('eis_route_carry_task_type'),
        value: '',
      },
      {
        span: 24,
        type: 'input',
        name: 'containerNo',
        required: true,
        label: '容器号',
        value: '',
      },
      {
        // labelname = '区域', span = 24, required = true, name = 'startRegion'
        ...area('起始区域', 24, false, 'startRegion'),
      },
      {
        span: 24,
        type: 'input',
        name: 'startLocation',
        required: true,
        label: '起点点位',
        value: '',
      },
      {
        // labelname = '区域', span = 24, required = true, name = 'startRegion'
        ...area('终点区域', 24, false, 'endRegion'),
      },
      {
        span: 24,
        type: 'select',
        name: 'endLocation',
        required: true,
        label: '终点点位',
        value: '',
        options: [
          { label: '否', value: 0 },
          { label: '是', value: 1 },
        ],
      },
      {
        span: 24,
        type: 'input',
        name: 'businessProperty',
        required: true,
        label: '业务属性',
        value: '',
      },

      {
        span: 24,
        type: 'number',
        name: 'priority',
        required: true,
        label: '优先级',
        value: '',
      },
    ],
  }
}

export default config
