askbot-dragon 0.9.11 → 0.9.13
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 +27 -27
- package/babel.config.js +6 -6
- package/dragon.iml +7 -7
- package/package.json +55 -55
- package/public/index.html +43 -43
- package/src/App.vue +31 -31
- package/src/api/index.js +1 -1
- package/src/api/mock.http +2 -2
- package/src/api/requestUrl.js +185 -185
- package/src/assets/js/AliyunlssUtil.js +92 -92
- package/src/assets/js/Base64Util.js +22 -22
- package/src/assets/js/script.js +36 -36
- package/src/assets/less/common.css +6773 -6773
- package/src/assets/less/converSationContainer/common.less +191 -191
- package/src/assets/less/converSationContainer/converSatonContainer.less +493 -493
- package/src/assets/less/iconfont.css +37 -37
- package/src/assets/less/ticketMessage.less +211 -211
- package/src/components/ActionAlertIframe.vue +112 -112
- package/src/components/AiGuide.vue +467 -467
- package/src/components/AskIFrame.vue +15 -15
- package/src/components/ConversationContainer.vue +3668 -1557
- package/src/components/FileType.vue +86 -86
- package/src/components/Message.vue +27 -27
- package/src/components/actionSatisfaction.vue +107 -107
- package/src/components/actionSendToBot.vue +62 -62
- package/src/components/answerDissatisfaction.vue +62 -62
- package/src/components/answerRadio.vue +76 -76
- package/src/components/ask-components/DissatisfactionOptions.vue +57 -57
- package/src/components/ask-components/Msgloading.vue +37 -37
- package/src/components/ask-components/SatisfactionV2.vue +15 -15
- package/src/components/askVideo.vue +138 -138
- package/src/components/assetDetails.vue +370 -370
- package/src/components/assetMessage.vue +228 -228
- package/src/components/associationIntention.vue +229 -229
- package/src/components/botActionSatisfactor.vue +68 -68
- package/src/components/chatContent.vue +513 -513
- package/src/components/feedBack.vue +136 -136
- package/src/components/file/AliyunOssComponents.vue +108 -108
- package/src/components/formTemplate.vue +3101 -2888
- package/src/components/loadingProcess.vue +164 -164
- package/src/components/message/ActionAlertIframe.vue +112 -112
- package/src/components/message/ShopMessage.vue +164 -164
- package/src/components/message/TextMessage.vue +924 -924
- package/src/components/message/TicketMessage.vue +177 -177
- package/src/components/message/swiper/index.js +4 -4
- package/src/components/message/swiper/ticketSwiper.vue +502 -502
- package/src/components/message/swiper/ticketSwiperItem.vue +61 -61
- package/src/components/msgLoading.vue +231 -231
- package/src/components/myPopup.vue +70 -70
- package/src/components/popup.vue +227 -227
- package/src/components/recommend.vue +89 -89
- package/src/components/selector/hOption.vue +20 -20
- package/src/components/selector/hSelector.vue +199 -199
- package/src/components/selector/hWrapper.vue +216 -216
- package/src/components/senderMessagePlatform.vue +50 -0
- package/src/components/source/BotMessage.vue +24 -24
- package/src/components/source/CustomMessage.vue +24 -24
- package/src/components/test.vue +260 -260
- package/src/components/tree.vue +247 -185
- package/src/components/utils/AliyunIssUtil.js +72 -72
- package/src/components/utils/ckeditor.js +123 -123
- package/src/components/utils/command.js +87 -87
- package/src/components/utils/editing.js +11 -11
- package/src/components/utils/format_date.js +25 -25
- package/src/components/utils/index.js +6 -6
- package/src/components/utils/math_utils.js +29 -15
- package/src/components/utils/plugin-image.js +11 -11
- package/src/components/utils/toolbar-ui.js +41 -41
- package/src/components/voiceComponent.vue +119 -119
- package/src/main.js +45 -45
- package/vue.config.js +47 -47
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="text-recommed-intent">
|
|
3
|
-
<p class="intent-des" v-if="msg.recommend&&msg.recommend.description" v-html="msg.recommend.description"></p>
|
|
4
|
-
<div class="bottom-link" v-if="msg.recommend&&msg.recommend.description"></div>
|
|
5
|
-
<div v-if="msg.recommend&&msg.recommend.list" class="options-list">
|
|
6
|
-
<p
|
|
7
|
-
v-for="(option, index) in msg.recommend.list"
|
|
8
|
-
class="options-item"
|
|
9
|
-
:class="index!==msg.recommend.list.length -1?'recommend-item':'last-item'"
|
|
10
|
-
:key="msg.nodeId + '_' + index"
|
|
11
|
-
@click="
|
|
12
|
-
$emit(
|
|
13
|
-
'onRadioClickReco',
|
|
14
|
-
'recdNodeId' +
|
|
15
|
-
'_' +
|
|
16
|
-
index +
|
|
17
|
-
'_' +
|
|
18
|
-
option.id +
|
|
19
|
-
'_' +
|
|
20
|
-
option.text,
|
|
21
|
-
option.text,
|
|
22
|
-
msg.apiKey
|
|
23
|
-
)
|
|
24
|
-
"
|
|
25
|
-
>
|
|
26
|
-
{{ option.text
|
|
27
|
-
}}<i class="arsenal_icon arsenalangle-right-solid"></i>
|
|
28
|
-
</p>
|
|
29
|
-
</div>
|
|
30
|
-
</div>
|
|
31
|
-
|
|
32
|
-
</template>
|
|
33
|
-
|
|
34
|
-
<script>
|
|
35
|
-
|
|
36
|
-
export default {
|
|
37
|
-
name: "recommend",
|
|
38
|
-
props: ["msg"]
|
|
39
|
-
}
|
|
40
|
-
</script>
|
|
41
|
-
|
|
42
|
-
<style scoped lang="less">
|
|
43
|
-
.text-recommed-intent{
|
|
44
|
-
/* max-width: 300px;*/
|
|
45
|
-
background-color: white;
|
|
46
|
-
.intent-des{
|
|
47
|
-
word-wrap: break-word;
|
|
48
|
-
word-break: break-all;
|
|
49
|
-
overflow: hidden;
|
|
50
|
-
padding: 8px 0;
|
|
51
|
-
height: auto;
|
|
52
|
-
/*border-bottom: 1px solid #EEEEEE;*/
|
|
53
|
-
color: #A9B3C6;
|
|
54
|
-
font-size: 13px;
|
|
55
|
-
background-color: white;
|
|
56
|
-
}
|
|
57
|
-
.bottom-link{
|
|
58
|
-
height: 1px;
|
|
59
|
-
background-color:#EEEEEE;
|
|
60
|
-
}
|
|
61
|
-
.options-list{
|
|
62
|
-
padding-top: 4px;
|
|
63
|
-
min-width: 120px;
|
|
64
|
-
.options-item{
|
|
65
|
-
|
|
66
|
-
height: 25px;
|
|
67
|
-
line-height: 25px;
|
|
68
|
-
background-color: #ffffff;
|
|
69
|
-
color: #366aff;
|
|
70
|
-
cursor:pointer;
|
|
71
|
-
display: flex;
|
|
72
|
-
align-items: center;
|
|
73
|
-
justify-content: space-between;
|
|
74
|
-
i{
|
|
75
|
-
padding-left: 10px;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
.recommend-item{
|
|
79
|
-
padding: 8px 0;
|
|
80
|
-
}
|
|
81
|
-
.last-item{
|
|
82
|
-
padding-top: 8px;
|
|
83
|
-
}
|
|
84
|
-
.end{
|
|
85
|
-
border-bottom-left-radius: 25px !important;
|
|
86
|
-
border-bottom-right-radius: 25px !important;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<div class="text-recommed-intent">
|
|
3
|
+
<p class="intent-des" v-if="msg.recommend&&msg.recommend.description" v-html="msg.recommend.description"></p>
|
|
4
|
+
<div class="bottom-link" v-if="msg.recommend&&msg.recommend.description"></div>
|
|
5
|
+
<div v-if="msg.recommend&&msg.recommend.list" class="options-list">
|
|
6
|
+
<p
|
|
7
|
+
v-for="(option, index) in msg.recommend.list"
|
|
8
|
+
class="options-item"
|
|
9
|
+
:class="index!==msg.recommend.list.length -1?'recommend-item':'last-item'"
|
|
10
|
+
:key="msg.nodeId + '_' + index"
|
|
11
|
+
@click="
|
|
12
|
+
$emit(
|
|
13
|
+
'onRadioClickReco',
|
|
14
|
+
'recdNodeId' +
|
|
15
|
+
'_' +
|
|
16
|
+
index +
|
|
17
|
+
'_' +
|
|
18
|
+
option.id +
|
|
19
|
+
'_' +
|
|
20
|
+
option.text,
|
|
21
|
+
option.text,
|
|
22
|
+
msg.apiKey
|
|
23
|
+
)
|
|
24
|
+
"
|
|
25
|
+
>
|
|
26
|
+
{{ option.text
|
|
27
|
+
}}<i class="arsenal_icon arsenalangle-right-solid"></i>
|
|
28
|
+
</p>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script>
|
|
35
|
+
|
|
36
|
+
export default {
|
|
37
|
+
name: "recommend",
|
|
38
|
+
props: ["msg"]
|
|
39
|
+
}
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<style scoped lang="less">
|
|
43
|
+
.text-recommed-intent{
|
|
44
|
+
/* max-width: 300px;*/
|
|
45
|
+
background-color: white;
|
|
46
|
+
.intent-des{
|
|
47
|
+
word-wrap: break-word;
|
|
48
|
+
word-break: break-all;
|
|
49
|
+
overflow: hidden;
|
|
50
|
+
padding: 8px 0;
|
|
51
|
+
height: auto;
|
|
52
|
+
/*border-bottom: 1px solid #EEEEEE;*/
|
|
53
|
+
color: #A9B3C6;
|
|
54
|
+
font-size: 13px;
|
|
55
|
+
background-color: white;
|
|
56
|
+
}
|
|
57
|
+
.bottom-link{
|
|
58
|
+
height: 1px;
|
|
59
|
+
background-color:#EEEEEE;
|
|
60
|
+
}
|
|
61
|
+
.options-list{
|
|
62
|
+
padding-top: 4px;
|
|
63
|
+
min-width: 120px;
|
|
64
|
+
.options-item{
|
|
65
|
+
|
|
66
|
+
height: 25px;
|
|
67
|
+
line-height: 25px;
|
|
68
|
+
background-color: #ffffff;
|
|
69
|
+
color: #366aff;
|
|
70
|
+
cursor:pointer;
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
justify-content: space-between;
|
|
74
|
+
i{
|
|
75
|
+
padding-left: 10px;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
.recommend-item{
|
|
79
|
+
padding: 8px 0;
|
|
80
|
+
}
|
|
81
|
+
.last-item{
|
|
82
|
+
padding-top: 8px;
|
|
83
|
+
}
|
|
84
|
+
.end{
|
|
85
|
+
border-bottom-left-radius: 25px !important;
|
|
86
|
+
border-bottom-right-radius: 25px !important;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
90
|
</style>
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<li class="h-selector-option">
|
|
3
|
-
<slot>{{value}}</slot>
|
|
4
|
-
</li>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script>
|
|
8
|
-
export default {
|
|
9
|
-
name: "hOption",
|
|
10
|
-
props: {
|
|
11
|
-
value: {
|
|
12
|
-
type: [String,Number],
|
|
13
|
-
required: true
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
|
-
<style scoped>
|
|
20
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<li class="h-selector-option">
|
|
3
|
+
<slot>{{value}}</slot>
|
|
4
|
+
</li>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
export default {
|
|
9
|
+
name: "hOption",
|
|
10
|
+
props: {
|
|
11
|
+
value: {
|
|
12
|
+
type: [String,Number],
|
|
13
|
+
required: true
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<style scoped>
|
|
20
|
+
|
|
21
21
|
</style>
|
|
@@ -1,200 +1,200 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="h-selector">
|
|
3
|
-
<!-- 显示在外部的内容,可以显示组件内部计算的数据值,也可以显示外部传入的显示文字 -->
|
|
4
|
-
<div class="h-selector-show" @click="showAddress">
|
|
5
|
-
{{showValue || defaultShowValue}}
|
|
6
|
-
</div>
|
|
7
|
-
<!-- 显示隐藏的移动动画,使用Vue的 transition组件实施 -->
|
|
8
|
-
<transition name="h-selector-move">
|
|
9
|
-
<!-- 级联选择器外层的容器,用于显示隐藏,以及级联选择器头部和内容的显示 -->
|
|
10
|
-
<div class="h-selector-container" v-if="show">
|
|
11
|
-
<!-- 级联选择器的头部,取消按钮,确定按钮,以及显示的标题 -->
|
|
12
|
-
<div class="h-selector-header">
|
|
13
|
-
<div @click="cancel" class="h-selector-header-cancel">取消</div>
|
|
14
|
-
<div class="h-selector-header-title">{{title}}</div>
|
|
15
|
-
<div @click="confirm" class="h-selector-header-confirm">确定</div>
|
|
16
|
-
</div>
|
|
17
|
-
<!-- 包裹级联选择器的容器 -->
|
|
18
|
-
<div class="h-selector-content">
|
|
19
|
-
<!-- 使用插槽,将外部的级联选择器显示到当前组件内,成为当前组件的子组件 -->
|
|
20
|
-
<slot></slot>
|
|
21
|
-
<div class="h-selector-bg"></div>
|
|
22
|
-
</div>
|
|
23
|
-
</div>
|
|
24
|
-
</transition>
|
|
25
|
-
<!-- 遮罩层,淡入淡出动画 -->
|
|
26
|
-
<transition name="h-selector-fade">
|
|
27
|
-
<div class="h-selector-layer" v-if="show" @click="cancel"></div>
|
|
28
|
-
</transition>
|
|
29
|
-
</div>
|
|
30
|
-
</template>
|
|
31
|
-
|
|
32
|
-
<script>
|
|
33
|
-
export default {
|
|
34
|
-
name: "hSelector",
|
|
35
|
-
props: {
|
|
36
|
-
value: { // 数据双向绑定所必须的属性
|
|
37
|
-
type: Object, // 期待接收一个Object的值
|
|
38
|
-
required: true // 必填的
|
|
39
|
-
},
|
|
40
|
-
showValue: { // 由外部定义显示在外层的内容
|
|
41
|
-
type: String,
|
|
42
|
-
},
|
|
43
|
-
title: { // 定义级联选择器的标题
|
|
44
|
-
type:String, // 接收字符串类型
|
|
45
|
-
default: '' // 默认为空字符
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
data() {
|
|
49
|
-
// 定义oldValue用来保存上一次的值,使用Object.assign拷贝一份,避免与绑定的value发生冲突
|
|
50
|
-
let oldValue = Object.assign({}, this.value);
|
|
51
|
-
return {
|
|
52
|
-
oldValue, // 保存上一次修改的值
|
|
53
|
-
show: false // 定义显示隐藏
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
computed: {
|
|
57
|
-
defaultShowValue() { // 定义默认显示的内容,建议使用外部定义的内容显示,内部只做了非常简单的处理
|
|
58
|
-
let arr = [];
|
|
59
|
-
for (let i in this.value) {
|
|
60
|
-
arr.push(i + ':' + this.value[i])
|
|
61
|
-
}
|
|
62
|
-
return arr.join('/');
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
mounted() {
|
|
66
|
-
// Vue实例都拥有的$on方法,监听的是从wrapper发布的changeSelected事件,触发this.changeSelected方法
|
|
67
|
-
this.$on('changeSelected', this.changeSelected);
|
|
68
|
-
},
|
|
69
|
-
// 定义方法
|
|
70
|
-
methods: {
|
|
71
|
-
// 修改当前选中的值,实现数据双向绑定的方法
|
|
72
|
-
changeSelected(prop, value) { // 接收两个参数,prop代表需要修改对象的哪个属性,value代表修改的值
|
|
73
|
-
let obj = {};
|
|
74
|
-
obj[prop] = value;
|
|
75
|
-
// 使用Object.assign将新的值与旧的值合并覆盖,并向外部发布新的值
|
|
76
|
-
let obj2 = Object.assign({}, this.value, obj);
|
|
77
|
-
this.$emit('input', obj2);
|
|
78
|
-
},
|
|
79
|
-
// 取消功能,将上一次的数据发送回外部,并隐藏级联选择器
|
|
80
|
-
cancel() {
|
|
81
|
-
this.$emit('input', this.oldValue);
|
|
82
|
-
this.show = false;
|
|
83
|
-
},
|
|
84
|
-
// 确定功能,将本次修改的值保存,并保存在oldValue中,以供下次使用
|
|
85
|
-
confirm() {
|
|
86
|
-
this.oldValue = Object.assign({}, this.value);
|
|
87
|
-
this.$emit('change', this.value);
|
|
88
|
-
this.show = false;
|
|
89
|
-
},
|
|
90
|
-
// 控制级联选择器显示
|
|
91
|
-
showAddress() {
|
|
92
|
-
this.show = true;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
</script>
|
|
97
|
-
|
|
98
|
-
<style scoped lang="less">
|
|
99
|
-
.h-selector {
|
|
100
|
-
letter-spacing: 1px;
|
|
101
|
-
font-size: 16px;
|
|
102
|
-
width: 100%;
|
|
103
|
-
height: 100%;
|
|
104
|
-
.h-selector-show {
|
|
105
|
-
width: 100%;
|
|
106
|
-
height: 100%;
|
|
107
|
-
box-sizing: border-box;
|
|
108
|
-
padding: 0 20px;
|
|
109
|
-
white-space: nowrap;
|
|
110
|
-
overflow: hidden;
|
|
111
|
-
text-overflow: ellipsis;
|
|
112
|
-
}
|
|
113
|
-
.h-selector-container {
|
|
114
|
-
position: absolute;
|
|
115
|
-
z-index: 999;
|
|
116
|
-
left: 0;
|
|
117
|
-
bottom: 0;
|
|
118
|
-
width: 100%;
|
|
119
|
-
background: #fff;
|
|
120
|
-
}
|
|
121
|
-
.h-selector-layer {
|
|
122
|
-
position: absolute;
|
|
123
|
-
background: rgba(0, 0, 0, 0.3);
|
|
124
|
-
width: 100%;
|
|
125
|
-
height: 100%;
|
|
126
|
-
top: 0;
|
|
127
|
-
left: 0;
|
|
128
|
-
z-index: 2;
|
|
129
|
-
}
|
|
130
|
-
ul, li {
|
|
131
|
-
margin: 0;
|
|
132
|
-
padding: 0;
|
|
133
|
-
list-style: none;
|
|
134
|
-
}
|
|
135
|
-
.h-selector-header {
|
|
136
|
-
display: flex;
|
|
137
|
-
align-items: center;
|
|
138
|
-
height: 40px;
|
|
139
|
-
justify-content: space-between;
|
|
140
|
-
padding: 0 30px;
|
|
141
|
-
.h-selector-header-cancel {
|
|
142
|
-
color: #e9aa14;
|
|
143
|
-
}
|
|
144
|
-
.h-selector-header-confirm {
|
|
145
|
-
color: #508aff;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
.h-selector-content {
|
|
149
|
-
display: flex;
|
|
150
|
-
width: 100%;
|
|
151
|
-
position: relative;
|
|
152
|
-
}
|
|
153
|
-
.h-selector-wrapper {
|
|
154
|
-
flex: 1;
|
|
155
|
-
overflow: hidden;
|
|
156
|
-
& + .h-selector-wrapper {
|
|
157
|
-
border-left: 1px solid #ddd;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
.h-selector-option {
|
|
161
|
-
line-height: 60px;
|
|
162
|
-
height: 60px;
|
|
163
|
-
text-align: center;
|
|
164
|
-
white-space: nowrap;
|
|
165
|
-
overflow: hidden;
|
|
166
|
-
text-overflow: ellipsis;
|
|
167
|
-
}
|
|
168
|
-
.h-selector-bg {
|
|
169
|
-
height: 100%;
|
|
170
|
-
width: 100%;
|
|
171
|
-
position: absolute;
|
|
172
|
-
top: 0;
|
|
173
|
-
left: 0;
|
|
174
|
-
background: linear-gradient(180deg, hsla(0, 0%, 100%, 0.9), hsla(0, 0%, 100%, 0.7)), linear-gradient(0deg, hsla(0, 0%, 100%, 0.9), hsla(0, 0%, 100%, 0.4));
|
|
175
|
-
backface-visibility: hidden;
|
|
176
|
-
pointer-events: none;
|
|
177
|
-
background-repeat: no-repeat;
|
|
178
|
-
background-position: top, bottom;
|
|
179
|
-
background-size: 100% 100px;
|
|
180
|
-
}
|
|
181
|
-
.h-selector-move-enter-to, .h-selector-move-leave {
|
|
182
|
-
transform: translate3d(0, 0, 0);
|
|
183
|
-
}
|
|
184
|
-
.h-selector-move-enter-active, .h-selector-move-leave-active {
|
|
185
|
-
transition: transform .6s;
|
|
186
|
-
}
|
|
187
|
-
.h-selector-move-enter, .h-selector-move-leave-to {
|
|
188
|
-
transform: translate3d(0, 100%, 0);
|
|
189
|
-
}
|
|
190
|
-
.h-selector-fade-enter-to, .h-selector-fade-leave {
|
|
191
|
-
opacity: 1;
|
|
192
|
-
}
|
|
193
|
-
.h-selector-fade-enter-active, .h-selector-fade-leave-active {
|
|
194
|
-
transition: opacity .4s;
|
|
195
|
-
}
|
|
196
|
-
.h-selector-fade-enter, .h-selector-fade-leave-to {
|
|
197
|
-
opacity: 0;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<div class="h-selector">
|
|
3
|
+
<!-- 显示在外部的内容,可以显示组件内部计算的数据值,也可以显示外部传入的显示文字 -->
|
|
4
|
+
<div class="h-selector-show" @click="showAddress">
|
|
5
|
+
{{showValue || defaultShowValue}}
|
|
6
|
+
</div>
|
|
7
|
+
<!-- 显示隐藏的移动动画,使用Vue的 transition组件实施 -->
|
|
8
|
+
<transition name="h-selector-move">
|
|
9
|
+
<!-- 级联选择器外层的容器,用于显示隐藏,以及级联选择器头部和内容的显示 -->
|
|
10
|
+
<div class="h-selector-container" v-if="show">
|
|
11
|
+
<!-- 级联选择器的头部,取消按钮,确定按钮,以及显示的标题 -->
|
|
12
|
+
<div class="h-selector-header">
|
|
13
|
+
<div @click="cancel" class="h-selector-header-cancel">取消</div>
|
|
14
|
+
<div class="h-selector-header-title">{{title}}</div>
|
|
15
|
+
<div @click="confirm" class="h-selector-header-confirm">确定</div>
|
|
16
|
+
</div>
|
|
17
|
+
<!-- 包裹级联选择器的容器 -->
|
|
18
|
+
<div class="h-selector-content">
|
|
19
|
+
<!-- 使用插槽,将外部的级联选择器显示到当前组件内,成为当前组件的子组件 -->
|
|
20
|
+
<slot></slot>
|
|
21
|
+
<div class="h-selector-bg"></div>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</transition>
|
|
25
|
+
<!-- 遮罩层,淡入淡出动画 -->
|
|
26
|
+
<transition name="h-selector-fade">
|
|
27
|
+
<div class="h-selector-layer" v-if="show" @click="cancel"></div>
|
|
28
|
+
</transition>
|
|
29
|
+
</div>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<script>
|
|
33
|
+
export default {
|
|
34
|
+
name: "hSelector",
|
|
35
|
+
props: {
|
|
36
|
+
value: { // 数据双向绑定所必须的属性
|
|
37
|
+
type: Object, // 期待接收一个Object的值
|
|
38
|
+
required: true // 必填的
|
|
39
|
+
},
|
|
40
|
+
showValue: { // 由外部定义显示在外层的内容
|
|
41
|
+
type: String,
|
|
42
|
+
},
|
|
43
|
+
title: { // 定义级联选择器的标题
|
|
44
|
+
type:String, // 接收字符串类型
|
|
45
|
+
default: '' // 默认为空字符
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
data() {
|
|
49
|
+
// 定义oldValue用来保存上一次的值,使用Object.assign拷贝一份,避免与绑定的value发生冲突
|
|
50
|
+
let oldValue = Object.assign({}, this.value);
|
|
51
|
+
return {
|
|
52
|
+
oldValue, // 保存上一次修改的值
|
|
53
|
+
show: false // 定义显示隐藏
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
computed: {
|
|
57
|
+
defaultShowValue() { // 定义默认显示的内容,建议使用外部定义的内容显示,内部只做了非常简单的处理
|
|
58
|
+
let arr = [];
|
|
59
|
+
for (let i in this.value) {
|
|
60
|
+
arr.push(i + ':' + this.value[i])
|
|
61
|
+
}
|
|
62
|
+
return arr.join('/');
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
mounted() {
|
|
66
|
+
// Vue实例都拥有的$on方法,监听的是从wrapper发布的changeSelected事件,触发this.changeSelected方法
|
|
67
|
+
this.$on('changeSelected', this.changeSelected);
|
|
68
|
+
},
|
|
69
|
+
// 定义方法
|
|
70
|
+
methods: {
|
|
71
|
+
// 修改当前选中的值,实现数据双向绑定的方法
|
|
72
|
+
changeSelected(prop, value) { // 接收两个参数,prop代表需要修改对象的哪个属性,value代表修改的值
|
|
73
|
+
let obj = {};
|
|
74
|
+
obj[prop] = value;
|
|
75
|
+
// 使用Object.assign将新的值与旧的值合并覆盖,并向外部发布新的值
|
|
76
|
+
let obj2 = Object.assign({}, this.value, obj);
|
|
77
|
+
this.$emit('input', obj2);
|
|
78
|
+
},
|
|
79
|
+
// 取消功能,将上一次的数据发送回外部,并隐藏级联选择器
|
|
80
|
+
cancel() {
|
|
81
|
+
this.$emit('input', this.oldValue);
|
|
82
|
+
this.show = false;
|
|
83
|
+
},
|
|
84
|
+
// 确定功能,将本次修改的值保存,并保存在oldValue中,以供下次使用
|
|
85
|
+
confirm() {
|
|
86
|
+
this.oldValue = Object.assign({}, this.value);
|
|
87
|
+
this.$emit('change', this.value);
|
|
88
|
+
this.show = false;
|
|
89
|
+
},
|
|
90
|
+
// 控制级联选择器显示
|
|
91
|
+
showAddress() {
|
|
92
|
+
this.show = true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
</script>
|
|
97
|
+
|
|
98
|
+
<style scoped lang="less">
|
|
99
|
+
.h-selector {
|
|
100
|
+
letter-spacing: 1px;
|
|
101
|
+
font-size: 16px;
|
|
102
|
+
width: 100%;
|
|
103
|
+
height: 100%;
|
|
104
|
+
.h-selector-show {
|
|
105
|
+
width: 100%;
|
|
106
|
+
height: 100%;
|
|
107
|
+
box-sizing: border-box;
|
|
108
|
+
padding: 0 20px;
|
|
109
|
+
white-space: nowrap;
|
|
110
|
+
overflow: hidden;
|
|
111
|
+
text-overflow: ellipsis;
|
|
112
|
+
}
|
|
113
|
+
.h-selector-container {
|
|
114
|
+
position: absolute;
|
|
115
|
+
z-index: 999;
|
|
116
|
+
left: 0;
|
|
117
|
+
bottom: 0;
|
|
118
|
+
width: 100%;
|
|
119
|
+
background: #fff;
|
|
120
|
+
}
|
|
121
|
+
.h-selector-layer {
|
|
122
|
+
position: absolute;
|
|
123
|
+
background: rgba(0, 0, 0, 0.3);
|
|
124
|
+
width: 100%;
|
|
125
|
+
height: 100%;
|
|
126
|
+
top: 0;
|
|
127
|
+
left: 0;
|
|
128
|
+
z-index: 2;
|
|
129
|
+
}
|
|
130
|
+
ul, li {
|
|
131
|
+
margin: 0;
|
|
132
|
+
padding: 0;
|
|
133
|
+
list-style: none;
|
|
134
|
+
}
|
|
135
|
+
.h-selector-header {
|
|
136
|
+
display: flex;
|
|
137
|
+
align-items: center;
|
|
138
|
+
height: 40px;
|
|
139
|
+
justify-content: space-between;
|
|
140
|
+
padding: 0 30px;
|
|
141
|
+
.h-selector-header-cancel {
|
|
142
|
+
color: #e9aa14;
|
|
143
|
+
}
|
|
144
|
+
.h-selector-header-confirm {
|
|
145
|
+
color: #508aff;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
.h-selector-content {
|
|
149
|
+
display: flex;
|
|
150
|
+
width: 100%;
|
|
151
|
+
position: relative;
|
|
152
|
+
}
|
|
153
|
+
.h-selector-wrapper {
|
|
154
|
+
flex: 1;
|
|
155
|
+
overflow: hidden;
|
|
156
|
+
& + .h-selector-wrapper {
|
|
157
|
+
border-left: 1px solid #ddd;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
.h-selector-option {
|
|
161
|
+
line-height: 60px;
|
|
162
|
+
height: 60px;
|
|
163
|
+
text-align: center;
|
|
164
|
+
white-space: nowrap;
|
|
165
|
+
overflow: hidden;
|
|
166
|
+
text-overflow: ellipsis;
|
|
167
|
+
}
|
|
168
|
+
.h-selector-bg {
|
|
169
|
+
height: 100%;
|
|
170
|
+
width: 100%;
|
|
171
|
+
position: absolute;
|
|
172
|
+
top: 0;
|
|
173
|
+
left: 0;
|
|
174
|
+
background: linear-gradient(180deg, hsla(0, 0%, 100%, 0.9), hsla(0, 0%, 100%, 0.7)), linear-gradient(0deg, hsla(0, 0%, 100%, 0.9), hsla(0, 0%, 100%, 0.4));
|
|
175
|
+
backface-visibility: hidden;
|
|
176
|
+
pointer-events: none;
|
|
177
|
+
background-repeat: no-repeat;
|
|
178
|
+
background-position: top, bottom;
|
|
179
|
+
background-size: 100% 100px;
|
|
180
|
+
}
|
|
181
|
+
.h-selector-move-enter-to, .h-selector-move-leave {
|
|
182
|
+
transform: translate3d(0, 0, 0);
|
|
183
|
+
}
|
|
184
|
+
.h-selector-move-enter-active, .h-selector-move-leave-active {
|
|
185
|
+
transition: transform .6s;
|
|
186
|
+
}
|
|
187
|
+
.h-selector-move-enter, .h-selector-move-leave-to {
|
|
188
|
+
transform: translate3d(0, 100%, 0);
|
|
189
|
+
}
|
|
190
|
+
.h-selector-fade-enter-to, .h-selector-fade-leave {
|
|
191
|
+
opacity: 1;
|
|
192
|
+
}
|
|
193
|
+
.h-selector-fade-enter-active, .h-selector-fade-leave-active {
|
|
194
|
+
transition: opacity .4s;
|
|
195
|
+
}
|
|
196
|
+
.h-selector-fade-enter, .h-selector-fade-leave-to {
|
|
197
|
+
opacity: 0;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
200
|
</style>
|