refactor: 优化问卷列表页面功能
1. 修复用户名字段显示问题,从created_user改为creater_user 2. 优化日期显示,只显示年月日 3. 修复搜索功能,修正关键字参数为key_word 4. 优化空状态组件交互逻辑 5. 改进分页加载逻辑
This commit is contained in:
@@ -1,35 +1,35 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { FcClock, FcBusinessman } from 'vue-icons-plus/fc';
|
import { FcClock, FcBusinessman } from 'vue-icons-plus/fc';
|
||||||
import clock from '@/assets/img/search/clock.svg';
|
import clock from '@/assets/img/search/clock.svg';
|
||||||
import people from '@/assets/img/search/people.svg';
|
import people from '@/assets/img/search/people.svg';
|
||||||
|
|
||||||
const survey = defineModel<object>('survey', { required: true });
|
const survey = defineModel<object>('survey', { required: true });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<h3>{{ survey.project_name }}</h3>
|
<h3>{{ survey.project_name }}</h3>
|
||||||
<el-space spacer="|" direction="horizontal">
|
<el-space spacer="|" direction="horizontal">
|
||||||
<section class="flex items-center pt-1">
|
<section class="flex items-center pt-1">
|
||||||
<img :src="people" alt="" style="margin-right: 5px" />
|
<img :src="people" alt="" style="margin-right: 5px" />
|
||||||
<el-text>{{ survey.created_user }}</el-text>
|
<el-text>{{ survey.creater_user }}</el-text>
|
||||||
</section>
|
</section>
|
||||||
<section class="flex items-center pt-1">
|
<section class="flex items-center pt-1">
|
||||||
<img :src="clock" alt="" style="margin-right: 5px" />
|
<img :src="clock" alt="" style="margin-right: 5px" />
|
||||||
<el-text>创建时间{{ survey.created_at }}</el-text>
|
<el-text>创建时间{{ survey.created_at.split(' ')[0] }}</el-text>
|
||||||
</section>
|
</section>
|
||||||
</el-space>
|
</el-space>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped module="item">
|
<style lang="scss" scoped module="item">
|
||||||
@use '@/assets/css/theme';
|
@use '@/assets/css/theme';
|
||||||
|
|
||||||
h3 {
|
h3 {
|
||||||
margin: 10px 0 12px 0;
|
margin: 10px 0 12px 0;
|
||||||
font-weight: 800;
|
font-weight: 800;
|
||||||
line-height: 15px;
|
line-height: 15px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,38 +1,34 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="new_survey">
|
<div class="new_survey">
|
||||||
<div v-if="$route.name !== 'home'">
|
<div v-if="$route.name !== 'home'">
|
||||||
<van-popup v-model:show="show" round closeable position="bottom" teleport="#app">
|
<van-popup v-model:show="show" round closeable position="bottom" teleport="#app">
|
||||||
<create-question :createdNewPage="false"></create-question>
|
<create-question :createdNewPage="false"></create-question>
|
||||||
</van-popup>
|
</van-popup>
|
||||||
</div>
|
</div>
|
||||||
<navigation />
|
<navigation />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import CreateQuestion from '@/views/Home/components/CreateSurvey/CreateQuestion.vue';
|
import CreateQuestion from '@/views/Home/components/CreateSurvey/CreateQuestion.vue';
|
||||||
import Navigation from '@/components/Navigation/Index.vue';
|
import Navigation from '@/components/Navigation/Index.vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
const route = useRoute();
|
function create() {
|
||||||
|
show.value = true;
|
||||||
// console.log(route.name);
|
}
|
||||||
import { ref } from 'vue';
|
const show = defineModel('show', { type: Boolean, default: false });
|
||||||
function create() {
|
</script>
|
||||||
show.value = true;
|
|
||||||
}
|
<style scoped lang="scss">
|
||||||
const show = ref(false);
|
@use '@/assets/css/theme';
|
||||||
</script>
|
|
||||||
|
.new_survey {
|
||||||
<style scoped lang="scss">
|
position: fixed;
|
||||||
@use '@/assets/css/theme';
|
bottom: 50px;
|
||||||
|
left: 0;
|
||||||
.new_survey {
|
box-sizing: border-box;
|
||||||
position: fixed;
|
width: 100vw;
|
||||||
bottom: 50px;
|
border-radius: theme.$card-radius;
|
||||||
left: 0;
|
background: #fff;
|
||||||
box-sizing: border-box;
|
}
|
||||||
width: 100vw;
|
</style>
|
||||||
border-radius: theme.$card-radius;
|
|
||||||
background: #fff;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -18,15 +18,20 @@
|
|||||||
<div v-for="item in survey" v-if="survey.length > 0" :key="item" class="new-survey_item">
|
<div v-for="item in survey" v-if="survey.length > 0" :key="item" class="new-survey_item">
|
||||||
<survey-item :survey="item" :is-analysis="true" :disable-action-button="false" />
|
<survey-item :survey="item" :is-analysis="true" :disable-action-button="false" />
|
||||||
</div>
|
</div>
|
||||||
<empty-container v-else />
|
<empty-container
|
||||||
|
v-if="survey.length === 0 && !searchValue"
|
||||||
|
:img-src="emptyImg"
|
||||||
|
@handle-click="handleEmptyClick"
|
||||||
|
:show-button="true"
|
||||||
|
/>
|
||||||
|
<NewSurvey v-model:show="showModel" />
|
||||||
</van-list>
|
</van-list>
|
||||||
</div>
|
</div>
|
||||||
<NewSurvey v-if="survey.length > 0" />
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onBeforeMount, onUnmounted, ref, watch } from 'vue';
|
import { onUnmounted, ref, watch } from 'vue';
|
||||||
import NavSearch from '@/components/Search/Index.vue';
|
import NavSearch from '@/components/Search/Index.vue';
|
||||||
import NewSurvey from '@/views/Home/components/NewSurvey/index.vue';
|
import NewSurvey from '@/views/Home/components/NewSurvey/index.vue';
|
||||||
import EmptyContainer from '@/views/Survey/components/EmptyContainer.vue';
|
import EmptyContainer from '@/views/Survey/components/EmptyContainer.vue';
|
||||||
@@ -39,7 +44,9 @@ import {
|
|||||||
requestLoading,
|
requestLoading,
|
||||||
searchValue
|
searchValue
|
||||||
} from '@/views/Survey/hooks/useSurveyData';
|
} from '@/views/Survey/hooks/useSurveyData';
|
||||||
|
import emptyImg from '@/assets/img/emptyImg.png';
|
||||||
|
|
||||||
|
const showModel = ref(false);
|
||||||
// 初始化 From 内容
|
// 初始化 From 内容
|
||||||
const form = ref({
|
const form = ref({
|
||||||
page: 0,
|
page: 0,
|
||||||
@@ -47,9 +54,11 @@ const form = ref({
|
|||||||
project_name: ''
|
project_name: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
// 当搜索框内容发生变化的时候,重置 finished 状态
|
|
||||||
watch(searchValue, () => {
|
watch(searchValue, () => {
|
||||||
|
// 当搜索框内容发生变化的时候,重置 finished 状态
|
||||||
finished.value = false;
|
finished.value = false;
|
||||||
|
// 重置搜索form 数据
|
||||||
|
form.value.page = 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
const blurs = () => {
|
const blurs = () => {
|
||||||
@@ -60,19 +69,20 @@ const blurs = () => {
|
|||||||
fetchSurveys(form.value);
|
fetchSurveys(form.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
onBeforeMount(() => {
|
|
||||||
// 刚进入的时候
|
|
||||||
// handleLoadSurveys();
|
|
||||||
});
|
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
// 当组件卸载的时候,清空 survey 数据
|
// 当组件卸载的时候,清空 survey 数据
|
||||||
survey.value = [];
|
survey.value = [];
|
||||||
|
// 清空搜索的字符
|
||||||
|
searchValue.value = '';
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleLoadSurveys() {
|
async function handleLoadSurveys() {
|
||||||
|
await fetchSurveys(form.value);
|
||||||
form.value.page = form.value.page + 1;
|
form.value.page = form.value.page + 1;
|
||||||
fetchSurveys(form.value);
|
}
|
||||||
|
|
||||||
|
function handleEmptyClick() {
|
||||||
|
showModel.value = true;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, useCssModule } from 'vue';
|
import { useCssModule } from 'vue';
|
||||||
|
|
||||||
const errorMsg = defineModel<string>('errorMsg', { default: ' - 更多任务期待您的创建 - ' });
|
const errorMsg = defineModel<string>('errorMsg', { default: ' - 更多任务期待您的创建 - ' });
|
||||||
const showButton = defineModel<boolean>('showButton', { default: false });
|
const showButton = defineModel<boolean>('showButton', { default: false });
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ async function fetchSurveys(form: any) {
|
|||||||
per_page: form.pageSize,
|
per_page: form.pageSize,
|
||||||
group_id: 0,
|
group_id: 0,
|
||||||
// project_name: searchValue.value
|
// project_name: searchValue.value
|
||||||
keyword: searchValue.value
|
key_word: searchValue.value
|
||||||
};
|
};
|
||||||
const res = await getSurveysPage(params);
|
const res = await getSurveysPage(params);
|
||||||
if (res.data.code === 0) {
|
if (res.data.code === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user