|
@@ -275,6 +275,7 @@ export default {
|
|
|
mixins: [mixinRegionModule],
|
|
mixins: [mixinRegionModule],
|
|
|
data () {
|
|
data () {
|
|
|
return {
|
|
return {
|
|
|
|
|
+ autoSaveTimer: null,
|
|
|
currentFile: '',
|
|
currentFile: '',
|
|
|
cropperIndex: null,
|
|
cropperIndex: null,
|
|
|
showCropper: false,
|
|
showCropper: false,
|
|
@@ -366,6 +367,17 @@ export default {
|
|
|
this.getDetail(this.$route.query.id)
|
|
this.getDetail(this.$route.query.id)
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ // 自动暂存:每30秒保存一次(仅编辑模式)
|
|
|
|
|
+ this.autoSaveTimer = setInterval(() => {
|
|
|
|
|
+ this.autoSave()
|
|
|
|
|
+ }, 30000)
|
|
|
|
|
+ },
|
|
|
|
|
+ beforeDestroy () {
|
|
|
|
|
+ if (this.autoSaveTimer) {
|
|
|
|
|
+ clearInterval(this.autoSaveTimer)
|
|
|
|
|
+ this.autoSaveTimer = null
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
recruitmentChange (e) {
|
|
recruitmentChange (e) {
|
|
@@ -601,6 +613,19 @@ export default {
|
|
|
}, 500)
|
|
}, 500)
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
|
|
+ autoSave () {
|
|
|
|
|
+ // 只在编辑模式(有id)时自动保存
|
|
|
|
|
+ if (!this.basicForm.id) return
|
|
|
|
|
+ let { signupStartEnd, activityStartEnd, ...newBasic } = JSON.parse(JSON.stringify(this.basicForm))
|
|
|
|
|
+ let { recruitmentFlag, userAgeFlag, userLevelFlag, ...newMore } = JSON.parse(JSON.stringify(this.moreForm))
|
|
|
|
|
+ let dto = { ...newBasic, ...newMore }
|
|
|
|
|
+ dto.state = dto.state ? 1 : 0
|
|
|
|
|
+ this.$http.put('/core/activity', dto).then(res => {
|
|
|
|
|
+ if (res.data.code === 0) {
|
|
|
|
|
+ this.$message({ message: '已自动暂存', type: 'success', duration: 1500 })
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(() => {})
|
|
|
|
|
+ },
|
|
|
handleSave () {
|
|
handleSave () {
|
|
|
this.$refs.moreRef.validate(valid => {
|
|
this.$refs.moreRef.validate(valid => {
|
|
|
if (valid) {
|
|
if (valid) {
|