OpinionText.vue
2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<template>
<div class="opinion-container">
<textarea
placeholder="请输入......"
rows="3"
maxlength="500"
@input="opinionInput"
v-model="opinion"
:validate="'email'"
/>
<el-row style="padding: 10px;background: #fafafa;">
<el-col :span="22">
<span>常用语:</span>
<el-tag
v-for="commonOpinion in approvalItem"
@click.native="choseCommonOpinion(commonOpinion)"
:key="commonOpinion"
>{{commonOpinion}}</el-tag>
</el-col>
<el-col :span="2" class="number-opinion">
<span :span="2">{{wordCount}}/500</span>
</el-col>
</el-row>
</div>
</template>
<script>
import req from "@/request.js";
export default {
name: "opinionText",
props:["procDefKey","text"],
data() {
return {
wordCount: 0,
opinion: "",
approvalItem:[],
};
},
watch: {
text: {
handler(newVal,oldVal){
this.opinion = newVal; //newVal即是instId
this.wordCount = this.opinion.length;
},
deep: true,
immediate: true
},
opinion: function(newVal,oldVal){
this.$emit("getOpinion",this.opinion);
},
},
methods: {
opinionInput() {
this.wordCount = this.opinion.length;
},
choseCommonOpinion(commonOpinion) {
this.opinion = (this.opinion += commonOpinion).substring(0, 500);
this.opinionInput();
},
getOpinion(){
return this.opinion;
}
},
created(){
let this_ =this;
this.opinion = this.text;
req.get(window.context.bpmModel + '/flow/approvalItem/v1/getApprovalByDefKeyAndTypeId?defKey='+this.procDefKey).then(function (rep) {
this_.approvalItem = rep.data;
});
}
};
</script>
<style lang="scss" scoped>
.opinion-container {
border: 1px solid #ebeef5;
}
.opinion-container > textarea {
padding: 5px;
margin-bottom: -3px;
border: none;
width: calc(100% - 10px);
resize: none;
outline: none;
}
.number-opinion {
text-align: right;
}
.el-tag {
margin-right: 7px;
height: 23px;
line-height: 21px;
color: #666;
background-color: transparent;
border-color: #ebeef5;
cursor: pointer;
}
.el-tag:hover {
border-color: #2761ff;
color: #2761ff;
}
</style>