This commit is contained in:
yangduo 2024-08-08 16:27:05 +08:00
parent bb1cfa1016
commit e21235247c
2 changed files with 141 additions and 97 deletions

View File

@ -8,10 +8,11 @@ export function addMail(data) {
})
}
export function getMailList(cursor, pagesize) {
export function getMailList(cursor, pagesize, data) {
return request({
url: '/mail/list?cursor=' + cursor + '&pagesize=' + pagesize,
method: 'get'
method: 'post',
data
})
}

View File

@ -1,76 +1,102 @@
<template>
<div class="app-container">
<el-table
v-table-scroll-load="nextStream"
:empty-text="emptytext"
height="700"
:data="mailList"
border
fit
highlight-current-row
style="width: 100%;"
>
<el-table-column
prop="mail_id"
label="邮件id"
/>
<el-table-column
prop="mail_type"
label="邮件类型"
/>
<el-table-column
prop="subject"
label="邮件标题"
/>
<el-table-column
prop="content"
label="邮件内容"
/>
<el-table-column
prop="sendtime"
label="发送时间"
>
<template slot-scope="{row}">
<span>
{{ parseTime(row.sendtime) }}
</span>
</template>
</el-table-column>
<el-table-column
prop="expiretime"
label="过期时间"
>
<template slot-scope="{row}">
<span>
{{ parseTime(row.expiretime) }}
</span>
</template>
</el-table-column>
<!-- <el-table-column prop="to" label="收件人" width="95">-->
<!-- </el-table-column>-->
<el-table-column label="附件" align="center" width="95">
<template slot-scope="{row}">
<span v-if="row.attachments != null && row.attachments.length > 0" class="link-type" @click="handleFetchAtta(row.attachments)">查看</span>
<el-tag v-else type="info"></el-tag>
</template>
</el-table-column>
<el-table-column
fixed="right"
label="操作"
width="100"
>
<template slot-scope="scope">
<el-button type="text" size="small" @click="handleUpdate(scope.row)">编辑</el-button>
<el-button type="text" size="small" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-dialog :visible.sync="dialogAttaVisible" title="附件">
<el-table :data="attaData" border fit highlight-current-row style="width: 100%">
<el-table-column prop="itemid" label="ItemId" />
<el-table-column prop="itemnum" label="ItemNum" />
</el-table>
</el-dialog>
<el-form ref="postForm" :model="postForm" :rules="rules" class="form-container">
<div class="createPost-main-container">
<el-row>
<el-col :span="5">
<el-form-item label-width="120px" label="邮件标题" class="postInfo-container-item" prop="subject">
<el-input v-model="postForm.subject" />
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label-width="120px" label="邮件内容" class="postInfo-container-item" prop="content">
<el-input v-model="postForm.content" />
</el-form-item>
</el-col>
<el-button style="margin-left: 10px;" type="success" @click="submitForm()">
查询
</el-button>
</el-row>
<el-table
:empty-text="emptytext"
height="700"
:data="mailList"
border
fit
highlight-current-row
style="width: 100%;"
>
<el-table-column
prop="mail_id"
label="邮件id"
/>
<el-table-column
prop="mail_type"
label="邮件类型"
/>
<el-table-column
prop="subject"
label="邮件标题"
/>
<el-table-column
prop="content"
label="邮件内容"
/>
<el-table-column
prop="sendtime"
label="发送时间"
>
<template slot-scope="{row}">
<span>
{{ parseTime(row.sendtime) }}
</span>
</template>
</el-table-column>
<el-table-column
prop="expiretime"
label="过期时间"
>
<template slot-scope="{row}">
<span>
{{ parseTime(row.expiretime) }}
</span>
</template>
</el-table-column>
<!-- <el-table-column prop="to" label="收件人" width="95">-->
<!-- </el-table-column>-->
<el-table-column label="附件" align="center" width="95">
<template slot-scope="{row}">
<span v-if="row.attachments != null && row.attachments.length > 0" class="link-type" @click="handleFetchAtta(row.attachments)">查看</span>
<el-tag v-else type="info"></el-tag>
</template>
</el-table-column>
<el-table-column
fixed="right"
label="操作"
width="100"
>
<template slot-scope="scope">
<el-button type="text" size="small" @click="handleUpdate(scope.row)">编辑</el-button>
<el-button type="text" size="small" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
background
:current-page="curpage"
:page-size="pagesize"
:page-count="totalpage"
layout="prev, pager, next"
@current-change="handleCurrentChange"
/>
<el-dialog :visible.sync="dialogAttaVisible" title="附件">
<el-table :data="attaData" border fit highlight-current-row style="width: 100%">
<el-table-column prop="itemid" label="ItemId" />
<el-table-column prop="itemnum" label="ItemNum" />
</el-table>
</el-dialog>
</div>
</el-form>
</div>
</template>
<script>
@ -84,32 +110,61 @@ export default {
},
data() {
return {
postForm: {
subject: '',
content: ''
},
rules: {
subject: [{ required: false, message: '', trigger: 'blur' }],
content: [{ required: false, message: '', trigger: 'blur' }]
},
dialogAttaVisible: false,
mailList: [],
attaData: [],
cursor: 0,
remaining: 0,
pagesize: 50,
emptytext: ' '
pagesize: 8,
totalpage: 0,
curpage: 0,
emptytext: ' ',
querydata: null
}
},
created() {
this.getList()
this.querydata = JSON.parse(JSON.stringify(this.postForm))
this.getList(this.querydata)
},
methods: {
parseTime,
getList() {
getMailList(this.cursor, this.pagesize).then(response => {
getList(data) {
getMailList(this.curpage, this.pagesize, data).then(response => {
if (response.code === 0) {
this.mailList = response.data
this.cursor = response.cursor
this.remaining = response.remaining
this.curpage = response.curpage
this.totalpage = response.totalpage
if (this.mailList === undefined || this.mailList.length <= 0) {
this.emptytext = 'No data'
}
}
})
},
submitForm() {
console.log('valid begin')
try {
this.$refs['postForm'].validate((valid) => {
console.log('valid end', valid)
if (valid) {
this.querydata = JSON.parse(JSON.stringify(this.postForm))
this.curpage = 0
this.getList(this.querydata)
}
})
} catch (e) {
console.log(e)
}
},
handleCurrentChange(val) {
this.curpage = val
this.getList(this.querydata)
},
handleFetchAtta(row) {
this.attaData = row
this.dialogAttaVisible = true
@ -128,7 +183,9 @@ export default {
type: 'success',
duration: 1200,
onClose: () => {
this.cursor = 0
if (this.curpage === this.totalpage && this.mailList.length < 2 && this.curpage > 1) {
this.curpage--
}
this.getList()
}
})
@ -140,20 +197,6 @@ export default {
})
}
})
},
nextStream() {
console.log('remaining', this.remaining)
if (this.remaining > 0) {
this.remaining = 0
getMailList(this.cursor, this.pagesize).then(response => {
if (response.code === 0) {
console.log('next response', response)
this.mailList = this.mailList.concat(response.data)
this.cursor = response.cursor
this.remaining = response.remaining
}
})
}
}
}
}