WorkOrderMaterialUseLog.js 7.37 KB
let action = null;
layui.config({
    base: "/js/",
    version: 134
}).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 = "wo",
        controllerName = "WorkOrderMaterialUseLog",
        app = null,
        completState = 90;

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

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

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

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

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

        uploadOptions: function () {
            var options = {
                url: `/${areaName}/${controllerName}/Import`,
                fromFile: "#excelfile",
                content: $("#ImportData")
            }
            return options;
        },

        editBefore: function (data, callBack) {
            form.val("modifyForm", data);
            if (callBack != null) callBack();
        },

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

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

        //所有动作成功之后
        actionSuccess: (falg) => {
            app.data.tableIns.config.where = {};
            app.data.tableIns.config.page.curr = 1;
            app.data.tableIns.reload(app.data.tableElem, {});
        }
    }

    app = {
        data: {
            cols: [[
                { checkbox: true, fixed: true },
                { field: "id", width: 80, hide: true, title: "Id" },
                { field: "keys", width: 80, hide: true, title: "Keys" },
                { field: "productHeaderCode", width: 150, title: "产品编码" },
                { field: "lineCode", width: 150, title: "产线编码", hide: true },
                { field: "review_code", width: 150, title: "追溯码" },
                
                { field: "crux", width: 100, title: "精追件标识", templet: '#cruxLabel' },

                { field: "stationCode", width: 150, title: "工位编码" },
                { field: "oprSequenceCode", width: 150, title: "工序编码" },
                { field: "oprSequenceName", width: 150, title: "工序名称" },
                { field: "equipmentCode", width: 150, title: "设备编码" },
                { field: "materialCode", width: 150, title: "物料编码" },
                { field: "materialName", width: 150, title: "物料名称" },
                { field: "workOrderCode", width: 150, title: "工单编码" },
                { field: "qyt", width: 150, title: "数量" },
                {
                    field: "employ", width: 150, title: "是否使用", templet: function (d) {
                        if (d.employ == 0) {
                            return '<label>否</label >';
                        } else {
                            return '<label>是</label >';
                        }
                    }
},
                { field: "createTime", width: 150, title: "建立时间" },
                { field: "createBy", width: 150, title: "建立者" },
                { field: "remarks", width: 150, title: "备注" },
            ]],
            tableIns: null,
            tableElem: "mainList",
            //下拉框配置
            selectOption: {
                stationCode: {
                    SelType: "FromUrl",
                    SelFrom: "/configure/Station/Load",
                    SelLabel: "workStationName",
                    SelValue: "workStationCode",
                    Dom: [$("[name='stationCode']")]
                },
                productHeaderCode: {
                    SelType: "FromUrl",
                    SelFrom: "/configure/ProductHeader/Load",
                    SelLabel: "productName",
                    SelValue: "productCode",
                    Dom: [$("[name='productHeaderCode']")]
                },
                lineCode: {
                    SelType: "FromUrl",
                    SelFrom: "/configure/Line/Load",
                    SelLabel: "lineName",
                    SelValue: "lineCode",
                    Dom: [$("[name='lineCode']")]
                },
                //station: {
                //    SelType: "FromUrl",
                //    SelFrom: `/${areaName}/${controllerName}/StationLineSelect`,
                //    SelLabel: "workStationName",
                //    SelValue: "workStationCode",
                //    OptGroup: true,
                //    Dom: [$("[name='stationCode']")]
                //},
                //返回的数据 用于后续操作
                selectData: {

                }
            }
        },
        methods: {
            initTable: function () {
                let options = {
                    elem: "#" + app.data.tableElem,
                    url: `/${areaName}/${controllerName}/Load`,
                    cols: sysU.columnRecord(app.data.tableElem, app.data.cols),
                    toolbar: '#toolbarTable',
                }
                app.data.tableIns = sysU.initTable(options);
            },

            initSelectTable: function () {

            },

            initFrom() {
                sysU.initSelect(app.data.selectOption);
            },

            initSelectMaterial() {
                var opt1 = {
                    elem: ".materialCode",
                    checkedKey: "materialCode",
                    doneKey: {
                        key: "materialCode",
                        lableValue: "materialName"
                    },
                    searchKey: "materialCode",
                    searchName: "物料编码"
                };
                sysU.initSelectMaterial(opt1);
            }
        },
        registerEvent: function () {

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