|
|
@@ -13,7 +13,7 @@
|
|
|
<el-icon><Link /></el-icon>获取链接
|
|
|
</el-button>
|
|
|
<el-button size="small" type="primary" plain @click="handleSave('draft')">保存草稿</el-button>
|
|
|
- <el-button size="small" type="primary" @click="handleSave('publish')">发布上线</el-button>
|
|
|
+ <el-button v-if="canPublish" size="small" type="primary" @click="handleSave('publish')">发布上线</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
@@ -221,6 +221,7 @@ export default {
|
|
|
],
|
|
|
configData: {},
|
|
|
pageStatus: 'draft',
|
|
|
+ isModified: false,
|
|
|
sortTarget: 1,
|
|
|
linkDialogVisible: false,
|
|
|
linkForm: { campaignId: '', channelId: '' },
|
|
|
@@ -232,6 +233,9 @@ export default {
|
|
|
currentTierData() {
|
|
|
return this.configData[this.currentTier] || null
|
|
|
},
|
|
|
+ canPublish() {
|
|
|
+ return !this.isModified && ['draft', 'modified'].includes(this.pageStatus)
|
|
|
+ },
|
|
|
linkQueryStr() {
|
|
|
const params = []
|
|
|
if (this.linkForm.campaignId) params.push(`CampaignId=${this.linkForm.campaignId}`)
|
|
|
@@ -257,6 +261,7 @@ export default {
|
|
|
const res = await request.get('/api/page-config/home')
|
|
|
this.configData = this.normalizeHomeConfig(res.data.config || {})
|
|
|
this.pageStatus = res.data.status
|
|
|
+ this.isModified = false
|
|
|
},
|
|
|
normalizeHomeConfig(config) {
|
|
|
Object.keys(config).forEach((key) => {
|
|
|
@@ -280,6 +285,7 @@ export default {
|
|
|
if (this.pageStatus === 'published') {
|
|
|
this.pageStatus = 'modified'
|
|
|
}
|
|
|
+ this.isModified = true
|
|
|
},
|
|
|
onTierChange() {},
|
|
|
triggerUpload(type, index) {
|
|
|
@@ -334,9 +340,14 @@ export default {
|
|
|
},
|
|
|
async handleSave(type) {
|
|
|
if (!this.validatePrivilegeImages()) return
|
|
|
- const status = type === 'publish' ? 'published' : 'draft'
|
|
|
+ if (type === 'publish' && this.isModified) {
|
|
|
+ ElMessage.warning('请先保存草稿后再发布上线')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const status = type === 'publish' ? 'published' : (this.pageStatus === 'published' || this.pageStatus === 'modified' ? 'modified' : 'draft')
|
|
|
await request.put('/api/page-config/home', { config: this.configData, status })
|
|
|
this.pageStatus = status
|
|
|
+ this.isModified = false
|
|
|
ElMessage.success(type === 'publish' ? '已发布权益介绍页配置!' : '已保存权益介绍页配置草稿!')
|
|
|
},
|
|
|
onPrivilegeImageToggle(val) {
|