n20-common-lib 2.4.64 → 2.4.65

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": "2.4.64",
3
+ "version": "2.4.65",
4
4
  "private": false,
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -49,7 +49,6 @@
49
49
  "dependencies": {
50
50
  "axios": "*",
51
51
  "dayjs": "*",
52
- "element-ui": "^2.15.14",
53
52
  "js-cookie": "^3.0.1",
54
53
  "jsonwebtoken": "^8.5.1",
55
54
  "lz-string": "^1.4.4",
@@ -63,6 +62,7 @@
63
62
  "vuedraggable": "*"
64
63
  },
65
64
  "devDependencies": {
65
+ "element-ui": "^2.15.14",
66
66
  "@babel/plugin-proposal-optional-chaining": "^7.14.5",
67
67
  "@babel/plugin-transform-flow-comments": "^7.14.5",
68
68
  "@vue/cli-plugin-babel": "~4.5.0",
@@ -1,5 +1,6 @@
1
1
  import Tree from './index.vue'
2
2
 
3
+ /* istanbul ignore next */
3
4
  Tree.install = function (Vue) {
4
5
  Vue.component(Tree.name, Tree)
5
6
  }
@@ -4,6 +4,8 @@
4
4
  :node-key="nodeKey"
5
5
  :expand-on-click-node="false"
6
6
  :data="data"
7
+ :check-strictly="checkStrictlyC"
8
+ :show-checkbox="showCheckbox"
7
9
  :props="props"
8
10
  v-bind="$attrs"
9
11
  v-on="$listeners"
@@ -16,14 +18,21 @@
16
18
  >
17
19
  <span class="flex-box flex-v">
18
20
  <img :src="node.level == 1 ? folder : desc" class="m-r-ss" alt="" />
19
-
20
21
  {{ (data[props.value] ? '(' + data[props.value] + ') ' : '') + data[props.label] }}
21
22
  </span>
22
23
  <el-button
23
- v-if="node.data[nodeKey] === checkFlag && checkFlag.data && checkFlag.data[nodeKey]"
24
+ v-if="showCheckbox && node.checked && node.data[nodeKey] === checkFlag?.data?.[nodeKey]"
24
25
  type="text"
25
- @click="handleChecked(node)"
26
- >{{ '只勾选当前节点' }}</el-button
26
+ class="m-r-s"
27
+ @click="handleClose(node, data)"
28
+ >{{ $lc('取消勾选') }}</el-button
29
+ >
30
+ <el-button
31
+ v-else-if="showCheckbox && !node.checked && node.data[nodeKey] === checkFlag?.data?.[nodeKey]"
32
+ type="text"
33
+ class="m-r-s"
34
+ @click="handleChecked(node, data)"
35
+ >{{ $lc('只勾选本层级') }}</el-button
27
36
  >
28
37
  </div>
29
38
  </el-tree>
@@ -40,6 +49,14 @@ export default {
40
49
  type: Object,
41
50
  default: () => ({})
42
51
  },
52
+ showCheckbox: {
53
+ type: Boolean,
54
+ default: false
55
+ },
56
+ checkStrictly: {
57
+ type: Boolean,
58
+ default: false
59
+ },
43
60
  nodeKey: {
44
61
  type: String,
45
62
  default: ''
@@ -53,12 +70,24 @@ export default {
53
70
  list: []
54
71
  }
55
72
  },
73
+ computed: {
74
+ checkStrictlyC: {
75
+ get() {
76
+ return this.checkStrictly
77
+ },
78
+ set(v) {
79
+ console.log(v, 123)
80
+ return this.$emit('update:checkStrictly', v)
81
+ }
82
+ }
83
+ },
56
84
  mounted() {
57
85
  this.setRefData()
58
86
  },
59
87
  methods: {
60
88
  setRefData() {
61
89
  const {
90
+ store,
62
91
  filter,
63
92
  updateKeyChildren,
64
93
  getCheckedNodes,
@@ -97,12 +126,20 @@ export default {
97
126
  this.append = append
98
127
  this.insertBefore = insertBefore
99
128
  this.insertAfter = insertAfter
129
+ this.store = store
100
130
  },
101
- handleChecked(node) {
131
+ handleChecked(node, data) {
132
+ this.store.checkStrictly = true
102
133
  this.setChecked(node.data, true)
134
+ this.store.checkStrictly = false
103
135
  },
104
136
  mouseenterTree(node, data) {
105
137
  this.checkFlag = node
138
+ },
139
+ handleClose(node, data) {
140
+ this.store.checkStrictly = true
141
+ this.setChecked(node.data, false)
142
+ this.store.checkStrictly = false
106
143
  }
107
144
  }
108
145
  }
@@ -48,7 +48,7 @@
48
48
  type="text"
49
49
  @click="
50
50
  () => {
51
- footerBtn.export.click()
51
+ footerBtn.importBtn.click()
52
52
  progressV = false
53
53
  }
54
54
  "
@@ -0,0 +1,10 @@
1
+ import directive from './src/directive.js'
2
+ import service from './src/index.js'
3
+
4
+ export default {
5
+ install(Vue) {
6
+ Vue.use(directive)
7
+ },
8
+ directive,
9
+ service
10
+ }
@@ -0,0 +1,134 @@
1
+ import Vue from 'vue'
2
+ import Loading from './loading.vue'
3
+ import { addClass, removeClass, getStyle } from 'element-ui/src/utils/dom'
4
+ import { PopupManager } from 'element-ui/src/utils/popup'
5
+ import afterLeave from 'element-ui/src/utils/after-leave'
6
+ const Mask = Vue.extend(Loading)
7
+
8
+ const loadingDirective = {}
9
+ loadingDirective.install = Vue => {
10
+ if (Vue.prototype.$isServer) return
11
+ const toggleLoading = (el, binding) => {
12
+ if (binding.value) {
13
+ el.instance.processShowFn(binding.value)
14
+ Vue.nextTick(() => {
15
+ if (binding.modifiers.fullscreen) {
16
+ el.originalPosition = getStyle(document.body, 'position')
17
+ el.originalOverflow = getStyle(document.body, 'overflow')
18
+ el.maskStyle.zIndex = PopupManager.nextZIndex()
19
+
20
+ addClass(el.mask, 'is-fullscreen')
21
+ insertDom(document.body, el, binding)
22
+ } else {
23
+ removeClass(el.mask, 'is-fullscreen')
24
+
25
+ if (binding.modifiers.body) {
26
+ el.originalPosition = getStyle(document.body, 'position')
27
+ ;['top', 'left'].forEach(property => {
28
+ const scroll = property === 'top' ? 'scrollTop' : 'scrollLeft'
29
+ el.maskStyle[property] =
30
+ el.getBoundingClientRect()[property] +
31
+ document.body[scroll] +
32
+ document.documentElement[scroll] -
33
+ parseInt(getStyle(document.body, `margin-${property}`), 10) +
34
+ 'px'
35
+ })
36
+ ;['height', 'width'].forEach(property => {
37
+ el.maskStyle[property] = el.getBoundingClientRect()[property] + 'px'
38
+ })
39
+
40
+ insertDom(document.body, el, binding)
41
+ } else {
42
+ el.originalPosition = getStyle(el, 'position')
43
+ insertDom(el, el, binding)
44
+ }
45
+ }
46
+ })
47
+ } else {
48
+ afterLeave(
49
+ el.instance,
50
+ _ => {
51
+ if (!el.instance.hiding) return
52
+ el.domVisible = false
53
+ const target = binding.modifiers.fullscreen || binding.modifiers.body ? document.body : el
54
+ removeClass(target, 'el-loading-parent--relative')
55
+ removeClass(target, 'el-loading-parent--hidden')
56
+ el.instance.hiding = false
57
+ },
58
+ 300,
59
+ true
60
+ )
61
+ el.instance.visible = false
62
+ el.instance.hiding = true
63
+ }
64
+ }
65
+ const insertDom = (parent, el, binding) => {
66
+ if (!el.domVisible && getStyle(el, 'display') !== 'none' && getStyle(el, 'visibility') !== 'hidden') {
67
+ Object.keys(el.maskStyle).forEach(property => {
68
+ el.mask.style[property] = el.maskStyle[property]
69
+ })
70
+
71
+ if (el.originalPosition !== 'absolute' && el.originalPosition !== 'fixed' && el.originalPosition !== 'sticky') {
72
+ addClass(parent, 'el-loading-parent--relative')
73
+ }
74
+ if (binding.modifiers.fullscreen && binding.modifiers.lock) {
75
+ addClass(parent, 'el-loading-parent--hidden')
76
+ }
77
+ el.domVisible = true
78
+
79
+ parent.appendChild(el.mask)
80
+ Vue.nextTick(() => {
81
+ if (el.instance.hiding) {
82
+ el.instance.$emit('after-leave')
83
+ } else {
84
+ el.instance.visible = true
85
+ }
86
+ })
87
+ el.domInserted = true
88
+ } else if (el.domVisible && el.instance.hiding === true) {
89
+ el.instance.visible = true
90
+ el.instance.hiding = false
91
+ }
92
+ }
93
+
94
+ Vue.directive('tableLoading', {
95
+ bind: function (el, binding, vnode) {
96
+ const textExr = el.getAttribute('element-loading-text')
97
+ const spinnerExr = el.getAttribute('element-loading-spinner')
98
+ const backgroundExr = el.getAttribute('element-loading-background')
99
+ const customClassExr = el.getAttribute('element-loading-custom-class')
100
+ const vm = vnode.context
101
+ const mask = new Mask({
102
+ el: document.createElement('div'),
103
+ data: {
104
+ text: (vm && vm[textExr]) || textExr,
105
+ spinner: (vm && vm[spinnerExr]) || spinnerExr,
106
+ background: (vm && vm[backgroundExr]) || backgroundExr,
107
+ customClass: (vm && vm[customClassExr]) || customClassExr,
108
+ fullscreen: !!binding.modifiers.fullscreen
109
+ }
110
+ })
111
+ el.instance = mask
112
+ el.mask = mask.$el
113
+ el.maskStyle = {}
114
+ binding.value && toggleLoading(el, binding)
115
+ },
116
+
117
+ update: function (el, binding) {
118
+ el.instance.setText(el.getAttribute('element-loading-text'))
119
+ if (binding.oldValue !== binding.value) {
120
+ toggleLoading(el, binding)
121
+ }
122
+ },
123
+
124
+ unbind: function (el, binding) {
125
+ if (el.domInserted) {
126
+ el.mask && el.mask.parentNode && el.mask.parentNode.removeChild(el.mask)
127
+ toggleLoading(el, { value: false, modifiers: binding.modifiers })
128
+ }
129
+ el.instance && el.instance.$destroy()
130
+ }
131
+ })
132
+ }
133
+
134
+ export default loadingDirective
@@ -0,0 +1,113 @@
1
+ import Vue from 'vue'
2
+ import loadingVue from './loading.vue'
3
+ import { addClass, removeClass, getStyle } from 'element-ui/src/utils/dom'
4
+ import { PopupManager } from 'element-ui/src/utils/popup'
5
+ import afterLeave from 'element-ui/src/utils/after-leave'
6
+ import merge from 'element-ui/src/utils/merge'
7
+
8
+ const LoadingConstructor = Vue.extend(loadingVue)
9
+
10
+ const defaults = {
11
+ text: null,
12
+ fullscreen: true,
13
+ body: false,
14
+ lock: false,
15
+ customClass: ''
16
+ }
17
+
18
+ let fullscreenLoading
19
+
20
+ LoadingConstructor.prototype.originalPosition = ''
21
+ LoadingConstructor.prototype.originalOverflow = ''
22
+
23
+ LoadingConstructor.prototype.close = function () {
24
+ if (this.fullscreen) {
25
+ fullscreenLoading = undefined
26
+ }
27
+ afterLeave(
28
+ this,
29
+ (_) => {
30
+ const target = this.fullscreen || this.body ? document.body : this.target
31
+ removeClass(target, 'el-loading-parent--relative')
32
+ removeClass(target, 'el-loading-parent--hidden')
33
+ if (this.$el && this.$el.parentNode) {
34
+ this.$el.parentNode.removeChild(this.$el)
35
+ }
36
+ this.$destroy()
37
+ },
38
+ 300
39
+ )
40
+ this.visible = false
41
+ }
42
+
43
+ const addStyle = (options, parent, instance) => {
44
+ let maskStyle = {}
45
+ if (options.fullscreen) {
46
+ instance.originalPosition = getStyle(document.body, 'position')
47
+ instance.originalOverflow = getStyle(document.body, 'overflow')
48
+ maskStyle.zIndex = PopupManager.nextZIndex()
49
+ } else if (options.body) {
50
+ instance.originalPosition = getStyle(document.body, 'position')
51
+ ;['top', 'left'].forEach((property) => {
52
+ let scroll = property === 'top' ? 'scrollTop' : 'scrollLeft'
53
+ maskStyle[property] =
54
+ options.target.getBoundingClientRect()[property] +
55
+ document.body[scroll] +
56
+ document.documentElement[scroll] +
57
+ 'px'
58
+ })
59
+ ;['height', 'width'].forEach((property) => {
60
+ maskStyle[property] = options.target.getBoundingClientRect()[property] + 'px'
61
+ })
62
+ } else {
63
+ instance.originalPosition = getStyle(parent, 'position')
64
+ }
65
+ Object.keys(maskStyle).forEach((property) => {
66
+ instance.$el.style[property] = maskStyle[property]
67
+ })
68
+ }
69
+
70
+ const Loading = (options = {}) => {
71
+ if (Vue.prototype.$isServer) return
72
+ options = merge({}, defaults, options)
73
+ if (typeof options.target === 'string') {
74
+ options.target = document.querySelector(options.target)
75
+ }
76
+ options.target = options.target || document.body
77
+ if (options.target !== document.body) {
78
+ options.fullscreen = false
79
+ } else {
80
+ options.body = true
81
+ }
82
+ if (options.fullscreen && fullscreenLoading) {
83
+ return fullscreenLoading
84
+ }
85
+
86
+ let parent = options.body ? document.body : options.target
87
+ let instance = new LoadingConstructor({
88
+ el: document.createElement('div'),
89
+ data: options
90
+ })
91
+
92
+ addStyle(options, parent, instance)
93
+ if (
94
+ instance.originalPosition !== 'absolute' &&
95
+ instance.originalPosition !== 'fixed' &&
96
+ instance.originalPosition !== 'sticky'
97
+ ) {
98
+ addClass(parent, 'el-loading-parent--relative')
99
+ }
100
+ if (options.fullscreen && options.lock) {
101
+ addClass(parent, 'el-loading-parent--hidden')
102
+ }
103
+ parent.appendChild(instance.$el)
104
+ Vue.nextTick(() => {
105
+ instance.visible = true
106
+ })
107
+ if (options.fullscreen) {
108
+ fullscreenLoading = instance
109
+ }
110
+ return instance
111
+ }
112
+
113
+ export default Loading
@@ -0,0 +1,90 @@
1
+ <template>
2
+ <transition name="el-loading-fade" @after-leave="handleAfterLeave">
3
+ <div
4
+ v-show="visible"
5
+ class="el-loading-mask"
6
+ :style="{ backgroundColor: background || '' }"
7
+ :class="[customClass, { 'is-fullscreen': fullscreen }]"
8
+ >
9
+ <div class="el-loading-spinner">
10
+ <img class="loadingCss" src="./loading.png" />
11
+ <div class="numCss">
12
+ <div class="process">{{ percentage }}%</div>
13
+ <div v-if="percentage == 100" class="m-t-ss" style="font-size: 10px">Completed</div>
14
+ </div>
15
+ </div>
16
+ </div>
17
+ </transition>
18
+ </template>
19
+
20
+ <script>
21
+ export default {
22
+ data() {
23
+ return {
24
+ text: null,
25
+ spinner: null,
26
+ background: null,
27
+ fullscreen: true,
28
+ visible: false,
29
+ customClass: '',
30
+ processShow: false,
31
+ timer: null,
32
+ percentage: 0
33
+ }
34
+ },
35
+ watch: {},
36
+ methods: {
37
+ handleAfterLeave() {
38
+ this.$emit('after-leave')
39
+ },
40
+ processShowFn(val) {
41
+ // // 查询进度条
42
+ this.percentage = 0
43
+ this.timer = setInterval(async (_) => {
44
+ // 计算当前进度
45
+ this.percentage = this.percentage + 5
46
+ // 若进度值达到百分之百时,
47
+ if (this.percentage > 99) {
48
+ this.percentage = 99
49
+ }
50
+ }, 3)
51
+ },
52
+ setText(text) {
53
+ if (text > 0) {
54
+ this.percentage = text
55
+ clearInterval(this.timer)
56
+ }
57
+ }
58
+ }
59
+ }
60
+ </script>
61
+ <style lang="scss" scoped>
62
+ .loadingCss {
63
+ width: 120px;
64
+ height: 120px;
65
+ animation: rotate 3s linear infinite;
66
+ }
67
+ /deep/.el-loading-mask {
68
+ background-color: #fff;
69
+ }
70
+ .el-loading-spinner {
71
+ position: relative;
72
+ margin-top: -62px;
73
+ }
74
+ .numCss {
75
+ position: absolute;
76
+ display: flex;
77
+ flex-direction: column;
78
+ align-items: center;
79
+ justify-content: center;
80
+ height: 80px;
81
+ width: 80px;
82
+ top: calc(50% - 44px);
83
+ left: calc(50% - 40px);
84
+ color: var(--color-primary);
85
+ }
86
+ .process {
87
+ font-size: 20px;
88
+ font-weight: bold;
89
+ }
90
+ </style>
package/src/index.js CHANGED
@@ -94,6 +94,7 @@ import VHas from './directives/VHas/index.js'
94
94
  import VMove from './directives/VMove/index.js'
95
95
  import VRuleKey from './directives/VRuleKey/index.js'
96
96
  import { HoverTooltip, TitleDirective } from './directives/VTitle/index.js'
97
+ import VTableLoading from './directives/loading/index.js'
97
98
 
98
99
  /** 注入方法 */
99
100
  import dayjs from 'dayjs'
@@ -221,6 +222,7 @@ const install = function (Vue, opts = { prefix: 'Cl', i18nConfig: {} }) {
221
222
  Vue.use(VRuleKey)
222
223
  Vue.use(VClickOutside)
223
224
  Vue.use(VHas)
225
+ Vue.use(VTableLoading)
224
226
 
225
227
  Vue.use(i18n, opts.i18nConfig)
226
228
  Vue.prototype.$axios = axios