|
|
@@ -1,6 +1,5 @@
|
|
|
<template>
|
|
|
<div class="app-container">
|
|
|
- <!-- 可选:添加 loading 提示 -->
|
|
|
<el-form ref="form" :model="form" label-width="140px" v-loading="loading">
|
|
|
<div v-for="(answer, index) in form.answers" :key="index">
|
|
|
<div style="margin-bottom: 20px; margin-top: 20px;">
|
|
|
@@ -9,14 +8,13 @@
|
|
|
</span>
|
|
|
</div>
|
|
|
<div style="margin-left: 31px;">
|
|
|
- <!-- flag 控制是否可编辑 -->
|
|
|
+ <!-- 只显示 value 在 answer.value 中的选项 -->
|
|
|
<el-checkbox-group
|
|
|
- :disabled="answer.flag || false"
|
|
|
v-model="form.answers[index].value"
|
|
|
size="mini"
|
|
|
>
|
|
|
<el-checkbox
|
|
|
- v-for="dict in answer.options"
|
|
|
+ v-for="dict in filteredOptions(answer)"
|
|
|
:key="dict.value"
|
|
|
:label="dict.value"
|
|
|
>
|
|
|
@@ -26,7 +24,6 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <!-- 如果没有数据 -->
|
|
|
<div v-if="!form.answers || form.answers.length === 0" style="text-align: center; color: #999; padding: 20px;">
|
|
|
暂无采集信息
|
|
|
</div>
|
|
|
@@ -71,6 +68,14 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 过滤出 answer.options 中 value 在 answer.value 数组里的选项
|
|
|
+ filteredOptions(answer) {
|
|
|
+ if (!Array.isArray(answer.value) || !Array.isArray(answer.options)) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ const selectedValues = new Set(answer.value); // 提升性能,避免多次遍历
|
|
|
+ return answer.options.filter(option => selectedValues.has(option.value));
|
|
|
+ },
|
|
|
fetchCollectionInfo(userId) {
|
|
|
this.loading = true;
|
|
|
console.log("传入的用户信息:", userId)
|
|
|
@@ -95,16 +100,3 @@ export default {
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
-
|
|
|
-<style scoped>
|
|
|
-::v-deep .el-checkbox__input.is-disabled + span.el-checkbox__label {
|
|
|
- color: #1890ff;
|
|
|
-}
|
|
|
-::v-deep .el-checkbox-button.is-disabled.is-checked .el-checkbox-button__inner {
|
|
|
- color: #1890ff;
|
|
|
-}
|
|
|
-::v-deep .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner::after {
|
|
|
- border-color: #1890ff;
|
|
|
-}
|
|
|
-/* 可添加一些样式优化 */
|
|
|
-</style>
|