Workcenter.js 7.21 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 = "configure",
        controllerName = "Workcenter",
        app = null,
        completState = 90;

    action = {
        addOptions: function () {
            $("#workCenterCode").css("background-color", "#FFFFFF");
            $("#workCenterCode").attr("disabled", false);
            var options = {
                fromId: "#modifyForm form",
                url: `/${areaName}/${controllerName}/Ins`,
                submit: "submit(fromAdd)",
                area: ['500px', '300px']
            }
            return options;
        },

        editOptions: function () {
            debugger
            $("#workCenterCode").css("background-color", "#F5F5F5");
            $("#workCenterCode").attr("disabled", "disabled");
            var options = {
                fromId: "#modifyForm form",
                url: `/${areaName}/${controllerName}/Upd`,
                submit: "submit(fromUpdate)",
                area: ['500px', '300px']
            }
            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 () {
            debugger
            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}/${controllerName}/Import`,
                fromFile: "#excelfile",
                content: $("#ImportData")
            }
            return options;
        },

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

        editSaveBefore: function (data, callBack) {
            if (typeof data.field.isDelete == "undefined") data.field["isDelete"] = "0";
            if (callBack != null) callBack();
        },


        //分配工位 
        btnStepStation: function (data, toolbarId) {
            debugger
            let checkStatus = table.checkStatus(toolbarId);
            if (checkStatus.data.length != 1) {
                layer.alert(sysU.config.titleSelectOne, { icon: 2, shadeClose: true, title: sysU.config.titleSelectOne });
                return;
            }
            var workCenterId = checkStatus.data[0].id
            var workCenterCode = checkStatus.data[0].workCenterCode;
            var workKey = checkStatus.data[0].key;
            var url = `/configure/Station/Index?menuFlag=-2&selectColKeyCustom=workStationCode&timestamp=${new Date().getTime()}&page=Workcenter&workCenterCode=${workCenterCode}&workCenterId=${workCenterId}&workKey=${workKey}`;
            var index = layer.open({
                title: "分配工位",
                type: 2,
                area: ['1000px', '600px'],
                content: url
            });
            localStorage.setItem("openIndex", index);
        },

        //分配班组 todo
        btnTeamWorkStep: function (data, toolbarId) {
            debugger
            let checkStatus = table.checkStatus(toolbarId);
            if (checkStatus.data.length != 1) {
                layer.alert(sysU.config.titleSelectOne, { icon: 2, shadeClose: true, title: sysU.config.titleSelectOne });
                return;
            }
            var workCenterId = checkStatus.data[0].id
            var workCenterCode = checkStatus.data[0].workCenterCode;
            var workKey = checkStatus.data[0].key;
            var url = `/configure/BaseTeam/Index?menuFlag=-2&selectColKeyCustom=teamCode&timestamp=${new Date().getTime()}&page=Workcenter&workCenterCode=${workCenterCode}&workCenterId=${workCenterId}&workKey=${workKey}`;
            var index = layer.open({
                title: "分配班组",
                type: 2,
                area: ['1000px', '600px'],
                content: url
            });
            localStorage.setItem("openIndex", index);
        },

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

    app = {
        data: {
            cols: [[
                { checkbox: true, fixed: true },
                { field: "id", width: 80, hide: true, title: "Id" },
                { field: "key", width: 150, hide:true, title: "key" },
                { field: "workCenterCode", width: 150, title: "工作中心编码" },
                { field: "workCenterName", width: 150, title: "工作中心名称" },
                { field: "createTime", width: 150, title: "建立时间" },
                { field: "createBy", width: 150, title: "建立者" },
                { field: "updateTime", width: 150, title: "更新时间" },
                { field: "updateBy", 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 () {
                let options = {
                    elem: "#" + app.data.tableElem,
                    url: `/${areaName}/${controllerName}/Load`,
                    cols: sysU.columnRecord(app.data.tableElem, app.data.cols),
                    toolbar: '#toolbarTable',
                }
                app.data.tableIns = sysU.initTable(options);
            },

            initSelectTable: function () {

            },

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

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