StoreHouse_Admin.js 45 KB

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