BusWorkorderDetail.js 8.45 KB
let action = null;
layui.config({
    base: "/js/",
    version: 1
}).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 = "Board",
        controllerName = "BusWorkorderDetail",
        app = null;

    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;
        },
        rowClickOptions: function () {
            var options = {
                isDefault: true,
                targetTableId: app.data.tableElem,
                tabfilter: "tableTabBody",
                tabId: 2,
                //customFn: app.methods.initTableDesc
            }
            return options;
        },

        uploadOptions: function () {
            var options = {
                url: `/${areaName}/${controllerName}/Import`,
                fromFile: "#excelfile",
                content: $("#ImportData")
            }
            return options;
        },
        addBefore: function (callBack) {
            //callBack是回调函数,如果editBefore有ajax 放在成功之后
            if (callBack != null) callBack();
        },

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

        checkboxMethod: function (obj) {
            var page = "".GetUrlParam("page"),
                xxx = "".GetUrlParam("xxx");
            if (page == "xxx") {
                var sendData = {
                    
                };
                var ajaxConfig = {
                    data: sendData,
                    url: `${areaName}/${controllerName}/xxx`,
                    success: function (result) {
                        if (sysU.successBefore(result)) return false;
                        layer.msg(result.Message);
                    }
                };
                sysU.ajax(ajaxConfig);
            }
        },
        //所有动作成功之后
        actionSuccess: (falg) => {
           debugger
           sysU.refreshTable(app, u, sendDataDesc, falg);
        },
        closeAfter: function (callBack) {
            if (callBack != null) callBack();
        }
    }

    app = {
        data: {
            cols: [[
                { checkbox: true, fixed: true },
                { field: "id", width: 80, hide: true, title: "Id" },
                /*{ field: "bodyKeys", width: 150, title: "bodyKeys" },*/
                /*{ field: "headKeys", width: 150, title: "headKeys" },*/
                //{ field: "serialNumber", width: 150, title: "序号" },
                //{ field: "serialNumberName", width: 150, title: "serialNumberName" },
                //{ field: "lineCode", width: 150, title: "产线Code" },
                { field: "stationCode", width: 150, title: "工位code" },
                { field: "oprSequenceCode", width: 150, title: "工序code" },
                { field: "oprSequenceName", width: 150, title: "工序名称" },
                { field: "equipmentCode", width: 150, title: "设备编码" },
                { field: "state", width: 150, title: "任务状态" },
                //{ field: "isRework", width: 150, title: "true返工 false未返工" },
                //{ field: "planStartTime", width: 150, title: "计划开始时间" },
                //{ field: "planEndTime", width: 150, title: "计划结束时间" },
                //{ field: "actualStartTime", width: 150, title: "实际开始时间" },
                //{ field: "actualEndTime", width: 150, title: "实际结束时间" },
                //{ field: "createTime", width: 150, title: "建立时间" },
                //{ field: "createBy", width: 150, title: "建立者" },
                //{ field: "updateTime", width: 150, title: "更新时间" },
                //{ field: "updateBy", width: 150, title: "更新者" },
                //{ field: "productHeaderCode", width: 150, title: "产品表code" },
                //{ field: "isDelete", width: 150, title: "isDelete" },
                //{ field: "materialCode", width: 150, title: "物料编码" },
                //{ field: "materialName", width: 150, title: "物料名称" },
                //{ field: "qty", width: 150, title: "需求数据" },
                //{ field: "whCode", width: 150, title: "需求单位" },
                //{ field: "workOrderCode", width: 150, title: "工单code/生产订单号" },
                { field: "workReportStatus", width: 150, title: "报工状态" },
                /*{ field: "procedCode", width: 150, title: "procedCode" },*/
                { field: "workCenterCode", width: 150, title: "工作中心编码" },
                { field: "teamCode", width: 150, title: "班组编码" },
            ]],
            tableIns: null,
            tableElem: "mainList",
            //下拉框配置
            selectOption: {
                //station: {
                //    SelType: "FromUrl",
                //    SelFrom: `/${areaName}/${controllerName}/StationLineSelect`,
                //    SelLabel: "workStationName",
                //    SelValue: "workStationCode",
                //    OptGroup: true,
                //    Dom: [$("[name='stationCode']")]
                //},
                //返回的数据 用于后续操作
                selectData: {

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

                    }
                }
                if (options != undefined) $.extend(config, options);
                app.data.tableIns = sysU.initTable(options);
            },

            initSelectTable: function () {
              var opt1 = {
                    elem: ".productCode",
                    checkedKey: "productCode",
                    doneKey: {
                        key: "productCode",
                        lableValue: "productName"
                    },
                    searchKey: "productCode",
                    searchName: "产品编码"
                };
               sysU.initSelectProduct(opt1);
            },

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

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