/**
 * guoj
 * 2018.10.16
 * 货位
 */
 import { UPCLOUD_RDC_TMS_MAINDATA_SERVICE,UPCLOUD_RDC_TMS_BUSINESS_SERVICE,UPCLOUD_RDC_TMS_INTERFACE_SERVICE} from '@/config/serviceSettings.js';
 import { getSelectGJ, querySysPicture } from '@/utils/prolog.ajax.js';
 export default () => {
    //获取下拉框
    getSelectGJ([{ "objectcode": "itemtype" }, { "objectcode": "wms_loctype" }, { "objectcode": "wms_abcattr" },
    { "objectcode": "stacktype" }, { "objectcode": "wms_storagecondition" }, { "objectcode": "wms_locationstatus" },
    { "objectcode": "stroragegroup" }, { "objectcode": "gjcapacitylimittype" }], function (data) {
        data.data.stroragegroup.unshift({ "text": "", "value": "" });
        data.data.wms_storagecondition.unshift({ "text": "", "value": "" });
        $("#position_select").attr("consignor", JSON.stringify(data.data));

    });
    //库别
    var warehouse = getDropDownWharehouseGJ();
    //新增修改状态
    var position_change;
    var positguoj = { "pageSize": 10, "pageNum": 1 };
    var opts = {
        //terrace显示全部，card分页显示
        skin: "card",
        columns: [
            { id: "locid", name: "id", type: "ro", width: "130", hidden: true },
            { id: "loccode", name: "货位编号", type: "ro", width: "100" },
            { id: "areano", name: "区域", type: "ro", width: "60" },
            { id: "loctype", name: "库别", type: "ro", width: "80" },
            { id: "tunnelno", name: "巷道", type: "ro", align: "right", width: "60" },
            { id: "locRow", name: "排", type: "ro", align: "right", width: "60" },
            { id: "locFloor", name: "层", type: "ro", align: "right", width: "60" },
            { id: "locCol", name: "列", type: "ro", align: "right", width: "60" },
            { id: "picktype1group", name: "拣选方式分组1", type: "ro", width: "130", hidden: true },
            { id: "itemnum", name: "品种限制", type: "ro", width: "130", hidden: true },
            { id: "lotnum", name: "批次限制", type: "ro", width: "130", hidden: true },
            { id: "lotnum2", name: "件数限制", type: "ro", width: "130", hidden: true },
            { id: "containernum", name: "数量限制", type: "ro", align: "right", width: "130", hidden: true },
            { id: "limitvalue", name: "体积限制(m3)", type: "ro", align: "right", width: "130", hidden: true },
            { id: "weightlimit", name: "重量限制(KG)", type: "ro", align: "right", width: "130", hidden: true },
            {
                id: "capacitylimittype", name: "容器限制方式", type: "ro", width: "90", render: function (v, rd) {
                    if (rd["capacitylimittype"] == "ITEMNUM") {
                        return "按品种";
                    }
                    if (rd["capacitylimittype"] == "LOTNUM") {
                        return "按品规";
                    }
                    if (rd["capacitylimittype"] == "QTY") {
                        return "按数量";
                    }
                    if (rd["capacitylimittype"] == "VOL") {
                        return "按体积";
                    }
                }
            },
            { id: "pickseqno", name: "拣货顺序号", type: "ro", width: "80", hidden: true },
            { id: "putawayseqno", name: "上架顺序号", type: "ro", width: "80", hidden: true },
            {
                id: "keeptemperature", name: "存储条件", type: "ro", width: "80", render: function (v, rd) {
                    if (rd["keeptemperature"] == "1") {
                        return "常温";
                    }
                    if (rd["keeptemperature"] == "2") {
                        return "恒温";
                    }
                    if (rd["keeptemperature"] == "3") {
                        return "冷藏";
                    }
                    if (rd["keeptemperature"] == "4") {
                        return "冷冻";
                    }
                    if (rd["keeptemperature"] == "5") {
                        return "阴凉";
                    }
                }
            },
            {
                id: "status", name: "状态", type: "ro", width: "110", render: function (v, rd) {
                    if (rd["status"] == "10") {
                        return Prolog.getCircle("black") + "创建";
                    }
                    if (rd["status"] == "20") {
                        return Prolog.getCircle("green") + "启用";
                    }
                    if (rd["status"] == "30") {
                        return Prolog.getCircle("yellow") + "锁定(可出不可入)";
                    }
                    if (rd["status"] == "40") {
                        return Prolog.getCircle("blue") + "锁定(可入不可出)";
                    }
                    if (rd["status"] == "50") {
                        return Prolog.getCircle("red") + "锁定(不可入不可出)";
                    }
                }
            },
            { id: "loclength", name: "长", type: "ro", align: "right", width: "80", hidden: true },
            { id: "locwidth", name: "宽", type: "ro", align: "right", width: "80", hidden: true },
            { id: "locheight", name: "高", type: "ro", align: "right", width: "80", hidden: true },
            { id: "floorno", name: "楼层号", type: "ro", width: "60", hidden: true },
            {
                id: "locgroup", name: "货位类型", type: "ro", width: "130", hidden: true, render: function (v, rd) {
                    if (rd["locgroup"] == "1") {
                        return "普通货位";
                    }
                    if (rd["locgroup"] == "2") {
                        return "提前拣选";
                    }
                    if (rd["locgroup"] == "3") {
                        return "暂存货位";
                    }
                    if (rd["locgroup"] == "4") {
                        return "第三方货位";
                    }
                }
            },
            { id: "abcgroup", name: "ABC属性", type: "ro", width: "130", hidden: true },
            {
                id: "storegroup", name: "逻辑区域", type: "ro", width: "130", render: function (v, rd) {
                    if (rd["storegroup"] == "Luoj_area1") {
                        return "百货";
                    }
                    if (rd["storegroup"] == "Luoj_area2") {
                        return "其它";
                    }
                }
            },
            { id: "itemgroup", name: "商品主类", type: "ro", width: "130" },
            { id: "storagestatus", name: "存储状态", type: "ro", width: "130" },
            { id: "reserve", name: "预留位置", type: "ro", width: "130" },
            { id: "itemgroup", name: "已占用数量", type: "ro", width: "130" },
            { id: "itemgroup", name: "已占用重量", type: "ro", width: "130" },
            { id: "itemgroup", name: "已占用品种", type: "ro", width: "130" },
            { id: "itemgroup", name: "已占用批次", type: "ro", width: "130" },
            { id: "itemgroup", name: "已占用件数", type: "ro", width: "130" },
            { id: "itemgroup", name: "已占用体积", type: "ro", width: "130" },
            {
                id: "stacktype", name: "码放类型", type: "ro", hidden: true, width: "130", render: function (v, rd) {
                    if (rd["stacktype"] == "1") {
                        return "堆垛";
                    }
                    if (rd["stacktype"] == "2") {
                        return "货架";
                    }
                    if (rd["stacktype"] == "3") {
                        return "托盘";
                    }
                }
            },
            { id: "branchcode", name: "仓编号", type: "ro", width: "130", hidden: true },
            { id: "createby", name: "创建人", type: "ro", width: "130", hidden: true },
            { id: "createdate", name: "创建时间", type: "ro", width: "130" },
            {
                id: "op", name: "操作", type: "button", align: "left", fixed: "right", width: "200", render: function () {
                    return "删除^position_deleteClick,修改^position_updataClick,复制^position_copy,详情^position_detailed";
                }
            }
        ],
        multiselect: true,
        fixedLast: true, //开启固定列，固定最后一行，倒数第二列不能隐藏
        enableSideBar: true, //开启侧边工具栏
        sideBar: [
            { type: "settings", position: "label-left", labelWidth: 80 },
            { type: "input", name: "loccode", label: "货位编号:" },
            { type: "input", name: "tunnelno", label: "巷道:" },
            {
                type: "combo", name: "loctype", readonly: true, label: "库:", options: warehouse
            },
            {
                type: "combo", readonly: true, name: "areano", label: "区域:"
            },
            {
                type: "combo", readonly: true, name: "storegroup", label: "逻辑区域:", options: JSON.parse($("#position_select").attr("consignor")).stroragegroup
            },
            {
                type: "combo", readonly: true, name: "keeptemperature", label: "存储条件:", options: JSON.parse($("#position_select").attr("consignor")).wms_storagecondition
            },
            { type: "button", name: "querypos", value: "查询" },
            { type: "button", name: "Reset", className: "normal", value: "重置" },
            { type: "button", name: "addBtn", offsetLeft: 10, value: "<i class='layui-icon layui-icon-add-1'></i>新增" },
            { type: "button", name: "exportBtn", value: "<i class='layui-icon layui-icon-download-circle'></i>导出" }
        ],
        imagePath: "/prologui/dist/images/PlgGrid",
        url: "/basic/location/list",//数据接口
        type: "post",//数据提交方式，默认为get
        pagebar: {
            buttons: [
                { text: "删除", className: "layui-btn-danger", name: "delete" }
            ]
            // type: 'simple' //full simple
        },
        params: JSON.stringify(positguoj),//查询提交参数，分页参数默认为pageNum,pageSize
        contentType: "application/json",
        page: true, //是否启用分页
        totalCount: "totalCount" //总记录数字段，默认totalCount
    };
    //分页参数 pageSize pageNum
    var grid4 = new PlgGrid(opts).renderTo("guojzhuans4");
    grid4.getSideBarForm().setFormData({ "systemId": "prolog-healthy-wms" });
    grid4.loadData();

    //按钮添加方法
    grid4.attachSideBarEvent("onButtonClick", function (name) {
        if (name == "querypos") {
            var fdata = grid4.getSideBarForm().getFormData();
            grid4.setParams(JSON.stringify(fdata));
            grid4.reload();
        }
        if (name == "addBtn") {
            $("#displayErr").html("新增");
            availableGJ();
            position_from1.clear();
            position_from2.clear();
            position_from3.clear();
            position_from4.clear();
            initAddFrom();
            position_change = 0;
            $("#tastzhusn").css("display", "block");
            $("#guojzhuans4").css("display", "none");
            $("#post_Template").css("display", "none");
            $("#position_div9").css("display", "none");
        }
        if (name == "impandexpBtn") {
            $("#tastzhusn").css("display", "none");
            $("#guojzhuans4").css("display", "none");
            $("#post_Template").css("display", "block");
            $("#position_div9").css("display", "none");
        }
        if (name == "exportBtn") {
            unfilledWorktime_export();
        }
        if (name == "Reset") {
            grid4.getSideBarForm().clear();
        }
    });
    //主界面导出事件
    function unfilledWorktime_export() {
        let pload = PlgDialog.load(2, { shade: [0.6, "#fff"] });
        if (grid4.getRowsNum() <= 0) {
            PlgDialog.close(pload);
            PlgDialog.msg("没有要导出的数据");
            return;
        }
        let url = "/basic/location/export";
        let name = "货位" + Prolog.formatDate(new Date(), "%YY%MM%DD") + ".xls";
        let p = grid4.getSideBarForm().getFormData();
        Prolog.exportFile(url, name, "", "get", p);
        PlgDialog.close(pload);

    }


    //按钮添加方法
    grid4.attachPageBarEvent(function (name) {
        //删除
        if (name == "delete") {
            let data = [];
            let datas = getDeleteAll(grid4);
            datas.forEach(v => {
                data.push({ locid: v });
            });
            data = JSON.stringify(data);
            utilDelete("/basic/location/batch-delete", "post", data, function (data) {
                setTimeout(() => { PlgDialog.msg(data.message == null ? "接口调用失败" : data.message); }, 300);
                grid4.reload();
            }, "application/json");
        }
    });
    //删除
    window.position_deleteClick = function (rid) {
        grid4.selectRowById(rid);
        let data = [];
        let datas = getDeleteAll(grid4);
        datas.forEach(v => {
            data.push({ locid: v });
        });
        data = JSON.stringify(data);
        utilDelete("/basic/location/batch-delete", "post", data, function (data) {
            setTimeout(() => { PlgDialog.msg(data.message == null ? "接口调用失败" : data.message); }, 300);
            grid4.reload();
        }, "application/json");
    };
    //修改
    window.position_updataClick = function (rid) {
        $("#displayErr").html("修改");
        grid4.selectRowById(rid);
        availableGJ();
        position_from2.disableItem("loccode");
        initAddFrom(1);
        position_change = 1;
        $("#tastzhusn").css("display", "block");
        $("#guojzhuans4").css("display", "none");
        $("#post_Template").css("display", "none");
        $("#position_div9").css("display", "none");
    };
    //复制
    window.position_copy = function (rid) {
        $("#displayErr").html("新增");
        grid4.selectRowById(rid);
        availableGJ();
        initAddFrom(2);
        position_change = 0;
        $("#tastzhusn").css("display", "block");
        $("#guojzhuans4").css("display", "none");
        $("#post_Template").css("display", "none");
        $("#position_div9").css("display", "none");
    }; //详情
    window.position_detailed = function (rid, rdata) {
        $("#tastzhusn").css("display", "none");
        $("#guojzhuans4").css("display", "none");
        $("#post_Template").css("display", "none");
        $("#position_div9").css("display", "block");
        var dataSelect = JSON.parse($("#position_select").attr("consignor"));
        new PlgPanel({
            renderer: "position_div422",
            skin: 2,
            header: {
                isShow: true,
                title: "属性"
            },
            defaultBody: {
                layoutCol: 3,
                valueBj: true,
                cols: [
                    [{ value: getSelectValue(warehouse, rdata.loctype), label: "库" },
                    { value: rdata.areanoname == null ? rdata.areano : rdata.areanoname, label: "区域" },
                    { value: rdata.pickseqno, label: "拣货顺序号" },
                    { value: getSelectValue(dataSelect.wms_loctype, rdata.locgroup), label: "货位类型" },
                    { value: getSelectValue(dataSelect.wms_abcattr, rdata.abcgroup), label: "ABC属性" },
                    { value: rdata.putawayseqno, label: "上架顺序号" },
                    { value: getSelectValue(dataSelect.stroragegroup, rdata.storegroup), label: "逻辑区域" },
                    { value: getSelectValue(dataSelect.wms_locationstatus, rdata.status), label: "状态" },
                    { value: getSelectValue(dataSelect.itemtype, rdata.itemgroup), label: "商品主类" },
                    { value: getSelectValue(dataSelect.stacktype, rdata.stacktype), label: "码放类型" },
                    { value: getSelectValue(dataSelect.wms_storagecondition, rdata.keeptemperature), label: "存储条件" },
                    { value: getSelectValue(dataSelect.gjcapacitylimittype, rdata.capacitylimittype), label: "限制方式" },
                    { value: getSelectValue(dataSelect.gjcapacitylimittype, rdata.storagestatus), label: "存储状态" },
                    { value: getSelectValue(dataSelect.gjcapacitylimittype, rdata.reserve), label: "预留位置" }]
                ]
            }
        });
        new PlgPanel({
            renderer: "position_div422",
            skin: 2,
            empyt: false,
            header: {
                isShow: true,
                title: "编码"
            },
            defaultBody: {
                layoutCol: 3,
                valueBj: true,
                cols: [
                    [
                        { value: rdata.loccode, label: "货位编号" },
                        { value: rdata.locRow, label: "排" },
                        { value: rdata.locFloor, label: "层" },
                        { value: rdata.tunnelno, label: "巷道" },
                        { value: rdata.locCol, label: "列" }
                    ]
                ]
            }
        });
        new PlgPanel({
            renderer: "position_div422",
            skin: 2,
            empyt: false,
            header: {
                isShow: true,
                title: "约束条件"
            },
            defaultBody: {
                layoutCol: 3,
                valueBj: true,
                cols: [
                    [
                        { value: rdata.picktype1group, label: "拣选方式" },
                        { value: rdata.itemnum, label: "品种限制" },
                        { value: rdata.containernum, label: "数量限制(个)" },
                        { value: rdata.limitvalue, label: "体积限制(c3)" },
                        { value: rdata.weightlimit, label: "重量限制(kg)" },
                        { value: rdata.lotnum, label: "批次限制" },
                        { value: rdata.floorno, label: "楼层号" },
                        { value: rdata.lotnum, label: "件数限制" }
                    ]
                ]
            }
        });
        new PlgPanel({
            renderer: "position_div422",
            skin: 2,
            empyt: false,
            header: {
                isShow: true,
                title: "尺寸"
            },
            defaultBody: {
                layoutCol: 3,
                valueBj: true,
                cols: [
                    [
                        { value: rdata.loclength, label: "长(cm)" },
                        { value: rdata.locwidth, label: "宽(cm)" },
                        { value: rdata.locheight, label: "高(cm)" }
                    ]
                ]
            }
        });
        new PlgPanel({
            renderer: "position_div422",
            skin: 2,
            empyt: false,
            header: {
                isShow: true,
                title: "容器限制方式"
            },
            defaultBody: {
                layoutCol: 3,
                valueBj: true,
                cols: [
                    [
                        { value: rdata.loclength, label: "已占用数量" },
                        { value: rdata.locwidth, label: "已占用重量" },
                        { value: rdata.locheight, label: "已占用品种" },
                        { value: rdata.locwidth, label: "已占用批次" },
                        { value: rdata.locheight, label: "已占用件数" },
                        { value: rdata.locheight, label: "已占用体积" }
                    ]
                ]
            }
        });
    };
    function setFormData(plgform, data) {
        var fromData = plgform.getFormData();
        for (var key in fromData) {
            fromData[key] = data[key];
        }
        plgform.setFormData(fromData);
    }
    //二级联动
    function linkage(type, data, datas) {
        data.attachComboEvent("loctype", "onChange", function (id) {
            if (id == null || id == "") {
                id = "GJZS1";
            }
            data.getCombo("areano").setComboText("");
            data.loadComboData("areano", { url: "/basic/area/sub-list", type: "post", contentType: "application/json", data: JSON.stringify([{ "refstoreroom": id }]), valueField: "value", textField: "value" });

        });
        if (type == 1) {
            data.getCombo("areano").setComboText("");
            data.loadComboData("areano", { url: "/basic/area/sub-list", type: "post", contentType: "application/json", data: JSON.stringify([{ "refstoreroom": datas.loctype }]), valueField: "value", textField: "value" });
            data.getCombo("areano").setComboText(datas.areano == "" ? datas.areano : datas.areano);
        }
        if (type == 3) {
            data.getCombo("areano").setComboText("");
        }
    }
    //跳转页面
    var carousel = layui.carousel;
    carousel.render({
        elem: "#position_div",
        autoplay: false,
        index: 0,
        arrow: "none",
        indicator: "none",
        anim: "fade",
        width: "100%", //设置容器宽度
        height: "100%"
    });

    function initAddFrom(type) {
        if (type == 1) {
            let data = grid4.getSelectedRowData();
            setFormData(position_from1, data);
            setFormData(position_from2, data);
            setFormData(position_from3, data);
            setFormData(position_from4, data);
            linkage(1, position_from1, data);
            return;
        }
        if (type == 2) {
            let datas = grid4.getSelectedRowData();
            let data = JSON.parse(JSON.stringify(datas));
            data.loccode = "";
            data.locFloor = "";
            data.tunnelno = "";
            data.locCol = "";
            data.locRow = "";
            setFormData(position_from1, data);
            setFormData(position_from2, data);
            setFormData(position_from3, data);
            setFormData(position_from4, data);
            linkage(1, position_from1, data);
            return;
        }

        linkage(0, position_from1);
    }

    position_div1 = {
        renderer: "position_div1",
        items: [
            { type: "settings", position: "label-left", labelWidth: 90 },
            {
                type: "fieldset", name: "goodsDesc", label: "属性", list: [
                    { type: "hidden", name: "locid", label: "id:", width: 107 },
                    {
                        type: "combo", name: "loctype", readonly: true, label: "库:", width: 107, options: warehouse, validate: "NotEmpty", required: true
                    },
                    {
                        type: "combo", name: "areano", readonly: true, label: "区域:", width: 107, validate: "NotEmpty", required: true
                    },
                    { type: "input", name: "pickseqno", label: "拣货顺序号:", width: 107 },
                    { type: "newcolumn", offset: 10 },
                    {
                        type: "combo", name: "locgroup", readonly: true, label: "货位类型:", width: 107, options: JSON.parse($("#position_select").attr("consignor")).wms_loctype, validate: "NotEmpty", required: true
                    },
                    {
                        type: "combo", name: "abcgroup", readonly: true, label: "ABC属性:", width: 107, options: JSON.parse($("#position_select").attr("consignor")).wms_abcattr
                    },
                    { type: "input", name: "putawayseqno", label: "上架顺序号:", width: 107 },
                    { type: "newcolumn", offset: 10 },
                    {
                        type: "combo", name: "storegroup", readonly: true, label: "逻辑区域:", width: 107, options: JSON.parse($("#position_select").attr("consignor")).stroragegroup, validate: "NotEmpty", required: true
                    },
                    {
                        type: "combo", name: "status", readonly: true, label: "状态:", width: 107, options: JSON.parse($("#position_select").attr("consignor")).wms_locationstatus
                    },
                    {
                        type: "combo", name: "storagestatus", readonly: true, label: "存储状态:", width: 107, options: JSON.parse($("#position_select").attr("consignor")).wms_locationstatus
                    },
                    { type: "newcolumn", offset: 10 },
                    {
                        type: "combo", name: "itemgroup", readonly: true, label: "商品主类:", width: 107, options: JSON.parse($("#position_select").attr("consignor")).itemtype
                    },
                    {
                        type: "combo", name: "stacktype", readonly: true, label: "码放类型:", width: 107, options: JSON.parse($("#position_select").attr("consignor")).stacktype
                    },
                    {
                        type: "checkbox", name: "reserve", label: "预留位置:", width: 107
                    },
                    { type: "newcolumn", offset: 10 },
                    {
                        type: "combo", name: "keeptemperature", readonly: true, label: "存储条件:", width: 107, options: JSON.parse($("#position_select").attr("consignor")).wms_storagecondition
                    },
                    {
                        type: "combo", name: "capacitylimittype", readonly: true, label: "容器限制方式:", width: 107, options: JSON.parse($("#position_select").attr("consignor")).gjcapacitylimittype
                    }]
            }]
    };
    position_div2 = {
        renderer: "position_div2",
        items: [
            { type: "settings", position: "label-left", labelWidth: 90 },
            {
                type: "fieldset", name: "goodsDesc", label: "编码", list: [
                    { type: "input", name: "loccode", label: "货位编号:", width: 161, editable: false, validate: "NotEmpty", required: true },
                    { type: "input", name: "locRow", label: "排:", width: 161, validate: "NotEmpty", required: true },
                    { type: "newcolumn", offset: 10 },
                    { type: "input", name: "locFloor", label: "层:", width: 161, validate: "NotEmpty", required: true },
                    { type: "newcolumn", offset: 10 },
                    { type: "input", name: "tunnelno", label: "巷道:", width: 161, validate: "NotEmpty", required: true },
                    { type: "newcolumn", offset: 10 },
                    { type: "input", name: "locCol", label: "列:", width: 161, validate: "NotEmpty", required: true }]
            }]
    };
    position_div3 = {
        renderer: "position_div3",
        items: [
            { type: "settings", position: "label-left", width: 500, labelWidth: 90 },
            {
                type: "fieldset", name: "goodsDesc", label: "约束条件", list: [
                    { type: "input", name: "picktype1group", label: "拣选方式分组1:", width: 161 },
                    { type: "input", name: "itemnum", label: "品种限制:", width: 161, validate: "NotEmpty", required: true },
                    { type: "newcolumn", offset: 10 },
                    { type: "input", name: "containernum", label: "数量限制(个):", width: 161, validate: "ValidNumeric", required: true },
                    { type: "input", name: "limitvalue", label: "体积限制(m3):", width: 161, validate: "ValidNumeric", required: true },
                    { type: "newcolumn", offset: 10 },
                    { type: "input", name: "weightlimit", label: "重量限制(KG):", width: 161, validate: "ValidNumeric", required: true },
                    { type: "input", name: "lotnum", label: "批次限制:", width: 161, validate: "NotEmpty", required: true },
                    { type: "newcolumn", offset: 10 },
                    { type: "input", name: "floorno", label: "楼层号:", width: 161 },
                    { type: "input", name: "lotnum2", label: "件数限制:", width: 161, validate: "NotEmpty", required: true }]
            }]
    };
    position_div4 = {
        renderer: "position_div4",
        items: [
            { type: "settings", position: "label-left", width: 500, labelWidth: 90 },
            {
                type: "fieldset", name: "goodsDesc", label: "尺寸", list: [
                    { type: "input", name: "loclength", label: "长(cm):", width: 161, validate: "ValidNumeric", required: true },
                    { type: "newcolumn", offset: 10 },
                    { type: "input", name: "locwidth", label: "宽(cm):", width: 161, validate: "ValidNumeric", required: true },
                    { type: "newcolumn", offset: 10 },
                    { type: "input", name: "locheight", label: "高(cm):", width: 161, validate: "ValidNumeric", required: true },
                    { type: "newcolumn", offset: 265 }]
            }]
    };
    position_div5 = {
        renderer: "position_div5",
        items: [
            { type: "settings", position: "label-left", width: 500, labelWidth: 90 },
            {
                type: "fieldset", name: "goodsDesc", label: "容器限制方式", list: [
                    { type: "input", name: "loclength", label: "已占用数量:", width: 161, validate: "ValidNumeric", required: true },
                    { type: "input", name: "loclength2", label: "已占用件数:", width: 161, validate: "ValidNumeric", required: true },
                    { type: "newcolumn", offset: 10 },
                    { type: "input", name: "locwidth", label: "已占用重量:", width: 161, validate: "ValidNumeric", required: true },
                    { type: "input", name: "locwidth2", label: "已占用体积:", width: 161, validate: "ValidNumeric", required: true },
                    { type: "newcolumn", offset: 10 },
                    { type: "input", name: "locheight3", label: "已占用品种:", width: 161, validate: "ValidNumeric", required: true },
                    { type: "newcolumn", offset: 10 },
                    { type: "input", name: "locheight", label: "已占用批次:", width: 161, validate: "ValidNumeric", required: true }]
            }]
    };
    position_from1 = new PlgForm(position_div1);
    position_from2 = new PlgForm(position_div2);
    position_from3 = new PlgForm(position_div3);
    position_from4 = new PlgForm(position_div4);
    position_from5 = new PlgForm(position_div5);
    //保存
    document.querySelector("#position_save").onclick = function () {
        var feik1 = position_from1.validate();
        var feik2 = position_from2.validate();
        var feik3 = position_from3.validate();
        var feik4 = position_from4.validate();
        if (!feik1 || !feik2 || !feik3 || !feik4) {
            return;
        }
        var positionData1 = position_from1.getFormData();
        var positionData2 = position_from2.getFormData();
        var positionData3 = position_from3.getFormData();
        var positionData4 = position_from4.getFormData();
        // 合并对象
        var url = "/basic/location/batch-create";
        var type = "post";
        var jsonData = Object.assign(positionData1, positionData2, positionData3, positionData4);
        //修改
        if (position_change == 1) {
            url = "/basic/location/update";
            type = "put";
        }
        else {
            jsonData = [jsonData];
        }
        utilAjaxGJ(url, type, JSON.stringify(jsonData), function (data) {
            setTimeout(() => { PlgDialog.msg(data.message == null ? "接口调用失败" : data.message); }, 300);
            $("#tastzhusn").css("display", "none");
            $("#guojzhuans4").css("display", "block");
            $("#post_Template").css("display", "none");
            $("#position_div9").css("display", "none");
            grid4.reload();
        }, "application/json");
    };
    //可以编辑
    function availableGJ() {
        position_from1.enableAllItem();
        position_from2.enableAllItem();
        position_from3.enableAllItem();
        position_from4.enableItem("loclength");
        position_from4.enableItem("locwidth");
        position_from4.enableItem("locheight");
        position_from4.enableItem("postion_save");
    }
    linkage(3, grid4.getSideBarForm());

    //返回
    $(document).on("click", "#position_back1", function () {
        $("#tastzhusn").css("display", "none");
        $("#guojzhuans4").css("display", "block");
        $("#post_Template").css("display", "none");
        $("#position_div9").css("display", "none");
    });
    utilImportGJ2("post_Template1", "postionImportId", "postionExportId", "url", function () {
        $("#tastzhusn").css("display", "none");
        $("#guojzhuans4").css("display", "block");
        $("#post_Template").css("display", "none");
        $("#position_div9").css("display", "none");
    });
};