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