feat(DataAnalyse): 列表配置添加disabled状态 不可取消选中
This commit is contained in:
@@ -24,7 +24,9 @@
|
|||||||
class="custom-checkbox-group my-checkbox-group"
|
class="custom-checkbox-group my-checkbox-group"
|
||||||
>
|
>
|
||||||
<a-row v-for="(child, index) in item.children" :key="index" style="margin-bottom: 10px">
|
<a-row v-for="(child, index) in item.children" :key="index" style="margin-bottom: 10px">
|
||||||
<a-checkbox :value="child.value"> <span class="checkbox-content" v-html="child.title"></span></a-checkbox>
|
<a-checkbox :value="child.value" :disabled="child.disabled">
|
||||||
|
<span class="checkbox-content" v-html="child.title"></span>
|
||||||
|
</a-checkbox>
|
||||||
</a-row>
|
</a-row>
|
||||||
</a-checkbox-group>
|
</a-checkbox-group>
|
||||||
</div>
|
</div>
|
||||||
@@ -69,19 +71,26 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleChange(e) {
|
function handleChange(e) {
|
||||||
if (e.target.checked) {
|
const targetValue = e.target.value;
|
||||||
checkedList.value.forEach((item) => {
|
checkedList.value.forEach((item) => {
|
||||||
if (item.value === e.target.value) {
|
if (item.value === targetValue) {
|
||||||
item.selected = item.children.map((item) => item.value);
|
if (e.target.checked) {
|
||||||
|
// 选中时全选所有未被禁用的子项
|
||||||
|
const enabledChildren = item.children
|
||||||
|
.filter(child => !child.disabled)
|
||||||
|
.map(child => child.value);
|
||||||
|
item.selected = [...new Set([...item.selected, ...enabledChildren])];
|
||||||
|
} else {
|
||||||
|
// 取消选中时只保留被禁用的子项
|
||||||
|
const disabledChildren = item.children
|
||||||
|
.filter(child => child.disabled)
|
||||||
|
.map(child => child.value);
|
||||||
|
item.selected = item.selected.filter(val =>
|
||||||
|
disabledChildren.includes(val)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
} else {
|
});
|
||||||
checkedList.value.forEach((item) => {
|
|
||||||
if (item.value === e.target.value) {
|
|
||||||
item.selected = [];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
function handleOk() {
|
function handleOk() {
|
||||||
const selectList = checkedList.value.map((item) => item.selected);
|
const selectList = checkedList.value.map((item) => item.selected);
|
||||||
|
|||||||
@@ -484,7 +484,14 @@ export default defineComponent({
|
|||||||
getSurveyHeadInfo().then(res => {
|
getSurveyHeadInfo().then(res => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
answer_columns.value = res.data.survey_columns;
|
answer_columns.value = res.data.survey_columns;
|
||||||
|
let disabledList = ['project_name','scene_name','status_txt','updated_at']
|
||||||
|
answer_columns.value[0].children.forEach(item=>{
|
||||||
|
if (disabledList.includes(item.value)){
|
||||||
|
item.disabled = true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
console.log('answer_columns.value');
|
||||||
|
console.log(answer_columns.value);
|
||||||
// 获取原始 columns 数据
|
// 获取原始 columns 数据
|
||||||
let originalColumns = res.data.columns;
|
let originalColumns = res.data.columns;
|
||||||
// 处理 columns 数据结构
|
// 处理 columns 数据结构
|
||||||
|
|||||||
Reference in New Issue
Block a user