import { remote } from '@/views/EIS/remote/index.js'
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
    //   },

    on: {
      search: () => {
        //   this.params = { name: 'hdwss' }
      },
      change: (event, value, rowData, form) => {},
    },
    toolBar: {
      rowId: 'id',
      items: [
        {
          type: 'input',
          name: 'areaNo',
          label: '区域编号',
          value: '',
        },
        {
          type: 'select',
          name: 'areaType',
          label: '区域类别',
          value: '',
          options: [
            { value: 10, label: '区域' },
            { value: 20, label: '接驳口' },
          ],
        },
      ],
    },

    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
          },
        },
      ],
    },
  }
}
const baseUrl = '/api/upcloud-base-wh-control-mysql-eistest'
const config = {
  remoteUrl: {
    url: baseUrl + '/containermoveconfig/get-ContainerMoveConfig-page',
    headers: {
      'Content-Type': 'application/JSON',
    },
    method: 'post',
  },
  items: [
    {
      // labelname = '区域', span = 24, required = true, name = 'startRegion'
      //   ...area('起始区域', 6, false, 'sourceArea')
      span: 6,
      type: 'input',
      name: 'sourceArea',
      label: '起始区域',
      value: '',
    },
    {
      // labelname = '区域', span = 24, required = true, name = 'startRegion'
      //   ...area('目标区域', 6, false, 'targetArea'),
      span: 6,
      type: 'input',
      name: 'targetArea',
      label: '目标区域',
      value: '',
    },
    // {
    //   span: 8,
    //   type: 'select',
    //   name: 'containerType',
    //   label: '容器类型',
    //   value: '',
    //   options: [
    //     { label: '空托盘垛', value: 80 },
    //     { label: '空托盘', value: 90 }
    //   ]
    // },
    {
      span: 6,
      type: 'select',
      name: 'containerType',
      label: '容器类型',
      value: '',
      ...remote('eis_cfg_auto_carry_container_type'),
    },
    // {
    //   span: 8,
    //   type: 'select',
    //   name: 'taskType',
    //   label: '任务类型',
    //   value: '',
    //   options: [
    //     { label: '空托盘垛回收', value: 81 },
    //     { label: '空托盘垛补给', value: 82 },
    //     { label: '空托盘回收', value: 91 },
    //     { label: '空托盘补给', value: 92 }
    //   ]
    // },
    {
      span: 6,
      type: 'select',
      name: 'taskType',
      label: '任务类型',
      value: '',
      ...remote('eis_cfg_auto_carry_task_type'),
    },
    {
      span: 6,
      type: 'buttonGroup',
      style: { textAlign: 'left', marginLeft: '50px' },
      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: '容器类型',
      dataIndex: 'containerType',
      align: 'center',
      key: 'containerType',
      ...remote('eis_cfg_auto_carry_container_type'),
      //   customRender(text) {
      //     text == 80 && (text = '空托盘垛')
      //     text == 90 && (text = '空托盘')
      //     return text
      //   }
    },
    {
      title: '任务类型',
      key: 'taskType',
      dataIndex: 'taskType',
      //   scopedSlots: { customRender: 'deviceStatus' },
      align: 'center',
      ...remote('eis_cfg_auto_carry_task_type'),
      //   customRender(text) {
      //     text == 81 && (text = '空托盘垛回收')
      //     text == 82 && (text = '空托盘垛补给')
      //     text == 91 && (text = '故空托盘回收障')
      //     text == 92 && (text = '空托盘补给')
      //     return text
      //   }
    },
    {
      title: '是否开启',
      dataIndex: 'isAvailable',
      align: 'center',
      key: 'isAvailable',
      scopedSlots: { customRender: 'isAvailable' },
    },

    {
      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: null,
    },
    {
      span: 24,
      type: 'select',
      name: 'containerType',
      label: '容器类型',
      value: '',
      options: [
        { label: '空托盘垛', value: 80 },
        { label: '空托盘', value: 90 },
      ],
    },
    {
      span: 24,
      type: 'select',
      name: 'taskType',
      required: true,
      label: '任务类型',
      value: '',
      options: [
        { label: '空托盘垛回收', value: 81 },
        { label: '空托盘垛补给', value: 82 },
        { label: '空托盘回收', value: 91 },
        { label: '空托盘补给', value: 92 },
      ],
    },
    {
      span: 24,
      type: 'radio',
      required: true,
      name: 'isAvailable',
      label: '是否开启',
      value: 1,
      options: [
        { label: '是', value: 1 },
        { label: '否', value: 0 },
      ],
    },
    {
      span: 24,
      type: 'radio',
      required: true,
      name: 'isAuto',
      label: '是否自动',
      value: 1,
      options: [
        { label: '是', value: 1 },
        { label: '否', value: 0 },
      ],
    },
  ],
  details: {
    currentArea: '当前节点区域',
    nextArea: '下个节点区域',
    routeTaskState: '任务状态',
    routeExecuteState: '执行状态',
    currentLocation: '当前节点点位',
    nextLocation: '下个节点点位',
    deviceTask_id: '设备任务ID',
    deviceNo: '执行设备编号',
    arriveTime: '到位时间',
    errorMsg: '错误消息',
    updateTime: '修改时间',
  },
}
export default config
