refactor: 移除冗余代码并优化代码结构

- 删除了多处不必要的 console.log 语句
- 优化了部分组件的代码结构,提高了可读性
- 移除了未使用的变量和导入
- 统一了代码格式,提高了代码的一致性
This commit is contained in:
陈昱达
2025-03-28 13:55:36 +08:00
parent ce29be95a8
commit 9de9f64d49
13 changed files with 227 additions and 115 deletions

View File

@@ -31,10 +31,7 @@ const route = useRoute();
const router = useRouter(); const router = useRouter();
function goBack() { function goBack() {
console.log(window.history.length);
console.log(window.history.length > 1 && route.name !== 'home');
if (window.history.length > 1 && route.name !== 'home') { if (window.history.length > 1 && route.name !== 'home') {
console.log(1);
window.history.back(); window.history.back();
} else { } else {
appBridge.navigateBack(); appBridge.navigateBack();
@@ -43,7 +40,6 @@ function goBack() {
// 处理物理返回键 // 处理物理返回键
const handlePopState = () => { const handlePopState = () => {
console.log('handlePopState');
goBack(); goBack();
}; };

View File

@@ -246,9 +246,7 @@ const confirm = ({ selectedValues }) => {
emit('saveOption'); emit('saveOption');
}; };
const minVaule = (e) => { const minVaule = (e) => {
console.log(actionQuestion.value.config.max);
if (actionQuestion.value.config.max) { if (actionQuestion.value.config.max) {
console.log(111);
if (Number(e.target.value) > Number(actionQuestion.value.config.max)) { if (Number(e.target.value) > Number(actionQuestion.value.config.max)) {
actionQuestion.value.config.min = actionQuestion.value.config.max; actionQuestion.value.config.min = actionQuestion.value.config.max;
} }

View File

@@ -121,12 +121,10 @@ const actionQuestion = computed({
return props.modelValue; return props.modelValue;
}, },
set(newValue) { set(newValue) {
console.log(`newValue`, newValue);
emit('update:modelValue', newValue); emit('update:modelValue', newValue);
} }
}); });
console.log(`action question`, actionQuestion.value);
// 处理显示值如果值为0则返回空字符串以显示placeholder // 处理显示值如果值为0则返回空字符串以显示placeholder
const displayValue = (value) => { const displayValue = (value) => {
return value === 0 ? '' : Number(value); return value === 0 ? '' : Number(value);

View File

@@ -84,7 +84,6 @@ const emit = defineEmits(['updateConfig']);
watch( watch(
() => props.config, () => props.config,
(newConfig, oldValue) => { (newConfig, oldValue) => {
console.log(`value change`, newConfig.max, newConfig.min);
// 如果最低分大于最高分或者分数过大,则取消赋值 // 如果最低分大于最高分或者分数过大,则取消赋值
if (newConfig.max > MAX_NUM && newConfig.min > MAX_NUM) { if (newConfig.max > MAX_NUM && newConfig.min > MAX_NUM) {
// showToast({ // showToast({
@@ -143,7 +142,6 @@ function emitInfo() {
} }
function intervalChange(value) { function intervalChange(value) {
console.log(value);
// localConfig.value.score_interval = value === 0 ? 1 : value; // localConfig.value.score_interval = value === 0 ? 1 : value;
localConfig.value = JSON.parse(JSON.stringify(localConfig.value)); localConfig.value = JSON.parse(JSON.stringify(localConfig.value));

View File

@@ -77,7 +77,6 @@ const sortedData = computed(() => {
const otherOptions = data.value.filter((item) => { const otherOptions = data.value.filter((item) => {
return !item.is_fixed && !item.is_remove_other; return !item.is_fixed && !item.is_remove_other;
}); });
console.log([...otherOptions, ...lastOptions, ...remoteOtherOptions]);
// 顺序 剩余选项 + 置底选项 + 排他选项 // 顺序 剩余选项 + 置底选项 + 排他选项
return [...otherOptions, ...lastOptions, ...remoteOtherOptions]; return [...otherOptions, ...lastOptions, ...remoteOtherOptions];
}); });

View File

@@ -15,7 +15,6 @@ const props = defineProps<{
active: boolean; active: boolean;
}>(); }>();
const { config } = question.value; const { config } = question.value;
console.log(config);
// 答案 // 答案
const answer = ref<FileList | []>([]); const answer = ref<FileList | []>([]);

View File

@@ -42,7 +42,6 @@ const emitValue = () => {
// 组件选择 // 组件选择
const activeComponent = selectActiveComponent(); const activeComponent = selectActiveComponent();
function selectActiveComponent(): Component { function selectActiveComponent(): Component {
console.log(`question_type`, element.value.question_type);
switch (element.value.question_type) { switch (element.value.question_type) {
case 8: case 8:
return MatrixText; return MatrixText;
@@ -55,7 +54,6 @@ function selectActiveComponent(): Component {
} }
} }
console.log(`active component`, activeComponent);
// 增加 popover 的 actions // 增加 popover 的 actions
const popoverActions = [ const popoverActions = [
{ {

View File

@@ -82,8 +82,6 @@ const element = defineModel('element', {
} }
}); });
console.log(element.value, 1);
/** /**
* *
* @param index {number} 索引 * @param index {number} 索引

View File

@@ -228,7 +228,6 @@ function saveCanvasState() {
// 如果是页面刷新,则不保存状态 // 如果是页面刷新,则不保存状态
if (isPageRefresh) { if (isPageRefresh) {
console.log('页面刷新,不保存画布状态');
// 清除之前保存的状态 // 清除之前保存的状态
if (window.indexedDB) { if (window.indexedDB) {
try { try {

View File

@@ -98,7 +98,6 @@ const fetchSurveys = async () => {
if (nameList.length) { if (nameList.length) {
survey.value.created_at = timeList[0]; survey.value.created_at = timeList[0];
} }
console.log(survey.value);
} else { } else {
// Toast() // Toast()
} }

View File

@@ -634,8 +634,6 @@ let settingList = [];
const getQuestionDetail = () => { const getQuestionDetail = () => {
let sn = sessionStorage.getItem('sn'); let sn = sessionStorage.getItem('sn');
if (sn) { if (sn) {
console.log(sn, 213123);
snQuestions({ sn: sn }).then((res) => { snQuestions({ sn: sn }).then((res) => {
if (res.data) { if (res.data) {
questionInfo.value.survey = Object.assign({}, res.data.data.survey); questionInfo.value.survey = Object.assign({}, res.data.data.survey);

View File

@@ -24,7 +24,10 @@
<!-- <img :src="icon" alt="icon" />--> <!-- <img :src="icon" alt="icon" />-->
</div> </div>
</div> </div>
<div v-if="styleInfo.logo_status && styleInfo.logo_url" class="example-logo" :style="[ <div
v-if="styleInfo.logo_status && styleInfo.logo_url"
class="example-logo"
:style="[
{ {
'justify-content': 'justify-content':
styleInfo.logo_site === 1 styleInfo.logo_site === 1
@@ -39,7 +42,8 @@
!styleInfo.head_img_status && styleInfo.background_status !styleInfo.head_img_status && styleInfo.background_status
? `background-color: ${styleInfo.background_color};background-image: url(${styleInfo.background_url})` ? `background-color: ${styleInfo.background_color};background-image: url(${styleInfo.background_url})`
: '' : ''
]"> ]"
>
<img class="logo" :src="styleInfo.logo_url" alt="logo" /> <img class="logo" :src="styleInfo.logo_url" alt="logo" />
</div> </div>
@@ -47,8 +51,14 @@
<!-- eslint-disable-next-line --> <!-- eslint-disable-next-line -->
<div class="questions"> <div class="questions">
<!-- 提前终止和正常完成 --> <!-- 提前终止和正常完成 -->
<q-last v-if="page === pages.length + 1" :code="questionsData?.action?.code" :action="questionsData?.action" <q-last
:survey="questionsData?.survey" :isAnswer="isAnswer" :isTemplate="isTemplate" /> v-if="page === pages.length + 1"
:code="questionsData?.action?.code"
:action="questionsData?.action"
:survey="questionsData?.survey"
:isAnswer="isAnswer"
:isTemplate="isTemplate"
/>
<!-- 问卷名和描述 --> <!-- 问卷名和描述 -->
<!-- <q-first v-else-if="page === 0" isMobile :title="questionsData?.survey?.title" <!-- <q-first v-else-if="page === 0" isMobile :title="questionsData?.survey?.title"
:desc="questionsData?.survey?.introduction" :questions="questionsData?.questions" :isAnswer="isAnswer" :desc="questionsData?.survey?.introduction" :questions="questionsData?.questions" :isAnswer="isAnswer"
@@ -60,8 +70,13 @@
:questionType="question.question_type" :questionIndex="question.question_index" :questionType="question.question_type" :questionIndex="question.question_index"
:showTitle="styleInfo.is_question_number && true" isMobile :isAnswer="isAnswer"> --> :showTitle="styleInfo.is_question_number && true" isMobile :isAnswer="isAnswer"> -->
<div v-for="question in questions" v-else :id="'questionIndex' + question.question_index" <div
:key="question.question_index" class="question"> v-for="question in questions"
v-else
:id="'questionIndex' + question.question_index"
:key="question.question_index"
class="question"
>
<!-- <q-radio--> <!-- <q-radio-->
<!-- v-if="question.question_type === 1"--> <!-- v-if="question.question_type === 1"-->
<!-- :list="question.list"--> <!-- :list="question.list"-->
@@ -77,17 +92,37 @@
<!-- :question="question"--> <!-- :question="question"-->
<!-- />--> <!-- />-->
<!-- 单选题 --> <!-- 单选题 -->
<preview-choice v-if="question.question_type === 1" v-model:answer="question.answer" <preview-choice
:answerIndex="getQuestionIndex(questionsData.questions, question)" :list="question.list" v-if="question.question_type === 1"
:config="question.config" :hideOptions="question.hideOptions" :stem="question.stem" v-model:answer="question.answer"
:answerSn="questionsData.answer.sn" :answerSurveySn="questionsData.answer.survey_sn" :question="question" :answerIndex="getQuestionIndex(questionsData.questions, question)"
@previous="previous" @next="next" @change-answer="onRelation($event, question)" /> :list="question.list"
:config="question.config"
:hideOptions="question.hideOptions"
:stem="question.stem"
:answerSn="questionsData.answer.sn"
:answerSurveySn="questionsData.answer.survey_sn"
:question="question"
@previous="previous"
@next="next"
@change-answer="onRelation($event, question)"
/>
<!-- 多选题 --> <!-- 多选题 -->
<preview-checkbox v-else-if="question.question_type === 2" v-model:answer="question.answer" <preview-checkbox
:answerIndex="getQuestionIndex(questionsData.questions, question)" :list="question.list" v-else-if="question.question_type === 2"
:config="question.config" :hideOptions="question.hideOptions" :stem="question.stem" v-model:answer="question.answer"
:answerSn="questionsData.answer.sn" :answerSurveySn="questionsData.answer.survey_sn" :question="question" :answerIndex="getQuestionIndex(questionsData.questions, question)"
@change-answer="onRelation($event, question)" @previous="previous" @next="next" /> :list="question.list"
:config="question.config"
:hideOptions="question.hideOptions"
:stem="question.stem"
:answerSn="questionsData.answer.sn"
:answerSurveySn="questionsData.answer.survey_sn"
:question="question"
@change-answer="onRelation($event, question)"
@previous="previous"
@next="next"
/>
<!-- &lt;!&ndash; 级联题 &ndash;&gt;--> <!-- &lt;!&ndash; 级联题 &ndash;&gt;-->
<!-- <q-cascader--> <!-- <q-cascader-->
<!-- v-else-if="question.question_type === 3"--> <!-- v-else-if="question.question_type === 3"-->
@@ -98,19 +133,43 @@
<!-- isMobile--> <!-- isMobile-->
<!-- />--> <!-- />-->
<!-- 填空题 --> <!-- 填空题 -->
<preview-completion v-else-if="question.question_type === 4" :config="question.config" :answer="question.answer" <preview-completion
:answerIndex="getQuestionIndex(questionsData.questions, question)" :stem="question.stem" v-else-if="question.question_type === 4"
:answerSn="questionsData.answer.sn" :answerSurveySn="questionsData.answer.survey_sn" :question="question" :config="question.config"
@previous="previous" @next="next" @change-answer="onRelation($event, question)" /> :answer="question.answer"
:answerIndex="getQuestionIndex(questionsData.questions, question)"
:stem="question.stem"
:answerSn="questionsData.answer.sn"
:answerSurveySn="questionsData.answer.survey_sn"
:question="question"
@previous="previous"
@next="next"
@change-answer="onRelation($event, question)"
/>
<!-- 打分题 --> <!-- 打分题 -->
<preview-rate v-else-if="question.question_type === 5" v-model:answer="question.answer" <preview-rate
:answerIndex="getQuestionIndex(questionsData.questions, question)" :list="question.list" v-else-if="question.question_type === 5"
:config="question.config" :question="question" isMobile @change-answer="onRelation($event, question)" /> v-model:answer="question.answer"
:answerIndex="getQuestionIndex(questionsData.questions, question)"
:list="question.list"
:config="question.config"
:question="question"
isMobile
@change-answer="onRelation($event, question)"
/>
<!-- 图文说明题 --> <!-- 图文说明题 -->
<preview-text-with-images :answerIndex="getQuestionIndex(questionsData.questions, question)" <preview-text-with-images
:stem="question.stem" v-else-if="question.question_type === 6" :config="question.config" @previous="previous" :answerIndex="getQuestionIndex(questionsData.questions, question)"
@next="next" v-model:answer="question.answer" :answerSn="questionsData.answer.sn" :stem="question.stem"
:answerSurveySn="questionsData.answer.survey_sn" :question="question" /> v-else-if="question.question_type === 6"
:config="question.config"
@previous="previous"
@next="next"
v-model:answer="question.answer"
:answerSn="questionsData.answer.sn"
:answerSurveySn="questionsData.answer.survey_sn"
:question="question"
/>
<!-- &lt;!&ndash; 日期时间题 &ndash;&gt;--> <!-- &lt;!&ndash; 日期时间题 &ndash;&gt;-->
<!-- <q-date--> <!-- <q-date-->
<!-- v-else-if="question.question_type === 7"--> <!-- v-else-if="question.question_type === 7"-->
@@ -120,20 +179,45 @@
<!-- isMobile--> <!-- isMobile-->
<!-- />--> <!-- />-->
<!-- 矩阵填空题 --> <!-- 矩阵填空题 -->
<preview-matrix-text v-else-if="question.question_type === 8" v-model:answer="question.answer" <preview-matrix-text
:answerIndex="getQuestionIndex(questionsData.questions, question)" :list="question.list" v-else-if="question.question_type === 8"
:questionIndex="question.question_index" :config="question.config" :stem="question.stem" :question="question" v-model:answer="question.answer"
@previous="previous" @next="next" @change-answer="onRelation($event, question)" /> :answerIndex="getQuestionIndex(questionsData.questions, question)"
:list="question.list"
:questionIndex="question.question_index"
:config="question.config"
:stem="question.stem"
:question="question"
@previous="previous"
@next="next"
@change-answer="onRelation($event, question)"
/>
<!-- 矩阵单选题 --> <!-- 矩阵单选题 -->
<preview-matrix-radio v-else-if="question.question_type === 9" v-model:answer="question.answer" <preview-matrix-radio
:answerIndex="getQuestionIndex(questionsData.questions, question)" :list="question.list" v-else-if="question.question_type === 9"
:questionIndex="question.question_index" :config="question.config" :stem="question.stem" v-model:answer="question.answer"
:answerSn="questionsData.answer.sn" :answerSurveySn="questionsData.answer.survey_sn" :question="question" :answerIndex="getQuestionIndex(questionsData.questions, question)"
@change-answer="onRelation($event, question)" @previous="previous" @next="next" /> :list="question.list"
:questionIndex="question.question_index"
:config="question.config"
:stem="question.stem"
:answerSn="questionsData.answer.sn"
:answerSurveySn="questionsData.answer.survey_sn"
:question="question"
@change-answer="onRelation($event, question)"
@previous="previous"
@next="next"
/>
<!-- 矩阵多选题 --> <!-- 矩阵多选题 -->
<preview-matrix-checkbox v-else-if="question.question_type === 10" v-model:answer="question.answer" <preview-matrix-checkbox
:answerIndex="getQuestionIndex(questionsData.questions, question)" :list="question.list" v-else-if="question.question_type === 10"
:config="question.config" :question="question" @change-answer="onRelation($event, question)" /> v-model:answer="question.answer"
:answerIndex="getQuestionIndex(questionsData.questions, question)"
:list="question.list"
:config="question.config"
:question="question"
@change-answer="onRelation($event, question)"
/>
<!-- &lt;!&ndash; 矩阵打分题 &ndash;&gt;--> <!-- &lt;!&ndash; 矩阵打分题 &ndash;&gt;-->
<!-- <matrix-rate--> <!-- <matrix-rate-->
<!-- v-else-if="question.question_type === 11"--> <!-- v-else-if="question.question_type === 11"-->
@@ -201,10 +285,16 @@
<!-- isMobile--> <!-- isMobile-->
<!-- />--> <!-- />-->
<!-- 文件上传题 --> <!-- 文件上传题 -->
<preview-file-upload v-else-if="question.question_type === 18" v-model:answer="question.answer" <preview-file-upload
:answerIndex="getQuestionIndex(questionsData.questions, question)" :config="question.config" v-else-if="question.question_type === 18"
:question="question" isMobile :questionIndex="question.question_index" v-model:answer="question.answer"
@change-answer="onRelation($event, question)" /> :answerIndex="getQuestionIndex(questionsData.questions, question)"
:config="question.config"
:question="question"
isMobile
:questionIndex="question.question_index"
@change-answer="onRelation($event, question)"
/>
<!-- &lt;!&ndash; 地理位置题 &ndash;&gt;--> <!-- &lt;!&ndash; 地理位置题 &ndash;&gt;-->
<!-- <q-map--> <!-- <q-map-->
<!-- v-else-if="question.question_type === 19"--> <!-- v-else-if="question.question_type === 19"-->
@@ -233,9 +323,14 @@
<!-- isMobile--> <!-- isMobile-->
<!-- />--> <!-- />-->
<!-- 签名题 --> <!-- 签名题 -->
<preview-sign v-else-if="question.question_type === 22" :config="question.config" :question="question" <preview-sign
v-model:answer="question.answer" :answerIndex="getQuestionIndex(questionsData.questions, question)" v-else-if="question.question_type === 22"
@change-answer="onRelation($event, question)" /> :config="question.config"
:question="question"
v-model:answer="question.answer"
:answerIndex="getQuestionIndex(questionsData.questions, question)"
@change-answer="onRelation($event, question)"
/>
<!-- &lt;!&ndash; 知情同意书 &ndash;&gt;--> <!-- &lt;!&ndash; 知情同意书 &ndash;&gt;-->
<!-- <q-consent--> <!-- <q-consent-->
<!-- v-else-if="question.question_type === 23"--> <!-- v-else-if="question.question_type === 23"-->
@@ -359,12 +454,26 @@
<!-- :question="question"--> <!-- :question="question"-->
<!-- />--> <!-- />-->
<!-- &lt;!&ndash; 高级题型-NPS &ndash;&gt;--> <!-- &lt;!&ndash; 高级题型-NPS &ndash;&gt;-->
<preview-n-p-s v-else-if="question.question_type === 106" v-model:answer="question.answer" <preview-n-p-s
:answerIndex="getQuestionIndex(questionsData.questions, question)" :isPreview="isPreview" v-else-if="question.question_type === 106"
:title="question.title" :stem="question.stem" :list="question.list" :config="question.config" v-model:answer="question.answer"
:isAnswer="isAnswer" :questionIndex="question.question_index" :label="question.title" :loading="loading" :answerIndex="getQuestionIndex(questionsData.questions, question)"
:isTemplate="isTemplate" :showTitle="styleInfo.is_question_number" :question="question" @previous="previous" :isPreview="isPreview"
@next="next" @change-answer="onRelation($event, question)" /> :title="question.title"
:stem="question.stem"
:list="question.list"
:config="question.config"
:isAnswer="isAnswer"
:questionIndex="question.question_index"
:label="question.title"
:loading="loading"
:isTemplate="isTemplate"
:showTitle="styleInfo.is_question_number"
:question="question"
@previous="previous"
@next="next"
@change-answer="onRelation($event, question)"
/>
</div> </div>
<!-- <LangTranslate v-if="isAnswer && styleInfo.is_yip" translate-key="PoweredByDigitalTechnologyCenterYIP" <!-- <LangTranslate v-if="isAnswer && styleInfo.is_yip" translate-key="PoweredByDigitalTechnologyCenterYIP"
@@ -375,14 +484,33 @@
</div> </div>
<!-- 分页 --> <!-- 分页 -->
<!-- eslint-disable max-len --> <!-- eslint-disable max-len -->
<pfe-pagination v-if="isPreview" class="pagination" :isPreview="isPreview" :page="page" :pages="pages.length + 1" <pfe-pagination
:min="styleInfo.is_home ? 0 : 1" :loading="loading" :showPrevious="styleInfo.is_up_button" v-if="isPreview"
:showStart="styleInfo.is_start_button" :startText="styleInfo.start_button_text" class="pagination"
:showSubmit="styleInfo.is_submit_button" :submitText="localPageTimer.is_show && localPageTimer.short_time :isPreview="isPreview"
:page="page"
:pages="pages.length + 1"
:min="styleInfo.is_home ? 0 : 1"
:loading="loading"
:showPrevious="styleInfo.is_up_button"
:showStart="styleInfo.is_start_button"
:startText="styleInfo.start_button_text"
:showSubmit="styleInfo.is_submit_button"
:submitText="
localPageTimer.is_show && localPageTimer.short_time
? `${localPageTimer.short_time}S` ? `${localPageTimer.short_time}S`
: styleInfo.submit_button_text : styleInfo.submit_button_text
" :buttonTextColor="styleInfo.button_text_color" :buttonColor="styleInfo.button_color" :nextText="localPageTimer.is_show && localPageTimer.short_time ? `${localPageTimer.short_time}S` : '' "
" :nextDisabled="localPageTimer.short_time" isMobile @previous="previous" @next="next"> :buttonTextColor="styleInfo.button_text_color"
:buttonColor="styleInfo.button_color"
:nextText="
localPageTimer.is_show && localPageTimer.short_time ? `${localPageTimer.short_time}S` : ''
"
:nextDisabled="localPageTimer.short_time"
isMobile
@previous="previous"
@next="next"
>
</pfe-pagination> </pfe-pagination>
</div> </div>
<!-- eslint-enable max-len --> <!-- eslint-enable max-len -->
@@ -444,7 +572,6 @@ questionsData.value?.questions && clearAnswer(questionsData.value.questions);
page.value = 1; page.value = 1;
// 清空action // 清空action
// delete questionsData.value.action; // delete questionsData.value.action;
console.log(`come in preview`, questionsData.value);
const props = defineProps({ const props = defineProps({
isTemplate: { isTemplate: {
@@ -460,12 +587,11 @@ const props = defineProps({
// 初始化 isTemplate // 初始化 isTemplate
isTemplate.value = props.isTemplate ? props.isTemplate : route.query.is_template === '1'; isTemplate.value = props.isTemplate ? props.isTemplate : route.query.is_template === '1';
console.log(`now page is template? ${isTemplate.value}`);
// 开始更新数据 // 开始更新数据
getQuestions(); getQuestions();
// 更新数据 // 更新数据
async function getQuestions () { async function getQuestions() {
let { data } = await AnswerApi.getQuetions({ let { data } = await AnswerApi.getQuetions({
id: route.query.sn, id: route.query.sn,
data: { data: {
@@ -487,7 +613,7 @@ async function getQuestions () {
} }
// 上一页 // 上一页
async function previous () { async function previous() {
if (prevLoading.value || loading.value) { if (prevLoading.value || loading.value) {
return; return;
} }
@@ -510,7 +636,7 @@ async function previous () {
} }
// 下一页 // 下一页
async function next (callbackBeforePage) { async function next(callbackBeforePage) {
// console.log(`click next button`, prevLoading.value || loading.value); // console.log(`click next button`, prevLoading.value || loading.value);
// if (prevLoading.value || loading.value) { // if (prevLoading.value || loading.value) {
// return; // return;
@@ -531,7 +657,7 @@ async function next (callbackBeforePage) {
// 开始答题 // 开始答题
// 答题 // 答题
async function answer (callback, callbackBeforePage) { async function answer(callback, callbackBeforePage) {
if ((questions.value.length || !questionsData.value.questions.length) && !props.isTemplate) { if ((questions.value.length || !questionsData.value.questions.length) && !props.isTemplate) {
// 表单验证(当前页) // 表单验证(当前页)
const errors = questions.value.filter((question) => { const errors = questions.value.filter((question) => {
@@ -1040,7 +1166,7 @@ async function answer (callback, callbackBeforePage) {
} }
// 关联引用 // 关联引用
function onRelation ( function onRelation(
// 避免出现参数 undefined 情况 // 避免出现参数 undefined 情况
{ options, value, list } = {}, { options, value, list } = {},
{ question_type: _questionType, question_index: _questionIndex, related, answer } = {} { question_type: _questionType, question_index: _questionIndex, related, answer } = {}
@@ -1156,7 +1282,7 @@ function onRelation (
}); });
} }
function jumpImmediately () { function jumpImmediately() {
const code = questionsData.value.action?.code; const code = questionsData.value.action?.code;
if (page.value !== pages.value.length + 1 && ![20004, 20011, 20016].includes(code)) { if (page.value !== pages.value.length + 1 && ![20004, 20011, 20016].includes(code)) {
return; return;
@@ -1209,7 +1335,7 @@ function jumpImmediately () {
} }
// 更新答案 // 更新答案
function updateAnswer (auto) { function updateAnswer(auto) {
if (auto) { if (auto) {
auto.forEach((autoItem) => { auto.forEach((autoItem) => {
const question = questionsData.value.questions.find( const question = questionsData.value.questions.find(
@@ -1232,7 +1358,7 @@ function updateAnswer (auto) {
} }
} }
// 选项隐藏 // 选项隐藏
function hideOptions (hide) { function hideOptions(hide) {
const questionIndex = hide?.question_index; const questionIndex = hide?.question_index;
if (questionIndex) { if (questionIndex) {
const question = questionsData.value.questions.find( const question = questionsData.value.questions.find(
@@ -1243,7 +1369,7 @@ function hideOptions (hide) {
} }
// 要搜索的数组和要查找的连续数字的数量n // 要搜索的数组和要查找的连续数字的数量n
function hasNConsecutiveNumbers (arr, n, onTrue, onFalse) { function hasNConsecutiveNumbers(arr, n, onTrue, onFalse) {
let count = 1; let count = 1;
let warnStart = 0; let warnStart = 0;
let prevNum = arr[0]; let prevNum = arr[0];
@@ -1266,7 +1392,7 @@ function hasNConsecutiveNumbers (arr, n, onTrue, onFalse) {
// eslint-disable // eslint-disable
// 跳转链接 // 跳转链接
function toUrl (url) { function toUrl(url) {
// 创建一个新的变量来存储修改后的 URL // 创建一个新的变量来存储修改后的 URL
let modifiedUrl = url; let modifiedUrl = url;
@@ -1289,7 +1415,7 @@ function toUrl (url) {
* 清空 answer 答案 * 清空 answer 答案
* @param questions * @param questions
*/ */
function clearAnswer (questions) { function clearAnswer(questions) {
if (!questions) return; if (!questions) return;
questions.forEach((question) => { questions.forEach((question) => {
if (!question.answer) return; if (!question.answer) return;

View File

@@ -4,8 +4,9 @@
<div class="qrcode-box"> <div class="qrcode-box">
<img class="bg_img" :src="bg" alt="" /> <img class="bg_img" :src="bg" alt="" />
<div class="content"> <div class="content">
<p class="tit" style="overflow: auto; max-height: 50px;">{{ surveyTitle ? surveyTitle : '' <p class="tit" style="overflow: auto; max-height: 50px">
}}</p> {{ surveyTitle ? surveyTitle : '' }}
</p>
<p style="margin-top: 6px; font-size: 500">扫码填写问卷</p> <p style="margin-top: 6px; font-size: 500">扫码填写问卷</p>
</div> </div>
<img class="qrcode-img" :src="publishInfo?.img_url" alt="" /> <img class="qrcode-img" :src="publishInfo?.img_url" alt="" />
@@ -24,7 +25,13 @@
<div v-if="status === 0 || status === 2" class="enable-box"> <div v-if="status === 0 || status === 2" class="enable-box">
<img class="not-publish-icon" src="@/assets/img/publish/not_pulish.png" alt="" /> <img class="not-publish-icon" src="@/assets/img/publish/not_pulish.png" alt="" />
<div class="content">点击"启用"按钮后问卷才可以开始回收数据</div> <div class="content">点击"启用"按钮后问卷才可以开始回收数据</div>
<van-button type="primary" style="margin-top: 20px" class="btn" color="#70b936" @click="openPublishModal"> <van-button
type="primary"
style="margin-top: 20px"
class="btn"
color="#70b936"
@click="openPublishModal"
>
<template #icon> <template #icon>
<i class="mobilefont mobilefont-fasong"></i> <i class="mobilefont mobilefont-fasong"></i>
</template> </template>
@@ -102,7 +109,7 @@ const operateBtn = (item: OperateItem) => {
} }
}; };
// 复制链接 // 复制链接
function copyLink () { function copyLink() {
const input = document.createElement('input'); const input = document.createElement('input');
input.value = publishInfo.value.url; input.value = publishInfo.value.url;
document.body.appendChild(input); document.body.appendChild(input);
@@ -112,7 +119,7 @@ function copyLink () {
showToast('链接复制成功'); showToast('链接复制成功');
} }
// 分享链接 // 分享链接
function shareLink () { function shareLink() {
const params = { const params = {
type: 'shareToWx', type: 'shareToWx',
title: surveyTitle.value title: surveyTitle.value
@@ -126,14 +133,13 @@ function shareLink () {
// 朋友圈1 微信好友0 // 朋友圈1 微信好友0
scene: 0 scene: 0
}; };
console.log(params);
appBridge.shareToWeChat(params, () => { appBridge.shareToWeChat(params, () => {
// 分享成功 // 分享成功
}); });
} }
// 下载二维码 // 下载二维码
function downLoadImg () { function downLoadImg() {
const { title, url } = publishInfo.value.download_url; const { title, url } = publishInfo.value.download_url;
if (appBridge.isInReactNative()) { if (appBridge.isInReactNative()) {
appBridge.save2Album(url, () => { appBridge.save2Album(url, () => {
@@ -148,7 +154,7 @@ function downLoadImg () {
document.body.removeChild(link); document.body.removeChild(link);
} }
} }
async function openPublishModal () { async function openPublishModal() {
const res = await canPlanetPublish(route.query.sn as string, publishType.value); const res = await canPlanetPublish(route.query.sn as string, publishType.value);
if (res) { if (res) {
await publishSurvey({ await publishSurvey({
@@ -164,7 +170,7 @@ async function openPublishModal () {
} }
} }
function getCode () { function getCode() {
getQrcode(sn) getQrcode(sn)
.then((res) => { .then((res) => {
if (res.data) { if (res.data) {
@@ -175,7 +181,7 @@ function getCode () {
showFailToast(error.data?.message || error.message || '服务器错误'); showFailToast(error.data?.message || error.message || '服务器错误');
}); });
} }
function fetchInfo () { function fetchInfo() {
getSurveyInfo(sn) getSurveyInfo(sn)
.then((res) => { .then((res) => {
status.value = Number(res.data.data.status); status.value = Number(res.data.data.status);