StoreHouse_Admin.js 34 KB

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