Запись в бд
This commit is contained in:
1 parent
d4099e264d
commit
bc26a6a50d
4 files changed
+83
-25
No files matched your search
@@ -7,12 +7,12 @@
|
||||
<v-container>
|
||||
<v-row>
|
||||
<v-col class="flex-grow-0 py-0 text-no-wrap align-self-center text-button">
|
||||
Оцените сайт
|
||||
Оцените сайт
|
||||
</v-col>
|
||||
<v-divider/>
|
||||
</v-row>
|
||||
<v-row
|
||||
v-for="(x, key) in tab_baseCriteria"
|
||||
v-for="(x, key) in t_baseCriteria"
|
||||
:key = key
|
||||
>
|
||||
<v-col class="flex-grow-0 pb-0">
|
||||
@@ -52,6 +52,7 @@
|
||||
</v-card-text>
|
||||
<v-card-actions class="pt-0">
|
||||
<small v-if="average < 5 || comment.length > 0" class="pl-5">
|
||||
|
||||
Вы оценили сайт на <span class="font-weight-black">{{average}}</span> {{myLabel()}}
|
||||
</small>
|
||||
<v-spacer/>
|
||||
@@ -74,7 +75,7 @@
|
||||
color="blue-darken-1"
|
||||
variant="text"
|
||||
text="Обновить"
|
||||
@click="feedAll"
|
||||
@click="proba"
|
||||
/>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
@@ -94,30 +95,43 @@ export default {
|
||||
|
||||
setup(props, context) {
|
||||
const comment = ref("")
|
||||
const tab_baseCriteria = ref([])
|
||||
const t_baseCriteria = ref([])
|
||||
const tab_userComment = ref([])
|
||||
const t_userComment = ref([])
|
||||
|
||||
onMounted(() => {
|
||||
axiosApiInstance.get('api/feedback/formfeed/')
|
||||
.then(data => {
|
||||
tab_baseCriteria.value = data.data.baseCriteria
|
||||
tab_userComment.value = data.data.userComment
|
||||
}
|
||||
)
|
||||
|
||||
axiosApiInstance.get('api/feedback/baseCriteria/')
|
||||
.then(data => {
|
||||
t_baseCriteria.value = data.data.results
|
||||
})
|
||||
|
||||
axiosApiInstance.get(`api/feedback/userComment/`)
|
||||
.then(data => {
|
||||
t_userComment.value = data.data.results
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
function feedAll() {
|
||||
const feedObj = {}
|
||||
// feedObj.ratingstatus = ratingStatus.value.decFeed
|
||||
feedObj.ratingstatus = ratingStatus.value.decFeed
|
||||
feedObj.comment = comment.value
|
||||
axiosApiInstance.post('api/feedback/comment/', feedObj)
|
||||
axiosApiInstance.post('api/feedback/formfeed/', feedObj)
|
||||
comment.value=""
|
||||
tab_baseCriteria.value.map(e=>e.rating=5)
|
||||
t_baseCriteria.value.map(e=>e.rating=5)
|
||||
}
|
||||
|
||||
function feedUp() {
|
||||
const feedObj = {}
|
||||
feedObj.comment = comment.value
|
||||
feedObj.ratingstatus = ratingStatus.value.decFeed
|
||||
axiosApiInstance.put('api/feedback/formupdate/', feedObj)
|
||||
}
|
||||
|
||||
const ratingStatus = computed(() => {
|
||||
const decFeed = []
|
||||
tab_baseCriteria.value.map(e =>
|
||||
t_baseCriteria.value.map(e =>
|
||||
{
|
||||
const { id, rating } = {...e}
|
||||
decFeed.push({id:id, rating:rating})
|
||||
@@ -126,8 +140,8 @@ export default {
|
||||
});
|
||||
|
||||
const average = computed(()=> {
|
||||
const sum = tab_baseCriteria.value.reduce((total, obj)=> total + obj.rating, 0)
|
||||
const sumlen = sum/tab_baseCriteria.value.length
|
||||
const sum = t_baseCriteria.value.reduce((total, obj)=> total + obj.rating, 0)
|
||||
const sumlen = sum/t_baseCriteria.value.length
|
||||
const ukr = Number.isInteger(sumlen)?sumlen:sumlen.toFixed(1)
|
||||
return ukr
|
||||
})
|
||||
@@ -149,7 +163,15 @@ export default {
|
||||
context.emit('menusClose')
|
||||
}
|
||||
|
||||
return {tab_baseCriteria, tab_userComment, comment, average, feedAll, menusCloses, myLabel}
|
||||
function proba() {
|
||||
const feedObj = {}
|
||||
|
||||
feedObj.comment = comment.value
|
||||
axiosApiInstance.post(`api/feedback/userComment/`, feedObj)
|
||||
// console.log(t_userComment.value, 't_userComment.value');
|
||||
}
|
||||
|
||||
return {t_baseCriteria, tab_userComment, comment, average, feedAll, feedUp, menusCloses, myLabel, proba}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user