import { upcloud_base_common,  } from "@/config/serviceSettings";
import {
  genWarehouseAuthSearchModal, genCargoownerAuthSearchModal,
  genBldgSearchModal, genWarehouseAreaSearchModal, genContainerSearchModal
} from "../../../../../../SearchModal";

let grid = {
  labelCol: { span: 6 }, span: 8,
};
var rcvTypeOption = []
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,
        options: [
          { label: '整件库', value: 'ZJK' },
          { label: '零货库', value: 'LHK' },
          { label: '直调库', value: 'ZDK' },
          { label: '整散合一库', value: 'HYK' },
          { label: '待处理库', value: 'CLK' },
          { label: '代管库', value: 'DGK' },
          { label: '越库区', value: 'YKQ' },
        ],
        // 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' }, enableFuzzyQuery: true }),
      // { 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, { enableFuzzyQuery: true }),
      { type: 'input', name: 'billNo', label: '单据编号', value: '', ...grid },
      { type: 'input', name: 'rcvNo', 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: 'select', name: 'rcvType', label: '入库类型', value: '',required:true,
        options:[
          { label: "代管入库", value: '8' },
          { label: "待检入库", value: '9' },
        ],
        // replaceFields: { value: 'dictCode', label: 'dictName' },
        ...grid,

        }

    ],
    columns: [
      { hidden: true, title: "rcvHeaderId", dataIndex: "rcvHeaderId", key: "rcvHeaderId" },
      { hidden: true, title: "mtlOwnerId", dataIndex: "mtlOwnerId", key: "mtlOwnerId" },
      { hidden: true, title: "warehouseId", dataIndex: "warehouseId", key: "warehouseId" },
      { hidden: true, title: "手动编号", dataIndex: "customBillNum", key: "customBillNum", width: 90, },
      { hidden: true, title: "单位助记码", dataIndex: "shipperZjm", key: "shipperZjm", width: 90 },
      { hidden: true, title: "客户", dataIndex: "customerName", key: "customerName", width: 120 },
      { hidden: true, title: "供应商", dataIndex: "vendorName", key: "vendorName", width: 120 },
      { hidden: true, title: "仓库", dataIndex: "warehouseName", key: "warehouseName", width: 120 },
      { hidden: true, title: "备注", dataIndex: "comments", key: "comments", width: 60 },

      {
        title: "验收日期", dataIndex: "rqcDate", key: "rqcDate", width: 130, /* format: "YYYY-MM-DD HH:mm:ss", */
        // customRender(text) {
        //   return text ? text.substring(0, 10) : '';
        // }
      },
      { title: "ERP单据编号", dataIndex: "asnBillNum", key: "asnBillNum", width: 130 },
      { title: "收货单号", dataIndex: "autoBillNum", key: "autoBillNum", width: 130 },
      { title: "业主编码", dataIndex: "mtlOwnerNum", key: "mtlOwnerNum", width: 130 },
      { title: "业主名称", dataIndex: "mtlOwnerName", key: "mtlOwnerName", width: 150 },
      { title: "单位名称", dataIndex: "shipperName", key: "shipperName", width: 170 },
      { title: "采购员", dataIndex: "buyerMane", key: "buyerMane", width: 120 },
      { title: "收货员", dataIndex: "executorUser", key: "executorUser", width: 120 },
      { title: "验收员", dataIndex: "rqcUser", key: "rqcUser", width: 120 },
      { title: "双人验收员", dataIndex: "rqcUser2", key: "rqcUser2", width: 120 },
     
    //   {
    //     title: "入库类型", dataIndex: "rcvType", width: 140, 
    //     remoteUrl: { url: upcloud_base_common+'/dict/listbytype?dicttypeCodes=oms_asn_bill_type', method: 'post' },
    //    replaceFields: {
    //      value: 'dictCode',
    //      // value: 'dictName',
    //      label: 'dictName'
    //    },
    //  },
     {
      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: 'dictCode',
       label: 'dictName'
     },
   },
      { title: "ERP单据备注", dataIndex: "asnRemark", key: "asnRemark" },
    ]

  }
}