UserTradeDaySummary_Admin.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. var ExcelData;
  2. function ConfirmImport() {
  3. $.ajax({
  4. type: "POST",
  5. url: "/Admin/UserTradeDaySummary/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. laydate.render({
  59. elem: '#TradeMonthSelect'
  60. , type: 'month'
  61. });
  62. //excel导入
  63. excel = layui.excel;
  64. $('#ExcelFile').change(function (e) {
  65. var files = e.target.files;
  66. excel.importExcel(files, { }, function (data) {
  67. ExcelData = data[0].sheet1;
  68. });
  69. });
  70. //监听单元格编辑
  71. table.on('edit(LAY-list-manage)', function(obj){
  72. var value = obj.value //得到修改后的值
  73. ,data = obj.data //得到所在行所有键值
  74. ,field = obj.field; //得到字段
  75. if(field == "Sort"){
  76. $.ajax({
  77. type: "POST",
  78. url: "/Admin/UserTradeDaySummary/Sort?r=" + Math.random(1),
  79. data: "Id=" + data.Id + "&Sort=" + value,
  80. dataType: "text",
  81. success: function (data) {
  82. }
  83. });
  84. }
  85. });
  86. //列表数据
  87. table.render({
  88. elem: '#LAY-list-manage'
  89. , url: '/Admin/UserTradeDaySummary/IndexData' //模拟接口
  90. , cols: [[
  91. { type: 'checkbox', fixed: 'left' }
  92. ,{field:'MakerCode', width: 200, title:'创客编号', sort: true}
  93. ,{field:'RealName', width: 200, title:'创客姓名', sort: true}
  94. ,{field:'TradeDate', width: 200, title:'交易日期', sort: true}
  95. ,{field:'TradeMonth', width: 200, title:'交易所在月份', sort: true}
  96. ,{field:'BrandId', width: 200, title:'产品名称', sort: true}
  97. ,{field:'HelpDirectTradeAmt', width: 300, title:'扶持期直营贷记卡交易', sort: true}
  98. ,{field:'NotHelpDirectTradeAmt', width: 300, title:'稳定期直营贷记卡交易', sort: true}
  99. ,{field:'HelpDirectDebitTradeAmt', width: 300, title:'扶持期直营借记卡交易', sort: true}
  100. ,{field:'NotHelpDirectDebitTradeAmt', width: 300, title:'稳定期直营借记卡交易', sort: true}
  101. ,{field:'HelpNonDirectTradeAmt', width: 300, title:'扶持期非直营贷记卡交易', sort: true}
  102. ,{field:'NotHelpNonDirectTradeAmt', width: 300, title:'稳定期非直营贷记卡交易', sort: true}
  103. ,{field:'HelpNonDirectDebitTradeAmt', width: 300, title:'扶持期非直营借记卡交易', sort: true}
  104. ,{field:'NotHelpNonDirectDebitTradeAmt', width: 300, title:'稳定期非直营借记卡交易', sort: true}
  105. ,{field:'Remark', width: 200, title:'备注', sort: true}
  106. ]]
  107. , where: {
  108. }
  109. , page: true
  110. , limit: 30
  111. , height: 'full-' + String($('.layui-card-header').height() + 130)
  112. , text: '对不起,加载出现异常!'
  113. , done: function (res, curr, count) {
  114. $("#HelpDirectTradeAmt").text(res.other.HelpDirectTradeAmt);
  115. $("#NotHelpDirectTradeAmt").text(res.other.NotHelpDirectTradeAmt);
  116. $("#HelpDirectDebitTradeAmt").text(res.other.HelpDirectDebitTradeAmt);
  117. $("#NotHelpDirectDebitTradeAmt").text(res.other.NotHelpDirectDebitTradeAmt);
  118. $("#HelpNonDirectTradeAmt").text(res.other.HelpNonDirectTradeAmt);
  119. $("#NotHelpNonDirectTradeAmt").text(res.other.NotHelpNonDirectTradeAmt);
  120. $("#HelpNonDirectDebitTradeAmt").text(res.other.HelpNonDirectDebitTradeAmt);
  121. $("#NotHelpNonDirectDebitTradeAmt").text(res.other.NotHelpNonDirectDebitTradeAmt);
  122. $(".layui-none").text("无数据");
  123. }
  124. });
  125. //监听工具条
  126. table.on('tool(LAY-list-manage)', function (obj) {
  127. var data = obj.data;
  128. if (obj.event === 'del') {
  129. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  130. $.ajax({
  131. type: "POST",
  132. url: "/Admin/UserTradeDaySummary/Delete?r=" + Math.random(1),
  133. data: "Id=" + data.Id,
  134. dataType: "text",
  135. success: function (data) {
  136. if (data == "success") {
  137. obj.del();
  138. layer.close(index);
  139. } else {
  140. parent.layer.msg(data);
  141. }
  142. }
  143. });
  144. });
  145. } else if (obj.event === 'edit') {
  146. var tr = $(obj.tr);
  147. var perContent = layer.open({
  148. type: 2
  149. , title: '创客交易日汇总-编辑'
  150. , content: 'Edit?Id=' + data.Id + ''
  151. , maxmin: true
  152. , area: ['500px', '450px']
  153. , btn: ['确定', '取消']
  154. , yes: function (index, layero) {
  155. var iframeWindow = window['layui-layer-iframe' + index]
  156. , submitID = 'LAY-list-front-submit'
  157. , submit = layero.find('iframe').contents().find('#' + submitID);
  158. setTimeout(function () {
  159. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  160. var errObj = $(this).find('.layui-form-danger');
  161. if (errObj.length > 0) {
  162. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  163. submit.click();
  164. }
  165. });
  166. }, 300);
  167. //监听提交
  168. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  169. var field = data.field; //获取提交的字段
  170. var userdata = "";
  171. for (var prop in field) {
  172. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  173. }
  174. //提交 Ajax 成功后,静态更新表格中的数据
  175. //$.ajax({});
  176. $.ajax({
  177. type: "POST",
  178. url: "/Admin/UserTradeDaySummary/Edit?r=" + Math.random(1),
  179. data: userdata,
  180. dataType: "text",
  181. success: function (data) {
  182. layer.close(index); //关闭弹层
  183. if (data == "success") {
  184. table.reload('LAY-list-manage'); //数据刷新
  185. } else {
  186. layer.msg(data);
  187. }
  188. }
  189. });
  190. });
  191. submit.trigger('click');
  192. }
  193. , success: function (layero, index) {
  194. }
  195. });
  196. layer.full(perContent);
  197. }
  198. });
  199. //监听搜索
  200. form.on('submit(LAY-list-front-search)', function (data) {
  201. var field = data.field;
  202. //执行重载
  203. table.reload('LAY-list-manage', {
  204. where: field,
  205. page: {
  206. curr: 1
  207. }
  208. });
  209. });
  210. form.on('submit(LAY-list-front-searchall)', function (data) {
  211. table.reload('LAY-list-manage', {
  212. where: null,
  213. page: {
  214. curr: 1
  215. }
  216. });
  217. });
  218. //事件
  219. var active = {
  220. batchdel: function () {
  221. var checkStatus = table.checkStatus('LAY-list-manage')
  222. , data = checkStatus.data; //得到选中的数据
  223. if (data.length < 1) {
  224. parent.layer.msg("请选择要删除的项");
  225. } else {
  226. var ids = "";
  227. $.each(data, function (index, value) {
  228. ids += data[index].Id + ",";
  229. });
  230. ids = ids.substring(0, ids.length - 1);
  231. var index = layer.confirm('确定要删除吗?删除后不能恢复!', function (index) {
  232. $.ajax({
  233. type: "POST",
  234. url: "/Admin/UserTradeDaySummary/Delete?r=" + Math.random(1),
  235. data: "Id=" + ids,
  236. dataType: "text",
  237. success: function (data) {
  238. layer.close(index);
  239. if (data == "success") {
  240. table.reload('LAY-list-manage');
  241. } else {
  242. layer.msg(data);
  243. }
  244. }
  245. });
  246. });
  247. }
  248. }
  249. , add: function () {
  250. var perContent = layer.open({
  251. type: 2
  252. , title: '创客交易日汇总-添加'
  253. , content: 'Add'
  254. , maxmin: true
  255. , area: ['500px', '450px']
  256. , btn: ['确定', '取消']
  257. , yes: function (index, layero) {
  258. var iframeWindow = window['layui-layer-iframe' + index]
  259. , submitID = 'LAY-list-front-submit'
  260. , submit = layero.find('iframe').contents().find('#' + submitID);
  261. setTimeout(function () {
  262. layero.find('iframe').contents().find('.layui-tab-item').each(function (i) {
  263. var errObj = $(this).find('.layui-form-danger');
  264. if (errObj.length > 0) {
  265. iframeWindow.element.tabChange('mytabbar', String(i + 1));
  266. submit.click();
  267. }
  268. });
  269. }, 300);
  270. //监听提交
  271. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  272. var field = data.field; //获取提交的字段
  273. var userdata = "";
  274. for (var prop in field) {
  275. userdata += prop + "=" + encodeURIComponent(field[prop]) + "&";
  276. }
  277. //提交 Ajax 成功后,静态更新表格中的数据
  278. //$.ajax({});
  279. $.ajax({
  280. type: "POST",
  281. url: "/Admin/UserTradeDaySummary/Add?r=" + Math.random(1),
  282. data: userdata,
  283. dataType: "text",
  284. success: function (data) {
  285. layer.close(index); //关闭弹层
  286. if (data == "success") {
  287. table.reload('LAY-list-manage'); //数据刷新
  288. } else {
  289. layer.msg(data);
  290. }
  291. }
  292. });
  293. });
  294. submit.trigger('click');
  295. }
  296. });
  297. layer.full(perContent);
  298. }
  299. , ImportData: function () {
  300. layer.open({
  301. type: 1,
  302. title: '导入',
  303. maxmin: false,
  304. area: ['460px', '180px'],
  305. content: $('#excelForm'),
  306. cancel: function () {
  307. }
  308. });
  309. }
  310. , ExportExcel: function () {
  311. var userdata = '';
  312. $(".layuiadmin-card-header-auto input").each(function (i) {
  313. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  314. });
  315. $(".layuiadmin-card-header-auto select").each(function (i) {
  316. userdata += $(this).attr('name') + '=' + encodeURIComponent($(this).val()) + '&';
  317. });
  318. $.ajax({
  319. type: "GET",
  320. url: "/Admin/UserTradeDaySummary/ExportExcel?r=" + Math.random(1),
  321. data: userdata,
  322. dataType: "json",
  323. success: function (data) {
  324. data.Obj.unshift(data.Fields);
  325. excel.exportExcel(data.Obj, data.Info, 'xlsx');
  326. }
  327. });
  328. }
  329. , Open: function () {
  330. var checkStatus = table.checkStatus('LAY-list-manage')
  331. , data = checkStatus.data; //得到选中的数据
  332. if(data.length < 1){
  333. parent.layer.msg("请选择要开启的项");
  334. }else{
  335. var ids = "";
  336. $.each(data, function (index, value) {
  337. ids += data[index].Id + ",";
  338. });
  339. ids = ids.substring(0, ids.length - 1);
  340. var index = layer.confirm('确定要开启吗?', function (index) {
  341. $.ajax({
  342. type: "POST",
  343. url: "/Admin/UserTradeDaySummary/Open?r=" + Math.random(1),
  344. data: "Id=" + ids,
  345. dataType: "text",
  346. success: function (data) {
  347. layer.close(index);
  348. if (data == "success") {
  349. table.reload('LAY-list-manage');
  350. } else {
  351. layer.msg(data);
  352. }
  353. }
  354. });
  355. });
  356. }
  357. }
  358. , Close: function () {
  359. var checkStatus = table.checkStatus('LAY-list-manage')
  360. , data = checkStatus.data; //得到选中的数据
  361. if(data.length < 1){
  362. parent.layer.msg("请选择要关闭的项");
  363. }else{
  364. var ids = "";
  365. $.each(data, function (index, value) {
  366. ids += data[index].Id + ",";
  367. });
  368. ids = ids.substring(0, ids.length - 1);
  369. var index = layer.confirm('确定要关闭吗?', function (index) {
  370. $.ajax({
  371. type: "POST",
  372. url: "/Admin/UserTradeDaySummary/Close?r=" + Math.random(1),
  373. data: "Id=" + ids,
  374. dataType: "text",
  375. success: function (data) {
  376. layer.close(index);
  377. if (data == "success") {
  378. table.reload('LAY-list-manage');
  379. } else {
  380. layer.msg(data);
  381. }
  382. }
  383. });
  384. });
  385. }
  386. }
  387. };
  388. $('.layui-btn').on('click', function () {
  389. var type = $(this).data('type');
  390. active[type] ? active[type].call(this) : '';
  391. });
  392. });