StoreHouse_Admin.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885
  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. title: '操作',
  271. width: 300,
  272. align: 'center',
  273. fixed: 'right',
  274. toolbar: '#table-list-tools'
  275. }
  276. ]
  277. ],
  278. where: {
  279. },
  280. page: true,
  281. limit: 30,
  282. height: 'full-' + String($('.layui-card-header').height() + 130),
  283. text: '对不起,加载出现异常!',
  284. done: function (res, curr, count) {
  285. $(".layui-none").text("无数据");
  286. }
  287. });
  288. //监听工具条
  289. table.on('tool(LAY-list-manage)', function (obj) {
  290. var data = obj.data;
  291. if (obj.event === 'del') {
  292. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  293. $.ajax({
  294. type: "POST",
  295. url: "/Admin/StoreHouse/Delete?r=" + Math.random(1),
  296. data: "Id=" + data.Id,
  297. dataType: "text",
  298. success: function (data) {
  299. if (data == "success") {
  300. obj.del();
  301. layer.close(index);
  302. } else {
  303. parent.layer.msg(data);
  304. }
  305. }
  306. });
  307. });
  308. } else if (obj.event === 'sycn') {
  309. var index = layer.confirm('确定要同步该仓库的库存数据吗?', function (index) {
  310. layer.close(index);
  311. var loadindex = layer.load(1, {
  312. shade: [0.5, '#000']
  313. });
  314. $.ajax({
  315. type: "POST",
  316. url: "/Admin/StoreHouse/SycnData?r=" + Math.random(1),
  317. data: "Id=" + data.Id,
  318. dataType: "text",
  319. success: function (data) {
  320. layer.close(loadindex);
  321. if (data == "success") {
  322. layer.msg('同步成功');
  323. table.reload('LAY-list-manage');
  324. } else {
  325. layer.msg(data);
  326. }
  327. }
  328. });
  329. });
  330. } else if (obj.event === 'edit') {
  331. var tr = $(obj.tr);
  332. var perContent = layer.open({
  333. type: 2,
  334. title: '仓库-编辑',
  335. content: 'Edit?Id=' + data.Id + '',
  336. maxmin: true,
  337. area: ['800px', '650px'],
  338. btn: ['确定', '取消'],
  339. yes: function (index, layero) {
  340. var iframeWindow = window['layui-layer-iframe' + index],
  341. submitID = 'LAY-list-front-submit',
  342. submit = layero.find('iframe').contents().find('#' + submitID);
  343. setTimeout(function () {
  344. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  345. var errObj = $(this).find('.layui-form-danger');
  346. if (errObj.length > 0) {
  347. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  348. submit.click();
  349. }
  350. });
  351. }, 300);
  352. //监听提交
  353. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  354. var field = data.field; //获取提交的字段
  355. var userdata = "";
  356. for (var prop in field) {
  357. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  358. }
  359. //提交 Ajax 成功后,静态更新表格中的数据
  360. //$.ajax({});
  361. $.ajax({
  362. type: "POST",
  363. url: "/Admin/StoreHouse/Edit?r=" + Math.random(1),
  364. data: userdata,
  365. dataType: "text",
  366. success: function (data) {
  367. if (data == "success") {
  368. layer.close(index); //关闭弹层
  369. table.reload('LAY-list-manage'); //数据刷新
  370. } else {
  371. layer.msg(data);
  372. }
  373. }
  374. });
  375. });
  376. submit.trigger('click');
  377. },
  378. success: function (layero, index) {
  379. }
  380. });
  381. } else if (obj.event === 'edits') {
  382. var tr = $(obj.tr);
  383. var perContent = layer.open({
  384. type: 2,
  385. title: '一键新建仓库',
  386. content: 'Edits?Id=' + data.Id + '',
  387. maxmin: true,
  388. area: ['860px', '650px'],
  389. btn: ['确定', '取消'],
  390. yes: function (index, layero) {
  391. var iframeWindow = window['layui-layer-iframe' + index],
  392. submitID = 'LAY-list-front-submit',
  393. submit = layero.find('iframe').contents().find('#' + submitID);
  394. setTimeout(function () {
  395. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  396. var errObj = $(this).find('.layui-form-danger');
  397. if (errObj.length > 0) {
  398. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  399. submit.click();
  400. }
  401. });
  402. }, 300);
  403. //监听提交
  404. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  405. var field = data.field; //获取提交的字段
  406. var userdata = "";
  407. for (var prop in field) {
  408. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  409. }
  410. //提交 Ajax 成功后,静态更新表格中的数据
  411. //$.ajax({});
  412. $.ajax({
  413. type: "POST",
  414. url: "/Admin/StoreHouse/Edits?r=" + Math.random(1),
  415. data: userdata,
  416. dataType: "text",
  417. success: function (data) {
  418. if (data == "success") {
  419. layer.close(index); //关闭弹层
  420. table.reload('LAY-list-manage'); //数据刷新
  421. } else {
  422. layer.msg(data);
  423. }
  424. }
  425. });
  426. });
  427. submit.trigger('click');
  428. },
  429. success: function (layero, index) {
  430. }
  431. });
  432. }
  433. });
  434. //监听搜索
  435. form.on('submit(LAY-list-front-search)', function (data) {
  436. var field = data.field;
  437. field.ShowFlag = 1;
  438. //执行重载
  439. table.reload('LAY-list-manage', {
  440. where: field,
  441. page: {
  442. curr: 1
  443. }
  444. });
  445. });
  446. form.on('submit(LAY-list-front-searchall)', function (data) {
  447. table.reload('LAY-list-manage', {
  448. where: null,
  449. page: {
  450. curr: 1
  451. }
  452. });
  453. });
  454. //事件
  455. var active = {
  456. batchdel: function () {
  457. var checkStatus = table.checkStatus('LAY-list-manage'),
  458. data = checkStatus.data; //得到选中的数据
  459. if (data.length < 1) {
  460. parent.layer.msg("请选择要删除的项");
  461. } else {
  462. var ids = "";
  463. $.each(data, function (index, value) {
  464. ids += data[index].Id + ",";
  465. });
  466. ids = ids.substring(0, ids.length - 1);
  467. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  468. $.ajax({
  469. type: "POST",
  470. url: "/Admin/StoreHouse/Delete?r=" + Math.random(1),
  471. data: "Id=" + ids,
  472. dataType: "text",
  473. success: function (data) {
  474. layer.close(index);
  475. if (data == "success") {
  476. table.reload('LAY-list-manage');
  477. } else {
  478. layer.msg(data);
  479. }
  480. }
  481. });
  482. });
  483. }
  484. },
  485. add: function () {
  486. var perContent = layer.open({
  487. type: 2,
  488. title: '仓库-添加',
  489. content: 'Add',
  490. maxmin: true,
  491. area: ['950px', '650px'],
  492. btn: ['确定', '取消'],
  493. yes: function (index, layero) {
  494. var iframeWindow = window['layui-layer-iframe' + index],
  495. submitID = 'LAY-list-front-submit',
  496. submit = layero.find('iframe').contents().find('#' + submitID);
  497. setTimeout(function () {
  498. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  499. var errObj = $(this).find('.layui-form-danger');
  500. if (errObj.length > 0) {
  501. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  502. submit.click();
  503. }
  504. });
  505. }, 300);
  506. //监听提交
  507. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  508. var field = data.field; //获取提交的字段
  509. var userdata = "";
  510. for (var prop in field) {
  511. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  512. }
  513. //提交 Ajax 成功后,静态更新表格中的数据
  514. //$.ajax({});
  515. $.ajax({
  516. type: "POST",
  517. url: "/Admin/StoreHouse/Add?r=" + Math.random(1),
  518. data: userdata,
  519. dataType: "text",
  520. success: function (data) {
  521. if (data == "success") {
  522. layer.close(index); //关闭弹层
  523. table.reload('LAY-list-manage'); //数据刷新
  524. } else {
  525. layer.msg(data);
  526. }
  527. }
  528. });
  529. });
  530. submit.trigger('click');
  531. }
  532. });
  533. },
  534. ImportMachine: function () {
  535. var perContent = layer.open({
  536. type: 2,
  537. title: '机具入库',
  538. content: 'Import?ExcelKind=1',
  539. maxmin: true,
  540. area: ['650px', '350px'],
  541. btn: ['确定', '取消'],
  542. yes: function (index, layero) {
  543. var iframeWindow = window['layui-layer-iframe' + index],
  544. submitID = 'LAY-list-front-submit',
  545. submit = layero.find('iframe').contents().find('#' + submitID);
  546. //监听提交
  547. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  548. var field = data.field; //获取提交的字段
  549. var userdata = "";
  550. for (var prop in field) {
  551. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  552. }
  553. //提交 Ajax 成功后,静态更新表格中的数据
  554. //$.ajax({});
  555. var loadindex = layer.load(1, {
  556. shade: [0.5, '#000']
  557. });
  558. $.ajax({
  559. type: "POST",
  560. url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
  561. data: userdata,
  562. dataType: "text",
  563. success: function (data) {
  564. if (data.indexOf("success") == 0) {
  565. var datalist = data.split('|');
  566. var key = datalist[1];
  567. CheckImport(table, key, loadindex, index);
  568. } else {
  569. layer.msg(data);
  570. }
  571. }
  572. });
  573. });
  574. submit.trigger('click');
  575. }
  576. });
  577. },
  578. ImportChange: function () {
  579. var perContent = layer.open({
  580. type: 2,
  581. title: '仓库调拨',
  582. content: 'Import?ExcelKind=2',
  583. maxmin: true,
  584. area: ['650px', '350px'],
  585. btn: ['确定', '取消'],
  586. yes: function (index, layero) {
  587. var iframeWindow = window['layui-layer-iframe' + index],
  588. submitID = 'LAY-list-front-submit',
  589. submit = layero.find('iframe').contents().find('#' + submitID);
  590. //监听提交
  591. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  592. var field = data.field; //获取提交的字段
  593. var userdata = "";
  594. for (var prop in field) {
  595. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  596. }
  597. //提交 Ajax 成功后,静态更新表格中的数据
  598. //$.ajax({});
  599. var loadindex = layer.load(1, {
  600. shade: [0.5, '#000']
  601. });
  602. $.ajax({
  603. type: "POST",
  604. url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
  605. data: userdata,
  606. dataType: "text",
  607. success: function (data) {
  608. if (data.indexOf("success") == 0) {
  609. var datalist = data.split('|');
  610. var key = datalist[1];
  611. CheckImport(table, key, loadindex, index);
  612. } else {
  613. layer.msg(data);
  614. }
  615. }
  616. });
  617. });
  618. submit.trigger('click');
  619. }
  620. });
  621. },
  622. ImportSend: function () {
  623. var perContent = layer.open({
  624. type: 2,
  625. title: '仓库发货至创客',
  626. content: 'Import?ExcelKind=3',
  627. maxmin: true,
  628. area: ['650px', '350px'],
  629. btn: ['确定', '取消'],
  630. yes: function (index, layero) {
  631. var iframeWindow = window['layui-layer-iframe' + index],
  632. submitID = 'LAY-list-front-submit',
  633. submit = layero.find('iframe').contents().find('#' + submitID);
  634. //监听提交
  635. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  636. var field = data.field; //获取提交的字段
  637. var userdata = "";
  638. for (var prop in field) {
  639. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  640. }
  641. //提交 Ajax 成功后,静态更新表格中的数据
  642. //$.ajax({});
  643. var loadindex = layer.load(1, {
  644. shade: [0.5, '#000']
  645. });
  646. $.ajax({
  647. type: "POST",
  648. url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
  649. data: userdata,
  650. dataType: "text",
  651. success: function (data) {
  652. if (data.indexOf("success") == 0) {
  653. var datalist = data.split('|');
  654. var key = datalist[1];
  655. CheckImport(table, key, loadindex, index);
  656. } else {
  657. layer.msg(data);
  658. }
  659. }
  660. });
  661. });
  662. submit.trigger('click');
  663. }
  664. });
  665. },
  666. ImportBack: function () {
  667. var perContent = layer.open({
  668. type: 2,
  669. title: '机具回仓库',
  670. content: 'Import?ExcelKind=4',
  671. maxmin: true,
  672. area: ['650px', '350px'],
  673. btn: ['确定', '取消'],
  674. yes: function (index, layero) {
  675. var iframeWindow = window['layui-layer-iframe' + index],
  676. submitID = 'LAY-list-front-submit',
  677. submit = layero.find('iframe').contents().find('#' + submitID);
  678. //监听提交
  679. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  680. var field = data.field; //获取提交的字段
  681. var userdata = "";
  682. for (var prop in field) {
  683. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  684. }
  685. //提交 Ajax 成功后,静态更新表格中的数据
  686. //$.ajax({});
  687. var loadindex = layer.load(1, {
  688. shade: [0.5, '#000']
  689. });
  690. $.ajax({
  691. type: "POST",
  692. url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
  693. data: userdata,
  694. dataType: "text",
  695. success: function (data) {
  696. if (data.indexOf("success") == 0) {
  697. var datalist = data.split('|');
  698. var key = datalist[1];
  699. CheckImport(table, key, loadindex, index);
  700. } else {
  701. layer.msg(data);
  702. }
  703. }
  704. });
  705. });
  706. submit.trigger('click');
  707. }
  708. });
  709. }, ImportRejectStore: function () {
  710. ExcelKind = 1;
  711. layer.open({
  712. type: 1,
  713. title: '导入',
  714. maxmin: false,
  715. area: ['650px', '350px'],
  716. // btn: ['确定', '取消'],
  717. content: $('#excelForm'),
  718. cancel: function () {
  719. }
  720. });
  721. $("#excelTemp").html('<a href="/users/创客机具驳回仓库模版.xlsx">点击下载创客机具驳回仓库模版</a>');
  722. },
  723. ExportExcel: function () {
  724. var userdata = '';
  725. $(".layuiadmin-card-header-auto input").each(function (i) {
  726. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  727. });
  728. $(".layuiadmin-card-header-auto select").each(function (i) {
  729. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  730. });
  731. $.ajax({
  732. type: "GET",
  733. url: "/Admin/StoreHouse/ExportExcel?r=" + Math.random(1),
  734. data: userdata,
  735. dataType: "json",
  736. success: function (data) {
  737. data.Obj.unshift(data.Fields);
  738. excel.exportExcel(data.Obj, data.Info, 'xlsx');
  739. }
  740. });
  741. },
  742. Open: function () {
  743. var checkStatus = table.checkStatus('LAY-list-manage'),
  744. data = checkStatus.data; //得到选中的数据
  745. if (data.length < 1) {
  746. parent.layer.msg("请选择要开启的项");
  747. } else {
  748. var ids = "";
  749. $.each(data, function (index, value) {
  750. ids += data[index].Id + ",";
  751. });
  752. ids = ids.substring(0, ids.length - 1);
  753. var index = layer.confirm('确定要开启吗?', function (index) {
  754. $.ajax({
  755. type: "POST",
  756. url: "/Admin/StoreHouse/Open?r=" + Math.random(1),
  757. data: "Id=" + ids,
  758. dataType: "text",
  759. success: function (data) {
  760. layer.close(index);
  761. if (data == "success") {
  762. table.reload('LAY-list-manage');
  763. } else {
  764. layer.msg(data);
  765. }
  766. }
  767. });
  768. });
  769. }
  770. },
  771. Close: function () {
  772. var checkStatus = table.checkStatus('LAY-list-manage'),
  773. data = checkStatus.data; //得到选中的数据
  774. if (data.length < 1) {
  775. parent.layer.msg("请选择要关闭的项");
  776. } else {
  777. var ids = "";
  778. $.each(data, function (index, value) {
  779. ids += data[index].Id + ",";
  780. });
  781. ids = ids.substring(0, ids.length - 1);
  782. var index = layer.confirm('确定要关闭吗?', function (index) {
  783. $.ajax({
  784. type: "POST",
  785. url: "/Admin/StoreHouse/Close?r=" + Math.random(1),
  786. data: "Id=" + ids,
  787. dataType: "text",
  788. success: function (data) {
  789. layer.close(index);
  790. if (data == "success") {
  791. table.reload('LAY-list-manage');
  792. } else {
  793. layer.msg(data);
  794. }
  795. }
  796. });
  797. });
  798. }
  799. },
  800. SycnData: function () {
  801. var index = layer.confirm('确定要同步所有仓库的库存数据吗?', function (index) {
  802. layer.close(index);
  803. var loadindex = layer.load(1, {
  804. shade: [0.5, '#000']
  805. });
  806. $.ajax({
  807. type: "POST",
  808. url: "/Admin/StoreHouse/SycnData?r=" + Math.random(1),
  809. data: "Id=0",
  810. dataType: "text",
  811. success: function (data) {
  812. layer.close(loadindex);
  813. if (data == "success") {
  814. layer.msg('同步成功');
  815. table.reload('LAY-list-manage');
  816. } else {
  817. layer.msg(data);
  818. }
  819. }
  820. });
  821. });
  822. },
  823. };
  824. $('.layui-btn').on('click', function () {
  825. var type = $(this).data('type');
  826. active[type] ? active[type].call(this) : '';
  827. });
  828. });