n20-common-lib 2.1.21 → 2.1.22

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.1.21",
3
+ "version": "2.1.22",
4
4
  "private": false,
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -6,12 +6,7 @@
6
6
  :options="areaTree"
7
7
  :filterable="filterable"
8
8
  :clearable="clearable"
9
- :props="{
10
- value: 'regionNo',
11
- label: 'regionName',
12
- children: 'children',
13
- expandTrigger: 'hover'
14
- }"
9
+ :props="propsAs"
15
10
  v-on="$listeners"
16
11
  />
17
12
  </template>
@@ -44,6 +39,10 @@ export default {
44
39
  countryId: {
45
40
  type: String,
46
41
  default: 'CHN'
42
+ },
43
+ props: {
44
+ type: Object,
45
+ default: undefined
47
46
  }
48
47
  },
49
48
  data() {
@@ -52,6 +51,15 @@ export default {
52
51
  }
53
52
  },
54
53
  computed: {
54
+ propsAs() {
55
+ let _prop = {
56
+ value: 'regionNo',
57
+ label: 'regionName',
58
+ children: 'children',
59
+ expandTrigger: 'hover'
60
+ }
61
+ return Object.assign(_prop, this.props)
62
+ },
55
63
  areaKey() {
56
64
  return this.countryId === 'CHN' ? '_china_area_tree_' : `_${this.countryId}_area_tree_`
57
65
  },
@@ -27,10 +27,10 @@
27
27
  </div>
28
28
  <div class="text-c m-t m-b">
29
29
  <slot name="actions">
30
- <el-button size="mini" type="primary" style="width: 76px" @click="filter">
30
+ <el-button type="primary" @click="filter">
31
31
  {{ filterText }}
32
32
  </el-button>
33
- <el-button size="mini" plain style="width: 76px" @click="clear">
33
+ <el-button plain @click="clear">
34
34
  {{ clearText }}
35
35
  </el-button>
36
36
  </slot>
@@ -155,7 +155,7 @@
155
155
  </dialogWrap>
156
156
  <!-- 消息/通知 -->
157
157
  <el-popover ref="noticePop" trigger="click" width="400" @after-enter="$refs.noticeContent.show()">
158
- <noticePop ref="noticeContent" :num.sync="noticeNum" />
158
+ <noticePop ref="noticeContent" />
159
159
  </el-popover>
160
160
  <el-dialog :visible.sync="scV" :title="'切换用户' | $lc" append-to-body width="600px">
161
161
  <switchUser :visible.sync="scV" :user-no="userNo" />
@@ -270,6 +270,10 @@ export default {
270
270
  this.show = true
271
271
  }
272
272
  })
273
+
274
+ this.getNNum()
275
+ document.addEventListener('visibilitychange', this.getNNum)
276
+ window.addEventListener('message', this.updateNotice)
273
277
  },
274
278
  mounted() {
275
279
  let userInfo = JSON.parse(sessionStorage.getItem('userInfo') || '{}')
@@ -281,6 +285,10 @@ export default {
281
285
  }
282
286
  this.rolesList = userInfo.roles || []
283
287
  },
288
+ beforeDestroy() {
289
+ document.removeEventListener('visibilitychange', this.getNNum)
290
+ window.removeEventListener('message', this.updateNotice)
291
+ },
284
292
  methods: {
285
293
  // 跳转打主数据人员页面
286
294
  goMdmUser() {
@@ -422,6 +430,29 @@ export default {
422
430
  })
423
431
 
424
432
  this.underway = !!res.data
433
+ },
434
+ // 更新消息条数
435
+ updateNotice(ev) {
436
+ if (ev.data === 'NstcUpdateNotice') {
437
+ this.getNNum()
438
+ }
439
+ },
440
+ // 获取消息条数
441
+ getNNum() {
442
+ clearTimeout(this.getNNumTimeOut)
443
+ if (!document.hidden) {
444
+ Promise.all([
445
+ axios.get('/bems/wkb/messageCenter/getUnReadTotal/' + this.username, null, { loading: false, noMsg: true }),
446
+ axios.get('/bems/1.0/notice/notReadCount', null, {
447
+ loading: false,
448
+ noMsg: true
449
+ })
450
+ ]).then(([res_1, res_2]) => {
451
+ this.noticeNum = (res_1.data.data || 0) + (res_2.data || 0)
452
+ })
453
+
454
+ this.getNNumTimeOut = setTimeout(this.loopGetNNum, 1000 * 60 * 3)
455
+ }
425
456
  }
426
457
  }
