//区域编号SearchModel
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 + '/eisPortInfoAreaService/portinfoarea',
    headers: {
      'Content-Type': 'application/JSON',
    },
    method: 'get',
  },
  items: [
    {
      span: 8,
      type: 'input',
      name: 'portNo',
      label: '出入口编号',
      value: '',
    },
    {
      span: 8,
      type: 'buttonGroup',
      style: { textAlign: 'left' },
      options: [
        {
          value: '查询',
          icon: 'search',
          btnType: 'primary',
          style: 'margin-right:10px',
          htmlType: 'submit',
        },
        {
          value: '重置',
          icon: 'redo',
          on: {
            click: (event, form) => {
              console.log(form)
              form.resetFields()
            },
          },
        },
      ],
    },
  ],
  columns: [
    {
      dataIndex: 'portNo',
      key: 'portNo',
      align: 'center',
      title: '出入口编号',
    },
    {
      title: '可入库区域',
      dataIndex: 'areaNo',
      align: 'center',
      key: 'areaNo',
    },
    {
      title: '区域优先级',
      dataIndex: 'priority',
      align: 'center',
      key: 'priority',
      customRender(text) {
        // text == 1 && (text = '字符串')
        // text == 2 && (text = '整数')
        // text == 3 && (text = '小数')
        return text
      },
    },
    {
      title: '任务数权值',
      dataIndex: 'taskPower',
      align: 'center',
      key: 'taskPower',
      customRender(text) {
        // text == 0 && (text = '否')
        // text == 1 && (text = '是')
        return text
      },
    },

    {
      title: '库存存放比例',
      dataIndex: 'containerCountPower',
      align: 'center',
      key: 'containerCountPower',
    },

    {
      title: '操作',
      key: 'operation',
      scopedSlots: { customRender: 'operation' },
      //   fixed: 'right',
      align: 'center',
    },
  ],
  Modelitems: [
    {
      span: 24,
      type: 'select',
      name: 'portNo',
      required: true,
      label: '出入口编号',
      remoteUrl: {
        url: baseUrl + '/eisPortInfoService/portinfo/dictionary',
        method: 'post',
      },
      replaceFields: {
        label: 'portNo',
        value: 'portNo',
      },
      autoLoad: true,
      value: '',
    },
    {
      span: 24,
      type: 'input',
      name: 'id',
      hidden: true,
      label: 'id',
      value: '',
    },
    // {
    //   span: 24,
    //   type: 'input',
    //   required: true,
    //   name: 'areaNo',
    //   label: '可入库区域',
    //   value: ''
    // },
    {
      // labelname = '区域', span = 24, required = true, name = 'startRegion'
      ...area('可入库区域', 24, true, 'areaNo'),
    },
    {
      span: 24,
      type: 'number',
      required: true,
      name: 'containerCountPower',
      label: '库存存放比例',
      value: '',
    },

    {
      span: 24,
      type: 'number',
      name: 'priority',
      required: true,
      label: '区域优先级',
      value: '',
    },

    {
      span: 24,
      type: 'number',
      required: true,
      name: 'taskPower',
      label: '任务数权值',
      value: '',
      options: [
        { label: '否', value: 0 },
        { label: '是', value: 1 },
      ],
    },
    {
      span: 24,
      type: 'input',
      name: 'remark',
      label: '备注',
      value: '',
    },
  ],
  details: {
    currentArea: '当前节点区域',
    nextArea: '下个节点区域',
    routeTaskState: '任务状态',
    routeExecuteState: '执行状态',
    currentLocation: '当前节点点位',
    nextLocation: '下个节点点位',
    deviceTask_id: '设备任务ID',
    deviceNo: '执行设备编号',
    arriveTime: '到位时间',
    errorMsg: '错误消息',
    updateTime: '修改时间',
  },
}
export default config
