群控系统服务端开发模式-应用开发-前端邮箱配置开发

ops/2024/11/29 6:44:34/

一、添加视图

        在根目录下src文件夹下views文件夹下param文件夹下mail文件夹下,新建index.vue,代码如下

<template><div class="app-container"><div class="filter-container" style="float:left;"><el-form :inline="true" :model="searchParams" class="demo-form-inline"><el-form-item><el-input v-model="searchParams.id" style="width: 160px;" placeholder="请输入ID" clearable /></el-form-item><el-form-item><el-input v-model="searchParams.title" style="width: 180px;" placeholder="请输入邮箱服务标题" clearable /></el-form-item><el-form-item><el-input v-model="searchParams.username" style="width: 180px;" placeholder="请输入发件人邮箱" clearable /></el-form-item><el-form-item><el-button class="search-btn el-button--infoSearch" type="primary" @click="search()">搜索</el-button><el-button class="search-btn el-button--infoSearch" style="background:#F2F6FC;" @click="clearSearch">重置</el-button></el-form-item></el-form></div><div class="filter-container" style="float:right;"><el-button v-if="$store.getters.butts.includes('ParamMailIndexAdd')" class="filter-item" style="margin-left: 10px;" type="primary" @click="handleAdd">添加</el-button><el-button class="filter-item" style="margin-left: 10px;" @click="search(currentPage)">刷新</el-button><el-button v-if="$store.getters.butts.includes('ParamMailIndexTostatus')" class="filter-item" style="margin-left: 10px;" @click="handleStatus(1)" type="success">启用</el-button><el-button v-if="$store.getters.butts.includes('ParamMailIndexTostatus')" class="filter-item" style="margin-left: 10px;" @click="handleStatus(0)" type="warning">禁用</el-button><el-button v-if="$store.getters.butts.includes('ParamMailIndexDelete')" class="filter-item" @click="handleDelete" type="danger">删除</el-button></div><el-tableref="resTable"v-loading="listLoading":data="list"row-key="id"highlight-current-rowmax-height="750"default-expand-allstyle="width: 100%;margin-top:10px;"border:default-sort="{prop: 'id', order: 'descending'}"><el-table-column type="selection" width="50" align="center" /><el-table-column align="center" label="ID" sortable prop="id"><template slot-scope="{row}"><span>{{ row.id }}</span></template></el-table-column><el-table-column align="center" label="邮箱服务标题"><template slot-scope="{row}"><span>{{ row.title }}</span></template></el-table-column><el-table-column align="center" label="发件人邮箱"><template slot-scope="{row}"><span>{{ row.username }}</span></template></el-table-column><el-table-column align="center" label="邮箱服务地址"><template slot-scope="{row}"><span>{{ row.smtp_address }}</span></template></el-table-column><el-table-column align="center" label="邮箱服务端口号"><template slot-scope="{row}"><span>{{ row.smtp_port }}</span></template></el-table-column><el-table-column align="center" label="邮箱服务有效期"><template slot-scope="{row}"><el-link v-if="row.smtp_lifespan == 0" type="danger" :underline="false">无限期</el-link><el-link v-if="row.smtp_lifespan > 0" type="warning" :underline="false">{{ row.smtp_lifespan }}天</el-link></template></el-table-column><el-table-column align="center" label="邮箱服务协议"><template slot-scope="{row}"><span>{{ row.smtp_protocol }}</span></template></el-table-column><el-table-column align="center" label="状态"><template slot-scope="{row}"><el-tag type="success" v-if="row.status === 1">启用</el-tag><el-tag type="warning" v-if="row.status === 0">禁用</el-tag></template></el-table-column><el-table-column align="center" label="添加时间"><template slot-scope="{row}"><span>{{ row.create_time }}</span></template></el-table-column><el-table-column align="center" label="修改时间"><template slot-scope="{row}"><span>{{ row.update_time }}</span></template></el-table-column><el-table-column align="center" label="操作" width="210"><template slot-scope="{row}"><el-button v-if="$store.getters.butts.includes('ParamMailIndexDetails')" size="mini" @click="handleDetails(row.id)" type="info">详情</el-button><el-button v-if="$store.getters.butts.includes('ParamMailIndexEdit')" size="mini" @click="handleEdit(row.id)" type="primary">编辑</el-button><el-button v-if="$store.getters.butts.includes('ParamMailIndexDelete')" size="mini" @click="handleDelete(row.id)" type="danger">删除</el-button></template></el-table-column></el-table><div class="block"><el-pagination:hide-on-single-page="true":current-page="currentPage":page-sizes="pageSizes":page-size="currentSize"layout="total, sizes, prev, pager, next, jumper":total="dataTotal"@size-change="handleSizeChange"@current-change="handleCurrentChange"/></div><transition name="dialog-fade"><el-dialog :visible.sync="dialogVisible" :title="resTemp.id === 0 ? '添加' : '编辑'" :close-on-click-modal="false" :close-on-press-escape="false"><el-form ref="resForm" :rules="formRules" :model="resTemp" label-position="right" label-width="150px"><el-form-item label="邮箱服务标题" prop="title"><el-input v-model="resTemp.title" placeholder="请填写邮箱服务标题" /></el-form-item><el-form-item label="发件人邮箱" prop="username"><el-input v-model="resTemp.username" placeholder="请填写发件人邮箱" /></el-form-item><el-form-item label="邮箱服务地址" prop="smtp_address"><el-input v-model="resTemp.smtp_address" placeholder="请填写邮箱服务地址" /></el-form-item><el-form-item label="邮箱服务端口" prop="smtp_port"><el-input-number v-model="resTemp.smtp_port" placeholder="请填写邮箱服务端口" /></el-form-item><el-form-item label="邮箱服务授权码" prop="smtp_password"><el-input v-model="resTemp.smtp_password" placeholder="请填写邮箱服务授权码" /></el-form-item><el-form-item label="邮箱服务有效期" prop="smtp_lifespan"><el-input-number v-model="resTemp.smtp_lifespan" placeholder="请填写邮箱服务有效期" /><el-link type="danger" :underline="false">0为无限期</el-link></el-form-item><el-form-item label="邮箱服务协议" prop="smtp_protocol"><el-input v-model="resTemp.smtp_protocol" placeholder="请填写邮箱服务协议" /></el-form-item></el-form><div slot="footer" class="dialog-footer"><el-button @click="dialogVisible=false">取消</el-button><el-button v-if="$store.getters.butts.includes('ParamMailIndexSave')" type="primary" @click="saveInfo()">提交</el-button></div></el-dialog></transition><transition name="dialog-fade"><el-dialog :visible.sync="dialogDetails" title="详情" :close-on-click-modal="false" :close-on-press-escape="false"><el-form ref="resForm" :model="resTemp" label-position="right" label-width="150px"><el-form-item label="邮箱服务标题"><el-input v-model="resTemp.title" placeholder="请填写邮箱服务标题" disabled /></el-form-item><el-form-item label="发件人邮箱"><el-input v-model="resTemp.username" placeholder="请填写发件人邮箱" disabled /></el-form-item><el-form-item label="邮箱服务地址"><el-input v-model="resTemp.smtp_address" placeholder="请填写邮箱服务地址" disabled /></el-form-item><el-form-item label="邮箱服务端口"><el-input-number v-model="resTemp.smtp_port" placeholder="请填写邮箱服务端口" disabled /></el-form-item><el-form-item label="邮箱服务授权码"><el-input v-model="resTemp.smtp_password" placeholder="请填写邮箱服务授权码" disabled /></el-form-item><el-form-item label="邮箱服务有效期"><el-input-number v-model="resTemp.smtp_lifespan" placeholder="请填写邮箱服务有效期" disabled /></el-form-item><el-form-item label="邮箱服务协议"><el-input v-model="resTemp.smtp_protocol" placeholder="请填写邮箱服务协议" disabled /></el-form-item><el-form-item label="状态"><el-switchv-model="resTemp.status"active-value="1"inactive-value="0"disabled/></el-form-item></el-form><div slot="footer" class="dialog-footer"><el-button @click="dialogDetails=false">取消</el-button></div></el-dialog></transition></div>
</template>
<script>import { succ, warn, err } from '@/utils/message'import { getInfo, getList, saveInfo, deleteInfo, statusInfo } from '@/api/param/mail'export default {name: 'ParamMailIndex', // 名空间// 初始化数据data() {return {list: [], // 初始化管理员列表pageSizes: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500],currentPage: 1, // 当前页数currentSize: 10, // 每页条数dataTotal: 0, // 总数据searchParams: {id: '',title: '',username:''},// 要提交数据resTemp: {id: 0, // 0 添加 >0 编辑title: '',username: '',smtp_address: '',smtp_port: 0,smtp_password: '',smtp_lifespan: 0,smtp_protocol: '',status: '1'},// 要验证数据formRules: {title: [{ required: true, trigger: 'blur', message: '邮件服务标题必须填写' },{ min: 2, max: 20, message: '长度在 1 到 30 个字符', trigger: 'blur' }],username: [{ required: true, trigger: 'blur', message: '发件人邮箱必须填写' },{ min: 8, max: 250, message: '长度在 8 到 250 个字符', trigger: 'blur' }],smtp_address: [{ required: true, trigger: 'blur', message: '邮箱服务地址必须填写' },{ min: 10, max: 250, message: '长度在 10 到 250 个字符', trigger: 'blur' }],smtp_port: [{ required: true, trigger: 'blur', message: '邮箱服务端口号必须填写' }],smtp_password: [{ required: true, trigger: 'blur', message: '邮箱服务授权码必须填写' },{ min: 10, max: 50, message: '长度在 10 到 50 个字符', trigger: 'blur' }],smtp_lifespan: [{ required: true, trigger: 'blur', message: '邮箱服务有效期必须填写' }],smtp_protocol: [{ required: true, trigger: 'blur', message: '邮箱服务协议必须填写' },{ min: 2, max: 5, message: '长度在 2 到 5 个字符', trigger: 'blur' }]},listLoading: true, // 显示list加载框dialogVisible: false, // 初始化弹窗是否显示dialogDetails: false}},// 初始化执行的created() {this.getList()// 获取管理员数据},// 所有的方法都需要放到这个里面methods: {// 搜索search() {this.getList(1)},// 管理员数据 --异步async getList(page = 0) {this.listLoading = trueconst params = {currentPage: page === 0 ? this.currentPage : page,currentSize: this.currentSize,...this.searchParams}await getList(params).then(res => {this.list = res.data.listthis.dataTotal = res.data.meat.total * 1})// 延时setTimeout(() => {this.listLoading = false}, 0.5 * 1000)},// 清除搜索功能clearSearch() {this.searchParams = {id: '',title: ''}this.getList()},// 重置表单数据 ---添加时候需要使用resetTemp() {this.resTemp = {id: 0, // 0 添加 >0 编辑title: '',username: '',smtp_address: '',smtp_port: 0,smtp_password: '',smtp_lifespan: 0,smtp_protocol: '',status: '1'}},// 添加方法handleAdd() {this.resetTemp()this.dialogVisible = truethis.$nextTick(() => {this.$refs['resForm'].clearValidate()})},// 编辑方法handleEdit(id) {getInfo({ id: id }).then(res => {const row = res.datathis.resTemp = Object.assign({}, row)this.resTemp.status = row.status + ''// 将数字强行转换成字符串this.dialogVisible = truethis.$nextTick(() => {this.$refs['resForm'].clearValidate()})})},// 详情handleDetails(id){getInfo({ id: id }).then(res => {const row = res.datathis.resTemp = Object.assign({}, row)this.resTemp.status = row.status + ''// 将数字强行转换成字符串this.dialogDetails = truethis.$nextTick(() => {this.$refs['resForm'].clearValidate()})})},// 新建保存数据async saveInfo() {this.$refs.resForm.validate(valid => {if (valid) {this.loading = truesaveInfo(this.resTemp).then(res => {this.loading = falsesucc(res.message)this.getList()this.dialogVisible = false})} else {return false}})},// 删除handleDelete(id) {this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning',center: true}).then(async() => {const ids = []if (id > 0) { // 单个删除ids.push(id)} else { // 批量删除const select = this.$refs.resTable.selectionif (select.length === 0) {warn('批量删除必须选择指定产品')return false}// 组合数据select.forEach(item => {ids.push(item.id)})}// 删除deleteInfo({ id: ids }).then(res => {this.getList()// 更新列表succ(res.message)// 提示结果})}).catch(err => {err(err.message)return false})},// 启禁用handleStatus(status){let statusText = status == 1 ? '启用' : '禁用';this.$confirm('此操作将永久'+ statusText +'该产品, 是否继续?', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning',center: true}).then(async() => {const ids = []const select = this.$refs.resTable.selectionif (select.length === 0) {warn('批量'+ statusText +'必须选择指定产品')return false}// 组合数据select.forEach(item => {ids.push(item.id)})// 删除statusInfo({ id: ids, status:status }).then(res => {this.getList()//更新列表succ(res.message)// 提示结果})}).catch(err => {err(err.message)return false})},// 每页条数切换handleSizeChange(val) {this.currentSize = valthis.getList()},// 页数切换handleCurrentChange(val) {this.currentPage = valthis.getList()}}}
</script>
<style lang="scss" scoped>.app-container {padding:10px;.roles-table {margin-top: 30px;}.permission-tree {margin-bottom: 30px;}}.el-image-viewer__close{color: #fff;}.roleId .el-select{width:100%;}
</style>

二、添加ajax请求

        在根目录下src文件夹下api文件夹下param文件夹下mail.js,代码如下

import request from '@/utils/request'
// 列表
export function getList(params) {return request({url: '/param/mail/get_list',method: 'get',params:params})
}
// 所有
export function getAll() {return request({url: '/param/mail/get_all',method: 'post'})
}
// 获取
export function getInfo(data) {return request({url: '/param/mail/get_info',method: 'post',data})
}
// 保存
export function saveInfo(data) {return request({url: '/param/mail/save_info',method: 'post',data})
}
// 删除
export function deleteInfo(data) {return request({url: '/param/mail/delete_info',method: 'post',data})
}
// 启禁用
export function statusInfo(data) {return request({url: '/param/mail/status_info',method: 'post',data})
}

http://www.ppmy.cn/ops/137592.html

相关文章

Python语法基础(三)

&#x1f308;个人主页&#xff1a;羽晨同学 &#x1f4ab;个人格言:“成为自己未来的主人~” 我们这篇文章来说一下函数的返回值和匿名函数 函数的返回值 我们先来看下面的这一段函数的定义代码 # 1、返回值的意义 def func1():print(111111111------start)num166print…

深入讲解Spring Boot和Spring Cloud,外加图书管理系统实战!

很抱歉&#xff0c;我的疏忽&#xff0c;说了这么久还没有给大家详细讲解过Spring Boot和Spring Cloud,那今天给大家详细讲解一下。 大家可以和下面这三篇博客一起看&#xff1a; 1、Spring Boot 和 Spring Cloud 微服务开发实践详解https://blog.csdn.net/speaking_me/artic…

ffmpeg 增亮 docker 使用

使用最新的 docker pull jrottenberg/ffmpeg docker run -it --rm -v /path/to/input:/input -v /path/to/output:/output jrottenberg/ffmpeg <ffmpeg command>比如我想增亮 在 /home 目录下 有一个 video.mp4 docker run --rm -v /home:/home jrottenberg/ffmpeg:7…

我们来学mysql -- EXPLAIN之filtered(原理篇)

EXPLAIN之filtered 题记filtered 题记 书接上文《 EXPLAIN之rows》2024美国大选已定&#xff0c;川普剑登上铁王座&#xff0c;在此过程中出谋划策的幕僚很重要&#xff0c;是他们决定了最终的执行计划在《查询成本之索引选择》中提到&#xff0c;explain的输出&#xff0c;就…

React(五)——useContecxt/Reducer/useCallback/useRef/React.memo/useMemo

文章目录 项目地址十六、useContecxt十七、useReducer十八、React.memo以及产生的问题18.1组件嵌套的渲染规律18.2 React.memo18.3 引出问题 十九、useCallback和useMemo19.1 useCallback对函数进行缓存19.2 useMemo19.2.1 基本的使用19.2.2 缓存属性数据 19.2.3 对于更新的理解…

深入理解 JavaScript 中的 AbortController

在现代 JavaScript 开发中&#xff0c;处理异步操作是极为常见的任务。然而&#xff0c;有时我们需要一种机制来主动取消正在进行的异步操作&#xff0c;这时候 AbortController 就派上了大用场。本文将深入探讨 AbortController 的功能、用法以及它在实际开发中的应用场景。 …

练习题 - Django 4.x CSRF 站点保护示例和使用配置方法

在 Web 应用程序的开发中,安全性是一个非常重要的方面。CSRF(跨站请求伪造)是一种常见的网络攻击方式,攻击者通过伪造用户的请求来执行恶意操作。为了防止这种攻击,Django 提供了内置的 CSRF 防护机制。学习如何在 Django 中正确配置和使用 CSRF 保护,可以有效地提高 Web…

csp-j初赛模拟试题(解析)

题目&#xff1a; 在 C中&#xff0c;以下哪个关键字用于实现多态性&#xff1f; A. virtualB. staticC. externD. const 以下数据结构中&#xff0c;不属于线性结构的是&#xff08; &#xff09;。 A. 栈B. 队列C. 二叉树D. 链表 一个有 8 个顶点的无向图&#xff0c;若每个…