UserCashRecordForBusiness_Admin.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. var ExcelData;
  2. var excel;
  3. layui.config({
  4. base: '/layuiadmin/' //静态资源所在路径
  5. }).extend({
  6. myexcel: 'layui/lay/modules/excel',
  7. index: 'lib/index' //主入口模块
  8. }).use(['index', 'table', 'excel', 'laydate'], function () {
  9. var $ = layui.$,
  10. form = layui.form,
  11. table = layui.table;
  12. //- 筛选条件-日期
  13. var laydate = layui.laydate;
  14. var layCreateDate = laydate.render({
  15. elem: '#CreateDate',
  16. type: 'date',
  17. range: true,
  18. trigger: 'click',
  19. change: function (value, date, endDate) {
  20. var op = true;
  21. if (date.year == endDate.year && endDate.month - date.month <= 1) {
  22. if (endDate.month - date.month == 1 && endDate.date > date.date) {
  23. op = false;
  24. layCreateDate.hint('日期范围请不要超过1个月');
  25. setTimeout(function () {
  26. $(".laydate-btns-confirm").addClass("laydate-disabled");
  27. }, 1);
  28. }
  29. } else {
  30. op = false;
  31. layCreateDate.hint('日期范围请不要超过1个月');
  32. setTimeout(function () {
  33. $(".laydate-btns-confirm").addClass("laydate-disabled");
  34. }, 1);
  35. }
  36. if (op) {
  37. $('#CreateDate').val(value);
  38. }
  39. }
  40. });
  41. //excel导入
  42. excel = layui.excel;
  43. $('#ExcelFile').change(function (e) {
  44. var files = e.target.files;
  45. excel.importExcel(files, {}, function (data) {
  46. ExcelData = data[0].sheet1;
  47. });
  48. });
  49. //监听单元格编辑
  50. table.on('edit(LAY-list-manage)', function (obj) {
  51. var value = obj.value //得到修改后的值
  52. ,
  53. data = obj.data //得到所在行所有键值
  54. ,
  55. field = obj.field; //得到字段
  56. if (field == "Sort") {
  57. $.ajax({
  58. type: "POST",
  59. url: "/Admin/UserCashRecordForBusiness/Sort?r=" + Math.random(1),
  60. data: "Id=" + data.Id + "&Sort=" + value,
  61. dataType: "text",
  62. success: function (data) { }
  63. });
  64. }
  65. });
  66. //列表数据
  67. table.render({
  68. elem: '#LAY-list-manage',
  69. url: '/Admin/UserCashRecordForBusiness/IndexData' //模拟接口
  70. ,
  71. cols: [[
  72. { type: 'checkbox', fixed: 'left' }
  73. , { field: 'MakerCode', width: 200, title: '创客编号', sort: true }
  74. , { field: 'RealName', width: 200, title: '创客姓名', sort: true }
  75. , { field: 'CashOrderNo', width: 200, title: '提现单号', sort: true }
  76. , { field: 'TradeAmount', width: 200, title: '提现金额', sort: true }
  77. , { field: 'CreateDate', width: 200, title: '提现时间', sort: true }
  78. , { field: 'SeoKeyword', width: 200, title: '备注', sort: true }
  79. , { field: 'CreateMan', width: 200, title: '操作人', sort: true }
  80. // , { title: '操作', align: 'center', width: 300, fixed: 'right', toolbar: '#table-list-tools' }
  81. ]],
  82. where: {
  83. },
  84. page: true,
  85. limit: 30,
  86. height: 'full-' + String($('.layui-card-header').height() + 130),
  87. text: '对不起,加载出现异常!',
  88. done: function (res, curr, count) {
  89. $(".layui-none").text("无数据");
  90. layer.close(loadindex);
  91. }
  92. });
  93. //监听工具条
  94. table.on('tool(LAY-list-manage)', function (obj) {
  95. var data = obj.data;
  96. });
  97. //监听搜索
  98. form.on('submit(LAY-list-front-search)', function (data) {
  99. var field = data.field;
  100. //执行重载
  101. table.reload('LAY-list-manage', {
  102. where: field,
  103. page: {
  104. curr: 1
  105. }
  106. });
  107. });
  108. form.on('submit(LAY-list-front-searchall)', function (data) {
  109. table.reload('LAY-list-manage', {
  110. where: null,
  111. page: {
  112. curr: 1
  113. }
  114. });
  115. });
  116. //事件
  117. var active = {
  118. add: function () {
  119. var perContent = layer.open({
  120. type: 2,
  121. title: '直营团队提现记录-添加',
  122. content: 'Add',
  123. maxmin: true,
  124. area: ['500px', '450px'],
  125. btn: ['确定', '取消'],
  126. yes: function (index, layero) {
  127. var iframeWindow = window['layui-layer-iframe' + index],
  128. submitID = 'LAY-list-front-submit',
  129. submit = layero.find('iframe').contents().find('#' + submitID);
  130. setTimeout(function () {
  131. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  132. var errObj = $(this).find('.layui-form-danger');
  133. if (errObj.length > 0) {
  134. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  135. submit.click();
  136. }
  137. });
  138. }, 300);
  139. //监听提交
  140. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  141. var field = data.field; //获取提交的字段
  142. var userdata = "";
  143. for (var prop in field) {
  144. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  145. }
  146. //提交 Ajax 成功后,静态更新表格中的数据
  147. //$.ajax({});
  148. // var info = "";
  149. // $.ajax({
  150. // url: "/Admin/UserCashRecordForBusiness/GetReserve?r=" + Math.random(1),
  151. // // data: searchInfo,
  152. // data: userdata,
  153. // dataType: "text",
  154. // success: function (data) {
  155. // info = data;
  156. // }
  157. // });
  158. // var indexs = layer.confirm('确定要进行提现吗?' + info, function (indexs) {
  159. getInfo(userdata, function (info) {
  160. var indexs = layer.confirm(info + '\n确定要进行提现吗?', function (indexs) {
  161. $.ajax({
  162. type: "POST",
  163. url: "/Admin/UserCashRecordForBusiness/Add?r=" + Math.random(1),
  164. data: userdata,
  165. dataType: "text",
  166. success: function (data) {
  167. layer.close(index); //关闭弹层
  168. layer.close(indexs); //关闭弹层
  169. if (data == "success") {
  170. layer.msg("成功");
  171. table.reload('LAY-list-manage'); //数据刷新
  172. } else {
  173. layer.msg(data);
  174. }
  175. }
  176. });
  177. });
  178. })
  179. });
  180. submit.trigger('click');
  181. }
  182. });
  183. // layer.full(perContent);
  184. },
  185. ExportExcel: function () {
  186. var userdata = '';
  187. $(".layuiadmin-card-header-auto input").each(function (i) {
  188. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  189. });
  190. $(".layuiadmin-card-header-auto select").each(function (i) {
  191. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  192. });
  193. // $.ajax({
  194. // type: "GET",
  195. // url: "/Admin/UserCashRecordForBusiness/ExportExcel?r=" + Math.random(1),
  196. // data: userdata,
  197. // dataType: "json",
  198. // success: function (data) {
  199. // data.Obj.unshift(data.Fields);
  200. // excel.exportExcel(data.Obj, data.Info, 'xlsx');
  201. // }
  202. // });
  203. var index = layer.confirm('确定导出吗?', function (index) {
  204. var indexs = layer.load(1, {
  205. shade: [0.5, '#000']
  206. });
  207. $.ajax({
  208. type: "POST",
  209. url: "/Admin/UserCashRecordForBusiness/QuickExportExcelDo?r=" + Math.random(1),
  210. data: userdata,
  211. dataType: "text",
  212. success: function (data) {
  213. layer.close(index); //关闭弹层
  214. if (data == "success") {
  215. layer.close(indexs); //关闭弹层
  216. layer.msg('导出成功,请到我的下载中点击下载文件', {
  217. time: 1000
  218. }, function () {
  219. window.location.reload();
  220. });
  221. } else {
  222. layer.close(indexs); //关闭弹层
  223. layer.msg(data);
  224. }
  225. }
  226. });
  227. });
  228. }
  229. };
  230. $('.layui-btn').on('click', function () {
  231. var type = $(this).data('type');
  232. active[type] ? active[type].call(this) : '';
  233. });
  234. });
  235. function getInfo(userdata, func) {
  236. $.ajax({
  237. url: "/Admin/UserCashRecordForBusiness/GetReserve?r=" + Math.random(1),
  238. data: userdata,
  239. dataType: "text",
  240. success: function (data) {
  241. info = data;
  242. func(info);
  243. }
  244. });
  245. };