import { remote } from '@/views/EIS/remote/index.js'
const outboundTaskTypeNo = function () {
  return {
    title: '出库任务单类型编号',
    type: 'searchModal',
    dataIndex: 'outboundTaskTypeNo',
    width: 200,
    name: 'outboundTaskTypeNo',
    targetClick: true,
    targetValueKey: 'typeNo',
    span: 8,
    label: '出库任务单类型编号',
    required: false,
    targetClick: true,
    value: '',
    remoteUrl: {
      url: base + '/outStg/get-out-stg',
      method: 'post',
    },
    toolBar: {
      rowId: 'id',
      items: [
        {
          span: 8,
          type: 'input',
          name: 'typeNo',
          label: '任务单类型编号',
          value: '',
        },
        {
          span: 8,
          type: 'input',
          name: 'typeName',
          label: '任务单类型名称',
          value: '',
        },
        {
          span: 8,
          type: 'select',
          name: 'outModel',
          label: '出库模式',
          value: '',
          ...remote('eis_out_stg_cfg_out_model'),
        },
        //   eis_out_stg_cfg_out_model
      ],
    },
    doneBefore: function (res) {
      console.log(res)
      return res
    },

    tableConfig: {
      rowKey: 'id',
      remoteBefore: function (vnode, remoteUrl) {
        console.log(remoteUrl)
        // remoteUrl.params.areaType = 20
        return remoteUrl
      },
      columns: [
        {
          dataIndex: 'typeNo',
          key: 'typeNo',
          align: 'center',
          title: '出库任务单类型编号',
        },
        {
          title: '出库任务单类型名称',
          dataIndex: 'typeName',
          align: 'center',
          key: 'typeName',
          customRender(text) {
            //   text == 10 && (text = '区域')
            //   text == 20 && (text = '接驳口')
            return text
          },
        },
        {
          dataIndex: 'outModel',
          key: 'outModel',
          align: 'center',
          title: '出库模式',
          ...remote('eis_out_stg_cfg_out_model'),
        },
        // {
        //   dataIndex: 'dispatchPriority',
        //   key: 'dispatchPriority',
        //   align: 'center',
        //   title: '调度优先级'
        // },
        // {
        //   dataIndex: 'maxOrderNum',
        //   key: 'maxOrderNum',
        //   align: 'center',
        //   title: '最大组单数量'
        // },
        // {
        //   dataIndex: 'maxOrderVolume',
        //   key: 'maxOrderVolume',
        //   align: 'center',
        //   title: '最大组单体积'
        // },
        // {
        //   dataIndex: 'storeMatchingStrategy',
        //   key: 'storeMatchingStrategy',
        //   align: 'center',
        //   title: '库存匹配策略',
        //   customRender(text) {
        //     text == 1 && (text = '按品种')
        //     text == 2 && (text = '按品批')
        //     return text
        //   }
        // },
        // {
        //   dataIndex: 'outboundExpiryDateRate',
        //   key: 'outboundExpiryDateRate',
        //   align: 'center',
        //   title: '优先出库最高时效百分比'
        // },
        // {
        //   dataIndex: 'prohibitExpiryDateRate',
        //   key: 'prohibitExpiryDateRate',
        //   align: 'center',
        //   title: '禁止出库最高时效百分比'
        // },
        // {
        //   dataIndex: 'clearStoreStrategy',
        //   key: 'clearStoreStrategy',
        //   align: 'center',
        //   title: '清库存策略',
        //   customRender(text) {
        //     text == 1 && (text = '是')
        //     text == 0 && (text = '否')
        //     return text
        //   }
        // },
        // {
        //   dataIndex: 'composeOrderConfig',
        //   key: 'composeOrderConfig',
        //   align: 'center',
        //   title: '组单策略配置'
        // },
        // {
        //   dataIndex: 'StartingArea',
        //   key: 'StartingArea',
        //   align: 'center',
        //   title: '源区域配置',
        //   scopedSlots: { customRender: 'StartingArea' }
        // },
        // {
        //   dataIndex: 'EndinggArea',
        //   key: 'EndinggArea',
        //   align: 'center',
        //   title: '目标区域配置',
        //   scopedSlots: { customRender: 'EndinggArea' }
        // }
      ],
    },
  }
}

