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
          },
        },
      ],
    },
  }
}
// /api/service-ai-eis-route-center-eistest-wrb
// /api/upcloud-base-wh-dev-mysql-eistest-wrb
// SERVICE-AI-EIS-ROUTE-CENTER-EISTEST-WRB-CB
const baseUrl = '/api/service-ai-eis-route-center-eistest'
// const baseUrl = '/wrb1'
const config = function (that) {
  return {
    remoteUrl: {
      url: baseUrl + '/containerLocation/queryContainerTaskInfo',
      headers: {
        'Content-Type': 'application/JSON',
      },
      method: 'get',
    },
    items: [
      {
        span: 6,
        type: 'input',
        name: 'containerNo',
        required: true,
        label: '容器号',
        value: '',
      },
      {
        span: 6,
        type: 'select',
        name: 'taskState',
        disabled: true,
        // required: true,
        label: '任务状态',
        value: null,
        options: [
          // 任务状态(0未开始;10待发送任务;20已发送指令;30设备回告开始;40已经离开原位置)
          { label: '未开始', value: 0 },
          { label: '待发送任务', value: 10 },
          { label: '已发送指令', value: 20 },
          { label: '设备回告开始', value: 30 },
          { label: '已经离开原位置', value: 40 },
        ],
      },

      {
        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: 'containerNo',
        key: 'containerNo',
        align: 'center',
        title: '容器号',
      },
      {
        title: '任务类型',
        dataIndex: 'taskType',
        align: 'center',
        key: 'taskType',
      },
      {
        title: '起始区域',
        dataIndex: 'startRegion',
        align: 'center',
        key: 'startRegion',
        //   ...remote('eis_cfg_auto_carry_container_type'),
        //   customRender(text) {
        //     text == 80 && (text = '空托盘垛')
        //     text == 90 && (text = '空托盘')
        //     return text
        //   }
      },
      {
        title: '起始货位',
        key: 'startLocation',
        dataIndex: 'startLocation',
        //   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: 'endRegion',
        align: 'center',
        key: 'endRegion',
      },
      {
        title: '终点货位',
        dataIndex: 'endLocation',
        align: 'center',
        key: 'endLocation',
      },

      {
        title: '任务状态',
        dataIndex: 'taskStatus',
        align: 'center',
        key: 'taskStatus',
        customRender(text) {
          // 0：未开始，1：已开始，2：已完成
          text == 0 && (text = '未开始')
          text == 1 && (text = '已开始')
          text == 2 && (text = '已完成')

          return text
        },
      },

      {
        title: '优先级',
        dataIndex: 'priority',
        align: 'center',
        key: 'priority',
      },

      {
        title: '任务描述',
        dataIndex: 'taskRemark',
        align: 'center',
        key: 'taskRemark',
      },

      {
        title: '创建时间',
        dataIndex: 'createTime',
        align: 'center',
        key: 'createTime',
      },

      // {
      //   title: '操作',
      //   key: 'operation',
      //   scopedSlots: { customRender: 'operation' },
      //   //   fixed: 'right',
      //   align: 'center',
      // },
    ],
    his: {
      remoteUrl: {
        url: baseUrl + '/containerLocation/queryContainerTaskHisInfo',
        headers: {
          'Content-Type': 'application/JSON',
        },
        method: 'get',
      },
      // containerLocation/queryContainerTaskHisInfo
      items: [
        {
          span: 6,
          type: 'input',
          name: 'containerNo',
          required: true,
          label: '容器号',
          value: '',
        },
        {
          span: 6,
          type: 'select',
          name: 'taskState',
          disabled: true,
          // required: true,
          label: '任务状态',
          value: null,
          options: [
            // 任务状态(0未开始;10待发送任务;20已发送指令;30设备回告开始;40已经离开原位置)
            { label: '未开始', value: 0 },
            { label: '待发送任务', value: 10 },
            { label: '已发送指令', value: 20 },
            { label: '设备回告开始', value: 30 },
            { label: '已经离开原位置', value: 40 },
          ],
        },

        {
          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: 'containerNo',
          key: 'containerNo',
          align: 'center',
          title: '容器号',
        },
        {
          title: '任务类型',
          dataIndex: 'taskType',
          align: 'center',
          key: 'taskType',
        },
        {
          title: '起始区域',
          dataIndex: 'startRegion',
          align: 'center',
          key: 'startRegion',
          //   ...remote('eis_cfg_auto_carry_container_type'),
          //   customRender(text) {
          //     text == 80 && (text = '空托盘垛')
          //     text == 90 && (text = '空托盘')
          //     return text
          //   }
        },
        {
          title: '起始货位',
          key: 'startLocation',
          dataIndex: 'startLocation',
          //   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: 'endRegion',
          align: 'center',
          key: 'endRegion',
        },
        {
          title: '终点货位',
          dataIndex: 'endLocation',
          align: 'center',
          key: 'endLocation',
        },

        {
          title: '任务状态',
          dataIndex: 'taskStatus',
          align: 'center',
          key: 'taskStatus',
          customRender(text) {
            // 0：未开始，1：已开始，2：已完成
            text == 0 && (text = '未开始')
            text == 1 && (text = '已开始')
            text == 2 && (text = '已完成')

            return text
          },
        },

        {
          title: '优先级',
          dataIndex: 'priority',
          align: 'center',
          key: 'priority',
        },

        {
          title: '任务描述',
          dataIndex: 'taskRemark',
          align: 'center',
          key: 'taskRemark',
        },

        {
          title: '创建时间',
          dataIndex: 'createTime',
          align: 'center',
          key: 'createTime',
        },

        // {
        //   title: '操作',
        //   key: 'operation',
        //   scopedSlots: { customRender: 'operation' },
        //   //   fixed: 'right',
        //   align: 'center',
        // },
      ],
    },
  }
}

export default config
