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