懒羊羊
2023-08-30 71e81ed1d12e4d69f53c8ad9e066650ad4186293
提交 | 用户 | 时间
71e81e 1 layui.use(['table', 'admin', 'ax', 'func'], function () {
2     var $ = layui.$;
3     var table = layui.table;
4     var $ax = layui.ax;
5     var admin = layui.admin;
6     var func = layui.func;
7
8     /**
9      * 报废内容配置管理
10      */
11     var ScrapCategoryConf = {
12         tableId: "scrapCategoryConfTable"
13     };
14
15     /**
16      * 初始化表格的列
17      */
18     ScrapCategoryConf.initColumn = function () {
19         return [[
20             {type: 'checkbox'},
21             {field: 'id', hide: true, title: '主键id'},
22             {field: 'lineCode', sort: true, title: '产线编号'},
23             // {field: 'lineName', sort: true, title: '产线名称'},
24             {field: 'locationCode', sort: true, title: '工位编号'},
25             // {field: 'locationName', sort: true, title: '工位名称'},
26             {field: 'scrapCategory', sort: true, title: '报废类目'},
27             {field: 'scrapReason', sort: true, title: '报废原因'},
28             {field: 'state', sort: true, title: '状态'},
29             {field: 'remarks', sort: true, title: '备注'},
30             {field: 'createUser', sort: true, title: '创建用户'},
31             {field: 'updateUser', sort: true, title: '更改用户'},
32             {field: 'updateTime', sort: true, title: '更改时间',minWidth:160},
33             {field: 'createTime', sort: true, title: '创建时间',minWidth:160},
34             {align: 'center', toolbar: '#tableBar', title: '操作', width: 125}
35         ]];
36     };
37
38     /**
39      * 点击查询按钮
40      */
41     ScrapCategoryConf.search = function () {
42         var queryData = {};
43
44         queryData['lineCode'] = $('#lineCode').val();
45         queryData['lineName'] = $('#lineName').val();
46         queryData['locationCode'] = $('#locationCode').val();
47
48         table.reload(ScrapCategoryConf.tableId, {
49             where: queryData, page: {curr: 1}
50         });
51     };
52
53     /**
54      * 弹出添加对话框
55      */
56     ScrapCategoryConf.openAddDlg = function () {
57         window.location.href = Feng.ctxPath + '/scrapCategoryConf/add'
58     };
59
60      /**
61       * 点击编辑
62       *
63       * @param data 点击按钮时候的行数据
64       */
65       ScrapCategoryConf.openEditDlg = function (data) {
66           window.location.href = Feng.ctxPath + '/scrapCategoryConf/edit?id=' + data.id
67       };
68
69
70     /**
71      * 导出excel按钮
72      */
73     ScrapCategoryConf.exportExcel = function () {
74         var checkRows = table.checkStatus(ScrapCategoryConf.tableId);
75         if (checkRows.data.length === 0) {
76             Feng.error("请选择要导出的数据");
77         } else {
78             table.exportFile(tableResult.config.id, checkRows.data, 'xls');
79         }
80     };
81
82     /**
83      * 点击删除
84      *
85      * @param data 点击按钮时候的行数据
86      */
87     ScrapCategoryConf.onDeleteItem = function (data) {
88         var operation = function () {
89             var ajax = new $ax(Feng.ctxPath + "/scrapCategoryConf/delete", function (data) {
90                 Feng.success("删除成功!");
91                 table.reload(ScrapCategoryConf.tableId);
92             }, function (data) {
93                 Feng.error("删除失败!" + data.responseJSON.message + "!");
94             });
95             ajax.set("id", data.id);
96             ajax.start();
97         };
98         Feng.confirm("是否删除?", operation);
99     };
100
101     // 渲染表格
102     var tableResult = table.render({
103         elem: '#' + ScrapCategoryConf.tableId,
104         url: Feng.ctxPath + '/scrapCategoryConf/list',
105         page: true,
106         height: "full-158",
107         cellMinWidth: 100,
108         cols: ScrapCategoryConf.initColumn()
109     });
110
111     // 搜索按钮点击事件
112     $('#btnSearch').click(function () {
113         ScrapCategoryConf.search();
114     });
115
116     // 添加按钮点击事件
117     $('#btnAdd').click(function () {
118
119     ScrapCategoryConf.openAddDlg();
120
121     });
122
123     // 导出excel
124     $('#btnExp').click(function () {
125         ScrapCategoryConf.exportExcel();
126     });
127
128     // 工具条点击事件
129     table.on('tool(' + ScrapCategoryConf.tableId + ')', function (obj) {
130         var data = obj.data;
131         var layEvent = obj.event;
132
133         if (layEvent === 'edit') {
134             ScrapCategoryConf.openEditDlg(data);
135         } else if (layEvent === 'delete') {
136             ScrapCategoryConf.onDeleteItem(data);
137         }
138     });
139 });