PrizeFlowRecord_Admin.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. var ExcelData, ExcelKind;
  2. function ConfirmImport() {
  3. $.ajax({
  4. type: "POST",
  5. url: "/Admin/PrizeFlowRecord/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. //excel导入
  31. excel = layui.excel;
  32. $('#ExcelFile').change(function (e) {
  33. var files = e.target.files;
  34. excel.importExcel(files, {}, function (data) {
  35. ExcelData = data[0].sheet1;
  36. });
  37. });
  38. //监听单元格编辑
  39. table.on('edit(LAY-list-manage)', function (obj) {
  40. var value = obj.value //得到修改后的值
  41. , data = obj.data //得到所在行所有键值
  42. , field = obj.field; //得到字段
  43. });
  44. //列表数据
  45. table.render({
  46. elem: '#LAY-list-manage'
  47. , url: '/Admin/PrizeFlowRecord/IndexData' //模拟接口
  48. , cols: [[
  49. { type: 'checkbox', fixed: 'left' }
  50. , { field: 'Id', fixed: 'left', title: 'ID', width: 80, sort: true, unresize: true }
  51. , { field: 'KindName', width: 200, title: '来源类型', sort: true }
  52. , { field: 'CodeNumber', width: 200, title: '机具号/订单号', sort: true }
  53. , { field: 'CreateDate', width: 200, title: '创建时间', sort: true }
  54. , { field: 'Detail', width: 600, title: '描述', sort: true }
  55. ]]
  56. , where: {
  57. }
  58. , page: true
  59. , limit: 30
  60. , height: 'full-220'
  61. , text: '对不起,加载出现异常!'
  62. , done: function (res, curr, count) {
  63. $(".layui-none").text("无数据");
  64. }
  65. });
  66. //监听工具条
  67. table.on('tool(LAY-list-manage)', function (obj) {
  68. var data = obj.data;
  69. });
  70. //监听搜索
  71. form.on('submit(LAY-list-front-search)', function (data) {
  72. var field = data.field;
  73. //执行重载
  74. table.reload('LAY-list-manage', {
  75. where: field,
  76. page: {
  77. curr: 1
  78. }
  79. });
  80. });
  81. form.on('submit(LAY-list-front-searchall)', function (data) {
  82. table.reload('LAY-list-manage', {
  83. where: null,
  84. page: {
  85. curr: 1
  86. }
  87. });
  88. });
  89. //事件
  90. var active = {
  91. };
  92. $('.layui-btn').on('click', function () {
  93. var type = $(this).data('type');
  94. active[type] ? active[type].call(this) : '';
  95. });
  96. });