BusCutplanHead.js 13.3 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 = "Material",
        controllerName = "BusCutplanHead",
        app = null;

    action = {
        addOptions: function () {
            var options = {
                fromId: "#modifyForm form",
                url: `/${areaName}/${controllerName}/Ins`,
                //whereExtend: null,
                //isAddWhereExtend: "arbitrarily",
                //mainTable: app.data.tableIns,
                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;
        },

        rowClickOptions: function () {
            var options = {
                isDefault: true,
                targetTableId: app.data.tableElem,
                tabfilter: "tableTabBody",
                tabId: 2,
                customFn: app.methods.initTableDesc
            }
            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);
            }
        },
        //手动完成切割方案
        CompleteExecute: function (sysU, toolbarId, obj) {
            var checkStatus = table.checkStatus(toolbarId);
            if (checkStatus.data.length != 1) {
                layer.alert(sysU.config.titleSelectOne, { icon: sysU.config.iconoError, shadeClose: true, title: sysU.config.titleSelectOneRowData });
                return;
            }
            layer.confirm('确定手动完成方案么?', { icon: 3, title: '提示' }, function (index) {
                var ajaxConfig = {
                    data: { ID: checkStatus.data[0].ID },
                    url: `/${areaName}/${tableName}/CompleteExecute`,
                    success: function (result) {
                        if (sysU.successBefore(result)) return;
                        layer.msg(result.Message, { icon: sysU.config.iconoOk, shade: 0.4, time: 1000 });
                        action.actionSuccess(app.data.tableElem, app.data.tableIns.config.page.curr);
                    }
                };
                sysU.ajax(ajaxConfig);
            });
        },

        //取消方案
        CancelPlan: function (sysU, toolbarId, obj) {
            var checkStatus = table.checkStatus(toolbarId);
            if (checkStatus.data.length != 1) {
                layer.alert(sysU.config.titleSelectOne, { icon: sysU.config.iconoError, shadeClose: true, title: sysU.config.titleSelectOneRowData });
                return;
            }
            layer.confirm('确定取消方案么?', { icon: 3, title: '提示' }, function (index) {
                var ajaxConfig = {
                    data: { ID: checkStatus.data[0].ID },
                    url: `/${areaName}/${tableName}/CancelPlan`,
                    success: function (result) {
                        if (sysU.successBefore(result)) return;
                        layer.msg(result.Message, { icon: sysU.config.iconoOk, shade: 0.4, time: 1000 });
                        action.actionSuccess(app.data.tableElem, app.data.tableIns.config.page.curr);
                    }
                };
                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: "keys", width: 80, hide: true, title: "Keys" },
                { field: "lotNo", width: 150, title: "批次码" },
                { field: "materialCode", width: 150, title: "物料编码" },
                { field: "pipeLength", width: 150, title: "管材长度" },
                { field: "lossCount", width: 150, title: "总损耗率" },
                { field: "oddmentsCode", width: 150, title: "余料编码" },
                { field: "oddmentsLength", width: 150, title: "余料长度" },
                //{ field: "lineCode", width: 150, title: "线体" },
                { field: "planStartTime", width: 150, title: "计划生产日期" },
                { field: "level", width: 150, title: "生产优先级" },
                { field: "state", width: 150, title: "生产状态", templet: function (obj) { return "".GetState(window.top.EnumCutPlanHeadStatus, obj.state) } },
                { field: "actualStartTime", width: 150, title: "生产实际开始时间" },
                { field: "actualEndTime", width: 150, title: "生产实际完成时间" },
                { field: "dischargeStartTime", width: 150, title: "下料开始时间" },
                { field: "dischargeEndTime", width: 150, title: "下料完成时间" },
                { field: "cutStartTime", width: 150, title: "切割开始时间" },
                { field: "cutEndTime", width: 150, title: "切割完成时间" },
                //{ field: "extend1", width: 150, title: "预留字段1" },
                //{ field: "extend2", width: 150, title: "预留字段2" },
                //{ field: "extend3", width: 150, title: "预留字段3" },
                //{ field: "extend4", width: 150, title: "预留字段4" },
                { 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, hide: true, title: "Id" },
                { field: "bodyKeys", width: 150, hide: true, title: "bodyKeys" },
                { field: "headKeys", width: 150, hide: true, title: "headkey" },
                { field: "iwpNo", width: 150, title: "工单号" },
                { field: "barCode", width: 150, title: "追踪码" },
                { field: "isendproduct", width: 150, title: "是否成品管", templet: function (obj) { return obj.isendproduct == 0 ? "否" : "是" } },
                { field: "cuttingLength", width: 150, title: "切割长度" },
                //{ field: "cutFlanConfig", width: 150, title: "切割余量" },
                { field: "cutState", width: 150, title: "生产状态", templet: function (obj) { return "".GetState(window.top.EnumCutPlanDetailStatus, obj.cutState) } },
                { field: "cutStartTime", width: 150, title: "切割开始时间" },
                { field: "cutEndTime", width: 150, title: "切割完成时间" },
                { field: "cutLevel", width: 150, title: "切割优先级" },
                //{ field: "extend1", width: 150, title: "预留字段1" },
                //{ field: "extend2", width: 150, title: "预留字段2" },
                //{ field: "extend3", width: 150, title: "预留字段3" },
                //{ field: "extend4", width: 150, title: "预留字段4" },
                //{ field: "createTime", width: 150, title: "createTime" },
                //{ field: "createBy", width: 150, title: "createBy" },
                //{ field: "updateTime", width: 150, title: "updateTime" },
                //{ field: "updateBy", width: 150, title: "updateBy" },
                //{ field: "workOrderHeadKeys", width: 150, title: "工单头表key" },
                //{ field: "workOrderDetailKeys", width: 150, title: "工单明细key" },

            ]],
            tableIns: null,
            tableIns: null,
            tableInsDesc: null,
            tableElem: "mainList",
            tableElemDesc: "mainListDesc",
            //下拉框配置
            selectOption: {
                //station: {
                //    SelType: "FromUrl",
                //    SelFrom: `/${areaName}/${controllerName}/StationLineSelect`,
                //    SelLabel: "workStationName",
                //    SelValue: "workStationCode",
                //    OptGroup: true,
                //    Dom: [$("[name='stationCode']")]
                //},
                //返回的数据 用于后续操作
                selectData: {

                }
            }
        },
        methods: {
            initTable: function (opt) {
                var config = {};
                if (opt != undefined) $.extend(config, opt);
                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) {

                    }
                }
                app.data.tableIns = sysU.initTable(options);
            },
            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',
                    limit: 0,
                    page: false,
                    where: sendData
                }
                app.data.tableInsDesc = sysU.initTable(opt);
            },
            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 () {
            //var sendDataWhere = form.val("listForm")
            app.methods.initTable();
            app.methods.initFrom();
            app.registerEvent();
        }
    };
    app.init();
});