Team1Info_Admin.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. var ExcelData, ExcelKind;
  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 layActivationTime = laydate.render({
  15. elem: '#ActivationTime',
  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. layActivationTime.hint('日期范围请不要超过1个月');
  25. setTimeout(function () {
  26. $(".laydate-btns-confirm").addClass("laydate-disabled");
  27. }, 1);
  28. }
  29. } else {
  30. op = false;
  31. layActivationTime.hint('日期范围请不要超过1个月');
  32. setTimeout(function () {
  33. $(".laydate-btns-confirm").addClass("laydate-disabled");
  34. }, 1);
  35. }
  36. if (op) {
  37. $('#ActivationTime').val(value);
  38. }
  39. }
  40. });
  41. var layBindingTime = laydate.render({
  42. elem: '#BindingTime',
  43. type: 'date',
  44. range: true,
  45. trigger: 'click',
  46. change: function (value, date, endDate) {
  47. var op = true;
  48. if (date.year == endDate.year && endDate.month - date.month <= 1) {
  49. if (endDate.month - date.month == 1 && endDate.date > date.date) {
  50. op = false;
  51. layBindingTime.hint('日期范围请不要超过1个月');
  52. setTimeout(function () {
  53. $(".laydate-btns-confirm").addClass("laydate-disabled");
  54. }, 1);
  55. }
  56. } else {
  57. op = false;
  58. layBindingTime.hint('日期范围请不要超过1个月');
  59. setTimeout(function () {
  60. $(".laydate-btns-confirm").addClass("laydate-disabled");
  61. }, 1);
  62. }
  63. if (op) {
  64. $('#BindingTime').val(value);
  65. }
  66. }
  67. });
  68. //excel导入
  69. excel = layui.excel;
  70. $('#ExcelFile').change(function (e) {
  71. var files = e.target.files;
  72. excel.importExcel(files, {}, function (data) {
  73. ExcelData = data[0].Sheet1;
  74. });
  75. });
  76. //监听单元格编辑
  77. table.on('edit(LAY-list-manage)', function (obj) {
  78. var value = obj.value //得到修改后的值
  79. ,
  80. data = obj.data //得到所在行所有键值
  81. ,
  82. field = obj.field; //得到字段
  83. if (field == "Sort") {
  84. $.ajax({
  85. type: "POST",
  86. url: "/Admin/StoreHouse/Sort?r=" + Math.random(1),
  87. data: "Id=" + data.Id + "&Sort=" + value,
  88. dataType: "text",
  89. success: function (data) { }
  90. });
  91. }
  92. });
  93. //列表数据
  94. table.render({
  95. elem: '#LAY-list-manage'
  96. , url: '/Admin/SysTools/Team1InfoDo' //模拟接口
  97. , cols: [[
  98. { type: 'checkbox', fixed: 'left' }
  99. , { field: 'wname', width: 200, title: '伙伴名称', sort: true }
  100. , { field: 'Name', width: 200, title: '机具品牌', sort: true }
  101. , { field: 'PosSn', width: 200, title: '机具Sn', sort: true }
  102. , { field: 'merchantname', width: 200, title: '商户姓名', sort: true }
  103. , { field: 'SeoKeyword', width: 200, title: '服务费', sort: true }
  104. , { field: 'BindingTime', width: 200, title: '绑定时间', sort: true }
  105. , { field: 'ActivationTime', width: 200, title: '激活时间', sort: true }
  106. , { field: 'amount', width: 200, title: '返现金额', sort: true }
  107. , { field: 'maxdate', width: 200, title: '返现时间', sort: true }
  108. , { field: 'CreditRewardAmount', width: 200, title: '开机奖', sort: true }
  109. , { field: 'opdate', width: 200, title: '开机奖发放时间', sort: true }
  110. , { field: 'info', width: 200, title: '发放对象', sort: true }
  111. ]]
  112. , where: {
  113. }
  114. , page: true
  115. , limit: 30
  116. , height: 'full-' + String($('.layui-card-header').height() + 130)
  117. , text: '对不起,加载出现异常!'
  118. , done: function (res, curr, count) {
  119. $(".layui-none").text("无数据");
  120. }
  121. });
  122. $('.layui-btn').on('click', function () {
  123. var type = $(this).data('type');
  124. active[type] ? active[type].call(this) : '';
  125. });
  126. //监听工具条
  127. table.on('tool(LAY-list-manage)', function (obj) {
  128. var data = obj.data;
  129. });
  130. //监听搜索
  131. form.on('submit(LAY-list-front-search)', function (data) {
  132. var field = data.field;
  133. //执行重载
  134. table.reload('LAY-list-manage', {
  135. where: field,
  136. page: {
  137. curr: 1
  138. }
  139. });
  140. });
  141. form.on('submit(LAY-list-front-searchall)', function (data) {
  142. table.reload('LAY-list-manage', {
  143. where: null,
  144. page: {
  145. curr: 1
  146. }
  147. });
  148. });
  149. //事件
  150. var active = {
  151. ExportExcel: function () {
  152. var userdata = '';
  153. $(".layuiadmin-card-header-auto input").each(function (i) {
  154. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  155. });
  156. $(".layuiadmin-card-header-auto select").each(function (i) {
  157. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  158. });
  159. var index = layer.confirm('确定导出吗?', function (index) {
  160. var indexs = layer.load(1, {
  161. shade: [0.5, '#000']
  162. });
  163. $.ajax({
  164. type: "POST",
  165. url: "/Admin/SysTools/ExportTeam1InfoExcelDo?r=" + Math.random(1),
  166. data: userdata,
  167. dataType: "text",
  168. success: function (data) {
  169. layer.close(index); //关闭弹层
  170. if (data == "success") {
  171. layer.close(indexs); //关闭弹层
  172. layer.msg('导出成功,请到我的下载中点击下载文件', {
  173. time: 1000
  174. }, function () {
  175. window.location.reload();
  176. });
  177. } else {
  178. layer.close(indexs); //关闭弹层
  179. layer.msg(data);
  180. }
  181. }
  182. });
  183. });
  184. },
  185. };
  186. $('.layui-btn').on('click', function () {
  187. var type = $(this).data('type');
  188. active[type] ? active[type].call(this) : '';
  189. });
  190. });