TradeRecordSIM_Admin.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. var excel;
  2. layui.config({
  3. base: '/layuiadmin/' //静态资源所在路径
  4. }).extend({
  5. myexcel: 'layui/lay/modules/excel',
  6. index: 'lib/index' //主入口模块
  7. }).use(['index', 'table', 'excel', 'laydate'], function () {
  8. var $ = layui.$
  9. , form = layui.form
  10. , table = layui.table;
  11. //- 筛选条件-日期
  12. var laydate = layui.laydate;
  13. var layCreateDate = laydate.render({
  14. elem: '#CreateDate',
  15. type: 'date',
  16. range: true,
  17. trigger: 'click',
  18. change: function (value, date, endDate) {
  19. var op = true;
  20. if (date.year == endDate.year && endDate.month - date.month <= 1) {
  21. if (endDate.month - date.month == 1 && endDate.date > date.date) {
  22. op = false;
  23. layCreateDate.hint('日期范围请不要超过1个月');
  24. setTimeout(function () {
  25. $(".laydate-btns-confirm").addClass("laydate-disabled");
  26. }, 1);
  27. }
  28. } else {
  29. op = false;
  30. layCreateDate.hint('日期范围请不要超过1个月');
  31. setTimeout(function () {
  32. $(".laydate-btns-confirm").addClass("laydate-disabled");
  33. }, 1);
  34. }
  35. if (op) {
  36. $('#CreateDate').val(value);
  37. }
  38. }
  39. });
  40. var layTradeDate = laydate.render({
  41. elem: '#DateStr',
  42. trigger: 'click',
  43. type: 'date',
  44. });
  45. //excel导入
  46. excel = layui.excel;
  47. $('#ExcelFile').change(function (e) {
  48. var files = e.target.files;
  49. excel.importExcel(files, {}, function (data) {
  50. ExcelData = data[0].sheet1;
  51. });
  52. });
  53. //监听单元格编辑
  54. table.on('edit(LAY-list-manage)', function (obj) {
  55. var value = obj.value //得到修改后的值
  56. , data = obj.data //得到所在行所有键值
  57. , field = obj.field; //得到字段
  58. if (field == "Sort") {
  59. $.ajax({
  60. type: "POST",
  61. url: "/Admin/TradeRecord/Sort?r=" + Math.random(1),
  62. data: "Id=" + data.Id + "&Sort=" + value,
  63. dataType: "text",
  64. success: function (data) {
  65. }
  66. });
  67. }
  68. });
  69. //激活预览列表数据
  70. table.render({
  71. elem: '#LAY-list-manage'
  72. , url: '/Admin/TradeRecord/IndexDataSIMDo' //模拟接口
  73. , cols: [[
  74. { type: 'checkbox', fixed: 'left' }
  75. , { field: 'iccId', width: 200, title: '广电卡号', sort: true } //广电卡号
  76. , { field: 'orderNo', width: 200, title: '订单编码', sort: true } //订单编码
  77. , { field: 'orderCreateTime', width: 200, title: '订单创建时间', sort: true } //订单创建时间
  78. , { field: 'phoneNo', width: 200, title: '选择号码', sort: true } //选择号码
  79. , { field: 'firstCharge', width: 200, title: '是否有首充', sort: true } //是否有首充
  80. , { field: 'initialChargeAmount', width: 200, title: '首充金额(元)', sort: true } //首充金额(元)
  81. , { field: 'province', width: 200, title: '号码归属省份', sort: true } //号码归属省份
  82. , { field: 'city', width: 200, title: '号码归属地市', sort: true } //号码归属地市
  83. , { field: 'productName', width: 200, title: '商品名称', sort: true } //商品名称
  84. , { field: 'promotionName', width: 200, title: '促销活动名称', sort: true } //促销活动名称
  85. , { field: 'productTypeName', width: 200, title: '商品类型名称', sort: true } //商品类型名称
  86. , { field: 'paidInAmount', width: 200, title: '实付金额', sort: true } //实付金额(元)
  87. , { field: 'orderStatus', width: 200, title: '订单状态', sort: true } //订单状态
  88. , { field: 'activationStatusName', width: 200, title: '激活状态名称', sort: true } //激活状态名称
  89. , { field: 'activationTime', width: 200, title: '激活时间', sort: true } //激活时间
  90. , { field: 'jobId', width: 200, title: 'BOSS员工工号', sort: true } //BOSS员工工号
  91. ]]
  92. , page: true
  93. , limit: 30
  94. , height: 'full-' + String($('.layui-card-header').height() + 130)
  95. , text: '对不起,加载出现异常!'
  96. , done: function (res, curr, count) {
  97. $(".layui-none").text("无数据");
  98. }
  99. });
  100. //监听搜索
  101. form.on('submit(LAY-list-front-search)', function (data) {
  102. var field = data.field;
  103. //执行重载
  104. table.reload('LAY-list-manage', {
  105. where: field,
  106. page: {
  107. curr: 1
  108. }
  109. });
  110. });
  111. form.on('submit(LAY-list-front-GetSimTradePost)', function (data) {
  112. var field = data.field;
  113. console.log(field);
  114. var index = layer.load(1, {
  115. shade: [0.5, '#000']
  116. });
  117. $.ajax({
  118. type: "POST",
  119. url: "/Admin/TradeRecord/GetSimTradePost?r=" + Math.random(1),
  120. data: "DateStr=" + field.DateStr,
  121. dataType: "text",
  122. success: function (msg) {
  123. layer.close(index); //关闭弹层
  124. if (msg == "success") {
  125. layer.msg("提交成功");
  126. } else {
  127. layer.msg(msg);
  128. }
  129. }
  130. });
  131. });
  132. form.on('submit(LAY-list-front-searchall)', function (data) {
  133. table.reload('LAY-list-manage', {
  134. where: null,
  135. page: {
  136. curr: 1
  137. }
  138. });
  139. });
  140. //事件
  141. var active = {
  142. GetActInfo: function () {
  143. var index = layer.confirm('确定要获取吗?', function (index) {
  144. //监听提交
  145. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  146. var field = data.field; //获取提交的字段
  147. var userdata = "";
  148. for (var prop in field) {
  149. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  150. }
  151. //提交 Ajax 成功后,静态更新表格中的数据
  152. //$.ajax({});
  153. $.ajax({
  154. type: "POST",
  155. url: "/Admin/TradeRecord/GetSimTradePost?r=" + Math.random(1),
  156. data: userdata,
  157. dataType: "text",
  158. success: function (data) {
  159. layer.close(index); //关闭弹层
  160. if (data == "success") {
  161. layer.msg("提交成功");
  162. } else {
  163. layer.msg(data);
  164. }
  165. }
  166. });
  167. });
  168. });
  169. }
  170. };
  171. $('.layui-btn').on('click', function () {
  172. var type = $(this).data('type');
  173. active[type] ? active[type].call(this) : '';
  174. });
  175. });