import { genCustomerSearchModal, genWarehouseAuthSearchModal } from '@/views/kzyWMS/SearchModal'
import { upcloud_base_common, upcloud_base_wh_outbound } from '@/config/serviceSettings'

const grid = { span: 8, labelCol: { span: 6 } }

export const items = [
  // 仓库
  // 波次下发后可按照波次、单据编号、部门、配送方向批量提高单据拣货优先级；
  ...genWarehouseAuthSearchModal(1, true, false, null, null, grid),

  ...genCustomerSearchModal(1, false, false, null, null, grid),
  { type: 'input', name: 'waveCode', label: '波次编号', value: '', ...grid },
  { type: 'input', name: 'code', label: '订单编号', value: '', ...grid },
  {
    type: 'select',
    name: 'billTypeCode',
    label: '单据类型',
    remoteUrl: { url: upcloud_base_common + '/dict/listbytype?dicttypeCodes=do_bill_type', method: 'post' },
    replaceFields: {
      label: 'dictName',
      value: 'dictCode'
    },
    defaultValueIndex: 0,
    autoLoad: true,
    destroyOptions: false,
    ...grid
  },
  { type: 'input', name: 'createBy', label: '开单员', value: '', ...grid },
  { type: 'date', name: 'startDate', label: '开始日期', format: 'YYYY-MM-DD', value: '', ...grid },
  { type: 'date', name: 'endDate', label: '结束日期', format: 'YYYY-MM-DD', value: '', ...grid },
//   {type: 'input', name: 'shipperName', label: '客户名称', value: '', ...grid},
//   {type: 'input', name: 'createby', label: '业务员', value: '', ...grid},
//   {type: 'input', name: 'remark', label: '备注', value: '', ...grid},
//   {type: 'select', name: 'isEmergency', label: '是否急单', value: '', ...grid, options: [{label: 1, value: '否'}, {label: 2, value: '是'}]},
  {
    type: 'select',
    name: 'status',
    label: '状态',
    remoteUrl: { url: upcloud_base_wh_outbound + '/wave/bill/status/enum', method: 'get' },
    replaceFields: {
      label: 'name',
      value: 'code'
    },
    defaultValueIndex: 0,
    autoLoad: true,
    destroyOptions: false,
    ...grid
  },
  {
    span: 22, labelCol: { span: 6 },
    type: 'buttonGroup',
    style: { textAlign: 'right' },
    options: [
      { value: '查询', icon: 'search', btnType: 'primary', style: 'margin-right:16px', htmlType: 'submit' },
      {
        value: '重置', name: 'ccz', icon: 'redo',
        on: {
          click(event, form) {
            form.resetFields()
          }
        }
      }
    ]
  }
]

export const columns = [
  // { dataIndex:'attainDate', title:'预定到货日',width:120,scopedSlots:{customRender:'attainDate'}},
  { dataIndex: 'code', title: '订单编号', width: 100, sorter: (a, b) => a.code.localeCompare(b.code) },
  { dataIndex: 'type', title: '单据类型', width: 100, sorter: (a, b) => a.type.localeCompare(b.type) },
  { dataIndex: 'shipperName', title: '收货单位(客户)名称', width: 80, sorter: (a, b) => a.shipperName.localeCompare(b.shipperName) },
  { dataIndex: 'status', title: '状态', width: 80, sorter: (a, b) => a.status.localeCompare(b.status) },
  { dataIndex: 'totalPcs', title: '总件数', width: 80, sorter: (a, b) => b.totalPcs - a.totalPcs },
  { dataIndex: 'totalQty', title: '总数量', width: 80, sorter: (a, b) => b.totalQty - a.totalQty },
  { dataIndex: 'priority', title: '订单紧急等级', width: 80, sorter: (a, b) => b.priority - a.priority },
  { dataIndex: 'carrierName', title: '物流商名称', width: 100, sorter: (a, b) => a.carrierName.localeCompare(b.carrierName) },
  // {dataIndex: 'receiveWay', title: '提货方式', width: 120, scopedSlots: {customRender: 'receiveWay'}, ellipsis: true, sorter: (a, b) => a.receiveWay.localeCompare(b.receiveWay)},
  { dataIndex: 'contactName', title: '收货联系人', width: 80, sorter: (a, b) => a.contactName.localeCompare(b.contactName) },
  { dataIndex: 'contactTel', title: '收货联系人电话', width: 120, ellipsis: true, sorter: (a, b) => a.contactTel.localeCompare(b.contactTel) },
  { dataIndex: 'containersNum', title: '包装数量', width: 80, sorter: (a, b) => b.containersNum - a.containersNum },
  { dataIndex: 'receiveAddress', title: '收货地址', width: 120, ellipsis: true, sorter: (a, b) => a.receiveAddress.localeCompare(b.receiveAddress) },
  { dataIndex: 'saleBranchName', title: '销售员部门', width: 80, sorter: (a, b) => a.saleBranchName.localeCompare(b.saleBranchName) },
  { dataIndex: 'shipperCode', title: '收货单位(客户)编码', width: 80, sorter: (a, b) => a.shipperCode.localeCompare(b.shipperCode) },
  { dataIndex: 'shipperType', title: '收货单位(客户)类型', width: 80, sorter: (a, b) => a.shipperType.localeCompare(b.shipperType) },
  { dataIndex: 'totalVolume', title: '总体积', width: 80, sorter: (a, b) => a.totalVolume - b.totalVolume },
  { dataIndex: 'totalWeight', title: '总重量', width: 80, sorter: (a, b) => a.totalWeight - b.totalWeight },
  { dataIndex: 'createBy', title: '开单员', width: 80, sorter: (a, b) => a.createBy.localeCompare(b.createBy) },
  { dataIndex: 'waveId', title: '波次编号', width: 80, sorter: (a, b) => a.waveId.localeCompare(b.waveId) },
  { dataIndex: 'consignorName', title: '货主名称', width: 80, sorter: (a, b) => a.consignorName.localeCompare(b.consignorName) }
]
