import items from "../model/girdform";
import { columns } from "../model/columns";
import { mainCols } from "../model/mainCols";
import {upcloud_base_wh_inbound,SERVICE_DATA_API_BASE} from "@/config/serviceSettings";

const modelConfig = function (_this) {
  return {
    title: '订单信息',
    //搜索框配置 girdform
    girdform: [
      // { type: 'input', name: 'tempSaveName', label: '暂存人', value: '', labelCol: { span: 8 }, span: 6, },
      ...items
    ],
    //订单列表数据
    mainlist: {
      remoteBefore(vn, params) {
        let p = { ...params }
        let pp = { "rcvTypeCodes": ["2", "5"], tempSave: 1 };
        if (params.data.warehouseCode) pp.warehouseCode = params.data.warehouseCode;
        if (params.data.cargoOwnerCode) pp.mtlOwnerNum = params.data.cargoOwnerCode;
        if (params.data.asnAutoBillNum) pp.asnAutoBillNum = params.data.asnAutoBillNum;
        if (params.data.itemZjm) pp.itemZjm = params.data.itemZjm;
        if (params.data.shipperZjm) pp.shipperZjm = params.data.shipperZjm;
        if (params.data.startTime) pp.startTime = params.data.startTime;
        if (params.data.endTime) pp.endTime = params.data.endTime;
        if (params.data.rcvType) pp.rcvType = params.data.rcvType;
        p.data = {
          num: '588464518951211008',
          pageNum: params.data.pageNum, pageSize: params.data.pageSize,
          params: pp
        };
        return p;
      },
      columns: [
        { title: '暂存ID', dataIndex: 'tempSaveId', key: 'tempSaveId', hidden: true },
        { title: '暂存人', dataIndex: 'tempSaveName', key: 'tempSaveName' },
        { title: '暂存时间', dataIndex: 'tempSaveTime', key: 'tempSaveTime' },
        ...mainCols
      ],
      operators: [
        {
          label: '单位查看',
          click(item) {
            _this.viewSupplierItem = item;
            _this.showViewSupplier = true;
          }
        }
      ],
      rowKey: /* 'billid' */'tempSaveId',
      remoteParams: {},
      remoteUrl: {
        url: SERVICE_DATA_API_BASE+'/search/page',
        method: 'post'
      }
    },
    //商品列表配置
    sublist: {
      rowKey: 'asnLineId',
      columns: [...columns],
      rowSelectType: 3,
      operators: [
        {
          label: '查看商品图片',
          click(item) {
            _this.viewCommodity = item;
            _this.showCommodity = true;
          }
        }
      ],
      GoodsremoteUrl: {
        url: upcloud_base_wh_inbound+'/rcvHeaders/v1.0/findItemWithRelatedTemp',
        method: 'get'
      },
      remoteBefore(data, record) {
        return {
          tempSaveId: record.tempSaveId,
        };
      },
      done(list) {
        _this.handleQueryItems(list, _this.$refs.historyModel)
      }
    }
  }
}
export default modelConfig
