|
@@ -40,7 +40,7 @@
|
|
<div
|
|
<div
|
|
v-for="item2 in item.children2"
|
|
v-for="item2 in item.children2"
|
|
:key="item2.value"
|
|
:key="item2.value"
|
|
- :class="selectData[item.id].other_type_id.includes(item2.id) ? 'tag tag-active' : 'tag'"
|
|
|
|
|
|
+ :class="selectData[item.id].children2.includes(item2.id) ? 'tag tag-active' : 'tag'"
|
|
@click="handleClickTag(item.id, item2)"
|
|
@click="handleClickTag(item.id, item2)"
|
|
>
|
|
>
|
|
{{ item2.label }}
|
|
{{ item2.label }}
|
|
@@ -57,10 +57,10 @@
|
|
<div
|
|
<div
|
|
v-for="item2 in item.children2"
|
|
v-for="item2 in item.children2"
|
|
:key="item2.value"
|
|
:key="item2.value"
|
|
- :class="selectData[item.id].other_type_id.includes(item2.id) ? 'tag tag-active' : 'tag'"
|
|
|
|
- @click="handleClickTag(item.ud, item2)"
|
|
|
|
|
|
+ :class="selectData[item.id].children2.includes(item2.id) ? 'tag tag-active' : 'tag'"
|
|
|
|
+ @click="handleClickTag(item.id, item2)"
|
|
>
|
|
>
|
|
- {{ item.label }}
|
|
|
|
|
|
+ {{ item2.label }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -70,10 +70,10 @@
|
|
<div
|
|
<div
|
|
v-for="item2 in item.children2"
|
|
v-for="item2 in item.children2"
|
|
:key="item2.value"
|
|
:key="item2.value"
|
|
- :class="selectData[item.id].other_type_id.includes(item2) ? 'tag tag-active' : 'tag'"
|
|
|
|
|
|
+ :class="selectData[item.id].children2.includes(item2.id) ? 'tag tag-active' : 'tag'"
|
|
@click="handleClickTag(item.id, item2)"
|
|
@click="handleClickTag(item.id, item2)"
|
|
>
|
|
>
|
|
- {{ item.label }}
|
|
|
|
|
|
+ {{ item2.label }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -99,7 +99,8 @@
|
|
import {getPersonalTypeTree} from "@/api/persons";
|
|
import {getPersonalTypeTree} from "@/api/persons";
|
|
|
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
- modelValue: Boolean
|
|
|
|
|
|
+ modelValue: Boolean,
|
|
|
|
+ data: Array
|
|
});
|
|
});
|
|
|
|
|
|
const emits = defineEmits(['update:modelValue','confirm']);
|
|
const emits = defineEmits(['update:modelValue','confirm']);
|
|
@@ -132,7 +133,7 @@ const selectData = ref({
|
|
},
|
|
},
|
|
'5': {
|
|
'5': {
|
|
dept_name: '',
|
|
dept_name: '',
|
|
- other_type_id: [],
|
|
|
|
|
|
+ children2: [],
|
|
other_type_label: [],
|
|
other_type_label: [],
|
|
children: [],
|
|
children: [],
|
|
labelData: []
|
|
labelData: []
|
|
@@ -143,7 +144,7 @@ const selectData = ref({
|
|
},
|
|
},
|
|
'7': {
|
|
'7': {
|
|
dept_name: '',
|
|
dept_name: '',
|
|
- other_type_id: [],
|
|
|
|
|
|
+ children2: [],
|
|
other_type_label: [],
|
|
other_type_label: [],
|
|
children: [],
|
|
children: [],
|
|
labelData: []
|
|
labelData: []
|
|
@@ -153,7 +154,7 @@ const selectData = ref({
|
|
labelData: []
|
|
labelData: []
|
|
},
|
|
},
|
|
'9': {
|
|
'9': {
|
|
- other_type_id: [],
|
|
|
|
|
|
+ children2: [],
|
|
other_type_label: [],
|
|
other_type_label: [],
|
|
children: [],
|
|
children: [],
|
|
labelData: []
|
|
labelData: []
|
|
@@ -183,17 +184,15 @@ const checkBoxChange = (data) => {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
selectData.value[data.id].labelData = labelData;
|
|
selectData.value[data.id].labelData = labelData;
|
|
- selectData.value[data.id].parentName = data.label;
|
|
|
|
- selectData.value[data.id].type_parent_id = data.id;
|
|
|
|
};
|
|
};
|
|
|
|
|
|
const handleClickTag = (key, data) => {
|
|
const handleClickTag = (key, data) => {
|
|
- let index = selectData.value[key].other_type_id.findIndex(item => item === data.id);
|
|
|
|
|
|
+ let index = selectData.value[key].children2.findIndex(item => item === data.id);
|
|
if (index > -1) {
|
|
if (index > -1) {
|
|
- selectData.value[key].other_type_id.splice(index, 1);
|
|
|
|
|
|
+ selectData.value[key].children2.splice(index, 1);
|
|
selectData.value[key].other_type_label.splice(index, 1);
|
|
selectData.value[key].other_type_label.splice(index, 1);
|
|
} else {
|
|
} else {
|
|
- selectData.value[key].other_type_id.push(data.id);
|
|
|
|
|
|
+ selectData.value[key].children2.push(data.id);
|
|
selectData.value[key].other_type_label.push(data.label);
|
|
selectData.value[key].other_type_label.push(data.label);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -204,10 +203,11 @@ const onCancel = () => {
|
|
const onConfirm = () => {
|
|
const onConfirm = () => {
|
|
let data = [];
|
|
let data = [];
|
|
for(let key in selectData.value) {
|
|
for(let key in selectData.value) {
|
|
|
|
+ // || !!selectData.value[key].dept_name || !!selectData.value[key].denger_point_name || !!selectData.value[key].other_type_2_name || (!!selectData.value[key].children2 && selectData.value[key].children2.length > 0)
|
|
if (selectData.value[key].children && selectData.value[key].children.length > 0) {
|
|
if (selectData.value[key].children && selectData.value[key].children.length > 0) {
|
|
let obj = {
|
|
let obj = {
|
|
- type_parent_id: selectData.value[key].type_parent_id,
|
|
|
|
- parentName: selectData.value[key].parentName,
|
|
|
|
|
|
+ type_parent_id: key,
|
|
|
|
+ type_parent: selectData.value[key].type_parent,
|
|
children: selectData.value[key].children,
|
|
children: selectData.value[key].children,
|
|
labelData: selectData.value[key].labelData
|
|
labelData: selectData.value[key].labelData
|
|
}
|
|
}
|
|
@@ -220,8 +220,8 @@ const onConfirm = () => {
|
|
if (key === '11' && selectData.value[key].other_type_2_name) {
|
|
if (key === '11' && selectData.value[key].other_type_2_name) {
|
|
obj.other_type_2_name = selectData.value[key].other_type_2_name;
|
|
obj.other_type_2_name = selectData.value[key].other_type_2_name;
|
|
}
|
|
}
|
|
- if (['5', '7', '9'].includes(key) && selectData.value[key].other_type_id && selectData.value[key].other_type_id.length > 0) {
|
|
|
|
- obj.other_type_id = selectData.value[key].other_type_id;
|
|
|
|
|
|
+ if (['5', '7', '9'].includes(key) && selectData.value[key].children2 && selectData.value[key].children2.length > 0) {
|
|
|
|
+ obj.children2 = selectData.value[key].children2;
|
|
obj.other_type_label = selectData.value[key].other_type_label;
|
|
obj.other_type_label = selectData.value[key].other_type_label;
|
|
}
|
|
}
|
|
data.push(obj)
|
|
data.push(obj)
|
|
@@ -230,7 +230,23 @@ const onConfirm = () => {
|
|
onCancel();
|
|
onCancel();
|
|
emits('confirm', data)
|
|
emits('confirm', data)
|
|
};
|
|
};
|
|
-
|
|
|
|
|
|
+const checkedItem = (data, id, id2) => {
|
|
|
|
+ for(let i = 0; i < data.length; i++) {
|
|
|
|
+ if (data[i].id === id) {
|
|
|
|
+ let index = 0
|
|
|
|
+ for (let j = 0; j < data[i].children.length; j++) {
|
|
|
|
+ if (data[i].children[j].id == id2) {
|
|
|
|
+ index++
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (index > 0) {
|
|
|
|
+ data[i].checked = true;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
getPersonalTypeTree().then((res) => {
|
|
getPersonalTypeTree().then((res) => {
|
|
const data = res.rows;
|
|
const data = res.rows;
|
|
@@ -238,7 +254,35 @@ onMounted(() => {
|
|
item.open = false;
|
|
item.open = false;
|
|
item.checked = false;
|
|
item.checked = false;
|
|
item.isIndeterminate = false;
|
|
item.isIndeterminate = false;
|
|
|
|
+ selectData.value[item.id].type_parent = item.label;
|
|
})
|
|
})
|
|
|
|
+ if (props.data && props.data.length > 0) {
|
|
|
|
+
|
|
|
|
+ props.data.forEach((item) => {
|
|
|
|
+ if (item.children.length > 0) {
|
|
|
|
+ item.children.forEach(item2 => {
|
|
|
|
+ checkedItem(data, item.type_parent_id, item2)
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ selectData.value[item.type_parent_id].children = item.children;
|
|
|
|
+ selectData.value[item.type_parent_id].labelData = item.labelData;
|
|
|
|
+ selectData.value[item.type_parent_id].type_parent = item.type_parent;
|
|
|
|
+ selectData.value[item.type_parent_id].type_parent_id = item.type_parent_id;
|
|
|
|
+ if (['4', '5', '7'].includes(item.type_parent_id)) {
|
|
|
|
+ selectData.value[item.type_parent_id].dept_name = item.dept_name;
|
|
|
|
+ }
|
|
|
|
+ if (item.type_parent_id === '10') {
|
|
|
|
+ selectData.value[item.type_parent_id].denger_point_name = item.denger_point_name;
|
|
|
|
+ }
|
|
|
|
+ if (item.type_parent_id === '11') {
|
|
|
|
+ selectData.value[item.type_parent_id].other_type_2_name = item.other_type_2_name;
|
|
|
|
+ }
|
|
|
|
+ if (['5', '7', '9'].includes(item.type_parent_id)) {
|
|
|
|
+ selectData.value[item.type_parent_id].children2 = item.children2 ? item.children2 : [];
|
|
|
|
+ selectData.value[item.type_parent_id].other_type_label = item.other_type_label;
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ };
|
|
selectOptions.value = res.rows;
|
|
selectOptions.value = res.rows;
|
|
});
|
|
});
|
|
})
|
|
})
|