You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
3.5 KiB
109 lines
3.5 KiB
/**
|
|
* 禁飞区
|
|
*/
|
|
import { ref } from 'vue';
|
|
import { defineStore } from 'pinia';
|
|
import http from '@/utils/http';
|
|
import * as urls from '@/config/urls';
|
|
import * as helpers from '@/utils/helpers';
|
|
|
|
export const useNoFlyZoneStore = defineStore('noFlyZone', () => {
|
|
const noFlyZoneList = ref([]);
|
|
const noFlyZoneExtra = ref({ total: null });
|
|
const noFlyZoneQueries = ref({ page: 1, pageSize: 10, all: undefined, type: undefined, search: undefined });
|
|
|
|
const noFlyZoneDetail = ref({});
|
|
|
|
function getNoFlyZoneList(otherQueries = {}, { mergeArgs = true, mergeData = true } = {}) {
|
|
return http.getInstance().get(urls.GET_NO_FLY_ZONE_LIST, {
|
|
params: { ...noFlyZoneQueries.value, ...otherQueries },
|
|
}).then(({ data }) => {
|
|
const { data: list, extra } = data;
|
|
if (mergeData) noFlyZoneList.value = list || [];
|
|
if (mergeData) noFlyZoneExtra.value = { ...noFlyZoneExtra.value, ...(extra || {}) };
|
|
if (mergeArgs) noFlyZoneQueries.value = { ...noFlyZoneQueries.value, ...otherQueries };
|
|
return data;
|
|
});
|
|
}
|
|
|
|
function getNoFlyZoneDetail(noFlyZoneId = '') {
|
|
const url = helpers.buildURL(urls.GET_NO_FLY_ZONE_DETAIL, noFlyZoneId);
|
|
return http.getInstance().get(url).then(({ data }) => {
|
|
const { data: detail } = data || {};
|
|
noFlyZoneDetail.value = detail;
|
|
return data;
|
|
});
|
|
}
|
|
|
|
function createNoFlyZone(formData = {}, { refreshList = false } = {}) {
|
|
const reqData = helpers.pick(formData, [
|
|
'detailAddress',
|
|
'effectTimeStart',
|
|
'effectTimeEnd',
|
|
'province',
|
|
// 'city',
|
|
// 'county',
|
|
'orbit',
|
|
]);
|
|
|
|
return http.getInstance().post(urls.CREATE_NO_FLY_ZONE, reqData).then(({ data }) => {
|
|
if (refreshList) getNoFlyZoneList();
|
|
return data;
|
|
});
|
|
}
|
|
|
|
function updateNoFlyZone(formData = {}, { refreshList = false } = {}) {
|
|
const reqData = helpers.pick(formData, [
|
|
'id',
|
|
'detailAddress',
|
|
'effectTimeStart',
|
|
'effectTimeEnd',
|
|
'province',
|
|
// 'city',
|
|
// 'county',
|
|
'orbit',
|
|
'isEnable',
|
|
]);
|
|
|
|
const url = helpers.buildURL(urls.UPDATE_NO_FLY_ZONE, reqData.id);
|
|
return http.getInstance().put(url, reqData).then(({ data }) => {
|
|
if (refreshList) getNoFlyZoneList();
|
|
return data;
|
|
});
|
|
}
|
|
|
|
function deleteNoFlyZone(noFlyZoneId = '', { refreshList = false } = {}) {
|
|
const url = helpers.buildURL(urls.DELETE_NO_FLY_ZONE, noFlyZoneId);
|
|
return http.getInstance().delete(url).then(({ data }) => {
|
|
if (refreshList) getNoFlyZoneList();
|
|
return data;
|
|
});
|
|
}
|
|
|
|
function updateNoFlyZoneState(formData = {}, { refreshList = false } = {}) {
|
|
const reqData = helpers.pick(formData, [
|
|
'id',
|
|
]);
|
|
|
|
const url = helpers.buildURL(urls.UPDATE_NO_FLY_ZONE_DISABLE, reqData.id);
|
|
return http.getInstance().put(url).then(({ data }) => {
|
|
if (refreshList) getNoFlyZoneList();
|
|
return data;
|
|
});
|
|
}
|
|
|
|
return {
|
|
noFlyZoneList,
|
|
noFlyZoneQueries,
|
|
noFlyZoneExtra,
|
|
noFlyZoneDetail,
|
|
getNoFlyZoneList,
|
|
createNoFlyZone,
|
|
updateNoFlyZone,
|
|
deleteNoFlyZone,
|
|
updateNoFlyZoneState,
|
|
getNoFlyZoneDetail,
|
|
};
|
|
});
|
|
|
|
export default null;
|
|
|