|
@@ -55,7 +55,7 @@
|
|
</el-select>
|
|
</el-select>
|
|
</template>
|
|
</template>
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
-import { computed, reactive, ref, watch } from 'vue';
|
|
|
|
|
|
+import { computed, nextTick, reactive, ref, watch } from "vue";
|
|
import { hotSpotSearch, hotSpotType } from '@/api/business/order';
|
|
import { hotSpotSearch, hotSpotType } from '@/api/business/order';
|
|
import { removeDuplicate } from '@/utils/arrayOperation';
|
|
import { removeDuplicate } from '@/utils/arrayOperation';
|
|
import { treeEventClass, treeEventClassSearch } from '@/api/auxiliary/eventClass';
|
|
import { treeEventClass, treeEventClassSearch } from '@/api/auxiliary/eventClass';
|
|
@@ -65,10 +65,6 @@ const props = defineProps({
|
|
type: [String, Array],
|
|
type: [String, Array],
|
|
default: () => '',
|
|
default: () => '',
|
|
},
|
|
},
|
|
- type: {
|
|
|
|
- type: String,
|
|
|
|
- default: 'hotspot',
|
|
|
|
- },
|
|
|
|
disabled: {
|
|
disabled: {
|
|
type: Boolean,
|
|
type: Boolean,
|
|
default: false,
|
|
default: false,
|
|
@@ -101,16 +97,13 @@ const props = defineProps({
|
|
default: true,
|
|
default: true,
|
|
},
|
|
},
|
|
} as any);
|
|
} as any);
|
|
-const inputPlaceholder = computed(() => {
|
|
|
|
- return props.type === 'hotspot' ? '热点名称' : '事件名称';
|
|
|
|
-});
|
|
|
|
// 选择节点展开
|
|
// 选择节点展开
|
|
const expandOnClickNode = computed(() => {
|
|
const expandOnClickNode = computed(() => {
|
|
return !props.checkStrictly;
|
|
return !props.checkStrictly;
|
|
});
|
|
});
|
|
const treeProps = computed(() => {
|
|
const treeProps = computed(() => {
|
|
return {
|
|
return {
|
|
- label: props.type === 'hotspot' ? 'hotSpotFullName' : 'eventFullName',
|
|
|
|
|
|
+ label: 'hotSpotFullName',
|
|
children: 'children',
|
|
children: 'children',
|
|
isLeaf: 'hasChild',
|
|
isLeaf: 'hasChild',
|
|
};
|
|
};
|
|
@@ -144,23 +137,20 @@ const loading = ref(false);
|
|
const treeRef = ref<RefType>();
|
|
const treeRef = ref<RefType>();
|
|
const loadNode = async (node: any, resolve: any) => {
|
|
const loadNode = async (node: any, resolve: any) => {
|
|
if (node.isLeaf) return resolve([]);
|
|
if (node.isLeaf) return resolve([]);
|
|
- const { showCheckbox, type, modelValue } = props;
|
|
|
|
|
|
+ const { showCheckbox, modelValue } = props;
|
|
try {
|
|
try {
|
|
loading.value = true;
|
|
loading.value = true;
|
|
- const method = type === 'hotspot' ? hotSpotType : treeEventClass;
|
|
|
|
- const { result } = await method({ id: node.data.id ? node.data.id : null });
|
|
|
|
|
|
+ const { result } = await hotSpotType({ id: node.data.id ? node.data.id : null });
|
|
resolve(result);
|
|
resolve(result);
|
|
state.id = modelValue;
|
|
state.id = modelValue;
|
|
if (showCheckbox) {
|
|
if (showCheckbox) {
|
|
treeRef.value.setCheckedKeys(modelValue);
|
|
treeRef.value.setCheckedKeys(modelValue);
|
|
const nodes = treeRef.value.getCheckedNodes();
|
|
const nodes = treeRef.value.getCheckedNodes();
|
|
- if (type === 'hotspot') state.name = nodes.map((item: any) => item.hotSpotFullName).join(',') ?? '';
|
|
|
|
- else state.name = nodes.map((item: any) => item.eventFullName).join(',') ?? '';
|
|
|
|
|
|
+ state.name = nodes.map((item: any) => item.hotSpotFullName).join(',') ?? '';
|
|
} else {
|
|
} else {
|
|
treeRef.value.setCurrentKey(modelValue);
|
|
treeRef.value.setCurrentKey(modelValue);
|
|
const currentNode = treeRef.value.getNode(modelValue);
|
|
const currentNode = treeRef.value.getNode(modelValue);
|
|
- if (type === 'hotspot') state.name = currentNode.data.hotSpotFullName;
|
|
|
|
- else state.name = currentNode.data.eventFullName;
|
|
|
|
|
|
+ state.name = currentNode.data.hotSpotFullName;
|
|
}
|
|
}
|
|
loading.value = false;
|
|
loading.value = false;
|
|
} catch (e) {
|
|
} catch (e) {
|
|
@@ -172,9 +162,7 @@ const filterMethod = (value: string) => {
|
|
if (value) {
|
|
if (value) {
|
|
lazyShow.value = false; //当输入框有值时关闭懒加载
|
|
lazyShow.value = false; //当输入框有值时关闭懒加载
|
|
loading.value = true;
|
|
loading.value = true;
|
|
- const { type } = props;
|
|
|
|
- const method = type === 'hotspot' ? hotSpotSearch : treeEventClassSearch;
|
|
|
|
- method(value)
|
|
|
|
|
|
+ hotSpotSearch(value)
|
|
.then((res) => {
|
|
.then((res) => {
|
|
//获取后端搜索的数据 //selectMacTree是我自己的后端接口,你们换成自己的
|
|
//获取后端搜索的数据 //selectMacTree是我自己的后端接口,你们换成自己的
|
|
state.treeData.length = 0;
|
|
state.treeData.length = 0;
|
|
@@ -205,14 +193,13 @@ const filterNode = (value: string, data: any) => {
|
|
// 单选
|
|
// 单选
|
|
const selectRef = ref<RefType>();
|
|
const selectRef = ref<RefType>();
|
|
const nodeClick = async (val: any, node: any) => {
|
|
const nodeClick = async (val: any, node: any) => {
|
|
- const { showCheckbox, checkStrictly, type } = props;
|
|
|
|
|
|
+ const { showCheckbox, checkStrictly } = props;
|
|
if (showCheckbox) return;
|
|
if (showCheckbox) return;
|
|
if (checkStrictly) {
|
|
if (checkStrictly) {
|
|
state.externalArr = [];
|
|
state.externalArr = [];
|
|
state.external = [];
|
|
state.external = [];
|
|
state.externalArr = getParentId(node, state.external);
|
|
state.externalArr = getParentId(node, state.external);
|
|
- if (type === 'hotspot') state.name = val.hotSpotFullName;
|
|
|
|
- else state.name = val.eventFullName;
|
|
|
|
|
|
+ state.name = val.hotSpotFullName;
|
|
state.id = val.id;
|
|
state.id = val.id;
|
|
emit('update:modelValue', val.id);
|
|
emit('update:modelValue', val.id);
|
|
emit('choose', { externalArr: state.externalArr, ...val });
|
|
emit('choose', { externalArr: state.externalArr, ...val });
|
|
@@ -222,8 +209,7 @@ const nodeClick = async (val: any, node: any) => {
|
|
state.externalArr = [];
|
|
state.externalArr = [];
|
|
state.external = [];
|
|
state.external = [];
|
|
state.externalArr = getParentId(node, state.external);
|
|
state.externalArr = getParentId(node, state.external);
|
|
- if (type === 'hotspot') state.name = val.hotSpotFullName;
|
|
|
|
- else state.name = val.eventFullName;
|
|
|
|
|
|
+ state.name = val.hotSpotFullName;
|
|
state.id = val.id;
|
|
state.id = val.id;
|
|
emit('update:modelValue', val.id);
|
|
emit('update:modelValue', val.id);
|
|
emit('choose', { externalArr: state.externalArr, ...val });
|
|
emit('choose', { externalArr: state.externalArr, ...val });
|
|
@@ -231,14 +217,13 @@ const nodeClick = async (val: any, node: any) => {
|
|
};
|
|
};
|
|
// 多选
|
|
// 多选
|
|
const checkChange = (val: any, e: any) => {
|
|
const checkChange = (val: any, e: any) => {
|
|
- const { showCheckbox, type } = props;
|
|
|
|
|
|
+ const { showCheckbox } = props;
|
|
if (!showCheckbox) return;
|
|
if (!showCheckbox) return;
|
|
const current = treeRef.value.getNode(val);
|
|
const current = treeRef.value.getNode(val);
|
|
state.checkedKeys = e.checkedKeys;
|
|
state.checkedKeys = e.checkedKeys;
|
|
state.checkedNodes = e.checkedNodes;
|
|
state.checkedNodes = e.checkedNodes;
|
|
state.id = e.checkedKeys;
|
|
state.id = e.checkedKeys;
|
|
- if (type === 'hotspot') state.name = e.checkedNodes.map((item: any) => item.hotSpotFullName).join(',') ?? '';
|
|
|
|
- else state.name = e.checkedNodes.map((item: any) => item.eventFullName).join(',') ?? '';
|
|
|
|
|
|
+ state.name = e.checkedNodes.map((item: any) => item.hotSpotFullName).join(',') ?? '';
|
|
if (props.externalArr.length) {
|
|
if (props.externalArr.length) {
|
|
state.externalArr = props.externalArr.concat(getParentId(current, state.external));
|
|
state.externalArr = props.externalArr.concat(getParentId(current, state.external));
|
|
} else {
|
|
} else {
|