车辆管理系统-后台管理系统web
liding
3 天以前 e4b773b5936ec1fa3747fd3d35b85799773d5f39
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<template>
  <!--v-if="isLogin"-->
  <div class="divBox" v-if="isLogin">
    <el-card v-loading="fullscreenLoading" class="box-card">
      <div slot="header" class="clearfix">
        <div class="container">
          <router-link :to="{path:'/operation/onePass'}">
            <el-button class="mb35" size="mini" icon="el-icon-arrow-left">返回</el-button>
          </router-link>
        </div>
        <el-button size="mini" type="primary" @click="add">添加短信模板</el-button>
      </div>
      <el-table
        v-loading="listLoading"
        :data="tableData.data"
        style="width: 100%"
        size="mini"
        highlight-current-row
      >
        <el-table-column
          prop="id"
          label="ID"
          min-width="50"
        />
        <el-table-column
          prop="temp_id"
          label="模板ID"
          min-width="80"
        />
        <el-table-column
          prop="title"
          label="模板名称"
          min-width="120"
        />
        <el-table-column
          prop="content"
          label="模板内容"
          min-width="500"
        />
        <el-table-column
          label="模板类型"
          min-width="100"
        >
          <template slot-scope="{row}">
            <span>{{ row.temp_type | typesFilter }}</span>
          </template>
        </el-table-column>
        <el-table-column label="模板状态">
          <template slot-scope="{row}">
            <span>{{ row.status | statusFilter }}</span>
          </template>
        </el-table-column>
      </el-table>
      <div class="block">
        <el-pagination
          :page-sizes="[20, 40, 60, 80]"
          :page-size="tableFrom.limit"
          :current-page="tableFrom.page"
          layout="total, sizes, prev, pager, next, jumper"
          :total="tableData.total"
          @size-change="handleSizeChange"
          @current-change="pageChange"
        />
      </div>
    </el-card>
 
    <!--编辑-->
    <el-dialog
      title="添加模板"
      :visible.sync="dialogVisible"
      width="500px"
      :before-close="handleClose">
      <zb-parser
        v-if="dialogVisible"
        :form-id="110"
        :is-create="isCreate"
        :edit-data="editData"
        @submit="handlerSubmit"
        @resetForm="resetForm"
      />
    </el-dialog>
  </div>
</template>
 
<script>
import { smsTempLstApi, tempCreateApi } from '@/api/sms'
import { roterPre } from '@/settings'
import { mapGetters } from 'vuex'
import zbParser from '@/components/FormGenerator/components/parser/ZBParser'
import {Debounce} from '@/utils/validate'
export default {
  name: 'SmsTemplate',
  components: { zbParser },
  filters: {
    statusFilter(status) {
      const statusMap = {
        0: '不可用',
        1: '可用'
      }
      return statusMap[status]
    },
    typesFilter(status) {
      const statusMap = {
        1: '验证码',
        2: '通知',
        3: '推广'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      isCreate: 0,
      editData: {},
      dialogVisible: false,
      fullscreenLoading: false,
      listLoading: false,
      tableData: {
        data: [],
        total: 0
      },
      tableFrom: {
        page: 1,
        limit: 20
      }
    }
  },
  computed: {
    ...mapGetters([
      'isLogin'
    ])
  },
  mounted() {
    if (!this.isLogin) {
      this.$router.push('/operation/onePass?url=' + this.$route.path)
    } else {
      this.getList()
    }
  },
  methods: {
    resetForm(formValue) {
      this.handleClose();
    },
    handleClose() {
      this.dialogVisible = false
      this.editData = {}
    },
    handlerSubmit:Debounce(function(formValue) {
      tempCreateApi(formValue).then(data => {
        this.$message.success('新增成功')
        this.dialogVisible = false
        this.editData = {}
        this.getList()
      })
    }),
    add() {
      this.dialogVisible = true
    },
    // 查看是否登录
    onIsLogin() {
      this.fullscreenLoading = true
      this.$store.dispatch('user/isLogin').then(async res => {
        const data = res
        if (!data.status) {
          this.$message.warning('请先登录')
          this.$router.push( '/operation/onePass?url=' + this.$route.path)
        } else {
          this.getList()
        }
        this.fullscreenLoading = false
      }).catch(res => {
        this.$router.push( '/operation/onePass?url=' + this.$route.path)
        this.fullscreenLoading = false
      })
    },
    // 列表
    getList() {
      this.listLoading = true
      smsTempLstApi(this.tableFrom).then(res => {
        this.tableData.data = res.data
        this.tableData.total = res.count
        this.listLoading = false
      }).catch(res => {
        this.listLoading = false
      })
    },
    pageChange(page) {
      this.tableFrom.page = page
      this.getList()
    },
    handleSizeChange(val) {
      this.tableFrom.limit = val
      this.getList()
    },
    // 表格搜索
    userSearchs() {
      this.tableFrom.page = 1
      this.getList()
    }
  }
}
</script>
 
<style scoped lang="scss">
  .selWidth{
    width: 350px !important;
  }
</style>