WorkOrderProgress.js 10.7 KB
let action = null,
    app = null;
layui.config({
    base: "/js/",
    version: 22
}).use(['system', 'JsBarcode', 'jqprint', "vue"], function () {
    var form = layui.form,
        $ = layui.jquery,
        element = layui.element,
        table = layui.table,
        system = layui.system,
        sysU = new system.u(),
        sendData = null,
        areaName = "wo",
        tableName = "WorkOrderProgress",
        vueApp = null,
        app = null,
        station = null;
    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: "id",
                titleConfirmDelete: "确定要删除所选信息吗(对应的明细数据也会删除)?"
            }
            return options;
        },

        deleteOptionsDesc: function () {
            var options = {
                url: `/${areaName}/${tableName}/DelByIdsDesc`,
                keyId: "id"
            }
            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;
        },

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

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

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

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

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

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

        //所有动作成功之后
        actionSuccess: (falg, curr = 1) => {
            debugger;
            sysU.refreshTable(app, sysU, sendData, falg);
        }
    }

    app = {
        data: {
            cols: [[
                { checkbox: true, hide: true, fixed: true },
                { field: "id", width: 80, hide: true, title: " id" },
                { field: "keys", width: 150, hide: true, title: "keys" },
                { field: "productHeaderCode", width: 150, title: "产品编号" },
                { field: "productName", width: 150, title: "产品名称" },
                { field: "workOrderCode", width: 150, title: "工单编码" },
                { field: "lineCode", width: 150, title: "产线编号" },
                { field: "lineName", width: 150, title: "产线名称" },
                { field: 'planCode', width: 150, title: '生产计划号' },
                { field: 'workOrderProgress', width: 100, title: '工序进度', templet: '#workOrderProgress' },
                { field: 'sendWorkOrderProgress', width: 100, title: '报工进度', templet: '#sendWorkOrderProgress' },
                { field: "actualStartTime", width: 150, title: "实际开始时间" },
                { field: "actualEndTime", width: 150, title: "实际结束时间" },
                { field: 'equipments', width: 100, title: '设备' },
                { field: 'users', width: 100, title: '人员' },
                { field: "createTime", width: 150, title: "创建时间" },
            ]],
            urlTable: `/${areaName}/${tableName}/Load`,
            tableIns: null,
            tableInsDesc: null,
            tableElem: "mainList",
            selectOption: {
                //stationCode: {
                //    SelType: "FromUrl",
                //    SelFrom: "/configure/Station/Load",
                //    SelLabel: "workStationName",
                //    SelValue: "workStationCode",
                //    Dom: [$("[name='stationCode']")]
                //},
                //返回的数据 用于后续操作
                selectData: {

                }
            }
        },
        methods: {
            initTable: function (options) {
                var config = {};
                if (options != undefined) $.extend(config, options);
                let opt = {
                    cols: sysU.columnRecord(app.data.tableElem, app.data.cols),
                    elem: "#" + app.data.tableElem,
                    url: `/${areaName}/${tableName}/Load`,
                    toolbar: '#toolbarTable',
                    height: 'full-55',
                    where: config
                }
                app.data.tableIns = sysU.initTable(opt);
            },
            initTableDesc: function (obj) {
                sysU.ajax({
                    data: { keys: obj.data.keys },
                    url: `/${areaName}/${tableName}/LoadDesc`,
                    success: function (data) {
                        vueApp.noProductiontime = [];
                        if (sysU.successBefore(data)) return;
                        vueApp.oprTimeLineList = data.Result;
                        vueApp.CurrentState = data.Result.every((value, index, arr) => {
                            if (value.state >= 100) {
                                return true;
                            }
                            else {
                                return false;
                            }
                        })
                    }
                });
            },
            initFrom: function () {
                sysU.initSelect(app.data.selectOption);
            },

            initVue: function () {
                vueApp = new Vue({
                    el: '#WorkOrderProgressInfo',
                    data: {
                        oprTimeLineList: [],
                        CurrentState: false
                    },
                    methods: {
                        GetStateValue(state) {
                            var str = "";
                            switch (state) {
                                case 0:
                                    str = "初始化";
                                    break;
                                case 30:
                                    str = "生产中";
                                    break;
                                case 60:
                                    str = "运输中";
                                    break;
                                case 100:
                                    str = "已完成";
                                    break;
                                case 200:
                                    str = "已变更无需处理"
                                    break;
                                default:
                                    str = "未知";
                                    break;
                            }
                            return str;
                        },
                        GetWorkReportStateValue(value) {
                            var str = "";
                            switch (value) {
                                case 0:
                                    str = "未报工";
                                    break;
                                case 10:
                                    str = "开工已报工";
                                    break;
                                case 20:
                                    str = "完工已报工";
                                    break;
                                case 30:
                                    str = "无需报工";
                                    break;
                                default:
                                    str = "未知";
                                    break;
                            }
                            return str;
                        }
                    }
                });
            },
        },
        registerEvent: function () {

        },

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