report-wv.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <link rel='stylesheet' href='../luckysheet/dist/plugins/plugins.css' />
  9. <link rel='stylesheet' href='../luckysheet/dist/plugins/css/pluginsCss.css' />
  10. <link rel='stylesheet' href='../luckysheet/dist/css/luckysheet.css' />
  11. <link rel='stylesheet' href='../luckysheet/dist/assets/iconfont/iconfont.css' />
  12. <link rel="stylesheet" href="../dist/css/layui.css">
  13. <style>
  14. .la-btn {
  15. position: absolute;
  16. left: 50%;
  17. bottom: 35px;
  18. transform: translate(-50%);
  19. padding: 0 2%;
  20. }
  21. .btn {
  22. width: 100%;
  23. }
  24. .layui-laypage-em {
  25. background-color: #1e9fff !important;
  26. }
  27. </style>
  28. </head>
  29. <body>
  30. <div id="luckysheet" style="margin:0px;padding:0px;position:absolute;width:100%;height:90%;left: 0px;top: 0px;">
  31. </div>
  32. <table id="demo" lay-filter="test"></table>
  33. <div class="la-btn">
  34. <button id="recordBtn" type="button" class="layui-btn layui-btn-normal layui-btn-sm btn">运行记录</button>
  35. </div>
  36. <script src="../jquery.min.js"></script>
  37. <script src="../dist/layui.js"></script>
  38. <script src="../luckysheet/dist/luckysheet.umd.js"></script>
  39. <script src="../luckysheet/dist/plugins/js/plugin.js"></script>
  40. <!-- uni 的 SDK -->
  41. <script type="text/javascript" src="https://unpkg.com/@dcloudio/uni-webview-js@0.0.3/index.js"></script>
  42. <script>
  43. document.addEventListener('UniAppJSBridgeReady', function() {
  44. uni.getEnv(function(res) {
  45. console.log('当前环境:' + JSON.stringify(res));
  46. const id = window.location.search.split('?id=')[1]
  47. $.ajax({
  48. url: "http://192.168.0.40:8081/reportTable/getReportTableById/" + id,
  49. type: 'GET',
  50. success: function(res) {
  51. if (res.code === 200) {
  52. const tableData = JSON.parse(res.data.reportTableData)
  53. const option = tableData.option
  54. console.log(tableData)
  55. if (option) {
  56. option.allowEdit = false
  57. tableData.showtoolbar = false
  58. tableData.option.enableAddRow = false
  59. tableData.option.enableAddBackTop = false
  60. let data = tableData.option.showtoolbarConfig
  61. for (let item in data) {
  62. data[item] = false
  63. }
  64. option.data = tableData.data
  65. luckysheet.create(option)
  66. printExcel()
  67. }
  68. } else {
  69. layer.msg(res.msg);
  70. }
  71. }
  72. })
  73. function printExcel(){
  74. luckysheet.hideGridLines()
  75. let imgSrc = luckysheet.getScreenshot();
  76. luckysheet.showGridLines();
  77. console.log(imgSrc);
  78. $.ajax({
  79. url: "" ,
  80. type: 'GET',
  81. success: function(res) {
  82. }
  83. })
  84. }
  85. $('#recordBtn').on('click', () => {
  86. layui.use('table', function() {
  87. var table = layui.table;
  88. var layer = layui.layer;
  89. layer.open({
  90. type: 1,
  91. title: '运行记录',
  92. content: $('#demo'),
  93. offset: ['180px', '45px'],
  94. end: function() {
  95. $('#demo').hide();
  96. $('.layui-table-view').hide()
  97. },
  98. cancel: function(index, layero) {
  99. $('.layui-layer-content').hide()
  100. }
  101. });
  102. var tableReload = table.render({
  103. elem: '#demo',
  104. width: 300,
  105. page: {
  106. elem: '#demo',
  107. layout: ['prev', 'page', 'next', 'count']
  108. },
  109. url: 'http://192.168.0.40:8081/reportTable/getAutoChReportTable',
  110. where: {
  111. autoTableId: id
  112. },
  113. text: {
  114. none: '暂无数据' //默认:无数据。
  115. },
  116. cols: [
  117. [{
  118. field: 'reportTableName',
  119. title: null,
  120. width: 300
  121. }]
  122. ],
  123. parseData: function(res) {
  124. return {
  125. "code": 0,
  126. "msg": res.msg,
  127. "count": res.data.count,
  128. "data": res.data.reportTableList
  129. };
  130. }
  131. });
  132. //触发行单击事件
  133. table.on('row(test)', function(obj) {
  134. const id = obj.data.id
  135. const title = obj.data.reportTableName
  136. uni.navigateTo({
  137. url: `/pages/reportForm/report-detail/recordDetail?id=${id}&title=${title}`
  138. })
  139. });
  140. $('th').hide()
  141. });
  142. })
  143. });
  144. });
  145. </script>
  146. </body>
  147. </html>