Team1Info_Admin.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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: 'SeoKeyword', width: 200, title: '服务费', sort: true }
  103. , { field: 'BindingTime', width: 200, title: '绑定时间', sort: true }
  104. , { field: 'ActivationTime', width: 200, title: '激活时间', sort: true }
  105. ]]
  106. , where: {
  107. }
  108. , page: true
  109. , limit: 30
  110. , height: 'full-' + String($('.layui-card-header').height() + 130)
  111. , text: '对不起,加载出现异常!'
  112. , done: function (res, curr, count) {
  113. $(".layui-none").text("无数据");
  114. }
  115. });
  116. $('.layui-btn').on('click', function () {
  117. var type = $(this).data('type');
  118. active[type] ? active[type].call(this) : '';
  119. });
  120. //监听工具条
  121. table.on('tool(LAY-list-manage)', function (obj) {
  122. var data = obj.data;
  123. });
  124. //监听搜索
  125. form.on('submit(LAY-list-front-search)', function (data) {
  126. var field = data.field;
  127. //执行重载
  128. table.reload('LAY-list-manage', {
  129. where: field,
  130. page: {
  131. curr: 1
  132. }
  133. });
  134. });
  135. form.on('submit(LAY-list-front-searchall)', function (data) {
  136. table.reload('LAY-list-manage', {
  137. where: null,
  138. page: {
  139. curr: 1
  140. }
  141. });
  142. });
  143. //事件
  144. var active = {
  145. ExportExcel: function () {
  146. var userdata = '';
  147. $(".layuiadmin-card-header-auto input").each(function (i) {
  148. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  149. });
  150. $(".layuiadmin-card-header-auto select").each(function (i) {
  151. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  152. });
  153. var index = layer.confirm('确定导出吗?', function (index) {
  154. var indexs = layer.load(1, {
  155. shade: [0.5, '#000']
  156. });
  157. $.ajax({
  158. type: "POST",
  159. url: "/Admin/SysTools/ExportTeam1InfoExcelDo?r=" + Math.random(1),
  160. data: userdata,
  161. dataType: "text",
  162. success: function (data) {
  163. layer.close(index); //关闭弹层
  164. if (data == "success") {
  165. layer.close(indexs); //关闭弹层
  166. layer.msg('导出成功,请到我的下载中点击下载文件', {
  167. time: 1000
  168. }, function () {
  169. window.location.reload();
  170. });
  171. } else {
  172. layer.close(indexs); //关闭弹层
  173. layer.msg(data);
  174. }
  175. }
  176. });
  177. });
  178. },
  179. };
  180. $('.layui-btn').on('click', function () {
  181. var type = $(this).data('type');
  182. active[type] ? active[type].call(this) : '';
  183. });
  184. });