FeedingOrder.js 9.98 KB

let action = null;
layui.config({
    base: "/js/",
    version: 129
}).use(["system"], function () {
    var form = layui.form,
        $ = layui.jquery,
        element = layui.element,
        table = layui.table,
        system = layui.system,
        sysU = new system.u(),
        sendData = null,
        areaName = "material",
        tableName = "FeedingOrder",
        app = null;

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

        addOptionsDesc: function () {
            var options = {
                fromId: "#modifyFormDesc form",
                url: `/${areaName}/${tableName}/InsDesc`,
                content: $("#modifyFormDesc"),
                submit: "submit(fromAddDesc)"
            }

            return options;
        },

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

        editOptionsDesc: function () {
            var options = {
                fromId: "#modifyFormDesc form",
                url: `/${areaName}/${tableName}/UpdDesc`,
                content: $("#modifyFormDesc"),
                submit: "submit(fromUpdateDesc)"
            }
            return options;
        },

        deleteOptions: function () {
            var options = {
                url: `/${areaName}/${tableName}/DelByIds`,
                keyId: "id",
                titleConfirmDelete: "确定要删除所选信息吗(对应的明细数据也会删除)?"
            }
            return options;
        },

        deleteOptionsDesc: function () {
            var options = {
                url: `/${areaName}/${tableName}/DelByIdsDesc`,
                keyId: "id"
            }
            return options;
        },

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

            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`
            }
            return options;
        },

        rowClickOptions: function () {
            var options = {
                isDefault: true,
                targetTableId: app.data.tableElem,
                tabfilter: "tableTabBody",
                tabId: 2,
                customFn: app.methods.initTableDesc
            }
            return options;
        },

        editBefore: function (data, callBack) {
            form.val("modifyForm", data);
            //callBack是回调函数,如果editBefore有ajax 放在成功之后
            if (callBack != null) callBack();
        },

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

        editBeforeDesc: function (data, callBack) {
            form.val("modifyFormDesc", data);
            //callBack是回调函数,如果editBefore有ajax 放在成功之后
            if (callBack != null) callBack();
        },
        editSaveBeforeDesc: function (data, callBack) {
            if (callBack != null) callBack();
        },

        addBefore: function (callBack) {
            //callBack是回调函数,如果editBefore有ajax 放在成功之后
            if (callBack != null) callBack();
        },

        addBeforeDesc: function (callBack) {
            //callBack是回调函数,如果editBefore有ajax 放在成功之后
            if (callBack != null) callBack();
        },

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

        //所有动作成功之后
        actionSuccess: (flag) => {
            debugger;
            var config = { Falg: app.data.Flag.val() };
            if (flag == "delete" || flag == "deleteDesc") {
                app.data.tableInsDesc.config.where = sendData;
                app.data.tableInsDesc.config.page.curr = 1;
                app.data.tableInsDesc.reload("mainListDesc", {});

                app.data.tableIns.config.where = config;
                app.data.tableIns.config.page.curr = 1;
                app.data.tableIns.reload("mainList", {});
            } else if (flag.indexOf("Desc") > -1) {
                app.data.tableInsDesc.config.where = sendData;
                app.data.tableInsDesc.config.page.curr = 1;
                app.data.tableInsDesc.reload("mainListDesc", {});
            } else {
                app.data.tableIns.config.where = config;
                app.data.tableIns.config.page.curr = 1;
                app.data.tableIns.reload("mainList", {});
            }
        }
    }

    app = {
        data: {
            cols: [[
                { field: "id", width: 80,  title: " id",hide: true },
                { field: "keys", width: 80,  hide: true, title: " keys" },
                { field: "IWPNo", width: 190,  title: "工单编码" },
                { field: "BillMaterialCode", width: 150,  title: "料单编码" },
                { field: "BillMaterialType", width: 180,  title: "料单类型", hide: true  },

                { field: "BillMaterialPlanTime", width: 150,  title: "预计到料时间" },
                { field: "BillMaterialZone", width: 150,  title: "放料区域" },
                { field: "locationCode", width: 150,  title: "库位编码" },
                {
                    field: "checkState", width: 180,  title: "发送质检状态", templet: (d) => {
                        return app.methods.getState(window.top.EnumFeedChekeState, d.checkState);
                 }},
                { field: "createTime", width: 150,  title: "创建时间" },
                { field: "createBy", width: 150,  title: "创建用户" },
                { field: "updateTime", width: 150,  title: "更新时间" },
                { field: "updateBy", width: 150,  title: "更新用户" }
            ]],
            colsDesc: [[
                { field: "id", width: 80,  title: "id" },
                { field: "headKeys", width: 150,  hide: true, title: "送料表头表标识" },
                { field: "MaterialCode", width: 150,  title: "物料编码" },
                { field: "BatchNo", width: 150,  title: "批次号" },
                { field: "PipeSN", width: 150,  title: "管材SN" },

                { field: "PipeLen", width: 80,  title: "长度" },
                { field: "Qty", width: 80,  title: "数量" },
                { field: "checkQty", width: 100,  title: "待检数" },
                { field: "inventoryQty", width: 100,  title: "入库数" },
                { field: "Unit", width: 80,  title: "单位" },

                { field: "CerNo", width: 150,  title: "证书号" },
                { field: "CerName", width: 150,  title: "证书名称" },
                { field: "CerUrl", width: 150,  title: "证书图片URL地址" },
                { field: "Remark", width: 150,  title: "备注" }
            ]],
            urlTable: `/${areaName}/${tableName}/Load`,
            tableIns: null,
            tableInsDesc: null,
            tableElem: "mainList",
            tableElemDesc: "mainListDesc",

            Flag: $("#Flag"),
            selectOption: {
                //返回的数据 用于后续操作
                selectData: {

                }
            }
        },
        methods: {
            initTable: function (options) {
                var config = { Falg: app.data.Flag.val() };
                if (options != undefined) $.extend(config, options);
                let opt = {
                    cols: sysU.columnRecord(app.data.tableElem, app.data.cols),
                    elem: "#" + app.data.tableElem,
                    url: `/${areaName}/${tableName}/Load`,
                    toolbar: "#toolbarTable",
                    height: "full-55",
                    where: config
                }
                app.data.tableIns = sysU.initTable(opt);
            },
            initTableDesc: function (obj) {
                sendData = { headKeys: obj.data.keys };
                let opt = {
                    cols: sysU.columnRecord(app.data.tableElemDesc, app.data.colsDesc),
                    elem: "#" + app.data.tableElemDesc,
                    url: `/${areaName}/${tableName}/LoadDesc`,
                    height: "full-55",
                    toolbar: "#toolbarTableDesc",
                    where: sendData
                }
                app.data.tableInsDesc = sysU.initTable(opt);
                //用于明细表与主表之间的关联查看
                //form.val("TitleTipsFrom", obj.data);
                //form.render();

            },
            getState: (data, value) => {
                for (var item in data) {
                    if (!Object.prototype.hasOwnProperty.call(data, item)) continue;
                    if (data[item] == value) {
                        return item;
                    }
                }
            },
            initFrom: function () {
                sysU.initSelect(app.data.selectOption);
            }
        },
        registerEvent: function () {

        },

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