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