const base = '/api/service-ai-eis-business-center-eistest'
const config = function (that) {
  return {
    remoteUrl: {
      url: base + '/outtaskmanager/getouttask',
      headers: {
        'Content-Type': 'application/JSON',
      },
      method: 'post',
    },
    items: [
      {
        span: 8,
        type: 'input',
        name: 'outTaskSmyId',
        label: '库存任务汇总单ID',
        value: '',
      },
      {
        span: 8,
        type: 'input',
        name: 'upperSystemTaskId',
        label: '上游系统任务单ID',
        value: '',
      },

      { ...outboundTaskTypeNo() },
      {
        span: 8,
        type: 'input',
        name: 'orderPoolId',
        label: '订单池ID',
        value: '',
      },

      {
        span: 8,
        type: 'select',
        name: 'state',
        label: '任务单状态',
        value: '',
        ...remote('eis_out_task_state'),
      },

      {
        span: 8,
        label: '开始日期',
        type: 'date',
        name: 'startTime',
        placeholder: '请输入开始日期',
        value: '',
        format: 'YYYY-MM-DD HH:mm:ss',
        showTime: true,
        style: 'padding-right:5px;',
      },
      {
        span: 8,
        type: 'date',
        label: '结束日期',
        name: 'finishTime',
        placeholder: '请输入结束日期',
        format: 'YYYY-MM-DD hh:mm:ss',
        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: 'id',
        key: 'id',
        align: 'center',
        width: 150,
        ellipsis: true,
        title: 'id',
      },
      {
        title: '库存任务汇总单ID',
        dataIndex: 'outTaskSmyId',
        ellipsis: true,
        align: 'center',
        width: 150,
        key: 'outTaskSmyId',
        // customRender(text) {
        //   text == 10 && (text = '区域')
        //   text == 20 && (text = '接驳口')
        //   return text
        // }
      },
      {
        title: '拣选单ID',
        dataIndex: 'pickingOrderId',
        ellipsis: true,
        align: 'center',
        width: 150,
        key: 'pickingOrderId',
      },
      {
        title: '上游系统任务单ID',
        key: 'upperSystemTaskId',
        width: 150,
        ellipsis: true,
        dataIndex: 'upperSystemTaskId',
        align: 'center',
      },
      {
        title: '出库任务单类型编号',
        dataIndex: 'outboundTaskTypeNo',
        align: 'center',
        ellipsis: true,
        width: 150,
        key: 'outboundTaskTypeNo',
        // customRender(text) {
        //   text == 0 && (text = '不索取')
        //   text == 1 && (text = '索取')
        //   return text
        // }
      },
      {
        title: '订单池ID',
        key: 'orderPoolId',
        width: 150,
        ellipsis: true,
        dataIndex: 'orderPoolId',
        align: 'center',
      },
      {
        title: '任务单状态',
        dataIndex: 'state',
        align: 'center',
        width: 150,
        key: 'state',
        ...remote('eis_out_task_state'),
      },
      {
        title: '是否短拣',
        width: 150,
        dataIndex: 'isShortPicking',
        align: 'center',
        key: 'isShortPicking',
        customRender(text) {
          text == 0 && (text = '否')
          text == 1 && (text = '是')
          return text
        },
      },
      {
        title: '优先级',
        dataIndex: 'priority',
        width: 150,
        align: 'center',
        key: 'priority',
      },
      {
        title: '创建时间',
        dataIndex: 'createTime',
        width: 150,
        align: 'center',
        key: 'createTime',
      },
      {
        title: '任务开始时间',
        dataIndex: 'startTime',
        width: 150,
        align: 'center',
        key: 'startTime',
      },
      {
        title: '任务完成时间',
        dataIndex: 'finishTime',
        width: 150,
        align: 'center',
        key: 'finishTime',
      },
      {
        title: '任务明细数',
        dataIndex: 'detailCount',
        scopedSlots: { customRender: 'detailCount' },
        width: 150,
        align: 'center',
        key: 'detailCount',
      },

      {
        title: '操作',
        key: 'operation',
        width: 150,
        align: 'center',
        scopedSlots: { customRender: 'operation' },
        fixed: 'right',
      },
    ],
    Modelitems: [
      {
        span: 24,
        type: 'number',
        name: 'priority',
        required: true,
        label: '优先级',
        value: '',
      },
      {
        span: 24,
        type: 'input',
        name: 'id',
        required: true,
        hidden: true,
        label: 'id',
        value: '',
      },
    ],
    details: {
      currentArea: '当前节点区域',
      nextArea: '下个节点区域',
      routeTaskState: '任务状态',
      routeExecuteState: '执行状态',
      currentLocation: '当前节点点位',
      nextLocation: '下个节点点位',
      deviceTask_id: '设备任务ID',
      deviceNo: '执行设备编号',
      arriveTime: '到位时间',
      errorMsg: '错误消息',
      updateTime: '修改时间',
    },
  }
}

export default config
