@wg-npm/survey-response 0.3.377-8.develop → 0.3.496-8.release
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/dist/survey-response.esm.js +17 -18
- package/package.json +5 -5
- package/src/components/question/type/evaluation.vue +12 -16
- package/src/components/question/type/matrix.vue +0 -5
- package/src/components/question/type/multi-selection.vue +0 -5
- package/src/components/question/type/single-selection.vue +0 -5
- package/src/mixins/option-layout-mixin.ts +1 -1
- package/src/styles/components/survey-response.less +10 -0
- package/src/ellipsis-tooltip.ts +0 -160
|
@@ -254,7 +254,7 @@ var OptionLayoutMixin = Vue.extend({
|
|
|
254
254
|
computed: {
|
|
255
255
|
optionLayout() {
|
|
256
256
|
const globalLayout = _.lowerCase(_.get(this.options, "layout", undefined));
|
|
257
|
-
if (this.isMobile || "vertical" == globalLayout) {
|
|
257
|
+
if (this.isMobile() || "vertical" == globalLayout) {
|
|
258
258
|
return "";
|
|
259
259
|
}
|
|
260
260
|
const questionLayout = _.lowerCase(_.get(this.question.options, "layout", "horizontal"));
|
|
@@ -318,7 +318,7 @@ var __vue_render__$c = function () {var _vm=this;var _h=_vm.$createElement;var _
|
|
|
318
318
|
type: 'array',
|
|
319
319
|
min: 1,
|
|
320
320
|
message: _vm.t('survey_response.question.question_required')
|
|
321
|
-
}}},[_c('CheckboxGroup',{on:{"on-change":_vm.selChange},model:{value:(_vm.value.answer),callback:function ($$v) {_vm.$set(_vm.value, "answer", $$v);},expression:"value.answer"}},[_c('Row',{attrs:{"type":"flex","justify":"start","gutter":60}},_vm._l((_vm.question.choices),function(choice){return _c('Col',{key:choice.id,class:_vm.optionLayout
|
|
321
|
+
}}},[_c('CheckboxGroup',{on:{"on-change":_vm.selChange},model:{value:(_vm.value.answer),callback:function ($$v) {_vm.$set(_vm.value, "answer", $$v);},expression:"value.answer"}},[_c('Row',{attrs:{"type":"flex","justify":"start","gutter":60}},_vm._l((_vm.question.choices),function(choice){return _c('Col',{key:choice.id,class:_vm.optionLayout},[_c('Checkbox',{key:choice.id,attrs:{"label":choice.id,"disabled":_vm.question.options.readonly}},[_c('span',[_vm._v(_vm._s(_vm.i18nText(choice.text)))])])],1)}),1)],1)],1)};
|
|
322
322
|
var __vue_staticRenderFns__$c = [];
|
|
323
323
|
|
|
324
324
|
/* style */
|
|
@@ -501,7 +501,7 @@ const __vue_script__$a = script$a;
|
|
|
501
501
|
var __vue_render__$a = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('FormItem',{attrs:{"prop":("answers[" + _vm.index + "].answer"),"rules":{
|
|
502
502
|
required: _vm.question.options.required,
|
|
503
503
|
message: _vm.t('survey_response.question.question_required')
|
|
504
|
-
}}},[_c('RadioGroup',{staticClass:"question-choice",on:{"on-change":_vm.selChange},model:{value:(_vm.value.answer),callback:function ($$v) {_vm.$set(_vm.value, "answer", $$v);},expression:"value.answer"}},[_c('Row',{attrs:{"type":"flex","justify":"start","gutter":60}},_vm._l((_vm.question.choices),function(choice){return _c('Col',{key:choice.id,class:_vm.optionLayout
|
|
504
|
+
}}},[_c('RadioGroup',{staticClass:"question-choice",on:{"on-change":_vm.selChange},model:{value:(_vm.value.answer),callback:function ($$v) {_vm.$set(_vm.value, "answer", $$v);},expression:"value.answer"}},[_c('Row',{attrs:{"type":"flex","justify":"start","gutter":60}},_vm._l((_vm.question.choices),function(choice){return _c('Col',{key:choice.id,class:_vm.optionLayout},[_c('Radio',{key:choice.id,attrs:{"disabled":_vm.question.options.readonly,"label":choice.id},nativeOn:{"click":function($event){return _vm.toggleAnswer(choice.id)}}},[(_vm.haveStar(choice))?_c('span',[_c('Icon',{attrs:{"type":"md-star","color":"orange","size":16}})],1):_vm._e(),_vm._v(" "),_c('span',[_vm._v(_vm._s(_vm.i18nText(choice.text)))])])],1)}),1)],1)],1)};
|
|
505
505
|
var __vue_staticRenderFns__$a = [];
|
|
506
506
|
|
|
507
507
|
/* style */
|
|
@@ -610,7 +610,7 @@ const __vue_script__$9 = script$9;
|
|
|
610
610
|
var __vue_render__$9 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',_vm._l((_vm.question.subQuestions),function(subQuestion,subIndex){return _c('div',{key:subIndex,staticClass:"sub-question"},[_c('span',{staticClass:"number"},[_vm._v("\n "+_vm._s(_vm.question.header.number)+"-"+_vm._s(subQuestion.number)+".")]),_vm._v(" "),_c('span',{staticClass:"title"},[_vm._v(" "+_vm._s(_vm.i18nText(subQuestion.text))+" ")]),_vm._v(" "),_c('FormItem',{attrs:{"prop":("answers[" + _vm.index + "].answer[" + subIndex + "].answer"),"rules":{
|
|
611
611
|
required: _vm.question.options.required,
|
|
612
612
|
message: _vm.t('survey_response.question.question_required')
|
|
613
|
-
}}},[_c('RadioGroup',{on:{"on-change":_vm.selChange},model:{value:(_vm.value.answer[subIndex].answer),callback:function ($$v) {_vm.$set(_vm.value.answer[subIndex], "answer", $$v);},expression:"value.answer[subIndex].answer"}},[_c('Row',{attrs:{"type":"flex","justify":"start","gutter":60}},_vm._l((_vm.question.choices),function(choice){return _c('Col',{key:choice.id,class:_vm.optionLayout
|
|
613
|
+
}}},[_c('RadioGroup',{on:{"on-change":_vm.selChange},model:{value:(_vm.value.answer[subIndex].answer),callback:function ($$v) {_vm.$set(_vm.value.answer[subIndex], "answer", $$v);},expression:"value.answer[subIndex].answer"}},[_c('Row',{attrs:{"type":"flex","justify":"start","gutter":60}},_vm._l((_vm.question.choices),function(choice){return _c('Col',{key:choice.id,class:_vm.optionLayout},[_c('Radio',{key:choice.id,attrs:{"label":choice.id,"disabled":subQuestion.options.readonly},nativeOn:{"click":function($event){return _vm.toggleAnswer(choice.id, subIndex)}}},[_c('span',[_vm._v(_vm._s(_vm.i18nText(choice.text)))])])],1)}),1)],1)],1)],1)}),0)};
|
|
614
614
|
var __vue_staticRenderFns__$9 = [];
|
|
615
615
|
|
|
616
616
|
/* style */
|
|
@@ -1218,20 +1218,21 @@ var script$2 = Vue.extend({
|
|
|
1218
1218
|
Col,
|
|
1219
1219
|
Card,
|
|
1220
1220
|
Icon,
|
|
1221
|
+
Tooltip,
|
|
1221
1222
|
STAR: Star,
|
|
1222
|
-
EXPR: Expr
|
|
1223
|
+
EXPR: Expr
|
|
1223
1224
|
},
|
|
1224
1225
|
mixins: [LocaleMixin],
|
|
1225
1226
|
inject: ["$rootComponent"],
|
|
1226
1227
|
props: {
|
|
1227
1228
|
question: {
|
|
1228
1229
|
type: Object,
|
|
1229
|
-
required: true
|
|
1230
|
+
required: true
|
|
1230
1231
|
},
|
|
1231
1232
|
answer: {
|
|
1232
1233
|
type: Object,
|
|
1233
|
-
required: true
|
|
1234
|
-
}
|
|
1234
|
+
required: true
|
|
1235
|
+
}
|
|
1235
1236
|
},
|
|
1236
1237
|
methods: {
|
|
1237
1238
|
iconType(id) {
|
|
@@ -1243,29 +1244,27 @@ var script$2 = Vue.extend({
|
|
|
1243
1244
|
return this.answer.answer == id
|
|
1244
1245
|
? "evaluation-cards evaluation-cards-current"
|
|
1245
1246
|
: "evaluation-cards";
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1248
1249
|
});
|
|
1249
1250
|
|
|
1250
1251
|
/* script */
|
|
1251
1252
|
const __vue_script__$2 = script$2;
|
|
1252
1253
|
|
|
1253
1254
|
/* template */
|
|
1254
|
-
var __vue_render__$2 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[(_vm.question.evaluationItems.length > 0)?_c('Row',{attrs:{"type":"flex","justify":"start","gutter":24}},_vm._l((_vm.question.evaluationItems),function(item){return _c('Col',{key:item.id,staticClass:"evaluation-item",attrs:{"xs":24,"sm":_vm.$rootComponent.layout === 'vertical' ? 24 : 6,"xl":_vm.$rootComponent.layout === 'vertical' ? 24 : 6,"md":_vm.$rootComponent.layout === 'vertical' ? 24 : 6,"lg":_vm.$rootComponent.layout === 'vertical' ? 24 : 6}},[_c('Card',{class:_vm.cardClasses(item.id),attrs:{"dis-hover":""}},[_c('div',{staticClass:"card-title",attrs:{"slot":"title"},slot:"title"},[_c('Icon',{staticClass:"icon",attrs:{"type":_vm.iconType(item.id),"size":36}})],1),_vm._v(" "),_c('div',{staticClass:"card-content"},[_c('
|
|
1255
|
+
var __vue_render__$2 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[(_vm.question.evaluationItems.length > 0)?_c('Row',{attrs:{"type":"flex","justify":"start","gutter":24}},_vm._l((_vm.question.evaluationItems),function(item){return _c('Col',{key:item.id,staticClass:"evaluation-item",attrs:{"xs":24,"sm":_vm.$rootComponent.layout === 'vertical' ? 24 : 6,"xl":_vm.$rootComponent.layout === 'vertical' ? 24 : 6,"md":_vm.$rootComponent.layout === 'vertical' ? 24 : 6,"lg":_vm.$rootComponent.layout === 'vertical' ? 24 : 6}},[_c('Card',{class:_vm.cardClasses(item.id),attrs:{"dis-hover":""}},[_c('div',{staticClass:"card-title",attrs:{"slot":"title"},slot:"title"},[_c('Icon',{staticClass:"icon",attrs:{"type":_vm.iconType(item.id),"size":36}})],1),_vm._v(" "),_c('div',{staticClass:"card-content"},[_c('Tooltip',{attrs:{"max-width":"200"}},[_c('p',{attrs:{"slot":"content"},slot:"content"},[_vm._v(_vm._s(_vm.i18nText(item.text)))]),_vm._v(" "),_c('p',{staticClass:"text"},[_vm._v(_vm._s(_vm.i18nText(item.text)))])]),_vm._v(" "),_c(_vm.question.options.evaluationType,{tag:"component",attrs:{"item":item}})],1)])],1)}),1):_vm._e()],1)};
|
|
1255
1256
|
var __vue_staticRenderFns__$2 = [];
|
|
1256
1257
|
|
|
1257
1258
|
/* style */
|
|
1258
|
-
const __vue_inject_styles__$2 =
|
|
1259
|
-
if (!inject) return
|
|
1260
|
-
inject("data-v-71844af4_0", { source: ".card-text[data-v-71844af4]{width:100%}", map: undefined, media: undefined });
|
|
1261
|
-
|
|
1262
|
-
};
|
|
1259
|
+
const __vue_inject_styles__$2 = undefined;
|
|
1263
1260
|
/* scoped */
|
|
1264
|
-
const __vue_scope_id__$2 =
|
|
1261
|
+
const __vue_scope_id__$2 = undefined;
|
|
1265
1262
|
/* module identifier */
|
|
1266
1263
|
const __vue_module_identifier__$2 = undefined;
|
|
1267
1264
|
/* functional template */
|
|
1268
1265
|
const __vue_is_functional_template__$2 = false;
|
|
1266
|
+
/* style inject */
|
|
1267
|
+
|
|
1269
1268
|
/* style inject SSR */
|
|
1270
1269
|
|
|
1271
1270
|
/* style inject shadow dom */
|
|
@@ -1280,7 +1279,7 @@ var __vue_staticRenderFns__$2 = [];
|
|
|
1280
1279
|
__vue_is_functional_template__$2,
|
|
1281
1280
|
__vue_module_identifier__$2,
|
|
1282
1281
|
false,
|
|
1283
|
-
|
|
1282
|
+
undefined,
|
|
1284
1283
|
undefined,
|
|
1285
1284
|
undefined
|
|
1286
1285
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wg-npm/survey-response",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4968.release",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"lint-fix": "eslint \"**/*.ts\" \"**/*.vue\" --fix --no-error-on-unmatched-pattern"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@wg-npm/survey-core": "0.3.
|
|
16
|
-
"@wg-npm/survey-service-api": "0.3.
|
|
15
|
+
"@wg-npm/survey-core": "0.3.4968.release",
|
|
16
|
+
"@wg-npm/survey-service-api": "0.3.4968.release",
|
|
17
17
|
"axios": "^0.19.2",
|
|
18
18
|
"deepmerge": "^4.2.2",
|
|
19
19
|
"lodash": "^4.17.15",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"@typescript-eslint/parser": "^3.6.0",
|
|
35
35
|
"@vue/eslint-config-prettier": "^6.0.0",
|
|
36
36
|
"@vue/eslint-config-typescript": "^5.0.2",
|
|
37
|
-
"@wg-npm/survey-core": "0.3.
|
|
38
|
-
"@wg-npm/survey-service-api": "0.3.
|
|
37
|
+
"@wg-npm/survey-core": "0.3.4968.release",
|
|
38
|
+
"@wg-npm/survey-service-api": "0.3.4968.release",
|
|
39
39
|
"acorn": "^7.3.1",
|
|
40
40
|
"axios": "^0.19.2",
|
|
41
41
|
"babelrc-rollup": "^3.0.0",
|
|
@@ -21,9 +21,10 @@
|
|
|
21
21
|
<Icon class="icon" :type="iconType(item.id)" :size="36" />
|
|
22
22
|
</div>
|
|
23
23
|
<div class="card-content">
|
|
24
|
-
<
|
|
25
|
-
<p
|
|
26
|
-
|
|
24
|
+
<Tooltip max-width="200">
|
|
25
|
+
<p slot="content">{{ i18nText(item.text) }}</p>
|
|
26
|
+
<p class="text">{{ i18nText(item.text) }}</p>
|
|
27
|
+
</Tooltip>
|
|
27
28
|
<component
|
|
28
29
|
:is="question.options.evaluationType"
|
|
29
30
|
:item="item"
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
|
|
38
39
|
<script lang="ts">
|
|
39
40
|
import Vue from "vue";
|
|
40
|
-
import { Col, Row, Card, Icon } from "view-design";
|
|
41
|
+
import { Col, Row, Card, Icon, Tooltip } from "view-design";
|
|
41
42
|
import LocaleMixin from "../../../mixins/locale-mixin";
|
|
42
43
|
import { QuestionEvaluationModel } from "@wg-npm/survey-core";
|
|
43
44
|
import Star from "./evaluation/star.vue";
|
|
@@ -50,20 +51,21 @@ export default Vue.extend({
|
|
|
50
51
|
Col,
|
|
51
52
|
Card,
|
|
52
53
|
Icon,
|
|
54
|
+
Tooltip,
|
|
53
55
|
STAR: Star,
|
|
54
|
-
EXPR: Expr
|
|
56
|
+
EXPR: Expr
|
|
55
57
|
},
|
|
56
58
|
mixins: [LocaleMixin],
|
|
57
59
|
inject: ["$rootComponent"],
|
|
58
60
|
props: {
|
|
59
61
|
question: {
|
|
60
62
|
type: Object as () => QuestionEvaluationModel,
|
|
61
|
-
required: true
|
|
63
|
+
required: true
|
|
62
64
|
},
|
|
63
65
|
answer: {
|
|
64
66
|
type: Object,
|
|
65
|
-
required: true
|
|
66
|
-
}
|
|
67
|
+
required: true
|
|
68
|
+
}
|
|
67
69
|
},
|
|
68
70
|
methods: {
|
|
69
71
|
iconType(id) {
|
|
@@ -75,13 +77,7 @@ export default Vue.extend({
|
|
|
75
77
|
return this.answer.answer == id
|
|
76
78
|
? "evaluation-cards evaluation-cards-current"
|
|
77
79
|
: "evaluation-cards";
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
80
82
|
});
|
|
81
83
|
</script>
|
|
82
|
-
|
|
83
|
-
<style lang="less" scoped>
|
|
84
|
-
.card-text {
|
|
85
|
-
width: 100%;
|
|
86
|
-
}
|
|
87
|
-
</style>
|
|
@@ -22,11 +22,6 @@
|
|
|
22
22
|
>
|
|
23
23
|
<Row type="flex" justify="start" :gutter="60">
|
|
24
24
|
<Col
|
|
25
|
-
:xs="24"
|
|
26
|
-
:sm="$rootComponent.layout === 'vertical' ? 24 : 6"
|
|
27
|
-
:xl="$rootComponent.layout === 'vertical' ? 24 : 6"
|
|
28
|
-
:md="$rootComponent.layout === 'vertical' ? 24 : 6"
|
|
29
|
-
:lg="$rootComponent.layout === 'vertical' ? 24 : 6"
|
|
30
25
|
v-for="choice in question.choices"
|
|
31
26
|
:key="choice.id"
|
|
32
27
|
:class="optionLayout"
|
|
@@ -11,11 +11,6 @@
|
|
|
11
11
|
<CheckboxGroup v-model="value.answer" @on-change="selChange">
|
|
12
12
|
<Row type="flex" justify="start" :gutter="60">
|
|
13
13
|
<Col
|
|
14
|
-
:xs="24"
|
|
15
|
-
:sm="$rootComponent.layout === 'vertical' ? 24 : 6"
|
|
16
|
-
:xl="$rootComponent.layout === 'vertical' ? 24 : 6"
|
|
17
|
-
:md="$rootComponent.layout === 'vertical' ? 24 : 6"
|
|
18
|
-
:lg="$rootComponent.layout === 'vertical' ? 24 : 6"
|
|
19
14
|
v-for="choice in question.choices"
|
|
20
15
|
:key="choice.id"
|
|
21
16
|
:class="optionLayout"
|
|
@@ -13,11 +13,6 @@
|
|
|
13
13
|
>
|
|
14
14
|
<Row type="flex" justify="start" :gutter="60">
|
|
15
15
|
<Col
|
|
16
|
-
:xs="24"
|
|
17
|
-
:sm="$rootComponent.layout === 'vertical' ? 24 : 6"
|
|
18
|
-
:xl="$rootComponent.layout === 'vertical' ? 24 : 6"
|
|
19
|
-
:md="$rootComponent.layout === 'vertical' ? 24 : 6"
|
|
20
|
-
:lg="$rootComponent.layout === 'vertical' ? 24 : 6"
|
|
21
16
|
v-for="choice in question.choices"
|
|
22
17
|
:key="choice.id"
|
|
23
18
|
:class="optionLayout"
|
|
@@ -96,10 +96,20 @@
|
|
|
96
96
|
.card-content {
|
|
97
97
|
text-align: center;
|
|
98
98
|
|
|
99
|
+
.ivu-tooltip {
|
|
100
|
+
display: unset;
|
|
101
|
+
}
|
|
102
|
+
.ivu-tooltip-rel{
|
|
103
|
+
display: unset;
|
|
104
|
+
}
|
|
105
|
+
|
|
99
106
|
p.text {
|
|
100
107
|
font-weight: 500;
|
|
101
108
|
font-size: 18px;
|
|
102
109
|
padding: 10px;
|
|
110
|
+
white-space: nowrap;/*把文本强制显示在一行*/
|
|
111
|
+
overflow: hidden;/*隐藏超出部分的文字*/
|
|
112
|
+
text-overflow: ellipsis;/*超出显示省略号*/
|
|
103
113
|
}
|
|
104
114
|
|
|
105
115
|
.desc {
|
package/src/ellipsis-tooltip.ts
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import Vue from "vue";
|
|
2
|
-
|
|
3
|
-
const GLOBAL_TOOLTIP_ID = "ellipsis-directive-tooltip-" + Math.random();
|
|
4
|
-
const singleTipBox = function (maxWidth) {
|
|
5
|
-
let tipBox = document.getElementById(GLOBAL_TOOLTIP_ID);
|
|
6
|
-
if (!tipBox) {
|
|
7
|
-
tipBox = document.createElement("div");
|
|
8
|
-
tipBox.id = GLOBAL_TOOLTIP_ID;
|
|
9
|
-
tipBox.style.display = "none";
|
|
10
|
-
tipBox.style.position = "fixed";
|
|
11
|
-
tipBox.style.maxWidth = maxWidth + "px";
|
|
12
|
-
tipBox.style.padding = "8px 12px";
|
|
13
|
-
tipBox.style.backgroundColor = "rgba(70,76,91,.9)";
|
|
14
|
-
tipBox.style.borderRadius = "4px";
|
|
15
|
-
tipBox.style.boxShadow = "0 1px 6px rgba(0,0,0,.2)";
|
|
16
|
-
tipBox.style.color = "#fff";
|
|
17
|
-
tipBox.style.zIndex = "1200";
|
|
18
|
-
tipBox.style.wordWrap = "break-word";
|
|
19
|
-
tipBox.style.wordBreak = "break-all";
|
|
20
|
-
document.body.appendChild(tipBox);
|
|
21
|
-
|
|
22
|
-
tipBox.addEventListener("mouseover", (event) => {
|
|
23
|
-
// @ts-ignore
|
|
24
|
-
tipBox.style.display = "block";
|
|
25
|
-
});
|
|
26
|
-
tipBox.addEventListener("mouseout", (event) => {
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
tipBox.style.display = "none";
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
return tipBox;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const createArrow = function () {
|
|
35
|
-
const arrow = document.createElement("div");
|
|
36
|
-
arrow.style.position = "absolute";
|
|
37
|
-
arrow.style.width = "0";
|
|
38
|
-
arrow.style.height = "0";
|
|
39
|
-
arrow.style.borderColor = "transparent";
|
|
40
|
-
arrow.style.borderStyle = "solid";
|
|
41
|
-
return arrow;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const setArrowStyle = function (event: MouseEvent, arrowEle, tipBox) {
|
|
45
|
-
if (event.clientY > tipBox.offsetTop) {
|
|
46
|
-
arrowEle.style.bottom = "-5px";
|
|
47
|
-
arrowEle.style.top = "auto";
|
|
48
|
-
arrowEle.style.borderWidth = "5px 5px 0";
|
|
49
|
-
arrowEle.style.borderTopColor = "rgba(70,76,91,.9)";
|
|
50
|
-
} else {
|
|
51
|
-
arrowEle.style.top = "-5px";
|
|
52
|
-
arrowEle.style.bottom = "auto";
|
|
53
|
-
arrowEle.style.borderWidth = "0 5px 5px";
|
|
54
|
-
arrowEle.style.borderBottomColor = "rgba(70,76,91,.9)";
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (event.clientX > tipBox.offsetLeft + 10) {
|
|
58
|
-
tipBox.style.display = "flex";
|
|
59
|
-
tipBox.style.justifyContent = "flex-end";
|
|
60
|
-
} else {
|
|
61
|
-
tipBox.style.display = "flex";
|
|
62
|
-
tipBox.style.justifyContent = "flex-start";
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const calcTextWidth = function (el) {
|
|
67
|
-
el.style.whiteSpace = "nowrap";
|
|
68
|
-
el.style.display = "inline-block";
|
|
69
|
-
const textWidth = el.offsetWidth;
|
|
70
|
-
el.style.display = "none";
|
|
71
|
-
return textWidth;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const calcParentWidth = function (el) {
|
|
75
|
-
el.style.display = "block";
|
|
76
|
-
return el.parentElement.offsetWidth;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const calcTipTop = function (el, tipBox) {
|
|
80
|
-
let tipTop = el.getBoundingClientRect().top + el.offsetHeight;
|
|
81
|
-
const tipBottom = tipTop + tipBox.offsetHeight;
|
|
82
|
-
if (window.innerHeight - tipBottom < 1) {
|
|
83
|
-
tipTop = tipTop - tipBox.offsetHeight - el.offsetHeight;
|
|
84
|
-
}
|
|
85
|
-
return tipTop + "px";
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const calcTopLeft = function (event, tipBox) {
|
|
89
|
-
let tipLeft = event.clientX - 10;
|
|
90
|
-
const tipRight = tipLeft + tipBox.offsetWidth;
|
|
91
|
-
if (window.innerWidth - tipRight < 1) {
|
|
92
|
-
tipLeft = tipLeft - tipBox.offsetWidth;
|
|
93
|
-
}
|
|
94
|
-
return tipLeft + "px";
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const ellipsis = function (el, defaultLine) {
|
|
98
|
-
const line = defaultLine || 1;
|
|
99
|
-
el.style.display = "-webkit-box";
|
|
100
|
-
el.style.webkitLineClamp = line;
|
|
101
|
-
el.style.webkitBoxOrient = "vertical";
|
|
102
|
-
el.style.textOverflow = "ellipsis";
|
|
103
|
-
el.style.overflow = "hidden";
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const show = function (tipBox) {
|
|
107
|
-
tipBox.style.display = "block";
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const hidden = function (tipBox) {
|
|
111
|
-
tipBox.style.display = "none";
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const contentText = function (tipBox, content) {
|
|
115
|
-
tipBox.innerText = content;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const ellipsisTip = function (el: HTMLElement, binding) {
|
|
119
|
-
const line = (binding.value && binding.value.defaultLine) || 1;
|
|
120
|
-
const textWidth = calcTextWidth(el);
|
|
121
|
-
const parentWidth = calcParentWidth(el);
|
|
122
|
-
el.style.whiteSpace = "normal";
|
|
123
|
-
if (textWidth > parentWidth * line) {
|
|
124
|
-
ellipsis(el, line);
|
|
125
|
-
const tipBox = singleTipBox(500);
|
|
126
|
-
const arrowEle = createArrow();
|
|
127
|
-
|
|
128
|
-
el.addEventListener("mousemove", (event) => {
|
|
129
|
-
contentText(
|
|
130
|
-
tipBox,
|
|
131
|
-
(binding.value && binding.value.content) || el.innerText
|
|
132
|
-
);
|
|
133
|
-
tipBox.appendChild(arrowEle);
|
|
134
|
-
show(tipBox);
|
|
135
|
-
el.style.cursor = "pointer";
|
|
136
|
-
tipBox.style.top = calcTipTop(el, tipBox);
|
|
137
|
-
tipBox.style.left = calcTopLeft(event, tipBox);
|
|
138
|
-
setArrowStyle(event, arrowEle, tipBox);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
el.addEventListener("mouseout", (event) => {
|
|
142
|
-
hidden(tipBox);
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
Vue.directive("ellipsis-tip", {
|
|
148
|
-
bind: function (el, binding, vnode) {
|
|
149
|
-
window.addEventListener("resize", () => ellipsisTip(el, binding));
|
|
150
|
-
},
|
|
151
|
-
inserted: function (el, binding, vnode) {
|
|
152
|
-
ellipsisTip(el, binding);
|
|
153
|
-
},
|
|
154
|
-
componentUpdated(el, binding) {
|
|
155
|
-
ellipsisTip(el, binding);
|
|
156
|
-
},
|
|
157
|
-
unbind(el, binding) {
|
|
158
|
-
window.removeEventListener("resize", () => ellipsisTip(el, binding));
|
|
159
|
-
},
|
|
160
|
-
});
|