|
@@ -2,7 +2,17 @@
|
|
|
<div id="list">
|
|
|
<el-row>
|
|
|
<el-col :span="24">
|
|
|
- <data-table :fields="fields" :opera="opera" :total="total" :data="list" @query="search">
|
|
|
+ <data-table
|
|
|
+ :fields="fields"
|
|
|
+ :opera="opera"
|
|
|
+ :total="total"
|
|
|
+ :data="list"
|
|
|
+ @query="search"
|
|
|
+ @toEdit="toEdit"
|
|
|
+ @toDelete="toDelete"
|
|
|
+ @toUse="({data})=>toDefaultTemplate(data,true)"
|
|
|
+ @toDisable="({data})=>toDefaultTemplate(data,false)"
|
|
|
+ >
|
|
|
<template #selfbtn>
|
|
|
<el-button type="primary" @click="toCreate">添加</el-button>
|
|
|
</template>
|
|
@@ -14,7 +24,7 @@
|
|
|
|
|
|
<script>
|
|
|
import dataTable from '@/components/free/filter-page-table.vue'
|
|
|
-import { mapState, createNamespacedHelpers } from 'vuex'
|
|
|
+import { createNamespacedHelpers } from 'vuex'
|
|
|
const { mapActions } = createNamespacedHelpers('template')
|
|
|
export default {
|
|
|
name: 'List',
|
|
@@ -30,7 +40,9 @@ export default {
|
|
|
],
|
|
|
opera: [
|
|
|
{ label: '编辑', method: 'toEdit' },
|
|
|
- { label: '删除', method: 'toDelete', type: 'danger' }
|
|
|
+ { label: '使用', method: 'toUse', type: 'success', display: i => !i.is_use, confirm: true },
|
|
|
+ { label: '禁用', method: 'toDisable', type: 'warning', display: i => i.is_use, confirm: true },
|
|
|
+ { label: '删除', method: 'toDelete', type: 'danger', confirm: true }
|
|
|
]
|
|
|
}
|
|
|
},
|
|
@@ -38,7 +50,7 @@ export default {
|
|
|
this.search()
|
|
|
},
|
|
|
methods: {
|
|
|
- ...mapActions(['query', 'delete']),
|
|
|
+ ...mapActions(['query', 'update', 'delete', 'toUse']),
|
|
|
async search({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
const res = await this.query({ skip, limit, ...info })
|
|
|
if (this.$checkRes(res)) {
|
|
@@ -46,10 +58,28 @@ export default {
|
|
|
this.$set(this, `total`, res.total)
|
|
|
}
|
|
|
},
|
|
|
- async toDelete({ data }) {},
|
|
|
- async toEdit({ data }) {},
|
|
|
+ async toDelete({ data }) {
|
|
|
+ const res = await this.delete(data._id || data.id)
|
|
|
+ if (this.$checkRes(res, res.msg, res.msg || '操作失败')) {
|
|
|
+ this.search()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async toEdit({ data }) {
|
|
|
+ this.$emit('toEdit', data._id)
|
|
|
+ },
|
|
|
async toCreate() {
|
|
|
this.$emit('toAdd')
|
|
|
+ },
|
|
|
+ async toDefaultTemplate(data, boo) {
|
|
|
+ let res
|
|
|
+ if (!boo) {
|
|
|
+ res = await this.update({ id: data._id || data.id, is_use: boo })
|
|
|
+ } else {
|
|
|
+ res = await this.toUse(data._id || data.id)
|
|
|
+ }
|
|
|
+ if (this.$checkRes(res, res.msg, res.msg || '操作失败')) {
|
|
|
+ this.search()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -58,4 +88,5 @@ export default {
|
|
|
<style lang="scss" scoped>
|
|
|
.main {
|
|
|
padding: 25px 30px 30px;
|
|
|
-}</style>
|
|
|
+}
|
|
|
+</style>
|