OrderRefund_Admin.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. var ExcelData;
  2. function ConfirmImport() {
  3. $.ajax({
  4. type: "POST",
  5. url: "/Admin/OrderRefund/Import?r=" + Math.random(1),
  6. data: "ExcelData=" + encodeURIComponent(JSON.stringify(ExcelData)),
  7. dataType: "text",
  8. success: function (data) {
  9. if (data == "success") {
  10. layer.msg("导入成功", {
  11. time: 2000
  12. }, function () {
  13. window.location.reload();
  14. });
  15. } else {
  16. layer.msg(data);
  17. }
  18. }
  19. });
  20. }
  21. layui.config({
  22. base: '/layuiadmin/' //静态资源所在路径
  23. }).extend({
  24. myexcel: 'layui/lay/modules/excel',
  25. index: 'lib/index' //主入口模块
  26. }).use(['index', 'table', 'excel', 'laydate'], function () {
  27. var $ = layui.$,
  28. form = layui.form,
  29. table = layui.table;
  30. //- 筛选条件-日期
  31. var laydate = layui.laydate;
  32. //excel导入
  33. var excel = layui.excel;
  34. $('#ExcelFile').change(function (e) {
  35. var files = e.target.files;
  36. excel.importExcel(files, {}, function (data) {
  37. ExcelData = data[0].Sheet1;
  38. });
  39. });
  40. //监听单元格编辑
  41. table.on('edit(LAY-list-manage)', function (obj) {
  42. var value = obj.value //得到修改后的值
  43. ,
  44. data = obj.data //得到所在行所有键值
  45. ,
  46. field = obj.field; //得到字段
  47. if (field == "Sort") {
  48. $.ajax({
  49. type: "POST",
  50. url: "/Admin/OrderRefund/Sort?r=" + Math.random(1),
  51. data: "Id=" + data.Id + "&Sort=" + value,
  52. dataType: "text",
  53. success: function (data) {}
  54. });
  55. }
  56. });
  57. //列表数据
  58. table.render({
  59. elem: '#LAY-list-manage',
  60. url: '/Admin/OrderRefund/IndexData' //模拟接口
  61. ,
  62. cols: [
  63. [{
  64. type: 'checkbox',
  65. fixed: 'left'
  66. }, {
  67. field: 'Id',
  68. fixed: 'left',
  69. title: 'ID',
  70. width: 80,
  71. sort: true,
  72. unresize: true
  73. }, {
  74. field: 'Reason',
  75. title: '退款原因',
  76. sort: true
  77. }, {
  78. field: 'Amount',
  79. title: '退款金额',
  80. sort: true
  81. }, {
  82. field: 'Mobile',
  83. title: '申请人手机号',
  84. sort: true
  85. }, {
  86. field: 'GoodStatus',
  87. title: '货物状态',
  88. sort: true
  89. }, {
  90. field: 'Status',
  91. title: '申请状态',
  92. sort: true
  93. }, {
  94. title: '操作',
  95. width: 150,
  96. align: 'center',
  97. fixed: 'right',
  98. toolbar: '#table-list-tools'
  99. }]
  100. ],
  101. page: true,
  102. limit: 30,
  103. height: 'full-' + String($('.layui-card-header').height() + 130),
  104. text: '对不起,加载出现异常!',
  105. done: function (res, curr, count) {
  106. $(".layui-none").text("无数据");
  107. }
  108. });
  109. //监听工具条
  110. table.on('tool(LAY-list-manage)', function (obj) {
  111. var data = obj.data;
  112. if (obj.event === 'del') {
  113. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  114. $.ajax({
  115. type: "POST",
  116. url: "/Admin/OrderRefund/Delete?r=" + Math.random(1),
  117. data: "Id=" + data.Id,
  118. dataType: "text",
  119. success: function (data) {
  120. if (data == "success") {
  121. obj.del();
  122. layer.close(index);
  123. } else {
  124. parent.layer.msg(data);
  125. }
  126. }
  127. });
  128. });
  129. } else if (obj.event === 'edit') {
  130. var tr = $(obj.tr);
  131. var perContent = layer.open({
  132. type: 2,
  133. title: '退款申请-编辑',
  134. content: 'Edit?Id=' + data.Id,
  135. maxmin: true,
  136. area: ['500px', '450px'],
  137. btn: ['确定退款', '取消'],
  138. yes: function (index, layero) {
  139. var iframeWindow = window['layui-layer-iframe' + index],
  140. submitID = 'LAY-list-front-submit',
  141. submit = layero.find('iframe').contents().find('#' + submitID);
  142. //凭证
  143. iframeWindow.checkPics("Photos");
  144. //监听提交
  145. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  146. var field = data.field; //获取提交的字段
  147. var userdata = "";
  148. for (var prop in field) {
  149. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  150. }
  151. //提交 Ajax 成功后,静态更新表格中的数据
  152. //$.ajax({});
  153. $.ajax({
  154. type: "POST",
  155. url: "/Admin/OrderRefund/Edit?r=" + Math.random(1),
  156. data: userdata,
  157. dataType: "text",
  158. success: function (data) {
  159. layer.close(index); //关闭弹层
  160. if (data == "success") {
  161. table.reload('LAY-list-manage'); //数据刷新
  162. } else {
  163. layer.msg(data);
  164. }
  165. }
  166. });
  167. });
  168. submit.trigger('click');
  169. },
  170. success: function (layero, index) {
  171. }
  172. });
  173. layer.full(perContent);
  174. }
  175. });
  176. //监听搜索
  177. form.on('submit(LAY-list-front-search)', function (data) {
  178. var field = data.field;
  179. //执行重载
  180. table.reload('LAY-list-manage', {
  181. where: field,
  182. page: {
  183. curr: 1
  184. }
  185. });
  186. });
  187. form.on('submit(LAY-list-front-searchall)', function (data) {
  188. table.reload('LAY-list-manage', {
  189. where: null,
  190. page: {
  191. curr: 1
  192. }
  193. });
  194. });
  195. //事件
  196. var active = {
  197. batchdel: function () {
  198. var checkStatus = table.checkStatus('LAY-list-manage'),
  199. data = checkStatus.data; //得到选中的数据
  200. if (data.length < 1) {
  201. parent.layer.msg("请选择要删除的项");
  202. } else {
  203. var ids = "";
  204. $.each(data, function (index, value) {
  205. ids += data[index].Id + ",";
  206. });
  207. ids = ids.substring(0, ids.length - 1);
  208. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  209. $.ajax({
  210. type: "POST",
  211. url: "/Admin/OrderRefund/Delete?r=" + Math.random(1),
  212. data: "Id=" + ids,
  213. dataType: "text",
  214. success: function (data) {
  215. layer.close(index);
  216. if (data == "success") {
  217. table.reload('LAY-list-manage');
  218. } else {
  219. layer.msg(data);
  220. }
  221. }
  222. });
  223. });
  224. }
  225. },
  226. add: function () {
  227. var perContent = layer.open({
  228. type: 2,
  229. title: '退款申请-添加',
  230. content: 'Add',
  231. maxmin: true,
  232. area: ['500px', '450px'],
  233. btn: ['确定', '取消'],
  234. yes: function (index, layero) {
  235. var iframeWindow = window['layui-layer-iframe' + index],
  236. submitID = 'LAY-list-front-submit',
  237. submit = layero.find('iframe').contents().find('#' + submitID);
  238. //凭证
  239. iframeWindow.checkPics("Photos");
  240. //监听提交
  241. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  242. var field = data.field; //获取提交的字段
  243. var userdata = "";
  244. for (var prop in field) {
  245. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  246. }
  247. //提交 Ajax 成功后,静态更新表格中的数据
  248. //$.ajax({});
  249. $.ajax({
  250. type: "POST",
  251. url: "/Admin/OrderRefund/Add?r=" + Math.random(1),
  252. data: userdata,
  253. dataType: "text",
  254. success: function (data) {
  255. layer.close(index); //关闭弹层
  256. if (data == "success") {
  257. table.reload('LAY-list-manage'); //数据刷新
  258. } else {
  259. layer.msg(data);
  260. }
  261. }
  262. });
  263. });
  264. submit.trigger('click');
  265. }
  266. });
  267. layer.full(perContent);
  268. },
  269. ImportData: function () {
  270. layer.open({
  271. type: 2,
  272. title: '导入',
  273. maxmin: false,
  274. area: ['460px', '180px'],
  275. content: $('#excelForm'),
  276. cancel: function () {}
  277. });
  278. },
  279. ExportExcel: function () {
  280. var userdata = $('#QueryForm').serialize();
  281. $.ajax({
  282. type: "POST",
  283. url: "/Admin/OrderRefund/ExportExcel?r=" + Math.random(1),
  284. data: userdata,
  285. dataType: "json",
  286. success: function (data) {
  287. data.Obj.unshift(data.Fields);
  288. excel.exportExcel(data.Obj, data.Info, 'xlsx');
  289. }
  290. });
  291. },
  292. Open: function () {
  293. var checkStatus = table.checkStatus('LAY-list-manage'),
  294. data = checkStatus.data; //得到选中的数据
  295. if (data.length < 1) {
  296. parent.layer.msg("请选择要开启的项");
  297. } else {
  298. var ids = "";
  299. $.each(data, function (index, value) {
  300. ids += data[index].Id + ",";
  301. });
  302. ids = ids.substring(0, ids.length - 1);
  303. var index = layer.confirm('确定要开启吗?', function (index) {
  304. $.ajax({
  305. type: "POST",
  306. url: "/Admin/OrderRefund/Open?r=" + Math.random(1),
  307. data: "Id=" + ids,
  308. dataType: "text",
  309. success: function (data) {
  310. layer.close(index);
  311. if (data == "success") {
  312. table.reload('LAY-list-manage');
  313. } else {
  314. layer.msg(data);
  315. }
  316. }
  317. });
  318. });
  319. }
  320. },
  321. Close: function () {
  322. var checkStatus = table.checkStatus('LAY-list-manage'),
  323. data = checkStatus.data; //得到选中的数据
  324. if (data.length < 1) {
  325. parent.layer.msg("请选择要关闭的项");
  326. } else {
  327. var ids = "";
  328. $.each(data, function (index, value) {
  329. ids += data[index].Id + ",";
  330. });
  331. ids = ids.substring(0, ids.length - 1);
  332. var index = layer.confirm('确定要关闭吗?', function (index) {
  333. $.ajax({
  334. type: "POST",
  335. url: "/Admin/OrderRefund/Close?r=" + Math.random(1),
  336. data: "Id=" + ids,
  337. dataType: "text",
  338. success: function (data) {
  339. layer.close(index);
  340. if (data == "success") {
  341. table.reload('LAY-list-manage');
  342. } else {
  343. layer.msg(data);
  344. }
  345. }
  346. });
  347. });
  348. }
  349. }
  350. };
  351. $('.layui-btn').on('click', function () {
  352. var type = $(this).data('type');
  353. active[type] ? active[type].call(this) : '';
  354. });
  355. });