OrderRefund_Admin.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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. { type: 'checkbox', fixed: 'left' },
  64. { field: 'Id', fixed: 'left', title: 'ID', width: 80, sort: true, unresize: true },
  65. { field: 'OrderNo', width: 200, title: '订单号', sort: true },
  66. { field: 'Refund', width: 200, title: '退款原因', sort: true },
  67. { field: 'ProductName', width: 200, title: '商品', sort: true },
  68. { field: 'Amount', width: 200, title: '退款金额', sort: true },
  69. { field: 'RefundType', width: 200, title: '退回方式', sort: true },
  70. { field: 'UserInfo', width: 200, title: '创客信息', sort: true },
  71. // { title: '操作', width: 150, align: 'center', fixed: 'right', toolbar: '#table-list-tools' }
  72. ]],
  73. page: true,
  74. limit: 30,
  75. height: 'full-' + String($('.layui-card-header').height() + 130),
  76. text: '对不起,加载出现异常!',
  77. done: function (res, curr, count) {
  78. $(".layui-none").text("无数据");
  79. }
  80. });
  81. //监听工具条
  82. table.on('tool(LAY-list-manage)', function (obj) {
  83. var data = obj.data;
  84. if (obj.event === 'del') {
  85. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  86. $.ajax({
  87. type: "POST",
  88. url: "/Admin/OrderRefund/Delete?r=" + Math.random(1),
  89. data: "Id=" + data.Id,
  90. dataType: "text",
  91. success: function (data) {
  92. if (data == "success") {
  93. obj.del();
  94. layer.close(index);
  95. } else {
  96. parent.layer.msg(data);
  97. }
  98. }
  99. });
  100. });
  101. } else if (obj.event === 'edit') {
  102. var tr = $(obj.tr);
  103. var perContent = layer.open({
  104. type: 2,
  105. title: '退款申请-编辑',
  106. content: 'Edit?Id=' + data.Id,
  107. maxmin: true,
  108. area: ['500px', '450px'],
  109. btn: ['确定退款', '取消'],
  110. yes: function (index, layero) {
  111. var iframeWindow = window['layui-layer-iframe' + index],
  112. submitID = 'LAY-list-front-submit',
  113. submit = layero.find('iframe').contents().find('#' + submitID);
  114. //凭证
  115. iframeWindow.checkPics("Photos");
  116. //监听提交
  117. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  118. var field = data.field; //获取提交的字段
  119. var userdata = "";
  120. for (var prop in field) {
  121. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  122. }
  123. //提交 Ajax 成功后,静态更新表格中的数据
  124. //$.ajax({});
  125. $.ajax({
  126. type: "POST",
  127. url: "/Admin/OrderRefund/Edit?r=" + Math.random(1),
  128. data: userdata,
  129. dataType: "text",
  130. success: function (data) {
  131. layer.close(index); //关闭弹层
  132. if (data == "success") {
  133. table.reload('LAY-list-manage'); //数据刷新
  134. } else {
  135. layer.msg(data);
  136. }
  137. }
  138. });
  139. });
  140. submit.trigger('click');
  141. },
  142. success: function (layero, index) {
  143. }
  144. });
  145. layer.full(perContent);
  146. }
  147. });
  148. //监听搜索
  149. form.on('submit(LAY-list-front-search)', function (data) {
  150. var field = data.field;
  151. //执行重载
  152. table.reload('LAY-list-manage', {
  153. where: field,
  154. page: {
  155. curr: 1
  156. }
  157. });
  158. });
  159. form.on('submit(LAY-list-front-searchall)', function (data) {
  160. table.reload('LAY-list-manage', {
  161. where: null,
  162. page: {
  163. curr: 1
  164. }
  165. });
  166. });
  167. //事件
  168. var active = {
  169. batchdel: function () {
  170. var checkStatus = table.checkStatus('LAY-list-manage'),
  171. data = checkStatus.data; //得到选中的数据
  172. if (data.length < 1) {
  173. parent.layer.msg("请选择要删除的项");
  174. } else {
  175. var ids = "";
  176. $.each(data, function (index, value) {
  177. ids += data[index].Id + ",";
  178. });
  179. ids = ids.substring(0, ids.length - 1);
  180. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  181. $.ajax({
  182. type: "POST",
  183. url: "/Admin/OrderRefund/Delete?r=" + Math.random(1),
  184. data: "Id=" + ids,
  185. dataType: "text",
  186. success: function (data) {
  187. layer.close(index);
  188. if (data == "success") {
  189. table.reload('LAY-list-manage');
  190. } else {
  191. layer.msg(data);
  192. }
  193. }
  194. });
  195. });
  196. }
  197. },
  198. add: function () {
  199. var perContent = layer.open({
  200. type: 2,
  201. title: '退款申请-添加',
  202. content: 'Add',
  203. maxmin: true,
  204. area: ['500px', '450px'],
  205. btn: ['确定', '取消'],
  206. yes: function (index, layero) {
  207. var iframeWindow = window['layui-layer-iframe' + index],
  208. submitID = 'LAY-list-front-submit',
  209. submit = layero.find('iframe').contents().find('#' + submitID);
  210. //凭证
  211. iframeWindow.checkPics("Photos");
  212. //监听提交
  213. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  214. var field = data.field; //获取提交的字段
  215. var userdata = "";
  216. for (var prop in field) {
  217. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  218. }
  219. //提交 Ajax 成功后,静态更新表格中的数据
  220. //$.ajax({});
  221. $.ajax({
  222. type: "POST",
  223. url: "/Admin/OrderRefund/Add?r=" + Math.random(1),
  224. data: userdata,
  225. dataType: "text",
  226. success: function (data) {
  227. layer.close(index); //关闭弹层
  228. if (data == "success") {
  229. table.reload('LAY-list-manage'); //数据刷新
  230. } else {
  231. layer.msg(data);
  232. }
  233. }
  234. });
  235. });
  236. submit.trigger('click');
  237. }
  238. });
  239. layer.full(perContent);
  240. },
  241. ImportData: function () {
  242. layer.open({
  243. type: 2,
  244. title: '导入',
  245. maxmin: false,
  246. area: ['460px', '180px'],
  247. content: $('#excelForm'),
  248. cancel: function () { }
  249. });
  250. },
  251. ExportExcel: function () {
  252. var userdata = $('#QueryForm').serialize();
  253. $.ajax({
  254. type: "POST",
  255. url: "/Admin/OrderRefund/ExportExcel?r=" + Math.random(1),
  256. data: userdata,
  257. dataType: "json",
  258. success: function (data) {
  259. data.Obj.unshift(data.Fields);
  260. excel.exportExcel(data.Obj, data.Info, 'xlsx');
  261. }
  262. });
  263. },
  264. Open: function () {
  265. var checkStatus = table.checkStatus('LAY-list-manage'),
  266. data = checkStatus.data; //得到选中的数据
  267. if (data.length < 1) {
  268. parent.layer.msg("请选择要开启的项");
  269. } else {
  270. var ids = "";
  271. $.each(data, function (index, value) {
  272. ids += data[index].Id + ",";
  273. });
  274. ids = ids.substring(0, ids.length - 1);
  275. var index = layer.confirm('确定要开启吗?', function (index) {
  276. $.ajax({
  277. type: "POST",
  278. url: "/Admin/OrderRefund/Open?r=" + Math.random(1),
  279. data: "Id=" + ids,
  280. dataType: "text",
  281. success: function (data) {
  282. layer.close(index);
  283. if (data == "success") {
  284. table.reload('LAY-list-manage');
  285. } else {
  286. layer.msg(data);
  287. }
  288. }
  289. });
  290. });
  291. }
  292. },
  293. Close: function () {
  294. var checkStatus = table.checkStatus('LAY-list-manage'),
  295. data = checkStatus.data; //得到选中的数据
  296. if (data.length < 1) {
  297. parent.layer.msg("请选择要关闭的项");
  298. } else {
  299. var ids = "";
  300. $.each(data, function (index, value) {
  301. ids += data[index].Id + ",";
  302. });
  303. ids = ids.substring(0, ids.length - 1);
  304. var index = layer.confirm('确定要关闭吗?', function (index) {
  305. $.ajax({
  306. type: "POST",
  307. url: "/Admin/OrderRefund/Close?r=" + Math.random(1),
  308. data: "Id=" + ids,
  309. dataType: "text",
  310. success: function (data) {
  311. layer.close(index);
  312. if (data == "success") {
  313. table.reload('LAY-list-manage');
  314. } else {
  315. layer.msg(data);
  316. }
  317. }
  318. });
  319. });
  320. }
  321. }
  322. };
  323. $('.layui-btn').on('click', function () {
  324. var type = $(this).data('type');
  325. active[type] ? active[type].call(this) : '';
  326. });
  327. });