refactor: 优化问卷列表页面功能
1. 修复用户名字段显示问题,从created_user改为creater_user 2. 优化日期显示,只显示年月日 3. 修复搜索功能,修正关键字参数为key_word 4. 优化空状态组件交互逻辑 5. 改进分页加载逻辑
This commit is contained in:
@@ -12,11 +12,11 @@ const survey = defineModel<object>('survey', { required: true });
|
|||||||
<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>
|
||||||
|
|||||||
@@ -11,16 +11,12 @@
|
|||||||
<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';
|
|
||||||
|
|
||||||
const route = useRoute();
|
|
||||||
|
|
||||||
// console.log(route.name);
|
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
function create() {
|
function create() {
|
||||||
show.value = true;
|
show.value = true;
|
||||||
}
|
}
|
||||||
const show = ref(false);
|
const show = defineModel('show', { type: Boolean, default: false });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@@ -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