邮件编辑增加保存本地缓存功能
This commit is contained in:
parent
0bc1c1ca9c
commit
feeb88c16a
@ -9,17 +9,29 @@
|
|||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="addMail"
|
@click="addMail"
|
||||||
|
icon="el-icon-plus"
|
||||||
>新增</el-button>
|
>新增</el-button>
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
@click="addFromDraft"
|
||||||
|
icon="el-icon-document"
|
||||||
|
plain
|
||||||
|
>从模板新增</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
@click="switchData"
|
@click="switchData"
|
||||||
type="success"
|
type="success"
|
||||||
|
icon="el-icon-d-caret"
|
||||||
>{{ switchText }}</el-button>
|
>{{ switchText }}</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
v-if="batch.show && ((isDev && permEdit) || (!isDev && permPublish))"
|
v-if="batch.show && ((isDev && permEdit) || (!isDev && permPublish))"
|
||||||
type="danger"
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
@click="batchDel"
|
@click="batchDel"
|
||||||
>批量删除</el-button>
|
>批量删除</el-button>
|
||||||
<el-button @click="batchOpt"> {{ batch.txt }} </el-button>
|
<el-button
|
||||||
|
@click="batchOpt"
|
||||||
|
icon="el-icon-setting"
|
||||||
|
> {{ batch.txt }} </el-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="r fr">
|
<div class="r fr">
|
||||||
<el-button
|
<el-button
|
||||||
@ -164,7 +176,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
v-if="modalForm.mailtype == 1"
|
v-if="modalForm.mailtype == 1"
|
||||||
label="发件人"
|
label="收件人"
|
||||||
prop="mailTo"
|
prop="mailTo"
|
||||||
>
|
>
|
||||||
<el-input v-model="modalForm.to" :disabled="!isNew"/>
|
<el-input v-model="modalForm.to" :disabled="!isNew"/>
|
||||||
@ -267,6 +279,11 @@
|
|||||||
</el-form>
|
</el-form>
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
<el-button @click="closeModal">取 消</el-button>
|
<el-button @click="closeModal">取 消</el-button>
|
||||||
|
<el-button
|
||||||
|
@click="reset"
|
||||||
|
type="warning"
|
||||||
|
plain
|
||||||
|
>重置</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="save"
|
@click="save"
|
||||||
@ -325,6 +342,7 @@ import {
|
|||||||
} from '@/api/mail'
|
} from '@/api/mail'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
|
|
||||||
|
const MAIL_DRAFT_KEY = 'mail_draft_key'
|
||||||
export default {
|
export default {
|
||||||
name: 'GameDetailsMail',
|
name: 'GameDetailsMail',
|
||||||
data() {
|
data() {
|
||||||
@ -480,12 +498,32 @@ export default {
|
|||||||
clearValidate(formName) {
|
clearValidate(formName) {
|
||||||
this.$refs[formName].clearValidate()
|
this.$refs[formName].clearValidate()
|
||||||
},
|
},
|
||||||
|
addFromDraft() {
|
||||||
// toolbar
|
|
||||||
addMail() {
|
|
||||||
this.openModal()
|
this.openModal()
|
||||||
this.isNew = true
|
this.isNew = true
|
||||||
this.modalForm = {
|
this.modalForm = this.readFromLocal()
|
||||||
|
},
|
||||||
|
saveToLocal(data) {
|
||||||
|
localStorage.setItem(MAIL_DRAFT_KEY, JSON.stringify(data))
|
||||||
|
},
|
||||||
|
readFromLocal() {
|
||||||
|
const localData = localStorage.getItem(MAIL_DRAFT_KEY)
|
||||||
|
let data
|
||||||
|
if (localData) {
|
||||||
|
try {
|
||||||
|
data = JSON.parse(localData)
|
||||||
|
} catch (err) {
|
||||||
|
console.log('get localstorage err')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!data) {
|
||||||
|
data = this.newEmptyMail()
|
||||||
|
}
|
||||||
|
data.mailid = ''
|
||||||
|
return data
|
||||||
|
},
|
||||||
|
newEmptyMail() {
|
||||||
|
return {
|
||||||
subject: '',
|
subject: '',
|
||||||
actived: true,
|
actived: true,
|
||||||
attachments: [],
|
attachments: [],
|
||||||
@ -500,6 +538,12 @@ export default {
|
|||||||
ext: ''
|
ext: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// toolbar
|
||||||
|
addMail() {
|
||||||
|
this.openModal()
|
||||||
|
this.isNew = true
|
||||||
|
this.modalForm = this.newEmptyMail()
|
||||||
|
},
|
||||||
batchOpt() {
|
batchOpt() {
|
||||||
this.batch.show = !this.batch.show
|
this.batch.show = !this.batch.show
|
||||||
this.batch.txt = this.batch.show ? '关闭' : '批量操作'
|
this.batch.txt = this.batch.show ? '关闭' : '批量操作'
|
||||||
@ -530,6 +574,19 @@ export default {
|
|||||||
delItem(index) {
|
delItem(index) {
|
||||||
this.modalForm.attachments.splice(index, 1)
|
this.modalForm.attachments.splice(index, 1)
|
||||||
},
|
},
|
||||||
|
reset() {
|
||||||
|
this.$confirm('确定重置为空的邮件?', '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
console.log('确定')
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.$message.info('已取消!')
|
||||||
|
})
|
||||||
|
},
|
||||||
save() {
|
save() {
|
||||||
this.validateForm('modalForm')
|
this.validateForm('modalForm')
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@ -539,6 +596,7 @@ export default {
|
|||||||
.then(res => {
|
.then(res => {
|
||||||
this.$message.success('保存成功!')
|
this.$message.success('保存成功!')
|
||||||
this.queryMails()
|
this.queryMails()
|
||||||
|
this.saveToLocal(this.modalForm)
|
||||||
this.closeModal()
|
this.closeModal()
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user