diff --git a/components.d.ts b/components.d.ts index d721417..7b3424c 100644 --- a/components.d.ts +++ b/components.d.ts @@ -17,6 +17,7 @@ declare module 'vue' { ElDropdown: typeof import('element-plus/es')['ElDropdown'] ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem'] ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu'] + ElEmpty: typeof import('element-plus/es')['ElEmpty'] ElIcon: typeof import('element-plus/es')['ElIcon'] ElInput: typeof import('element-plus/es')['ElInput'] ElOption: typeof import('element-plus/es')['ElOption'] @@ -59,6 +60,8 @@ declare module 'vue' { VanStepper: typeof import('vant/es')['Stepper'] VanSwitch: typeof import('vant/es')['Switch'] VanTab: typeof import('vant/es')['Tab'] + VanTabbar: typeof import('vant/es')['Tabbar'] + VanTabbarItem: typeof import('vant/es')['TabbarItem'] VanTabs: typeof import('vant/es')['Tabs'] VanTag: typeof import('vant/es')['Tag'] YLCascader: typeof import('./src/components/YLCascader.vue')['default'] diff --git a/public/tabbar/home.png b/public/tabbar/home.png new file mode 100644 index 0000000..6d181be Binary files /dev/null and b/public/tabbar/home.png differ diff --git a/public/tabbar/mine.png b/public/tabbar/mine.png new file mode 100644 index 0000000..15c4ad3 Binary files /dev/null and b/public/tabbar/mine.png differ diff --git a/public/tabbar/yl.png b/public/tabbar/yl.png new file mode 100644 index 0000000..244aea3 Binary files /dev/null and b/public/tabbar/yl.png differ diff --git a/src/components/MarketItem/MarketItem.vue b/src/components/MarketItem/MarketItem.vue index 80bc7db..b307303 100644 --- a/src/components/MarketItem/MarketItem.vue +++ b/src/components/MarketItem/MarketItem.vue @@ -1,54 +1,51 @@ @@ -135,13 +132,15 @@ onMounted(() => { \ No newline at end of file diff --git a/src/views/Survey/components/SuvreyItem.vue b/src/views/Survey/components/SuvreyItem.vue new file mode 100644 index 0000000..42f0070 --- /dev/null +++ b/src/views/Survey/components/SuvreyItem.vue @@ -0,0 +1,339 @@ + + + + + \ No newline at end of file diff --git a/src/views/Survey/hooks/useSurveyData.ts b/src/views/Survey/hooks/useSurveyData.ts new file mode 100644 index 0000000..09fdf0e --- /dev/null +++ b/src/views/Survey/hooks/useSurveyData.ts @@ -0,0 +1,95 @@ +import { + getSurveysPage, deleteSurveys, + saveTemplates +} from '@/api/home'; +import { ref } from 'vue'; +import { + showDialog, + showConfirmDialog, + showFailToast, + showToast +} from 'vant'; + +const form = ref({ + page: 0, + pageSize: 10, + project_name: '' +}); + +const searchValue = ref(''); +const survey = ref([]); +const total = ref(0); +const loading = ref(false); +const finished = ref(false); + +async function fetchSurveys() { + const params = { + page: form.value.page, + per_page: form.value.pageSize, + group_id: 0, + project_name: searchValue.value + }; + const res = await getSurveysPage(params); + if (res.data.code === 0) { + survey.value = survey.value.concat(res.data.data); + total.value = res.data.meta.total; + survey.value.forEach((item) => { + const sceneName = JSON.parse(JSON.stringify(item.scene_name)); + const nameList = sceneName.split('-'); + if (nameList.length > 0) { + item.scene_name = nameList[1] ? nameList[1] : nameList[0]; + } + + const timeList = item.created_at.split(' '); + if (nameList.length) { + item.created_at = timeList[0]; + } + }); + loading.value = false; + // 数据全部加载完成 + if (survey.value.length >= total.value) { + finished.value = true; + } + } else { + // Toast() + } +}; + +function deleteItem(item) { + showDialog({ + title: `确认删除问卷${item.project_name} ?`, + showCancelButton: true, + confirmButtonColor: '#03B03C' + }) + .then(async () => { + const res = await deleteSurveys(item.sn); + if (res.data.message) { + showToast(res.data.message); + } else { + showToast('删除成功!'); + } + form.value.page = 1; + survey.value = []; + await fetchSurveys(); + }) + .catch(() => { + // on cancel + }); +}; + +// 保存为模板 +async function saveTemplate(item) { + const data = JSON.parse(JSON.stringify(item)); + const res = await saveTemplates(item.sn, data); + if (res.data.code === 200 || res.data.code === 201) { + showConfirmDialog({ + message: '模板保存成功,请前往模板市场查看!', + showCancelButton: false + }); + } else { + showFailToast(res.data); + } +} +; + +export { form, fetchSurveys, loading, finished, survey, total, searchValue, deleteItem, saveTemplate }; \ No newline at end of file diff --git a/src/views/Survey/types/survey.d.ts b/src/views/Survey/types/survey.d.ts new file mode 100644 index 0000000..1839f39 --- /dev/null +++ b/src/views/Survey/types/survey.d.ts @@ -0,0 +1,18 @@ +type SurveyItem = { + scene_name: string + project_name: string + created_at: string + created_user?: string + scene_code_info?: number + owner?: string + source?: number + status?: number + answer_num?: number | string + recycle_progress?: string + recycle_time?: string + sn: string + is_time?: boolean + start_time?: string + end_time?: string | null + status_txt?: string +} \ No newline at end of file