|
| 1 | +<template> |
| 2 | + <div class="app-container"> |
| 3 | + <doc-alert title="邮件配置" url="https://doc.iocoder.cn/mail" /> |
| 4 | + |
| 5 | + <!-- 搜索工作栏 --> |
| 6 | + <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> |
| 7 | + <el-form-item label="邮箱" prop="mail"> |
| 8 | + <el-input v-model="queryParams.mail" placeholder="请输入邮箱" clearable @keyup.enter.native="handleQuery"/> |
| 9 | + </el-form-item> |
| 10 | + <el-form-item label="用户名" prop="username"> |
| 11 | + <el-input v-model="queryParams.username" placeholder="请输入用户名" clearable @keyup.enter.native="handleQuery"/> |
| 12 | + </el-form-item> |
| 13 | + <el-form-item> |
| 14 | + <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button> |
| 15 | + <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button> |
| 16 | + </el-form-item> |
| 17 | + </el-form> |
| 18 | + |
| 19 | + <!-- 操作工具栏 --> |
| 20 | + <el-row :gutter="10" class="mb8"> |
| 21 | + <el-col :span="1.5"> |
| 22 | + <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" |
| 23 | + v-hasPermi="['system:mail-account:create']">新增</el-button> |
| 24 | + </el-col> |
| 25 | + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> |
| 26 | + </el-row> |
| 27 | + |
| 28 | + <!-- 列表 --> |
| 29 | + <el-table v-loading="loading" :data="list"> |
| 30 | + <el-table-column label="编号" align="center" prop="id" /> |
| 31 | + <el-table-column label="邮箱" align="center" prop="mail" /> |
| 32 | + <el-table-column label="用户名" align="center" prop="username" /> |
| 33 | + <el-table-column label="SMTP 服务器域名" align="center" prop="host" /> |
| 34 | + <el-table-column label="SMTP 服务器端口" align="center" prop="port" /> |
| 35 | + <el-table-column label="是否开启 SSL" align="center" prop="sslEnable"> |
| 36 | + <template v-slot="scope"> |
| 37 | + <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.sslEnable" /> |
| 38 | + </template> |
| 39 | + </el-table-column> |
| 40 | + <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| 41 | + <template v-slot="scope"> |
| 42 | + <span>{{ parseTime(scope.row.createTime) }}</span> |
| 43 | + </template> |
| 44 | + </el-table-column> |
| 45 | + <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| 46 | + <template v-slot="scope"> |
| 47 | + <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" |
| 48 | + v-hasPermi="['system:mail-account:update']">修改</el-button> |
| 49 | + <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" |
| 50 | + v-hasPermi="['system:mail-account:delete']">删除</el-button> |
| 51 | + </template> |
| 52 | + </el-table-column> |
| 53 | + </el-table> |
| 54 | + <!-- 分页组件 --> |
| 55 | + <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" |
| 56 | + @pagination="getList"/> |
| 57 | + |
| 58 | + <!-- 对话框(添加 / 修改) --> |
| 59 | + <el-dialog :title="title" :visible.sync="open" width="500px" v-dialogDrag append-to-body> |
| 60 | + <el-form ref="form" :model="form" :rules="rules" label-width="140px"> |
| 61 | + <el-form-item label="邮箱" prop="mail"> |
| 62 | + <el-input v-model="form.mail" placeholder="请输入邮箱" /> |
| 63 | + </el-form-item> |
| 64 | + <el-form-item label="用户名" prop="username"> |
| 65 | + <el-input v-model="form.username" placeholder="请输入用户名,一般和邮箱一致" /> |
| 66 | + </el-form-item> |
| 67 | + <el-form-item label="密码" prop="password"> |
| 68 | + <el-input v-model="form.password" placeholder="请输入密码" /> |
| 69 | + </el-form-item> |
| 70 | + <el-form-item label="SMTP 服务器域名" prop="host"> |
| 71 | + <el-input v-model="form.host" placeholder="请输入 SMTP 服务器域名" /> |
| 72 | + </el-form-item> |
| 73 | + <el-form-item label="SMTP 服务器端口" prop="port"> |
| 74 | + <el-input v-model="form.port" placeholder="请输入 SMTP 服务器端口" /> |
| 75 | + </el-form-item> |
| 76 | + <el-form-item label="是否开启 SSL" prop="sslEnable"> |
| 77 | + <el-radio-group v-model="form.sslEnable"> |
| 78 | + <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.INFRA_BOOLEAN_STRING)" |
| 79 | + :key="dict.value" :label="dict.value === 'true'">{{dict.label}}</el-radio> |
| 80 | + </el-radio-group> |
| 81 | + </el-form-item> |
| 82 | + </el-form> |
| 83 | + <div slot="footer" class="dialog-footer"> |
| 84 | + <el-button type="primary" @click="submitForm">确 定</el-button> |
| 85 | + <el-button @click="cancel">取 消</el-button> |
| 86 | + </div> |
| 87 | + </el-dialog> |
| 88 | + </div> |
| 89 | +</template> |
| 90 | + |
| 91 | +<script> |
| 92 | +import { createMailAccount, updateMailAccount, deleteMailAccount, getMailAccount, getMailAccountPage } from "@/api/system/mail/account"; |
| 93 | +
|
| 94 | +export default { |
| 95 | + name: "MailAccount", |
| 96 | + components: { |
| 97 | + }, |
| 98 | + data() { |
| 99 | + return { |
| 100 | + // 遮罩层 |
| 101 | + loading: true, |
| 102 | + // 显示搜索条件 |
| 103 | + showSearch: true, |
| 104 | + // 总条数 |
| 105 | + total: 0, |
| 106 | + // 邮箱账号列表 |
| 107 | + list: [], |
| 108 | + // 弹出层标题 |
| 109 | + title: "", |
| 110 | + // 是否显示弹出层 |
| 111 | + open: false, |
| 112 | + // 查询参数 |
| 113 | + queryParams: { |
| 114 | + pageNo: 1, |
| 115 | + pageSize: 10, |
| 116 | + mail: null, |
| 117 | + username: null |
| 118 | + }, |
| 119 | + // 表单参数 |
| 120 | + form: {}, |
| 121 | + // 表单校验 |
| 122 | + rules: { |
| 123 | + mail: [{ required: true, message: "邮箱不能为空", trigger: "blur" }], |
| 124 | + username: [{ required: true, message: "用户名不能为空", trigger: "blur" }], |
| 125 | + password: [{ required: true, message: "密码不能为空", trigger: "blur" }], |
| 126 | + host: [{ required: true, message: "SMTP 服务器域名不能为空", trigger: "blur" }], |
| 127 | + port: [{ required: true, message: "SMTP 服务器端口不能为空", trigger: "blur" }], |
| 128 | + sslEnable: [{ required: true, message: "是否开启 SSL不能为空", trigger: "blur" }], |
| 129 | + }, |
| 130 | + }; |
| 131 | + }, |
| 132 | + created() { |
| 133 | + this.getList(); |
| 134 | + }, |
| 135 | + methods: { |
| 136 | + /** 查询列表 */ |
| 137 | + getList() { |
| 138 | + this.loading = true; |
| 139 | + // 执行查询 |
| 140 | + getMailAccountPage(this.queryParams).then(response => { |
| 141 | + this.list = response.data.list; |
| 142 | + this.total = response.data.total; |
| 143 | + this.loading = false; |
| 144 | + }); |
| 145 | + }, |
| 146 | + /** 取消按钮 */ |
| 147 | + cancel() { |
| 148 | + this.open = false; |
| 149 | + this.reset(); |
| 150 | + }, |
| 151 | + /** 表单重置 */ |
| 152 | + reset() { |
| 153 | + this.form = { |
| 154 | + id: undefined, |
| 155 | + mail: undefined, |
| 156 | + username: undefined, |
| 157 | + password: undefined, |
| 158 | + host: undefined, |
| 159 | + port: undefined, |
| 160 | + sslEnable: true, |
| 161 | + }; |
| 162 | + this.resetForm("form"); |
| 163 | + }, |
| 164 | + /** 搜索按钮操作 */ |
| 165 | + handleQuery() { |
| 166 | + this.queryParams.pageNo = 1; |
| 167 | + this.getList(); |
| 168 | + }, |
| 169 | + /** 重置按钮操作 */ |
| 170 | + resetQuery() { |
| 171 | + this.resetForm("queryForm"); |
| 172 | + this.handleQuery(); |
| 173 | + }, |
| 174 | + /** 新增按钮操作 */ |
| 175 | + handleAdd() { |
| 176 | + this.reset(); |
| 177 | + this.open = true; |
| 178 | + this.title = "添加邮箱账号"; |
| 179 | + }, |
| 180 | + /** 修改按钮操作 */ |
| 181 | + handleUpdate(row) { |
| 182 | + this.reset(); |
| 183 | + const id = row.id; |
| 184 | + getMailAccount(id).then(response => { |
| 185 | + this.form = response.data; |
| 186 | + this.open = true; |
| 187 | + this.title = "修改邮箱账号"; |
| 188 | + }); |
| 189 | + }, |
| 190 | + /** 提交按钮 */ |
| 191 | + submitForm() { |
| 192 | + this.$refs["form"].validate(valid => { |
| 193 | + if (!valid) { |
| 194 | + return; |
| 195 | + } |
| 196 | + // 修改的提交 |
| 197 | + if (this.form.id != null) { |
| 198 | + updateMailAccount(this.form).then(response => { |
| 199 | + this.$modal.msgSuccess("修改成功"); |
| 200 | + this.open = false; |
| 201 | + this.getList(); |
| 202 | + }); |
| 203 | + return; |
| 204 | + } |
| 205 | + // 添加的提交 |
| 206 | + createMailAccount(this.form).then(response => { |
| 207 | + this.$modal.msgSuccess("新增成功"); |
| 208 | + this.open = false; |
| 209 | + this.getList(); |
| 210 | + }); |
| 211 | + }); |
| 212 | + }, |
| 213 | + /** 删除按钮操作 */ |
| 214 | + handleDelete(row) { |
| 215 | + const id = row.id; |
| 216 | + this.$modal.confirm('是否确认删除邮箱账号编号为"' + id + '"的数据项?').then(function() { |
| 217 | + return deleteMailAccount(id); |
| 218 | + }).then(() => { |
| 219 | + this.getList(); |
| 220 | + this.$modal.msgSuccess("删除成功"); |
| 221 | + }).catch(() => {}); |
| 222 | + } |
| 223 | + } |
| 224 | +}; |
| 225 | +</script> |
0 commit comments