Loop_Admin.js 29 KB

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