| | |
| | | getCountryByUid, |
| | | getStationByUid, |
| | | getPowerByUid, |
| | | getBattByUid, |
| | | } from '@/api/station.js'; |
| | | |
| | | |
| | |
| | | const city = ref(""); |
| | | const country = ref(""); |
| | | const stationName = ref(""); |
| | | const stationId = ref(""); |
| | | const powerId = ref(""); |
| | | const lockName = ref(""); |
| | | const battId = ref(""); |
| | | const proviceList = ref([]); |
| | | const cityList = ref([]); |
| | | const countryList = ref([]); |
| | | const stationList = ref([]); |
| | | const powerList = ref([]); |
| | | const battList = ref([]); |
| | | |
| | | onMounted(() => { |
| | | getProviceList(); |
| | | getStationList(); |
| | | getPowerList(); |
| | | const isManual = ref(false); |
| | | |
| | | let loadPromise = null; |
| | | |
| | | onMounted(async () => { |
| | | loadPromise = new Promise(async (resolve, reject) => { |
| | | await getProviceList(); |
| | | await getStationList(); |
| | | await getPowerList(); |
| | | await getBattList(); |
| | | |
| | | resolve(); |
| | | }); |
| | | }); |
| | | |
| | | watch( |
| | |
| | | city.value = ""; |
| | | } |
| | | powerId.value = ""; |
| | | lockName.value = ""; |
| | | battId.value = ""; |
| | | getPowerList(); |
| | | getBattList(); |
| | | } |
| | | ); |
| | | |
| | |
| | | country.value = ""; |
| | | } |
| | | powerId.value = ""; |
| | | lockName.value = ""; |
| | | battId.value = ""; |
| | | getPowerList(); |
| | | getBattList(); |
| | | } |
| | | ); |
| | | |
| | |
| | | stationName.value = ""; |
| | | } |
| | | powerId.value = ""; |
| | | lockName.value = ""; |
| | | battId.value = ""; |
| | | getPowerList(); |
| | | getBattList(); |
| | | } |
| | | ); |
| | | |
| | | watch( |
| | | () => stationName.value, |
| | | (val) => { |
| | | if (val) { |
| | | powerId.value = ""; |
| | | getPowerList(); |
| | | } else { |
| | | powerList.value = []; |
| | | powerId.value = ""; |
| | | async (val) => { |
| | | // if (val) { |
| | | // powerId.value = ""; |
| | | // } else { |
| | | // powerList.value = []; |
| | | // powerId.value = ""; |
| | | // } |
| | | let station = stationList.value.find(v => v.stationName == val); |
| | | if (station) { |
| | | stationId.value = station.stationId; |
| | | } |
| | | powerId.value = ""; |
| | | lockName.value = ""; |
| | | getPowerList(); |
| | | if (!isManual.value) { |
| | | powerId.value = ""; |
| | | battId.value = ""; |
| | | await getPowerList(); |
| | | await getBattList(); |
| | | } |
| | | } |
| | | ); |
| | | |
| | |
| | | } |
| | | cityList.value = _list; |
| | | // city.value = ""; |
| | | return _list; |
| | | }); |
| | | } |
| | | |
| | |
| | | } |
| | | countryList.value = _list; |
| | | // country.value = ""; |
| | | return _list; |
| | | }); |
| | | } |
| | | |
| | |
| | | } |
| | | stationList.value = _list; |
| | | // stationName.value = ""; |
| | | return _list; |
| | | }); |
| | | } |
| | | |
| | |
| | | } |
| | | powerList.value = _list; |
| | | // powerId.value = ""; |
| | | return _list; |
| | | }); |
| | | } |
| | | |
| | | return { provice, city, country, stationName, powerId, proviceList, cityList, countryList, stationList, powerList, getProviceList, getCityList, getCountryList, getStationList, getPowerList }; |
| | | function getBattList() { |
| | | let params = { |
| | | provice: provice.value || undefined, |
| | | city: city.value || undefined, |
| | | country: country.value || undefined, |
| | | stationName: stationName.value || undefined, |
| | | }; |
| | | return getBattByUid(params).then((res) => { |
| | | let { code, data, data2 } = res; |
| | | let _list = []; |
| | | if (code && data) { |
| | | _list = data2; |
| | | } |
| | | battList.value = _list; |
| | | // powerId.value = ""; |
| | | isManual.value = false; |
| | | return _list; |
| | | }); |
| | | } |
| | | |
| | | return { provice, city, country, stationName, stationId, powerId, battId, proviceList, cityList, countryList, stationList, powerList, battList, getProviceList, getCityList, getCountryList, getStationList, getPowerList, getBattList, isManual, |
| | | whenLoaded: () => loadPromise, |
| | | }; |
| | | }; |