ReworkCheck.js 9.17 KB
let action = null;

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

    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: "keys",
                titleConfirmDelete: "尽量不要删除,可以选择禁用(对应明细数据也将被删除)?"
            }
            return options;
        },

        deleteOptionsDesc: function () {
            var options = {
                url: `/${areaName}/${tableName}/DelByIdsDesc`,
                keyId: "bodyKeys",
                titleConfirmDelete: "尽量不要删除,可以选择禁用?"
            }
            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;
        },

        addBefore: function (callBack) {
            app.methods.initSelectProduct();
            if (callBack != null) callBack();
        },
        addBeforeDesc: function (callBack) {
            $("input[name=headkeys]").val(sendData.headKeys);
            //callBack是回调函数,如果editBefore有ajax 放在成功之后
            if (callBack != null) callBack();
        },

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

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

        editBefore: function (data, callBack) {

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

        editBeforeDesc: function (data, callBack) {
            $("input[name=headkeys]").val(sendData.headKeys);
            form.val("modifyFormDesc", data);
            if (callBack != null) callBack();
        },

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

        editSaveBeforeDesc: function (data, callBack) {
            if (callBack != null) callBack();
        },
        
        //所有动作成功之后
        actionSuccess: (flag, curr = 1) => {
            debugger;
            if (flag == "delete" || flag == "deleteDesc") {
                app.data.tableIns.config.page.curr = curr;
                app.data.tableIns.reload(app.data.tableElem, {});
                if (app.data.tableInsDesc != null) app.data.tableInsDesc.reload(app.data.tableElemDesc, {});
            } else if (flag.indexOf("Desc") > -1) {
                app.data.tableInsDesc.config.where = sendData;
                app.data.tableInsDesc.config.page.curr = curr;
                app.data.tableInsDesc.reload(app.data.tableElemDesc, {});
            } else {
                app.data.tableIns.config.page.curr = curr;
                app.data.tableIns.reload(app.data.tableElem, {});
            }
        }
    }

    var app = {
        data: {
            cols: [[
                { field: 'id', width: 150,  hide: true, title: 'id' },
                { field: 'headKeys', width: 150, hide: true, title: 'headKeys' },
                { field: 'bodyKeys', width: 150, hide: true, title: 'bodyKeys' },

                { field: 'otherOrderCode', width: 150, title: '工单工作包号' },
                { field: 'headCode', width: 150, title: 'headCode' },
                { field: 'rFINo', width: 150, title: '报检单号' },

                { field: 'oprSequenceCode', width: 150, title: '工序编码' },
                { field: 'stationCode', width: 150, title: '工位编码' },
                { field: 'equipmentCode', width: 150, title: '设备编码' },

                { field: 'state', width: 120, title: '状态' },
                { field: 'checkResult', width: 120, title: '质检结果' },
                { field: 'remark', width: 120, title: '备注' },
                
                { field: 'createTime', width: 150, title: '建立时间' },
                { field: 'createBy', width: 100, title: '建立者' },
                { field: 'updateTime', width: 150, title: '更新时间' },
                { field: 'updateBy', width: 100, title: '更新者' }
            ]],
            colsDesc: [[
                { field: 'id', width: 150, hide: true, title: 'id' },
                { field: 'bodyKeys', width: 150, hide: true, title: 'bodyKeys' },

                { field: 'footerCode', width: 150, title: 'footerCode' },
                { field: 'oprSequenceCode', width: 220, title: '工序编码' },
                { field: 'stationCode', width: 220, title: '工位编码' },
                { field: 'equipmentCode', width: 150, title: '设备编码' },

                { field: 'state', width: 120, title: '状态' },
                { field: 'checkResult', width: 120, title: '质检结果' },
                { field: 'remark', width: 120, title: '备注' },

                { field: 'c1', width: 100, title: 'c1' },
                { field: 'c2', width: 100, title: 'c2' },
                { field: 'c3', width: 100, title: 'c3' },
                { field: 'c4', width: 100, title: 'c4' },
                { field: 'c5', width: 100, title: 'c5' },
                { field: 'c6', width: 100, title: 'c6' },
                { field: 'c7', width: 100, title: 'c7' },
                { field: 'c8', width: 100, title: 'c8' }
            ]],
            urlTable: `/${areaName}/${tableName}/Load`,
            tableIns: null,
            tableInsDesc: null,
            tableElem: "mainList",
            tableElemDesc: "mainListDesc"
        },
        methods: {
            initTable: function () {
                let options = {
                    elem: "#" + app.data.tableElem,
                    url: `/${areaName}/${tableName}/Load`,
                    cols: u.columnRecord(app.data.tableElem, app.data.cols),
                    toolbar: '#toolbarTable',
                    height: "full-56"
                }
                app.data.tableIns = u.initTable(options);
            },

            initTableDesc: function (obj) {
                sendData = { bodyKeys: obj.data.bodyKeys }
                let opt = {
                    cols: u.columnRecord(app.data.tableElemDesc, app.data.colsDesc),
                    elem: "#" + app.data.tableElemDesc,
                    url: `/${areaName}/${tableName}/LoadDesc`,
                    toolbar: '#toolbarTableDesc',
                    height: "full-56",
                    where: sendData
                }
                app.data.tableInsDesc = u.initTable(opt);
            },

            initFrom: function () {

            }
        },


        registerEvent: function () {

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

});