Generator.js 2.89 KB
let action = null;
layui.config({
    base: "/js/",
    version: 1
}).use(['system', 'table'], function () {
    var form = layui.form,
        $ = layui.jquery,
        element = layui.element,
        table = layui.table,
        system = layui.system,
        sysU = new system.u(),
        sendData = null,
        areaName = "Planned",
        controllerName = "Generator",
        app = null,
        completState = 90;
    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;
        },

        openCodeView: function (obj) {
            var entityName = obj.data.TableCode;
            layer.open({
                type: 2,
                title: `【${entityName}】生成代码`,
                shadeClose: true,
                maxmin: true, //开启最大化最小化按钮
                area: ['890px', '550px'],
                content: `CodePreview?entityName=${entityName}`,
                resizing: function (layero) {
                    console.log(layero);
                }
            });
        },
        //所有动作成功之后
        actionSuccess: (falg) => {
            sysU.refreshTable(app, sysU, null, falg);
        }
    }
    app = {
        data: {
            cols: [[
                { type: 'numbers', title: '序号' },
                { field: "TableCode", width: '42%', title: "表名称" },
                { field: "TableName", width: '43%', title: "说明(备注)" },
                { fixed: 'right', title: '操作', width: 125, minWidth: 125, toolbar: '#option', event: "openCodeView" }
            ]],
            tableIns: null,
            tableElem: "mainList",
            //下拉框配置
            selectOption: {

                //返回的数据 用于后续操作
                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();
});