master
张同海 2 years ago
parent 553107ed7f
commit c17d93bdcd

@ -0,0 +1,48 @@
import request from '@/utils/request'
/**
* parameter: {
* pkid: '',
* }
* @param parameter
* @returns {*}
*/
// 获取邮箱数据
export function mailAccountList(parameter) {
return request({
url: '/api/mail/mailAccountList',
method: 'post',
data: parameter,
})
}
// 获取解析器列表
export function parserList(parameter) {
return request({
url: '/api/mail/parserList',
method: 'get',
})
}
// 获取解析器配置列表
export function parserRelationList(parameter) {
return request({
url: '/api/mail/parserRelationList',
method: 'get',
params: parameter,
})
}
// 保存解析器配置(单邮箱)
export function saveParserRelation(data) {
return request({
url: '/api/mail/saveParserRelation',
method: 'post',
data: data,
})
}
// 发送解析邮件消息
export function parseMail(parameter) {
return request({
url: '/api/mail/parseMail',
method: 'get',
params: parameter,
})
}

@ -21,19 +21,19 @@ export const asyncRouterMap = [
component: () => import('@/views/dashboard/Workplace'),
meta: { title: '仪表盘', keepAlive: true, icon: 'home', permission: ['dashboard'] },
},
{
path: '/parser',
name: 'parser',
component: () => import('@/views/rulesEngine/parser'),
meta: { title: '解析器配置', keepAlive: true, icon: 'profile', permission: ['parser'] },
},
{
path: '/mail',
name: 'mail',
component: () => import('@/views/rulesEngine/mail'),
meta: { title: '邮件服务配置', keepAlive: true, icon: 'project', permission: ['mail'] },
meta: { title: '邮箱解析配置', keepAlive: true, icon: 'project', permission: ['mail'] },
},
// {
// path: '/parameterAccount',
// name: 'parameterAccount',
// component: () => import('@/views/rulesEngine/parameterAccount'),
// meta: { title: '规则参数台账', keepAlive: true, icon: 'profile', permission: ['parameterAccount'] },
// },
// {
// path: '/varAccount',
// name: 'varAccount',
// component: () => import('@/views/rulesEngine/varAccount'),

@ -15,38 +15,8 @@
/>
</a-form-item>
</a-col>
<a-col :md="8" :sm="24">
<!-- <a-form-item label="公司名称">
<a-input
placeholder="请输入公司名称"
v-decorator="['code', { rules: [{ required: false, message: '请输入公司名称' }] }]"
/>
</a-form-item> -->
</a-col>
<!-- <template v-if="advanced">
<a-col :md="8" :sm="24">
<a-form-item label="项目名称">
<a-input placeholder="请输入项目名称" v-decorator="['name', { rules: [{ required: false }] }]" />
</a-form-item>
</a-col>
<a-col :md="8" :sm="24">
<a-form-item label="更新时间">
<a-range-picker
format="YYYY-MM-DD HH:mm:ss"
:placeholder="['开始时间', '结束时间']"
v-decorator="['updataTime', { rules: [{ required: false }] }]"
/>
</a-form-item>
</a-col>
<a-col :md="8" :sm="24" v-if="advanced">
<a-form-item label="更新人">
<a-input
placeholder="请输入更新人"
v-decorator="['updataBy', { rules: [{ required: false }] }]"
/>
</a-form-item>
</a-col>
</template> -->
<a-col :md="8" :sm="24"> </a-col>
<a-col :md="(!advanced && 8) || 24" :sm="24">
<span
class="table-page-search-submitButtons"
@ -55,10 +25,6 @@
<a-button @click="tableReset"></a-button>
<a-button type="primary" style="margin-left: 8px" @click="tableRefresh"></a-button>
<a-button type="primary" style="margin-left: 8px" @click="showParserVisible"></a-button>
<!-- <a @click="toggleAdvanced" style="margin-left: 8px">
{{ advanced ? '收起' : '展开' }}
<a-icon :type="advanced ? 'up' : 'down'" />
</a> -->
</span>
</a-col>
</a-row>
@ -68,33 +34,7 @@
<x-card>
<div slot="content" class="table-page-search-wrapper">
<vxe-toolbar>
<!-- <template #buttons>
<a-button type="primary" icon="edit" @click="addProject"></a-button>
<a-popconfirm
title="确定作废当前选择项?"
ok-text="是"
cancel-text="否"
@confirm="confirmRemove"
@cancel="cancelRemove"
>
<a-button type="danger" icon="delete">作废</a-button>
</a-popconfirm>
</template> -->
<!-- <template #tools>
<div class="right">
<span class="tab-btn" @click="tableRefresh">
<a-icon type="redo" :style="{ fontSize: '16px' }" /> 刷新
</span>
<a-popover placement="bottom" v-model="setVisible" trigger="click">
<template #content>
<columnSetting :columns="showColumns" @columnChange="columnChange"></columnSetting>
</template>
<span class="tab-btn"> <a-icon type="setting" :style="{ fontSize: '16px' }" /> 设置 </span>
</a-popover>
</div>
</template> -->
</vxe-toolbar>
<vxe-toolbar> </vxe-toolbar>
<vxe-grid
ref="xGrid"
v-bind="gridOptions"
@ -121,6 +61,11 @@
<span class="tit">{{ column.title }}</span>
</div>
</template>
<template #useImap_default="{ column, row }">
<div class="column-header">
<span class="tit">{{ row[column.field] ? '是' : '否' }}</span>
</div>
</template>
<template #receivePort_header="{ column }">
<div class="column-header">
<span class="tit">{{ column.title }}</span>
@ -131,6 +76,11 @@
<span class="tit">{{ column.title }}</span>
</div>
</template>
<template #receiveSSL_default="{ column, row }">
<div class="column-header">
<span class="tit">{{ row[column.field] ? '是' : '否' }}</span>
</div>
</template>
<template #smtpServer_header="{ column }">
<div class="column-header">
<span class="tit">{{ column.title }}</span>
@ -146,6 +96,11 @@
<span class="tit">{{ column.title }}</span>
</div>
</template>
<template #smtpSSL_default="{ column, row }">
<div class="column-header">
<span class="tit">{{ row[column.field] ? '是' : '否' }}</span>
</div>
</template>
</vxe-grid>
</div>
</x-card>

