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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
| var syncTableData = [];
|
| layui.use(['table', 'laydate', 'form'], function () {
| var table = layui.table;
| var $ = layui.jquery;
| var layer = layui.layer;
| var layDate = layui.laydate;
| var form = layui.form;
|
|
| // 数据渲染
| tableIns = table.render({
| elem: '#locSum',
| headers: {token: localStorage.getItem('token')},
| url: baseUrl + '/locSync/queryLocSum',
| page: true,
| // limit: 16,
| // limits: [16, 30, 50, 100, 200, 500],
| even: true,
| toolbar: '#toolbar',
| cellMinWidth: 50,
| cols: [[
| {field: 'matnr', align: 'center', title: '物料编码', width: 200}
| , {field: 'maktx', align: 'center', title: '物料名称'}
| , {field: 'anfme', align: 'center', title: '总数量[平仓+立库]', width: 180}
| , {field: 'altme', align: 'center', title: '单位', width: 80}
| , {field: 'memo', align: 'center', title: '备注'}
| ]],
| request: {
| pageName: 'curr',
| pageSize: 'limit'
| },
| parseData: function (res) {
| return {
| 'code': res.code,
| 'msg': res.msg,
| 'count': res.data.total,
| 'data': res.data
| }
| },
| response: {
| statusCode: 200
| },
| done: function (res, curr, count) {
| if (res.code === 403) {
| top.location.href = baseUrl + "/";
| }
| pageCurr = curr;
| limit();
| syncTableData = res.data;
| }
| });
|
| // 监听头工具栏事件
| table.on('toolbar(locSum)', function (obj) {
| switch (obj.event) {
| case 'btnSync':
| $.ajax({
| url: baseUrl + "/locSync/syncLocWrkCount",
| headers: {'token': localStorage.getItem('token')},
| data: {},
| method: 'POST',
| traditional: true,
| success: function (res) {
| if (res.code === 200) {
| var msg = '';
| if (res.data == 0) {
| msg = '确定要同步库存数据吗?'
| } else {
| msg = '同步任务正在进行,确定要中止并重新同步吗?'
| }
| layer.confirm(msg, {
| shadeClose: true
| , btn: ['确定']
| }, function () {
| var paramList = [];
| syncTableData.map(function (e) {
| paramList.push({
| matnr: e.matnr,
| qty: e.anfme,
| });
| });
| var param = {
| 'list': paramList,
| };
| if (res.data > 0) {
| // 清空同步上传清单数据,再进行插入数据
| $.ajax({
| url: baseUrl + "/locSync/updateWrklocSync",
| headers: {'token': localStorage.getItem('token')},
| data: JSON.stringify(param),
| dataType: 'json',
| contentType: 'application/json;charset=UTF-8',
| method: 'POST',
| success: function (res) {
| if (res.code === 200) {
| layer.msg("库存同步中!");
| } else if (res.code === 403) {
| top.location.href = baseUrl + "/";
| } else {
| layer.msg(res.msg)
| }
| }
| });
| } else {
| // 调用同步上传清单数据插入接口
| $.ajax({
| url: baseUrl + "/locSync/insertWrklocSync",
| headers: {'token': localStorage.getItem('token')},
| data: JSON.stringify(param),
| dataType: 'json',
| contentType: 'application/json;charset=UTF-8',
| method: 'POST',
| success: function (res) {
| if (res.code === 200) {
| layer.msg("库存同步中!");
| } else if (res.code === 403) {
| top.location.href = baseUrl + "/";
| } else {
| layer.msg(res.msg)
| }
| }
| });
| }
| layer.closeAll();
| }
| );
| } else if (res.code === 403) {
| top.location.href = baseUrl + "/";
| } else {
| layer.msg(res.msg)
| }
| }
| });
| break;
| default:
| break;
| }
| });
| });
|
|