Причесаная форма обратной связи
This commit is contained in:
1 parent
75bbe7c97e
commit
6d3adbb54c
6 files changed
+44
-137
No files matched your search
@@ -12,7 +12,7 @@
|
||||
<v-divider/>
|
||||
</v-row>
|
||||
<v-row
|
||||
v-for="(x, key) in t_baseCriteria"
|
||||
v-for="(x, key) in feedbackdata.basecrit"
|
||||
:key = key
|
||||
>
|
||||
<v-col class="flex-grow-0 pb-0">
|
||||
@@ -27,7 +27,7 @@
|
||||
</v-col>
|
||||
<v-col class="py-0">
|
||||
<v-rating
|
||||
v-model="x.rating"
|
||||
v-model="feedbackdata.nowrating[key].rating"
|
||||
hover
|
||||
half-increments
|
||||
size="small"
|
||||
@@ -44,17 +44,14 @@
|
||||
variant="outlined"
|
||||
rows="5"
|
||||
row-height="15"
|
||||
v-model="comment"
|
||||
v-model="feedbackdata.nowcomment.comment"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</v-card-text>
|
||||
<v-card-actions class="pt-0">
|
||||
<my-helper
|
||||
:pretext="t_baseCriteria"
|
||||
/>
|
||||
<small v-if="average < 5 || comment.length > 0" class="pl-5">
|
||||
<small v-if="average < 5 || feedbackdata.nowcomment.id!=null" class="pl-5">
|
||||
Вы оценили сайт на <span class="font-weight-black">{{average}}</span> {{myLabel()}}
|
||||
</small>
|
||||
<v-spacer/>
|
||||
@@ -67,7 +64,7 @@
|
||||
<v-btn
|
||||
color="blue-darken-1"
|
||||
variant="text"
|
||||
:text="t_userComment.length==0?'Отправить':'Обновить'"
|
||||
:text="feedbackdata.nowcomment.id==null?'Отправить':'Обновить'"
|
||||
@click="feedSend"
|
||||
/>
|
||||
|
||||
@@ -80,6 +77,7 @@ import { ref, onMounted, computed } from 'vue'
|
||||
import { axiosApiInstance } from '@/utils/axios-api'
|
||||
|
||||
export default {
|
||||
|
||||
props: {
|
||||
LikeDialog: {
|
||||
type: Boolean,
|
||||
@@ -88,48 +86,30 @@ export default {
|
||||
},
|
||||
|
||||
setup(props, context) {
|
||||
const comment = ref("")
|
||||
const t_baseCriteria = ref([])
|
||||
const t_userComment = ref([])
|
||||
const feedbackdata= ref({nowcomment: {comment: '' }, nowrating: []})
|
||||
|
||||
function f_baseCriteria() {
|
||||
axiosApiInstance.get('api/feedback/baseCriteria/')
|
||||
.then(data => {
|
||||
t_baseCriteria.value = data.data.results
|
||||
console.log(data.data, 'gdgdgddgdg');
|
||||
t_baseCriteria.value.map(e=>
|
||||
console.log(e,'e')
|
||||
// e.rating = e.get_criteria[0].rating
|
||||
)
|
||||
})
|
||||
function f_feedbackdata() {
|
||||
axiosApiInstance.get('api/feedback/feedbackdata/')
|
||||
.then(data => {
|
||||
feedbackdata.value = data.data
|
||||
if (feedbackdata.value.nowrating.length == 0) {
|
||||
for (let x of feedbackdata.value.basecrit) {
|
||||
feedbackdata.value.nowrating.push({rating: x.rating, crit: x.id, id: null})
|
||||
}
|
||||
}
|
||||
|
||||
function f_userComment() {
|
||||
axiosApiInstance.get(`api/feedback/userComment/`)
|
||||
.then(data => {
|
||||
t_userComment.value = data.data.results
|
||||
comment.value=t_userComment.value[1].comment
|
||||
})
|
||||
}
|
||||
if (feedbackdata.value.nowcomment === null) {
|
||||
feedbackdata.value.nowcomment = { comment: '', id: null}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
f_baseCriteria()
|
||||
f_userComment()
|
||||
f_feedbackdata()
|
||||
})
|
||||
|
||||
const ratingStatus = computed(() => {
|
||||
const decFeed = []
|
||||
t_baseCriteria.value.map(e =>
|
||||
{
|
||||
const { id, rating } = {...e}
|
||||
decFeed.push({crit_id:id, rating:rating})
|
||||
});
|
||||
return { decFeed }
|
||||
});
|
||||
|
||||
const average = computed(()=> {
|
||||
const sum = t_baseCriteria.value.reduce((total, obj)=> total + obj.rating, 0)
|
||||
const sumlen = sum/t_baseCriteria.value.length
|
||||
const sum = feedbackdata.value.nowrating.reduce((total, obj)=> total + obj.rating, 0)
|
||||
const sumlen = sum/feedbackdata.value.nowrating.length
|
||||
const ukr = Number.isInteger(sumlen)?sumlen:sumlen.toFixed(1)
|
||||
return ukr
|
||||
})
|
||||
@@ -152,23 +132,11 @@ export default {
|
||||
}
|
||||
|
||||
function feedSend() {
|
||||
const feedObj = {}
|
||||
feedObj.comment = comment.value
|
||||
feedObj.ratingstatus = ratingStatus.value.decFeed
|
||||
if (t_userComment.value.length==0) {
|
||||
axiosApiInstance.post(`api/feedback/userComment/`, feedObj).then(data => {
|
||||
console.log(data);
|
||||
})
|
||||
}
|
||||
else {
|
||||
axiosApiInstance.put(`api/feedback/userCommentUp/${t_userComment.value[0].id}/`, feedObj).then(data => {
|
||||
console.log(data);
|
||||
}
|
||||
)}
|
||||
menusCloses()
|
||||
axiosApiInstance.post(`api/feedback/feedbackdata/`, {nowrating : feedbackdata.value.nowrating, nowcomment: feedbackdata.value.nowcomment} ).then(data => {})
|
||||
menusCloses()
|
||||
}
|
||||
|
||||
return {t_baseCriteria, t_userComment, comment, average, menusCloses, myLabel, feedSend}
|
||||
return {feedbackdata, average, menusCloses, myLabel, feedSend}
|
||||
|
||||
}
|
||||
|
||||
@@ -184,7 +152,6 @@ export default {
|
||||
.v-selection-control__input {
|
||||
width: 46%!important;
|
||||
height: 46%!important;
|
||||
|
||||
border-radius: 0!important;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user