懒羊羊
2023-08-30 71e81ed1d12e4d69f53c8ad9e066650ad4186293
提交 | 用户 | 时间
71e81e 1 layui.use(['laydate','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     var laydate = layui.laydate;
8
9
10     //日期时间选择器
11     laydate.render({
12         elem: '#startTime'
13         ,type: 'datetime'
14     });
15
16     laydate.render({
17         elem: '#endTime'
18         ,type: 'datetime'
19     });
20
21     /**
22      * 设备产品过程参数采集管理
23      */
24     var ParamCollection = {
25         tableId: "paramCollectionTable"
26     };
27
28     /**
29      * 初始化表格的列
30      */
31     ParamCollection.initColumn = function () {
32         return [[
33             {type: 'checkbox'},
34             {field: 'id', hide: true, title: '主键id'},
35             {field: 'workOrderNo', sort: true, title: '工单编号',minWidth:160},
36             {field: 'sfcCode', sort: true, title: '总成序列号',minWidth:160},
37             {field: 'productCode', sort: true, title: '产品编号' , width: 125},
38             {field: 'productionLine', sort: true, title: '产线编号', width: 125},
39             {field: 'locationCode', sort: true, title: '工位编号', width: 125},
40            /* {field: 'equipmentNo', sort: true, title: '设备编号', width: 125},*/
41             {field: 'paramCode', sort: true, title: '参数编码', width: 125},
42             {field: 'paramName', sort: true, title: '参数名称', width: 125},
43             {field: 'unit', sort: true, title: '单位'},
44             {field: 'paramValue', sort: true, title: '参数值'},
45             {field: 'paramUpper', sort: true, title: '参数上限', width: 125},
46             {field: 'paramLower', sort: true, title: '参数下限', width: 125},
47             {field: 'paramStandard', sort: true, title: '标准值'},
48             {field: 'createTime', sort: true, title: '采集时间',minWidth:160},
49             {field: 'state', sort: true, title: '状态'},
50           /*  {field: 'createUser', sort: true, title: '创建用户'},
51             {field: 'createTime', sort: true, title: '创建时间',minWidth:160},
52             {field: 'updateUser', sort: true, title: '更改用户'},
53             {field: 'updateTime', sort: true, title: '更改时间',minWidth:160},*/
54             {align: 'center', toolbar: '#tableBar', title: '操作', width: 125}
55         ]];
56     };
57
58     /**
59      * 点击查询按钮
60      */
61     ParamCollection.search = function () {
62         var queryData = {};
63         queryData['workOrderNo'] = $("#workOrderNo").val();
64         queryData['productionLine'] = $("#productionLine").val();
65         queryData['sfcCode'] = $("#sfcCode").val();
66         queryData['locationCode'] = $("#locationCode").val();
67         queryData['startTime'] = $("#startTime").val();
68         queryData['endTime'] = $("#endTime").val();
69
70
71         table.reload(ParamCollection.tableId, {
72             where: queryData, page: {curr: 1}
73         });
74     };
75
76     /**
77      * 跳转到添加页面
78      */
79     ParamCollection.jumpAddPage = function () {
80         window.location.href = Feng.ctxPath + '/paramCollection/add'
81     };
82
83     /**
84     * 跳转到编辑页面
85     *
86     * @param data 点击按钮时候的行数据
87     */
88     ParamCollection.jumpEditPage = function (data) {
89         window.location.href = Feng.ctxPath + '/paramCollection/edit?id=' + data.id
90     };
91
92     /**
93      * 导出excel按钮
94      */
95     ParamCollection.exportExcel = function () {
96         var checkRows = table.checkStatus(ParamCollection.tableId);
97         if (checkRows.data.length === 0) {
98             Feng.error("请选择要导出的数据");
99         } else {
100             table.exportFile(tableResult.config.id, checkRows.data, 'xls');
101         }
102     };
103
104     $("#btnExpAll").click(function () {
105         var queryData = {};
106         queryData['workOrderNo'] = $('#workOrderNo').val();
107         queryData['productionLine'] = $('#productionLine').val();
108         queryData['sfcCode'] = $('#sfcCode').val();
109         queryData['locationCode'] = $('#locationCode').val();
110         queryData['startTime'] = $("#startTime").val();
111         queryData['endTime'] = $("#endTime").val();
112         $.ajax({
113             type: "POST",
114             url: Feng.ctxPath + '/paramCollection/exportTable',
115             data: queryData,
116             success : function (result) {
117                 table.exportFile(tableResult.config.id, result.data, 'xls');
118             }
119         });
120     });
121
122     /**
123      * 点击删除
124      *
125      * @param data 点击按钮时候的行数据
126      */
127     ParamCollection.onDeleteItem = function (data) {
128         var operation = function () {
129             var ajax = new $ax(Feng.ctxPath + "/paramCollection/delete", function (data) {
130                 Feng.success("删除成功!");
131                 table.reload(ParamCollection.tableId);
132             }, function (data) {
133                 Feng.error("删除失败!" + data.responseJSON.message + "!");
134             });
135             ajax.set("id", data.id);
136             ajax.start();
137         };
138         Feng.confirm("是否删除?", operation);
139     };
140
141     // 渲染表格
142     var tableResult = table.render({
143         elem: '#' + ParamCollection.tableId,
144         url: Feng.ctxPath + '/paramCollection/list',
145         toolbar: '#toolbarDemo',
146         page: true,
147         height: "full-158",
148         cellMinWidth: 100,
149         cols: ParamCollection.initColumn()
150     });
151
152     // 搜索按钮点击事件
153     $('#btnSearch').click(function () {
154         ParamCollection.search();
155     });
156
157     // 添加按钮点击事件
158     $('#btnAdd').click(function () {
159
160     ParamCollection.jumpAddPage();
161
162     });
163
164     // 导出excel
165     $('#btnExp').click(function () {
166         ParamCollection.exportExcel();
167     });
168
169     // 工具条点击事件
170     table.on('tool(' + ParamCollection.tableId + ')', function (obj) {
171         var data = obj.data;
172         var layEvent = obj.event;
173
174         if (layEvent === 'edit') {
175             ParamCollection.jumpEditPage(data);
176         } else if (layEvent === 'delete') {
177             ParamCollection.onDeleteItem(data);
178         }
179     });
180 });