427
458
  }
@@ -74,7 +74,8 @@
74
74
  </el-tooltip>
75
75
 
76
76
  <el-badge :hidden="noticeNum === 0" :value="noticeNum">
77
- <span v-popover:noticePop class="news-btn iconfont icon-xiaoxi header-color"></span>
77
+ <span v-if="!noticeDrw" v-popover:noticePop class="news-btn iconfont icon-xiaoxi header-color"></span>
78
+ <span v-else class="news-btn iconfont icon-xiaoxi header-color" @click="customOpt.noticeDrawer"></span>
78
79
  </el-badge>
79
80
 
80
81
  <el-popover ref="by_popover" v-model="byV" placement="bottom-start" trigger="manual" popper-class="uby-w">
@@ -121,8 +122,11 @@
121
122
  <div class="uif-gs text-ellipsis">{{ userInfo.companyName }}</div>
122
123
  <div class="uif-js text-ellipsis">{{ rolesList.map((el) => el.name).join('/') }}</div>
123
124
  <div class="uif-by">
124
- <span>{{ byLabel }}</span>
125
- <span class="_edit el-icon-edit" @click="editByLabel"></span>
125
+ <template v-if="!byEV">
126
+ <span>{{ byLabel }}</span>
127
+ <span class="_edit el-icon-edit" @click="byEShow"></span>
128
+ </template>
129
+ <el-input v-else v-model="byLabel" size="mini" style="width: 92%" @blur="editByLabel" />
126
130
  </div>
127
131
  </div>
128
132
  <el-dropdown-item command="changePassword">
@@ -212,8 +216,8 @@
212
216
  <changePwd :visible.sync="cpwdV" />
213
217
  </dialogWrap>
214
218
  <!-- 消息/通知 -->
215
- <el-popover ref="noticePop" trigger="click" width="400" @after-enter="$refs.noticeContent.show()">
216
- <noticePop ref="noticeContent" :num.sync="noticeNum" />
219
+ <el-popover v-if="!noticeDrw" ref="noticePop" trigger="click" width="400" @after-enter="$refs.noticeContent.show()">
220
+ <noticePop ref="noticeContent" />
217
221
  </el-popover>
218
222
  <el-dialog :visible.sync="scV" :title="'切换用户' | $lc" append-to-body width="600px">
219
223
  <switchUser :visible.sync="scV" :user-no="userNo" />
@@ -303,10 +307,16 @@ export default {
303
307
  /* */
304
308
  byV: false,
305
309
  byLabel: '',
310
+ byEV: false,
306
311
  headerUserInfoBg: realUrl('/server-assets/userInfoBg.png'),
307
312
  inBack: window.localStorage.getItem('pageInType') === 'inBack'
308
313
  }
309
314
  },
315
+ computed: {
316
+ noticeDrw() {
317
+ return !!this.customOpt.noticeDrawer
318
+ }
319
+ },
310
320
  created() {
311
321
  getJsonc('/server-config.jsonc').then(({ _layoutData = {}, loginSetting }) => {
312
322
  let _loginSetting = loginSetting || _layoutData.loginSetting
@@ -343,6 +353,10 @@ export default {
343
353
  }, 6000)
344
354
  })
345
355
  })
356
+
357
+ this.getNNum()
358
+ document.addEventListener('visibilitychange', this.getNNum)
359
+ window.addEventListener('message', this.updateNotice)
346
360
  },
347
361
  mounted() {
348
362
  let userInfo = JSON.parse(sessionStorage.getItem('userInfo') || '{}')
@@ -354,6 +368,10 @@ export default {
354
368
  }
355
369
  this.rolesList = userInfo.roles || []
356
370
  },
