import { remote } from './remote'
import { upcloud_base_wh ,upcloud_base_chain} from "@/config/serviceSettings";

const items = [
  {
    type: 'date',
    name: 'billDateStart',
    label: '开始时间',
    format: 'YYYY-MM-DD HH:mm:ss'
  },
  {
    type: 'date',
    name: 'billDateEnd',
    label: '结束时间',
    format: 'YYYY-MM-DD HH:mm:ss'
  },
  {
    type: 'input',
    name: 'billDateEnd',
    label: '波次号',
    format: 'YYYY-MM-DD HH:mm:ss'
  },
  {
    type: 'select',
    name: 'status',
    label: '状态',
    format: 'YYYY-MM-DD HH:mm:ss'
  },
  {
    span: 24,
    type: 'buttonGroup',
    style: { textAlign: 'right' },
    options: [
      {
        value: '查询',
        icon: 'search',
        btnType: 'primary',
        style: 'margin-right:10px',
        htmlType: 'submit'
      },
      {
        value: '重置',
        name: 'ccz',
        icon: 'redo',
        on: {
          click(event, form) {
            form.resetFields()
          }
        }
      }
    ]
  }
]

const modalItems = [
  {
    type: 'input',
    name: 'dcId',
    label: '仓配中心id',
    hidden: true
  },
  {
    name: 'dcName',
    label: '仓配中心名称',
    type: 'searchModal',
    remoteUrl: { url: upcloud_base_wh +'/wmsdc/page', method: 'get' },
    rowKey: 'dcId',
    targetValueKey: 'dcName',
    required: true,
    toolBar: {
      items: [
        {
          type: 'input',
          name: 'dcCode',
          label: '仓配中心编码',
          value: ''
        },
        {
          type: 'input',
          name: 'dcName',
          label: '仓配中心名称',
          value: ''
        }
      ]
    },
    tableConfig: {
      columns: [
        {
          dataIndex: 'dcCode',
          title: '仓配中心编码'
        },
        {
          dataIndex: 'dcName',
          title: '仓配中心名称'
        }
      ]
    },
    on: {
      ok(event, value, rowData, form) {
        form.setFieldsValue({
          dcId: `${rowData[0].dcId}`
        })
      }
    }
  },
  {
    type: 'input',
    name: 'warehouseId',
    label: '仓库id',
    required: true,
    hidden: true
  },
  {
    type: 'searchModal',
    name: 'warehouseName',
    label: '仓库名称',
    remoteUrl: { url: upcloud_base_wh +'/warehouse/page', method: 'get' },
    rowKey: 'warehouseId',
    targetValueKey: 'warehouseName',
    required: true,
    toolBar: {
      items: [
        {
          type: 'input',
          name: 'warehouseCode',
          label: '仓库编码',
          value: ''
        },
        {
          type: 'input',
          name: 'warehouseName',
          label: '仓库名称',
          value: ''
        }
      ]
    },
    tableConfig: {
      columns: [
        {
          dataIndex: 'warehouseCode',
          title: '仓库编码'
        },
        {
          dataIndex: 'warehouseName',
          title: '仓库名称'
        }
      ]
    },
    on: {
      ok(event, value, rowData, form) {
        form.setFieldsValue({
          warehouseId: `${rowData[0].warehouseId}`
        })
      }
    }
  },
  {
    type: 'input',
    name: 'warehouseRoomId',
    label: '库房id',
    required: true,
    hidden: true
  },
  {
    type: 'searchModal',
    name: 'warehouseRoomName',
    label: '库房名称',
    required: true,
    remoteUrl: { url: upcloud_base_wh +'/baseWmsWarehouseRoomMst/page', method: 'post' },
    rowKey: 'warehouseRoomId',
    targetValueKey: 'warehouseRoomName',
    toolBar: {
      items: [
        {
          type: 'input',
          name: 'warehouseRoomCode',
          label: '库房编码',
          value: ''
        },
        {
          type: 'input',
          name: 'warehouseRoomName',
          label: '库房名称',
          value: ''
        }
      ]
    },
    tableConfig: {
      columns: [
        {
          dataIndex: 'warehouseRoomCode',
          title: '库房编码'
        },
        {
          dataIndex: 'warehouseRoomName',
          title: '库房名称'
        }
      ]
    },
    on: {
      ok(event, value, rowData, form) {
        form.setFieldsValue({
          warehouseRoomId: `${rowData[0].warehouseRoomId}`
        })
      }
    }
  },
  {
    type: 'input',
    name: 'warehouseAreaId',
    label: '库区id',
    required: true,
    hidden: true
  },
  {
    type: 'searchModal',
    name: 'warehouseAreaName',
    label: '库区名称',
    required: true,
    remoteUrl: { url: upcloud_base_wh +'/baseWmsWarehouseArea/page', method: 'post' },
    rowKey: 'warehouseAreaId',
    targetValueKey: 'warehouseAreaName',
    toolBar: {
      items: [
        {
          type: 'input',
          name: 'warehouseAreaCode',
          label: '库区编码',
          value: ''
        },
        {
          type: 'input',
          name: 'warehouseAreaName',
          label: '库区名称',
          value: ''
        }
      ]
    },
    tableConfig: {
      columns: [
        {
          dataIndex: 'warehouseAreaCode',
          title: '库区编码'
        },
        {
          dataIndex: 'warehouseAreaName',
          title: '库区名称'
        }
      ]
    },
    on: {
      ok(event, value, rowData, form) {
        form.setFieldsValue({
          warehouseAreaId: `${rowData[0].warehouseAreaId}`
        })
      }
    }
  },
  {
    type: 'input',
    name: 'stageCode',
    label: '集货区编码',
    required: true
  },
  {
    type: 'select',
    name: 'stageType',
    label: '集货区类型',
    required: true,
    ...remote('pub_workstage_stagetype')
  },
  {
    type: 'select',
    name: 'shiplineId',
    label: '配送方向',
    ...remote('common_shiplineid')
  },
  {
    type: 'select',
    name: 'deliveryType',
    label: '提货方式',
    ...remote('pub_workstage_delivertype')
  },
  {
    type: 'input',
    name: 'customerId',
    label: '客户id',
    hidden: true
  },
  {
    type: 'searchModal',
    name: 'customerName',
    label: '客户名称',
    required: true,
    remoteUrl: { url: upcloud_base_chain+'/baseCustomerMst/v1.0/page', method: 'post' },
    rowKey: 'customerId',
    targetValueKey: 'customerName',
    toolBar: {
      items: [
        {
          type: 'input',
          name: 'customerCode',
          label: '客户编码'
        },
        {
          type: 'input',
          name: 'customerName',
          label: '客户名称'
        }
      ]
    },
    tableConfig: {
      columns: [
        {
          dataIndex: 'customerCode',
          title: '客户编码'
        },
        {
          dataIndex: 'customerName',
          title: '客户名称'
        }
      ]
    },
    on: {
      ok(event, value, rowData, form) {
        form.setFieldsValue({
          customerId: `${rowData[0].customerId}`
        })
      }
    }
  },
  {
    type: 'input',
    name: 'numlimit',
    label: '订单数限制'
  },
  {
    type: 'input',
    name: 'tunnelno',
    label: '巷道'
  },
  {
    type: 'select',
    name: 'isEnable',
    label: '状态',
    options: [
      {
        label: '启用',
        value: 1
      },
      {
        label: '禁用',
        value: 0
      }
    ]
  }
]

