import { rcvTypeOptions } from "../../../../config/options";
import {
  genWarehouseAuthSearchModal, genCargoownerAuthSearchModal,
  genBldgSearchModal, genWarehouseAreaSearchModal, genContainerSearchModal
} from "../../../../../SearchModal";

import {upcloud_base_common} from "@/config/serviceSettings";

let grid = {
  labelCol: { span: 6 }, span: 8,
};

export const basicData = function (self) {
  return {
    searchItems: [
      ...genWarehouseAuthSearchModal(1, true, false, null, function(rowData,form){
        self.getL_Type()
      }, grid),
      ...genCargoownerAuthSearchModal(1, true, false, null, null, grid, { mapper: { cargoOwnerId: 'mtlOwnerId' } }),
      // { type: 'input', name: 'bldgId', label: '建筑物', value: '', ...grid },
      // ...genBldgSearchModal(1, false, false, function (vnode, p) {
      //   let vals = self.queryRefFromName('main').$refs.form.form.getFieldsValue();
      //   p.params.warehouseId = vals.warehouseId;
      //   return p;
      // }, null, grid),
      // {
      //   type: 'select', name: 'whAreaCategoryCode', label: '库别', value: '', ...grid,
      //   remoteUrl: { url: upcloud_base_common+'/dict/listbytype?dicttypeCodes=wms_storeroom', method: 'post' },
      //   replaceFields: {
      //     value: 'dictCode',
      //     label: 'dictName'
      //   }
      // },
      // ...genWarehouseAreaSearchModal(1, false, false, function (vnode, p) {
      //   let vals = self.queryRefFromName('main').$refs.form.form.getFieldsValue();
      //   p.params.warehouseId = vals.warehouseId;

      //   return p;
      // }, null, grid, { mapper: { warehouseAreaCode: 'whAreaCode' } }),
      // // { type: 'input', name: 'whAreaCode', label: '库区', value: '', ...grid },
      // ...genContainerSearchModal(1, false, false, function (vnode, p) {
      //   let vals = self.queryRefFromName('main').$refs.form.form.getFieldsValue();
      //   p.params.warehouseId = vals.warehouseId;
      //   return p;
      // }, null, grid),
      { type: 'input', name: 'billNo', label: '单据编号', value: '', ...grid },
      { type: 'input', name: 'autoBillNum', label: '收货编号', value: '', ...grid },
      // { type: 'input', name: 'containerCode', label: '容器号', value: '', ...grid },
      // { type: 'input', name: 'instockLabel', label: '上架标签条码', value: '', ...grid },
      { type: 'input', name: 'itemZjm', label: '商品助记码', value: '', ...grid },
      { type: 'input', name: 'shipperZjm', label: '单位助记码', value: '', ...grid },
      {
        type: 'select', name: 'rcvType', label: '收货类型', value: '',
        ...grid, options: [
          ...rcvTypeOptions
        ],
      },
      // { type: 'input', name: 'autoBillNum', label: '自动单号', value: '', ...grid },
      // { type: 'input', name: 'customBillNum', label: '手工单号', value: '', ...grid },

    ],
    columns: [
      { hidden: true, title: "rcvHeaderId", dataIndex: "rcvHeaderId", key: "rcvHeaderId" },
      { title: "原单据编号", dataIndex: "asnBillNum", key: "asnBillNum", width: 90 },
      { title: "收货编号", dataIndex: "autoBillNum", key: "autoBillNum", width: 140 },
      { title: "手动编号", dataIndex: "customBillNum", key: "customBillNum", width: 90, hidden: true },
      { title: "业主编码", dataIndex: "mtlOwnerNum", key: "mtlOwnerNum", width: 90 },
      { title: "业主名称", dataIndex: "mtlOwnerName", key: "mtlOwnerName", width: 90 },
      // { title: "验收员", dataIndex: "%", key: "%", width: 90 },
      { title: "操作员", dataIndex: "executorUser", key: "executorUser", width: 90 },
      {
        title: "收货日期", dataIndex: "rcvDate", key: "rcvDate", width: 80,
        customRender(text) {
          return text ? text.substring(0, 10) : '';
        }
      },
      { title: "客户", dataIndex: "customerName", key: "customerName", width: 120 },
      { title: "供应商", dataIndex: "vendorName", key: "vendorName", width: 120 },
      { title: "仓库", dataIndex: "warehouseName", key: "warehouseName", width: 120 },
      // { title: "原单据编号", dataIndex: "srcAutoBillNum", key: "srcAutoBillNum", width: 150 },
      { title: "采购员", dataIndex: "buyerMane", key: "buyerMane", width: 90 },
      // { title: "收货员", dataIndex: "executorUser", key: "executorUser", width: 90 },
      {
        title: "入库类型", dataIndex: "rcvType", width: 140, 
       // scopedSlots: { customRender: 'rcvReason1' }
       autoLoad: true, remoteUrl: { url: upcloud_base_common+'/dict/listbytype?dicttypeCodes=oms_asn_bill_type', method: 'post' },
       replaceFields: {
         value: 'dictCode',
         // value: 'dictName',
         label: 'dictName'
       },
     },
      { title: "备注", dataIndex: "comments", key: "comments", width: 60 },
    ]

  }
}