const baseUrl = '/api/upcloud-base-wh-dev-mysql-eistest'

// const baseUrl = '/wrb1'
import { remote } from '@/views/EIS/remote/index.js'

const config = function (that) {
  return {
    remoteUrl: {
      url: baseUrl + '/eisWhArea/getAll-storeArea',
      headers: {
        'Content-Type': 'application/JSON',
      },
      method: 'get',
    },
    items: [
      {
        span: 8,
        type: 'input',
        name: 'areaNo',
        label: '区域编号',
        value: '',
      },
      {
        span: 8,
        type: 'select',
        name: 'areaType',
        label: '区域类别',
        value: '',
        options: [
          { label: '区域', value: 10 },
          { label: '接驳口', value: 20 },
        ],
      },

      {
        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: 'areaNo',
        key: 'areaNo',
        align: 'center',
        title: '区域编号',
      },
      {
        title: '区域类别',
        dataIndex: 'areaType',
        align: 'center',
        key: 'areaType',
        customRender(text) {
          text == 10 && (text = '区域')
          text == 20 && (text = '接驳口')

          return text
        },
      },
      {
        title: 'GCS点位编号',
        dataIndex: 'gcsLocationNo',
        ellipsis: true,
        align: 'center',
        key: 'gcsLocationNo',
      },
      {
        title: 'MCS点位编号',
        key: 'mcsLocationNo',
        ellipsis: true,
        dataIndex: 'mcsLocationNo',
        align: 'center',
      },
      {
        title: 'RCS点位编号',
        dataIndex: 'rcsLocationNo',
        align: 'center',
        ellipsis: true,
        key: 'rcsLocationNo',
        // customRender(text) {
        //   text == 0 && (text = '不索取')
        //   text == 1 && (text = '索取')
        //   return text
        // }
      },
      {
        title: 'SPS点位编号',
        key: 'spsLocationNo',
        ellipsis: true,
        dataIndex: 'spsLocationNo',
        align: 'center',
      },
      {
        title: '锚点X',
        key: 'pointX',
        ellipsis: true,
        dataIndex: 'pointX',
        align: 'center',
      },
      {
        title: '锚点Y',
        key: 'pointY',
        ellipsis: true,
        dataIndex: 'pointY',
        align: 'center',
      },

      {
        title: '层',
        dataIndex: 'layer',
        align: 'center',
        key: 'layer',
      },
      {
        title: 'X',
        dataIndex: 'x',
        align: 'center',
        key: 'x',
      },
      {
        title: 'Y',
        dataIndex: 'y',
        align: 'center',
        key: 'y',
      },
      {
        title: '高度限制',
        dataIndex: 'maxHeight',
        align: 'center',
        key: 'maxHeight',
      },
      {
        title: '最大容器数',
        dataIndex: 'maxCount',
        align: 'center',
        key: 'maxCount',
      },
      {
        title: '分配货位策略',
        dataIndex: 'locationStrategy',
        align: 'center',
        key: 'locationStrategy',
        ...remote('eisInboundStrategyType'),
      },
      {
        title: '跨层区域',
        dataIndex: 'gcsArea',
        align: 'center',
        ellipsis: true,
        key: 'gcsArea',
      },
      {
        title: 'WMS接口区域',
        dataIndex: 'wmsAreaNo',
        align: 'center',
        ellipsis: true,
        key: 'wmsAreaNo',
      },
      {
        title: '下游WCS系统',
        dataIndex: 'deviceSystem',
        align: 'center',
        ellipsis: true,
        key: 'deviceSystem',
      },
      {
        title: '二次分配货位策略',
        dataIndex: 'secondStrategy',
        align: 'center',
        ellipsis: true,
        width: 150,
        key: 'secondStrategy',
        ...remote('secondStrategy'),
      },
      {
        title: '备注',
        dataIndex: 'remark',
        align: 'center',
        ellipsis: true,
        key: 'remark',
      },
      {
        title: '修改时间',
        dataIndex: 'updateTime',
        align: 'center',
        ellipsis: true,
        key: 'updateTime',
      },
      {
        title: '创建时间',
        dataIndex: 'createTime',
        ellipsis: true,
        align: 'center',
        key: 'createTime',
      },

      {
        title: '操作',
        key: 'operation',
        scopedSlots: { customRender: 'operation' },
        width: 150,
        fixed: 'right',
        align: 'center',
      },
    ],
    Modelitems: [
      {
        span: 24,
        type: 'input',
        name: 'id',
        hidden: true,
        label: 'id',
        value: '',
      },
      {
        span: 24,
        type: 'input',
        name: 'areaNo',
        required: true,
        label: '区域编号',
        value: '',
      },

      {
        span: 24,
        type: 'select',
        name: 'areaType',
        required: true,
        label: '区域类别',
        options: [
          { label: '区域', value: 10 },
          { label: '接驳口', value: 20 },
        ],
        on: {
          change(value, label, options, vnode) {
            console.log(arguments)
            if (value == 20) {
              that.config.Modelitems.forEach((item) => {
                if (
                  item.name == 'gcsLocationNo' ||
                  item.name == 'mcsLocationNo' ||
                  item.name == 'rcsLocationNo' ||
                  item.name == 'spsLocationNo' ||
                  item.name == 'x' ||
                  item.name == 'y' ||
                  item.name == 'rcsLocationNo'
                ) {
                  item.hidden = false
                  item.required = false
                }
                if (item.name == 'locationStrategy') {
                  item.hidden = true
                  item.required = false
                }
                if (item.name == 'pointX' || item.name == 'pointY') {
                  item.hidden = true
                  item.required = false
                }
              })
              console.log(that.config.Modelitems)
            } else if (value == 10) {
              that.config.Modelitems.forEach((item) => {
                if (
                  item.name == 'gcsLocationNo' ||
                  item.name == 'mcsLocationNo' ||
                  item.name == 'rcsLocationNo' ||
                  item.name == 'spsLocationNo' ||
                  item.name == 'x' ||
                  item.name == 'y' ||
                  item.name == 'locationStrategy' ||
                  item.name == 'rcsLocationNo'
                ) {
                  item.hidden = true
                  item.required = false
                }
                if (item.name == 'locationStrategy') {
                  item.hidden = false
                  item.required = true
                }
                if (item.name == 'pointX' || item.name == 'pointY') {
                  item.hidden = false
                  item.required = false
                }
              })
            }
            // console.log(that.$refs.model.form.fieldsStore)
            console.log(that.config.Modelitems)
          },
        },
        value: '',
      },
      {
        span: 24,
        type: 'input',
        name: 'gcsLocationNo',
        // hidden: true,
        required: false,
        label: 'GCS点位',
        value: '',
      },
      {
        span: 24,
        type: 'input',
        name: 'mcsLocationNo',
        // hidden: true,
        required: false,
        label: 'MCS点位',
        value: '',
      },

      {
        span: 24,
        type: 'input',
        name: 'rcsLocationNo',
        hidden: true,
        required: false,
        label: 'RCS点位',
        value: '',
      },

      {
        span: 24,
        type: 'input',
        name: 'spsLocationNo',
        hidden: true,
        required: false,
        label: 'SPS点位',
        value: '',
      },
      {
        span: 24,
        type: 'input',
        name: 'layer',
        required: true,
        label: '层',
        value: '',
      },

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

      {
        span: 24,
        type: 'input',
        name: 'y',
        hidden: true,
        required: true,
        label: 'Y轴',
        value: '',
      },
      {
        span: 24,
        type: 'input',
        name: 'pointX',
        hidden: true,
        required: true,
        label: '锚点X',
        value: '',
      },

      {
        span: 24,
        type: 'input',
        name: 'pointY',
        hidden: true,
        required: true,
        label: '锚点Y',
        value: '',
      },
      //   {
      //     title: '下游WCS系统',
      //     dataIndex: 'deviceSystem',
      //     align: 'center',
      //     ellipsis: true,
      //     key: 'deviceSystem'
      //   },
      {
        span: 24,
        type: 'input',
        name: 'deviceSystem',
        required: true,
        label: '下游WCS系统',
        value: '',
      },

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

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

      //   policy
      {
        span: 24,
        type: 'select',
        required: false,
        name: 'locationStrategy',
        hidden: true,
        label: '分配货位策略',
        value: '',
        ...remote('eisInboundStrategyType'),
      },
      {
        span: 24,
        type: 'input',
        name: 'gcsArea',
        required: false,
        label: '跨层区域',
        value: '',
      },
      {
        span: 24,
        type: 'input',
        name: 'wmsAreaNo',
        required: true,
        label: 'WMS接口区域',
        value: '',
      },
      {
        span: 24,
        type: 'input',
        name: 'policy',
        required: true,
        label: '结束区域',
        value: '',
      },
      {
        span: 24,
        type: 'select',
        name: 'secondStrategy',
        required: true,
        label: '二次分配配置',
        value: '',
        //
        ...remote('secondStrategy'),
      },

      {
        span: 24,
        type: 'textarea',
        name: 'remark',
        required: true,
        label: '备注',
        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: 'locationStrategy',
        label: '分配货位策略',
        value: '',
        ...remote('eisInboundStrategyType'),
      },
      {
        span: 24,
        type: 'input',
        name: 'gcsArea',
        required: false,
        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: 'locationStrategy',
        label: '分配货位策略',
        value: '',
        ...remote('eisInboundStrategyType'),
      },
      {
        span: 24,
        type: 'input',
        name: 'gcsArea',
        required: false,
        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
