fix[design]: 在创建页面添加保存提示

- 增加 Dialog 取提示是否保存
- 去除多余的 watch 导入
This commit is contained in:
Huangzhe
2025-03-25 13:55:32 +08:00
parent e6dcbfbba9
commit 64589679c8
3 changed files with 36 additions and 23 deletions

View File

@@ -2,14 +2,8 @@
<div class="common-layout container">
<!-- title 标题和搜索栏 -->
<header class="header">
<van-nav-bar
class="navbar-header"
:title="$route.meta.title"
left-arrow
safe-area-inset-top
:border="false"
@click-left="goBack"
>
<van-nav-bar class="navbar-header" :title="$route.meta.title" left-arrow safe-area-inset-top :border="false"
@click-left="goBack">
<template #left>
<van-icon name="left-long" class-prefix="mobilefont" size="18" style="color: #fff" />
</template>
@@ -25,10 +19,25 @@
<script setup>
import { RouterView, useRouter, useRoute } from 'vue-router';
import appBridge from '@/assets/js/appBridge';
// import { Dialog } from 'vant';
const route = useRoute();
const router = useRouter();
function goBack() {
function goBack () {
// 查看当前路由, 如果路由是 create则提示是否保存
// if (route.name === 'create') {
// Dialog.confirm({
// title: '提示',
// message: '是否保存问卷',
// // confirmButtonText: '保存',
// // cancelButtonText: '不保存'
// }).then(() => {
// // on confirm
// }).catch(() => {
// // on cancel
// });
// }
setTimeout(() => {
if (window.history.length > 1 && route.name !== 'home') {
router.go(-1);

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, onMounted, ref, useTemplateRef, onUnmounted, watch } from 'vue';
import { computed, onMounted, ref, useTemplateRef, onUnmounted } from 'vue';
import { useRoute } from 'vue-router';
import { showConfirmDialog } from 'vant';

View File

@@ -65,7 +65,7 @@
>
<template #button="{ item }">
<div v-if="activeId === item.id" class="design-button">
<van-button size="small" @click="show = true"> + 添加题目 </van-button>
<van-button size="small" @click="show = true"> + 添加题目</van-button>
</div>
</template>
@@ -204,7 +204,7 @@
:min="1"
@blur="saveSetting"
>
<template #right-icon> </template>
<template #right-icon> </template>
</van-field>
</van-cell-group>
</van-cell-group>
@@ -303,7 +303,7 @@
input-align="right"
@blur="saveSetting"
>
<template #right-icon> </template>
<template #right-icon> </template>
</van-field>
</van-cell-group>
<van-cell title="设备答题次数限制" class="border-bottom" :border="false" label-align="left">
@@ -332,7 +332,7 @@
input-align="right"
@blur="saveSetting"
>
<template #right-icon> </template>
<template #right-icon> </template>
</van-field>
</van-cell-group>
</van-cell-group>
@@ -359,18 +359,18 @@
<script setup lang="ts">
import emptyImage from '@/assets/img/empty.png';
import { ref, computed, onMounted, watch, onBeforeMount } from 'vue';
import { computed, onBeforeMount, onMounted, ref, watch } from 'vue';
import * as Base64 from 'js-base64';
import {
changeStatus,
getSetting,
saveQuestions,
saveQuestion,
snQuestions,
sync,
saveSettings,
saveProjectName,
getSurveysDetail,
changeStatus
saveProjectName,
saveQuestion,
saveQuestions,
saveSettings,
snQuestions,
sync
} from '@/api/design/index';
import { getFormattedTime } from '@/utils/utils';
import Design from '@/views/Design/Index.vue';
@@ -381,7 +381,7 @@ import { basicQuesTypeList } from '@/utils/common';
import { useRoute, useRouter } from 'vue-router';
import YLPicker from '@/components/YLPicker.vue';
import { getPages } from '@/utils/public';
import { showConfirmDialog, showFailToast, showToast, Toast } from 'vant';
import { showConfirmDialog, showFailToast, showToast } from 'vant';
// 获取 Store 实例
const counterStore = useCounterStore();
@@ -877,6 +877,7 @@ onBeforeMount(() => {
height: 30px;
line-height: 30px;
}
:deep(.introduction) {
overflow: auto;
width: 230px;
@@ -1074,8 +1075,10 @@ onBeforeMount(() => {
:deep(.van-cell) {
padding: 8px;
}
.line-border {
position: relative;
&::after {
content: '';
position: absolute;
@@ -1085,6 +1088,7 @@ onBeforeMount(() => {
transform: scaleY(0.5);
}
}
.survey-action {
position: fixed;
z-index: 1;