cl
2024-01-23 6dadf36ef118fbb3b2cd5aca94cde88e29fb55dc
提交 | 用户 | 时间
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 MaterialShortageAlarm = {
12         tableId: "materialShortageAlarmTable"
13     };
14
15     /**
16      * 初始化表格的列
17      */
18     MaterialShortageAlarm.initColumn = function () {
19         return [[
20             {type: 'checkbox'},
21             {field: 'id', hide: true, title: '主键id'},
22             {field: 'workOrderNo', sort: true, title: '工单编号',minWidth:160},
23             {field: 'productCode', sort: true, title: '产品编号', width: 125},
24             {field: 'productionLine', sort: true, title: '产线编号', width: 125},
25             {field: 'locationCode', sort: true, title: '工位编号', width: 125},
26             {field: 'equipmentNo', sort: true, title: '设备编号', width: 125},
27             {field: 'materialCode', sort: true, title: '物料编号', width: 125},
28             {field: 'quantity', sort: true, title: '数量'},
29             {field: 'badType', sort: true, title: '不良类型', width: 125},
30             {field: 'badDesc', sort: true, title: '不良描述', width: 125},
31             {field: 'callTime', sort: true, title: '缺料时间',minWidth:160},
32             {field: 'feedingTime', sort: true, title: '上料时间',minWidth:160},
33             {field: 'whetherToHandle', sort: true, title: '是否处理', width: 125},
34             {field: 'remarks', sort: true, title: '备注'},
35             {align: 'center', toolbar: '#tableBar', title: '操作', width: 125}
36         ]];
37     };
38
39     /**
40      * 点击查询按钮
41      */
42     MaterialShortageAlarm.search = function () {
43         var queryData = {};
44         queryData['workOrderNo'] = $("#workOrderNo").val();
45         queryData['productionLine'] = $("#productionLine").val();
46         queryData['equipmentNo'] = $("#equipmentNo").val();
47         queryData['materialCode'] = $("#materialCode").val();
48
49         table.reload(MaterialShortageAlarm.tableId, {
50             where: queryData, page: {curr: 1}
51         });
52     };
53
54     /**
55      * 弹出添加对话框
56      */
57     MaterialShortageAlarm.openAddDlg = function () {
58         window.location.href = Feng.ctxPath + '/materialShortageAlarm/add'
59     };
60
61      /**
62       * 点击编辑
63       *
64       * @param data 点击按钮时候的行数据
65       */
66       MaterialShortageAlarm.openEditDlg = function (data) {
67           window.location.href = Feng.ctxPath + '/materialShortageAlarm/edit?id=' + data.id
68       };
69
70
71     /**
72      * 导出excel按钮
73      */
74     MaterialShortageAlarm.exportExcel = function () {
75         var checkRows = table.checkStatus(MaterialShortageAlarm.tableId);
76         if (checkRows.data.length === 0) {
77             Feng.error("请选择要导出的数据");
78         } else {
79             table.exportFile(tableResult.config.id, checkRows.data, 'xls');
80         }
81     };
82
83     /**
84      * 点击删除
85      *
86      * @param data 点击按钮时候的行数据
87      */
88     MaterialShortageAlarm.onDeleteItem = function (data) {
89         var operation = function () {
90             var ajax = new $ax(Feng.ctxPath + "/materialShortageAlarm/delete", function (data) {
91                 Feng.success("删除成功!");
92                 table.reload(MaterialShortageAlarm.tableId);
93             }, function (data) {
94                 Feng.error("删除失败!" + data.responseJSON.message + "!");
95             });
96             ajax.set("id", data.id);
97             ajax.start();
98         };
99         Feng.confirm("是否删除?", operation);
100     };
101
102     // 渲染表格
103     var tableResult = table.render({
104         elem: '#' + MaterialShortageAlarm.tableId,
105         url: Feng.ctxPath + '/materialShortageAlarm/list',
106         page: true,
107         height: "full-158",
108         cellMinWidth: 100,
109         cols: MaterialShortageAlarm.initColumn()
110     });
111
112     // 搜索按钮点击事件
113     $('#btnSearch').click(function () {
114         MaterialShortageAlarm.search();
115     });
116
117     // 添加按钮点击事件
118     $('#btnAdd').click(function () {
119
120     MaterialShortageAlarm.openAddDlg();
121
122     });
123
124     // 导出excel
125     $('#btnExp').click(function () {
126         MaterialShortageAlarm.exportExcel();
127     });
128
129     // 工具条点击事件
130     table.on('tool(' + MaterialShortageAlarm.tableId + ')', function (obj) {
131         var data = obj.data;
132         var layEvent = obj.event;
133
134         if (layEvent === 'edit') {
135             MaterialShortageAlarm.openEditDlg(data);
136         } else if (layEvent === 'delete') {
137             MaterialShortageAlarm.onDeleteItem(data);
138         }
139     });
140 });