report-wv.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  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>报表详情</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. .model {
  28. width: 100%;
  29. height: 100%;
  30. background: rgba(0, 0, 0, 0.3);
  31. position: fixed;
  32. z-index: 9999;
  33. }
  34. .table-box {
  35. width: 300px;
  36. height: 300px;
  37. background: #ffffff;
  38. margin: auto;
  39. position: absolute;
  40. top: 0;
  41. left: 0;
  42. right: 0;
  43. bottom: 0;
  44. padding: 10px;
  45. overflow-y: auto;
  46. }
  47. .head {
  48. display: flex;
  49. justify-content: flex-end;
  50. font-size: 20px;
  51. font-weight: bold;
  52. color: #000000;
  53. }
  54. .cel {
  55. cursor: pointer;
  56. }
  57. #table {
  58. width: 100%;
  59. margin-top: 20px;
  60. font-size: 18px;
  61. }
  62. #table tr {
  63. width: 100%;
  64. height: 30px;
  65. }
  66. #table td {
  67. border-bottom: 1px solid #000000;
  68. border-top: 1px solid #000000;
  69. padding: 5px;
  70. }
  71. .layui-layer-title {
  72. text-align: center;
  73. font-size: 16px;
  74. padding: 0 81px;
  75. }
  76. .layui-layer {
  77. top: 70 !important;
  78. }
  79. </style>
  80. </head>
  81. <body>
  82. <div id="luckysheet" style="margin:0px;padding:0px;position:absolute;width:100%;height:90%;left: 0px;top: 0px;">
  83. </div>
  84. <table id="demo" lay-filter="test"></table>
  85. <!-- <div class="model" style="display: none;">
  86. <div class="table-box">
  87. <div class="head"> -->
  88. <!-- <div>运行记录</div> -->
  89. <!-- <div class="cel">×</div>
  90. </div>
  91. <table id="table">
  92. <tr>
  93. <th>
  94. 运行内容
  95. </th>
  96. </tr>
  97. </table>
  98. </div>
  99. </div> -->
  100. <div class="la-btn">
  101. <button id="recordBtn" type="button" class="layui-btn layui-btn-normal layui-btn-sm btn">运行记录</button>
  102. </div>
  103. <script src="../jquery.min.js"></script>
  104. <script src="../dist/layui.js"></script>
  105. <script src="../luckysheet/dist/luckysheet.umd.js"></script>
  106. <script src="../luckysheet/dist/plugins/js/plugin.js"></script>
  107. <script src="./plugins/exceljs.min.js"></script>
  108. <script src="./plugins/excelopput.js"></script>
  109. <script src="./plugins/echarts.js"></script>
  110. <!-- <script src="./echarts.js"></script> -->
  111. <script src="./cqcyCode.js"></script>
  112. <script src="./canvertChart.js"></script>
  113. <!-- uni 的 SDK -->
  114. <script src="./wvIP.js"></script>
  115. <script src="./plugins/axios.min.js"></script>
  116. <script type="text/javascript" src="../luckysheet/dist/plugins/js/uni-webview-js0.0.3_index.js"></script>
  117. <Script>
  118. function GetQueryString(name) {
  119. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  120. var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
  121. var context = "";
  122. if (r != null)
  123. context = decodeURIComponent(r[2]);
  124. reg = null;
  125. r = null;
  126. return context == null || context == "" || context == "undefined" ? "" : context;
  127. }
  128. </Script>
  129. <script>
  130. $(function() {
  131. document.addEventListener('UniAppJSBridgeReady', function() {
  132. uni.getEnv(function(res) {
  133. console.log('当前环境:' + JSON.stringify(res));
  134. window.sessionName = 'device_report_index'
  135. sessionStorage.removeItem(window.sessionName)
  136. const id = GetQueryString('id')
  137. axios.defaults.baseURL = baseUrl
  138. var reportTableName
  139. axios.get('/reportTable/getReportTableById?id=' + id)
  140. .then(res => {
  141. //console.log(res, 'res');
  142. const data = res.data
  143. if (data.code === 200) {
  144. // 报表类型
  145. let reportTableType = data.data.reportTableType
  146. //报表名
  147. reportTableName = data.data.reportTableName
  148. const templateData = JSON.parse(data.data.reportTableData)
  149. let s_data = $.extend(true, {}, templateData.sheet)
  150. delete s_data.chart
  151. const option = {
  152. container: 'luckysheet',
  153. data: [s_data],
  154. title: '报表模板',
  155. lang: 'zh',
  156. showinfobar: false,
  157. showtoolbar: false,
  158. showtoolbarConfig: {
  159. paintFormat: true, //格式刷
  160. moreFormats: true, // 单元格格式
  161. font: true, // 字体
  162. fontSize: true, // 字号大小
  163. bold: true, // 粗体 (Ctrl+B)
  164. italic: true, // 斜体 (Ctrl+I)
  165. strikethrough: true, // 删除线 (Alt+Shift+5)
  166. underline: true, // 下划线 (Alt+Shift+6)
  167. textColor: true, // 文本颜色
  168. fillColor: true, // 单元格颜色
  169. border: true, // 边框
  170. mergeCell: true, // 合并单元格
  171. horizontalAlignMode: true, // 水平对齐方式
  172. verticalAlignMode: true, // 垂直对齐方式
  173. function: true, // 公式
  174. print: false,
  175. image: true,
  176. link: true,
  177. textRotateMode: true,
  178. sortAndFilter: true
  179. },
  180. showsheetbar: false,
  181. showstatisticBar: false,
  182. sheetFormulaBar: false,
  183. allowCopy:false,
  184. allowUpdate:false,
  185. allowEdit:true,
  186. forceCalculation:true,
  187. cellRightClickConfig: {
  188. copy: false, // 复制
  189. copyAs: false, // 复制为
  190. paste: false, // 粘贴
  191. insertRow: false, // 插入行
  192. insertColumn: false, // 插入列
  193. deleteRow: false, // 删除选中行
  194. deleteColumn: false, // 删除选中列
  195. deleteCell: false, // 删除单元格
  196. hideRow: false, // 隐藏选中行和显示选中行
  197. hideColumn: false, // 隐藏选中列和显示选中列
  198. rowHeight: false, // 行高
  199. columnWidth: false, // 列宽
  200. clear: false, // 清除内容
  201. matrix: false, // 矩阵操作选区
  202. sort: false, // 排序选区
  203. filter: false, // 筛选选区
  204. chart: false, // 图表生成
  205. image: false, // 插入图片
  206. link: false, // 插入链接
  207. data: false, // 数据验证
  208. cellFormat: false // 设置单元格格式
  209. },
  210. plugins: ['chart'],
  211. hook: {
  212. cellEditBefore: function(range) {
  213. const cell = getCellData((range[0].row)[0], (range[0].column)[0])
  214. if (cell) {
  215. try {
  216. const data = JSON.parse(cell) || {}
  217. if (data && data.tableId) {
  218. return false
  219. }
  220. } catch(e) {
  221. //console.log(e)
  222. }
  223. }
  224. return false;
  225. },
  226. cellUpdateBefore: function(r, c, val) {
  227. const cell = getCellData(r, c)
  228. if (cell) {
  229. try {
  230. const data = JSON.parse(cell) || {}
  231. if (data && data.tableId) {
  232. return false
  233. }
  234. } catch(e) {
  235. //console.log(e)
  236. }
  237. }
  238. return true
  239. },
  240. cellMousedown:function(cell,position,sheet,ctx){
  241. //console.log('r='+position.r+','+'c='+position.c);
  242. //console.log(position.c);
  243. console.log(cell);
  244. },
  245. workbookCreateAfter: function() {
  246. luckysheet.setRangeShow('B1:B2', {
  247. success: () => {
  248. for (let key in templateData.chart) {
  249. //console.log(templateData.chart[key])
  250. luckysheet.showHistoryChart({
  251. chartId: key,
  252. option: templateData.chart[key].position,
  253. init: function(chart, chartId) {
  254. const colorForm = templateData.chart[key].colorForm
  255. if (colorForm.background) {
  256. templateData.chart[key].chartData.backgroundColor = colorForm.background
  257. $(`#${chartId}_c`).css('background', colorForm.background)
  258. }
  259. const xForm = templateData.chart[key].xForm;
  260. let chart_new = templateData.chart[key].chartData;
  261. if(xForm!=undefined){
  262. chart_new.xAxis[0].axisLabel.formatter = function (value) {
  263. var date = new Date(value);
  264. if(date.toString()=='Invalid Date'){
  265. return value
  266. }else{
  267. return new Date(value).format(xForm.formatter)
  268. }
  269. };
  270. }
  271. chart.setOption(chart_new, {
  272. notMerge: true
  273. })
  274. // chart.setOption(templateData.chart[key].chartData, {
  275. // notMerge: true
  276. // })
  277. if (colorForm.border) {
  278. $(`#${chartId}_c`).css('border', '1px solid ' + colorForm.border)
  279. }
  280. },
  281. })
  282. }
  283. // if(callback){
  284. // callback()
  285. // return
  286. // }
  287. }
  288. })
  289. }
  290. }
  291. }
  292. luckysheet.create(option)
  293. } else {
  294. }
  295. })
  296. $('#recordBtn').on('click', () => {
  297. $('.model').show()
  298. const token = window.localStorage.getItem('C_TOKEN')
  299. layui.use('table', function() {
  300. var table = layui.table;
  301. var layer = layui.layer;
  302. layer.open({
  303. type: 1,
  304. title: '运行记录',
  305. content: $('#demo'),
  306. offset: ['30px', '45px'],
  307. end: function() {
  308. $('#demo').hide();
  309. $('.layui-table-view').hide()
  310. },
  311. cancel: function(index, layero) {
  312. $('.layui-layer-content')
  313. .hide()
  314. }
  315. });
  316. var tableReload = table.render({
  317. elem: '#demo',
  318. width: 300,
  319. page: {
  320. elem: '#demo',
  321. layout: ['prev', 'page', 'next',
  322. 'count'
  323. ]
  324. },
  325. url: baseUrl+'/reportTable/getAutoChReportTable',
  326. headers: {
  327. token: token
  328. },
  329. where: {
  330. autoTableId: id
  331. },
  332. text: {
  333. none: '暂无数据' //默认:无数据。
  334. },
  335. cols: [
  336. [{
  337. field: 'reportTableName',
  338. title: null,
  339. width: 300
  340. }]
  341. ],
  342. parseData: function(res) {
  343. return {
  344. "code": 0,
  345. "msg": res.msg,
  346. "count": res.data.count,
  347. "data": res.data
  348. .reportTableList
  349. };
  350. }
  351. });
  352. //触发行单击事件
  353. table.on('row(test)', function(obj) {
  354. const id = obj.data.id
  355. const title = obj.data
  356. .reportTableName
  357. uni.navigateTo({
  358. url: `/pages/reportForm/report-detail/recordDetail?id=${id}&title=${title}`
  359. })
  360. });
  361. $('th').hide()
  362. });
  363. })
  364. });
  365. });
  366. })
  367. </script>
  368. </body>
  369. </html>