Loop_Admin.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738
  1. var ExcelData, ExcelKind;
  2. function ConfirmImport() {
  3. var index = layer.load(1, {
  4. shade: [0.5, '#000']
  5. });
  6. $.ajax({
  7. type: "POST",
  8. url: "/Admin/StoreHouse/Import?r=" + Math.random(1),
  9. data: "Kind=" + ExcelKind + "&ExcelData=" + encodeURIComponent(JSON.stringify(ExcelData)),
  10. dataType: "text",
  11. success: function (data) {
  12. layer.close(index);
  13. if (data.indexOf("success") == 0) {
  14. layer.msg("成功操作" + data.split('|')[1] + "部机具", {
  15. time: 2000
  16. }, function () {
  17. window.location.reload();
  18. });
  19. } else {
  20. layer.msg(data);
  21. }
  22. }
  23. });
  24. }
  25. function CheckImport(table, key, loadindex, index) {
  26. $.ajax({
  27. url: "/Admin/StoreHouse/CheckImportV2?r=" + Math.random(1),
  28. data: "key=" + key,
  29. dataType: "json",
  30. success: function (data) {
  31. if (data.status == 1) {
  32. layer.msg("成功操作" + data.data + "部机具", {
  33. time: 2000
  34. }, function () {
  35. layer.close(index); //关闭弹层
  36. layer.close(loadindex);
  37. table.reload('LAY-list-manage'); //数据刷新
  38. });
  39. } else if (data.status == 2) {
  40. layer.close(index); //关闭弹层
  41. layer.close(loadindex);
  42. var content = '';
  43. for (var i = 0; i < data.errList.length; i++) {
  44. content += data.errList[i] + '<br/>'
  45. }
  46. layer.alert(content);
  47. } else {
  48. layer.msg(data.data, {
  49. time: 1000
  50. }, function () {
  51. CheckImport(table, key, loadindex, index);
  52. });
  53. }
  54. }
  55. });
  56. }
  57. var excel;
  58. layui.config({
  59. base: '/layuiadmin/' //静态资源所在路径
  60. }).extend({
  61. myexcel: 'layui/lay/modules/excel',
  62. index: 'lib/index' //主入口模块
  63. }).use(['index', 'table', 'excel', 'laydate'], function () {
  64. var $ = layui.$,
  65. form = layui.form,
  66. table = layui.table;
  67. //- 筛选条件-日期
  68. var laydate = layui.laydate;
  69. var layCreateDate = laydate.render({
  70. elem: '#CreateDate',
  71. type: 'date',
  72. range: true,
  73. trigger: 'click',
  74. change: function (value, date, endDate) {
  75. var op = true;
  76. if (date.year == endDate.year && endDate.month - date.month <= 1) {
  77. if (endDate.month - date.month == 1 && endDate.date > date.date) {
  78. op = false;
  79. layCreateDate.hint('日期范围请不要超过1个月');
  80. setTimeout(function () {
  81. $(".laydate-btns-confirm").addClass("laydate-disabled");
  82. }, 1);
  83. }
  84. } else {
  85. op = false;
  86. layCreateDate.hint('日期范围请不要超过1个月');
  87. setTimeout(function () {
  88. $(".laydate-btns-confirm").addClass("laydate-disabled");
  89. }, 1);
  90. }
  91. if (op) {
  92. $('#CreateDate').val(value);
  93. }
  94. }
  95. });
  96. //excel导入
  97. excel = layui.excel;
  98. $('#ExcelFile').change(function (e) {
  99. var files = e.target.files;
  100. excel.importExcel(files, {}, function (data) {
  101. ExcelData = data[0].Sheet1;
  102. });
  103. });
  104. //监听单元格编辑
  105. table.on('edit(LAY-list-manage)', function (obj) {
  106. var value = obj.value //得到修改后的值
  107. ,
  108. data = obj.data //得到所在行所有键值
  109. ,
  110. field = obj.field; //得到字段
  111. if (field == "Sort") {
  112. $.ajax({
  113. type: "POST",
  114. url: "/Admin/StoreHouse/Sort?r=" + Math.random(1),
  115. data: "Id=" + data.Id + "&Sort=" + value,
  116. dataType: "text",
  117. success: function (data) { }
  118. });
  119. }
  120. });
  121. //列表数据
  122. table.render({
  123. elem: '#LAY-list-manage'
  124. , url: '/Admin/SysTools/LoopData' //模拟接口
  125. , cols: [[
  126. { type: 'checkbox', fixed: 'left' }
  127. , { field: 'ApplyNo', width: 200, title: '申请订单号', sort: true }
  128. , { field: 'OrderNo', width: 200, title: '订单号', sort: true }
  129. , { field: 'ComeSn', width: 300, title: '来源机具SN', sort: true, templet: '#ComeSnLoop' }
  130. , { field: 'ComeSnMakerCode', width: 200, title: '来源机具大盟主编号', sort: true }
  131. , { field: 'ComeSnRealName', width: 200, title: '来源机具大盟主姓名', sort: true }
  132. , { field: 'SendSn', width: 300, title: '发货SN', sort: true, templet: '#SendSnLoop' }
  133. , { field: 'SendSnMakerCode', width: 200, title: '发货机具大盟主编号', sort: true }
  134. , { field: 'SendSnRealName', width: 200, title: '发货机具大盟主姓名', sort: true }
  135. , { field: 'MakerCode', width: 200, title: '创客编号', sort: true }
  136. , { field: 'RealName', width: 200, title: '创客姓名', sort: true }
  137. , { field: 'CreateDate', width: 200, title: '申请时间', sort: true }
  138. , { field: 'Status', width: 200, title: '申请状态', sort: true }
  139. ]]
  140. , where: {
  141. SwapSnExpand: SwapSnExpand,
  142. SnNos: SnNos
  143. }
  144. , page: true
  145. , limit: 30
  146. , height: 'full-' + String($('.layui-card-header').height() + 130)
  147. , text: '对不起,加载出现异常!'
  148. , done: function (res, curr, count) {
  149. $(".layui-none").text("无数据");
  150. }
  151. });
  152. $('.layui-btn').on('click', function () {
  153. var type = $(this).data('type');
  154. active[type] ? active[type].call(this) : '';
  155. });
  156. //监听工具条
  157. table.on('tool(LAY-list-manage)', function (obj) {
  158. var data = obj.data;
  159. if (obj.event === 'del') {
  160. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  161. $.ajax({
  162. type: "POST",
  163. url: "/Admin/StoreHouse/Delete?r=" + Math.random(1),
  164. data: "Id=" + data.Id,
  165. dataType: "text",
  166. success: function (data) {
  167. if (data == "success") {
  168. obj.del();
  169. layer.close(index);
  170. } else {
  171. parent.layer.msg(data);
  172. }
  173. }
  174. });
  175. });
  176. } else if (obj.event === 'sycn') {
  177. var index = layer.confirm('确定要同步该仓库的库存数据吗?', function (index) {
  178. layer.close(index);
  179. var loadindex = layer.load(1, {
  180. shade: [0.5, '#000']
  181. });
  182. $.ajax({
  183. type: "POST",
  184. url: "/Admin/StoreHouse/SycnData?r=" + Math.random(1),
  185. data: "Id=" + data.Id,
  186. dataType: "text",
  187. success: function (data) {
  188. layer.close(loadindex);
  189. if (data == "success") {
  190. layer.msg('同步成功');
  191. table.reload('LAY-list-manage');
  192. } else {
  193. layer.msg(data);
  194. }
  195. }
  196. });
  197. });
  198. } else if (obj.event === 'edit') {
  199. var tr = $(obj.tr);
  200. var perContent = layer.open({
  201. type: 2,
  202. title: '仓库-编辑',
  203. content: 'Edit?Id=' + data.Id + '',
  204. maxmin: true,
  205. area: ['800px', '650px'],
  206. btn: ['确定', '取消'],
  207. yes: function (index, layero) {
  208. var iframeWindow = window['layui-layer-iframe' + index],
  209. submitID = 'LAY-list-front-submit',
  210. submit = layero.find('iframe').contents().find('#' + submitID);
  211. setTimeout(function () {
  212. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  213. var errObj = $(this).find('.layui-form-danger');
  214. if (errObj.length > 0) {
  215. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  216. submit.click();
  217. }
  218. });
  219. }, 300);
  220. //监听提交
  221. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  222. var field = data.field; //获取提交的字段
  223. var userdata = "";
  224. for (var prop in field) {
  225. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  226. }
  227. //提交 Ajax 成功后,静态更新表格中的数据
  228. //$.ajax({});
  229. $.ajax({
  230. type: "POST",
  231. url: "/Admin/StoreHouse/Edit?r=" + Math.random(1),
  232. data: userdata,
  233. dataType: "text",
  234. success: function (data) {
  235. if (data == "success") {
  236. layer.close(index); //关闭弹层
  237. table.reload('LAY-list-manage'); //数据刷新
  238. } else {
  239. layer.msg(data);
  240. }
  241. }
  242. });
  243. });
  244. submit.trigger('click');
  245. },
  246. success: function (layero, index) {
  247. }
  248. });
  249. } else if (obj.event === 'edits') {
  250. var tr = $(obj.tr);
  251. var perContent = layer.open({
  252. type: 2,
  253. title: '一键新建仓库',
  254. content: 'Edits?Id=' + data.Id + '',
  255. maxmin: true,
  256. area: ['860px', '650px'],
  257. btn: ['确定', '取消'],
  258. yes: function (index, layero) {
  259. var iframeWindow = window['layui-layer-iframe' + index],
  260. submitID = 'LAY-list-front-submit',
  261. submit = layero.find('iframe').contents().find('#' + submitID);
  262. setTimeout(function () {
  263. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  264. var errObj = $(this).find('.layui-form-danger');
  265. if (errObj.length > 0) {
  266. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  267. submit.click();
  268. }
  269. });
  270. }, 300);
  271. //监听提交
  272. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  273. var field = data.field; //获取提交的字段
  274. var userdata = "";
  275. for (var prop in field) {
  276. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  277. }
  278. //提交 Ajax 成功后,静态更新表格中的数据
  279. //$.ajax({});
  280. $.ajax({
  281. type: "POST",
  282. url: "/Admin/StoreHouse/Edits?r=" + Math.random(1),
  283. data: userdata,
  284. dataType: "text",
  285. success: function (data) {
  286. if (data == "success") {
  287. layer.close(index); //关闭弹层
  288. table.reload('LAY-list-manage'); //数据刷新
  289. } else {
  290. layer.msg(data);
  291. }
  292. }
  293. });
  294. });
  295. submit.trigger('click');
  296. },
  297. success: function (layero, index) {
  298. }
  299. });
  300. }
  301. });
  302. //监听搜索
  303. form.on('submit(LAY-list-front-search)', function (data) {
  304. var field = data.field;
  305. //执行重载
  306. table.reload('LAY-list-manage', {
  307. where: field,
  308. page: {
  309. curr: 1
  310. }
  311. });
  312. });
  313. form.on('submit(LAY-list-front-searchall)', function (data) {
  314. table.reload('LAY-list-manage', {
  315. where: null,
  316. page: {
  317. curr: 1
  318. }
  319. });
  320. });
  321. //事件
  322. var active = {
  323. batchdel: function () {
  324. var checkStatus = table.checkStatus('LAY-list-manage'),
  325. data = checkStatus.data; //得到选中的数据
  326. if (data.length < 1) {
  327. parent.layer.msg("请选择要删除的项");
  328. } else {
  329. var ids = "";
  330. $.each(data, function (index, value) {
  331. ids += data[index].Id + ",";
  332. });
  333. ids = ids.substring(0, ids.length - 1);
  334. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  335. $.ajax({
  336. type: "POST",
  337. url: "/Admin/StoreHouse/Delete?r=" + Math.random(1),
  338. data: "Id=" + ids,
  339. dataType: "text",
  340. success: function (data) {
  341. layer.close(index);
  342. if (data == "success") {
  343. table.reload('LAY-list-manage');
  344. } else {
  345. layer.msg(data);
  346. }
  347. }
  348. });
  349. });
  350. }
  351. },
  352. add: function () {
  353. var perContent = layer.open({
  354. type: 2,
  355. title: '仓库-添加',
  356. content: 'Add',
  357. maxmin: true,
  358. area: ['950px', '650px'],
  359. btn: ['确定', '取消'],
  360. yes: function (index, layero) {
  361. var iframeWindow = window['layui-layer-iframe' + index],
  362. submitID = 'LAY-list-front-submit',
  363. submit = layero.find('iframe').contents().find('#' + submitID);
  364. setTimeout(function () {
  365. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  366. var errObj = $(this).find('.layui-form-danger');
  367. if (errObj.length > 0) {
  368. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  369. submit.click();
  370. }
  371. });
  372. }, 300);
  373. //监听提交
  374. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  375. var field = data.field; //获取提交的字段
  376. var userdata = "";
  377. for (var prop in field) {
  378. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  379. }
  380. //提交 Ajax 成功后,静态更新表格中的数据
  381. //$.ajax({});
  382. $.ajax({
  383. type: "POST",
  384. url: "/Admin/StoreHouse/Add?r=" + Math.random(1),
  385. data: userdata,
  386. dataType: "text",
  387. success: function (data) {
  388. if (data == "success") {
  389. layer.close(index); //关闭弹层
  390. table.reload('LAY-list-manage'); //数据刷新
  391. } else {
  392. layer.msg(data);
  393. }
  394. }
  395. });
  396. });
  397. submit.trigger('click');
  398. }
  399. });
  400. },
  401. ImportMachine: function () {
  402. var perContent = layer.open({
  403. type: 2,
  404. title: '机具入库',
  405. content: 'Import?ExcelKind=1',
  406. maxmin: true,
  407. area: ['650px', '350px'],
  408. btn: ['确定', '取消'],
  409. yes: function (index, layero) {
  410. var iframeWindow = window['layui-layer-iframe' + index],
  411. submitID = 'LAY-list-front-submit',
  412. submit = layero.find('iframe').contents().find('#' + submitID);
  413. //监听提交
  414. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  415. var field = data.field; //获取提交的字段
  416. var userdata = "";
  417. for (var prop in field) {
  418. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  419. }
  420. //提交 Ajax 成功后,静态更新表格中的数据
  421. //$.ajax({});
  422. var loadindex = layer.load(1, {
  423. shade: [0.5, '#000']
  424. });
  425. $.ajax({
  426. type: "POST",
  427. url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
  428. data: userdata,
  429. dataType: "text",
  430. success: function (data) {
  431. if (data.indexOf("success") == 0) {
  432. var datalist = data.split('|');
  433. var key = datalist[1];
  434. CheckImport(table, key, loadindex, index);
  435. } else {
  436. layer.msg(data);
  437. }
  438. }
  439. });
  440. });
  441. submit.trigger('click');
  442. }
  443. });
  444. },
  445. ImportChange: function () {
  446. var perContent = layer.open({
  447. type: 2,
  448. title: '仓库调拨',
  449. content: 'Import?ExcelKind=2',
  450. maxmin: true,
  451. area: ['650px', '350px'],
  452. btn: ['确定', '取消'],
  453. yes: function (index, layero) {
  454. var iframeWindow = window['layui-layer-iframe' + index],
  455. submitID = 'LAY-list-front-submit',
  456. submit = layero.find('iframe').contents().find('#' + submitID);
  457. //监听提交
  458. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  459. var field = data.field; //获取提交的字段
  460. var userdata = "";
  461. for (var prop in field) {
  462. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  463. }
  464. //提交 Ajax 成功后,静态更新表格中的数据
  465. //$.ajax({});
  466. var loadindex = layer.load(1, {
  467. shade: [0.5, '#000']
  468. });
  469. $.ajax({
  470. type: "POST",
  471. url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
  472. data: userdata,
  473. dataType: "text",
  474. success: function (data) {
  475. if (data.indexOf("success") == 0) {
  476. var datalist = data.split('|');
  477. var key = datalist[1];
  478. CheckImport(table, key, loadindex, index);
  479. } else {
  480. layer.msg(data);
  481. }
  482. }
  483. });
  484. });
  485. submit.trigger('click');
  486. }
  487. });
  488. },
  489. ImportSend: function () {
  490. var perContent = layer.open({
  491. type: 2,
  492. title: '仓库发货至创客',
  493. content: 'Import?ExcelKind=3',
  494. maxmin: true,
  495. area: ['650px', '350px'],
  496. btn: ['确定', '取消'],
  497. yes: function (index, layero) {
  498. var iframeWindow = window['layui-layer-iframe' + index],
  499. submitID = 'LAY-list-front-submit',
  500. submit = layero.find('iframe').contents().find('#' + submitID);
  501. //监听提交
  502. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  503. var field = data.field; //获取提交的字段
  504. var userdata = "";
  505. for (var prop in field) {
  506. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  507. }
  508. //提交 Ajax 成功后,静态更新表格中的数据
  509. //$.ajax({});
  510. var loadindex = layer.load(1, {
  511. shade: [0.5, '#000']
  512. });
  513. $.ajax({
  514. type: "POST",
  515. url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
  516. data: userdata,
  517. dataType: "text",
  518. success: function (data) {
  519. if (data.indexOf("success") == 0) {
  520. var datalist = data.split('|');
  521. var key = datalist[1];
  522. CheckImport(table, key, loadindex, index);
  523. } else {
  524. layer.msg(data);
  525. }
  526. }
  527. });
  528. });
  529. submit.trigger('click');
  530. }
  531. });
  532. },
  533. ImportBack: function () {
  534. var perContent = layer.open({
  535. type: 2,
  536. title: '机具回仓库',
  537. content: 'Import?ExcelKind=4',
  538. maxmin: true,
  539. area: ['650px', '350px'],
  540. btn: ['确定', '取消'],
  541. yes: function (index, layero) {
  542. var iframeWindow = window['layui-layer-iframe' + index],
  543. submitID = 'LAY-list-front-submit',
  544. submit = layero.find('iframe').contents().find('#' + submitID);
  545. //监听提交
  546. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  547. var field = data.field; //获取提交的字段
  548. var userdata = "";
  549. for (var prop in field) {
  550. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  551. }
  552. //提交 Ajax 成功后,静态更新表格中的数据
  553. //$.ajax({});
  554. var loadindex = layer.load(1, {
  555. shade: [0.5, '#000']
  556. });
  557. $.ajax({
  558. type: "POST",
  559. url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
  560. data: userdata,
  561. dataType: "text",
  562. success: function (data) {
  563. if (data.indexOf("success") == 0) {
  564. var datalist = data.split('|');
  565. var key = datalist[1];
  566. CheckImport(table, key, loadindex, index);
  567. } else {
  568. layer.msg(data);
  569. }
  570. }
  571. });
  572. });
  573. submit.trigger('click');
  574. }
  575. });
  576. },
  577. ExportExcel: function () {
  578. var userdata = '';
  579. $(".layuiadmin-card-header-auto input").each(function (i) {
  580. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  581. });
  582. $(".layuiadmin-card-header-auto select").each(function (i) {
  583. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  584. });
  585. $.ajax({
  586. type: "GET",
  587. url: "/Admin/StoreHouse/ExportExcel?r=" + Math.random(1),
  588. data: userdata,
  589. dataType: "json",
  590. success: function (data) {
  591. data.Obj.unshift(data.Fields);
  592. excel.exportExcel(data.Obj, data.Info, 'xlsx');
  593. }
  594. });
  595. },
  596. Open: function () {
  597. var checkStatus = table.checkStatus('LAY-list-manage'),
  598. data = checkStatus.data; //得到选中的数据
  599. if (data.length < 1) {
  600. parent.layer.msg("请选择要开启的项");
  601. } else {
  602. var ids = "";
  603. $.each(data, function (index, value) {
  604. ids += data[index].Id + ",";
  605. });
  606. ids = ids.substring(0, ids.length - 1);
  607. var index = layer.confirm('确定要开启吗?', function (index) {
  608. $.ajax({
  609. type: "POST",
  610. url: "/Admin/StoreHouse/Open?r=" + Math.random(1),
  611. data: "Id=" + ids,
  612. dataType: "text",
  613. success: function (data) {
  614. layer.close(index);
  615. if (data == "success") {
  616. table.reload('LAY-list-manage');
  617. } else {
  618. layer.msg(data);
  619. }
  620. }
  621. });
  622. });
  623. }
  624. },
  625. Close: function () {
  626. var checkStatus = table.checkStatus('LAY-list-manage'),
  627. data = checkStatus.data; //得到选中的数据
  628. if (data.length < 1) {
  629. parent.layer.msg("请选择要关闭的项");
  630. } else {
  631. var ids = "";
  632. $.each(data, function (index, value) {
  633. ids += data[index].Id + ",";
  634. });
  635. ids = ids.substring(0, ids.length - 1);
  636. var index = layer.confirm('确定要关闭吗?', function (index) {
  637. $.ajax({
  638. type: "POST",
  639. url: "/Admin/StoreHouse/Close?r=" + Math.random(1),
  640. data: "Id=" + ids,
  641. dataType: "text",
  642. success: function (data) {
  643. layer.close(index);
  644. if (data == "success") {
  645. table.reload('LAY-list-manage');
  646. } else {
  647. layer.msg(data);
  648. }
  649. }
  650. });
  651. });
  652. }
  653. },
  654. SycnData: function () {
  655. var index = layer.confirm('确定要同步所有仓库的库存数据吗?', function (index) {
  656. layer.close(index);
  657. var loadindex = layer.load(1, {
  658. shade: [0.5, '#000']
  659. });
  660. $.ajax({
  661. type: "POST",
  662. url: "/Admin/StoreHouse/SycnData?r=" + Math.random(1),
  663. data: "Id=0",
  664. dataType: "text",
  665. success: function (data) {
  666. layer.close(loadindex);
  667. if (data == "success") {
  668. layer.msg('同步成功');
  669. table.reload('LAY-list-manage');
  670. } else {
  671. layer.msg(data);
  672. }
  673. }
  674. });
  675. });
  676. },
  677. };
  678. $('.layui-btn').on('click', function () {
  679. var type = $(this).data('type');
  680. active[type] ? active[type].call(this) : '';
  681. });
  682. });