Обратная связь готова

This commit is contained in:
iriska-gri committed 2023-09-12 16:48:57 +03:00
1 parent fd2309c154
commit 0a9601629c
5 files changed
+34 -28

No files matched your search

BIN
View File
Binary file not shown.
+3 -1
View File
@@ -12,9 +12,11 @@ class RatingStatusSerializer(serializers.ModelSerializer):
class BaseCriteriaSerializer(serializers.ModelSerializer): class BaseCriteriaSerializer(serializers.ModelSerializer):
get_criteria = RatingStatusSerializer(many=True)
class Meta: class Meta:
model = BaseCriteria model = BaseCriteria
fields = '__all__' fields = ['id', 'name', 'ico', 'rating', 'color', 'get_criteria']
class UserCommentSerializer(serializers.ModelSerializer): class UserCommentSerializer(serializers.ModelSerializer):
+6 -1
View File
@@ -11,8 +11,13 @@ from .models import *
class BaseCriteriaAPI(ListAPIView): class BaseCriteriaAPI(ListAPIView):
queryset = BaseCriteria.objects.all() print('-----------Отправляю GET запрос в таблицу BaseCriteria-----------')
serializer_class = BaseCriteriaSerializer serializer_class = BaseCriteriaSerializer
queryset = BaseCriteria.objects.all()
class UserCommentAPI(ListCreateAPIView): class UserCommentAPI(ListCreateAPIView):
+18 -24
View File
@@ -51,14 +51,14 @@
</v-container> </v-container>
</v-card-text> </v-card-text>
<v-card-actions class="pt-0"> <v-card-actions class="pt-0">
<!-- <my-helper
:pretext="t_userComment"
/> -->
<small v-if="average < 5 || comment.length > 0" class="pl-5"> <small v-if="average < 5 || comment.length > 0" class="pl-5">
Вы оценили сайт на <span class="font-weight-black">{{average}}</span> {{myLabel()}} Вы оценили сайт на <span class="font-weight-black">{{average}}</span> {{myLabel()}}
</small> </small>
<v-spacer/> <v-spacer/>
<v-btn <v-btn
color="blue-darken-1" color="blue-darken-1"
variant="text" variant="text"
text="Закрыть" text="Закрыть"
@@ -68,15 +68,9 @@
color="blue-darken-1" color="blue-darken-1"
variant="text" variant="text"
:text="t_userComment.length==0?'Отправить':'Обновить'" :text="t_userComment.length==0?'Отправить':'Обновить'"
@click="proba" @click="feedSend"
/> />
<!-- <v-btn
v-else
color="blue-darken-1"
variant="text"
text="Обновить"
@click="proba"
/> -->
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</template> </template>
@@ -96,33 +90,31 @@ export default {
setup(props, context) { setup(props, context) {
const comment = ref("") const comment = ref("")
const t_baseCriteria = ref([]) const t_baseCriteria = ref([])
const tab_userComment = ref([])
const t_userComment = ref([]) const t_userComment = ref([])
function f_baseCriteria() { function f_baseCriteria() {
axiosApiInstance.get('api/feedback/baseCriteria/') axiosApiInstance.get('api/feedback/baseCriteria/')
.then(data => { .then(data => {
t_baseCriteria.value = data.data.results t_baseCriteria.value = data.data.results
t_baseCriteria.value.map(e=>
e.rating = e.get_criteria[0].rating
)
}) })
} }
function f_userComment() { function f_userComment() {
axiosApiInstance.get(`api/feedback/userComment/`) axiosApiInstance.get(`api/feedback/userComment/`)
.then(data => { .then(data => {
t_userComment.value = data.data.results t_userComment.value = data.data.results
comment.value=t_userComment.value[0].comment
}) })
} }
onMounted(() => { onMounted(() => {
f_baseCriteria() f_baseCriteria()
f_userComment() f_userComment()
}) })
const ratingStatus = computed(() => { const ratingStatus = computed(() => {
const decFeed = [] const decFeed = []
t_baseCriteria.value.map(e => t_baseCriteria.value.map(e =>
@@ -157,22 +149,24 @@ export default {
context.emit('menusClose') context.emit('menusClose')
} }
function proba() { function feedSend() {
const feedObj = {} const feedObj = {}
feedObj.comment = comment.value feedObj.comment = comment.value
feedObj.ratingstatus = ratingStatus.value.decFeed feedObj.ratingstatus = ratingStatus.value.decFeed
if (t_userComment.value.length==0) { if (t_userComment.value.length==0) {
axiosApiInstance.post(`api/feedback/userComment/`, feedObj) axiosApiInstance.post(`api/feedback/userComment/`, feedObj).then(data => {
console.log(data);
})
} }
else { else {
axiosApiInstance.put(`api/feedback/userCommentUp/${t_userComment.value[0].id}/`, feedObj) axiosApiInstance.put(`api/feedback/userCommentUp/${t_userComment.value[0].id}/`, feedObj).then(data => {
console.log(data);
} }
f_userComment() )}
console.log(t_userComment.value, '111111111111111111111111111111'); menusCloses()
} }
return {t_baseCriteria, t_userComment, tab_userComment, comment, average, menusCloses, myLabel, proba} return {t_baseCriteria, t_userComment, comment, average, menusCloses, myLabel, feedSend}
} }
+7 -2
View File
@@ -50,7 +50,8 @@
</template> </template>
<script> <script>
import {useAppStore} from '@/store/app' import { ref, onMounted, computed } from 'vue'
import {useAppStore} from '@/store/app'
import {useAccountStore} from '@/store/AccountStore' import {useAccountStore} from '@/store/AccountStore'
import {pagecounter} from '@/utils/universal_functions' import {pagecounter} from '@/utils/universal_functions'
import NewsList from '@/components/news-list.vue' import NewsList from '@/components/news-list.vue'
@@ -68,8 +69,12 @@ import {useAppStore} from '@/store/app'
}, },
setup(){ setup(){
const appStore = useAppStore() onMounted(() => {
pagecounter() pagecounter()
})
const appStore = useAppStore()
const model= null const model= null
const accountStore = useAccountStore() const accountStore = useAccountStore()