StoreHouse_Admin.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884
  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. //执行重载
  438. table.reload('LAY-list-manage', {
  439. where: field,
  440. page: {
  441. curr: 1
  442. }
  443. });
  444. });
  445. form.on('submit(LAY-list-front-searchall)', function (data) {
  446. table.reload('LAY-list-manage', {
  447. where: null,
  448. page: {
  449. curr: 1
  450. }
  451. });
  452. });
  453. //事件
  454. var active = {
  455. batchdel: function () {
  456. var checkStatus = table.checkStatus('LAY-list-manage'),
  457. data = checkStatus.data; //得到选中的数据
  458. if (data.length < 1) {
  459. parent.layer.msg("请选择要删除的项");
  460. } else {
  461. var ids = "";
  462. $.each(data, function (index, value) {
  463. ids += data[index].Id + ",";
  464. });
  465. ids = ids.substring(0, ids.length - 1);
  466. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  467. $.ajax({
  468. type: "POST",
  469. url: "/Admin/StoreHouse/Delete?r=" + Math.random(1),
  470. data: "Id=" + ids,
  471. dataType: "text",
  472. success: function (data) {
  473. layer.close(index);
  474. if (data == "success") {
  475. table.reload('LAY-list-manage');
  476. } else {
  477. layer.msg(data);
  478. }
  479. }
  480. });
  481. });
  482. }
  483. },
  484. add: function () {
  485. var perContent = layer.open({
  486. type: 2,
  487. title: '仓库-添加',
  488. content: 'Add',
  489. maxmin: true,
  490. area: ['950px', '650px'],
  491. btn: ['确定', '取消'],
  492. yes: function (index, layero) {
  493. var iframeWindow = window['layui-layer-iframe' + index],
  494. submitID = 'LAY-list-front-submit',
  495. submit = layero.find('iframe').contents().find('#' + submitID);
  496. setTimeout(function () {
  497. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  498. var errObj = $(this).find('.layui-form-danger');
  499. if (errObj.length > 0) {
  500. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  501. submit.click();
  502. }
  503. });
  504. }, 300);
  505. //监听提交
  506. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  507. var field = data.field; //获取提交的字段
  508. var userdata = "";
  509. for (var prop in field) {
  510. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  511. }
  512. //提交 Ajax 成功后,静态更新表格中的数据
  513. //$.ajax({});
  514. $.ajax({
  515. type: "POST",
  516. url: "/Admin/StoreHouse/Add?r=" + Math.random(1),
  517. data: userdata,
  518. dataType: "text",
  519. success: function (data) {
  520. if (data == "success") {
  521. layer.close(index); //关闭弹层
  522. table.reload('LAY-list-manage'); //数据刷新
  523. } else {
  524. layer.msg(data);
  525. }
  526. }
  527. });
  528. });
  529. submit.trigger('click');
  530. }
  531. });
  532. },
  533. ImportMachine: function () {
  534. var perContent = layer.open({
  535. type: 2,
  536. title: '机具入库',
  537. content: 'Import?ExcelKind=1',
  538. maxmin: true,
  539. area: ['650px', '350px'],
  540. btn: ['确定', '取消'],
  541. yes: function (index, layero) {
  542. var iframeWindow = window['layui-layer-iframe' + index],
  543. submitID = 'LAY-list-front-submit',
  544. submit = layero.find('iframe').contents().find('#' + submitID);
  545. //监听提交
  546. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  547. var field = data.field; //获取提交的字段
  548. var userdata = "";
  549. for (var prop in field) {
  550. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  551. }
  552. //提交 Ajax 成功后,静态更新表格中的数据
  553. //$.ajax({});
  554. var loadindex = layer.load(1, {
  555. shade: [0.5, '#000']
  556. });
  557. $.ajax({
  558. type: "POST",
  559. url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
  560. data: userdata,
  561. dataType: "text",
  562. success: function (data) {
  563. if (data.indexOf("success") == 0) {
  564. var datalist = data.split('|');
  565. var key = datalist[1];
  566. CheckImport(table, key, loadindex, index);
  567. } else {
  568. layer.msg(data);
  569. }
  570. }
  571. });
  572. });
  573. submit.trigger('click');
  574. }
  575. });
  576. },
  577. ImportChange: function () {
  578. var perContent = layer.open({
  579. type: 2,
  580. title: '仓库调拨',
  581. content: 'Import?ExcelKind=2',
  582. maxmin: true,
  583. area: ['650px', '350px'],
  584. btn: ['确定', '取消'],
  585. yes: function (index, layero) {
  586. var iframeWindow = window['layui-layer-iframe' + index],
  587. submitID = 'LAY-list-front-submit',
  588. submit = layero.find('iframe').contents().find('#' + submitID);
  589. //监听提交
  590. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  591. var field = data.field; //获取提交的字段
  592. var userdata = "";
  593. for (var prop in field) {
  594. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  595. }
  596. //提交 Ajax 成功后,静态更新表格中的数据
  597. //$.ajax({});
  598. var loadindex = layer.load(1, {
  599. shade: [0.5, '#000']
  600. });
  601. $.ajax({
  602. type: "POST",
  603. url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
  604. data: userdata,
  605. dataType: "text",
  606. success: function (data) {
  607. if (data.indexOf("success") == 0) {
  608. var datalist = data.split('|');
  609. var key = datalist[1];
  610. CheckImport(table, key, loadindex, index);
  611. } else {
  612. layer.msg(data);
  613. }
  614. }
  615. });
  616. });
  617. submit.trigger('click');
  618. }
  619. });
  620. },
  621. ImportSend: function () {
  622. var perContent = layer.open({
  623. type: 2,
  624. title: '仓库发货至创客',
  625. content: 'Import?ExcelKind=3',
  626. maxmin: true,
  627. area: ['650px', '350px'],
  628. btn: ['确定', '取消'],
  629. yes: function (index, layero) {
  630. var iframeWindow = window['layui-layer-iframe' + index],
  631. submitID = 'LAY-list-front-submit',
  632. submit = layero.find('iframe').contents().find('#' + submitID);
  633. //监听提交
  634. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  635. var field = data.field; //获取提交的字段
  636. var userdata = "";
  637. for (var prop in field) {
  638. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  639. }
  640. //提交 Ajax 成功后,静态更新表格中的数据
  641. //$.ajax({});
  642. var loadindex = layer.load(1, {
  643. shade: [0.5, '#000']
  644. });
  645. $.ajax({
  646. type: "POST",
  647. url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
  648. data: userdata,
  649. dataType: "text",
  650. success: function (data) {
  651. if (data.indexOf("success") == 0) {
  652. var datalist = data.split('|');
  653. var key = datalist[1];
  654. CheckImport(table, key, loadindex, index);
  655. } else {
  656. layer.msg(data);
  657. }
  658. }
  659. });
  660. });
  661. submit.trigger('click');
  662. }
  663. });
  664. },
  665. ImportBack: function () {
  666. var perContent = layer.open({
  667. type: 2,
  668. title: '机具回仓库',
  669. content: 'Import?ExcelKind=4',
  670. maxmin: true,
  671. area: ['650px', '350px'],
  672. btn: ['确定', '取消'],
  673. yes: function (index, layero) {
  674. var iframeWindow = window['layui-layer-iframe' + index],
  675. submitID = 'LAY-list-front-submit',
  676. submit = layero.find('iframe').contents().find('#' + submitID);
  677. //监听提交
  678. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  679. var field = data.field; //获取提交的字段
  680. var userdata = "";
  681. for (var prop in field) {
  682. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  683. }
  684. //提交 Ajax 成功后,静态更新表格中的数据
  685. //$.ajax({});
  686. var loadindex = layer.load(1, {
  687. shade: [0.5, '#000']
  688. });
  689. $.ajax({
  690. type: "POST",
  691. url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
  692. data: userdata,
  693. dataType: "text",
  694. success: function (data) {
  695. if (data.indexOf("success") == 0) {
  696. var datalist = data.split('|');
  697. var key = datalist[1];
  698. CheckImport(table, key, loadindex, index);
  699. } else {
  700. layer.msg(data);
  701. }
  702. }
  703. });
  704. });
  705. submit.trigger('click');
  706. }
  707. });
  708. }, ImportRejectStore: function () {
  709. ExcelKind = 1;
  710. layer.open({
  711. type: 1,
  712. title: '导入',
  713. maxmin: false,
  714. area: ['650px', '350px'],
  715. // btn: ['确定', '取消'],
  716. content: $('#excelForm'),
  717. cancel: function () {
  718. }
  719. });
  720. $("#excelTemp").html('<a href="/users/创客机具驳回仓库模版.xlsx">点击下载创客机具驳回仓库模版</a>');
  721. },
  722. ExportExcel: function () {
  723. var userdata = '';
  724. $(".layuiadmin-card-header-auto input").each(function (i) {
  725. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  726. });
  727. $(".layuiadmin-card-header-auto select").each(function (i) {
  728. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  729. });
  730. $.ajax({
  731. type: "GET",
  732. url: "/Admin/StoreHouse/ExportExcel?r=" + Math.random(1),
  733. data: userdata,
  734. dataType: "json",
  735. success: function (data) {
  736. data.Obj.unshift(data.Fields);
  737. excel.exportExcel(data.Obj, data.Info, 'xlsx');
  738. }
  739. });
  740. },
  741. Open: function () {
  742. var checkStatus = table.checkStatus('LAY-list-manage'),
  743. data = checkStatus.data; //得到选中的数据
  744. if (data.length < 1) {
  745. parent.layer.msg("请选择要开启的项");
  746. } else {
  747. var ids = "";
  748. $.each(data, function (index, value) {
  749. ids += data[index].Id + ",";
  750. });
  751. ids = ids.substring(0, ids.length - 1);
  752. var index = layer.confirm('确定要开启吗?', function (index) {
  753. $.ajax({
  754. type: "POST",
  755. url: "/Admin/StoreHouse/Open?r=" + Math.random(1),
  756. data: "Id=" + ids,
  757. dataType: "text",
  758. success: function (data) {
  759. layer.close(index);
  760. if (data == "success") {
  761. table.reload('LAY-list-manage');
  762. } else {
  763. layer.msg(data);
  764. }
  765. }
  766. });
  767. });
  768. }
  769. },
  770. Close: function () {
  771. var checkStatus = table.checkStatus('LAY-list-manage'),
  772. data = checkStatus.data; //得到选中的数据
  773. if (data.length < 1) {
  774. parent.layer.msg("请选择要关闭的项");
  775. } else {
  776. var ids = "";
  777. $.each(data, function (index, value) {
  778. ids += data[index].Id + ",";
  779. });
  780. ids = ids.substring(0, ids.length - 1);
  781. var index = layer.confirm('确定要关闭吗?', function (index) {
  782. $.ajax({
  783. type: "POST",
  784. url: "/Admin/StoreHouse/Close?r=" + Math.random(1),
  785. data: "Id=" + ids,
  786. dataType: "text",
  787. success: function (data) {
  788. layer.close(index);
  789. if (data == "success") {
  790. table.reload('LAY-list-manage');
  791. } else {
  792. layer.msg(data);
  793. }
  794. }
  795. });
  796. });
  797. }
  798. },
  799. SycnData: function () {
  800. var index = layer.confirm('确定要同步所有仓库的库存数据吗?', function (index) {
  801. layer.close(index);
  802. var loadindex = layer.load(1, {
  803. shade: [0.5, '#000']
  804. });
  805. $.ajax({
  806. type: "POST",
  807. url: "/Admin/StoreHouse/SycnData?r=" + Math.random(1),
  808. data: "Id=0",
  809. dataType: "text",
  810. success: function (data) {
  811. layer.close(loadindex);
  812. if (data == "success") {
  813. layer.msg('同步成功');
  814. table.reload('LAY-list-manage');
  815. } else {
  816. layer.msg(data);
  817. }
  818. }
  819. });
  820. });
  821. },
  822. };
  823. $('.layui-btn').on('click', function () {
  824. var type = $(this).data('type');
  825. active[type] ? active[type].call(this) : '';
  826. });
  827. });