123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- <!DOCTYPE html>
- <html lang="zh">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>运行记录</title>
- <link rel='stylesheet' href='../luckysheet/dist/plugins/plugins.css' />
- <link rel='stylesheet' href='../luckysheet/dist/plugins/css/pluginsCss.css' />
- <link rel='stylesheet' href='../luckysheet/dist/css/luckysheet.css' />
- <link rel='stylesheet' href='../luckysheet/dist/assets/iconfont/iconfont.css' />
- <link rel="stylesheet" href="../dist/css/layui.css">
- <style>
- .la-btn {
- position: absolute;
- bottom: 20px;
- left: 50%;
- margin-left: -35px
- }
- </style>
- </head>
- <body>
- <div id="luckysheet"
- style="margin:0px;padding:0px;position:absolute;width:100%;height:100%;left: 0px;top: 0px;"></div>
- <script src="../jquery.min.js"></script>
- <script src="../dist/layui.js"></script>
- <script src="./cqcyCode.js"></script>
- <script src="../luckysheet/dist/luckysheet.umd.js"></script>
- <script src="../luckysheet/dist/plugins/js/plugin.js"></script>
- <script src="./echarts.js"></script>
- <script src="./cqcyCode.js"></script>
- <script src="./canvertChart.js"></script>
- <!-- uni 的 SDK -->
- <script src="./wvIP.js"></script>
- <script type="text/javascript" src="../luckysheet/dist/plugins/js/uni-webview-js0.0.3_index.js"></script>
- <script>
- document.addEventListener('UniAppJSBridgeReady', function() {
- uni.getEnv(function(res) {
- window.sessionName = 'device_report_index'
- sessionStorage.removeItem(window.sessionName)
- console.log('33333')
- const id = window.location.search.split('?id=')[1]
- const token = window.localStorage.getItem('C_TOKEN')
-
- $.ajax({
- url: "" + id,
- type: 'GET',
- beforeSend: function(xhr) {
- this.url = baseUrl +
- "/reportTable/getReportTableById?id=" +
- id
- xhr.setRequestHeader("Authorization", "Bearer " +
- token);
- xhr.setRequestHeader("token", token);
- },
- success: function(res) {
- const data = res.data
- if (res.code === 200) {
- // 报表数据
- let templateData = JSON.parse(data.reportTableData)
- // 报表类型
- let reportTableType = data.reportTableType
- //报表名称
- let reportTableName = data.reportTableName
- console.log(templateData)
- let s_data = $.extend(true, {}, templateData.sheet)
- delete s_data.chart
- const option = {
- container: 'luckysheet',
- data: [s_data],
- title: '报表模板',
- lang: 'zh',
- showinfobar: false,
- showtoolbar: false,
- showtoolbarConfig: {
- paintFormat: true, //格式刷
- moreFormats: true, // 单元格格式
- font: true, // 字体
- fontSize: true, // 字号大小
- bold: true, // 粗体 (Ctrl+B)
- italic: true, // 斜体 (Ctrl+I)
- strikethrough: true, // 删除线 (Alt+Shift+5)
- underline: true, // 下划线 (Alt+Shift+6)
- textColor: true, // 文本颜色
- fillColor: true, // 单元格颜色
- border: true, // 边框
- mergeCell: true, // 合并单元格
- horizontalAlignMode: true, // 水平对齐方式
- verticalAlignMode: true, // 垂直对齐方式
- function: true, // 公式
- print: false,
- image: true,
- link: true,
- textRotateMode: true,
- sortAndFilter: true
- },
- showsheetbar: false,
- showstatisticBar: false,
- sheetFormulaBar: false,
- allowCopy:false,
- allowUpdate:false,
- allowEdit:true,
- forceCalculation:true,
- cellRightClickConfig: {
- copy: false, // 复制
- copyAs: false, // 复制为
- paste: false, // 粘贴
- insertRow: false, // 插入行
- insertColumn: false, // 插入列
- deleteRow: false, // 删除选中行
- deleteColumn: false, // 删除选中列
- deleteCell: false, // 删除单元格
- hideRow: false, // 隐藏选中行和显示选中行
- hideColumn: false, // 隐藏选中列和显示选中列
- rowHeight: false, // 行高
- columnWidth: false, // 列宽
- clear: false, // 清除内容
- matrix: false, // 矩阵操作选区
- sort: false, // 排序选区
- filter: false, // 筛选选区
- chart: false, // 图表生成
- image: false, // 插入图片
- link: false, // 插入链接
- data: false, // 数据验证
- cellFormat: false // 设置单元格格式
- },
- plugins: ['chart'],
- hook: {
- cellEditBefore: function(range) {
- const cell = getCellData((range[0].row)[0], (range[0].column)[0])
- if (cell) {
- try {
- const data = JSON.parse(cell) || {}
- if (data && data.tableId) {
- return false
- }
- } catch(e) {
- //console.log(e)
- }
- }
- return false;
- },
- cellUpdateBefore: function(r, c, val) {
- const cell = getCellData(r, c)
- if (cell) {
- try {
- const data = JSON.parse(cell) || {}
- if (data && data.tableId) {
- return false
- }
- } catch(e) {
- //console.log(e)
- }
- }
- return true
- },
- cellMousedown:function(cell,position,sheet,ctx){
- //console.log('r='+position.r+','+'c='+position.c);
- //console.log(position.c);
- console.log(cell);
- },
- workbookCreateAfter: function() {
- luckysheet.setRangeShow('B1:B2', {
- success: () => {
- for (let key in templateData.chart) {
- //console.log(templateData.chart[key])
- luckysheet.showHistoryChart({
- chartId: key,
- option: templateData.chart[key].position,
- init: function(chart, chartId) {
- const colorForm = templateData.chart[key].colorForm
- if (colorForm.background) {
- templateData.chart[key].chartData.backgroundColor = colorForm.background
- $(`#${chartId}_c`).css('background', colorForm.background)
- }
- const xForm = templateData.chart[key].xForm;
- let chart_new = templateData.chart[key].chartData;
- if(xForm!=undefined){
- chart_new.xAxis[0].axisLabel.formatter = function (value) {
- var date = new Date(value);
- if(date.toString()=='Invalid Date'){
- return value
- }else{
- return new Date(value).format(xForm.formatter)
- }
- };
- }
- chart.setOption(chart_new, {
- notMerge: true
- })
- // chart.setOption(templateData.chart[key].chartData, {
- // notMerge: true
- // })
- if (colorForm.border) {
- $(`#${chartId}_c`).css('border', '1px solid ' + colorForm.border)
- }
- },
- })
- }
- // if(callback){
- // callback()
- // return
- // }
- }
- })
- }
- }
- }
- luckysheet.create(option)
- } else {
- }
- }
- })
- });
- });
- </script>
- </body>
- </html>
|