const columns = [
  {
    dataIndex: 'wavesId',
    title: '波次ID'
  },
  {
    dataIndex: 'wavesCode',
    title: '波次编号'
  },
  {
    dataIndex: 'warehouseId',
    title: '物理仓ID'
  },
  {
    dataIndex: 'mtlOwnerId',
    title: '货主ID'
  },
  {
    dataIndex: 'enterpriseId',
    title: '企业ID'
  },
  {
    dataIndex: 'billStruct',
    title: '订单结构'
  },
  {
    dataIndex: 'billLevel',
    title: '优先级'
  },
  {
    dataIndex: 'billType',
    title: '订单类型'
  },
  {
    dataIndex: 'creatorName',
    title: '创建人'
  },
  {
    dataIndex: 'modifierName',
    title: '最后修改人'
  },
  {
    dataIndex: 'gmtCreate',
    title: '创建日期'
  },
  {
    dataIndex: 'gmtModified',
    title: '最后修改日期'
  },
  {
    dataIndex: 'status',
    title: '状态',
    scopedSlots: { customRender: 'isEnable' }
  },
  {
    dataIndex: 'action',
    title: '操作',
    scopedSlots: { customRender: 'action' },
    width: 140,
    fixed: 'right'
  }
]

export { items, modalItems, columns }
