Parcourir la source

well selector complete

lloyd il y a 3 mois
Parent
commit
580aefdd15

+ 5 - 1
src/api/publicUrl.js

@@ -226,5 +226,9 @@ let publicUrl = {
226 226
 	downLoadMeterExample:'/centralbase/CbPcProWellMeterTeam/downLoadMeterExample',//下载示例
227 227
 	uploadMeter:'/centralbase/CbPcProWellMeterTeam/uploadMeter',//下载示例
228 228
 
229
+
230
+	//一次性获取所有井选择信息
231
+	wellsTree:'data-authorize/refactor/well/navigate/auth',
232
+
229 233
 }
230
-export default publicUrl
234
+export default publicUrl

+ 2 - 2
src/components/NewWorkPage/DvhCompareDialog.vue

@@ -1,7 +1,7 @@
1 1
 <script>
2 2
 import mockData from "@/components/NewWorkPage/data";
3
-import "./css/Layout.css"
4
-import "./css/DvhCheck.css"
3
+import "./css/layout.css"
4
+import "./css/dvh-check.css"
5 5
 
6 6
 export default {
7 7
   name: "DvhCompareDialog",

+ 3 - 3
src/components/NewWorkPage/MainLayout.vue

@@ -1,5 +1,5 @@
1 1
 <script>
2
-import "./css/NewWorkPage.css"
2
+import "./css/new-work-page.css"
3 3
 import mockData from "@/components/NewWorkPage/data";
4 4
 import DvhCompareDialog from "@/components/NewWorkPage/DvhCompareDialog.vue";
5 5
 import WellSelector from "@/components/NewWorkPage/WellSelector.vue";
@@ -11,7 +11,7 @@ export default {
11 11
     return {
12 12
       //井选择器
13 13
       wellSelector: {
14
-        options: mockData.wellSelectorData
14
+        selected:''
15 15
       },
16 16
       //功图校核页面
17 17
       dvhCardCheck: {
@@ -28,7 +28,7 @@ export default {
28 28
 <template>
29 29
   <div class="main">
30 30
     <div class="header">
31
-     <WellSelector></WellSelector>
31
+     <WellSelector :selected.sync="wellSelector.selected"></WellSelector>
32 32
       <el-button type="primary" size="small">查询</el-button>
33 33
 
34 34
 

+ 75 - 2
src/components/NewWorkPage/WellSelector.vue

@@ -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' }"

+ 12 - 0
src/components/NewWorkPage/css/custom-selector.css

@@ -0,0 +1,12 @@
1
+.custom-el-selector {
2
+    width: 150px;
3
+}
4
+
5
+.custom-el-popper .el-cascader-panel {
6
+    background-color: rgb(246, 244, 244);
7
+}
8
+
9
+.custom-el-popper .el-cascader-panel .el-cascader-node{
10
+    height: 26px;
11
+    font-size: 14px;
12
+}

src/components/NewWorkPage/css/DvhCheck.css → src/components/NewWorkPage/css/dvh-check.css


src/components/NewWorkPage/css/Layout.css → src/components/NewWorkPage/css/layout.css


src/components/NewWorkPage/css/NewWorkPage.css → src/components/NewWorkPage/css/new-work-page.css