const baseUrl = '/api/upcloud-base-wh-control-mysql-eistest'
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
          },
        },
      ],
    },
  }
}

const config = {
  remoteUrl: {
    url: baseUrl + '/eisPortInfoService/portinfo/page',
    headers: {
      'Content-Type': 'application/JSON',
    },
    method: 'post',
  },
  items: [
    {
      span: 8,
      type: 'input',
      name: 'portNo',
      label: '出入口编号',
      value: '',
    },
    {
      span: 8,
      type: 'input',
      name: 'portIp',
      label: '出入口IP',
      value: '',
    },
    {
      // labelname = '区域', span = 24, required = true, name = 'startRegion'
      //   ...area('区域', 6, false, 'areaNo')
      span: 8,
      type: 'input',
      name: 'areaNo',
      label: '区域',
      value: '',
    },
    {
      span: 8,
      type: 'select',
      name: 'portType',
      label: '出入口类型',
      value: '',
      options: [
        { label: '入库口', value: 1 },
        { label: '出库口', value: 2 },
        { label: '出入口', value: 3 },
      ],
    },
    {
      span: 8,
      type: 'select',
      name: 'taskType',
      label: '任务类型',
      value: '',
      options: [
        { label: '任务容器口', value: 1 },
        { label: '空容器口', value: 2 },
      ],
    },
    {
      span: 8,
      type: 'select',
      name: 'workType',
      label: '工作类型',
      value: '',
      options: [
        { label: '人工', value: 1 },
        { label: 'AGV', value: 2 },
      ],
    },

    {
      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: 'portNo',
      key: 'portNo',
      align: 'center',
      title: '出入口编号',
    },
    {
      title: '出库口IP',
      dataIndex: 'portIp',
      align: 'center',
      key: 'portIp',
    },
    {
      title: '区域',
      dataIndex: 'areaNo',
      align: 'center',
      key: 'areaNo',
      customRender(text) {
        text == 1 && (text = '出库口')
        text == 2 && (text = '在线拣选')
        return text
      },
    },
    {
      title: '出入库口类型',
      key: 'portType',
      dataIndex: 'portType',
      align: 'center',
      customRender(text) {
        text == 1 && (text = '入库口')
        text == 2 && (text = '出库口')
        text == 3 && (text = '出入口')
        return text
      },
    },
    {
      title: '任务类型',
      dataIndex: 'taskType',
      align: 'center',
      key: 'taskType',
      customRender(text) {
        text == 1 && (text = '任务容器口')
        text == 2 && (text = '空容器口')
        return text
      },
    },
    {
      title: '工作类型',
      dataIndex: 'workType',
      align: 'center',
      key: 'workType',
      customRender(text) {
        text == 1 && (text = '人工')
        text == 2 && (text = 'AGV')
        return text
      },
    },

    {
      title: '退回标识',
      dataIndex: 'reBack',
      align: 'center',
      key: 'reBack',
      customRender(text) {
        text == 0 && (text = '不可回退')
        text == 1 && (text = '可以回退')
        return text
      },
    },
    {
      title: 'LED显示标识',
      dataIndex: 'showLed',
      align: 'center',
      key: 'showLed',
      customRender(text) {
        text == 0 && (text = '不显示led屏')
        text == 1 && (text = '显示led屏')
        return text
      },
    },
    {
      title: '切换方向模式',
      dataIndex: 'dirMode',
      align: 'center',
      key: 'dirMode',
      customRender(text) {
        text == 0 && (text = '不允许切换方向')
        text == 1 && (text = '自动切换方向')
        text == 2 && (text = '手动切换方向')
        return text
      },
    },
    {
      title: '是否进行高度校验',
      dataIndex: 'detection',
      align: 'center',
      key: 'detection',
      customRender(text) {
        text == 0 && (text = '不进行高度检测')
        text == 1 && (text = '进行高度检测')
        return text
      },
    },
    {
      title: '是否锁定',
      dataIndex: 'portLock',
      align: 'center',
      key: 'portLock',
      customRender(text) {
        text == 0 && (text = '不锁定')
        text == 1 && (text = '锁定')
        return text
      },
    },
    {
      title: '备注',
      dataIndex: 'remarks',
      ellipsis: true,
      align: 'center',
      key: 'remarks',
    },

    {
      title: '操作',
      key: 'operation',
      scopedSlots: { customRender: 'operation' },
      fixed: 'right',
      width: 150,
      align: 'center',
    },
  ],
  Modelitems: [
    {
      span: 24,
      type: 'input',
      name: 'portNo',
      required: true,
      label: '出入口编号',
      value: '',
    },
    {
      span: 24,
      type: 'input',
      name: 'id',
      hidden: true,
      label: 'id',
      value: '',
    },
    {
      span: 24,
      type: 'input',
      required: true,
      name: 'portIp',
      label: '出库口IP',
      value: '',
    },
    // {
    //   span: 24,
    //   type: 'input',
    //   name: 'areaNo',
    //   required: true,
    //   label: '区域',
    //   value: ''
    // },
    {
      // labelname = '区域', span = 24, required = true, name = 'startRegion'
      ...area('区域', 24, true, 'areaNo'),
    },

    {
      span: 24,
      type: 'select',
      required: true,
      name: 'portType',
      label: '出库口类型',
      value: 1,
      options: [
        { label: '入库口', value: 1 },
        { label: '出库口', value: 2 },
        { label: '出入口', value: 3 },
      ],
    },
    {
      span: 24,
      type: 'select',
      required: true,
      name: 'taskType',
      label: '任务类型',
      value: 1,
      options: [
        { label: '任务容器口', value: 1 },
        { label: '空容器口', value: 2 },
      ],
    },
    {
      span: 24,
      type: 'select',
      required: true,
      name: 'workType',
      label: '工作类型',
      value: 1,
      options: [
        { label: '人工', value: 1 },
        { label: 'AGV', value: 2 },
      ],
    },

    {
      span: 24,
      type: 'radio',
      required: true,
      name: 'reBack',
      label: '是否退回',
      value: 0,
      options: [
        {
          value: 0,
          label: '不可回退',
        },
        {
          value: 1,
          label: '可以回退',
        },
      ],
    },
    {
      span: 24,
      type: 'radio',
      name: 'showLed',
      required: true,
      label: '是否显示LED',
      value: 1,
      options: [
        {
          value: 0,
          label: '不显示led屏',
        },
        {
          value: 1,
          label: '显示led屏',
        },
      ],
    },
    {
      span: 24,
      type: 'radio',
      name: 'dirMode',
      required: true,
      label: '切换方向模式',
      value: 1,
      options: [
        {
          value: 0,
          label: '不允许切换方向',
        },
        {
          value: 1,
          label: '自动切换方向',
        },
        {
          value: 2,
          label: '手动切换方向',
        },
      ],
    },
    {
      span: 24,
      type: 'radio',
      name: 'detection',
      required: true,
      label: '高度检测',
      value: 1,
      options: [
        {
          value: 0,
          label: '不进行高度检测',
        },
        {
          value: 1,
          label: '进行高度检测',
        },
      ],
    },
    {
      span: 24,
      type: 'radio',
      name: 'portLock',
      required: true,
      label: '锁定',
      value: 1,
      options: [
        {
          value: 0,
          label: '不锁定',
        },
        {
          value: 1,
          label: '锁定',
        },
      ],
    },
    {
      span: 24,
      type: 'textarea',
      name: 'remarks',
      label: '备注',
      value: '',
    },
  ],
  details: {
    currentArea: '当前节点区域',
    nextArea: '下个节点区域',
    routeTaskState: '任务状态',
    routeExecuteState: '执行状态',
    currentLocation: '当前节点点位',
    nextLocation: '下个节点点位',
    deviceTask_id: '设备任务ID',
    deviceNo: '执行设备编号',
    arriveTime: '到位时间',
    errorMsg: '错误消息',
    updateTime: '修改时间',
  },
}
export default config
