report-wv.html 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  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. .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. </style>
  72. </head>
  73. <body>
  74. <div id="luckysheet" style="margin:0px;padding:0px;position:absolute;width:100%;height:90%;left: 0px;top: 0px;">
  75. </div>
  76. <!-- <table id="demo" lay-filter="test"></table> -->
  77. <div class="model" style="display: none;">
  78. <div class="table-box">
  79. <div class="head">
  80. <!-- <div>运行记录</div> -->
  81. <div class="cel">×</div>
  82. </div>
  83. <table id="table">
  84. <tr>
  85. <th>
  86. 运行内容
  87. </th>
  88. </tr>
  89. </table>
  90. </div>
  91. </div>
  92. <div class="la-btn">
  93. <button id="recordBtn" type="button" class="layui-btn layui-btn-normal layui-btn-sm btn">运行记录</button>
  94. </div>
  95. <script src="../jquery.min.js"></script>
  96. <script src="../dist/layui.js"></script>
  97. <script src="../luckysheet/dist/luckysheet.umd.js"></script>
  98. <script src="../luckysheet/dist/plugins/js/plugin.js"></script>
  99. <script src="./echarts.js"></script>
  100. <script src="./cqcyCode.js"></script>
  101. <script src="./canvertChart.js"></script>
  102. <!-- uni 的 SDK -->
  103. <script src="./wvIP.js"></script>
  104. <script src="./plugins/axios.min.js"></script>
  105. <script type="text/javascript" src="../luckysheet/dist/plugins/js/uni-webview-js0.0.3_index.js"></script>
  106. <script>
  107. $(function() {
  108. document.addEventListener('UniAppJSBridgeReady', function() {
  109. uni.getEnv(function(res) {
  110. console.log('当前环境:' + JSON.stringify(res));
  111. const id = window.location.search.split('?id=')[1]
  112. // axios.defaults.baseURL = "http://192.168.0.40:8081"
  113. getUserIP(function(ip) {
  114. axios.defaults.baseURL = "http://" + ip + ":8081"
  115. });
  116. axios.get('/reportTable/getReportTableById?id=' + id).then(res => {
  117. console.log(res, 'res');
  118. const data = res.data
  119. if (data.code === 200) {
  120. // 报表数据
  121. let tableData = JSON.parse(data.data.reportTableData)
  122. let option = tableData.option
  123. // 基础数据项值
  124. let baseItem = tableData.baseItem
  125. // 数据项
  126. let reportTableItemList = data.data.reportTableItemList
  127. let reportChartList = data.data.reportChartList
  128. // 报表类型
  129. let reportTableType = data.data.reportTableType
  130. let luckysheetOption = {
  131. container: 'luckysheet', // 设定 DOM 容器的 id
  132. title: '报表模板', // 设定表格名称
  133. lang: 'zh', // 设定表格语言
  134. showinfobar: false, // 是否显示顶部信息栏
  135. showtoolbar: false, // 是否显示工具栏
  136. showtoolbarConfig: {
  137. paintFormat: true, //格式刷
  138. moreFormats: true, // 单元格格式
  139. font: true, // 字体
  140. fontSize: true, // 字号大小
  141. bold: true, // 粗体 (Ctrl+B)
  142. italic: true, // 斜体 (Ctrl+I)
  143. strikethrough: true, // 删除线 (Alt+Shift+5)
  144. underline: true, // 下划线 (Alt+Shift+6)
  145. textColor: true, // 文本颜色
  146. fillColor: true, // 单元格颜色
  147. border: true, // 边框
  148. mergeCell: true, // 合并单元格
  149. horizontalAlignMode: true, // 水平对齐方式
  150. verticalAlignMode: true, // 垂直对齐方式
  151. function: true, // 公式
  152. // image: true
  153. // chart: true
  154. },
  155. showsheetbar: false, // 是否显示底部 sheet 页按钮
  156. sheetFormulaBar: false, // 是否显示公式
  157. row: 120, // 是否显示底部 sheet 页按钮
  158. data: [{
  159. "name": "统计报表", //工作表名称
  160. }],
  161. cellRightClickConfig: { // 自定义配置单元格右击菜单
  162. copy: true, // 复制
  163. copyAs: false, // 复制为
  164. paste: true, // 粘贴
  165. insertRow: true, // 插入行
  166. insertColumn: true, // 插入列
  167. deleteRow: true, // 删除选中行
  168. deleteColumn: true, // 删除选中列
  169. deleteCell: false, // 删除单元格
  170. hideRow: false, // 隐藏选中行和显示选中行
  171. hideColumn: false, // 隐藏选中列和显示选中列
  172. rowHeight: true, // 行高
  173. columnWidth: true, // 列宽
  174. clear: false, // 清除内容
  175. matrix: false, // 矩阵操作选区
  176. sort: false, // 排序选区
  177. filter: false, // 筛选选区
  178. chart: true, // 图表生成
  179. image: false, // 插入图片
  180. link: false, // 插入链接
  181. data: false, // 数据验证
  182. cellFormat: false // 设置单元格格式
  183. },
  184. plugins: ['chart']
  185. }
  186. if (!option) {
  187. option = JSON.parse(JSON.stringify(luckysheetOption))
  188. }
  189. option.data = tableData.data
  190. // 设置工作表保护
  191. option.data[0].config.authority = {
  192. sheet: 1, // 如果为 1 或 true,则该工作表受到保护;如果为 0 或 false,则该工作表不受保护。
  193. hintText: '该工作表受到保护,无法操作', // 弹窗提示的文字
  194. }
  195. // 关闭右键菜单
  196. option.cellRightClickConfig.chart = false
  197. option.cellRightClickConfig.columnWidth = false
  198. option.cellRightClickConfig.rowHeight = false
  199. option.cellRightClickConfig.deleteColumn = false
  200. option.cellRightClickConfig.deleteRow = false
  201. option.cellRightClickConfig.insertColumn = false
  202. option.cellRightClickConfig.insertRow = false
  203. // 关闭工具栏
  204. option.showtoolbar = false
  205. option.enableAddRow = false
  206. option.showtoolbarConfig = {
  207. bold: false,
  208. border: false,
  209. fillColor: false,
  210. font: false,
  211. fontSize: false,
  212. function: false,
  213. horizontalAlignMode: false,
  214. italic: false,
  215. mergeCell: false,
  216. moreFormats: false,
  217. paintFormat: false,
  218. strikethrough: false,
  219. textColor: false,
  220. underline: false,
  221. verticalAlignMode: false
  222. }
  223. // 钩子函数
  224. option.hook = {
  225. workbookCreateAfter() {
  226. // 图表操作
  227. for (let i in reportChartList) {
  228. insertEChartInfo(reportChartList[i])
  229. }
  230. // option.data.forEach((data, i) => {
  231. // if (data.chart && data.chart.length > 0) {
  232. // data.chart.forEach((chart, j) => {
  233. // console.log(chart.chart_id)
  234. // let dom = document.getElementById(chart.chart_id + '_c')
  235. // if (dom) dom.style.display = 'none'
  236. // })
  237. // }
  238. // })
  239. // 绘制基础数据项
  240. drawBaseInfo(baseItem)
  241. // 绘制数据值
  242. drawTableData(reportTableItemList,
  243. reportTableType)
  244. luckysheet.setRangeShow('BH1')
  245. convertChart(tableData)
  246. printExcel()
  247. }
  248. }
  249. luckysheet.create(option)
  250. } else {
  251. }
  252. })
  253. // $.ajax({
  254. // url: "http://192.168.0.40:8081/reportTable/getReportTableById",
  255. // type: 'GET',
  256. // data: {
  257. // id: id
  258. // },
  259. // // beforeSend: function() {
  260. // // getUserIP(function(ip) {
  261. // // console.log("得到的本地IP :" + ip);
  262. // // this.url = "http://" + ip +
  263. // // ":8081/reportTable/getReportTableById"
  264. // // });
  265. // // },
  266. // success: function(res) {
  267. // if (res.code === 200) {
  268. // console.log(res.data, 'res.data');
  269. // // 报表数据
  270. // let tableData = JSON.parse(res.data.reportTableData)
  271. // let option = tableData.option
  272. // console.log(tableData, 'jsonData')
  273. // // 基础数据项值
  274. // let baseItem = tableData.baseItem
  275. // // 数据项
  276. // let reportTableItemList = res.data.reportTableItemList
  277. // let reportChartList = res.data.reportChartList
  278. // // 报表类型
  279. // let reportTableType = res.data.reportTableType
  280. // let luckysheetOption = {
  281. // container: 'luckysheet', // 设定 DOM 容器的 id
  282. // title: '报表模板', // 设定表格名称
  283. // lang: 'zh', // 设定表格语言
  284. // showinfobar: false, // 是否显示顶部信息栏
  285. // showtoolbar: false, // 是否显示工具栏
  286. // showtoolbarConfig: {
  287. // paintFormat: true, //格式刷
  288. // moreFormats: true, // 单元格格式
  289. // font: true, // 字体
  290. // fontSize: true, // 字号大小
  291. // bold: true, // 粗体 (Ctrl+B)
  292. // italic: true, // 斜体 (Ctrl+I)
  293. // strikethrough: true, // 删除线 (Alt+Shift+5)
  294. // underline: true, // 下划线 (Alt+Shift+6)
  295. // textColor: true, // 文本颜色
  296. // fillColor: true, // 单元格颜色
  297. // border: true, // 边框
  298. // mergeCell: true, // 合并单元格
  299. // horizontalAlignMode: true, // 水平对齐方式
  300. // verticalAlignMode: true, // 垂直对齐方式
  301. // function: true, // 公式
  302. // // image: true
  303. // // chart: true
  304. // },
  305. // showsheetbar: false, // 是否显示底部 sheet 页按钮
  306. // sheetFormulaBar: false, // 是否显示公式
  307. // row: 120, // 是否显示底部 sheet 页按钮
  308. // data: [{
  309. // "name": "统计报表", //工作表名称
  310. // }],
  311. // cellRightClickConfig: { // 自定义配置单元格右击菜单
  312. // copy: true, // 复制
  313. // copyAs: false, // 复制为
  314. // paste: true, // 粘贴
  315. // insertRow: true, // 插入行
  316. // insertColumn: true, // 插入列
  317. // deleteRow: true, // 删除选中行
  318. // deleteColumn: true, // 删除选中列
  319. // deleteCell: false, // 删除单元格
  320. // hideRow: false, // 隐藏选中行和显示选中行
  321. // hideColumn: false, // 隐藏选中列和显示选中列
  322. // rowHeight: true, // 行高
  323. // columnWidth: true, // 列宽
  324. // clear: false, // 清除内容
  325. // matrix: false, // 矩阵操作选区
  326. // sort: false, // 排序选区
  327. // filter: false, // 筛选选区
  328. // chart: true, // 图表生成
  329. // image: false, // 插入图片
  330. // link: false, // 插入链接
  331. // data: false, // 数据验证
  332. // cellFormat: false // 设置单元格格式
  333. // },
  334. // plugins: ['chart']
  335. // }
  336. // if (!option) {
  337. // option = JSON.parse(JSON.stringify(luckysheetOption))
  338. // }
  339. // option.data = tableData.data
  340. // // 设置工作表保护
  341. // option.data[0].config.authority = {
  342. // sheet: 1, // 如果为 1 或 true,则该工作表受到保护;如果为 0 或 false,则该工作表不受保护。
  343. // hintText: '该工作表受到保护,无法操作', // 弹窗提示的文字
  344. // }
  345. // // 关闭右键菜单
  346. // option.cellRightClickConfig.chart = false
  347. // option.cellRightClickConfig.columnWidth = false
  348. // option.cellRightClickConfig.rowHeight = false
  349. // option.cellRightClickConfig.deleteColumn = false
  350. // option.cellRightClickConfig.deleteRow = false
  351. // option.cellRightClickConfig.insertColumn = false
  352. // option.cellRightClickConfig.insertRow = false
  353. // // 关闭工具栏
  354. // option.showtoolbar = false
  355. // option.enableAddRow = false
  356. // option.showtoolbarConfig = {
  357. // bold: false,
  358. // border: false,
  359. // fillColor: false,
  360. // font: false,
  361. // fontSize: false,
  362. // function: false,
  363. // horizontalAlignMode: false,
  364. // italic: false,
  365. // mergeCell: false,
  366. // moreFormats: false,
  367. // paintFormat: false,
  368. // strikethrough: false,
  369. // textColor: false,
  370. // underline: false,
  371. // verticalAlignMode: false
  372. // }
  373. // // 钩子函数
  374. // option.hook = {
  375. // workbookCreateAfter() {
  376. // // 图表操作
  377. // for (let i in reportChartList) {
  378. // insertEChartInfo(reportChartList[i])
  379. // }
  380. // // option.data.forEach((data, i) => {
  381. // // if (data.chart && data.chart.length > 0) {
  382. // // data.chart.forEach((chart, j) => {
  383. // // console.log(chart.chart_id)
  384. // // let dom = document.getElementById(chart.chart_id + '_c')
  385. // // if (dom) dom.style.display = 'none'
  386. // // })
  387. // // }
  388. // // })
  389. // // 绘制基础数据项
  390. // drawBaseInfo(baseItem)
  391. // // 绘制数据值
  392. // drawTableData(reportTableItemList,
  393. // reportTableType)
  394. // luckysheet.setRangeShow('BH1')
  395. // convertChart(tableData)
  396. // printExcel()
  397. // }
  398. // }
  399. // luckysheet.create(option)
  400. // } else {
  401. // layer.msg(res.msg);
  402. // }
  403. // }
  404. // })
  405. function printExcel() {
  406. let currentSelected = luckysheet.getRange()
  407. luckysheet.hideGridLines()
  408. // 如果当前选中区只是一个单元格,则认为选取无效。
  409. if (currentSelected[0] != null &&
  410. (currentSelected[0].row[1] - currentSelected[0].row[0] >= 1 ||
  411. currentSelected[0].column[1] - currentSelected[0].column[0] >= 1)) {
  412. // 生成base64图片
  413. //let imgSrc = luckysheet.getScreenshot();
  414. setTimeout(() => {
  415. luckysheet.getScreenshotNew((imgSrc) => {
  416. console.info('printImg', imgSrc)
  417. // top.document.write(`<img src='${imgSrc}'/>`)
  418. luckysheet.showGridLines();
  419. })
  420. }, 200)
  421. } else {
  422. // 获取打印区域的行列
  423. let RowColumn = getPrintSheetArea();
  424. // 因需要打印左边的边框,需重新设置第一列
  425. //RowColumn.column[0] = 0;
  426. // 进行选区操作
  427. luckysheet.setRangeShow(RowColumn);
  428. const cellData = handelCell(luckysheet.getAllSheets()[0].celldata)
  429. let {
  430. minR,
  431. maxR,
  432. minC,
  433. maxC
  434. } = cellData
  435. luckysheet.setRangeShow({
  436. row: [0, maxR],
  437. column: [0, maxC]
  438. });
  439. // let imgSrc = luckysheet.getScreenshot(); // 生成base64图片
  440. // console.log(imgSrc);
  441. setTimeout(() => {
  442. luckysheet.getScreenshotNew((imgSrc) => {
  443. console.info('printImg', imgSrc)
  444. // top.document.write(`<img src='${imgSrc}'/>`)
  445. luckysheet.showGridLines();
  446. })
  447. }, 800)
  448. }
  449. }
  450. function handelCell(data) {
  451. let minR = data[0].r
  452. let maxR = data[data.length - 1].r
  453. let minC = data[0].c
  454. let cData = data.map(item => {
  455. return item.c
  456. })
  457. let maxC = cData.sort(function(a, b) {
  458. return b - a;
  459. })[0];
  460. return {
  461. minR,
  462. maxR,
  463. minC,
  464. maxC
  465. }
  466. }
  467. // top.window.document.write(imgSrc)
  468. // $.ajax({
  469. // url: "localhost:8084?file="+imgSrc,
  470. // type: 'GET',
  471. // success: function(res) {
  472. // }
  473. // })
  474. function getPrintSheetArea() {
  475. const sheetData = luckysheet.getSheetData();
  476. let objRowColumn = {
  477. row: [0, 0], //行
  478. column: [0, 0], //列
  479. };
  480. // * item是行、index是行索引、it是一行里的一格、itemIndex是这一格在这一行里的列索引
  481. sheetData.forEach((item, index) => {
  482. //行数
  483. item.forEach((it, itemIndex) => {
  484. if (it !== null && it.v) {
  485. // console.log(index, it)
  486. if (objRowColumn.row[1] < index) {
  487. objRowColumn.row[1] = index; //row第二位
  488. }
  489. if (objRowColumn.column[1] < itemIndex) {
  490. objRowColumn.column[1] =
  491. itemIndex; //column第二位
  492. }
  493. }
  494. });
  495. });
  496. return objRowColumn;
  497. }
  498. /** 绘制表格数据 */
  499. function drawTableData(tableItemList, type) {
  500. if (!tableItemList || tableItemList.length == 0) return
  501. // 事件驱动报表
  502. if (type == 2 || type == 4) {
  503. tableItemList.forEach((tableItem, i) => {
  504. let valueList = tableItem.valueList ? tableItem.valueList
  505. .split(',') : []
  506. let xAxis = tableItem.xaxis
  507. let yAxis = tableItem.yaxis
  508. if (valueList.length == 0) {
  509. luckysheet.setCellValue(xAxis, yAxis, '')
  510. } else {
  511. valueList.forEach((v, j) => {
  512. luckysheet.setCellValue(xAxis + j, yAxis,
  513. v)
  514. })
  515. }
  516. })
  517. return
  518. }
  519. // 其余报表信息
  520. tableItemList.forEach((tableItem, i) => {
  521. let standby = tableItem.standby ? JSON.parse(tableItem.standby) :
  522. {}
  523. let dataIndex = standby.index != null ? standby.index : -1
  524. let valueList = tableItem.valueList ? tableItem.valueList.split(
  525. ',') : []
  526. let val = (dataIndex == -1 || (dataIndex + 1) > valueList
  527. .length) ?
  528. cqcyCode['invalidData'] : valueList[dataIndex]
  529. let xAxis = tableItem.xaxis
  530. let yAxis = tableItem.yaxis
  531. try {
  532. luckysheet.setCellValue(xAxis, yAxis, val)
  533. } catch (e) {
  534. console.warn(e)
  535. }
  536. })
  537. }
  538. /** 绘制基础数据项布局信息 */
  539. function drawBaseInfo(baseData) {
  540. if (!baseData) return
  541. let option = luckysheet.getAllSheets()[0]
  542. option.celldata.map(item => {
  543. if (item.v.v) {
  544. item.v.v = String(item.v.v).trim()
  545. if (item.v.v.match(/\${([^}]+)}/g)) { // 替换${xxx}内部数据
  546. if (item.v.v.indexOf('${currDate}') > -1) {
  547. let val = item.v.v
  548. val = val.replace('${currDate}', baseData.currDate)
  549. luckysheet.setCellValue(item.r, item.c, val)
  550. }
  551. if (item.v.v.indexOf('${currDateTime}') > -1) {
  552. let val = item.v.v
  553. val = val.replace('${currDateTime}', baseData
  554. .currDateTime)
  555. luckysheet.setCellValue(item.r, item.c, val)
  556. }
  557. if (item.v.v.indexOf('${userName}') > -1) {
  558. let val = item.v.v
  559. val = val.replace('${userName}', baseData.userName)
  560. luckysheet.setCellValue(item.r, item.c, val)
  561. }
  562. if (item.v.v.indexOf('${winUserName}') > -1) {
  563. let val = item.v.v
  564. val = val.replace('${winUserName}', baseData
  565. .winUserName)
  566. luckysheet.setCellValue(item.r, item.c, val)
  567. }
  568. }
  569. }
  570. })
  571. }
  572. /** 向 Excel 插入图表 */
  573. function insertEChartInfo(chart) {
  574. let _self = this
  575. let info = JSON.parse(chart.standby)
  576. let reportChartItemList = chart.reportChartItemList
  577. let chartType = chart.chartType
  578. // 系列
  579. let series = info.option.series
  580. for (let i in series) {
  581. let temp = series[i]
  582. temp.data = []
  583. for (let j in reportChartItemList) {
  584. let _name = reportChartItemList[j].describe ?
  585. reportChartItemList[j].describe : reportChartItemList[j]
  586. .itemName
  587. if (chartType == 'pie') {
  588. temp.name = _name
  589. temp.data.push({
  590. 'name': _name,
  591. 'value': reportChartItemList[j].valueList
  592. })
  593. } else {
  594. let _t = []
  595. let t = reportChartItemList[i].valueList ?
  596. reportChartItemList[i].valueList.split(',') : []
  597. t.forEach((temp) => {
  598. _t.push(parseFloat(temp))
  599. })
  600. temp.data = _t
  601. }
  602. }
  603. }
  604. if (chartType != 'pie') {
  605. // x 轴
  606. let xAxis = info.option.xAxis
  607. let legend = info.option.legend
  608. // xAxis.data = []
  609. legend.data = []
  610. xAxis.data = (reportChartItemList && reportChartItemList.length >
  611. 0) ? reportChartItemList[0].dataTimeList : []
  612. // xAxis.data = xAxis.data.slice(0, 7)
  613. for (let i in reportChartItemList) {
  614. let name = reportChartItemList[i].describe ? reportChartItemList[
  615. i].describe : reportChartItemList[i].itemName
  616. // xAxis.data.push(name)
  617. legend.data.push(name)
  618. }
  619. }
  620. setTimeout(() => {
  621. const sheet = luckysheet.getLuckysheetfile()[0]
  622. let optionData = sheet.data
  623. try {
  624. let flag = false
  625. insertLuckysheetEChart({
  626. selector: '#luckysheet',
  627. info,
  628. sheet,
  629. optionData,
  630. echarts,
  631. luckysheet,
  632. $,
  633. _self,
  634. flag
  635. })
  636. } catch (e) {
  637. console.log(999, e == 'echarts is not defined')
  638. console.error(e)
  639. }
  640. }, 200)
  641. }
  642. $('#recordBtn').on('click', () => {
  643. $('.model').show()
  644. <<<<<<< HEAD
  645. $.ajax({
  646. type: 'GET',
  647. url: "/reportTable/getAutoChReportTable",
  648. beforeSend: function() {
  649. getUserIP(function(ip) {
  650. console.log("得到的本地IP :" + ip);
  651. this.url =
  652. "http://" + ip +
  653. ":8081/reportTable/getAutoChReportTable"
  654. });
  655. },
  656. success: function(res) {
  657. if (res.code === 200) {
  658. $.each(res.data.reportTableList, function(k,
  659. v) {
  660. $("#table tbody").append(
  661. "<tr data-id='1' data-title='123'>" +
  662. "<td>" + k +
  663. "</td>" +
  664. "</tr>" + "<tr >"
  665. )
  666. })
  667. =======
  668. var tableReload = table.render({
  669. elem: '#demo',
  670. width: 300,
  671. page: {
  672. elem: '#demo',
  673. layout: ['prev', 'page', 'next',
  674. 'count'
  675. ]
  676. },
  677. url: 'http://localhost:8081/reportTable/getAutoChReportTable',
  678. where: {
  679. autoTableId: id
  680. },
  681. text: {
  682. none: '暂无数据' //默认:无数据。
  683. },
  684. cols: [
  685. [{
  686. field: 'reportTableName',
  687. title: null,
  688. width: 300
  689. }]
  690. ],
  691. parseData: function(res) {
  692. return {
  693. "code": 0,
  694. "msg": res.msg,
  695. "count": res.data.count,
  696. "data": res.data
  697. .reportTableList
  698. };
  699. >>>>>>> 1808d45f36d85773c8654d57ee5f28ce304c85c1
  700. }
  701. }
  702. })
  703. // layui.use('table', function() {
  704. // var table = layui.table;
  705. // var layer = layui.layer;
  706. // layer.open({
  707. // type: 1,
  708. // title: '运行记录',
  709. // content: $('#demo'),
  710. // offset: ['180px', '45px'],
  711. // end: function() {
  712. // $('#demo').hide();
  713. // $('.layui-table-view').hide()
  714. // },
  715. // cancel: function(index, layero) {
  716. // $('.layui-layer-content')
  717. // .hide()
  718. // }
  719. // });
  720. // var tableReload = table.render({
  721. // elem: '#demo',
  722. // width: 300,
  723. // page: {
  724. // elem: '#demo',
  725. // layout: ['prev', 'page', 'next',
  726. // 'count'
  727. // ]
  728. // },
  729. // // url: 'http://192.168.0.40:8081/reportTable/getAutoChReportTable',
  730. // where: {
  731. // autoTableId: id
  732. // },
  733. // text: {
  734. // none: '暂无数据' //默认:无数据。
  735. // },
  736. // cols: [
  737. // [{
  738. // field: 'reportTableName',
  739. // title: null,
  740. // width: 300
  741. // }]
  742. // ],
  743. // parseData: function(res) {
  744. // return {
  745. // "code": 0,
  746. // "msg": res.msg,
  747. // "count": res.data.count,
  748. // "data": res.data
  749. // .reportTableList
  750. // };
  751. // }
  752. // });
  753. // getUserIP(function(ip) {
  754. // console.log("得到的本地IP :" + ip);
  755. // tableReload.config.url = "http://" + ip +
  756. // ":8081/reportTable/getAutoChReportTable"
  757. // });
  758. // //触发行单击事件
  759. // table.on('row(test)', function(obj) {
  760. // const id = obj.data.id
  761. // const title = obj.data
  762. // .reportTableName
  763. // uni.navigateTo({
  764. // url: `/pages/reportForm/report-detail/recordDetail?id=${id}&title=${title}`
  765. // })
  766. // });
  767. // $('th').hide()
  768. // });
  769. })
  770. $('.cel').on('click', () => {
  771. $('.model').hide()
  772. })
  773. });
  774. });
  775. })
  776. </script>
  777. </body>
  778. </html>