diff --git a/src/api/question.ts b/src/api/question.ts index be9307f..3f91829 100644 --- a/src/api/question.ts +++ b/src/api/question.ts @@ -14,6 +14,7 @@ export interface IQuestionData { quality: number withNext: boolean shop?: string + status?: number } export const defaultQuestionData: IQuestionData = { diff --git a/src/api/shoppuzzle.ts b/src/api/shoppuzzle.ts index 7540c1c..0575538 100644 --- a/src/api/shoppuzzle.ts +++ b/src/api/shoppuzzle.ts @@ -34,10 +34,11 @@ export const importQuestions = (shop: string, data: any) => data }) -export const deleteShopQuestion = (shop: string, id: string) => +export const deleteShopQuestion = (shop: string, ids: string[]) => request({ - url: `/api/${shop}/puzzle/${id}/delete`, - method: 'post' + url: `/api/${shop}/puzzle/delete`, + method: 'post', + data: { ids } }) export const getShopCategory = (shop: string) => diff --git a/src/views/question/shop_puzzle_editor.vue b/src/views/question/shop_puzzle_editor.vue index 765dd0e..396b813 100644 --- a/src/views/question/shop_puzzle_editor.vue +++ b/src/views/question/shop_puzzle_editor.vue @@ -302,7 +302,7 @@ export default class extends Vue { cancelButtonText: '取消', type: 'warning' }) - await deleteShopQuestion(this.postForm.shop!, this.postForm._id!) + await deleteShopQuestion(this.postForm.shop!, [this.postForm._id!]) this.loading = false EventBus.$emit(EVENT_SHOP_PUZZLES_UPDATE, {}) this.$store.dispatch('delView', this.$route) diff --git a/src/views/question/shop_puzzles.vue b/src/views/question/shop_puzzles.vue index aa1ecbb..f7b66eb 100644 --- a/src/views/question/shop_puzzles.vue +++ b/src/views/question/shop_puzzles.vue @@ -157,7 +157,13 @@ {{ item }} - + + + 0 ? '确定删除选中的题目' : '确定删除所有题目' await this.$confirm(str, 'Warning', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }) - if (this.multipleSelection.length > 0) { - for (const s of this.multipleSelection) { - this.questions.splice(this.questions.indexOf(s), 1) - } - (this.$refs.question_table as any).clearSelection() - } else { - this.questions.length = 0 + const ids: string[] = [] + for (const s of this.multipleSelection) { + ids.push(s._id) } - this.sliceData() + const { data } = await deleteShopQuestion(this.listQuery.shop, ids); + (this.$refs.question_table as any).clearSelection() this.$message({ type: 'success', - message: 'Deleted!' + message: `删除成功, 本次删除${data.n}条记录` }) + await this.getList() } catch (err) { console.log(err) }