he wei
2025-04-23 b9bd29a1a81f6f7de479e3cc3fdfe3d85fc660bf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import { ref, reactive, onMounted, computed, watch, watchEffect, nextTick } from "vue";
import { ElMessageBox, ElMessage, ElLoading } from "element-plus";
import {
  getProviceByUid,
  getCityByUid,
  getCountryByUid,
  getStationByUid,
  getLockByUid,
} from '@/api/station.js';
 
 
export default () => {
  const stationName1 = ref("");
  const stationName2 = ref("");
  const stationName3 = ref("");
  const stationName4 = ref("");
  const lockId = ref("");
  const lockName = ref("");
  const stationList1 = ref([]);
  const stationList2 = ref([]);
  const stationList3 = ref([]);
  const stationList4 = ref([]);
  const lockList = ref([]);
 
  onMounted(() => {
    getProviceList();
    getStationList();
    getLockList();
  });
 
  watch(
    () => stationName1.value,
    (val) => {
      if (val) {
        stationName2.value = "";
        getCityList();
      } else {
        stationList2.value = [];
        stationName2.value = "";
      }
      lockId.value = "";
      lockName.value = "";
      getLockList();
    }
  );
 
  watch(
    () => stationName2.value,
    (val) => {
      if (val) {
        stationName3.value = "";
        getCountryList();
      } else {
        stationList3.value = [];
        stationName3.value = "";
      }
      lockId.value = "";
      lockName.value = "";
      getLockList();
    }
  );
 
  watch(
    () => stationName3.value,
    (val) => {
      if (val) {
        stationName4.value = "";
        getStationList();
      } else {
        stationList4.value = [];
        stationName4.value = "";
      }
      lockId.value = "";
      lockName.value = "";
      getLockList();
    }
  );
 
  watch(
    () => stationName4.value,
    (val) => {
      if (val) {
        lockId.value = "";
        getLockList();
      } else {
        lockList.value = [];
        lockId.value = "";
      }
      lockId.value = "";
      lockName.value = "";
      getLockList();
    }
  );
 
  function getProviceList() {
    return getProviceByUid().then((res) => {
      let { code, data, data2 } = res;
      let _list = [];
      if (code && data) {
        _list = data2;
      }
      stationList1.value = _list;
      return _list;
    });
  }
 
  function getCityList() {
    return getCityByUid(stationName1.value).then((res) => {
      let { code, data, data2 } = res;
      let _list = [];
      if (code && data) {
        _list = data2;
      }
      stationList2.value = _list;
      // stationName2.value = "";
    });
  }
 
  function getCountryList() {
    return getCountryByUid(stationName1.value, stationName2.value).then((res) => {
      let { code, data, data2 } = res;
      let _list = [];
      if (code && data) {
        _list = data2;
      }
      stationList3.value = _list;
      // stationName3.value = "";
    });
  }
 
  function getStationList() {
    let params = {
      stationName1: stationName1.value || undefined,
      stationName2: stationName2.value || undefined,
      stationName3: stationName3.value || undefined,
    };
    return getStationByUid(params).then((res) => {
      let { code, data, data2 } = res;
      let _list = [];
      if (code && data) {
        _list = data2;
      }
      stationList4.value = _list;
      // stationName4.value = "";
    });
  }
 
  function getLockList() {
    let params = {
      stationName1: stationName1.value || undefined,
      stationName2: stationName2.value || undefined,
      stationName3: stationName3.value || undefined,
      stationName4: stationName4.value || undefined
    };
    return getLockByUid(params).then((res) => {
      let { code, data, data2 } = res;
      let _list = [];
      if (code && data) {
        _list = data2;
      }
      lockList.value = _list;
      // lockId.value = "";
    });
  }
 
  return { stationName1, stationName2, stationName3, stationName4, lockId, stationList1, stationList2, stationList3, stationList4, lockList, getProviceList, getCityList, getCountryList, getStationList, getLockList };
};