StoreHouse_Admin.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  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: 'datetime',
  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/StoreHouse/IndexData' //模拟接口
  125. ,
  126. cols: [
  127. [{
  128. type: 'checkbox',
  129. fixed: 'left'
  130. }, {
  131. field: 'Id',
  132. fixed: 'left',
  133. title: 'ID',
  134. width: 80,
  135. sort: true,
  136. unresize: true
  137. }, {
  138. field: 'StoreNo',
  139. width: 200,
  140. title: '仓库编号',
  141. sort: true
  142. }, {
  143. field: 'StoreName',
  144. width: 200,
  145. title: '仓库名称',
  146. sort: true
  147. }, {
  148. field: 'ManageUserIdMakerCode',
  149. width: 200,
  150. title: '仓库负责人编号',
  151. sort: true,
  152. templet: '#ManageTpl'
  153. }, {
  154. field: 'ManageUserIdRealName',
  155. width: 200,
  156. title: '仓库管理员',
  157. sort: true
  158. }, {
  159. field: 'UserIdMakerCode',
  160. width: 200,
  161. title: '仓库归属创客编号',
  162. sort: true,
  163. templet: '#MakerCodeTpl'
  164. }, {
  165. field: 'UserIdRealName',
  166. width: 200,
  167. title: '仓库归属人真实姓名',
  168. sort: true
  169. }, {
  170. field: 'BrandId',
  171. width: 300,
  172. title: '产品类型',
  173. sort: true
  174. }, {
  175. field: 'Address',
  176. width: 200,
  177. title: '仓库地址',
  178. sort: true
  179. }, {
  180. field: 'ManageUserIdMobile',
  181. width: 200,
  182. title: '仓库管理员手机号',
  183. sort: true
  184. }, {
  185. field: 'ManagerEmail',
  186. width: 200,
  187. title: '管理者邮箱',
  188. sort: true
  189. }, {
  190. field: 'StoreType',
  191. width: 200,
  192. title: '仓库类型',
  193. sort: true
  194. }, {
  195. field: 'TotalNum',
  196. width: 200,
  197. title: '总库存数',
  198. sort: true
  199. }, {
  200. field: 'LaveNum',
  201. width: 200,
  202. title: '剩余库存数',
  203. sort: true
  204. }, {
  205. field: 'OutNum',
  206. width: 200,
  207. title: '出库数',
  208. sort: true
  209. }, {
  210. field: 'LimitTopUserId',
  211. width: 200,
  212. title: '限制创客特殊仓库',
  213. sort: true
  214. }, {
  215. field: 'StoreStatus',
  216. width: 200,
  217. title: '仓库状态',
  218. sort: true
  219. }, {
  220. field: 'StoreKind',
  221. width: 200,
  222. title: '仓库归属类型',
  223. sort: true
  224. }, {
  225. field: 'CreateMan',
  226. width: 200,
  227. title: '创建人',
  228. sort: true
  229. }, {
  230. field: 'CreateDate',
  231. width: 200,
  232. title: '创建时间',
  233. sort: true
  234. }
  235. , {
  236. field: 'Sort',
  237. fixed: 'right',
  238. title: '排序',
  239. width: 80,
  240. edit: 'text'
  241. }, {
  242. title: '操作',
  243. width: 300,
  244. align: 'center',
  245. fixed: 'right',
  246. toolbar: '#table-list-tools'
  247. }
  248. ]
  249. ],
  250. where: {
  251. },
  252. page: true,
  253. limit: 30,
  254. height: 'full-' + String($('.layui-card-header').height() + 130),
  255. text: '对不起,加载出现异常!',
  256. done: function (res, curr, count) {
  257. $(".layui-none").text("无数据");
  258. }
  259. });
  260. //监听工具条
  261. table.on('tool(LAY-list-manage)', function (obj) {
  262. var data = obj.data;
  263. if (obj.event === 'del') {
  264. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  265. $.ajax({
  266. type: "POST",
  267. url: "/Admin/StoreHouse/Delete?r=" + Math.random(1),
  268. data: "Id=" + data.Id,
  269. dataType: "text",
  270. success: function (data) {
  271. if (data == "success") {
  272. obj.del();
  273. layer.close(index);
  274. } else {
  275. parent.layer.msg(data);
  276. }
  277. }
  278. });
  279. });
  280. } else if (obj.event === 'sycn') {
  281. var index = layer.confirm('确定要同步该仓库的库存数据吗?', function (index) {
  282. layer.close(index);
  283. var loadindex = layer.load(1, {
  284. shade: [0.5, '#000']
  285. });
  286. $.ajax({
  287. type: "POST",
  288. url: "/Admin/StoreHouse/SycnData?r=" + Math.random(1),
  289. data: "Id=" + data.Id,
  290. dataType: "text",
  291. success: function (data) {
  292. layer.close(loadindex);
  293. if (data == "success") {
  294. layer.msg('同步成功');
  295. table.reload('LAY-list-manage');
  296. } else {
  297. layer.msg(data);
  298. }
  299. }
  300. });
  301. });
  302. } else if (obj.event === 'edit') {
  303. var tr = $(obj.tr);
  304. var perContent = layer.open({
  305. type: 2,
  306. title: '仓库-编辑',
  307. content: 'Edit?Id=' + data.Id + '',
  308. maxmin: true,
  309. area: ['800px', '650px'],
  310. btn: ['确定', '取消'],
  311. yes: function (index, layero) {
  312. var iframeWindow = window['layui-layer-iframe' + index],
  313. submitID = 'LAY-list-front-submit',
  314. submit = layero.find('iframe').contents().find('#' + submitID);
  315. setTimeout(function () {
  316. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  317. var errObj = $(this).find('.layui-form-danger');
  318. if (errObj.length > 0) {
  319. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  320. submit.click();
  321. }
  322. });
  323. }, 300);
  324. //监听提交
  325. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  326. var field = data.field; //获取提交的字段
  327. var userdata = "";
  328. for (var prop in field) {
  329. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  330. }
  331. //提交 Ajax 成功后,静态更新表格中的数据
  332. //$.ajax({});
  333. $.ajax({
  334. type: "POST",
  335. url: "/Admin/StoreHouse/Edit?r=" + Math.random(1),
  336. data: userdata,
  337. dataType: "text",
  338. success: function (data) {
  339. if (data == "success") {
  340. layer.close(index); //关闭弹层
  341. table.reload('LAY-list-manage'); //数据刷新
  342. } else {
  343. layer.msg(data);
  344. }
  345. }
  346. });
  347. });
  348. submit.trigger('click');
  349. },
  350. success: function (layero, index) {
  351. }
  352. });
  353. } else if (obj.event === 'edits') {
  354. var tr = $(obj.tr);
  355. var perContent = layer.open({
  356. type: 2,
  357. title: '一键新建仓库',
  358. content: 'Edits?Id=' + data.Id + '',
  359. maxmin: true,
  360. area: ['860px', '650px'],
  361. btn: ['确定', '取消'],
  362. yes: function (index, layero) {
  363. var iframeWindow = window['layui-layer-iframe' + index],
  364. submitID = 'LAY-list-front-submit',
  365. submit = layero.find('iframe').contents().find('#' + submitID);
  366. setTimeout(function () {
  367. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  368. var errObj = $(this).find('.layui-form-danger');
  369. if (errObj.length > 0) {
  370. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  371. submit.click();
  372. }
  373. });
  374. }, 300);
  375. //监听提交
  376. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  377. var field = data.field; //获取提交的字段
  378. var userdata = "";
  379. for (var prop in field) {
  380. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  381. }
  382. //提交 Ajax 成功后,静态更新表格中的数据
  383. //$.ajax({});
  384. $.ajax({
  385. type: "POST",
  386. url: "/Admin/StoreHouse/Edits?r=" + Math.random(1),
  387. data: userdata,
  388. dataType: "text",
  389. success: function (data) {
  390. if (data == "success") {
  391. layer.close(index); //关闭弹层
  392. table.reload('LAY-list-manage'); //数据刷新
  393. } else {
  394. layer.msg(data);
  395. }
  396. }
  397. });
  398. });
  399. submit.trigger('click');
  400. },
  401. success: function (layero, index) {
  402. }
  403. });
  404. }
  405. });
  406. //监听搜索
  407. form.on('submit(LAY-list-front-search)', function (data) {
  408. var field = data.field;
  409. //执行重载
  410. table.reload('LAY-list-manage', {
  411. where: field,
  412. page: {
  413. curr: 1
  414. }
  415. });
  416. });
  417. form.on('submit(LAY-list-front-searchall)', function (data) {
  418. table.reload('LAY-list-manage', {
  419. where: null,
  420. page: {
  421. curr: 1
  422. }
  423. });
  424. });
  425. //事件
  426. var active = {
  427. batchdel: function () {
  428. var checkStatus = table.checkStatus('LAY-list-manage'),
  429. data = checkStatus.data; //得到选中的数据
  430. if (data.length < 1) {
  431. parent.layer.msg("请选择要删除的项");
  432. } else {
  433. var ids = "";
  434. $.each(data, function (index, value) {
  435. ids += data[index].Id + ",";
  436. });
  437. ids = ids.substring(0, ids.length - 1);
  438. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  439. $.ajax({
  440. type: "POST",
  441. url: "/Admin/StoreHouse/Delete?r=" + Math.random(1),
  442. data: "Id=" + ids,
  443. dataType: "text",
  444. success: function (data) {
  445. layer.close(index);
  446. if (data == "success") {
  447. table.reload('LAY-list-manage');
  448. } else {
  449. layer.msg(data);
  450. }
  451. }
  452. });
  453. });
  454. }
  455. },
  456. add: function () {
  457. var perContent = layer.open({
  458. type: 2,
  459. title: '仓库-添加',
  460. content: 'Add',
  461. maxmin: true,
  462. area: ['950px', '650px'],
  463. btn: ['确定', '取消'],
  464. yes: function (index, layero) {
  465. var iframeWindow = window['layui-layer-iframe' + index],
  466. submitID = 'LAY-list-front-submit',
  467. submit = layero.find('iframe').contents().find('#' + submitID);
  468. setTimeout(function () {
  469. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  470. var errObj = $(this).find('.layui-form-danger');
  471. if (errObj.length > 0) {
  472. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  473. submit.click();
  474. }
  475. });
  476. }, 300);
  477. //监听提交
  478. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  479. var field = data.field; //获取提交的字段
  480. var userdata = "";
  481. for (var prop in field) {
  482. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  483. }
  484. //提交 Ajax 成功后,静态更新表格中的数据
  485. //$.ajax({});
  486. $.ajax({
  487. type: "POST",
  488. url: "/Admin/StoreHouse/Add?r=" + Math.random(1),
  489. data: userdata,
  490. dataType: "text",
  491. success: function (data) {
  492. if (data == "success") {
  493. layer.close(index); //关闭弹层
  494. table.reload('LAY-list-manage'); //数据刷新
  495. } else {
  496. layer.msg(data);
  497. }
  498. }
  499. });
  500. });
  501. submit.trigger('click');
  502. }
  503. });
  504. },
  505. ImportMachine: function () {
  506. var perContent = layer.open({
  507. type: 2,
  508. title: '机具入库',
  509. content: 'Import?ExcelKind=1',
  510. maxmin: true,
  511. area: ['650px', '350px'],
  512. btn: ['确定', '取消'],
  513. yes: function (index, layero) {
  514. var iframeWindow = window['layui-layer-iframe' + index],
  515. submitID = 'LAY-list-front-submit',
  516. submit = layero.find('iframe').contents().find('#' + submitID);
  517. //监听提交
  518. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  519. var field = data.field; //获取提交的字段
  520. var userdata = "";
  521. for (var prop in field) {
  522. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  523. }
  524. //提交 Ajax 成功后,静态更新表格中的数据
  525. //$.ajax({});
  526. var loadindex = layer.load(1, {
  527. shade: [0.5, '#000']
  528. });
  529. $.ajax({
  530. type: "POST",
  531. url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
  532. data: userdata,
  533. dataType: "text",
  534. success: function (data) {
  535. if (data.indexOf("success") == 0) {
  536. var datalist = data.split('|');
  537. var key = datalist[1];
  538. CheckImport(table, key, loadindex, index);
  539. } else {
  540. layer.msg(data);
  541. }
  542. }
  543. });
  544. });
  545. submit.trigger('click');
  546. }
  547. });
  548. },
  549. ImportChange: function () {
  550. var perContent = layer.open({
  551. type: 2,
  552. title: '仓库调拨',
  553. content: 'Import?ExcelKind=2',
  554. maxmin: true,
  555. area: ['650px', '350px'],
  556. btn: ['确定', '取消'],
  557. yes: function (index, layero) {
  558. var iframeWindow = window['layui-layer-iframe' + index],
  559. submitID = 'LAY-list-front-submit',
  560. submit = layero.find('iframe').contents().find('#' + submitID);
  561. //监听提交
  562. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  563. var field = data.field; //获取提交的字段
  564. var userdata = "";
  565. for (var prop in field) {
  566. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  567. }
  568. //提交 Ajax 成功后,静态更新表格中的数据
  569. //$.ajax({});
  570. var loadindex = layer.load(1, {
  571. shade: [0.5, '#000']
  572. });
  573. $.ajax({
  574. type: "POST",
  575. url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
  576. data: userdata,
  577. dataType: "text",
  578. success: function (data) {
  579. if (data.indexOf("success") == 0) {
  580. var datalist = data.split('|');
  581. var key = datalist[1];
  582. CheckImport(table, key, loadindex, index);
  583. } else {
  584. layer.msg(data);
  585. }
  586. }
  587. });
  588. });
  589. submit.trigger('click');
  590. }
  591. });
  592. },
  593. ImportSend: function () {
  594. var perContent = layer.open({
  595. type: 2,
  596. title: '仓库发货至创客',
  597. content: 'Import?ExcelKind=3',
  598. maxmin: true,
  599. area: ['650px', '350px'],
  600. btn: ['确定', '取消'],
  601. yes: function (index, layero) {
  602. var iframeWindow = window['layui-layer-iframe' + index],
  603. submitID = 'LAY-list-front-submit',
  604. submit = layero.find('iframe').contents().find('#' + submitID);
  605. //监听提交
  606. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  607. var field = data.field; //获取提交的字段
  608. var userdata = "";
  609. for (var prop in field) {
  610. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  611. }
  612. //提交 Ajax 成功后,静态更新表格中的数据
  613. //$.ajax({});
  614. var loadindex = layer.load(1, {
  615. shade: [0.5, '#000']
  616. });
  617. $.ajax({
  618. type: "POST",
  619. url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
  620. data: userdata,
  621. dataType: "text",
  622. success: function (data) {
  623. if (data.indexOf("success") == 0) {
  624. var datalist = data.split('|');
  625. var key = datalist[1];
  626. CheckImport(table, key, loadindex, index);
  627. } else {
  628. layer.msg(data);
  629. }
  630. }
  631. });
  632. });
  633. submit.trigger('click');
  634. }
  635. });
  636. },
  637. ImportBack: function () {
  638. var perContent = layer.open({
  639. type: 2,
  640. title: '机具回仓库',
  641. content: 'Import?ExcelKind=4',
  642. maxmin: true,
  643. area: ['650px', '350px'],
  644. btn: ['确定', '取消'],
  645. yes: function (index, layero) {
  646. var iframeWindow = window['layui-layer-iframe' + index],
  647. submitID = 'LAY-list-front-submit',
  648. submit = layero.find('iframe').contents().find('#' + submitID);
  649. //监听提交
  650. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  651. var field = data.field; //获取提交的字段
  652. var userdata = "";
  653. for (var prop in field) {
  654. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  655. }
  656. //提交 Ajax 成功后,静态更新表格中的数据
  657. //$.ajax({});
  658. var loadindex = layer.load(1, {
  659. shade: [0.5, '#000']
  660. });
  661. $.ajax({
  662. type: "POST",
  663. url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
  664. data: userdata,
  665. dataType: "text",
  666. success: function (data) {
  667. if (data.indexOf("success") == 0) {
  668. var datalist = data.split('|');
  669. var key = datalist[1];
  670. CheckImport(table, key, loadindex, index);
  671. } else {
  672. layer.msg(data);
  673. }
  674. }
  675. });
  676. });
  677. submit.trigger('click');
  678. }
  679. });
  680. },
  681. ExportExcel: function () {
  682. var userdata = '';
  683. $(".layuiadmin-card-header-auto input").each(function (i) {
  684. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  685. });
  686. $(".layuiadmin-card-header-auto select").each(function (i) {
  687. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  688. });
  689. $.ajax({
  690. type: "GET",
  691. url: "/Admin/StoreHouse/ExportExcel?r=" + Math.random(1),
  692. data: userdata,
  693. dataType: "json",
  694. success: function (data) {
  695. data.Obj.unshift(data.Fields);
  696. excel.exportExcel(data.Obj, data.Info, 'xlsx');
  697. }
  698. });
  699. },
  700. Open: function () {
  701. var checkStatus = table.checkStatus('LAY-list-manage'),
  702. data = checkStatus.data; //得到选中的数据
  703. if (data.length < 1) {
  704. parent.layer.msg("请选择要开启的项");
  705. } else {
  706. var ids = "";
  707. $.each(data, function (index, value) {
  708. ids += data[index].Id + ",";
  709. });
  710. ids = ids.substring(0, ids.length - 1);
  711. var index = layer.confirm('确定要开启吗?', function (index) {
  712. $.ajax({
  713. type: "POST",
  714. url: "/Admin/StoreHouse/Open?r=" + Math.random(1),
  715. data: "Id=" + ids,
  716. dataType: "text",
  717. success: function (data) {
  718. layer.close(index);
  719. if (data == "success") {
  720. table.reload('LAY-list-manage');
  721. } else {
  722. layer.msg(data);
  723. }
  724. }
  725. });
  726. });
  727. }
  728. },
  729. Close: function () {
  730. var checkStatus = table.checkStatus('LAY-list-manage'),
  731. data = checkStatus.data; //得到选中的数据
  732. if (data.length < 1) {
  733. parent.layer.msg("请选择要关闭的项");
  734. } else {
  735. var ids = "";
  736. $.each(data, function (index, value) {
  737. ids += data[index].Id + ",";
  738. });
  739. ids = ids.substring(0, ids.length - 1);
  740. var index = layer.confirm('确定要关闭吗?', function (index) {
  741. $.ajax({
  742. type: "POST",
  743. url: "/Admin/StoreHouse/Close?r=" + Math.random(1),
  744. data: "Id=" + ids,
  745. dataType: "text",
  746. success: function (data) {
  747. layer.close(index);
  748. if (data == "success") {
  749. table.reload('LAY-list-manage');
  750. } else {
  751. layer.msg(data);
  752. }
  753. }
  754. });
  755. });
  756. }
  757. },
  758. SycnData: function () {
  759. var index = layer.confirm('确定要同步所有仓库的库存数据吗?', function (index) {
  760. layer.close(index);
  761. var loadindex = layer.load(1, {
  762. shade: [0.5, '#000']
  763. });
  764. $.ajax({
  765. type: "POST",
  766. url: "/Admin/StoreHouse/SycnData?r=" + Math.random(1),
  767. data: "Id=0",
  768. dataType: "text",
  769. success: function (data) {
  770. layer.close(loadindex);
  771. if (data == "success") {
  772. layer.msg('同步成功');
  773. table.reload('LAY-list-manage');
  774. } else {
  775. layer.msg(data);
  776. }
  777. }
  778. });
  779. });
  780. },
  781. };
  782. $('.layui-btn').on('click', function () {
  783. var type = $(this).data('type');
  784. active[type] ? active[type].call(this) : '';
  785. });
  786. });