n20-common-lib 1.3.44 → 1.3.45

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n20-common-lib",
3
- "version": "1.3.44",
3
+ "version": "1.3.45",
4
4
  "private": false,
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -64,6 +64,7 @@
64
64
  </template>
65
65
 
66
66
  <script>
67
+ import importG from '../../utils/importGlobal.js'
67
68
  import { tipShow, tipHide } from '../../directives/VTitle/index.js'
68
69
  export default {
69
70
  filters: {
@@ -101,11 +102,9 @@ export default {
101
102
  taskDefIdMap.forEach((obj) => {
102
103
  this.addEvent(obj)
103
104
  })
104
- let panzoom = window._g_panzoom
105
- if (!panzoom) {
106
- const _module = await import(/*webpackChunkName: "g_panzoom"*/ 'panzoom')
107
- panzoom = window._g_panzoom = _module.default
108
- }
105
+ let { default: panzoom } = await importG('panzoom', () =>
106
+ import(/*webpackChunkName: "panzoom"*/ 'panzoom')
107
+ )
109
108
 
110
109
  this.svgPanzoom = panzoom(this.svgC, {
111
110
  maxZoom: this.max,
@@ -24,21 +24,14 @@
24
24
  </template>
25
25
 
26
26
  <script>
27
+ import importG from '../../utils/importGlobal.js'
27
28
  export default {
28
29
  name: 'DragList',
29
30
  components: {
30
- vueDraggable: () => {
31
- if (!window._g_vuedraggable) {
32
- return import(
33
- /*webpackChunkName: "g_vuedraggable"*/ 'vuedraggable'
34
- ).then((_module) => {
35
- window._g_vuedraggable = _module
36
- return _module
37
- })
38
- } else {
39
- return Promise.resolve(window._g_vuedraggable)
40
- }
41
- }
31
+ vueDraggable: () =>
32
+ importG('vuedraggable', () =>
33
+ import(/*webpackChunkName: "vuedraggable"*/ 'vuedraggable')
34
+ )
42
35
  },
43
36
  props: {
44
37
  list: {
@@ -5,6 +5,7 @@
5
5
  <script>
6
6
  import resize from './mixins/resize'
7
7
  import merge from 'lodash/merge'
8
+ import importG from '../../utils/importGlobal.js'
8
9
 
9
10
  import { color, axisConfig, pieConfig } from './define'
10
11
 
@@ -57,13 +58,9 @@ export default {
57
58
 
58
59
  methods: {
59
60
  async initChart() {
60
- let echarts = window._g_echarts
61
- if (!echarts) {
62
- const _module = await import(
63
- /*webpackChunkName: "g_echarts"*/ 'echarts'
64
- )
65
- echarts = window._g_echarts = _module
66
- }
61
+ let echarts = await importG('echarts', () =>
62
+ import(/*webpackChunkName "echarts"*/ 'echarts')
63
+ )
67
64
  this.chart = echarts.init(this.$refs['chart'])
68
65
  this.setOption()
69
66
  },
@@ -177,6 +177,7 @@ import axios from '../../utils/axios'
177
177
  import auth from '../../utils/auth'
178
178
  import qrCode from './qrcode.vue'
179
179
  import { siteTree2menus, siteTree2RelaNos } from './utils'
180
+ import importG from '../../utils/importGlobal.js'
180
181
 
181
182
  function encode(pwd = '', key = 0) {
182
183
  if (pwd === '') return ''
@@ -494,13 +495,12 @@ export default {
494
495
  async loginAfter(data) {
495
496
  auth.setToken(data.accessToken)
496
497
  try {
497
- let decode = window._g_jsonwebtoken_decode
498
- if (!decode) {
499
- const _module = await import(
500
- /*webpackChunkName: "g_jsonwebtoken_decode"*/ 'jsonwebtoken/decode'
498
+ let { default: decode } = await importG('jsonwebtoken/decode', () =>
499
+ import(
500
+ /*webpackChunkName: "jsonwebtoken_decode"*/ 'jsonwebtoken/decode'
501
501
  )
502
- decode = window._g_jsonwebtoken_decode = _module.default
503
- }
502
+ )
503
+
504
504
  let tokenObj = decode(data.accessToken)
505
505
  let userInfo = JSON.parse(tokenObj.user_name)
506
506
  this.userNo = userInfo.userNo
@@ -21,6 +21,7 @@
21
21
  </template>
22
22
  <script>
23
23
  import axios from '../../utils/axios'
24
+ import importG from '../../utils/importGlobal.js'
24
25
 
25
26
  export default {
26
27
  data() {
@@ -52,14 +53,9 @@ export default {
52
53
 
53
54
  let qrCanvas = this.$refs['qr-canvas']
54
55
  let width = qrCanvas.clientWidth
55
-
56
- let QRCode = window._g_qrcode
57
- if (!QRCode) {
58
- const _module = await import(
59
- /*webpackChunkName: "g_qrcode"*/ 'qrcode'
60
- )
61
- QRCode = window._g_qrcode = _module.default
62
- }
56
+ let { default: QRCode } = await importG('qrcode', () =>
57
+ import(/*webpackChunkName: "qrcode"*/ 'qrcode')
58
+ )
63
59
  QRCode.toCanvas(this.$refs['qr-canvas'], this.qrCode, {
64
60
  width: width,
65
61
  height: width,
@@ -5,7 +5,7 @@
5
5
  :key="item.label"
6
6
  type="text"
7
7
  size="mini"
8
- :disabled="item.disabled"
8
+ :disabled="item.disabled | dbdBtn(row)"
9
9
  @click="$emit('command', item.command)"
10
10
  >{{ item.label }}</el-button
11
11
  >
@@ -16,7 +16,7 @@
16
16
  v-for="item in moreBtns"
17
17
  :key="item.label"
18
18
  :command="item.command"
19
- :disabled="item.disabled"
19
+ :disabled="item.disabled | dbdBtn(row)"
20
20
  >{{ item.label }}</el-dropdown-item
21
21
  >
22
22
  </el-dropdown-menu>
@@ -26,6 +26,17 @@
26
26
 
27
27
  <script>
28
28
  export default {
29
+ filters: {
30
+ dbdBtn(dbd, row) {
31
+ if (dbd === undefined || dbd === null) {
32
+ return false
33
+ } else if (typeof dbd === 'boolean') {
34
+ return dbd
35
+ } else if (typeof dbd === 'function') {
36
+ return dbd(row)
37
+ }
38
+ }
39
+ },
29
40
  props: {
30
41
  btnList: {
31
42
  type: Array,
package/src/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import './utils/importGlobal.js' // 联合加载组件保存位置
1
2
  /** 提供组件给外部使用的入口 */
2
3
  import ContentLoading from './components/ContentLoading/index.vue'
3
4
  import ContentNull from './components/ContentNull/index.vue'
@@ -0,0 +1,16 @@
1
+ window._g_import_g_ || (window._g_import_g_ = {})
2
+
3
+ function importG(name, ipt) {
4
+ return new Promise((resolve, reject) => {
5
+ if (window._g_import_g_[name]) {
6
+ resolve(window._g_import_g_[name])
7
+ } else {
8
+ ipt().then((_module) => {
9
+ window._g_import_g_[name] = _module
10
+ resolve(_module)
11
+ })
12
+ }
13
+ })
14
+ }
15
+
16
+ export default importG
@@ -1,13 +1,13 @@
1
+ import importG from './importGlobal.js'
2
+
1
3
  export default async function toExcel({
2
4
  columns = [],
3
5
  rows = [],
4
6
  name = 'sheet01'
5
7
  }) {
6
- let ExcelJS = window._g_exceljs
7
- if (!ExcelJS) {
8
- const _module = await import(/*webpackChunkName: "g_exceljs"*/ 'exceljs')
9
- ExcelJS = window._g_exceljs = _module.default
10
- }
8
+ let { default: ExcelJS } = await importG('exceljs', () =>
9
+ import(/*webpackChunkName: "exceljs"*/ 'exceljs')
10
+ )
11
11
 
12
12
  // 创建工作簿
13
13
  const workbook = new ExcelJS.Workbook()
@@ -1,10 +1,9 @@
1
+ import importG from './importGlobal.js'
2
+
1
3
  export default async function toJson(file, name) {
2
- let _xlsx = window._g_xlsx
3
- if (!_xlsx) {
4
- const _module = await import(/*webpackChunkName: "g_xlsx"*/ 'xlsx')
5
- _xlsx = window._g_xlsx = _module
6
- }
7
- const { read, utils } = _xlsx
4
+ const { read, utils } = await importG('xlsx', () =>
5
+ import(/*webpackChunkName: "xlsx"*/ 'xlsx')
6
+ )
8
7
 
9
8
  let pro = new Promise((resolve, reject) => {
10
9
  if (file instanceof Blob) {
@@ -1,9 +1,9 @@
1
+ import importG from './importGlobal.js'
2
+
1
3
  export default async function toJson(file, name) {
2
- let ExcelJS = window._g_exceljs
3
- if (!ExcelJS) {
4
- const _module = await import(/*webpackChunkName: "g_exceljs"*/ 'exceljs')
5
- ExcelJS = window._g_exceljs = _module.default
6
- }
4
+ let { default: ExcelJS } = await importG('exceljs', () =>
5
+ import(/*webpackChunkName: "exceljs"*/ 'exceljs')
6
+ )
7
7
 
8
8
  const workbook = new ExcelJS.Workbook()
9
9
  return new Promise((resolve, reject) => {