n20-common-lib 1.3.32 → 1.3.33
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 +1 -1
- package/src/components/EventBubble/demo/a.vue +29 -0
- package/src/components/EventBubble/demo/b.vue +12 -0
- package/src/components/EventBubble/demo/c.vue +18 -0
- package/src/components/EventBubble/index.vue +9 -4
- package/src/components/InputNumber/index.vue +1 -1
- package/src/components/Layout/HeaderWrap/index.vue +27 -10
- package/src/components/PageHeader/style.scss +8 -2
- package/src/index.js +9 -4
- package/src/utils/auth.js +1 -0
- package/src/utils/i18n/index.js +1 -1
- package/src/utils/toExcel.js +23 -0
package/package.json
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div ref="ad">
|
|
4
|
+
<el-card class="box-card" :header="header">
|
|
5
|
+
<cB />
|
|
6
|
+
<p>这里的传值,是只依赖DOM结构,利用自定义事件/事件冒泡实现值得传递</p>
|
|
7
|
+
</el-card>
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script>
|
|
13
|
+
import cB from './b.vue'
|
|
14
|
+
export default {
|
|
15
|
+
components: { cB },
|
|
16
|
+
data() {
|
|
17
|
+
return {
|
|
18
|
+
header: ''
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
mounted() {
|
|
22
|
+
this.$refs['ad'].addEventListener('demoEv', (event) => {
|
|
23
|
+
event.stopPropagation()
|
|
24
|
+
const cD = event.target.customData
|
|
25
|
+
this.header = cD.title
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
</script>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="flex-box flex-v">
|
|
3
|
+
<label>标题</label><el-input class="flex-item m-l" v-model="title" />
|
|
4
|
+
<EventBubble :data-custom="{ title: title }" data-event="demoEv" />
|
|
5
|
+
</div>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
import EventBubble from '../index.vue'
|
|
10
|
+
export default {
|
|
11
|
+
components: { EventBubble },
|
|
12
|
+
data() {
|
|
13
|
+
return {
|
|
14
|
+
title: '默认标题'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
<script>
|
|
6
6
|
// 触发自定义冒泡事假
|
|
7
|
-
// XXX:还差iframe的处理
|
|
8
7
|
export default {
|
|
8
|
+
name: 'EventBubble',
|
|
9
9
|
props: {
|
|
10
10
|
dataCustom: {
|
|
11
11
|
type: Object,
|
|
@@ -25,7 +25,9 @@ export default {
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
mounted() {
|
|
28
|
-
this
|
|
28
|
+
this.$nextTick(() => {
|
|
29
|
+
this.setData(this.dataCustom)
|
|
30
|
+
})
|
|
29
31
|
},
|
|
30
32
|
methods: {
|
|
31
33
|
setData(obj) {
|
|
@@ -42,11 +44,14 @@ function dispatchEvent(el, type) {
|
|
|
42
44
|
var evEvent = undefined
|
|
43
45
|
|
|
44
46
|
if (!window[evName]) {
|
|
45
|
-
evEvent =
|
|
46
|
-
evEvent.initEvent(type, true, false)
|
|
47
|
+
evEvent = new CustomEvent(type, { bubbles: true, cancelable: false })
|
|
47
48
|
window[evName] = evEvent
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
el.dispatchEvent(window[evName])
|
|
52
|
+
// iframe is not target
|
|
53
|
+
// if (el.nodeName !== 'IFRAME' && window.frameElement) {
|
|
54
|
+
// dispatchEvent(window.frameElement, type)
|
|
55
|
+
// }
|
|
51
56
|
}
|
|
52
57
|
</script>
|
|
@@ -179,6 +179,7 @@
|
|
|
179
179
|
</template>
|
|
180
180
|
|
|
181
181
|
<script>
|
|
182
|
+
import Cookies from 'js-cookie'
|
|
182
183
|
import { themeList } from '../../../utils/theme.config.js'
|
|
183
184
|
|
|
184
185
|
import dialogWrap from '../../Dialog/index.vue'
|
|
@@ -229,7 +230,7 @@ const i18n = {
|
|
|
229
230
|
en: ':'
|
|
230
231
|
},
|
|
231
232
|
秒: {
|
|
232
|
-
en: '
|
|
233
|
+
en: ''
|
|
233
234
|
},
|
|
234
235
|
'确定退出,将清除未提交的临时操作,是否继续?': {
|
|
235
236
|
en: 'Are you sure to exit? Uncommitted temporary operations will be cleared. Do you want to continue?'
|
|
@@ -299,23 +300,35 @@ export default {
|
|
|
299
300
|
},
|
|
300
301
|
setUserVisible(v) {
|
|
301
302
|
if (v) {
|
|
302
|
-
let loginTime = sessionStorage.getItem('loginTime')
|
|
303
|
-
if (loginTime) {
|
|
304
|
-
this.durationTime = dayjs.duration(Date.now() - loginTime).format(
|
|
305
|
-
`HH${this.$l('小时', this.i18n)}
|
|
306
|
-
mm${this.$l('分', this.i18n)}
|
|
307
|
-
ss${this.$l('秒', this.i18n)}`
|
|
308
|
-
)
|
|
309
|
-
}
|
|
310
|
-
|
|
311
303
|
let userInfo = JSON.parse(sessionStorage.getItem('userInfo') || '{}')
|
|
312
304
|
this.userInfo = {
|
|
313
305
|
userName: userInfo.uname,
|
|
314
306
|
companyName: userInfo.cltName
|
|
315
307
|
}
|
|
316
308
|
this.rolesList = userInfo.roles || []
|
|
309
|
+
|
|
310
|
+
let loginTime = sessionStorage.getItem('loginTime')
|
|
311
|
+
if (loginTime) {
|
|
312
|
+
this.setDurationTime(loginTime)
|
|
313
|
+
this.durationTime_timeout = setInterval(
|
|
314
|
+
() => this.setDurationTime(loginTime),
|
|
315
|
+
500
|
|
316
|
+
)
|
|
317
|
+
}
|
|
318
|
+
} else {
|
|
319
|
+
clearInterval(this.durationTime_timeout)
|
|
317
320
|
}
|
|
318
321
|
},
|
|
322
|
+
setDurationTime(loginTime) {
|
|
323
|
+
this.durationTime = dayjs
|
|
324
|
+
.duration(Date.now() - loginTime)
|
|
325
|
+
.format(
|
|
326
|
+
`HH${this.$l('小时', this.i18n)}mm${this.$l(
|
|
327
|
+
'分',
|
|
328
|
+
this.i18n
|
|
329
|
+
)}ss${this.$l('秒', this.i18n)}`
|
|
330
|
+
)
|
|
331
|
+
},
|
|
319
332
|
// 打开帮助文档
|
|
320
333
|
openHelp() {
|
|
321
334
|
axios
|
|
@@ -357,6 +370,10 @@ export default {
|
|
|
357
370
|
setLang() {
|
|
358
371
|
this.langV = false
|
|
359
372
|
window.localStorage.setItem('pageLang', this.langVal)
|
|
373
|
+
Cookies.set(
|
|
374
|
+
'language',
|
|
375
|
+
['zh-cn', 'zh-hk'].includes(this.langVal) ? 'zh' : this.langVal
|
|
376
|
+
)
|
|
360
377
|
window.location.reload()
|
|
361
378
|
},
|
|
362
379
|
setTheme({ value }) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
.page-header {
|
|
1
|
+
.n20-page-header {
|
|
2
2
|
display: flex;
|
|
3
3
|
line-height: 20px;
|
|
4
4
|
padding-bottom: 2px;
|
|
5
5
|
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
|
6
|
+
|
|
6
7
|
.page-header__left {
|
|
7
8
|
display: flex;
|
|
8
9
|
align-items: center;
|
|
@@ -10,12 +11,15 @@
|
|
|
10
11
|
margin-right: 16px;
|
|
11
12
|
position: relative;
|
|
12
13
|
}
|
|
14
|
+
|
|
13
15
|
.page-header__left:hover {
|
|
14
16
|
color: var(--color-primary);
|
|
17
|
+
|
|
15
18
|
.page-header__title {
|
|
16
19
|
color: var(--color-primary);
|
|
17
20
|
}
|
|
18
21
|
}
|
|
22
|
+
|
|
19
23
|
.page-header__left:after {
|
|
20
24
|
content: '';
|
|
21
25
|
position: absolute;
|
|
@@ -26,14 +30,16 @@
|
|
|
26
30
|
transform: translateY(-50%);
|
|
27
31
|
background-color: #dcdfe6;
|
|
28
32
|
}
|
|
33
|
+
|
|
29
34
|
.page-header__title {
|
|
30
35
|
font-size: 14px;
|
|
31
36
|
line-height: 20px;
|
|
32
37
|
color: #3d4a57;
|
|
33
38
|
}
|
|
39
|
+
|
|
34
40
|
.page-header__content {
|
|
35
41
|
font-size: 14px;
|
|
36
42
|
line-height: 20px;
|
|
37
43
|
color: #3d4a57;
|
|
38
44
|
}
|
|
39
|
-
}
|
|
45
|
+
}
|
package/src/index.js
CHANGED
|
@@ -48,10 +48,11 @@ import FlowStep from './components/FlowStep/index.vue'
|
|
|
48
48
|
import CascaderArea from './components/CascaderArea/index.vue'
|
|
49
49
|
import FileExportAsync from './components/FileExportAsync/index.vue'
|
|
50
50
|
import FlowDialog from './components/ApprovalRecord/flowDialog.vue'
|
|
51
|
-
import ChildRange from './components/ChildRange/index'
|
|
52
|
-
import FileImport from './components/FileImport/index'
|
|
53
|
-
import PageHeader from './components/PageHeader/index'
|
|
54
|
-
import Descriptions from './components/Descriptions'
|
|
51
|
+
import ChildRange from './components/ChildRange/index.vue'
|
|
52
|
+
import FileImport from './components/FileImport/index.vue'
|
|
53
|
+
import PageHeader from './components/PageHeader/index.vue'
|
|
54
|
+
import Descriptions from './components/Descriptions/index.vue'
|
|
55
|
+
import EventBubble from './components/EventBubble/index.vue'
|
|
55
56
|
// ECharts 不要打包进来
|
|
56
57
|
// import Search from './components/Search/index.vue'
|
|
57
58
|
import Stamp from './components/Stamp/index.vue'
|
|
@@ -142,6 +143,7 @@ const components = [
|
|
|
142
143
|
FileImport,
|
|
143
144
|
PageHeader,
|
|
144
145
|
Descriptions,
|
|
146
|
+
EventBubble,
|
|
145
147
|
// Search,
|
|
146
148
|
approvalImg,
|
|
147
149
|
Stamp,
|
|
@@ -154,6 +156,8 @@ const components = [
|
|
|
154
156
|
const install = function (Vue, opts = { prefix: 'Cl', i18nConfig: {} }) {
|
|
155
157
|
components.forEach((component) => {
|
|
156
158
|
let name = component.name
|
|
159
|
+
if (!name) return console.error('Component name is required:', component)
|
|
160
|
+
|
|
157
161
|
name = opts.prefix + name.replace(name[0], name[0].toUpperCase())
|
|
158
162
|
Vue.component(name, component)
|
|
159
163
|
})
|
|
@@ -251,6 +255,7 @@ export {
|
|
|
251
255
|
FileImport,
|
|
252
256
|
PageHeader,
|
|
253
257
|
Descriptions,
|
|
258
|
+
EventBubble,
|
|
254
259
|
// Search,
|
|
255
260
|
approvalImg,
|
|
256
261
|
Stamp
|
package/src/utils/auth.js
CHANGED
package/src/utils/i18n/index.js
CHANGED
package/src/utils/toExcel.js
CHANGED
|
@@ -90,3 +90,26 @@ function toExcel({ columns = [], rows = [], name = 'sheet01' }) {
|
|
|
90
90
|
})
|
|
91
91
|
}
|
|
92
92
|
export default toExcel
|
|
93
|
+
|
|
94
|
+
export function toJson(file, name) {
|
|
95
|
+
const workbook = new ExcelJS.Workbook()
|
|
96
|
+
return new Promise((resolve, reject) => {
|
|
97
|
+
workbook.xlsx
|
|
98
|
+
.load(file)
|
|
99
|
+
.then(() => {
|
|
100
|
+
const worksheet = workbook.getWorksheet(name || 1)
|
|
101
|
+
let rows = []
|
|
102
|
+
worksheet.eachRow((r) => {
|
|
103
|
+
let row = []
|
|
104
|
+
r.eachCell((c) => {
|
|
105
|
+
row.push(c.value)
|
|
106
|
+
})
|
|
107
|
+
rows.push(row)
|
|
108
|
+
})
|
|
109
|
+
resolve(rows)
|
|
110
|
+
})
|
|
111
|
+
.catch((err) => {
|
|
112
|
+
reject(err)
|
|
113
|
+
})
|
|
114
|
+
})
|
|
115
|
+
}
|