doum
3 天以前 080e537d61b916493b569b085aeb140c355c8170
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<template>
  <TableLayout :permissions="['business:ddnoticeconfig:query']">
 
    <!-- 表格和分页 -->
    <template v-slot:table-wrap>
      <ul class="toolbar">
        <li><el-button type="primary" @click="batchStatus(0)">批量启用</el-button></li>
        <li><el-button @click="batchStatus(1)">批量禁用</el-button></li>
      </ul>
      <el-table
        :height="tableHeightNew"
        v-loading="isWorking.search"
        :data="tableData.list"
        stripe
        @selection-change="handleSelectionChange"
      >
        <el-table-column align="center" type="selection" width="55"></el-table-column>
        <el-table-column prop="titile" label="标题"></el-table-column>
        <el-table-column prop="status" label="状态" width="150px">
          <template slot-scope="{row}">
            <el-switch
              v-model="row.status"
              @change="changeStatus(row)"
              active-color="#13ce66"
              inactive-color="#ff4949"
              :active-value="0"
              :inactive-value="1">
            </el-switch>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        @size-change="handleSizeChange"
        @current-change="handlePageChange"
        :pagination="tableData.pagination"
      >
      </pagination>
    </template>
  </TableLayout>
</template>
 
<script>
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
import { H5ddNoticeConfig } from '@/api/business/ddNoticeConfig'
import { Message } from 'element-ui'
export default {
  name: 'DdNoticeConfig',
  extends: BaseTable,
  components: { TableLayout, Pagination },
  data () {
    return {
      // 搜索
      searchForm: {},
      ids: []
    }
  },
  created () {
    this.config({
      module: '钉钉公众号通知配置',
      api: '/business/ddNoticeConfig',
      'field.id': 'id',
      'field.main': 'id'
    })
    this.search()
  },
  methods: {
    handleSelectionChange(val) {
      this.ids = val.map(i => i.id)
    },
    batchStatus(status) {
      const { ids } = this
      if (ids.length == 0) return Message.error('请先选择要更改的通知')
      this.$confirm(`确定${status == 0 ? '启用' : '禁用'}选中的所有通知吗?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        H5ddNoticeConfig({
          ids: ids.join(','),
          status
        }).then(res => {
          Message.success('批量更新成功')
          this.search()
        }, () => {
          this.search()
        })
      })
    },
    changeStatus(row) {
      H5ddNoticeConfig({
        ids: row.id,
        status: row.status
      }).then(res => {
        Message.success('状态更新成功')
      }, () => {
        this.search()
      })
    },
  }
}
</script>