@ -9,12 +9,16 @@ export default {
showHeaderOverflow: true,
slots: { header: 'receiveServer_header' },
},
{ field: 'useImap', title: '使用IMAP', slots: { header: 'useImap_header' } },
{ field: 'useImap', title: '使用IMAP', slots: { header: 'useImap_header', default: 'useImap_default' } },
{ field: 'receivePort', title: '收件端口', slots: { header: 'receivePort_header' } },
{ field: 'receiveSSL', title: '收件使用SSL', slots: { header: 'receiveSSL_header' } },
{
field: 'receiveSSL',
title: '收件使用SSL',
slots: { header: 'receiveSSL_header', default: 'receiveSSL_default' },
},
{ field: 'smtpServer', title: '发件服务器', slots: { header: 'smtpServer_header' } },
{ field: 'smtpPort', title: '发件端口', slots: { header: 'smtpPort_header' } },
{ field: 'smtpSSL', title: '发件是使用SSL', slots: { header: 'smtpSSL_header' } },
{ field: 'smtpSSL', title: '发件是使用SSL', slots: { header: 'smtpSSL_header', default: 'smtpSSL_default' } },
// { title: '操作', width: 80, noDraggable: true, slots: { default: 'operate' }, fixed: 'right' }
],
}

@ -0,0 +1,418 @@
<template>
<div>
<a-row :gutter="24">
<a-col :md="24" :sm="24" style="padding: 0 0 0 0">
<x-card>
<div slot="content" class="table-page-search-wrapper">
<vxe-toolbar>
<template #buttons>
<a-button type="primary" icon="edit" @click="addProject"></a-button>
</template>
</vxe-toolbar>
<vxe-grid
ref="xGrid"
v-bind="gridOptions"
@page-change="handlePageChange"
@resizable-change="resizableChange"
>
<template #parserName_header="{ column }">
<div class="column-header">
<span class="tit">{{ column.title }}</span>
</div>
</template>
<template #parserType_header="{ column }">
<div class="column-header">
<span class="tit">{{ column.title }}</span>
</div>
</template>
<template #processorChain_header="{ column }">
<div class="column-header">
<span class="tit">{{ column.title }}</span>
</div>
</template>
<template #subjectRegex_header="{ column }">
<div class="column-header">
<span class="tit">{{ column.title }}</span>
</div>
</template>
<template #senderRegex_header="{ column }">
<div class="column-header">
<span class="tit">{{ column.title }}</span>
</div>
</template>
<template #attachRegex_header="{ column }">
<div class="column-header">
<span class="tit">{{ column.title }}</span>
</div>
</template>
<template #operate="{ row }">
<vxe-button type="text" icon="vxe-icon-edit" @click="editColumns(row)"></vxe-button>
</template>
</vxe-grid>
</div>
</x-card>
</a-col>
<add-form ref="addForm" :fromData="addFromData" :type="addFromType" @ok="handleOk" />
</a-row>
</div>
</template>
<script>
import { XCard } from '@/components'
import columnSetting from '@/components/tableColumnSetting'
import addForm from './modules/addForm'
import { mailAccountList, parserList, parserRelationList, saveParserRelation, parseMail } from '@/api/parser'
import { addConfig } from '@/api/common'
import initData from './modules/initData'
export default {
name: 'ParameterAccount',
components: {
XCard,
columnSetting,
addForm,
},
data() {
return {
// /
advanced: false,
//
form: this.$form.createForm(this),
//
setVisible: false,
showColumns: null,
gridOptions: {
height: '650',
border: true,
resizable: true,
showOverflow: true,
// height: 530,
loading: true,
stripe: true,
round: true,
autoResize: true,
columnConfig: { resizable: true },
importConfig: {},
exportConfig: {},
pagerConfig: {
total: 0,
currentPage: 1,
pageSize: 10,
pageSizes: [10, 20, 50, 100, 200, 500],
},
columns: JSON.parse(JSON.stringify(initData.columns)),
data: [],
},
addFromData: {},
addFromType: 'add',
tableSortType: '',
tableSortOrder: '1',
parserVisible: false,
parserTableData: [],
}
},
created() {
this.showColumns = JSON.parse(JSON.stringify(initData.columns))
// this.getTableList()
this.parserList()
},
mounted() {},
methods: {
addParams() {},
showParserVisible() {
let select = this.$refs.xGrid.getCheckboxRecords()
if (select.length == 1) {
this.parserVisible = true
parserRelationList({ mailAccount: select[0].mailAccount }).then((res) => {
this.$refs.MailModal.getData().forEach((item) => {
item.parserMail = false
})
this.$refs.MailModal.clearCheckboxRow()
this.$refs.MailModal.getData().forEach((item) => {
res.data.forEach((item2) => {
if (item2.parserId == item.gid) {
this.$refs.MailModal.setCheckboxRow(item, true)
}
})
})
})
} else {
this.$message.warning('请仅选择一条!')
}
},
handleOk(e) {
let select = this.$refs.MailModal.getCheckboxRecords()
let parserIdData = []
select.forEach((item) => {
parserIdData.push(item.gid)
})
saveParserRelation({
parserId: parserIdData,
mailAccount: this.$refs.xGrid.getCheckboxRecords()[0].mailAccount,
}).then(() => {
this.$refs.MailModal.getData().forEach((item) => {
console.log(item)
if (item.parserMail) {
parseMail({ gid: item.gid }).then((res) => {
console.log(res)
})
}
})
this.parserVisible = false
})
},
init(queryParam = {}) {
this.gridOptions.pagerConfig = {
total: 0,
currentPage: 1,
pageSize: 10,
pageSizes: [10, 20, 50, 100, 200, 500],
}
this.gridOptions.data = []
this.getTableList(queryParam)
},
parserList() {
parserList().then((res) => {
if (res.statusCode == 200) {
this.gridOptions.pagerConfig.total = res.data.total
this.gridOptions.data = res.data
this.gridOptions.loading = false
}
// res.data.forEach((item) => {
// item.parserMail = false
// })
// this.parserTableData = res.data
// console.log(res)
})
},
getTableList(queryParam = {}) {
mailAccountList({
...queryParam,
page: this.gridOptions.pagerConfig.currentPage,
limit: this.gridOptions.pagerConfig.pageSize,
}).then((res) => {
if (res.statusCode == 200) {
this.gridOptions.pagerConfig.total = res.data.total
this.gridOptions.data = res.data.mailAccount
this.gridOptions.loading = false
}
})
},
handlePageChange({ currentPage, pageSize }) {
console.log(currentPage, pageSize)
const {
form: { validateFields },
} = this
validateFields((err, values) => {
if (!err) {
if (values.createdTime) {
const time = values.createdTime.map((item, index) => {
const str = this.dateFtt('YYYY-MM-DD', item._d)
return str
})
console.log(time)
values.createdTime = time
}
if (values.updataTime) {
const _time = values.updataTime.map((item, index) => {
const str = this.dateFtt('YYYY-MM-DD', item._d)
return str
})
console.log(_time)
values.updataTime = _time
}
if (this.gridOptions.pagerConfig.pageSize !== pageSize) {
console.log('pagesize变化', pageSize)
this.gridOptions.pagerConfig.pageSize = pageSize
// this.editColumnsSave(this.gridOptions.columns, pageSize)
}
this.gridOptions.pagerConfig.currentPage = currentPage
this.gridOptions.pagerConfig.pageSize = pageSize
this.getTableList(values)
}
})
},
toggleAdvanced() {
this.advanced = !this.advanced
},
tableRefresh() {
const {
form: { validateFields },
} = this
validateFields((err, values) => {
if (!err) {
this.getTableList(values)
}
})
},
dateFtt(fmt, date) {
const o = {
'Y+': date.getFullYear(),
'M+': date.getMonth() + 1,
'D+': date.getDate(),
'h+': date.getHours(),
'm+': date.getMinutes(),
's+': date.getSeconds(),
}
for (const k in o) {
if (new RegExp(`(${k})`).test(fmt)) {
const str = o[k] + ''
fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : this.padZero(str))
}
}
return fmt
},
padZero(num) {
return new RegExp(/^\d$/g).test(num) ? `0${num}` : num
},
cancelRemove(e) {
console.log(e)
this.$message.error('取消操作')
},
columnChange(data) {
const arr = []
data.map((item, index) => {
if (item.checked) {
arr.push(item)
}
})
this.showColumns = []
this.showColumns = arr
this.gridOptions.columns = arr
this.editColumnsSave(this.gridOptions.columns)
this.$forceUpdate()
},
addProject() {
this.addFromData = {}
this.addFromType = 'add'
this.addFromId = ''
this.$refs.addForm.add()
},
tableReset() {
this.form.resetFields()
this.init()
},
// handleOk() {
// const form = this.$refs.addForm.form
// form.validateFields((errors, values) => {
// if (!errors) {
// console.log('values', values)
// Save({
// pkId: this.addFromId,
// projectCode: values.projectCode,
// projectName: values.projectName,
// projectDesp: values.projectDesp,
// genDate: this.addFromData.genDate,
// genEr: this.addFromData.genEr,
// genName: this.addFromData.genName,
// updDate: this.addFromData.updDate,
// updEr: this.addFromData.updEr,
// updName: this.addFromData.updName,
// })
// .then((res) => {
// this.$refs.addForm.$data.confirmLoading = false
// if (res.succ) {
// this.$message.success('')
// this.$refs.addForm.handleCancel()
// this.tableRefresh()
// } else {
// this.$message.error(res.msg)
// }
// })
// .catch((err) => {
// console.log(err)
// })
// }
// })
// },
tableHeaderSort(type) {
if (this.tableSortType === type) {
this.tableSortOrder = this.tableSortOrder === '0' ? '1' : '0'
} else {
this.tableSortType = type
this.tableSortOrder = '0'
}
this.tableRefresh()
},
resizableChange(e) {
this.gridOptions.columns[e.columnIndex].width = e.resizeWidth
this.editColumnsSave(this.gridOptions.columns)
},
editColumnsSave(columns = {}, pageSize = this.gridOptions.pagerConfig.pageSize) {
const data = {
columns: columns,
pageSize: pageSize,
}
addConfig({
settingCode: 'rules_project_account',
settingJson: JSON.stringify(data),
}).then((res) => {
console.log('保存成功')
})
},
},
}
</script>
<style lang="less" scoped>
.right {
float: right;
margin-right: 20px;
cursor: pointer;
padding-top: 10px;
}
.tab-btn {
margin-right: 10px;
}
.table-page-search-submitButtons {
text-align: right;
}
.ant-btn {
margin-right: 8px;
}
.table {
margin: 8px auto 20px;
}
.column-header {
.tit {
display: inline-block;
height: 18px;
line-height: 18px;
vertical-align: top;
}
.icon {
display: inline-block;
position: relative;
width: 20px;
height: 18px;
vertical-align: top;
.icon-btn {
position: absolute;
width: 20px;
height: 9px;
color: #ccc;
&.top {
top: -2px;
left: 0;
}
&.bottom {
bottom: 2px;
left: 0;
}
&.active {
color: #666;
}
}
}
}
</style>

