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

@ -15,26 +15,34 @@ export function mailAccountList(parameter) {
data: parameter,
})
}
export function GetInfo(parameter) {
// 获取解析器列表
export function parserList(parameter) {
return request({
url: RuleEngine.GetInfo + '/' + parameter,
url: '/api/mail/parserList',
method: 'get',
})
}
export function Save(parameter) {
// 获取解析器配置列表
export function parserRelationList(parameter) {
return request({
url: RuleEngine.Save,
method: 'post',
data: parameter,
url: '/api/mail/parserRelationList',
method: 'get',
params: parameter,
})
}
export function Delete(parameter) {
// 保存解析器配置(单邮箱)
export function saveParserRelation(data) {
return request({
url: RuleEngine.Delete,
url: '/api/mail/saveParserRelation',
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 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">
{{ advanced ? '收起' : '展开' }}
<a-icon :type="advanced ? 'up' : 'down'" />
@ -101,10 +101,6 @@
@page-change="handlePageChange"
@resizable-change="resizableChange"
>
<template #operate="{ row }">
<vxe-button type="text" icon="vxe-icon-edit" @click="editColumns(row)"></vxe-button>
</template>
<template #mailAccount_header="{ column }">
<div class="column-header">
<span class="tit">{{ column.title }}</span>
@ -154,7 +150,20 @@
</div>
</x-card>
</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" /> -->
</a-row>
</div>
@ -165,7 +174,7 @@ import columnSetting from '@/components/tableColumnSetting'
import addForm from './modules/addForm'
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 initData from './modules/initData'
export default {
@ -210,6 +219,8 @@ export default {
addFromType: 'add',
tableSortType: '',
tableSortOrder: '1',
parserVisible: false,
parserTableData: [],
}
},
watch: {
@ -223,9 +234,52 @@ export default {
created() {
this.showColumns = JSON.parse(JSON.stringify(initData.columns))
this.getTableList()
this.parserList()
},
mounted() {},
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 = {}) {
this.gridOptions.pagerConfig = {
total: 0,
@ -236,14 +290,21 @@ export default {
this.gridOptions.data = []
this.getTableList(queryParam)
},
parserList() {
parserList().then((res) => {
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) => {
console.log(res)
if (res.statusCode == 200) {
this.gridOptions.pagerConfig.total = res.data.total
this.gridOptions.data = res.data.mailAccount
@ -408,6 +469,7 @@ export default {
},
editColumns(data) {
console.log(data)
this.addFromType = 'edit'
this.addFromId = data.pkId
GetInfo(this.addFromId).then((res) => {
@ -430,39 +492,39 @@ export default {
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)
})
}
})
},
// 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) {

Loading…
Cancel
Save