BusCutplanHead.js 8.14 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 = {


        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}/${tableName}/Import`
            }
            return options;
        },

        rowClickOptions: function () {
            var options = {
                isDefault: true,
                targetTableId: app.data.tableElem,
                tabfilter: "tableTabBody",
                tabId: 2,
                customFn: app.methods.initTableDesc
            }
            return options;
        },

        

        //手动完成切割方案
        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}/${controllerName}/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}/${controllerName}/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) => {
            app.methods.initTable();
        }
    }

    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: "管材SN" },
                { field: "materialCode", width: 150, title: "物料编码" },
                { field: "pipeLength", width: 150, title: "管材长度" },
                { field: "lossCount", width: 150, title: "总利用率", templet: function (obj) { return obj.lossCount > 0 ? (obj.lossCount * 100).toFixed(2) + "%" : "" } },
                { 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: (d) => { return "".GetState(window.top.EnumCutPlanHeadStatus, d.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: "createTime", width: 150, title: "套料时间" },
                { field: "createBy", 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 (d) { return "".GetState(window.top.EnumCutPlanDetailStatus, d.cutState) } },
                { field: "cutStartTime", width: 150, title: "切割开始时间" },
                { field: "cutEndTime", width: 150, title: "切割完成时间" },
                { field: "cutLevel", width: 150, title: "切割优先级" }

            ]],
            tableIns: null,
            tableIns: null,
            tableInsDesc: null,
            tableElem: "mainList",
            tableElemDesc: "mainListDesc",
        },
        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 = { keys: obj.data.keys }
                let opt = {
                    cols: sysU.columnRecord(app.data.tableElemDesc, app.data.colsDesc),
                    elem: "#" + app.data.tableElemDesc,
                    url: `/${areaName}/${controllerName}/LoadDesc`,
                    height: 'full-55',
                    toolbar: '#toolbarTableDesc',
                    limit: 0,
                    page: false,
                    where: sendData
                }
                app.data.tableInsDesc = sysU.initTable(opt);
            },
            initFrom() {
                
            }
        },
        registerEvent: function () {

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