1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
| function getCol() {
| var cols = [];
| cols.push(
| {field: 'fbillNo', align: 'center', title: '通知单号', width: 130}
| , {field: 'fsourceBillNo', align: 'center', title: '生产单号', width: 120}
| , {field: 'fnumber', align: 'center', title: '物料编码', width: 140}
| , {field: 'fname', align: 'center', title: '物料名称', width: 350}
| , {field: 'fmodel', align: 'center', title: '规格', width: 180}
| );
| return cols;
| }
|
| layui.use(['table', 'laydate', 'form', 'upload'], function () {
| var table = layui.table;
| var $ = layui.jquery;
| var layer = layui.layer;
| var layDate = layui.laydate;
| var form = layui.form;
| var upload = layui.upload;
|
| // 数据渲染
| tableIns = table.render({
| elem: '#salesOrder',
| headers: {token: localStorage.getItem('token')},
| url: baseUrl + '/erp/cpicmo/query',
| even: true,
| toolbar: '#toolbar',
| cellMinWidth: 50,
| cols: [getCol()],
| parseData: function (res) {
| return {
| 'code': res.code,
| 'msg': res.msg,
| 'data': res.data
| }
| },
| response: {
| statusCode: 200
| },
| done: function (res, curr, count) {
| if (res.code === 403) {
| top.location.href = baseUrl + "/";
| }
| }
| });
|
| // 搜索栏重置事件
| form.on('submit(reset)', function (data) {
| clearFormVal($('#search-box'));
| tableReload(false);
| });
|
| // 搜索栏搜索事件
| form.on('submit(search)', function (data) {
| tableReload(false);
| });
|
|
| // 时间选择器
| layDate.render({
| elem: '.layui-laydate-range'
| , style: 'width: 150px'
| , range: true
| });
| });
|
| /* 表格数据重载 */
| function tableReload(child) {
| var searchData = {};
| $.each($('#search-box [name]').serializeArray(), function() {
| searchData[this.name] = this.value;
| });
|
| (child ? parent.tableIns : tableIns).reload({
| where: searchData,
| done: function (res, curr, count) {
| if (res.code === 403) {
| top.location.href = baseUrl + "/";
| }
| limit(child);
| }
| });
| }
|
| /* 监听回车事件 */
| $('body').keydown(function () {
| if (event.keyCode === 13) {
| $("#search").click();
| }
| });
|
|