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