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({ return request({
url: '/mail/list?cursor=' + cursor + '&pagesize=' + pagesize, url: '/mail/list?cursor=' + cursor + '&pagesize=' + pagesize,
method: 'get' method: 'post',
data
}) })
} }

View File

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