增加 删除功能
This commit is contained in:
parent
eb4fd48b82
commit
614b69a8b1
@ -829,14 +829,14 @@ export const LibrariesApiAxiosParamCreator = function (configuration?: Configura
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @summary 显示资料库
|
||||
* @summary 删除资料库
|
||||
* @param {number} libraryId 资料库 ID
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
libraryLibraryIdGet: async (libraryId: number, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
libraryLibraryIdDelete: async (libraryId: number, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
// verify required parameter 'libraryId' is not null or undefined
|
||||
assertParamExists('libraryLibraryIdGet', 'libraryId', libraryId)
|
||||
assertParamExists('libraryLibraryIdDelete', 'libraryId', libraryId)
|
||||
const localVarPath = `/library/{LibraryId}`
|
||||
.replace(`{${"LibraryId"}}`, encodeURIComponent(String(libraryId)));
|
||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||
@ -846,7 +846,7 @@ export const LibrariesApiAxiosParamCreator = function (configuration?: Configura
|
||||
baseOptions = configuration.baseOptions;
|
||||
}
|
||||
|
||||
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
|
||||
const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options};
|
||||
const localVarHeaderParameter = {} as any;
|
||||
const localVarQueryParameter = {} as any;
|
||||
|
||||
@ -866,14 +866,14 @@ export const LibrariesApiAxiosParamCreator = function (configuration?: Configura
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @summary 删除资料库
|
||||
* @summary 显示资料库
|
||||
* @param {number} libraryId 资料库 ID
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
libraryLibraryIdPost: async (libraryId: number, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
libraryLibraryIdGet: async (libraryId: number, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
// verify required parameter 'libraryId' is not null or undefined
|
||||
assertParamExists('libraryLibraryIdPost', 'libraryId', libraryId)
|
||||
assertParamExists('libraryLibraryIdGet', 'libraryId', libraryId)
|
||||
const localVarPath = `/library/{LibraryId}`
|
||||
.replace(`{${"LibraryId"}}`, encodeURIComponent(String(libraryId)));
|
||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||
@ -883,7 +883,7 @@ export const LibrariesApiAxiosParamCreator = function (configuration?: Configura
|
||||
baseOptions = configuration.baseOptions;
|
||||
}
|
||||
|
||||
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
|
||||
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
|
||||
const localVarHeaderParameter = {} as any;
|
||||
const localVarQueryParameter = {} as any;
|
||||
|
||||
@ -937,6 +937,19 @@ export const LibrariesApiFp = function(configuration?: Configuration) {
|
||||
const operationBasePath = operationServerMap['LibrariesApi.librariesPost']?.[index]?.url;
|
||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @summary 删除资料库
|
||||
* @param {number} libraryId 资料库 ID
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async libraryLibraryIdDelete(libraryId: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.libraryLibraryIdDelete(libraryId, options);
|
||||
const index = configuration?.serverIndex ?? 0;
|
||||
const operationBasePath = operationServerMap['LibrariesApi.libraryLibraryIdDelete']?.[index]?.url;
|
||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @summary 显示资料库
|
||||
@ -950,19 +963,6 @@ export const LibrariesApiFp = function(configuration?: Configuration) {
|
||||
const operationBasePath = operationServerMap['LibrariesApi.libraryLibraryIdGet']?.[index]?.url;
|
||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @summary 删除资料库
|
||||
* @param {number} libraryId 资料库 ID
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async libraryLibraryIdPost(libraryId: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.libraryLibraryIdPost(libraryId, options);
|
||||
const index = configuration?.serverIndex ?? 0;
|
||||
const operationBasePath = operationServerMap['LibrariesApi.libraryLibraryIdPost']?.[index]?.url;
|
||||
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
@ -993,6 +993,16 @@ export const LibrariesApiFactory = function (configuration?: Configuration, base
|
||||
librariesPost(name: number, options?: any): AxiosPromise<ModelLibrary> {
|
||||
return localVarFp.librariesPost(name, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @summary 删除资料库
|
||||
* @param {number} libraryId 资料库 ID
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
libraryLibraryIdDelete(libraryId: number, options?: any): AxiosPromise<void> {
|
||||
return localVarFp.libraryLibraryIdDelete(libraryId, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @summary 显示资料库
|
||||
@ -1003,16 +1013,6 @@ export const LibrariesApiFactory = function (configuration?: Configuration, base
|
||||
libraryLibraryIdGet(libraryId: number, options?: any): AxiosPromise<void> {
|
||||
return localVarFp.libraryLibraryIdGet(libraryId, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @summary 删除资料库
|
||||
* @param {number} libraryId 资料库 ID
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
libraryLibraryIdPost(libraryId: number, options?: any): AxiosPromise<void> {
|
||||
return localVarFp.libraryLibraryIdPost(libraryId, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@ -1047,6 +1047,18 @@ export class LibrariesApi extends BaseAPI {
|
||||
return LibrariesApiFp(this.configuration).librariesPost(name, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary 删除资料库
|
||||
* @param {number} libraryId 资料库 ID
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
* @memberof LibrariesApi
|
||||
*/
|
||||
public libraryLibraryIdDelete(libraryId: number, options?: AxiosRequestConfig) {
|
||||
return LibrariesApiFp(this.configuration).libraryLibraryIdDelete(libraryId, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary 显示资料库
|
||||
@ -1058,18 +1070,6 @@ export class LibrariesApi extends BaseAPI {
|
||||
public libraryLibraryIdGet(libraryId: number, options?: AxiosRequestConfig) {
|
||||
return LibrariesApiFp(this.configuration).libraryLibraryIdGet(libraryId, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary 删除资料库
|
||||
* @param {number} libraryId 资料库 ID
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
* @memberof LibrariesApi
|
||||
*/
|
||||
public libraryLibraryIdPost(libraryId: number, options?: AxiosRequestConfig) {
|
||||
return LibrariesApiFp(this.configuration).libraryLibraryIdPost(libraryId, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,11 +3,34 @@
|
||||
<v-container v-else>
|
||||
<h1>资料库</h1>
|
||||
|
||||
<div>
|
||||
<!-- <div>
|
||||
{{ selected_ids }}
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<v-btn @click="selectAll">全选</v-btn>
|
||||
<v-btn @click="selectAll" :color="selected_ids.length > 0 ? 'primary' : ''">全选</v-btn>
|
||||
|
||||
<v-btn
|
||||
class="ml-2"
|
||||
:disabled="selected_ids.length === 0"
|
||||
:loading="is_deleting"
|
||||
>删除所选
|
||||
|
||||
<v-dialog
|
||||
v-model="show_dialog"
|
||||
activator="parent"
|
||||
width="auto"
|
||||
>
|
||||
<v-card>
|
||||
<v-card-text>
|
||||
确认删除所选项?
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-btn color="primary" @click="deleteSelected" :loading="is_deleting">确认删除</v-btn>
|
||||
<v-btn @click="show_dialog = false">取消</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-btn>
|
||||
<v-card class="mt-3">
|
||||
<v-list>
|
||||
<v-list-item
|
||||
@ -36,29 +59,27 @@
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-card>
|
||||
|
||||
|
||||
</v-container>
|
||||
|
||||
<div class="text-center">
|
||||
<v-container>
|
||||
<v-row justify="center">
|
||||
<v-col cols="8">
|
||||
<v-container class="max-width">
|
||||
<v-pagination
|
||||
v-model="page"
|
||||
class="my-4"
|
||||
:length="libraries.Total"
|
||||
:disabled="loading"
|
||||
@update:model-value="load"
|
||||
></v-pagination>
|
||||
</v-container>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</div>
|
||||
|
||||
<v-container>
|
||||
<v-row justify="center">
|
||||
<v-col cols="8">
|
||||
<v-container class="max-width">
|
||||
<v-pagination
|
||||
v-model="page"
|
||||
class="my-4"
|
||||
:length="libraries.Total"
|
||||
:disabled="loading"
|
||||
@update:model-value="load"
|
||||
></v-pagination>
|
||||
</v-container>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</div>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -70,13 +91,18 @@ const loading = ref(false);
|
||||
|
||||
const page = ref(1);
|
||||
const libraries = ref({});
|
||||
const selected_ids = ref([]);
|
||||
const is_deleting = ref(false);
|
||||
const show_dialog = ref(false);
|
||||
|
||||
const load = () => {
|
||||
loading.value = true;
|
||||
selected_ids.value = [];
|
||||
library
|
||||
.librariesGet(page.value)
|
||||
.then((r) => {
|
||||
libraries.value = r.data;
|
||||
page.value = r.data.Page
|
||||
console.log(r.data.Data);
|
||||
})
|
||||
.finally(() => {
|
||||
@ -90,8 +116,6 @@ const goto = (libraryId) => {
|
||||
console.log(libraryId);
|
||||
};
|
||||
|
||||
const selected_ids = ref([]);
|
||||
|
||||
function isSelected(id) {
|
||||
return this.selected_ids.includes(id);
|
||||
}
|
||||
@ -110,7 +134,7 @@ function toggleSelection(id) {
|
||||
/**
|
||||
* Selects all items if none are selected, otherwise clears the selection.
|
||||
*
|
||||
* @return {void}
|
||||
* @return {void}
|
||||
*/
|
||||
function selectAll() {
|
||||
if (selected_ids.value.length > 0) {
|
||||
@ -122,4 +146,33 @@ function selectAll() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function deleteSelected() {
|
||||
if (selected_ids.value.length > 0) {
|
||||
is_deleting.value = true;
|
||||
libraries.value.Data.forEach((item) => {
|
||||
library.libraryLibraryIdDelete(item.ID).then((r) => {
|
||||
console.log("Library deleted: " + item.ID);
|
||||
|
||||
// remove
|
||||
libraries.value.Data = libraries.value.Data.filter(
|
||||
(i) => i.ID !== item.ID
|
||||
)
|
||||
});
|
||||
});
|
||||
|
||||
selected_ids.value = [];
|
||||
setTimeout(() => {
|
||||
if (page.value == libraries.value.Page) {
|
||||
page.value = page.value - 1;
|
||||
}
|
||||
|
||||
load();
|
||||
|
||||
is_deleting.value = false;
|
||||
|
||||
show_dialog.value = false
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user