|
@@ -1,12 +1,17 @@
|
1
|
1
|
<script>
|
2
|
2
|
import mockData from "@/components/NewWorkPage/data";
|
|
3
|
+import {postAction} from "@/api/manage";
|
|
4
|
+import publicUrl from "@/api/publicUrl";
|
|
5
|
+import "./css/custom-selector.css"
|
3
|
6
|
|
4
|
7
|
export default {
|
5
|
8
|
name: "WellSelector",
|
|
9
|
+ props: ['selected'],
|
|
10
|
+ emits: ["update:selected"],
|
6
|
11
|
data() {
|
7
|
12
|
return {
|
8
|
13
|
wellSelector: {
|
9
|
|
- selected: '',
|
|
14
|
+ selected: [],
|
10
|
15
|
options: mockData.wellSelectorData
|
11
|
16
|
},
|
12
|
17
|
}
|
|
@@ -14,6 +19,71 @@ export default {
|
14
|
19
|
methods: {
|
15
|
20
|
changeSelected(node) {
|
16
|
21
|
console.log(node);
|
|
22
|
+ this.$emit("update:selected", node[node.length - 1]);
|
|
23
|
+ },
|
|
24
|
+ transSelectorOptions(d, node) {
|
|
25
|
+ if (!node) node = []
|
|
26
|
+ d.forEach(item => {
|
|
27
|
+ let m = {
|
|
28
|
+ value: item.wellId ? item.wellId : item.orgId,
|
|
29
|
+ label: item.orgName ? item.orgName : item.wellCommonName,
|
|
30
|
+ }
|
|
31
|
+
|
|
32
|
+ if (item.children && item.children.length > 0) {
|
|
33
|
+ m.children = []
|
|
34
|
+ this.transSelectorOptions(item.children, m.children)
|
|
35
|
+ }
|
|
36
|
+ node.push(m)
|
|
37
|
+ })
|
|
38
|
+ return node
|
|
39
|
+ },
|
|
40
|
+ async getWellsTree() {
|
|
41
|
+ let _this = this
|
|
42
|
+ await postAction(publicUrl.wellsTree).then((res) => {
|
|
43
|
+ if (res.data.status !== 1 || res.data.data.length <= 0) {
|
|
44
|
+ console.log('没有井信息')
|
|
45
|
+ return
|
|
46
|
+ }
|
|
47
|
+ let d = res.data.data
|
|
48
|
+ _this.wellSelector.options = _this.transSelectorOptions(d, [])
|
|
49
|
+ }).catch(reason => {
|
|
50
|
+ console.log(reason);
|
|
51
|
+ })
|
|
52
|
+ },
|
|
53
|
+ searchCheckNode(wellId, node, find) {
|
|
54
|
+ if (!wellId || !node || !find) return false
|
|
55
|
+ for (let i = 0; i < node.length; i++) {
|
|
56
|
+ if (node[i].value === wellId) {
|
|
57
|
+ find.unshift(node[i].value)
|
|
58
|
+ return true
|
|
59
|
+ }
|
|
60
|
+ if (node[i].children && node[i].children.length > 0) {
|
|
61
|
+ if (this.searchCheckNode(wellId, node[i].children, find)) {
|
|
62
|
+ find.unshift(node[i].value)
|
|
63
|
+ return true
|
|
64
|
+ }
|
|
65
|
+ }
|
|
66
|
+ }
|
|
67
|
+ return false
|
|
68
|
+ },
|
|
69
|
+ manualSelectWell(wellId) {
|
|
70
|
+ let find = []
|
|
71
|
+ this.searchCheckNode(wellId, this.wellSelector.options, find, 0);
|
|
72
|
+ this.wellSelector.selected = find
|
|
73
|
+ }
|
|
74
|
+ },
|
|
75
|
+ async mounted() {
|
|
76
|
+ await this.getWellsTree()
|
|
77
|
+ this.manualSelectWell('WELLTL100000864')
|
|
78
|
+ },
|
|
79
|
+ watch: {
|
|
80
|
+ selected: {
|
|
81
|
+ handler(newVal, oldVal) {
|
|
82
|
+ let cur = ''
|
|
83
|
+ if (this.wellSelector.selected.length > 0) cur = this.wellSelector.selected[this.wellSelector.selected.length - 1]
|
|
84
|
+ if (newVal !== cur)
|
|
85
|
+ this.wellSelector.selected = this.searchCheckNode(newVal, this.wellSelector.options, [])
|
|
86
|
+ }
|
17
|
87
|
}
|
18
|
88
|
}
|
19
|
89
|
}
|
|
@@ -22,9 +92,12 @@ export default {
|
22
|
92
|
<template>
|
23
|
93
|
<el-cascader
|
24
|
94
|
v-model="wellSelector.selected"
|
25
|
|
- placeholder="选择一口井"
|
|
95
|
+ class="custom-el-selector"
|
|
96
|
+ popper-class="custom-el-popper"
|
|
97
|
+ placeholder="手动选择一口井"
|
26
|
98
|
separator=' > '
|
27
|
99
|
clearable
|
|
100
|
+ :show-all-levels="false"
|
28
|
101
|
filterable
|
29
|
102
|
:options="wellSelector.options"
|
30
|
103
|
:props="{ expandTrigger: 'hover' }"
|