forked from liweijie/education
教学大纲停用改删除
This commit is contained in:
@@ -34,12 +34,13 @@
|
|||||||
<div class="list-actions">
|
<div class="list-actions">
|
||||||
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button>
|
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
|
v-if="Number(searchForm.ty) !== 1"
|
||||||
type="danger"
|
type="danger"
|
||||||
plain
|
plain
|
||||||
icon="el-icon-delete"
|
icon="el-icon-circle-close"
|
||||||
:disabled="!selection.length"
|
:disabled="!activeSelection.length"
|
||||||
@click="handleBatchDelete"
|
@click="handleBatchDelete"
|
||||||
>删除所选</el-button>
|
>停用所选</el-button>
|
||||||
<el-button icon="el-icon-download" @click="handleDownload">下载</el-button>
|
<el-button icon="el-icon-download" @click="handleDownload">下载</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -87,7 +88,14 @@
|
|||||||
<el-table-column label="操作" width="160" align="center" fixed="right">
|
<el-table-column label="操作" width="160" align="center" fixed="right">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button type="text" size="mini" icon="el-icon-edit" @click="handleEdit(scope.row)">编辑</el-button>
|
<el-button type="text" size="mini" icon="el-icon-edit" @click="handleEdit(scope.row)">编辑</el-button>
|
||||||
<el-button type="text" size="mini" icon="el-icon-delete" class="danger-text-btn" @click="handleDelete(scope.row)">删除</el-button>
|
<el-button
|
||||||
|
v-if="!isDisabled(scope.row)"
|
||||||
|
type="text"
|
||||||
|
size="mini"
|
||||||
|
icon="el-icon-circle-close"
|
||||||
|
class="danger-text-btn"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
>停用</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@@ -341,6 +349,9 @@ export default {
|
|||||||
}
|
}
|
||||||
const start = (this.pageNum - 1) * this.pageSize
|
const start = (this.pageNum - 1) * this.pageSize
|
||||||
return this.tableData.slice(start, start + this.pageSize)
|
return this.tableData.slice(start, start + this.pageSize)
|
||||||
|
},
|
||||||
|
activeSelection() {
|
||||||
|
return this.selection.filter(row => !this.isDisabled(row))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@@ -452,33 +463,39 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
/* ---------- 删除 / 批量删除 ---------- */
|
/* ---------- 停用 / 批量停用 ---------- */
|
||||||
|
isDisabled(row) {
|
||||||
|
return Number(row && row.ty) === 1
|
||||||
|
},
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
this.$confirm('删除后该条记录将置为「停用」,是否继续?', '提示', {
|
if (this.isDisabled(row)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.$confirm('确认停用该条教学大纲吗?', '提示', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return deleteSyllabus(row.bh)
|
return deleteSyllabus(row.bh)
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.$message.success('删除成功')
|
this.$message.success('停用成功')
|
||||||
this.fetchList()
|
this.fetchList()
|
||||||
}).catch(() => {})
|
}).catch(() => {})
|
||||||
},
|
},
|
||||||
handleBatchDelete() {
|
handleBatchDelete() {
|
||||||
if (!this.selection.length) {
|
const bhList = this.activeSelection.map(row => row.bh)
|
||||||
this.$message.warning('请先勾选要删除的记录')
|
if (!bhList.length) {
|
||||||
|
this.$message.warning('请先勾选要停用的记录')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const bhList = this.selection.map(row => row.bh)
|
this.$confirm('确定停用所选 ' + bhList.length + ' 条记录吗?', '提示', {
|
||||||
this.$confirm('确定删除所选 ' + bhList.length + ' 条记录吗?(将置为「停用」)', '提示', {
|
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return batchDeleteSyllabus(bhList)
|
return batchDeleteSyllabus(bhList)
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.$message.success('批量删除成功')
|
this.$message.success('批量停用成功')
|
||||||
this.fetchList()
|
this.fetchList()
|
||||||
}).catch(() => {})
|
}).catch(() => {})
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user