Inspection.js 4.56 KB
let action = null;

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

    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: "companyId"
            }
            return options;
        },

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

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

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

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

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

        uploadBefore: function (formData, callBack) {

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

    var app = {
        data: {
            cols: [[
                { field: "id", width: 60, title: "序号", hide: true },
                { field: "keys", width: 150, title: "keys", hide: true },
                { field: "zizeng", width: 80, title: "序号", fixed: "left", type: "numbers" },

                { field: "workOrderBodyKeys", width: 100, title: "workOrderBodyKeys", hide: true},
                { field: "workOrderCode", width: 150, title: "工单号" },
                { field: "lineCode", width: 150, title: "线体编码" },

                { field: "stationCode", width: 100, title: "工位编码" },
                { field: "equipmentCode", width: 130, title: "设备编码" },
                { field: "oprSequenceCode", width: 130, title: "工序" },

                { field: "oprSequenceName", width: 130, title: "工序名称" },
                { field: "actualStartTime", width: 100, title: "开始时间" },
                { field: "actualEndTime", width: 150, title: "结束时间" },

                { field: "progressType", width: 150, title: "开工\完工", templet: "#progressType" },
                { field: "sendStatus", width: 150, title: "报检标识", templet: "#sendStatus"  },

                { field: "createBy", width: 150, title: "报检人员" }
            ]],
            tableIns: null,
            tableElem: "mainList"
        },
        methods: {
            initTable: function (opt) {
                var config = {};
                if (opt != undefined) $.extend(config, opt);
                let options = {
                    elem: "#" + app.data.tableElem,
                    url: `/${areaName}/${tableName}/LoadInspection`,
                    cols: app.data.cols,
                    limit: 0,
                    page: false,
                    where: config
                }
                app.data.tableIns = u.initTable(options);
            }
        },
        registerEvent: function () {

        },
        init: function () {
            sendData = {
                workOrderCode: "".GetUrlParam("workOrderCode")
            }
            app.methods.initTable(sendData);
            app.registerEvent();
        }
    };
    app.init();
});