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,7 +1,23 @@
<template>
<div class="app-container">
<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
v-table-scroll-load="nextStream"
:empty-text="emptytext"
height="700"
:data="mailList"
@ -65,6 +81,14 @@
</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" />
@ -72,6 +96,8 @@
</el-table>
</el-dialog>
</div>
</el-form>
</div>
</template>
<script>
// import Pagination from '@/components/Pagination/index.vue'
@ -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
}
})
}
}
}
}