import { remote } from '@/views/EIS/remote/index.js'
const baseUrl = '/api/service-ai-eis-business-center-eistest'
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: baseUrl + '/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 config = function (that) {
  return {
    remoteUrl: {
      url: baseUrl + '/outtaskhismanager/getouttaskhis',
      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: '',
        options: [
          { label: '区域', value: 10 },
          { label: '接驳口', value: 20 },
        ],
      },
      {
        ...outboundTaskTypeNo(),
      },
      {
        span: 8,
        type: 'input',
        name: 'orderPoolId',
        label: '订单池ID',
        value: '',
      },
      {
        span: 8,
        type: 'input',
        name: 'pickingOrderId',
        label: '拣选单ID',
        value: '',
      },
      {
        span: 8,
        type: 'select',
        name: 'status',
        label: '任务单状态',
        value: '',
        ...remote('eis_out_task_state'),
      },
      //   {
      //     type: 'row',
      //     label: '创建时间',
      //     list: [
      //       {
      //         type: 'date',
      //         name: 'createTimeFrom',
      //         placeholder: '请输入开始日期',
      //         value: '',
      //         format: 'YYYY-MM-DD HH:mm:ss',
      //         showTime: true,

      //         style: 'padding-right:5px;'
      //       },
      //       {
      //         type: 'date',
      //         name: 'createTimeTo',
      //         placeholder: '请输入结束日期',
      //         format: 'YYYY-MM-DD hh:mm:ss',
      //         value: ''
      //       }
      //     ]
      //   },
      {
        span: 8,
        label: '创建时间',
        type: 'date',
        name: 'createTimeFrom',
        placeholder: '请输入开始日期',
        value: '',
        format: 'YYYY-MM-DD HH:mm:ss',
        showTime: true,
        style: 'padding-right:5px;',
      },
      {
        span: 8,
        label: '结束时间',
        type: 'date',
        name: 'createTimeTo',
        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',
        // customRender(text) {
        //   text == 0 && (text = '未开始')
        //   text == 1 && (text = '进行中')
        //   text == 2 && (text = '已完成')
        //   text == 3 && (text = '已暂停')
        //   text == 4 && (text = '已取消')

        //   return text
        // }
      },
      {
        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'),

        // 任务单状态（0未开始、1进行中、3已暂停、2已完成）
      },
      {
        title: '是否短拣',
        width: 150,
        dataIndex: 'isShortPicking',
        align: 'center',
        key: 'isShortPicking',
        customRender(text) {
          text == 0 && (text = '否')
          text == 1 && (text = '是')
          return text
        },
      },
      {
        title: '优先级',
        width: 150,
        dataIndex: 'priority',
        align: 'center',
        key: 'priority',
      },
      {
        title: '创建时间',
        dataIndex: 'expireDate',
        width: 150,
        align: 'center',
        key: 'expireDate',
      },

      {
        title: '任务开始时间',
        dataIndex: 'startTime',
        width: 150,
        align: 'center',
        key: 'startTime',
      },

      {
        title: '任务完成时间',
        dataIndex: 'finishTime',
        width: 150,
        align: 'center',
        key: 'finishTime',
      },

      {
        title: '任务明细数',
        dataIndex: 'detailCount',
        width: 150,
        scopedSlots: { customRender: 'detailCount' },
        align: 'center',
        key: 'detailCount',
      },

      //   {
      //     title: '操作',
      //     key: 'operation',
      //     width: 150,
      //     scopedSlots: { customRender: 'operation' },
      //     fixed: 'right',
      //     align: 'center'
      //   }
    ],
    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: '修改时间',
    },
    Modelitemsupdate1: [
      {
        span: 24,
        type: 'input',
        name: 'areaNo',
        required: true,
        label: '区域编号',
        value: '',
      },
      {
        span: 24,
        type: 'input',
        name: 'id',
        hidden: true,
        label: 'id',
        value: '',
      },
      {
        span: 24,
        type: 'select',
        name: 'areaType',
        required: true,
        label: '区域类别',
        options: [
          { label: '区域', value: 10 },
          { label: '接驳口', value: 20 },
        ],
        on: {
          change(value, label, options) {
            console.log(arguments)
            if (value == 10) {
              //区域
              that.config.Modelitems = that.config.Modelitemsupdate1
            } else if (value == 20) {
              //接驳口
              that.config.Modelitems = that.config.Modelitemsupdate
            }
          },
        },
        value: '',
      },
      {
        span: 24,
        type: 'input',
        name: 'layer',
        required: true,
        label: '层',
        value: '',
      },
      {
        span: 24,
        type: 'input',
        name: 'maxHeight',
        required: true,
        label: '高度限制',
        value: '',
      },

      {
        span: 24,
        type: 'number',
        name: 'maxCount',
        required: true,
        label: '最大容器数',
        value: '',
      },

      {
        span: 24,
        type: 'select',
        required: true,
        name: 'policy',
        label: '分配货位策略',
        value: 0,
        options: [
          {
            value: 0,
            label: '否',
          },
          {
            value: 1,
            label: '是',
          },
        ],
      },
      {
        span: 24,
        type: 'input',
        name: 'gcsArea',
        required: true,
        label: '跨层区域',
        value: '',
      },
      {
        span: 24,
        type: 'input',
        name: 'wmsAreaNo',
        required: true,
        label: 'WMS接口区域',
        value: '',
      },
      {
        span: 24,
        type: 'input',
        name: 'deviceSystem',
        required: true,
        label: '下游WCS系统',
        value: '',
      },
      {
        span: 24,
        type: 'textarea',
        name: 'remark',
        required: true,
        label: '备注',
        value: '',
      },
    ],
    Modelitemsupdate: [
      {
        span: 24,
        type: 'input',
        name: 'areaNo',
        required: true,
        label: '区域编号',
        value: '',
      },
      {
        span: 24,
        type: 'input',
        name: 'id',
        hidden: true,
        label: 'id',
        value: '',
      },
      {
        span: 24,
        type: 'select',
        name: 'areaType',
        label: '区域类别',
        options: [
          { label: '区域', value: 10 },
          { label: '接驳口', value: 20 },
        ],
        on: {
          change(value, label, options) {
            console.log(arguments)
            if (value == 10) {
              that.config.Modelitems = that.config.Modelitemsupdate1
            } else if (value == 20) {
              that.config.Modelitems = that.config.Modelitemsupdate
            }
          },
        },
        value: '',
      },
      {
        span: 24,
        type: 'input',
        name: 'gcsLocationNo',
        required: true,
        label: 'GCS点位',
        // rules: [
        //   {
        //     validator: function(rule, value, callback) {
        //       //   console.log(rule, value, callback)
        //       const pwdRegex = new RegExp(/[\u4E00-\u9FA5]/g)
        //       console.log(pwdRegex.test(value))
        //       if (pwdRegex.test(value)) {
        //         console.log(1122)
        //         callback(new Error('不能含有中文'))
        //       } else {
        //         callback()
        //       }
        //     },
        //     required: true
        //   }
        // ],
        value: '',
      },
      {
        span: 24,
        type: 'input',
        name: 'mcsLocationNo',
        required: true,
        label: 'MCS点位',
        // rules: [
        //   {
        //     validator: function(rule, value, callback) {
        //       //   console.log(rule, value, callback)
        //       const pwdRegex = new RegExp(/[\u4E00-\u9FA5]/g)
        //       console.log(pwdRegex.test(value))
        //       if (pwdRegex.test(value)) {
        //         console.log(1122)
        //         callback(new Error('不能含有中文'))
        //       } else {
        //         callback()
        //       }
        //     },
        //     required: true
        //   }
        // ],
        value: '',
      },

      {
        span: 24,
        type: 'input',
        name: 'rcsLocationNo',
        required: true,
        label: 'RCS点位',
        // rules: [
        //   {
        //     validator: function(rule, value, callback) {
        //       //   console.log(rule, value, callback)
        //       const pwdRegex = new RegExp(/[\u4E00-\u9FA5]/g)
        //       console.log(pwdRegex.test(value))
        //       if (pwdRegex.test(value)) {
        //         console.log(1122)
        //         callback(new Error('不能含有中文'))
        //       } else {
        //         callback()
        //       }
        //     },
        //     required: true
        //   }
        // ],
        value: '',
      },

      {
        span: 24,
        type: 'input',
        name: 'layer',
        required: true,
        label: '层',
        value: '',
      },

      {
        span: 24,
        type: 'input',
        name: 'x',
        required: true,
        label: 'X轴',
        value: '',
      },

      {
        span: 24,
        type: 'input',
        name: 'y',
        required: true,
        label: 'Y轴',
        value: '',
      },

      {
        span: 24,
        type: 'input',
        name: 'maxHeight',
        required: true,
        label: '高度限制',
        value: '',
      },

      {
        span: 24,
        type: 'number',
        name: 'maxCount',
        required: true,
        label: '最大容器数',
        value: '',
      },

      {
        span: 24,
        type: 'select',
        required: true,
        name: 'policy',
        label: '分配货位策略',
        value: 0,
        options: [
          {
            value: 0,
            label: '否',
          },
          {
            value: 1,
            label: '是',
          },
        ],
      },
      {
        span: 24,
        type: 'input',
        name: 'gcsArea',
        required: true,
        label: '跨层区域',
        value: '',
      },
      {
        span: 24,
        type: 'input',
        name: 'wmsAreaNo',
        required: true,
        label: 'WMS接口区域',
        value: '',
      },
      {
        span: 24,
        type: 'textarea',
        name: 'remark',
        required: true,
        label: '备注',
        value: '',
      },
    ],
  }
}

export default config
