master
张同海 2 years ago
parent 598b87a520
commit 553107ed7f

@ -15,26 +15,34 @@ export function mailAccountList(parameter) {
data: parameter, data: parameter,
}) })
} }
// 获取解析器列表
export function GetInfo(parameter) { export function parserList(parameter) {
return request({ return request({
url: RuleEngine.GetInfo + '/' + parameter, url: '/api/mail/parserList',
method: 'get', method: 'get',
}) })
} }
// 获取解析器配置列表
export function Save(parameter) { export function parserRelationList(parameter) {
return request({ return request({
url: RuleEngine.Save, url: '/api/mail/parserRelationList',
method: 'post', method: 'get',
data: parameter, params: parameter,
}) })
} }
// 保存解析器配置(单邮箱)
export function Delete(parameter) { export function saveParserRelation(data) {
return request({ return request({
url: RuleEngine.Delete, url: '/api/mail/saveParserRelation',
method: 'post', method: 'post',
data: parameter, data: data,
})
}
// 发送解析邮件消息
export function parseMail(parameter) {
return request({
url: '/api/mail/parseMail',
method: 'get',
params: parameter,
}) })
} }

@ -54,7 +54,7 @@
> >
<a-button @click="tableReset"></a-button> <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="tableRefresh"></a-button>
<a-button type="primary" style="margin-left: 8px" @click="tableReset"></a-button> <a-button type="primary" style="margin-left: 8px" @click="showParserVisible"></a-button>
<!-- <a @click="toggleAdvanced" style="margin-left: 8px"> <!-- <a @click="toggleAdvanced" style="margin-left: 8px">
{{ advanced ? '收起' : '展开' }} {{ advanced ? '收起' : '展开' }}
<a-icon :type="advanced ? 'up' : 'down'" /> <a-icon :type="advanced ? 'up' : 'down'" />
@ -101,10 +101,6 @@
@page-change="handlePageChange" @page-change="handlePageChange"
@resizable-change="resizableChange" @resizable-change="resizableChange"
> >
<template #operate="{ row }">
<vxe-button type="text" icon="vxe-icon-edit" @click="editColumns(row)"></vxe-button>
</template>
<template #mailAccount_header="{ column }"> <template #mailAccount_header="{ column }">
<div class="column-header"> <div class="column-header">
<span class="tit">{{ column.title }}</span> <span class="tit">{{ column.title }}</span>
@ -154,7 +150,20 @@
</div> </div>
</x-card> </x-card>
</a-col> </a-col>
<a-modal v-model="parserVisible" title="编辑" @ok="handleOk" width="40%">
<template #footer>
<a-button key="submit" type="primary" @click="handleOk"></a-button>
</template>
<vxe-table ref="MailModal" align="left" :data="parserTableData">
<vxe-column type="checkbox" width="60"></vxe-column>
<vxe-column field="parserName" title="解析器名称"></vxe-column>
<vxe-column field="parserMail" title="是否转发邮件">
<template #default="{ row }">
<vxe-checkbox v-model="row.parserMail"></vxe-checkbox>
</template>
</vxe-column>
</vxe-table>
</a-modal>
<!-- <add-form ref="addForm" :fromData="addFromData" :type="addFromType" @ok="handleOk" /> --> <!-- <add-form ref="addForm" :fromData="addFromData" :type="addFromType" @ok="handleOk" /> -->
</a-row> </a-row>
</div> </div>
@ -165,7 +174,7 @@ import columnSetting from '@/components/tableColumnSetting'
import addForm from './modules/addForm' import addForm from './modules/addForm'
import { GetPage, GetInfo, Save, Delete } from '@/api/rulesEngineProject' import { GetPage, GetInfo, Save, Delete } from '@/api/rulesEngineProject'
import { mailAccountList } from '@/api/mail' import { mailAccountList, parserList, parserRelationList, saveParserRelation, parseMail } from '@/api/mail'
import { addConfig } from '@/api/common' import { addConfig } from '@/api/common'
import initData from './modules/initData' import initData from './modules/initData'
export default { export default {
@ -210,6 +219,8 @@ export default {
addFromType: 'add', addFromType: 'add',
tableSortType: '', tableSortType: '',
tableSortOrder: '1', tableSortOrder: '1',
parserVisible: false,
parserTableData: [],
} }
}, },
watch: { watch: {
@ -223,9 +234,52 @@ export default {
created() { created() {
this.showColumns = JSON.parse(JSON.stringify(initData.columns)) this.showColumns = JSON.parse(JSON.stringify(initData.columns))
this.getTableList() this.getTableList()
this.parserList()
}, },
mounted() {}, mounted() {},
methods: { methods: {
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 = {}) { init(queryParam = {}) {
this.gridOptions.pagerConfig = { this.gridOptions.pagerConfig = {
total: 0, total: 0,
@ -236,14 +290,21 @@ export default {
this.gridOptions.data = [] this.gridOptions.data = []
this.getTableList(queryParam) this.getTableList(queryParam)
}, },
parserList() {
parserList().then((res) => {
res.data.forEach((item) => {
item.parserMail = false
})
this.parserTableData = res.data
console.log(res)
})
},
getTableList(queryParam = {}) { getTableList(queryParam = {}) {
mailAccountList({ mailAccountList({
...queryParam, ...queryParam,
page: this.gridOptions.pagerConfig.currentPage, page: this.gridOptions.pagerConfig.currentPage,
limit: this.gridOptions.pagerConfig.pageSize, limit: this.gridOptions.pagerConfig.pageSize,
}).then((res) => { }).then((res) => {
console.log(res)
if (res.statusCode == 200) { if (res.statusCode == 200) {
this.gridOptions.pagerConfig.total = res.data.total this.gridOptions.pagerConfig.total = res.data.total
this.gridOptions.data = res.data.mailAccount this.gridOptions.data = res.data.mailAccount
@ -408,6 +469,7 @@ export default {
}, },
editColumns(data) { editColumns(data) {
console.log(data)
this.addFromType = 'edit' this.addFromType = 'edit'
this.addFromId = data.pkId this.addFromId = data.pkId
GetInfo(this.addFromId).then((res) => { GetInfo(this.addFromId).then((res) => {
@ -430,39 +492,39 @@ export default {
this.form.resetFields() this.form.resetFields()
this.init() this.init()
}, },
handleOk() { // handleOk() {
const form = this.$refs.addForm.form // const form = this.$refs.addForm.form
form.validateFields((errors, values) => { // form.validateFields((errors, values) => {
if (!errors) { // if (!errors) {
console.log('values', values) // console.log('values', values)
Save({ // Save({
pkId: this.addFromId, // pkId: this.addFromId,
projectCode: values.projectCode, // projectCode: values.projectCode,
projectName: values.projectName, // projectName: values.projectName,
projectDesp: values.projectDesp, // projectDesp: values.projectDesp,
genDate: this.addFromData.genDate, // genDate: this.addFromData.genDate,
genEr: this.addFromData.genEr, // genEr: this.addFromData.genEr,
genName: this.addFromData.genName, // genName: this.addFromData.genName,
updDate: this.addFromData.updDate, // updDate: this.addFromData.updDate,
updEr: this.addFromData.updEr, // updEr: this.addFromData.updEr,
updName: this.addFromData.updName, // updName: this.addFromData.updName,
}) // })
.then((res) => { // .then((res) => {
this.$refs.addForm.$data.confirmLoading = false // this.$refs.addForm.$data.confirmLoading = false
if (res.succ) { // if (res.succ) {
this.$message.success('保存成功') // this.$message.success('')
this.$refs.addForm.handleCancel() // this.$refs.addForm.handleCancel()
this.tableRefresh() // this.tableRefresh()
} else { // } else {
this.$message.error(res.msg) // this.$message.error(res.msg)
} // }
}) // })
.catch((err) => { // .catch((err) => {
console.log(err) // console.log(err)
}) // })
} // }
}) // })
}, // },
tableHeaderSort(type) { tableHeaderSort(type) {
if (this.tableSortType === type) { if (this.tableSortType === type) {

Loading…
Cancel
Save