8/25 dev bug
This commit is contained in:
@@ -70,9 +70,9 @@
|
||||
<span>属性配置</span>
|
||||
</div>
|
||||
</template>
|
||||
<el-form style="position: sticky; top: 60px" label-width="80px">
|
||||
<el-form-item label="题目标题">
|
||||
<el-input maxlength="20" v-model.trim="activeQuestion.title" placeholder="请输入题目标题" />
|
||||
<el-form :rules="rules" :model="activeQuestion" style="position: sticky; top: 60px" label-width="80px">
|
||||
<el-form-item label="题目标题" prop="title">
|
||||
<el-input maxlength="50" v-model.trim="activeQuestion.title" placeholder="请输入题目标题" />
|
||||
</el-form-item>
|
||||
<el-form-item label="是否必填">
|
||||
<el-switch v-model.trim="activeQuestion.required" />
|
||||
@@ -87,9 +87,13 @@
|
||||
placeholder="选项内容"
|
||||
style="width: 200px; margin-right: 10px; margin-bottom: 10px"
|
||||
/>
|
||||
<el-button link type="danger" :icon="Delete" @click="activeQuestion.options.splice(idx, 1)"> 删除 </el-button>
|
||||
<el-button link type="danger" v-if="activeQuestion.options.length > 2" :icon="Delete" @click="activeQuestion.options.splice(idx, 1)">
|
||||
删除
|
||||
</el-button>
|
||||
</div>
|
||||
<el-button type="primary" @click="activeQuestion.options.push({ label: '新选项' })"> 添加选项 </el-button>
|
||||
<el-button type="primary" @click="activeQuestion.options.push({ label: '选项' + (activeQuestion.options.length + 1) })">
|
||||
添加选项
|
||||
</el-button>
|
||||
</template>
|
||||
</el-form>
|
||||
</el-card>
|
||||
@@ -141,6 +145,10 @@ const form = ref<QuestionComponentnaireForm>({
|
||||
content: []
|
||||
});
|
||||
|
||||
const rules = ref({
|
||||
title: [{ required: true, message: '请输入问卷标题', trigger: 'blur' }]
|
||||
});
|
||||
|
||||
const activeIndex = ref<number>(-1);
|
||||
|
||||
// ==================== 计算属性 ====================
|
||||
@@ -190,10 +198,15 @@ function deleteQuestion(index: number): void {
|
||||
// ==================== 业务方法 ====================
|
||||
/** 表单验证 */
|
||||
function validateForm(): boolean {
|
||||
// 验证问卷标题
|
||||
if (!form.value.title.trim()) {
|
||||
ElMessage.error('请输入问卷标题');
|
||||
return false;
|
||||
}
|
||||
if (form.value.content.some((item) => item.title === '')) {
|
||||
ElMessage.error('请填写所有题目标题');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user