371
+ beforeDestroy() {
372
+ document.removeEventListener('visibilitychange', this.getNNum)
373
+ window.removeEventListener('message', this.updateNotice)
374
+ },
357
375
  methods: {
358
376
  // 跳转打主数据人员页面
359
377
  goMdmUser() {
@@ -377,6 +395,10 @@ export default {
377
395
  },
378
396
  // 打开帮助文档
379
397
  openHelp() {
398
+ if (this.customOpt.openHelp) {
399
+ this.customOpt.openHelp()
400
+ return false
401
+ }
380
402
  axios
381
403
  .get(`/bems/1.0/userManual`, {}, { responseType: 'blob' })
382
404
  .then((res) => {
@@ -454,7 +476,10 @@ export default {
454
476
  window.location.reload()
455
477
  },
456
478
  dowApp() {
457
- // alert('客户端下载')
479
+ if (this.customOpt.dowApp) {
480
+ this.customOpt.dowApp()
481
+ return false
482
+ }
458
483
  let name = 'download.exe'
459
484
  let aDom = document.createElement('a')
460
485
  aDom.href = `${prefix}server-assets/${name}`
@@ -537,21 +562,56 @@ export default {
537
562
  this.headerUserUrl = window.URL.createObjectURL(login)
538
563
  })
539
564
  },
540
- async editByLabel() {
541
- let { value } = await this.$prompt($lc('请输入欢迎语'), $lc('修改'), {
542
- confirmButtonText: $lc('确定'),
543
- cancelButtonText: $lc('取消'),
544
- inputValue: this.byLabel
545
- })
546
- await this.$axios.get(`/bems/portal/portalUserIndexConfig/saveConfigSign/${value}`)
565
+ byEShow() {
566
+ this.byLabelO = this.byLabel
567
+ this.byEV = true
568
+ },
569
+ editByLabel() {
570
+ // let { value } = await this.$prompt($lc('请输入欢迎语'), $lc('修改'), {
571
+ // confirmButtonText: $lc('确定'),
572
+ // cancelButtonText: $lc('取消'),
573
+ // inputValue: this.byLabel
574
+ // })
575
+ // await this.$axios.get(`/bems/portal/portalUserIndexConfig/saveConfigSign/${value}`)
576
+ // this.byLabel = value
547
577
 
548
- this.byLabel = value
578
+ this.$axios
579
+ .get(`/bems/portal/portalUserIndexConfig/saveConfigSign/${this.byLabel}`)
580
+ .then(() => {
581
+ this.byEV = false
582
+ })
583
+ .catch(() => {
584
+ this.byLabel = this.byLabelO
585
+ })
549
586
  },
550
587
  getByLabel() {
551
588
  return this.$axios.get(`/bems/portal/portalUserIndexConfig/getConfigByUno`).then((res) => {
552
589
  let data = res.data || {}
553
- this.byLabel = data.signature ?? this.byLabel
590
+ data.signature && (this.byLabel = data.signature)
554
591
  })
592
+ },
593
+ // 更新消息条数
594
+ updateNotice(ev) {
595
+ if (ev.data === 'NstcUpdateNotice') {
596
+ this.getNNum()
597
+ }
598
+ },
599
+ // 获取消息条数
600
+ getNNum() {
601
+ clearTimeout(this.getNNumTimeOut)
602
+ if (!document.hidden) {
603
+ Promise.all([
604
+ axios.get('/bems/wkb/messageCenter/getUnReadTotal/' + this.username, null, { loading: false, noMsg: true }),
605
+ axios.get('/bems/1.0/notice/notReadCount', null, {
606
+ loading: false,
607
+ noMsg: true
608
+ })
609
+ ]).then(([res_1, res_2]) => {
610
+ this.noticeNum = (res_1.data.data || 0) + (res_2.data || 0)
611
+ })
612
+
613
+ this.getNNumTimeOut = setTimeout(this.loopGetNNum, 1000 * 60 * 3)
614
+ }
555
615
  }
556
616
  }
557
617
  }
@@ -81,12 +81,6 @@ export default {
81
81
  return `【${msgT}】${item.title}`
82
82
  }
83
83
  },
84
- props: {
85
- num: {
86
- type: Number,
87
- default: 0
88
- }
89
- },
90
84
  data() {
91
85
  return {
92
86
  showKey: 0,
@@ -102,25 +96,6 @@ export default {
102
96
  afficheTotal: 0
103
97
  }
104
98
  },
105
- computed: {
106
- numC: {
107
- get() {
108
- return this.num
109
- },
110
- set(n) {
111
- this.$emit('update:num', n)
112
- }
113
- }
114
- },
115
- created() {
116
- this.getNNum()
117
- document.addEventListener('visibilitychange', this.getNNum)
118
- window.addEventListener('message', this.updateNotice)
119
- },
120
- beforeDestroy() {
121
- document.removeEventListener('visibilitychange', this.getNNum)
122
- window.removeEventListener('message', this.updateNotice)
123
- },
124
99
  methods: {
125
100
  show() {
126
101
  this.showKey = this.showKey + 1
@@ -128,30 +103,6 @@ export default {
128
103
  this.getMsgList()
129
104
  this.getAfficheList()
130
105
  },
131
- updateNotice(ev) {
132
- if (ev.data === 'NstcUpdateNotice') {
133
- this.getNNum()
134
- }
135
- },
136
- getNNum() {
137
- clearTimeout(this.getNNumTimeOut)
138
- if (!document.hidden) {
139
- Promise.all([
140
- axios.get('/bems/wkb/messageCenter/getUnReadTotal/' + this.username, null, { loading: false, noMsg: true }),
141
- axios.get('/bems/1.0/notice/notReadCount', null, {
142
- loading: false,
143
- noMsg: true
144
- })
145
- ]).then(([res_1, res_2]) => {
146
- this.noticeNum = res_1.data.data
147
- this.afficheNum = res_2.data
148
-
149
- this.numC = this.noticeNum + this.afficheNum
150
- })
151
-
152
- this.getNNumTimeOut = setTimeout(this.loopGetNNum, 1000 * 60 * 5)
153
- }
154
- },
155
106
  getMsgList() {
156
107
  this.nLd = true
157
108
  axios
@@ -221,25 +172,18 @@ export default {
221
172
  .then(() => {
222
173
  item.readState = '1'
223
174
  this.noticeNum = this.noticeNum - 1
224
- this.numC = this.numC - 1
175
+ window.postMessage('NstcUpdateNotice')
225
176
  })
226
177
  }
227
178
  },
228
179
  seeDetailsAffiche(item) {
229
- if (this.$route.path === '/notice/views') {
230
- this.$router.push('/loading')
231
- setTimeout(() => {
232
- this.$router.push({
233
- path: `/notice/views`,
234
- query: { ntId: item.ntId, status: '1' }
235
- })
236
- }, 500)
237
- } else {
238
- this.$router.push({
239
- path: `/notice/views`,
240
- query: { ntId: item.ntId, status: '1' }
241
- })
242
- }
180
+ this.$router.push({
181
+ path: `/notice/views`,
182
+ query: { ntId: item.ntId, status: '1' }
183
+ })
184
+ setTimeout(function () {
185
+ window.postMessage('NstcUpdateNotice')
186
+ }, 3000)
243
187
  },
244
188
  readAll() {
245
189
  this.$msgboxPor({
package/src/index.js CHANGED
@@ -1,5 +1,6 @@
1
- import './utils/importGlobal.js' // 联合加载组件保存位置
1
+ import importG from './utils/importGlobal.js' // 联合加载组件保存位置
2
2
  import './utils/storagePro.js' // 扩展Storage
3
+ import './utils/numberPor.js' // 扩展Number
3
4
  /** 提供组件给外部使用的入口 */
4
5
  import ContentLoading from './components/ContentLoading/index.vue'
5
6
  import ContentNull from './components/ContentNull/index.vue'
@@ -221,6 +222,7 @@ export {
221
222
  auth,
222
223
  axios,
223
224
  getJsonc,
225
+ importG,
224
226
  downloadBlob,
225
227
  forEachs,
226
228
  list2tree,
@@ -0,0 +1,168 @@
1
+ /* eslint-disable no-extend-native */
2
+ if (!Number.add) {
3
+ let i = 1
4
+
5
+ const add = function (n, decimal = 10) {
6
+ let rN = this + n
7
+ return decimal ? Number(rN.toFixed(decimal)) : rN
8
+ }
9
+ const sub = function (n, decimal = 10) {
10
+ let rN = this - n
11
+ return decimal ? Number(rN.toFixed(decimal)) : rN
12
+ }
13
+ const mul = function (n, decimal = 10) {
14
+ let rN = this * n
15
+ return decimal ? Number(rN.toFixed(decimal)) : rN
16
+ }
17
+ const div = function (n, decimal = 10) {
18
+ let rN = this / n
19
+ return decimal ? Number(rN.toFixed(decimal)) : rN
20
+ }
21
+
22
+ // 去括号
23
+ const splitPts = function (obj) {
24
+ let mc = obj.mEl.match(/\([^()]+\)/g)
25
+ if (mc) {
26
+ mc.forEach((m) => {
27
+ let vk = 'El' + i++
28
+ obj.Els[vk] = m.replace(/\(|\)/g, '')
29
+ obj.mEl = obj.mEl.replace(m, vk)
30
+ })
31
+
32
+ return splitPts(obj)
33
+ } else {
34
+ return obj
35
+ }
36
+ }
37
+ // 负数转括号
38
+ const negToPts = function (Els, k) {
39
+ if (/\+-/.test(Els[k])) {
40
+ Els[k] = Els[k].replace(/\+-/, '-')
41
+ }
42
+
43
+ if (/--/.test(Els[k])) {
44
+ Els[k] = Els[k].replace(/--/, '+')
45
+ }
46
+
47
+ if (/\*-/.test(Els[k])) {
48
+ let mc = Els[k].match(/\*-[^+|-|*|/]+/g)
49
+ if (mc) {
50
+ mc.forEach((m) => {
51
+ let vk = 'El' + i++
52
+ Els[vk] = m.replace('*', '0')
53
+ Els[k] = Els[k].replace(m, '*' + vk)
54
+ })
55
+ }
56
+ }
57
+
58
+ if (/\/-/.test(Els[k])) {
59
+ let mc = Els[k].match(/\/-[^+|-|*|/]+/g)
60
+ if (mc) {
61
+ mc.forEach((m) => {
62
+ let vk = 'El' + i++
63
+ Els[vk] = m.replace('/', '0')
64
+ Els[k] = Els[k].replace(m, '/' + vk)
65
+ })
66
+ }
67
+ }
68
+ }
69
+ // 乘除转括号
70
+ const muldivToPts = function (Els, k) {
71
+ if (/\*|\//.test(Els[k]) && /\+|-/.test(Els[k])) {
72
+ let mc = Els[k].match(/[^+|-]*[*|/][^+|-]*/g)
73
+ if (mc) {
74
+ mc.forEach((m) => {
75
+ let vk = 'El' + i++
76
+ Els[vk] = m.replace(/\(|\)/g, '')
77
+ Els[k] = Els[k].replace(m, vk)
78
+ })
79
+ }
80
+ }
81
+ }
82
+ // 符号切割运算
83
+ const splitSmb = function (Els) {
84
+ for (let k in Els) {
85
+ Els[k + 'O'] = Els[k]
86
+ Els[k] = Els[k].replace(/\+|-|\*|\//g, (v) => ',' + v + ',')
87
+ Els[k] = Els[k].split(',')
88
+ }
89
+ }
90
+
91
+ const compute = function (Els, k, fc) {
92
+ let El = Els[k]
93
+ El.forEach((e, i) => {
94
+ if (/^El/.test(e)) {
95
+ El[i] = compute(Els, e, fc)
96
+ }
97
+ })
98
+
99
+ let L = El.length
100
+ let Val = Number(El[0])
101
+ for (let i = 1; i < L; i) {
102
+ if (['+', '-', '*', '/'].includes(El[i])) {
103
+ switch (El[i]) {
104
+ case '+':
105
+ Val = Val.add(Number(El[i + 1]), fc)
106
+ break
107
+ case '-':
108
+ Val = Val.sub(Number(El[i + 1]), fc)
109
+ break
110
+ case '*':
111
+ Val = Val.mul(Number(El[i + 1]), fc)
112
+ break
113
+ case '/':
114
+ Val = Val.div(Number(El[i + 1]), fc)
115
+ break
116
+ }
117
+ i += 2
118
+ }
119
+ }
120
+ return Val
121
+ }
122
+ const evaluate = function (evalStr = '', decimal = 10, proceDecimal) {
123
+ if (decimal) {
124
+ i = 1
125
+ let obj = { mEl: evalStr.replace(/\s/g, ''), Els: {} }
126
+
127
+ splitPts(obj)
128
+
129
+ let Els = obj.Els
130
+ Els['Elm'] = obj.mEl
131
+ obj = undefined
132
+
133
+ negToPts(Els, 'Elm')
134
+ for (let k in Els) {
135
+ k !== 'Elm' && negToPts(Els, k)
136
+ }
137
+
138
+ muldivToPts(Els, 'Elm')
139
+ for (let k in Els) {
140
+ k !== 'Elm' && muldivToPts(Els, k)
141
+ }
142
+
143
+ splitSmb(Els)
144
+
145
+ let RES = compute(Els, 'Elm', proceDecimal || decimal)
146
+ RES = RES.add(0, decimal)
147
+ return RES
148
+ } else {
149
+ // eslint-disable-next-line no-eval
150
+ eval('window._number_eval_res=' + evalStr)
151
+ let RES = window._number_eval_res
152
+ delete window._number_eval_res
153
+ return RES
154
+ }
155
+ }
156
+
157
+ Number.prototype.add = add
158
+ Number.prototype.sub = sub
159
+ Number.prototype.mul = mul
160
+ Number.prototype.div = div
161
+ /**
162
+ * @param {string} [evalStr='']
163
+ * @param {number} [decimal=10]
164
+ * @param {number} proceDecimal
165
+ * @return {number}
166
+ */
167
+ Number.eval = evaluate
168
+ }