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