feat: 完善 martrixQuestion 支持
- 现在支持全类型的矩阵问题 - 支持更改数据 - 新增相应数据内容 - 代码样式自动格式化
This commit is contained in:
@@ -1,57 +1,40 @@
|
||||
<template>
|
||||
<div class="design-create">
|
||||
<draggable
|
||||
v-model:data="questionInfo.questions"
|
||||
item-key="id"
|
||||
handle=".moverQues"
|
||||
chosenClass="chosen"
|
||||
animation="300"
|
||||
:scroll="true"
|
||||
v-model:data="questionInfo.questions" item-key="id" handle=".moverQues" chosenClass="chosen"
|
||||
animation="300" :scroll="true"
|
||||
>
|
||||
<template #item="{ element, index }">
|
||||
<choose-question
|
||||
:element="element"
|
||||
:questions="questionInfo.questions"
|
||||
:index="index"
|
||||
:chooseQuestionId="chooseQuestionId"
|
||||
@get-choose-question-id="getChooseQuestionId"
|
||||
:element="element" :questions="questionInfo.questions" :index="index"
|
||||
:chooseQuestionId="chooseQuestionId" @get-choose-question-id="getChooseQuestionId"
|
||||
>
|
||||
<!-- 选择题 -->
|
||||
<Choice
|
||||
v-if="element.question_type === 1 || element.question_type === 2"
|
||||
:element="element"
|
||||
v-if="element.question_type === 1 || element.question_type === 2" :element="element"
|
||||
:active="chooseQuestionId === element.id"
|
||||
></Choice>
|
||||
<!-- 填空题 -->
|
||||
<Completion
|
||||
v-if="element.question_type === 4"
|
||||
:element="element"
|
||||
:active="chooseQuestionId === element.id"
|
||||
v-if="element.question_type === 4" :element="element" :active="chooseQuestionId === element.id"
|
||||
sn="lXEBBpE2"
|
||||
></Completion>
|
||||
|
||||
<martrix-question
|
||||
v-if="element.question_type === 9"
|
||||
:element="element"
|
||||
:active="chooseQuestionId === element.id"
|
||||
v-if="element.question_type === 8 || element.question_type === 9 || element.question_type === 10"
|
||||
:element="element" :active="chooseQuestionId === element.id"
|
||||
/>
|
||||
|
||||
<!-- 打分题 -->
|
||||
<Rate
|
||||
v-if="element.question_type === 5"
|
||||
:element="element"
|
||||
:active="chooseQuestionId === element.id"
|
||||
v-if="element.question_type === 5" :element="element" :active="chooseQuestionId === element.id"
|
||||
sn="lXEBBpE2"
|
||||
/>
|
||||
<!--组件底部左侧操作-->
|
||||
<template #action="{ element: el }">
|
||||
<div class="flex slot-actions">
|
||||
<template v-for="(item, optionIndex) in actionOptions">
|
||||
<div
|
||||
v-if="item.question_type.includes(el.question_type)"
|
||||
:key="optionIndex"
|
||||
class="flex"
|
||||
>
|
||||
<div v-if="item.question_type.includes(el.question_type)" :key="optionIndex" class="flex">
|
||||
<template v-for="(act, actIndex) in item.actions" :key="actIndex">
|
||||
<div class="flex align-center action-item" @click="actionEvent(act, el)">
|
||||
<van-icon :name="act.icon"></van-icon>
|
||||
@@ -67,11 +50,8 @@
|
||||
<!-- {{ element.question_type }}-->
|
||||
<!-- {{questionInfo.survey.pages.length}}-->
|
||||
<paging
|
||||
v-if="!element.question_type && questionInfo.survey.pages.length > 1"
|
||||
:info="element"
|
||||
:index="index"
|
||||
:active="pageIsActive(activeIndex, questionInfo.questions, element.page)"
|
||||
@click.stop=""
|
||||
v-if="!element.question_type && questionInfo.survey.pages.length > 1" :info="element" :index="index"
|
||||
:active="pageIsActive(activeIndex, questionInfo.questions, element.page)" @click.stop=""
|
||||
/>
|
||||
</template>
|
||||
</draggable>
|
||||
@@ -159,6 +139,21 @@ const actionOptions = [
|
||||
fun: 'radioAddOption'
|
||||
}
|
||||
]
|
||||
}, {
|
||||
question_type: [8, 9, 10],
|
||||
// 矩阵问卷逻辑处理
|
||||
actions: [
|
||||
{
|
||||
label: '添加行标签',
|
||||
icon: 'add',
|
||||
fun: 'addMatrixRowOption'
|
||||
},
|
||||
{
|
||||
label: '添加列标签',
|
||||
icon: 'add',
|
||||
fun: 'addMatrixColumnOption'
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
// 事件分发
|
||||
@@ -188,6 +183,23 @@ const actionFun = {
|
||||
});
|
||||
});
|
||||
element.last_option_index += 1;
|
||||
},
|
||||
|
||||
/**
|
||||
* martrix 矩阵行数增加
|
||||
* @param element {import('./components/Questions/types/martrix.js').MatrixSurveyQuestion}
|
||||
*/
|
||||
addMatrixRowOption: (element) => {
|
||||
element.options[0].push({
|
||||
option: '新增行'
|
||||
});
|
||||
},
|
||||
/**
|
||||
* martrix 矩阵列数增加
|
||||
* @param element {import('./components/Questions/types/martrix.js').MatrixSurveyQuestion}
|
||||
*/
|
||||
addMatrixColumnOption: (element) => {
|
||||
element.options[1].push({ option: '新增列' });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -206,7 +218,7 @@ onMounted(() => {
|
||||
color: #333;
|
||||
|
||||
.slot-actions {
|
||||
& .action-item + .action-item {
|
||||
& .action-item+.action-item {
|
||||
margin-left: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user