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 };
|
};
|