feat(Design): 选择题支持单选和多选功能
- 修改 Choice 组件,支持单选和多选的渲染逻辑 - 新增 CheckboxAction 组件,用于多选题的排它项设置 - 更新 QuestionAction 组件,适配新的单选和多选逻辑 - 调整 Index 组件,支持单选和多选题的显示 - 修改 stores 中的 question_type 值,以区分单选和多选
This commit is contained in:
@@ -15,13 +15,13 @@
|
||||
></div>
|
||||
</template>
|
||||
<template #input>
|
||||
<van-checkbox-group>
|
||||
<template v-for="(item, index) in element.options" :key="index">
|
||||
<option-action v-model:data="element.options[index]" :active="active">
|
||||
<template v-for="(item, index) in element.options" :key="index">
|
||||
<van-radio-group v-if="element.question_type === 1">
|
||||
<option-action v-model:data="element.options[index]" :active="active" :question="element">
|
||||
<template #item="{ element: it, index: itIndex }">
|
||||
<van-checkbox
|
||||
<van-radio
|
||||
:key="itIndex"
|
||||
:name="it.value"
|
||||
:name="it.option_index"
|
||||
:label="it.label"
|
||||
:disabled="it.disabled"
|
||||
icon-size="0.45rem"
|
||||
@@ -29,7 +29,34 @@
|
||||
<template #default>
|
||||
<div class="flex align-center van-cell">
|
||||
<div
|
||||
class="van-cell--borderless"
|
||||
class="van-cell--borderless choice-html"
|
||||
:contenteditable="active"
|
||||
@blur="saveOption($event, it)"
|
||||
v-html="it.option"
|
||||
></div>
|
||||
<div v-if="it.is_other">
|
||||
<input class="other-input" type="text" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</van-radio>
|
||||
</template>
|
||||
</option-action>
|
||||
</van-radio-group>
|
||||
<van-checkbox-group v-if="element.question_type === 2" shape="square">
|
||||
<option-action v-model:data="element.options[index]" :active="active" :question="element">
|
||||
<template #item="{ element: it, index: itIndex }">
|
||||
<van-checkbox
|
||||
:key="itIndex"
|
||||
:name="it.option_index"
|
||||
:label="it.label"
|
||||
:disabled="it.disabled"
|
||||
icon-size="0.45rem"
|
||||
>
|
||||
<template #default>
|
||||
<div class="flex align-center van-cell">
|
||||
<div
|
||||
class="van-cell--borderless choice-html"
|
||||
:contenteditable="active"
|
||||
@blur="saveOption($event, it)"
|
||||
v-html="it.option"
|
||||
@@ -42,8 +69,8 @@
|
||||
</van-checkbox>
|
||||
</template>
|
||||
</option-action>
|
||||
</template>
|
||||
</van-checkbox-group>
|
||||
</van-checkbox-group>
|
||||
</template>
|
||||
</template>
|
||||
</van-field>
|
||||
</template>
|
||||
@@ -74,16 +101,26 @@ const saveStem = (e, ele) => {
|
||||
};
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.choice-html {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.base-select {
|
||||
& .van-checkbox-group {
|
||||
& .van-checkbox-group,
|
||||
.van-radio-group {
|
||||
width: 100%;
|
||||
|
||||
& .van-checkbox {
|
||||
& .van-checkbox,
|
||||
.van-radio {
|
||||
width: 100%;
|
||||
|
||||
& ::v-deep .van-checkbox__label {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
& ::v-deep .van-radio__label {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user