|
@@ -84,9 +84,18 @@
|
|
|
width="120"
|
|
|
>
|
|
|
<template slot-scope="scope">
|
|
|
+ <el-switch
|
|
|
+ v-model="scope.row.status"
|
|
|
+ active-color="#13ce66"
|
|
|
+ :active-value="1"
|
|
|
+ :inactive-value="2"
|
|
|
+ @change="handleStatusChange(scope.row)"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <!-- <template slot-scope="scope">
|
|
|
<el-tag v-if="scope.row.status === 1" type="success">开启中</el-tag>
|
|
|
<el-tag v-if="scope.row.status === 2" type="danger">禁用中</el-tag>
|
|
|
- </template>
|
|
|
+ </template> -->
|
|
|
</el-table-column>
|
|
|
<el-table-column
|
|
|
v-if="codes.includes('type')"
|
|
@@ -154,7 +163,7 @@
|
|
|
|
|
|
<script>
|
|
|
import CreateDialog from './CreateDialog.vue'
|
|
|
-import { del_rule } from '@/api/rule/config'
|
|
|
+import { del_rule, edit_rule_status } from '@/api/rule/config'
|
|
|
|
|
|
export default {
|
|
|
components: {
|
|
@@ -205,7 +214,11 @@ export default {
|
|
|
createData: {
|
|
|
bSwitch: false,
|
|
|
row: {}
|
|
|
- }
|
|
|
+ },
|
|
|
+ statusArr: [
|
|
|
+ { 'id': 1, 'name': '启用' },
|
|
|
+ { 'id': 2, 'name': '停用' }
|
|
|
+ ]
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
@@ -248,6 +261,23 @@ export default {
|
|
|
handleChange(val) {
|
|
|
const checkedCount = val.length
|
|
|
this.checkAll = checkedCount === this.defaultCodes.length
|
|
|
+ },
|
|
|
+ handleStatusChange(row) {
|
|
|
+ const statusIndex = this.statusArr.findIndex((value) => parseInt(value.id) === parseInt(row.status))
|
|
|
+ this.$confirm('确认要更改为 <strong>' + this.statusArr[statusIndex].name + '</strong> 状态吗?', '提示', {
|
|
|
+ dangerouslyUseHTMLString: true,
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ edit_rule_status({ id: row.id, status: row.status }).then((res) => {
|
|
|
+ this.$message.success(res.m || '操作成功')
|
|
|
+ }).catch(function() {
|
|
|
+ row.status = row.status === 1 ? 2 : 1
|
|
|
+ })
|
|
|
+ }).catch(function() {
|
|
|
+ row.status = row.status === 1 ? 2 : 1
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|