UserCashRecordForBusiness_Admin.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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: 'SeoKeyword', width: 200, title: '备注', sort: true }
  77. , { title: '操作', align: 'center', width: 300, fixed: 'right', toolbar: '#table-list-tools' }
  78. ]],
  79. where: {
  80. },
  81. page: true,
  82. limit: 30,
  83. height: 'full-' + String($('.layui-card-header').height() + 130),
  84. text: '对不起,加载出现异常!',
  85. done: function (res, curr, count) {
  86. $(".layui-none").text("无数据");
  87. layer.close(loadindex);
  88. }
  89. });
  90. //监听工具条
  91. table.on('tool(LAY-list-manage)', function (obj) {
  92. var data = obj.data;
  93. });
  94. //监听搜索
  95. form.on('submit(LAY-list-front-search)', function (data) {
  96. var field = data.field;
  97. //执行重载
  98. table.reload('LAY-list-manage', {
  99. where: field,
  100. page: {
  101. curr: 1
  102. }
  103. });
  104. });
  105. form.on('submit(LAY-list-front-searchall)', function (data) {
  106. table.reload('LAY-list-manage', {
  107. where: null,
  108. page: {
  109. curr: 1
  110. }
  111. });
  112. });
  113. //事件
  114. var active = {
  115. add: function () {
  116. var perContent = layer.open({
  117. type: 2,
  118. title: '直营团队提现记录-添加',
  119. content: 'Add',
  120. maxmin: true,
  121. area: ['500px', '450px'],
  122. btn: ['确定', '取消'],
  123. yes: function (index, layero) {
  124. var iframeWindow = window['layui-layer-iframe' + index],
  125. submitID = 'LAY-list-front-submit',
  126. submit = layero.find('iframe').contents().find('#' + submitID);
  127. setTimeout(function () {
  128. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  129. var errObj = $(this).find('.layui-form-danger');
  130. if (errObj.length > 0) {
  131. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  132. submit.click();
  133. }
  134. });
  135. }, 300);
  136. //监听提交
  137. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  138. var field = data.field; //获取提交的字段
  139. var userdata = "";
  140. for (var prop in field) {
  141. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  142. }
  143. //提交 Ajax 成功后,静态更新表格中的数据
  144. //$.ajax({});
  145. // var info = "";
  146. // $.ajax({
  147. // url: "/Admin/UserCashRecordForBusiness/GetReserve?r=" + Math.random(1),
  148. // // data: searchInfo,
  149. // data: userdata,
  150. // dataType: "text",
  151. // success: function (data) {
  152. // info = data;
  153. // }
  154. // });
  155. // var indexs = layer.confirm('确定要进行提现吗?' + info, function (indexs) {
  156. getInfo(userdata, function (info) {
  157. var indexs = layer.confirm(info + '\n确定要进行提现吗?', function (indexs) {
  158. $.ajax({
  159. type: "POST",
  160. url: "/Admin/UserCashRecordForBusiness/Add?r=" + Math.random(1),
  161. data: userdata,
  162. dataType: "text",
  163. success: function (data) {
  164. layer.close(index); //关闭弹层
  165. layer.close(indexs); //关闭弹层
  166. if (data == "success") {
  167. layer.msg("成功");
  168. table.reload('LAY-list-manage'); //数据刷新
  169. } else {
  170. layer.msg(data);
  171. }
  172. }
  173. });
  174. });
  175. })
  176. });
  177. submit.trigger('click');
  178. }
  179. });
  180. // layer.full(perContent);
  181. },
  182. ExportExcel: function () {
  183. var userdata = '';
  184. $(".layuiadmin-card-header-auto input").each(function (i) {
  185. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  186. });
  187. $(".layuiadmin-card-header-auto select").each(function (i) {
  188. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  189. });
  190. $.ajax({
  191. type: "GET",
  192. url: "/Admin/UserCashRecordForBusiness/ExportExcel?r=" + Math.random(1),
  193. data: userdata,
  194. dataType: "json",
  195. success: function (data) {
  196. data.Obj.unshift(data.Fields);
  197. excel.exportExcel(data.Obj, data.Info, 'xlsx');
  198. }
  199. });
  200. }
  201. };
  202. $('.layui-btn').on('click', function () {
  203. var type = $(this).data('type');
  204. active[type] ? active[type].call(this) : '';
  205. });
  206. });
  207. function getInfo(userdata, func) {
  208. $.ajax({
  209. url: "/Admin/UserCashRecordForBusiness/GetReserve?r=" + Math.random(1),
  210. data: userdata,
  211. dataType: "text",
  212. success: function (data) {
  213. info = data;
  214. func(info);
  215. }
  216. });
  217. };