hd-idevvue3 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/errorLog.js CHANGED
@@ -1,6 +1,8 @@
1
- import Vue from 'vue'
1
+ import {createApp} from 'vue'
2
2
  import errLog from '@/store/errLog'
3
3
 
4
+ const Vue = createApp({})
5
+
4
6
  // 生产环境错误日志
5
7
  if (process.env.NODE_ENV === 'production') {
6
8
  Vue.config.errorHandler = function(err, vm) {
@@ -21,7 +21,7 @@
21
21
  <el-button type="danger" @click="doDel()" keyType="del" :disabled="delLoading"
22
22
  :hotKeyRange="$vnode.context.$options._componentTag">{{$t('删除')}}
23
23
  </el-button>
24
- <el-button type="primary" @click="doSave()"keyType="save" :disabled="saveLoading"
24
+ <el-button type="primary" @click="doSave()" keyType="save" :disabled="saveLoading"
25
25
  :hotKeyRange="$vnode.context.$options._componentTag">{{$t('保存')}}
26
26
  </el-button>
27
27
  </span>
@@ -114,7 +114,7 @@
114
114
  <!-- <GridExFieldBak @save-ok="exFieldShow()" ref="exFieldShow" v-if="exField.open && exFieldShowIs" :table="exField.table"
115
115
  :columnList="exField.columnList" :gridCode="exField.gridCode"></GridExFieldBak>
116
116
  -->
117
- <PdfShow :gening="pdfAllExporting" @close="pdfShowIs=false" ref="pdfshow" v-if="pdfShowIs"></PdfShow>
117
+ <!-- <PdfShow :gening="pdfAllExporting" @close="pdfShowIs=false" ref="pdfshow" v-if="pdfShowIs"></PdfShow> -->
118
118
  <hd-right-menu ref="rightMenu" @do-add="doAdd" @do-update="doUpdateOne" @do-remove="doRemoveOne"
119
119
  @do-copy="doCopyOne" v-if="rightMenuOpen" v-show="rightMenuVisable">
120
120
  <template slot="rightMenu">
@@ -131,7 +131,7 @@
131
131
  import GridShow from './GridShow'
132
132
  import GridExField from './GridExField'
133
133
  import HdGridExt from './HdGridExt.js'
134
- import PdfShow from './PdfShow'
134
+ // import PdfShow from './PdfShow'
135
135
  import BigGrid from "./BigGrid.js";
136
136
  import ExtendColumn from "./ExtendColumn";
137
137
  import HdBtn from './HdBtn'
@@ -143,7 +143,7 @@ import HdRightMenu from "./HdRightMenu";
143
143
  */
144
144
  export default {
145
145
  name: 'HdGrid',
146
- components: { HdRightMenu, GridShow, PdfShow, GridExField, ExtendColumn, HdBtn }, // ElTableColumn已被改写,但是select ck不好使,需要有原来的
146
+ components: { HdRightMenu, GridShow, GridExField, ExtendColumn, HdBtn }, // ElTableColumn已被改写,但是select ck不好使,需要有原来的
147
147
  mixins: [HdGridExt, BigGrid],
148
148
  data() {
149
149
  return {
@@ -725,7 +725,7 @@ export default {
725
725
  display: flex;
726
726
  flex-direction: column;
727
727
 
728
- /deep/ .el-table {
728
+ :deep(.el-table) {
729
729
  //deep内的不会加随机数
730
730
  height: 100%;
731
731
  width: 100%;
@@ -3,7 +3,9 @@
3
3
  * @Date: 2017-10-12 12:06:49
4
4
  */
5
5
  'use strict'
6
- import Vue from 'vue'
6
+ import {createApp} from 'vue'
7
+ const Vue = createApp({})
8
+
7
9
  export default function treeToArray(data, expandAll, parent = null, level = null) {
8
10
  let tmp = []
9
11
  Array.from(data).forEach(function(record) {
@@ -18,7 +18,7 @@
18
18
  </template>
19
19
 
20
20
  <script>
21
- import XLSX from 'xlsx'
21
+ import * as XLSX from 'xlsx'
22
22
 
23
23
  export default {
24
24
  data() {
package/src/index.js CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  import common from './idev.common'
2
3
  import privilege from './views/privilege'
3
4
  import layout from './views/layout'
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable */
2
2
  import { saveAs } from 'file-saver'
3
- import XLSX from 'xlsx'
3
+ import * as XLSX from 'xlsx'
4
4
 
5
5
  function generateArray(table) {
6
6
  var out = [];
@@ -204,7 +204,7 @@
204
204
  display: inline-block;
205
205
  vertical-align: middle;
206
206
 
207
- /deep/ .el-input__inner {
207
+ :deep(.el-input__inner) {
208
208
  border-radius: 0;
209
209
  border: 0;
210
210
  padding-left: 0;
@@ -177,7 +177,7 @@
177
177
  display: inline-block;
178
178
  vertical-align: middle;
179
179
 
180
- /deep/ .el-input__inner {
180
+ :deep(.el-input__inner) {
181
181
  border-radius: 0;
182
182
  border: 0;
183
183
  padding-left: 0;
@@ -155,11 +155,11 @@
155
155
  <style lang="scss" scoped>
156
156
  @import 'css/menu.css'; // normalize.css 样式格式化
157
157
  .product_sort {
158
- /deep/ .el-scrollbar__wrap {
158
+ :deep(.el-scrollbar__wrap) {
159
159
  overflow-x: hidden;
160
160
  }
161
161
 
162
- /deep/ .is-horizontal {
162
+ :deep(.is-horizontal) {
163
163
  height: 0;
164
164
  }
165
165
  }
@@ -14,7 +14,7 @@
14
14
  </el-table-column>
15
15
  <!-- <el-table-column :input="require('../orgDept/orgnselect').default" :inputFormat="(result, row)=>row.orgnName" align="left" header-align="center" label="部门" prop="orgnId"
16
16
  sortable width="180px">-->
17
- </el-table-column>
17
+ <!-- </el-table-column> -->
18
18
  <el-table-column align="center" label="账号过期日期" prop="accountPassDate" sortable width="auto">
19
19
  </el-table-column>
20
20
  <el-table-column align="center" label="密码修改时间" prop="pwModifyTim" sortable width="auto">
@@ -24,13 +24,13 @@
24
24
  </template>
25
25
  </el-table-column>
26
26
 
27
- <el-table-column width="100px" align="center" label="索引名称" prop="indexName" sortable :rules="$r(0,0,30)" noEdit sortable>
27
+ <el-table-column width="100px" align="center" label="索引名称" prop="indexName" sortable :rules="$r(0,0,30)" noEdit >
28
28
  </el-table-column>
29
- <el-table-column width="120px" align="center" label="索引CODE" prop="searchCode" sortable :rules="$r(0,0,50)" sortable>
29
+ <el-table-column width="120px" align="center" label="索引CODE" prop="searchCode" sortable :rules="$r(0,0,50)" >
30
30
  </el-table-column>
31
31
  <el-table-column width="120px" align="center" label="索引菜单" :inputFormat="(v,r)=>r.menuName" prop="menuId" sortable noEdit>
32
32
  </el-table-column>
33
- <el-table-column width="330px" align="center" label="索引实体" prop="entityName" sortable :rules="$r(0,0,255)" sortable>
33
+ <el-table-column width="330px" align="center" label="索引实体" prop="entityName" sortable :rules="$r(0,0,255)" >
34
34
  </el-table-column>
35
35
  <el-table-column width="140px" align="center" label="上次刷新时间" :inputProp="$date" prop="flushTim" sortable noEdit>
36
36
  </el-table-column>
@@ -96,7 +96,7 @@
96
96
  }
97
97
  </script>
98
98
  <style rel="stylesheet/scss" lang="scss" scoped>
99
- /deep/ .gray-row { //deep必须有
99
+ :deep(.gray-row) { //deep必须有
100
100
  background: #DCDCDC;
101
101
  }
102
102
 
package/vite.config.js CHANGED
@@ -1,118 +1,93 @@
1
- import { fileURLToPath, URL } from 'node:url'
1
+ import { fileURLToPath, URL } from "node:url";
2
2
 
3
- import { defineConfig } from 'vite'
4
- import vue from '@vitejs/plugin-vue'
5
- import requireTransform from 'vite-plugin-require-transform';
3
+ import { defineConfig } from "vite";
4
+ import vue from "@vitejs/plugin-vue";
5
+ import path from "path";
6
6
 
7
- import AutoImport from 'unplugin-auto-import/vite';
7
+ import requireTransform from "vite-plugin-require-transform";
8
8
 
9
- import postcssImport from 'postcss-import'
10
- import autoprefixer from 'autoprefixer'
9
+ import AutoImport from "unplugin-auto-import/vite";
10
+
11
+ import postcssImport from "postcss-import";
12
+ import autoprefixer from "autoprefixer";
11
13
 
12
14
  // https://vitejs.dev/config/
13
15
  export default defineConfig({
14
- plugins: [vue(),
15
- requireTransform({
16
- fileRegex: /.js$|.vue$/
17
- }),
18
- AutoImport({
19
- imports: ['vue', 'vue-router']
20
- })],
16
+ plugins: [
17
+ vue(),
18
+ requireTransform({
19
+ fileRegex: /.js$|.vue$/,
20
+ }),
21
+ AutoImport({
22
+ imports: ["vue", "vue-router"],
23
+ }),
24
+ ],
25
+ base:'./',
21
26
  server: {
22
- proxy: {
23
- '/webresources/login/com/ComQuartzJob': 'http://localhost:8087/',
24
- '/webresources/login/com/ComQuartzLog': 'http://localhost:8087/',
25
- '/webresources': 'http://localhost:8080/',
26
- '/interface': 'http://localhost:8086',
27
- '/business': 'http://localhost:8081',
28
- '/bct': 'http://localhost:8082',
29
- '/lt': 'http://localhost:8083',
30
- '/group': 'http://localhost:8084',
31
- '/report': 'http://localhost:8085',
32
- '/prs': 'http://localhost:8089',
33
- // '/PrivilegeVueController': 'http://128.128.1.163:8080/',
34
- '/PrivilegeVueController': 'http://localhost:8080/',
35
- '/outernet': 'http://localhost:8080',
36
- '/webroot/decision': {
37
- target: 'http://128.128.1.77:8080/',
38
- changeOrigin: true,
39
- pathRewrite: { //当有统一path此处可不写,效果一样
40
- '^/webroot/decision': '/decision' //重写接口
41
- }
42
- },
43
- '/decision': 'http://128.128.1.77:8080/'
44
- },
27
+ host: '0.0.0.0', // 指定服务器应该监听哪个 IP 地址,默认localhost,可设置为'0.0.0.0'或 true
28
+ open: true, // 开发服务器启动时,自动在浏览器中打开应用程序
45
29
  strictPort: true,
46
30
  hrm: {
47
- clientPort: 5173
48
- }
31
+ clientPort: 5173,
32
+ },
49
33
  },
50
34
  resolve: {
51
- extensions: ['.js', '.vue', '.json'],
52
35
  alias: {
53
- '~': fileURLToPath(new URL('./', import.meta.url)),
54
- '@': fileURLToPath(new URL('./src', import.meta.url)),
55
- // 'idevvue$': 'X:/svn/HD_IDEV_FRAME/HD_IDEV_VUE_FRAME/lib/idv8.common.js',
56
- 'idevvue': fileURLToPath(new URL('./src/hdcom/idev.common.js', import.meta.url)),
57
- // 'idevvue$': 'X:/svn/HD_IDEV_FRAME/HD_IDEV_VUE_FRAME/src/hdcom/index.js',
58
-
59
- // 'idevvue$': 'idevvue/lib',
60
- // 'idevvuejs': 'idevvue\\lib\\js',//按需加载
61
- // 'idevvuejs': fileURLToPath(new URL('./src/views/privilege', import.meta.url)),//按需加载
62
-
63
- // 'ytgvue$': 'ytgvue/lib',
64
- // 'ytgvue$': '../../HD_YTG_GCTOS_WEB_PLUGIN/src',
65
- 'idevvuejs/HdLayout': fileURLToPath(new URL('./src/views/layout/HdLayout', import.meta.url)),
66
- 'idevvuejs/HdSearch': fileURLToPath(new URL('./src/views/layout/header/HeaderSearch', import.meta.url)),
67
- 'idevvuejs/sysfieldframe': fileURLToPath(new URL('./src/views/privilege/syscode/sysfieldframe', import.meta.url)),
68
- 'idevvuejs/menu': fileURLToPath(new URL('./src/views/privilege/menu/menu', import.meta.url)),
69
- 'idevvuejs/menuinfo': fileURLToPath(new URL('./src/views/privilege/menu/menuinfo', import.meta.url)),
70
- 'idevvuejs/userRole': fileURLToPath(new URL('./src/views/privilege/userRole/userRole', import.meta.url)),
71
- 'idevvuejs/role': fileURLToPath(new URL('./src/views/privilege/role/role', import.meta.url)),
72
- 'idevvuejs/orgDept': fileURLToPath(new URL('./src/views/privilege/orgDept/orgDept', import.meta.url)),
73
- 'idevvuejs/personDept': fileURLToPath(new URL('./src/views/privilege/personDept/personDept', import.meta.url)),
74
- 'idevvuejs/orgTree': fileURLToPath(new URL('./src/views/privilege/orgDept/orgTree.vue', import.meta.url)),
75
- 'idevvuejs/commsg': fileURLToPath(new URL('./src/views/privilege/commsg/commsg.vue', import.meta.url)),
76
- 'idevvuejs/commsgto': fileURLToPath(new URL('./src/views/privilege/commsg/commsgto.vue', import.meta.url)),
77
- 'idevvuejs/syslog': fileURLToPath(new URL('./src/views/privilege/syslog/syslog.vue', import.meta.url)),
78
- 'idevvuejs/syslogframe': fileURLToPath(new URL('./src/views/privilege/syslog/syslogframe.vue', import.meta.url)),
79
- 'idevvuejs/comquartzlog': fileURLToPath(new URL('./src/views/privilege/quartz/comquartzlog.vue', import.meta.url)),
80
- 'idevvuejs/comquartzjob': fileURLToPath(new URL('./src/views/privilege/quartz/comquartzjob.vue', import.meta.url)),
81
- 'idevvuejs/comsearch': fileURLToPath(new URL('./src/views/privilege/search/comsearch.vue', import.meta.url)),
82
- 'idevvuejs/authmobileupdate': fileURLToPath(new URL('./src/views/privilege/mobile/authmobileupdate.vue', import.meta.url)),
83
- 'idevvuejs/comexfield': fileURLToPath(new URL('./src/views/privilege/exfield/comexfield.vue', import.meta.url)),
84
-
85
- 'src': fileURLToPath(new URL('./src', import.meta.url)),
86
- 'assets': fileURLToPath(new URL('./src/assets', import.meta.url)),
87
- 'components': fileURLToPath(new URL('./src/components', import.meta.url)),
88
- 'views': fileURLToPath(new URL('./src/views', import.meta.url)),
89
- 'styles': fileURLToPath(new URL('./src/styles', import.meta.url)),
90
- 'api': fileURLToPath(new URL('./src/api', import.meta.url)),
91
- 'utils': fileURLToPath(new URL('./src/utils', import.meta.url)),
92
- 'store': fileURLToPath(new URL('./src/store', import.meta.url)),
93
- 'router': fileURLToPath(new URL('./src/router', import.meta.url)),
94
- 'mock': fileURLToPath(new URL('./src/mock', import.meta.url)),
95
- 'vendor': fileURLToPath(new URL('./src/vendor', import.meta.url)),
96
- 'static': fileURLToPath(new URL('./static', import.meta.url))
97
-
98
- }
36
+ "@": path.resolve(__dirname, 'src'),
37
+ },
38
+ extensions: [".js", ".ts", ".vue", ".json"],
99
39
  },
100
40
  css: {
101
41
  postcss: {
102
42
  plugins: [
103
43
  postcssImport,
104
- autoprefixer({// 自动添加前缀
44
+ autoprefixer({
45
+ // 自动添加前缀
105
46
  overrideBrowserslist: [
106
47
  "Android 4.1",
107
48
  "iOS 7.1",
108
49
  "Chrome > 31",
109
50
  "ff > 31",
110
- "ie >= 8"
51
+ "ie >= 8",
111
52
  //'last 2 versions', // 所有主流浏览器最近2个版本
112
53
  ],
113
- grid: true
114
- })
115
- ]
116
- }
117
- }
118
- })
54
+ grid: true,
55
+ }),
56
+ ],
57
+ },
58
+ },
59
+ // 打包配置 npm run build
60
+ build: {
61
+ //指定输出路径
62
+ outDir: "dist",
63
+ //生成静态资源的存放路径
64
+ assetsDir: "assets",
65
+ //小于此阈值的导入或引用资源将内联为 base64 编码,以避免额外的 http 请求。设置为 0 可以完全禁用此项
66
+ assetsInlineLimit: 4096,
67
+ //启用/禁用 CSS 代码拆分
68
+ cssCodeSplit: true,
69
+ //构建后是否生成 source map 文件
70
+ sourcemap: false,
71
+ lib: {
72
+ entry: path.resolve(__dirname, 'src/index.js'), // 确保路径正确
73
+ name: "hd-idevvue3",
74
+ },
75
+ //自定义底层的 Rollup 打包配置
76
+ rollupOptions: {
77
+ input: {
78
+ //可以配置多个,表示多入口
79
+ index: path.resolve(__dirname, "src/index.js"),
80
+ // project:resolve(__dirname,"project.html")
81
+ },
82
+ output: {
83
+ // chunkFileNames:'static/js/[name]-[hash].js',
84
+ // entryFileNames:"static/js/[name]-[hash].js",
85
+ // assetFileNames:"static/[ext]/name-[hash].[ext]"
86
+ },
87
+ },
88
+ //默认情况下,若 outDir 在 root 目录下,则 Vite 会在构建时清空该目录。
89
+ emptyOutDir: true,
90
+ //chunk 大小警告的限制
91
+ chunkSizeWarningLimit: 500,
92
+ },
93
+ });
package/dist/index.html DELETED
@@ -1,17 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6
- <meta name="renderer" content="webkit">
7
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
8
- <title>GCTOS</title>
9
-
10
- <script>if (typeof module === 'object') {window.jQuery = window.$ = module.exports;};</script>
11
- </head>
12
- <body>
13
- <div id="app"></div>
14
- <!-- built files will be auto injected -->
15
- </body>
16
- </html>
17
-
@@ -1,266 +0,0 @@
1
- <template>
2
- <el-dialog :fullscreen="true" :title="gening?'正在生成pdf':'PDF预览'" :visible.sync="visible" @close="$emit('close')"
3
- class="pdfshow">
4
- <el-row>
5
- <el-col :span="4">
6
- <el-switch @change="initPdf()" :active-text="$t('横向显示')" :inactive-text="$t('竖向显示')" v-model="isLandscape">
7
- </el-switch>
8
- </el-col>
9
- <el-col :span="4">
10
- {{$t('字号')}}
11
- <el-input :clearable="false" :placeholder="$t('请输入字号')" size="mini" style="width:100px"
12
- v-model.number="fontSize"></el-input>
13
- </el-col>
14
- <el-col :span="6">
15
- <el-pagination :current-page.sync="currentPage" :page-size.sync="pageSize" :page-sizes="[100, 200, 400]"
16
- :total="totalSize" @current-change="initPdf()" @size-change="initPdf()"
17
- layout="sizes, prev, pager, next">
18
- </el-pagination>
19
- </el-col>
20
- <el-col :span="4">
21
- <el-button @click="refreshGridData()">{{$t('刷新')}}</el-button>
22
- </el-col>
23
- </el-row>
24
- <el-row>
25
- <el-checkbox-group v-model="pdfExport" v-if="columnStyles.length>0">
26
- <el-checkbox v-for="(item, index) in resultData[0]" :label="index" :key="index">{{item}}
27
- <el-input :clearable="false" :placeholder="$t('最小宽')" size="mini" style="width:50px"
28
- v-model="columnStyles[index].cellWidth"></el-input>
29
- </el-checkbox>
30
- </el-checkbox-group>
31
- </el-row>
32
- <object id="output" style="width: 100%;height: calc(100% - 40px)" type="application/pdf">
33
- <p>It appears you don't have PDF support in this web browser</p>
34
- </object>
35
- </el-dialog>
36
- </template>
37
-
38
- <script>
39
- import jsPDF from 'jspdf';
40
- import 'jspdf-autotable';
41
-
42
- window.jsPDF = jsPDF
43
-
44
-
45
- export default {
46
- name: 'pdfshow',
47
- components: {},
48
- props: {
49
- gening: {//pdf生成中
50
- type: Boolean,
51
- default: function () {
52
- return true
53
- }
54
- },
55
- defaultSort: {
56
- type: Object,
57
- default: function () { // updTimFirst是因为会触发HdQuery的排序及查询,默认不让查询
58
- return { prop: 'updTim', order: 'descending' }
59
- }
60
- },
61
- pageHide: Boolean,
62
- ckHide: Boolean, // 是否显示checkbox默认显示
63
- indexHide: Boolean, // 是否显示index 默认显示
64
- recHide: Boolean, // 是否显示创建人 默认显示
65
- rowClassName: Function,
66
- // : [Array],
67
- excelPropHeader: Boolean// 导出excel是否包含属性头,默认false,导入excel如果需要模板,可以开启,并且会导出所有属性
68
- },
69
- data() {
70
- return {
71
- visible: true, //因为外层是v-if
72
- totalSize: 0,//数据总数
73
- isLandscape: false,//默认竖向
74
- pdfExport: [],// 导出pdf时不处理的字段
75
- currentPage: 1,
76
- pageSize: 400,
77
- resultData: [], //所有数据
78
- columnStyles: [],
79
- gridData: [], //展示数据
80
- gridStyles: [],
81
- title: '',
82
- fontSize: 10,
83
- }
84
- },
85
- mounted() {
86
-
87
- },
88
- methods: {
89
- handleSizeChange() {
90
- this.initPdf()
91
- },
92
- handleCurrentChange() {
93
- this.initPdf()
94
- },
95
- /**
96
- * 过滤不显示字段
97
- */
98
- initShowData() {
99
- this.gridData = this.resultData.map(v1 => {
100
- return v1.filter((v2, i2) =>
101
- this.pdfExport.indexOf(i2) > -1
102
- )
103
- });
104
- let flag = 0;
105
- this.gridStyles = this.resultData[0].reduce((total, v, i) => {
106
- if (this.pdfExport.indexOf(i) > -1) {
107
- let cellWidth = parseInt(this.columnStyles[i].cellWidth);
108
- // console.log('xxx'.cellWidth, this.columnStyles[i].cellWidth)
109
- total[flag++] = { cellWidth: isNaN(cellWidth) ? 'auto' : cellWidth }
110
- }
111
- return total
112
- }, {});
113
-
114
- },
115
- refreshGridData() {
116
- // console.log('refreshGridData', this.pdfExport)
117
- let obj = { isLandscape: this.isLandscape, fontSize: this.fontSize, cols: this.pdfExport, columnStyles: this.columnStyles }
118
- localStorage.setItem("HdPdfSel" + this.$parent.gridId, JSON.stringify(obj));
119
- this.initShowData();
120
- this.initPdf();
121
- },
122
- addScript() {//字体库太大,使用pdf时才会加载字体
123
- this.$message({
124
- type: 'success',
125
- showClose: true,
126
- duration: 99999,
127
- message: this.$t('正在初始化pdf脚本,请等待...')
128
- })
129
- var head = document.getElementsByTagName('head')[0];
130
- var script = document.createElement('script');
131
- const that = this;
132
- script.onload = script.onreadystatechange = () => {
133
- console.log('readyState', that.readyState)
134
- if (!that.readyState || that.readyState === "loaded" || that.readyState === "complete") {
135
- that.$message.closeAll()
136
- that.initPdf()//脚本渲染好后,再显示
137
- script.onload = script.onreadystatechange = null;
138
- }
139
- };
140
- script.type = 'text/javascript';
141
- script.src = 'static/js/simsun.js';
142
- head.appendChild(script);
143
- },
144
- genPdf(header, merdata, title) {
145
- // console.log('parent', this.$parent)
146
- // console.log('grid', this.$parent.gridId)
147
- this.totalSize = merdata.length - 1
148
- this.resultData.push(["#", ...merdata[0]]);
149
- for (let i = 1; i < merdata.length; i++) {
150
- this.resultData.push([i, ...merdata[i]]);
151
- }
152
-
153
- // console.log('localStorage', localStorage.getItem('HdPdfSel' + this.$parent.gridId));
154
- // let obj = {isLandscape: this.isLandscape, fontSize: this.fontSize, cols: this.pdfExport}
155
- // localStorage.setItem("HdPdfSel" + this.$parent.gridId, JSON.stringify(obj));
156
- let storeStr = localStorage.getItem('HdPdfSel' + this.$parent.gridId)
157
- if (storeStr) {
158
- let storeObj = JSON.parse(storeStr)
159
- this.pdfExport = storeObj.cols;
160
- this.fontSize = storeObj.fontSize
161
- this.isLandscape = storeObj.isLandscape
162
- if (!storeObj.columnStyles || storeObj.columnStyles.length < 1) {
163
- this.columnStyles = this.resultData[0].map(v => {
164
- return { cellWidth: 'auto' };
165
- });
166
- } else {
167
- this.columnStyles = storeObj.columnStyles
168
- }
169
-
170
- //默认全选
171
- if (!this.pdfExport || !Array.isArray(this.pdfExport) || this.pdfExport.length < 1) {
172
- this.pdfExport = [];
173
- for (let i = 0; i <= this.totalSize; i++) {
174
- this.pdfExport.push(i);
175
- }
176
- }
177
- }
178
- this.initShowData();
179
- this.title = title;
180
- this.addScript()
181
- },
182
- initPdf() {
183
- let startDataNum = (this.currentPage - 1) * this.pageSize + 1 //merdata第一位是header 要+1
184
- let endDataNum = (this.currentPage) * this.pageSize + 1
185
- let nowData = this.gridData.slice(startDataNum, endDataNum)
186
- this.$nextTick(() => {
187
- this.showPdf([this.gridData[0]], nowData, this.title)
188
- })
189
- },
190
- showPdf(header, merdata, title) {
191
- var head = header
192
- var body = merdata
193
- var doc = null
194
- if (this.isLandscape) {
195
- var doc = new jsPDF('l', 'pt');
196
- doc.setFont('simsun');
197
- // doc.setFontStyle('normal');
198
- doc.text(title, 450, 30, { align: 'center' });
199
- } else {
200
- var doc = new jsPDF('h', 'pt');
201
- doc.setFont('simsun');
202
- // doc.setFontStyle('normal');
203
- doc.text(title, 300, 30, { align: 'center' });
204
- }
205
- // doc.
206
- doc.autoTable({
207
- head: head,
208
- body: body,
209
- margin: { right: 12, left: 12 },
210
- styles: {
211
- font: "simsun",
212
- fontStyle: 'normal',
213
- lineColor: '#000',
214
- lineWidth: 1,
215
- fontSize: this.fontSize,
216
- cellPadding: 0.5,
217
- halign: 'center',
218
- overflow: "linebreak",
219
- cellWidth: '10',
220
- minCellWidth: '2',
221
- },
222
- headStyles: { font: "simsun", fontStyle: 'normal' }, // Red
223
- columnStyles: this.gridStyles,
224
- // columnStyles: {//列的样式
225
- // columnWidth: 20,
226
- // },
227
- // didParseCell: (HookData) => {//num居右
228
- // console.log('HookData', HookData, HookData.cell.text, HookData.cell, HookData.cell.text[0].length);
229
- // HookData.column.width = this.gridStyles[HookData.column.index].cellWidth
230
- // HookData.cell.width = this.gridStyles[HookData.column.index].cellWidth
231
- // HookData.cell.styles.cellWidth = this.gridStyles[HookData.column.index].cellWidth + 'px'
232
- // // if (!isNaN(HookData.cell.text)) {
233
- // // HookData.cell.styles.halign = 'right'
234
- // // }
235
- // }
236
- });
237
-
238
- document.getElementById("output").data = doc.output('datauristring');
239
- }
240
- },
241
- watch: {
242
- fontSize(newVal) {
243
- if (!newVal) {
244
- this.fontSize = 10
245
- } else if (newVal > 50) {
246
- this.fontSize = 50
247
- } else if (newVal < 2) {
248
- this.fontSize = 1
249
- }
250
- }
251
- }
252
- }
253
- </script>
254
- <style rel="stylesheet/scss" lang="scss" scoped>
255
- .pdfshow {
256
- /deep/ .el-dialog {
257
- // overflow: hidden;
258
- }
259
-
260
- /deep/ .el-dialog__body {
261
- //deep内的不会加随机数
262
- width: 100%;
263
- height: calc(100% - 55px);
264
- }
265
- }
266
- </style>