const resultMap = {
    '0': '合格',
    '1': '不合格',
    '2': '隔离'
};

let warehouseId = null;
let cargoOwnerId = null;
let itemId = null;
let itemCategoryCode = null;

export const extendFormItems = [
    { hidden: true, title: "taskId", dataIndex: "taskId", key: "taskId" },
    { hidden: true, title: "warehouseId", dataIndex: "warehouseId", key: "warehouseId" },
    { hidden: true, title: "warehouseLocatorId", dataIndex: "warehouseLocatorId", key: "warehouseLocatorId" },
    { hidden: true, title: "lineNum", dataIndex: "lineNum", key: "lineNum" },
    { hidden: true, title: "itemId", dataIndex: "itemId", key: "itemId" },
    { hidden: true, title: "inBoundLineId", dataIndex: "rcvLineId", key: "inBoundLineId" },
    { hidden: true, title: "batchNum", dataIndex: "batchNum", key: "batchNum" },
    { hidden: true, title: "batchId", dataIndex: "batchId", key: "batchId" },
    { hidden: true, title: "rcvHeaderId", dataIndex: "rcvHeaderId", key: "rcvHeaderId" },

    { hidden: true, type: 'txt', title: "库区编号", dataIndex: "whAreaCode", key: "whAreaCode" },
    { hidden: true, type: 'txt', title: "区域编号", dataIndex: "whAreaCategoryId", key: "whAreaCategoryId" },
    { hidden: true, type: 'txt', title: "库别编码", dataIndex: "whAreaCategoryCode", key: "whAreaCategoryCode" },
    { hidden: true, type: 'txt', title: "实际货位id", dataIndex: "realWhLocatorId", key: "realWhLocatorId" },
    { hidden: true, type: 'txt', title: "货位编号", dataIndex: "realWhLocatorName", key: "realWhLocatorName" },
    { hidden: true, type: 'txt', title: "货位编号", dataIndex: "realWhLocatorCode", key: "realWhLocatorCode" },
    { hidden: true, type: 'txt', title: "whLocatorId", dataIndex: "whLocatorId", key: "whLocatorId" },

    { type: 'txt', title: "商品编码", dataIndex: "itemNum", key: "itemNum", width: 120 },
    { type: 'txt', title: "商品名称", dataIndex: "itemName", key: "itemName", width: 160 },
    { type: 'txt', title: "商品分类", dataIndex: "categoryName", key: "categoryName", width: 120 },
    { type: 'txt', title: "批号", dataIndex: "manufacturerLotNum", key: "manufacturerLotNum", width: 60 },
    {
        type: 'txt', title: "生产日期", dataIndex: "batchProductionDate", key: "batchProductionDate", width: 80,
        customRender(text, record) {
            return record.manufacturerLotNum === '*' ? '' :
                (text ? text.substring(0, 10) : '');
        }
    },
    {
        type: 'txt', title: "有效期至", dataIndex: "batchExpiredDate", key: "batchExpiredDate", width: 80,
        customRender(text, record) {
            return record.manufacturerLotNum === '*' ? '' :
                (text ? text.substring(0, 10) : '');
        }
    },

    { type: 'txt', title: "包装单位", dataIndex: "uom", key: "uom", width: 80 },
    { type: 'txt', title: "包装含量", dataIndex: "conversionRate", key: "conversionRate", width: 90 },
    { type: 'txt', title: "上架件数", dataIndex: "oddCaseQty", key: "oddCaseQty", width: 120 },
    { type: 'txt', title: "上架零散数", dataIndex: "oddPieceQty", key: "oddPieceQty", width: 150 },
    { type: 'txt', title: "上架最小单位数量", dataIndex: "pieceQty", key: "pieceQty", width: 150 },

    {
        type: 'txt', title: "验收结果", dataIndex: "result", key: "result", width: 120,
        customRender(text) {
            return resultMap[text] || '';
        }
    },
    { type: 'txt', title: "建筑物", dataIndex: "bldgCode", key: "bldgCode", width: 90 },
    { type: 'txt', title: "库区编号", dataIndex: "warehouseAreaCodes", key: "warehouseAreaCodes", width: 120 },
    { type: 'txt', title: "库房", dataIndex: "whRoom", key: "whRoom", width: 60 },
    { type: 'edit', title: "货格编码", dataIndex: "goodsCaseCode", key: "goodsCaseCode", width: 60 },
    { type: 'edit', title: "容器号", dataIndex: "containerCode", key: "containerCode", width: 90 },
    {
        ...genWarehouseLocatorSearchModal(2, true, false, function (res, p) {
            p.params.warehouseId = warehouseId;
            p.params.cargoOwnerId = cargoOwnerId;
            p.params.itemId = itemId;
            p.params.itemCategoryCode = itemCategoryCode;
            return p;
        }, function (modalRowData, index) {
            if (!modalRowData) {
                warehouseId = null;
                cargoOwnerId = null;
                itemId = null;
                itemCategoryCode = null;
            } else {
                let ref = _this.queryRefFromName('list')
                let oldItem = ref.data[index];
                let newItem = {
                    ...oldItem,
                    whAreaCode: modalRowData[0].warehouseAreaCode,
                    whAreaCategoryId: modalRowData[0].warehouseAreaCategory,
                    whAreaCategoryCode: modalRowData[0].warehouseAreaCategoryCode,
                    realWhLocatorId: modalRowData[0].warehouseLocatorId,
                    realWhLocatorName: modalRowData[0].warehouseLocatorName,
                    realWhLocatorCode: modalRowData[0].warehouseLocatorCode,
                }
                ref.data.splice(index, 1, newItem)
            }
        }),
        title: '实际货位',
        width: 140,
    },
    // {
    //     type: 'search',
    //     width: 80,
    //     title: '实际货位',
    //     dataIndex: 'warehouseLocatorName',
    //     required: true,
    //     // remoteUrl: upcloud_base_wh_control+'/item-locator/v1/getLocatorLogic',
    //     remoteUrl: upcloud_base_wh+'/locator/page',
    //     targetValueKey: 'warehouseLocatorName',
    //     targetClick: true,
    //     rowKey: 'warehouseLocatorId',
    //     tableConfig: {
    //         columns: [
    //             { hidden: true, title: 'id', key: 'warehouseLocatorId', dataIndex: 'warehouseLocatorId' },
    //             // { title: '仓库编号', key: 'warehouseCode', dataIndex: 'warehouseCode' },
    //             // { title: '仓库名称', key: 'warehouseName', dataIndex: 'warehouseName' },
    //             { title: '建筑物编号', key: 'bldgCode', dataIndex: 'bldgCode' },
    //             { title: '建筑物名称', key: 'bldgName', dataIndex: 'bldgName' },
    //             // { title: '逻辑区编号', key: 'warehouseLogicCode', dataIndex: 'warehouseLogicCode' },
    //             // { title: '逻辑区名称', key: 'warehouseLogicName', dataIndex: 'warehouseLogicName' },
    //             { title: '货位编号', key: 'warehouseLocatorCode', dataIndex: 'warehouseLocatorCode' },
    //             { title: '货位名称', key: 'warehouseLocatorName', dataIndex: 'warehouseLocatorName' },

    //             // { title: '长', key: 'len', dataIndex: 'len' },
    //             // { title: '宽', key: 'wid', dataIndex: 'wid' },
    //             // { title: '高', key: 'hgt', dataIndex: 'hgt' },
    //             { title: '体积', key: 'containerVol', dataIndex: 'containerVol' },
    //             { title: '重量限制', key: 'wgtlmt', dataIndex: 'wgtlmt' },
    //             // { title: '容器类型', key: 'containerType', dataIndex: 'containerType' },
    //             // { title: '装填百分比', key: 'containerPercent', dataIndex: 'containerPercent' },
    //         ],
    //         remoteBefore(res, p) {
    //             p.params.warehouseId = warehouseId;
    //             p.params.cargoOwnerId = cargoOwnerId;
    //             p.params.itemId = itemId;
    //             p.params.itemCategoryCode = itemCategoryCode;
    //             return p;
    //         }
    //     },
    //     destroyOnClose: true,
    //     on: {
    //         change({ modalRowData, index, value, record }) {
    //             // 
    //             if (!value) {
    //                 
    //                 warehouseId = null;
    //                 cargoOwnerId = null;
    //                 itemId = null;
    //                 itemCategoryCode = null;
    //             } else {
    //                 let ref = _this.queryRefFromName('list')
    //                 let oldItem = ref.data[index];
    //                 let newItem = {
    //                     ...oldItem,
    //                     whAreaCode: modalRowData[0].warehouseAreaCode,
    //                     whAreaCategoryId: modalRowData[0].warehouseAreaCategory,
    //                     whAreaCategoryCode: modalRowData[0].warehouseAreaCategoryCode,
    //                     realWhLocatorId: modalRowData[0].warehouseLocatorId,
    //                     realWhLocatorName: modalRowData[0].warehouseLocatorName,
    //                     realWhLocatorCode: modalRowData[0].warehouseLocatorCode,
    //                 }
    //                 ref.data.splice(index, 1, newItem)
    //             }
    //         }

    //     }
    // },
    // { type: 'txt', title: "%显示货位", dataIndex: "xxxxx16", key: "xxxxx16", width: 120 },
    { type: 'txt', title: "库别", dataIndex: "whAreaCatagory", key: "whAreaCatagory", width: 60 },
    { type: 'txt', title: "拆分人", dataIndex: "spilterName", key: "spilterName", width: 90 },
    {
        type: 'txt', title: "是否正在拆分", dataIndex: "isSpilt", key: "isSpilt", width: 80,
        customRender(text) {
            return text ? '是' : '否';
        }
    },
    {
        title: '操作', key: 'operate', align: 'center', fixed: 'right', width: 100,
        scopedSlots: { customRender: 'action' },
    },
];
