Location.js 10.2 KB
let action = null;

layui.config({
    base: "/js/",
    version: 111
}).use(['system'], function () {
    var form = layui.form,
        $ = layui.jquery,
        system = layui.system,
        u = new system.u(),
        areaName = 'material',
        tableName = 'Location';

    action = {
        addOptions: function () {
            var options = {
                fromId: "#modifyForm form",
                url: `/${areaName}/${tableName}/Ins`,
                submit: "submit(fromAdd)"
            }
            return options;
        },

        editOptions: function () {
            var options = {
                fromId: "#modifyForm form",
                url: `/${areaName}/${tableName}/Upd`,
                submit: "submit(fromUpdate)"
            }
            return options;
        },

        deleteOptions: function () {
            var options = {
                url: `/${areaName}/${tableName}/DelByIds`,
                keyId: "code"
            }
            return options;
        },

        exportOptions: function () {
            var options = {
                fromId: "listForm",
                url: `/${areaName}/${tableName}/Export`,
                isDefault: false,
                excelCols: {
                    head: app.data.cols
                }
            }
            return options;
        },

        queryOptions: function () {
            var options = {
                resetFrom: "form[lay-filter=listForm]",
                fromId: "listForm",
                urlExport: `/${areaName}/${tableName}/Export`,
                urlQuery: `/${areaName}/${tableName}/Load`,
                mainTable: app.data.tableIns
            }
            return options;
        },

        uploadOptions: function () {
            var options = {
                url: `/${areaName}/${tableName}/Import`,
                fromFile: "#excelfile",
                content: $("#ImportData")
            }
            return options;
        },
        //btnIsStop: function () {
        //    var ajaxConfig = {
        //        type: "get",
        //        url: `/${areaName}/${tableName}/IsStope?id=` + data.id,
        //        success: function (result) {
        //            $("input[name='oneStart']").val(result[0].timeSpanStart.replace(':', '-'));
        //            $("input[name='oneEnd']").val(result[0].timeSpanEnd.replace(':', '-'));
        //            $("input[name='oneSequence']").val(result[0].sequence);
        //            $("#GetactionRangez").val(result[0].GetactionRangez);

        //            //拿下拉框
        //            var stateSelect = $("select[name=state]").html();

        //            for (var i = 1; i < result.length; i++) {

        //                //到时定义一个方法
        //                if (result.length > tab.rows.length) {

        //                    var str = ` <tr>
        //                        <td>
        //                            <div id="divBConent" class="div-flex" style="flex-wrap: wrap">
        //                                <input name="timeSpanStart"  type="text" lay-verify="required" class="layui-input layui-date" time="time" dateFormat="HH-mm" style="width:49%"><label style="width:2%">__</label>
        //                                <input name="timeSpanEnd" type="text" lay-verify="required" class="layui-input  layui-date" time="time" dateFormat="HH-mm" style="width:49%">
        //                            </div> 
        //                        </td>
        //                        <td>
        //                            <select name="state"  lay-filter="eform" lay-search>${stateSelect}</select>
        //                            <input name="sequence"  style="display: none" type="text" value="${tab.rows.length}"/>
        //                        </td>
        //                        <td>
        //                        <label class="close-btn" style="margin-top:10px; right:25px!important;"> </label>
        //                        </td>
        //                    </tr>`;

        //                    $("#tabtiems").append(str);
        //                }
        //                //找到name = 字段的input  赋值   后台传来的第一个是生产时间  从第二个开始
        //                $("input[name='timeSpanStart']")[i - 1].value = result[i].timeSpanStart.replace(':', '-');
        //                $("input[name='timeSpanEnd']")[i - 1].value = result[i].timeSpanEnd.replace(':', '-');
        //                $("input[name='sequence']")[i - 1].value = result[i].sequence;
        //                debugger
        //                $("select[name^='state']")[i - 1].value = result[i].state;
        //                form.render('select');
        //            }
        //        }
        //    };
        //    sysU.ajax(ajaxConfig);
         
           
        //},

        editBefore: function (data, callBack) {
            debugger
            form.val("modifyForm", data);
            var list = {};
            $(".ClearSelector_" + tableName).each(function () {
                var selDom = ($(this));
                if (!$(selDom)[0].name.startsWith("q")) {
                    list[$(selDom)[0].name] = data[$(selDom)[0].name] + "";
                }
            });
            form.val("modifyForm", list);
            if (callBack != null) callBack();
        },

        editAfter: function (callBack) {
           
            if (callBack != null) callBack();
        },

        addSaveBefore: function (data, callBack) {
            if (callBack != null) callBack();
        },
       


        //所有动作成功之后
        actionSuccess: (falg) => {
            if (falg === "add" || falg === "edit" || falg === "delete" || falg === "refresh" || falg === "upload") {
                app.data.tableIns.config.where = {};
                app.data.tableIns.config.page.curr = 1;
                app.data.tableIns.reload("mainList", {});
            }
        }
    }

    var app = {
        data: {
            cols: [[
                { checkbox: true, fixed: true },
                { field: 'id', width: 80,  title: 'Id' }, 
                { field: 'code', width: 150,  title: '库位' }, 
                { field: 'lineCode', width: 150,  title: '线体'}, 
                { field: 'row', width: 70,  title: '行' }, 
                { field: 'line', width: 70,  title: '列' }, 
                { field: 'layer', width: 70,  title: '层' }, 
                { field: 'grid', width: 70,  title: '格' }, 

                { field: 'type', width: 150,  title: '库位类型', templet: function (d) { return GetLabel('Type', 'DictValue', 'DictLabel', d.type) } },
                { field: 'containerId', width: 150,  hide: true, title: '容器id号' }, 
                { field: 'containerCode', width: 150,  title: '容器编码' }, 
                { field: 'zoneCode', width: 150,  title: '区域编码', templet: function (d) { return GetLabel('ZoneCode', 'DictValue', 'DictLabel', d.zoneCode) } }, 
                { field: 'status', width: 130,  title: '状态', templet: function (d) { return GetLabel('Status', 'DictValue', 'DictLabel', d.status) } }, 
             
                 { field: 'maxHeight', width: 100,  title: '高度上限' }, 
                 { field: 'maxWeight', width: 100,  title: '重量上限' }, 
                 { field: 'goodsNo', width: 150,  title: 'GoodsNo' }, 
             
                 { field: 'createTime', width: 150,  title: '创建时间' }, 
                 { field: 'createBy', width: 100,  title: '创建用户' }, 
                 { field: 'updateTime', width: 150,  title: '更新时间' }, 
                { field: 'updateBy', width: 100,  title: '更新用户' }
            ]],
            tableIns: null,
            tableElem: "mainList"
            ,
            selectOption: {
                'Status': {
                    SelType: "FromDict",
                    SelFrom: "locationStatus",
                    SelModel: "Status",
                    SelLabel: "DictLabel",
                    SelValue: "DictValue",
                    Dom: [$("[name='status']")]
                }
              , 'Type': {
                    SelType: "FromDict",
                    SelFrom: "warehouseType",
                    SelModel: "Type",
                    SelLabel: "DictLabel",
                    SelValue: "DictValue",
                    Dom: [$("[name='type']")]
                },

                'ZoneCode': {
                    SelType: "FromDict",
                    SelFrom: "zoneCode",
                    SelModel: "Type",
                    SelLabel: "DictLabel",
                    SelValue: "DictValue",
                    Dom: [$("[name='zoneCode']")]
                },
                'LineCode': {
                    SelType: "FromUrl",
                    SelFrom: "/configure/Line/Load",
                    SelModel: "lineCode",
                    SelLabel: "lineName",
                    SelValue: "lineCode",
                    Dom: [$("[name='lineCode']")]
                }, 'Warehouse': {
                    SelType: "FromUrl",
                    SelFrom: "/HomeRedis/GetBaseInfoByKey?key=warehouse",
                    SelLabel: "name",
                    SelValue: "code",
                    Dom: [$("[name='warehouseCode']")]
                },
                //返回的数据 用于后续操作
                selectData: {

                }
            }
        },
        methods: {
            initTable: function (opts) {
                var config = {};
                if (opts != undefined) $.extend(config, opts);
                let options = {
                    elem: "#" + app.data.tableElem,
                    url: `/${areaName}/${tableName}/Load`,
                    cols: u.columnRecord(app.data.tableElem, app.data.cols),
                    toolbar: '#toolbarTable',
                }
                app.data.tableIns = u.initTable(options);
            },
            initFrom: function () {
                debugger
                u.initSelect(app.data.selectOption);
            }
        },


        registerEvent: function () {

        },
        init: function () {
            app.methods.initTable();
            app.registerEvent();
            app.methods.initFrom();
        }
    };
    app.init();
});