StoreHouse_Admin.js 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059
  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: 'Status',
  236. width: 110,
  237. title: '仓库状态',
  238. sort: true
  239. }, {
  240. field: 'OpIdStatus',
  241. width: 130,
  242. title: '关联运营中心',
  243. sort: true
  244. },{
  245. field: 'StoreKind',
  246. width: 130,
  247. title: '仓库归属类型',
  248. sort: true
  249. }, {
  250. field: 'CreateMan',
  251. width: 130,
  252. title: '创建/修改人',
  253. sort: true
  254. }, {
  255. field: 'CreateDate',
  256. width: 110,
  257. title: '创建时间',
  258. sort: true
  259. }, {
  260. field: 'Deposit',
  261. width: 110,
  262. title: '押金',
  263. sort: true
  264. }, {
  265. field: 'ValidAmount',
  266. width: 110,
  267. title: '可用额度',
  268. sort: true
  269. }, {
  270. field: 'FixedAmount',
  271. width: 110,
  272. title: '固定额度',
  273. sort: true
  274. }, {
  275. field: 'TempAmount',
  276. width: 110,
  277. title: '临时额度',
  278. sort: true
  279. }, {
  280. field: 'PromissAmount',
  281. width: 110,
  282. title: '担保额度',
  283. sort: true
  284. }, {
  285. field: 'ThisMonthPreAmount',
  286. width: 150,
  287. title: '本月小分仓额度',
  288. sort: true
  289. }, {
  290. field: 'ValidPreAmount',
  291. width: 150,
  292. title: '可用小分仓额度',
  293. sort: true
  294. }, {
  295. title: '操作',
  296. width: 300,
  297. align: 'center',
  298. fixed: 'right',
  299. toolbar: '#table-list-tools'
  300. }
  301. ]
  302. ],
  303. where: {
  304. },
  305. page: true,
  306. limit: 30,
  307. height: 'full-' + String($('.layui-card-header').height() + 130),
  308. text: '对不起,加载出现异常!',
  309. done: function (res, curr, count) {
  310. $(".layui-none").text("无数据");
  311. }
  312. });
  313. //监听工具条
  314. table.on('tool(LAY-list-manage)', function (obj) {
  315. var data = obj.data;
  316. if (obj.event === 'del') {
  317. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  318. $.ajax({
  319. type: "POST",
  320. url: "/Admin/StoreHouse/Delete?r=" + Math.random(1),
  321. data: "Id=" + data.Id,
  322. dataType: "text",
  323. success: function (data) {
  324. if (data == "success") {
  325. obj.del();
  326. layer.close(index);
  327. } else {
  328. parent.layer.msg(data);
  329. }
  330. }
  331. });
  332. });
  333. } else if (obj.event === 'sycn') {
  334. var index = layer.confirm('确定要同步该仓库的库存数据吗?', function (index) {
  335. layer.close(index);
  336. var loadindex = layer.load(1, {
  337. shade: [0.5, '#000']
  338. });
  339. $.ajax({
  340. type: "POST",
  341. url: "/Admin/StoreHouse/SycnData?r=" + Math.random(1),
  342. data: "Id=" + data.Id,
  343. dataType: "text",
  344. success: function (data) {
  345. layer.close(loadindex);
  346. if (data == "success") {
  347. layer.msg('同步成功');
  348. table.reload('LAY-list-manage');
  349. } else {
  350. layer.msg(data);
  351. }
  352. }
  353. });
  354. });
  355. } else if (obj.event === 'edit') {
  356. var tr = $(obj.tr);
  357. var perContent = layer.open({
  358. type: 2,
  359. title: '仓库-编辑',
  360. content: 'Edit?Id=' + data.Id + '',
  361. maxmin: true,
  362. area: ['800px', '650px'],
  363. btn: ['确定', '取消'],
  364. yes: function (index, layero) {
  365. var iframeWindow = window['layui-layer-iframe' + index],
  366. submitID = 'LAY-list-front-submit',
  367. submit = layero.find('iframe').contents().find('#' + submitID);
  368. setTimeout(function () {
  369. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  370. var errObj = $(this).find('.layui-form-danger');
  371. if (errObj.length > 0) {
  372. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  373. submit.click();
  374. }
  375. });
  376. }, 300);
  377. //监听提交
  378. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  379. var field = data.field; //获取提交的字段
  380. var userdata = "";
  381. for (var prop in field) {
  382. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  383. }
  384. //提交 Ajax 成功后,静态更新表格中的数据
  385. //$.ajax({});
  386. $.ajax({
  387. type: "POST",
  388. url: "/Admin/StoreHouse/Edit?r=" + Math.random(1),
  389. data: userdata,
  390. dataType: "text",
  391. success: function (data) {
  392. if (data == "success") {
  393. layer.close(index); //关闭弹层
  394. table.reload('LAY-list-manage'); //数据刷新
  395. } else {
  396. layer.msg(data);
  397. }
  398. }
  399. });
  400. });
  401. submit.trigger('click');
  402. },
  403. success: function (layero, index) {
  404. }
  405. });
  406. } else if (obj.event === 'edits') {
  407. var tr = $(obj.tr);
  408. var perContent = layer.open({
  409. type: 2,
  410. title: '一键新建仓库',
  411. content: 'Edits?Id=' + data.Id + '',
  412. maxmin: true,
  413. area: ['860px', '650px'],
  414. btn: ['确定', '取消'],
  415. yes: function (index, layero) {
  416. var iframeWindow = window['layui-layer-iframe' + index],
  417. submitID = 'LAY-list-front-submit',
  418. submit = layero.find('iframe').contents().find('#' + submitID);
  419. setTimeout(function () {
  420. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  421. var errObj = $(this).find('.layui-form-danger');
  422. if (errObj.length > 0) {
  423. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  424. submit.click();
  425. }
  426. });
  427. }, 300);
  428. //监听提交
  429. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  430. var field = data.field; //获取提交的字段
  431. var userdata = "";
  432. for (var prop in field) {
  433. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  434. }
  435. //提交 Ajax 成功后,静态更新表格中的数据
  436. //$.ajax({});
  437. $.ajax({
  438. type: "POST",
  439. url: "/Admin/StoreHouse/Edits?r=" + Math.random(1),
  440. data: userdata,
  441. dataType: "text",
  442. success: function (data) {
  443. if (data == "success") {
  444. layer.close(index); //关闭弹层
  445. table.reload('LAY-list-manage'); //数据刷新
  446. } else {
  447. layer.msg(data);
  448. }
  449. }
  450. });
  451. });
  452. submit.trigger('click');
  453. },
  454. success: function (layero, index) {
  455. }
  456. });
  457. }
  458. });
  459. //监听搜索
  460. form.on('submit(LAY-list-front-search)', function (data) {
  461. var field = data.field;
  462. field.ShowFlag = 1;
  463. if (field.StoreNo == "" && field.StoreName == "" && field.UserIdMakerCode == "" && field.UserIdRealName == "" && field.ManageUserIdRealName == "" && field.ManageUserIdMobile == "" && field.ManageUserIdMakerCode == "" && field.ManagerEmail == "" && field.StoreStatusSelect == "" && field.CreateDateData == "" && field.MakerCode == "") {
  464. layer.alert('请输入查询条件');
  465. }
  466. else {
  467. //执行重载
  468. table.reload('LAY-list-manage', {
  469. where: field,
  470. page: {
  471. curr: 1
  472. }
  473. });
  474. }
  475. });
  476. form.on('submit(LAY-list-front-searchall)', function (data) {
  477. var field = data.field;
  478. field.ShowFlag = 1;
  479. field.StoreNo = "";
  480. field.StoreName = "";
  481. field.ManagerEmail = "";
  482. field.UserIdMakerCode = "";
  483. field.UserIdRealName = "";
  484. field.ManageUserIdRealName = "";
  485. field.ManageUserIdMobile = "";
  486. field.ManageUserIdMakerCode = "";
  487. field.StoreStatusSelect = "";
  488. field.CreateDateData = "";
  489. table.reload('LAY-list-manage', {
  490. where: field,
  491. page: {
  492. curr: 1
  493. }
  494. });
  495. });
  496. //事件
  497. var active = {
  498. batchdel: function () {
  499. var checkStatus = table.checkStatus('LAY-list-manage'),
  500. data = checkStatus.data; //得到选中的数据
  501. if (data.length < 1) {
  502. parent.layer.msg("请选择要删除的项");
  503. } else {
  504. var ids = "";
  505. $.each(data, function (index, value) {
  506. ids += data[index].Id + ",";
  507. });
  508. ids = ids.substring(0, ids.length - 1);
  509. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  510. $.ajax({
  511. type: "POST",
  512. url: "/Admin/StoreHouse/Delete?r=" + Math.random(1),
  513. data: "Id=" + ids,
  514. dataType: "text",
  515. success: function (data) {
  516. layer.close(index);
  517. if (data == "success") {
  518. table.reload('LAY-list-manage');
  519. } else {
  520. layer.msg(data);
  521. }
  522. }
  523. });
  524. });
  525. }
  526. },
  527. add: function () {
  528. var perContent = layer.open({
  529. type: 2,
  530. title: '仓库-添加',
  531. content: 'Add',
  532. maxmin: true,
  533. area: ['950px', '650px'],
  534. btn: ['确定', '取消'],
  535. yes: function (index, layero) {
  536. var iframeWindow = window['layui-layer-iframe' + index],
  537. submitID = 'LAY-list-front-submit',
  538. submit = layero.find('iframe').contents().find('#' + submitID);
  539. setTimeout(function () {
  540. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  541. var errObj = $(this).find('.layui-form-danger');
  542. if (errObj.length > 0) {
  543. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  544. submit.click();
  545. }
  546. });
  547. }, 300);
  548. //监听提交
  549. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  550. var field = data.field; //获取提交的字段
  551. var userdata = "";
  552. for (var prop in field) {
  553. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  554. }
  555. //提交 Ajax 成功后,静态更新表格中的数据
  556. //$.ajax({});
  557. $.ajax({
  558. type: "POST",
  559. url: "/Admin/StoreHouse/Add?r=" + Math.random(1),
  560. data: userdata,
  561. dataType: "text",
  562. success: function (data) {
  563. if (data == "success") {
  564. layer.close(index); //关闭弹层
  565. table.reload('LAY-list-manage'); //数据刷新
  566. } else {
  567. layer.msg(data);
  568. }
  569. }
  570. });
  571. });
  572. submit.trigger('click');
  573. }
  574. });
  575. },
  576. ImportMachine: function () {
  577. var perContent = layer.open({
  578. type: 2,
  579. title: '机具入库',
  580. content: 'Import?ExcelKind=1',
  581. maxmin: true,
  582. area: ['650px', '350px'],
  583. btn: ['确定', '取消'],
  584. yes: function (index, layero) {
  585. var iframeWindow = window['layui-layer-iframe' + index],
  586. submitID = 'LAY-list-front-submit',
  587. submit = layero.find('iframe').contents().find('#' + submitID);
  588. //监听提交
  589. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  590. var field = data.field; //获取提交的字段
  591. var userdata = "";
  592. for (var prop in field) {
  593. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  594. }
  595. //提交 Ajax 成功后,静态更新表格中的数据
  596. //$.ajax({});
  597. var loadindex = layer.load(1, {
  598. shade: [0.5, '#000']
  599. });
  600. $.ajax({
  601. type: "POST",
  602. url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
  603. data: userdata,
  604. dataType: "text",
  605. success: function (data) {
  606. if (data.indexOf("success") == 0) {
  607. var datalist = data.split('|');
  608. var key = datalist[1];
  609. CheckImport(table, key, loadindex, index);
  610. } else {
  611. layer.msg(data);
  612. }
  613. }
  614. });
  615. });
  616. submit.trigger('click');
  617. }
  618. });
  619. },
  620. ImportChange: function () {
  621. var perContent = layer.open({
  622. type: 2,
  623. title: '仓库调拨',
  624. content: 'Import?ExcelKind=2',
  625. maxmin: true,
  626. area: ['650px', '350px'],
  627. btn: ['确定', '取消'],
  628. yes: function (index, layero) {
  629. var iframeWindow = window['layui-layer-iframe' + index],
  630. submitID = 'LAY-list-front-submit',
  631. submit = layero.find('iframe').contents().find('#' + submitID);
  632. //监听提交
  633. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  634. var field = data.field; //获取提交的字段
  635. var userdata = "";
  636. for (var prop in field) {
  637. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  638. }
  639. //提交 Ajax 成功后,静态更新表格中的数据
  640. //$.ajax({});
  641. var loadindex = layer.load(1, {
  642. shade: [0.5, '#000']
  643. });
  644. $.ajax({
  645. type: "POST",
  646. url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
  647. data: userdata,
  648. dataType: "text",
  649. success: function (data) {
  650. if (data.indexOf("success") == 0) {
  651. var datalist = data.split('|');
  652. var key = datalist[1];
  653. CheckImport(table, key, loadindex, index);
  654. } else {
  655. layer.msg(data);
  656. }
  657. }
  658. });
  659. });
  660. submit.trigger('click');
  661. }
  662. });
  663. },
  664. ImportSend: function () {
  665. var perContent = layer.open({
  666. type: 2,
  667. title: '仓库发货至创客',
  668. content: 'Import?ExcelKind=3',
  669. maxmin: true,
  670. area: ['650px', '350px'],
  671. btn: ['确定', '取消'],
  672. yes: function (index, layero) {
  673. var iframeWindow = window['layui-layer-iframe' + index],
  674. submitID = 'LAY-list-front-submit',
  675. submit = layero.find('iframe').contents().find('#' + submitID);
  676. //监听提交
  677. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  678. var field = data.field; //获取提交的字段
  679. var userdata = "";
  680. for (var prop in field) {
  681. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  682. }
  683. //提交 Ajax 成功后,静态更新表格中的数据
  684. //$.ajax({});
  685. var loadindex = layer.load(1, {
  686. shade: [0.5, '#000']
  687. });
  688. $.ajax({
  689. type: "POST",
  690. url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
  691. data: userdata,
  692. dataType: "text",
  693. success: function (data) {
  694. if (data.indexOf("success") == 0) {
  695. var datalist = data.split('|');
  696. var key = datalist[1];
  697. CheckImport(table, key, loadindex, index);
  698. } else {
  699. layer.msg(data);
  700. }
  701. }
  702. });
  703. });
  704. submit.trigger('click');
  705. }
  706. });
  707. },
  708. ImportBack: function () {
  709. var perContent = layer.open({
  710. type: 2,
  711. title: '机具回仓库',
  712. content: 'Import?ExcelKind=4',
  713. maxmin: true,
  714. area: ['650px', '350px'],
  715. btn: ['确定', '取消'],
  716. yes: function (index, layero) {
  717. var iframeWindow = window['layui-layer-iframe' + index],
  718. submitID = 'LAY-list-front-submit',
  719. submit = layero.find('iframe').contents().find('#' + submitID);
  720. //监听提交
  721. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  722. var field = data.field; //获取提交的字段
  723. var userdata = "";
  724. for (var prop in field) {
  725. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  726. }
  727. //提交 Ajax 成功后,静态更新表格中的数据
  728. //$.ajax({});
  729. var loadindex = layer.load(1, {
  730. shade: [0.5, '#000']
  731. });
  732. $.ajax({
  733. type: "POST",
  734. url: "/Admin/StoreHouse/ImportPost?r=" + Math.random(1),
  735. data: userdata,
  736. dataType: "text",
  737. success: function (data) {
  738. if (data.indexOf("success") == 0) {
  739. var datalist = data.split('|');
  740. var key = datalist[1];
  741. CheckImport(table, key, loadindex, index);
  742. } else {
  743. layer.msg(data);
  744. }
  745. }
  746. });
  747. });
  748. submit.trigger('click');
  749. }
  750. });
  751. }, ImportRejectStore: function () {
  752. ExcelKind = 1;
  753. layer.open({
  754. type: 1,
  755. title: '导入',
  756. maxmin: false,
  757. area: ['650px', '350px'],
  758. // btn: ['确定', '取消'],
  759. content: $('#excelForm'),
  760. cancel: function () {
  761. }
  762. });
  763. $("#excelTemp").html('<a href="/users/创客机具驳回仓库模版.xlsx">点击下载创客机具驳回仓库模版</a>');
  764. },
  765. ExportExcel: function () {
  766. var userdata = '';
  767. $(".layuiadmin-card-header-auto input").each(function (i) {
  768. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  769. });
  770. $(".layuiadmin-card-header-auto select").each(function (i) {
  771. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  772. });
  773. $.ajax({
  774. type: "GET",
  775. url: "/Admin/StoreHouse/ExportExcel?r=" + Math.random(1),
  776. data: userdata,
  777. dataType: "json",
  778. success: function (data) {
  779. data.Obj.unshift(data.Fields);
  780. excel.exportExcel(data.Obj, data.Info, 'xlsx');
  781. }
  782. });
  783. }, BatchSetting: function () {
  784. var checkStatus = table.checkStatus('LAY-list-manage'),
  785. data = checkStatus.data; //得到选中的数据
  786. if (data.length < 1) {
  787. parent.layer.msg("请选择要关联的分仓");
  788. } else {
  789. var ids = "";
  790. $.each(data, function (index, value) {
  791. ids += data[index].Id + ",";
  792. });
  793. ids = ids.substring(0, ids.length - 1);
  794. var perContent = layer.open({
  795. type: 2,
  796. title: '关联分仓',
  797. content: 'BatchSetting',
  798. maxmin: true,
  799. area: ['550px', '350px'],
  800. btn: ['确定', '取消'],
  801. yes: function (index, layero) {
  802. var iframeWindow = window['layui-layer-iframe' + index],
  803. submitID = 'LAY-list-front-submit',
  804. submit = layero.find('iframe').contents().find('#' + submitID);
  805. setTimeout(function () {
  806. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  807. var errObj = $(this).find('.layui-form-danger');
  808. if (errObj.length > 0) {
  809. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  810. submit.click();
  811. }
  812. });
  813. }, 300);
  814. //监听提交
  815. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  816. var field = data.field; //获取提交的字段
  817. var userdata = "";
  818. for (var prop in field) {
  819. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  820. }
  821. //提交 Ajax 成功后,静态更新表格中的数据
  822. //$.ajax({});
  823. $.ajax({
  824. type: "POST",
  825. url: "/Admin/StoreHouse/BatchSetting?r=" + Math.random(1),
  826. data: userdata + "Id=" + ids,
  827. dataType: "text",
  828. success: function (data) {
  829. layer.close(index);
  830. if (data == "success") {
  831. table.reload('LAY-list-manage');
  832. }
  833. else if (data.indexOf("Warning") == 0) {
  834. var datalist = data.split('|');
  835. layer.alert(datalist[1], { time: 20000 }, function () {
  836. window.location.reload();
  837. });
  838. }
  839. else {
  840. layer.msg(data);
  841. }
  842. }
  843. });
  844. });
  845. submit.trigger('click');
  846. }
  847. });
  848. }
  849. },
  850. BatchCancle: function () {
  851. var checkStatus = table.checkStatus('LAY-list-manage'),
  852. data = checkStatus.data; //得到选中的数据
  853. if (data.length < 1) {
  854. parent.layer.msg("请选择要取消关联的分仓");
  855. } else {
  856. var ids = "";
  857. $.each(data, function (index, value) {
  858. ids += data[index].Id + ",";
  859. });
  860. ids = ids.substring(0, ids.length - 1);
  861. var perContent = layer.open({
  862. type: 2,
  863. title: '取消关联',
  864. content: 'BatchSetting',
  865. maxmin: true,
  866. area: ['650px', '550px'],
  867. btn: ['确定', '取消'],
  868. yes: function (index, layero) {
  869. var iframeWindow = window['layui-layer-iframe' + index],
  870. submitID = 'LAY-list-front-submit',
  871. submit = layero.find('iframe').contents().find('#' + submitID);
  872. setTimeout(function () {
  873. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  874. var errObj = $(this).find('.layui-form-danger');
  875. if (errObj.length > 0) {
  876. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  877. submit.click();
  878. }
  879. });
  880. }, 300);
  881. //监听提交
  882. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  883. var field = data.field; //获取提交的字段
  884. var userdata = "";
  885. for (var prop in field) {
  886. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  887. }
  888. //提交 Ajax 成功后,静态更新表格中的数据
  889. //$.ajax({});
  890. $.ajax({
  891. type: "POST",
  892. url: "/Admin/StoreHouse/BatchCancle?r=" + Math.random(1),
  893. data: userdata + "Id=" + ids,
  894. dataType: "text",
  895. success: function (data) {
  896. layer.close(index);
  897. if (data == "success") {
  898. table.reload('LAY-list-manage');
  899. }
  900. else if (data.indexOf("Warning") == 0) {
  901. var datalist = data.split('|');
  902. layer.alert(datalist[1], { time: 20000 }, function () {
  903. window.location.reload();
  904. });
  905. }
  906. else {
  907. layer.msg(data);
  908. }
  909. }
  910. });
  911. });
  912. submit.trigger('click');
  913. }
  914. });
  915. }
  916. },
  917. Open: function () {
  918. var checkStatus = table.checkStatus('LAY-list-manage'),
  919. data = checkStatus.data; //得到选中的数据
  920. if (data.length < 1) {
  921. parent.layer.msg("请选择要开启的项");
  922. } else {
  923. var ids = "";
  924. $.each(data, function (index, value) {
  925. ids += data[index].Id + ",";
  926. });
  927. ids = ids.substring(0, ids.length - 1);
  928. var index = layer.confirm('确定要开启吗?', function (index) {
  929. $.ajax({
  930. type: "POST",
  931. url: "/Admin/StoreHouse/Open?r=" + Math.random(1),
  932. data: "Id=" + ids,
  933. dataType: "text",
  934. success: function (data) {
  935. layer.close(index);
  936. if (data == "success") {
  937. table.reload('LAY-list-manage');
  938. } else {
  939. layer.msg(data);
  940. }
  941. }
  942. });
  943. });
  944. }
  945. },
  946. Close: function () {
  947. var checkStatus = table.checkStatus('LAY-list-manage'),
  948. data = checkStatus.data; //得到选中的数据
  949. if (data.length < 1) {
  950. parent.layer.msg("请选择要关闭的项");
  951. } else {
  952. var ids = "";
  953. $.each(data, function (index, value) {
  954. ids += data[index].Id + ",";
  955. });
  956. ids = ids.substring(0, ids.length - 1);
  957. var index = layer.confirm('确定要关闭吗?', function (index) {
  958. $.ajax({
  959. type: "POST",
  960. url: "/Admin/StoreHouse/Close?r=" + Math.random(1),
  961. data: "Id=" + ids,
  962. dataType: "text",
  963. success: function (data) {
  964. layer.close(index);
  965. if (data == "success") {
  966. table.reload('LAY-list-manage');
  967. } else {
  968. layer.msg(data);
  969. }
  970. }
  971. });
  972. });
  973. }
  974. },
  975. SycnData: function () {
  976. var index = layer.confirm('确定要同步所有仓库的库存数据吗?', function (index) {
  977. layer.close(index);
  978. var loadindex = layer.load(1, {
  979. shade: [0.5, '#000']
  980. });
  981. $.ajax({
  982. type: "POST",
  983. url: "/Admin/StoreHouse/SycnData?r=" + Math.random(1),
  984. data: "Id=0",
  985. dataType: "text",
  986. success: function (data) {
  987. layer.close(loadindex);
  988. if (data == "success") {
  989. layer.msg('同步成功');
  990. table.reload('LAY-list-manage');
  991. } else {
  992. layer.msg(data);
  993. }
  994. }
  995. });
  996. });
  997. },
  998. };
  999. $('.layui-btn').on('click', function () {
  1000. var type = $(this).data('type');
  1001. active[type] ? active[type].call(this) : '';
  1002. });
  1003. });