cl
2024-05-23 ba1a7a9ef126296e2798e313dc5b43f775a1123c
提交 | 用户 | 时间
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 ProductionOrderRecords = {
12         tableId: "productionOrderRecordsTable"
13     };
14
15     /**
16      * 初始化表格的列
17      */
18     ProductionOrderRecords.initColumn = function () {
19         return [[
20             {type: 'checkbox'},
21             {field: 'id', hide: true, title: 'ID'},
22             {field: 'workOrderNo', sort: true, title: '生产工单号',minWidth:160},
541017 23             {field: 'productNo', sort: true, title: 'SFC总成序列号',minWidth:160},
71e81e 24             /* {field: 'drawingNo', sort: true, title: '图号'},*/
ba1a7a 25             {field: 'materialCode', sort: true, title: '产品编号',minWidth:140},
C 26             {field: 'materialName', sort: true, title: '产品名称',minWidth:160},
541017 27             // {field: 'locationCode', sort: true, title: '工位编号',minWidth:110},
28             {field: 'startTime', sort: true, title: '上线时间',minWidth:160},
29             {field: 'endTime', sort: true, title: '下线时间',minWidth:160},
71e81e 30             {field: 'whetherPass', sort: true, title: '是否合格',minWidth:110},//(1是0否)
541017 31
32             /* {field: 'locationName', sort: true, title: '工位名称'},*/
33             // {field: 'locationType', sort: true, title: '工位类型',minWidth:110},//(1上线工位2过程工位3下线工位)
34             // {field: 'productQty', sort: true, title: '生产数量',minWidth:110},
35             //
36             // {field: 'notPassReason', sort: true, title: '不合格原因',minWidth:110},
37             // {field: 'operationUser', sort: true, title: '操作用户',minWidth:110}
71e81e 38             /*{field: 'spareField1', sort: true, title: '预留字段1'},
39             {field: 'spareField2', sort: true, title: '预留字段2'},
40             {field: 'spareField3', sort: true, title: '预留字段3'},
41             {field: 'spareField4', sort: true, title: '预留字段4'},
42             {field: 'remarks', sort: true, title: '备注'},
43             {field: 'serialNumber', sort: true, title: '顺序号'},
44             {align: 'center', toolbar: '#tableBar', title: '操作'}*/
45         ]];
46     };
47
48     /**
49      * 点击查询按钮
50      */
51     ProductionOrderRecords.search = function () {
52         var queryData = {};
53         queryData['productNo'] = $("#productNo").val();
54         queryData['workOrderNo'] = $("#workOrderNo").val();
55         queryData['materialCode'] = $("#materialCode").val();
56         queryData['locationCode'] = $("#locationCode").val();
57         table.reload(ProductionOrderRecords.tableId, {
58             where: queryData, page: {curr: 1}
59         });
60     };
61
62     /**
63      * 跳转到添加页面
64      */
65     ProductionOrderRecords.jumpAddPage = function () {
66         window.location.href = Feng.ctxPath + '/productionOrderRecords/add'
67     };
68
69     /**
70     * 跳转到编辑页面
71     *
72     * @param data 点击按钮时候的行数据
73     */
74     ProductionOrderRecords.jumpEditPage = function (data) {
75         window.location.href = Feng.ctxPath + '/productionOrderRecords/edit?id=' + data.id
76     };
77
78     /**
79      * 导出excel按钮
80      */
81     ProductionOrderRecords.exportExcel = function () {
82         var checkRows = table.checkStatus(ProductionOrderRecords.tableId);
83         if (checkRows.data.length === 0) {
84             Feng.error("请选择要导出的数据");
85         } else {
86             table.exportFile(tableResult.config.id, checkRows.data, 'xls');
87         }
88     };
89
90     /**
91      * 点击删除
92      *
93      * @param data 点击按钮时候的行数据
94      */
95     ProductionOrderRecords.onDeleteItem = function (data) {
96         var operation = function () {
97             var ajax = new $ax(Feng.ctxPath + "/productionOrderRecords/delete", function (data) {
98                 Feng.success("删除成功!");
99                 table.reload(ProductionOrderRecords.tableId);
100             }, function (data) {
101                 Feng.error("删除失败!" + data.responseJSON.message + "!");
102             });
103             ajax.set("id", data.id);
104             ajax.start();
105         };
106         Feng.confirm("是否删除?", operation);
107     };
108
109     // 渲染表格
110     var tableResult = table.render({
111         elem: '#' + ProductionOrderRecords.tableId,
112         url: Feng.ctxPath + '/productionOrderRecords/list',
113         toolbar: '#toolbarDemo',
114         page: true,
115         height: "full-158",
116         cellMinWidth: 100,
117         cols: ProductionOrderRecords.initColumn()
118     });
119
120     // 搜索按钮点击事件
121     $('#btnSearch').click(function () {
122         ProductionOrderRecords.search();
123     });
124
125     // 添加按钮点击事件
126     $('#btnAdd').click(function () {
127
128     ProductionOrderRecords.jumpAddPage();
129
130     });
131
132     // 导出excel
133     $('#btnExp').click(function () {
134         ProductionOrderRecords.exportExcel();
135     });
136
137     // 工具条点击事件
138     table.on('tool(' + ProductionOrderRecords.tableId + ')', function (obj) {
139         var data = obj.data;
140         var layEvent = obj.event;
141
142         if (layEvent === 'edit') {
143             ProductionOrderRecords.jumpEditPage(data);
144         } else if (layEvent === 'delete') {
145             ProductionOrderRecords.onDeleteItem(data);
146         }
147     });
148 });