@ -0,0 +1,157 @@
<template>
<a-modal
:title="`${type == 'edit' ? '修改' : '新增'}解析器`"
:width="900"
:visible="visible"
:confirmLoading="confirmLoading"
cancelText="关闭"
okText="保存"
@ok="handleSubmit"
@cancel="handleCancel"
>
<a-spin :spinning="formLoading">
<a-form :form="form">
<a-row :gutter="16">
<a-col :span="12">
<a-form-item label="解析器名称" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
<a-input
placeholder="请输入解析器名称"
v-decorator="['parserName', { rules: [{ required: true, message: '请输入解析器名称!' }] }]"
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="解析器类" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
<a-input
placeholder="请输入解析器类"
v-decorator="['parserType', { rules: [{ required: true, message: '请输入解析器类!' }] }]"
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="处理器链" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
<a-input
placeholder="请输入处理器链"
v-decorator="['processorChain', { rules: [{ required: true, message: '请输入处理器链!' }] }]"
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="标题正则表达式" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
<a-input
placeholder="请输入标题正则表达式"
v-decorator="['subjectRegex', { rules: [{ required: true, message: '请输入标题正则表达式!' }] }]"
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="发送人正则表达式" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
<a-input
placeholder="请输入发送人正则表达式"
v-decorator="['senderRegex', { rules: [{ required: true, message: '请输入发送人正则表达式!' }] }]"
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="附件正则表达式" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
<a-input
placeholder="请输入附件正则表达式"
v-decorator="['attachRegex', { rules: [{ required: true, message: '请输入附件正则表达式!' }] }]"
/>
</a-form-item>
</a-col>
</a-row>
</a-form>
<template v-if="type === 'edit'">
<div class="line">
<span>创建日期 {{ fromData.genDate || '--' }} </span><span>创建人 {{ fromData.genName || '--' }} </span>
</div>
<div class="line">
<span>更新日期 {{ fromData.updDate || '--' }} </span><span>更新人 {{ fromData.updName || '--' }} </span>
</div>
</template>
</a-spin>
</a-modal>
</template>
<script>
// import { sysDictTypeDropDown, sysConfigAdd } from '@/api/modular/system/configManage'
export default {
props: {
type: {
type: String,
default: 'add',
},
fromData: {
type: Object,
default: null,
},
},
data() {
return {
labelCol: {
xs: { span: 24 },
sm: { span: 8 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 15 },
},
visible: false,
confirmLoading: false,
formLoading: true,
form: this.$form.createForm(this),
}
},
watch: {
fromData: {
handler(nval, oval) {
if (!this.formLoading) {
this.$nextTick(() => {
this.form.setFieldsValue(nval)
})
}
},
deep: true,
},
},
methods: {
add() {
this.visible = true
this.formLoading = false
},
handleSubmit() {
const {
form: { validateFields },
} = this
this.confirmLoading = true
validateFields((errors, values) => {
if (!errors) {
this.$emit('ok', values)
} else {
this.confirmLoading = false
}
})
},
handleCancel() {
this.form.resetFields()
this.visible = false
},
},
}
</script>
<style lang="less" scoped>
.line {
height: 30px;
line-height: 30px;
text-align: right;
font-size: 14px;
span {
margin-left: 20px;
}
span:nth-of-type(2) {
width: 120px;
display: inline-block;
text-align: left;
}
}
</style>

@ -0,0 +1,21 @@
export default {
columns: [
{ type: 'checkbox', noDraggable: true, width: 100 },
{
field: 'parserName',
title: '解析器名称',
slots: { header: 'parserName_header' },
},
{ field: 'parserType', title: '解析器类', slots: { header: 'parserType_header' } },
{ field: 'processorChain', title: '处理器链', slots: { header: 'processorChain_header' } },
{ field: 'subjectRegex', title: '标题正则表达式', slots: { header: 'subjectRegex_header' } },
{ field: 'senderRegex', title: '发送人正则表达式', slots: { header: 'senderRegex_header' } },
{
field: 'attachRegex',
title: '附件正则表达式',
showHeaderOverflow: true,
slots: { header: 'attachRegex_header' },
},
{ title: '操作', width: 80, noDraggable: true, slots: { default: 'operate' }, fixed: 'right' },
],
}
Loading…
Cancel
Save