PosFeeWarningRecord_Admin.js 10 KB

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