n20-common-lib 1.1.10
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/README.md +24 -0
- package/package.json +120 -0
- package/src/assets/css/_coreLib.scss +26 -0
- package/src/assets/css/cl-approve-card.scss +66 -0
- package/src/assets/css/cl-drag-list.scss +22 -0
- package/src/assets/css/cl-empty.scss +10 -0
- package/src/assets/css/cl-expandable.scss +31 -0
- package/src/assets/css/cl-file-upload-table.scss +11 -0
- package/src/assets/css/cl-filter.scss +20 -0
- package/src/assets/css/cl-foldedpanel.scss +35 -0
- package/src/assets/css/cl-footer-box.scss +8 -0
- package/src/assets/css/cl-form-item.scss +281 -0
- package/src/assets/css/cl-more-tab.scss +98 -0
- package/src/assets/css/cl-nav-menu.scss +5 -0
- package/src/assets/css/cl-pagination.scss +71 -0
- package/src/assets/css/cl-secondary-tab.scss +30 -0
- package/src/assets/css/cl-sifting.scss +51 -0
- package/src/assets/css/cl-statis.scss +14 -0
- package/src/assets/css/cl-step.scss +164 -0
- package/src/assets/css/cl-suspend.scss +25 -0
- package/src/assets/css/cl-tertiary-tab.scss +37 -0
- package/src/assets/css/cl-upload.scss +41 -0
- package/src/assets/css/cl-worn-pagination.scss +50 -0
- package/src/assets/css/element-variables.scss +1053 -0
- package/src/assets/css/element.dev.scss +5 -0
- package/src/assets/css/font-icon.scss +22 -0
- package/src/assets/css/index.dev.scss +3 -0
- package/src/assets/css/index.scss +8 -0
- package/src/assets/css/normalize.scss +243 -0
- package/src/assets/css/rootvar.scss +66 -0
- package/src/assets/css/title-pop.scss +4 -0
- package/src/assets/getJsonc.js +51 -0
- package/src/assets/postMessage.js +2 -0
- package/src/assets/postMessageC.js +37 -0
- package/src/components/ApproveCard/index.vue +83 -0
- package/src/components/DatePicker/index.vue +22 -0
- package/src/components/Dialog/index.vue +115 -0
- package/src/components/DragList/index.vue +64 -0
- package/src/components/Empty/img/404.png +0 -0
- package/src/components/Empty/img/abnormal.svg +109 -0
- package/src/components/Empty/img/dispose.svg +72 -0
- package/src/components/Empty/img/empty.svg +58 -0
- package/src/components/Empty/img/general.svg +59 -0
- package/src/components/Empty/img/lock.svg +58 -0
- package/src/components/Empty/img/network.svg +60 -0
- package/src/components/Empty/img/relevant.svg +69 -0
- package/src/components/Empty/img/search.svg +73 -0
- package/src/components/Empty/index.vue +92 -0
- package/src/components/Expandable/index.vue +47 -0
- package/src/components/FileUploadTable/index.vue +456 -0
- package/src/components/Filters/index.vue +77 -0
- package/src/components/FoldedPanel/index.vue +64 -0
- package/src/components/FooterBox/index.vue +18 -0
- package/src/components/InputNumber/index.vue +126 -0
- package/src/components/MoreTab/index.vue +232 -0
- package/src/components/NavMenu/index.vue +90 -0
- package/src/components/Pagination/index.vue +126 -0
- package/src/components/SecondaryTab/index.vue +75 -0
- package/src/components/Select/index.vue +51 -0
- package/src/components/Sifting/index.vue +97 -0
- package/src/components/Statis/index.vue +55 -0
- package/src/components/Step/index.vue +65 -0
- package/src/components/Suspend/index.vue +63 -0
- package/src/components/Suspend/suspensionBtn.png +0 -0
- package/src/components/TertiaryTab/index.vue +49 -0
- package/src/components/TimePicker/index.vue +22 -0
- package/src/components/Upload/index.vue +237 -0
- package/src/components/WornPagination/index.vue +202 -0
- package/src/directives/VMove/index.js +42 -0
- package/src/directives/VTitle/index.js +55 -0
- package/src/directives/VTitle/tooltip.vue +21 -0
- package/src/directives/vDrag/index.js +72 -0
- package/src/index.js +111 -0
- package/src/utils/auth.js +41 -0
- package/src/utils/axios.js +180 -0
- package/src/utils/print.js +156 -0
- package/src/utils/pushLink.js +5 -0
- package/style/css/normalize.scss +243 -0
- package/style/fonts/element-icons.535877f5.woff +0 -0
- package/style/fonts/element-icons.732389de.ttf +0 -0
- package/style/index.css +3 -0
- package/style/index.css.map +1 -0
- package/style/index.umd.min.js +2 -0
- package/style/index.umd.min.js.map +1 -0
- package/style/server-config.jsonc +212 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<cl-dialog
|
|
3
|
+
class="p-t-0 p-b-0"
|
|
4
|
+
:title="title"
|
|
5
|
+
:width="50"
|
|
6
|
+
:dialog-visible="dialogVisible"
|
|
7
|
+
:before-close="beforeClose"
|
|
8
|
+
>
|
|
9
|
+
<div class="cl-sifting-box">
|
|
10
|
+
<div class="cl-sifting-left">
|
|
11
|
+
<!--top-->
|
|
12
|
+
<div class="cl-sifting-left-top">
|
|
13
|
+
<div class="cl-sifting-left-top-left">
|
|
14
|
+
<span class="cl-sifting-left-top-title">{{ title }}</span>
|
|
15
|
+
<span class="cl-sifting-opt-text">已选 </span>
|
|
16
|
+
<span class="cl-sifting-opt">4</span>
|
|
17
|
+
</div>
|
|
18
|
+
<span class="cl-sifting-opt cl-sifting-cursor" @click="handleCheckAll"
|
|
19
|
+
>全部选中</span
|
|
20
|
+
>
|
|
21
|
+
</div>
|
|
22
|
+
<!--end-->
|
|
23
|
+
<!--content-->
|
|
24
|
+
<div v-for="item in list" :key="item.title">
|
|
25
|
+
<span class="cl-sifting-group-title">{{ item.title }}</span>
|
|
26
|
+
<el-checkbox-group
|
|
27
|
+
v-model="checkedCities"
|
|
28
|
+
@change="handleCheckedCitiesChange"
|
|
29
|
+
>
|
|
30
|
+
<el-checkbox
|
|
31
|
+
v-for="(city, index) in item.children"
|
|
32
|
+
:key="index"
|
|
33
|
+
class="el-checkbox-class"
|
|
34
|
+
:label="city.name"
|
|
35
|
+
>{{ city.name }}</el-checkbox
|
|
36
|
+
>
|
|
37
|
+
</el-checkbox-group>
|
|
38
|
+
</div>
|
|
39
|
+
<!--end-->
|
|
40
|
+
</div>
|
|
41
|
+
<div class="cl-sifting-right">
|
|
42
|
+
<cl-drag-list :list="checkedCities" />
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
<div slot="footerBtn" class="cl-sifting-footer">
|
|
46
|
+
<el-button @click="beforeClose">取消</el-button>
|
|
47
|
+
<el-button type="primary" @click="handlAffirm">确认</el-button>
|
|
48
|
+
</div>
|
|
49
|
+
</cl-dialog>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<script>
|
|
53
|
+
export default {
|
|
54
|
+
name: 'Sifting',
|
|
55
|
+
props: {
|
|
56
|
+
title: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: ''
|
|
59
|
+
},
|
|
60
|
+
dialogVisible: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: false
|
|
63
|
+
},
|
|
64
|
+
beforeClose: {
|
|
65
|
+
type: Function,
|
|
66
|
+
default: () => {}
|
|
67
|
+
},
|
|
68
|
+
list: {
|
|
69
|
+
type: Array,
|
|
70
|
+
default: () => []
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
data() {
|
|
74
|
+
return {
|
|
75
|
+
checkedCities: []
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
methods: {
|
|
79
|
+
handleCheckAll() {
|
|
80
|
+
this.checkedCities = this.list
|
|
81
|
+
.map((c) => c.children)
|
|
82
|
+
.flat()
|
|
83
|
+
.map((r) => r.name)
|
|
84
|
+
console.log(this.checkedCities)
|
|
85
|
+
},
|
|
86
|
+
handlAffirm() {
|
|
87
|
+
this.$emit('Affirm', this.checkedCities)
|
|
88
|
+
},
|
|
89
|
+
handleCheckedCitiesChange(val) {
|
|
90
|
+
console.log(val)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
<style scoped>
|
|
97
|
+
</style>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* author: zhengwei
|
|
3
|
+
* time: 2021-9-1
|
|
4
|
+
*/
|
|
5
|
+
<template>
|
|
6
|
+
<div class="cl-statis">
|
|
7
|
+
<div class="cl-statis-left">
|
|
8
|
+
当页合计 <span class="cl-statis-division">|</span> 笔数:<span
|
|
9
|
+
class="primary"
|
|
10
|
+
>{{ pageSum }}</span
|
|
11
|
+
>
|
|
12
|
+
金额:<span class="primary">{{ pageAmount | numerify('0,0.00') }}元</span>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="footer-item">
|
|
15
|
+
全部合计 <span class="cl-statis-division">|</span> 笔数:<span
|
|
16
|
+
class="primary"
|
|
17
|
+
>{{ totalSun }}</span
|
|
18
|
+
>
|
|
19
|
+
金额:<span class="primary"
|
|
20
|
+
>{{ totalAmount | numerify('0,0.00') }}元</span
|
|
21
|
+
>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script>
|
|
27
|
+
import numerify from 'numerify'
|
|
28
|
+
export default {
|
|
29
|
+
name: 'Statis',
|
|
30
|
+
|
|
31
|
+
filters: {
|
|
32
|
+
numerify(v, f) {
|
|
33
|
+
return numerify(v, f)
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
props: {
|
|
37
|
+
pageSum: {
|
|
38
|
+
type: Number,
|
|
39
|
+
default: 0
|
|
40
|
+
},
|
|
41
|
+
pageAmount: {
|
|
42
|
+
type: Number,
|
|
43
|
+
default: 0
|
|
44
|
+
},
|
|
45
|
+
totalSun: {
|
|
46
|
+
type: Number,
|
|
47
|
+
default: 0
|
|
48
|
+
},
|
|
49
|
+
totalAmount: {
|
|
50
|
+
type: Number,
|
|
51
|
+
default: 0
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* author: zhengwei
|
|
3
|
+
* time: 2021-8-30
|
|
4
|
+
*/
|
|
5
|
+
<template>
|
|
6
|
+
<div class="cl-step">
|
|
7
|
+
<div :class="direction === 'horizontal' ? 'step-box' : 'cl-step-vertical'">
|
|
8
|
+
<div v-for="(item, index) of dataSource" :key="index" class="item">
|
|
9
|
+
<div
|
|
10
|
+
:class="action === index + 1 ? 'step-item-checked' : 'step-item-top'"
|
|
11
|
+
>
|
|
12
|
+
<span class="step-num" @click="handler(index, item)">{{
|
|
13
|
+
index + 1
|
|
14
|
+
}}</span>
|
|
15
|
+
<div
|
|
16
|
+
v-if="index !== dataSource.length - 1"
|
|
17
|
+
class="line"
|
|
18
|
+
:class="action === index + 1 ? 'cur' : ''"
|
|
19
|
+
></div>
|
|
20
|
+
</div>
|
|
21
|
+
<div class="name" :class="action === index + 1 ? 'cur1' : ''">
|
|
22
|
+
{{ item.name }}
|
|
23
|
+
</div>
|
|
24
|
+
<div v-if="item.time" class="time">{{ item.time }}</div>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
<slot></slot>
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script>
|
|
32
|
+
export default {
|
|
33
|
+
name: 'Step',
|
|
34
|
+
props: {
|
|
35
|
+
direction: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: 'horizontal'
|
|
38
|
+
},
|
|
39
|
+
active: {
|
|
40
|
+
type: Number,
|
|
41
|
+
default: 1
|
|
42
|
+
},
|
|
43
|
+
dataSource: {
|
|
44
|
+
type: Array,
|
|
45
|
+
default: () => []
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
data() {
|
|
49
|
+
return {
|
|
50
|
+
action: 1
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
computed: {},
|
|
54
|
+
watch: {},
|
|
55
|
+
mounted() {
|
|
56
|
+
this.action = this.active
|
|
57
|
+
},
|
|
58
|
+
methods: {
|
|
59
|
+
handler(i, val) {
|
|
60
|
+
this.action = i + 1
|
|
61
|
+
this.$emit('click', i, val)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
</script>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* author: zhengwei
|
|
3
|
+
* time: 2021-8-30
|
|
4
|
+
*/
|
|
5
|
+
<template>
|
|
6
|
+
<div
|
|
7
|
+
v-title="text"
|
|
8
|
+
v-move="moveFn"
|
|
9
|
+
class="cl-suspend"
|
|
10
|
+
:style="{ top: topAs }"
|
|
11
|
+
@click="(ev) => $emit('click', ev)"
|
|
12
|
+
>
|
|
13
|
+
<img src="./suspensionBtn.png" />
|
|
14
|
+
<span class="cl-suspend-text">
|
|
15
|
+
<slot></slot>
|
|
16
|
+
</span>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
<script>
|
|
20
|
+
export default {
|
|
21
|
+
name: 'Suspend',
|
|
22
|
+
props: {
|
|
23
|
+
text: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: ''
|
|
26
|
+
},
|
|
27
|
+
top: {
|
|
28
|
+
type: Number,
|
|
29
|
+
default: 15
|
|
30
|
+
},
|
|
31
|
+
icon: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: undefined
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
data() {
|
|
37
|
+
return {
|
|
38
|
+
winH: 1080,
|
|
39
|
+
moveY: 0
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
computed: {
|
|
43
|
+
topAs() {
|
|
44
|
+
return this.top * this.winH * 0.01 + this.moveY + 'px'
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
mounted() {
|
|
48
|
+
this.resizeFn()
|
|
49
|
+
window.addEventListener('resize', this.resizeFn)
|
|
50
|
+
},
|
|
51
|
+
beforeDestroy() {
|
|
52
|
+
window.removeEventListener('resize', this.resizeFn)
|
|
53
|
+
},
|
|
54
|
+
methods: {
|
|
55
|
+
resizeFn() {
|
|
56
|
+
this.winH = document.documentElement.clientHeight
|
|
57
|
+
},
|
|
58
|
+
moveFn(ev) {
|
|
59
|
+
this.moveY = this.moveY + ev.pageYc
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
</script>
|
|
Binary file
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* author: zhengwei
|
|
3
|
+
* time: 2021-9-1
|
|
4
|
+
*/
|
|
5
|
+
<template>
|
|
6
|
+
<ul class="cl-tertiary-tab">
|
|
7
|
+
<li
|
|
8
|
+
v-for="item in data"
|
|
9
|
+
:key="item.id"
|
|
10
|
+
class="cl-tertiary-tab-item"
|
|
11
|
+
:class="{ action: current === item.name }"
|
|
12
|
+
@click="handleClick(item)"
|
|
13
|
+
>
|
|
14
|
+
<div>{{ item.name }}</div>
|
|
15
|
+
</li>
|
|
16
|
+
</ul>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script>
|
|
20
|
+
export default {
|
|
21
|
+
name: 'TertiaryTab',
|
|
22
|
+
props: {
|
|
23
|
+
data: {
|
|
24
|
+
type: Array,
|
|
25
|
+
default: () => []
|
|
26
|
+
},
|
|
27
|
+
init: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: ''
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
data() {
|
|
33
|
+
return {
|
|
34
|
+
current: ''
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
mounted() {
|
|
38
|
+
if (this.init) {
|
|
39
|
+
this.current = this.init
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
methods: {
|
|
43
|
+
handleClick(item) {
|
|
44
|
+
this.current = item.name
|
|
45
|
+
this.$emit('click', item)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
</script>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-time-picker
|
|
3
|
+
ref="time-picker"
|
|
4
|
+
:class="{ 'has-value': value }"
|
|
5
|
+
v-bind="$attrs"
|
|
6
|
+
:value="value"
|
|
7
|
+
v-on="$listeners"
|
|
8
|
+
/>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script>
|
|
12
|
+
/* 与原生elmUI区别就是加了一个has-value */
|
|
13
|
+
export default {
|
|
14
|
+
name: 'TimePicker',
|
|
15
|
+
props: {
|
|
16
|
+
// eslint-disable-next-line vue/require-prop-types
|
|
17
|
+
value: {
|
|
18
|
+
default: undefined
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-upload
|
|
3
|
+
ref="upload"
|
|
4
|
+
:action="action"
|
|
5
|
+
:headers="headers"
|
|
6
|
+
:accept="accept"
|
|
7
|
+
:multiple="false"
|
|
8
|
+
:file-list="fileList"
|
|
9
|
+
:show-file-list="false"
|
|
10
|
+
v-bind="$attrs"
|
|
11
|
+
:on-success="successFn"
|
|
12
|
+
:on-error="errorFn"
|
|
13
|
+
:on-progress="progressFn"
|
|
14
|
+
:before-upload="beforeUploadFn"
|
|
15
|
+
v-on="$listeners"
|
|
16
|
+
>
|
|
17
|
+
<template slot="trigger">
|
|
18
|
+
<slot name="trigger">
|
|
19
|
+
<el-input :value="fileNameC" :placeholder="placeholder" readonly>
|
|
20
|
+
<template slot="suffix">
|
|
21
|
+
<i
|
|
22
|
+
v-if="fileNameC && showClear"
|
|
23
|
+
class="el-input__icon upload-clear el-icon-close"
|
|
24
|
+
style="pointer-events: all"
|
|
25
|
+
@click.stop="clearFile"
|
|
26
|
+
></i>
|
|
27
|
+
<i v-else class="el-input__icon cl-icon-shangchuan"></i>
|
|
28
|
+
</template>
|
|
29
|
+
</el-input>
|
|
30
|
+
</slot>
|
|
31
|
+
</template>
|
|
32
|
+
<template slot="tip">
|
|
33
|
+
<slot name="tip"></slot>
|
|
34
|
+
</template>
|
|
35
|
+
<el-dialog :visible.sync="progressV" title="提示">
|
|
36
|
+
<p v-if="!percentType">系统处理中,请稍等......</p>
|
|
37
|
+
<p v-else>{{ percentMsg }}</p>
|
|
38
|
+
<el-progress class="m-b" :percentage="percent" :status="percentType" />
|
|
39
|
+
</el-dialog>
|
|
40
|
+
</el-upload>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<script>
|
|
44
|
+
export default {
|
|
45
|
+
name: 'Upload',
|
|
46
|
+
props: {
|
|
47
|
+
fileName: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: ''
|
|
50
|
+
},
|
|
51
|
+
fileUrl: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: ''
|
|
54
|
+
},
|
|
55
|
+
placeholder: {
|
|
56
|
+
type: String,
|
|
57
|
+
default: '请选择文件'
|
|
58
|
+
},
|
|
59
|
+
msgType: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: 'dialog'
|
|
62
|
+
},
|
|
63
|
+
action: {
|
|
64
|
+
type: String,
|
|
65
|
+
default: '/bems/1.0/attach'
|
|
66
|
+
},
|
|
67
|
+
headers: {
|
|
68
|
+
type: Object,
|
|
69
|
+
default: () => ({
|
|
70
|
+
token: window.sessionStorage.getItem('token') || 'main-token'
|
|
71
|
+
})
|
|
72
|
+
},
|
|
73
|
+
size: {
|
|
74
|
+
type: [String, Number],
|
|
75
|
+
default: undefined
|
|
76
|
+
},
|
|
77
|
+
accept: {
|
|
78
|
+
type: String,
|
|
79
|
+
default: undefined
|
|
80
|
+
},
|
|
81
|
+
onRemove: {
|
|
82
|
+
type: Function,
|
|
83
|
+
default: undefined
|
|
84
|
+
},
|
|
85
|
+
onProgress: {
|
|
86
|
+
type: Function,
|
|
87
|
+
default: undefined
|
|
88
|
+
},
|
|
89
|
+
onSuccess: {
|
|
90
|
+
type: Function,
|
|
91
|
+
default: undefined
|
|
92
|
+
},
|
|
93
|
+
onError: {
|
|
94
|
+
type: Function,
|
|
95
|
+
default: undefined
|
|
96
|
+
},
|
|
97
|
+
beforeUpload: {
|
|
98
|
+
type: Function,
|
|
99
|
+
default: undefined
|
|
100
|
+
},
|
|
101
|
+
showClear: {
|
|
102
|
+
type: Boolean,
|
|
103
|
+
default: true
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
data() {
|
|
107
|
+
return {
|
|
108
|
+
fileList: [],
|
|
109
|
+
percent: 0,
|
|
110
|
+
percentMsg: '',
|
|
111
|
+
progressV: false,
|
|
112
|
+
percentType: undefined
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
computed: {
|
|
116
|
+
fileNameC: {
|
|
117
|
+
get() {
|
|
118
|
+
return this.fileName
|
|
119
|
+
},
|
|
120
|
+
set(v) {
|
|
121
|
+
this.$emit('update:fileName', v)
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
fileUrlC: {
|
|
125
|
+
get() {
|
|
126
|
+
return this.fileUrl
|
|
127
|
+
},
|
|
128
|
+
set(v) {
|
|
129
|
+
this.$emit('update:fileUrl', v)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
methods: {
|
|
134
|
+
clearFile() {
|
|
135
|
+
if (this.onRemove) {
|
|
136
|
+
this.onRemove(this.fileList[0], this.fileList)
|
|
137
|
+
} else {
|
|
138
|
+
this.fileNameC = ''
|
|
139
|
+
this.fileUrlC = ''
|
|
140
|
+
this.fileList.pop()
|
|
141
|
+
console.log('删除上传')
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
beforeUploadFn(file) {
|
|
145
|
+
let size = this.size
|
|
146
|
+
let sizeNum
|
|
147
|
+
|
|
148
|
+
if (size) {
|
|
149
|
+
if (/kb/i.test(size)) {
|
|
150
|
+
sizeNum = parseFloat(size) * 1024
|
|
151
|
+
} else if (/mb/i.test(size)) {
|
|
152
|
+
sizeNum = parseFloat(size) * 1024 * 1024
|
|
153
|
+
} else {
|
|
154
|
+
sizeNum = parseFloat(size)
|
|
155
|
+
}
|
|
156
|
+
if (file.size > sizeNum) {
|
|
157
|
+
this.$message.error('文件大小不能超过 ' + size + ' !')
|
|
158
|
+
return false
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let accept = this.accept
|
|
163
|
+
if (accept) {
|
|
164
|
+
let [ftB = '', ftA = ''] = file.type.split('/')
|
|
165
|
+
ftB = ftB + '/*'
|
|
166
|
+
ftA = file.name.match(/\.[^.]+$/)?.[0] || '.' + ftA
|
|
167
|
+
if (!(accept.includes(ftB) || accept.includes(ftA))) {
|
|
168
|
+
this.$message.error('文件格式错误 !')
|
|
169
|
+
return false
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (this.msgType === 'dialog') {
|
|
174
|
+
this.percent = 0
|
|
175
|
+
this.percentType = undefined
|
|
176
|
+
this.progressV = true
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (this.beforeUpload) {
|
|
180
|
+
return this.beforeUpload(file)
|
|
181
|
+
} else {
|
|
182
|
+
return
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
progressFn(event, file, fileList) {
|
|
186
|
+
if (this.onProgress) {
|
|
187
|
+
this.onProgress(event, file, fileList)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (this.msgType === 'dialog') {
|
|
191
|
+
this.percent = event.percent <= 99 ? Math.round(event.percent) : 99
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
successFn(response, file, fileList) {
|
|
195
|
+
if (this.onSuccess) {
|
|
196
|
+
this.onSuccess(response, file, fileList)
|
|
197
|
+
} else {
|
|
198
|
+
this.fileNameC = file.name
|
|
199
|
+
this.fileUrlC = response.data
|
|
200
|
+
this.fileList = [file]
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (this.msgType === 'dialog') {
|
|
204
|
+
this.percent = 100
|
|
205
|
+
this.percentType = 'success'
|
|
206
|
+
this.percentMsg = response.msg || '上传成功!'
|
|
207
|
+
} else if (this.msgType === 'message') {
|
|
208
|
+
if (!this.onSuccess) {
|
|
209
|
+
this.$message({
|
|
210
|
+
type: 'success',
|
|
211
|
+
message: response.msg,
|
|
212
|
+
showClose: true
|
|
213
|
+
})
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
errorFn(err, file, fileList) {
|
|
218
|
+
if (this.onError) {
|
|
219
|
+
this.onError(err, file, fileList)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (this.msgType === 'dialog') {
|
|
223
|
+
this.percentType = 'exception'
|
|
224
|
+
this.percentMsg = err?.msg || '上传失败!'
|
|
225
|
+
} else if (this.msgType === 'message') {
|
|
226
|
+
if (!this.onError) {
|
|
227
|
+
this.$message({
|
|
228
|
+
type: 'error',
|
|
229
|
+
message: err?.msg || '上传失败',
|
|
230
|
+
showClose: true
|
|
231
|
+
})
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
</script>
|