PosFeeWarningRecord_Admin.js 11 KB

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