| | |
| | | case 'edit': |
| | | showEditModel(data) |
| | | break; |
| | | case'sync': |
| | | case 'sync': |
| | | layer.confirm('确认同步库存?', function () { |
| | | notice.msg('正在同步库存......', {icon: 4}); // 加载提示 |
| | | |
| | | $.ajax({ |
| | | url: baseUrl + "/mat/sync", |
| | | method: 'POST', |
| | | contentType: 'application/json', // 正确的Content-Type位置 |
| | | headers: { |
| | | 'token': localStorage.getItem('token') |
| | | }, |
| | | data: JSON.stringify(data), |
| | | success: function (res) { |
| | | notice.destroy(); // 移除“正在同步”提示 |
| | | |
| | | if (res.code === 200) { |
| | | layer.msg('同步成功 ✅', {icon: 1}); // ✅ 成功提示 |
| | | $(".layui-laypage-btn")[0].click(); // 触发表格刷新 |
| | | } else { |
| | | layer.msg(res.msg || '同步失败 ❌', {icon: 2}); // ❌ 失败提示 |
| | | } |
| | | }, |
| | | error: function (xhr) { |
| | | notice.destroy(); |
| | | layer.msg('请求失败:' + (xhr.responseText || '未知错误'), {icon: 2}); |
| | | } |
| | | }); |
| | | }); |
| | | break; |
| | | } |
| | | }); |
| | | |