修正自定义题目无法删除的bug

This commit is contained in:
zhl 2021-06-01 11:01:01 +08:00
parent 5e7a24af26
commit df06dd5501
4 changed files with 35 additions and 15 deletions

View File

@ -14,6 +14,7 @@ export interface IQuestionData {
quality: number
withNext: boolean
shop?: string
status?: number
}
export const defaultQuestionData: IQuestionData = {

View File

@ -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) =>

View File

@ -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)

View File

@ -157,7 +157,13 @@
<el-tag v-for="item in row.groups" :key="item">{{ item }}</el-tag>
</template>
</el-table-column>
<el-table-column
label="状态"
>
<template slot-scope="{row}">
<span>{{ puzzleStatus(row.status) }}</span>
</template>
</el-table-column>
<el-table-column
align="center"
width="180"
@ -282,6 +288,17 @@ export default class extends Vue {
return formatQType(val)
}
private puzzleStatus(val: number) {
switch (val) {
case 1:
return '已审核'
case -1:
return '内容敏感'
default:
return '未审核'
}
}
async created() {
if (UserModule.level === 1) {
await this.getRemoteDeptList()
@ -322,7 +339,7 @@ export default class extends Vue {
cancelButtonText: '取消',
type: 'warning'
})
await deleteShopQuestion(this.listQuery.shop, row._id)
await deleteShopQuestion(this.listQuery.shop, [row._id])
this.list.splice($index, 1)
this.$message({
type: 'success',
@ -419,25 +436,26 @@ export default class extends Vue {
private async handleRemoveAll() {
try {
if (this.multipleSelection.length === 0) {
return
}
const str = this.multipleSelection.length > 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)
}