Merge branch 'feature/feature-20250331-h5' into uat

This commit is contained in:
陈昱达
2025-03-18 19:44:48 +08:00
13 changed files with 160 additions and 90 deletions

4
auto-imports.d.ts vendored
View File

@@ -5,4 +5,6 @@
// Generated by unplugin-auto-import
// biome-ignore lint: disable
export {}
declare global {}
declare global {
}

15
babel.config.json Normal file
View File

@@ -0,0 +1,15 @@
{
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "usage",
"corejs": 3,
"targets": {
"chrome": "58",
"ie": "11"
}
}
]
]
}

5
components.d.ts vendored
View File

@@ -26,11 +26,8 @@ declare module 'vue' {
VanCellGroup: typeof import('vant/es')['CellGroup']
VanCheckbox: typeof import('vant/es')['Checkbox']
VanCheckboxGroup: typeof import('vant/es')['CheckboxGroup']
VanCol: typeof import('vant/es')['Col']
VanDivider: typeof import('vant/es')['Divider']
VanField: typeof import('vant/es')['Field']
VanGrid: typeof import('vant/es')['Grid']
VanGridItem: typeof import('vant/es')['GridItem']
VanIcon: typeof import('vant/es')['Icon']
VanList: typeof import('vant/es')['List']
VanNavBar: typeof import('vant/es')['NavBar']
@@ -38,9 +35,7 @@ declare module 'vue' {
VanPopup: typeof import('vant/es')['Popup']
VanRadio: typeof import('vant/es')['Radio']
VanRadioGroup: typeof import('vant/es')['RadioGroup']
VanRow: typeof import('vant/es')['Row']
VanSearch: typeof import('vant/es')['Search']
VanStep: typeof import('vant/es')['Step']
VanStepper: typeof import('vant/es')['Stepper']
VanSwitch: typeof import('vant/es')['Switch']
VanTab: typeof import('vant/es')['Tab']

View File

@@ -19,7 +19,7 @@
</contenteditable>
</template>
<template #input>
<template v-for="(item, optionIndex) in element.options" :key="item.id">
<template v-for="item /*optionIndex*/ in element.options" :key="item.id">
<van-radio-group v-if="element.question_type === 1" v-model="choiceValue">
<option-action
:data="isPreview ? item.options : item"
@@ -61,7 +61,7 @@
<van-checkbox-group v-if="element.question_type === 2" v-model="value" shape="square">
<option-action
v-model:data="element.options[optionIndex]"
:data="isPreview ? item.options : item"
handle=".moverQues"
:active="active"
:question="element"
@@ -102,13 +102,12 @@
</template>
<script setup>
import OptionAction from '@/views/Design/components/ActionCompoents/OptionAction.vue';
import { defineAsyncComponent, ref } from 'vue';
import { defineAsyncComponent } from 'vue';
// 是否是预览
const isPreview = defineModel('isPreview', { default: false, type: Boolean });
const choiceValue = defineModel('answer', { default: '1', type: String });
// console.log(`choiceValue.value`, choiceValue.value);
const value = defineModel('checkboxAnswer', { default: [1, 2], type: Array });
const Contenteditable = defineAsyncComponent(() => import('@/components/contenteditable.vue'));
defineProps({
@@ -121,6 +120,11 @@ defineProps({
default: 0
}
});
/**
* 题目
* @type {ModelRef<Object, string, Object, Object>}
*/
const element = defineModel('element', {
type: Object,
default: () => {
@@ -129,7 +133,6 @@ const element = defineModel('element', {
};
}
});
const value = ref([]);
const emit = defineEmits(['update:element']);
const emitValue = () => {
emit('update:element', element.value);

View File

@@ -13,12 +13,12 @@ const question = defineModel<question>('element', {
// eslint-disable-next-line
const activeComponent = computed<Component>(() => {
switch (question.value.question_type) {
case 8:
return MatrixText;
case 9:
return MatrixRadio;
case 10:
return MatrixCheckbox;
case 8:
return MatrixText;
case 9:
return MatrixRadio;
case 10:
return MatrixCheckbox;
}
});

View File

@@ -30,9 +30,9 @@
<p>{{ element.config.prompt_right }}</p>
</div>
<RateCharacter
v-model:model="value"
:config="element.config"
:index="optionIndex"
v-model:model="value"
@change="handleRateChange"
/>
</div>

View File

@@ -9,7 +9,7 @@ import { showFailToast } from 'vant';
const contentShow = ref(false);
const show = ref(false);
onMounted(async () => {
onMounted(async() => {
if (utils.getSessionStorage('xToken')) {
const appToken = utils.getSessionStorage('xToken');
getUserInfo(appToken)

View File

@@ -87,12 +87,12 @@ const getList = () => {
if (res.data.code === 0) {
if (res.data.data) {
res.data.data.forEach((item) => {
if (item.parentCode && item.parentCode === 1) {
surveys.value.push(item);
}
// if (item.parentCode && item.parentCode === 1) {
surveys.value.push(item);
// }
});
surveys.value.push({});
// surveys.value.push({});
}
}
});
@@ -118,8 +118,8 @@ onMounted(() => {
class="survey"
@click="createdQuestion(survey)"
>
<img :src="survey.image" alt="" width="40" />
<span>{{ survey.title }}</span>
<img :src="survey.h5Image" alt="" width="40" />
<span>{{ survey.h5Title }}</span>
</div>
</div>
</div>

View File

@@ -61,7 +61,7 @@ import endPng from '@/assets/img/publish/end.png';
const survey = ref({
project_name: ''
});
const fetchSurveys = async () => {
const fetchSurveys = async() => {
const params = {
page: 1,
per_page: 10,

View File

@@ -134,7 +134,7 @@ const onLoad = () => {
fetchSurveys();
}, 500);
};
const fetchSurveys = async () => {
const fetchSurveys = async() => {
const params = {
page: form.value.page,
per_page: form.value.pageSize,
@@ -172,7 +172,7 @@ const deleteItem = (item) => {
showCancelButton: true,
confirmButtonColor: '#03B03C'
})
.then(async () => {
.then(async() => {
const res = await deleteSurveys(item.sn);
if (res.data.message) {
showToast(res.data.message);
@@ -196,7 +196,7 @@ const copyItem = (item) => {
showCancelButton: true,
confirmButtonColor: '#03B03C'
})
.then(async () => {
.then(async() => {
const res = await copySurveys(item.sn);
if (res.data.code === 200 || res.data.code === 201) {
showSuccessToast('复制成功');
@@ -237,7 +237,7 @@ const editItem = (item) => {
});
};
// 保存为模板
const saveTemplate = async (item) => {
const saveTemplate = async(item) => {
const data = JSON.parse(JSON.stringify(item));
const res = await saveTemplates(item.sn, data);
if (res.data.code === 200 || res.data.code === 201) {

View File

@@ -146,11 +146,9 @@
<!-- 投放设置-->
<van-action-sheet v-model:show="showSetting" title="" style="background-color: #f2f2f2">
<template #description>
<div class="setting_title flex flex-start">投放设置</div>
</template>
<van-cell-group :border="false" class="setting_group">
<van-cell title="每页一题" class="setting_block" :border="false" label-align="left">
<div class="van-action-sheet-title flex flex-start">投放设置</div>
<van-cell-group :border="false" class="round-group br12">
<van-cell title="每页一题" :border="false" label-align="left">
<template #right-icon>
<van-switch
v-model="questionInfo.survey.is_one_page_one_question"
@@ -162,7 +160,8 @@
></van-switch>
</template>
</van-cell>
<van-divider></van-divider>
</van-cell-group>
<van-cell-group :border="false" class="round-group br12">
<van-cell title="投放数量" class="setting_block" :border="false" label-align="left">
<template #right-icon>
<van-switch
@@ -190,8 +189,10 @@
<template #right-icon> </template>
</van-field>
</van-cell-group>
<van-divider></van-divider>
<van-cell title="有效期" class="border-top" :border="false" label-align="left">
</van-cell-group>
<van-cell-group :border="false" class="round-group br12">
<van-cell title="有效期" class="border-top" label-align="left">
<template #right-icon>
<van-switch
v-model="questionInfo.survey.is_time"
@@ -225,7 +226,7 @@
</van-field>
</van-cell-group>
<van-cell title="断点续答" :border="false" label-align="left">
<van-cell title="断点续答" label-align="left">
<template #right-icon>
<van-switch
v-model="questionInfo.survey.is_breakpoint"
@@ -241,7 +242,6 @@
<van-cell
title="企微身份获取(开启后仅支持私有化企业环境作答)"
class="border-bottom"
:border="false"
label-align="left"
>
<template #right-icon>
@@ -255,8 +255,10 @@
></van-switch>
</template>
</van-cell>
<van-divider></van-divider>
<van-cell title="IP答题次数限制" class="border-top" :border="false" label-align="left">
</van-cell-group>
<van-cell-group class="round-group br12" :border="false">
<van-cell title="IP答题次数限制" class="border-top" label-align="left">
<template #right-icon>
<van-switch
v-model="questionInfo.survey.is_ip_number"
@@ -268,7 +270,11 @@
></van-switch>
</template>
</van-cell>
<van-cell-group v-if="questionInfo.survey.is_ip_number === 1" class="child-group">
<van-cell-group
v-if="questionInfo.survey.is_ip_number === 1"
:border="false"
class="child-group"
>
<van-field
v-model="questionInfo.survey.is_number"
label="同一个IP地址只能作答"
@@ -306,18 +312,6 @@
<template #right-icon> </template>
</van-field>
</van-cell-group>
<van-divider></van-divider>
<!-- <van-field-->
<!-- v-model="endText"-->
<!-- label="结束语"-->
<!-- :border="false"-->
<!-- readonly-->
<!-- label-align="left"-->
<!-- input-align="right"-->
<!-- is-link-->
<!-- @click="openEndTextModel"-->
<!-- >-->
<!-- </van-field>-->
</van-cell-group>
</van-action-sheet>
@@ -441,14 +435,14 @@ const questionEvent = (item) => {
options:
item.json.options.length > 0
? item.json.options.map((item) => {
return item.map((it) => {
return {
...it,
// 主键生成
id: uuidv4()
};
});
})
return item.map((it) => {
return {
...it,
// 主键生成
id: uuidv4()
};
});
})
: []
})
);
@@ -585,7 +579,7 @@ const previewQuestion = () => {
router.push({ name: 'preview', query: { ...route.query } });
};
onMounted(async () => {
onMounted(async() => {
await getQuestionDetail();
});
</script>
@@ -798,6 +792,10 @@ onMounted(async () => {
font-weight: bold;
}
:deep(.van-cell) {
padding: 8px;
}
.survey-action {
position: fixed;
bottom: 0;

View File

@@ -114,23 +114,22 @@
@next="next"
@change-answer="onRelation($event, question)"
/>
<!-- &lt;!&ndash; 多选题 &ndash;&gt;-->
<!-- <q-checkbox-->
<!-- v-else-if="question.question_type === 2"-->
<!-- :list="question.list"-->
<!-- :config="question.config"-->
<!-- v-model:answer="question.answer"-->
<!-- v-model:answerIndex="question.answerIndex"-->
<!-- :hideOptions="question.hideOptions"-->
<!-- @changeAnswer="onRelation($event, question)"-->
<!-- :stem="question.stem"-->
<!-- @previous="previous"-->
<!-- @next="next"-->
<!-- isMobile-->
<!-- :answerSn="questionsData.answer.sn"-->
<!-- :answerSurveySn="questionsData.answer.survey_sn"-->
<!-- :question="question"-->
<!-- />-->
<!-- 多选题 -->
<preview-checkbox
v-else-if="question.question_type === 2"
v-model:answer="question.answer"
v-model:answerIndex="question.answerIndex"
: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;-->
<!-- <q-cascader-->
<!-- v-else-if="question.question_type === 3"-->
@@ -540,6 +539,7 @@ import layout from '@/layouts/index.vue';
// hooks file
import icon from '@/assets/img/create-right-back.png';
import PreviewCheckbox from '@/views/Survey/views/Preview/components/questions/PreviewCheckbox.vue';
// scrollbar
const scrollbar = useTemplateRef('scrollbar');
const questionStore = useQuestionStore();
@@ -559,7 +559,7 @@ const {
translatedText
} = storeToRefs(questionStore);
// console.log(`questionsData`, questionsData.value);
// console.log(`questionsData`, questions.value);
const props = defineProps({
isTemplate: {
type: Boolean,
@@ -597,13 +597,6 @@ async function getQuestions() {
questionsData.value = data;
}
// 获取 DOM 的内容
// function getDomString (htmlString) {
// if (typeof htmlString !== 'string') return;
// const match = htmlString.match(/<.*>(.*?)<\/.*>/);
// if (match) return match[1];
// }
// 上一页
async function previous() {
if (prevLoading.value || loading.value) {

View File

@@ -0,0 +1,64 @@
<template>
<choice
v-model:checkboxAnswer="choiceValue"
:element="question"
:index="answerIndex"
:is-preview="true"
/>
</template>
<script setup lang="ts">
import { watch, ref } from 'vue';
import Choice from '@/views/Design/components/Questions/Choice.vue';
type answerType = {
[key: string]: string;
};
/**
* answer 格式
* {
* 1:"1"
* 2:"1"
* }
*/
// 预览新增 v-model
const answer = defineModel<answerType>('answer', { default: undefined });
const answerIndex = defineModel<number>('answerIndex');
// const stem = defineModel<string>('stem', { default: '' });
const question = defineModel<question>('question', { default: { config: { is_required: false } } });
// const list = defineModel<questionsList[]>('list', { default: [[]] });
initData();
function initData() {
if (question.value.list.length) {
question.value.options = question.value.list;
question.value.questions = question.value.list;
}
if (question.value.list.length) question.value.questions = question.value.list;
}
const choiceValue = ref<string[]>(parseAnswer(answer.value));
// // 预览新增 emit ['changeAnswer', 'previous', 'next']
const emit = defineEmits(['update:element', 'changeAnswer', 'previous', 'next', 'update:element']);
/**
* 解析答案
*/
function parseAnswer(answer: answerType) {
if (!answer) return [];
return Object.keys(answer);
}
watch(
() => choiceValue.value,
() => {
const res: answerType = {};
choiceValue.value.forEach((key) => {
res[key] = '1';
});
answer.value = res;
console.log(res);
emit('changeAnswer', res);
}
);
</script>