完善设置-协议

master
panqihua 2 years ago
parent c9f9997c17
commit 503b011c67
  1. 57
      src/views/platform/config/user_agreement.vue

@ -2,28 +2,73 @@
<div class="app-container">
<el-row>
<el-col :span="4">
<div v-for="item in menuList" :key="item" @click="currentMenu=item"
:class="{'active':item===currentMenu,'inactive':item!==currentMenu}">{{ item }}
<div v-for="item in menuList" :key="item" @click="changeMenu(item)"
:class="{'active':item===currentMenu.configName,'inactive':item!==currentMenu.configName}">{{ item }}
</div>
</el-col>
<el-col :span="18" :offset="2">
<Editor/>
<Editor v-model="currentMenu.configValue"/>
</el-col>
</el-row>
<div class="text-center mt20">
<el-button type="primary">保存</el-button>
<el-button type="primary" @click="update">保存</el-button>
<el-button>重置</el-button>
</div>
</div>
</template>
<script>
import { getConfig, updateConfig } from '@/api/system/config'
export default {
name: 'user_agreement',
mounted() {
this.changeMenu()
},
data() {
let form = {
userAgreement: {
'configId': 100,
'configName': '用户协议',
'configKey': 'platform.user.agreement',
'configValue': '',
'active': true
},
privacyPolicy: {
'configId': 101,
'configName': '隐私政策',
'configKey': 'platform.privacy.policy',
'configValue': '',
'active': false
}
}
let menuList = Object.keys(form).map(item => form[item].configName)
return {
currentMenu: '用户协议',
menuList: ['用户协议', '隐私政策']
form,
menuList
}
},
methods: {
update() {
updateConfig(this.currentMenu).then(response => {
this.$modal.msgSuccess(`${this.currentMenu.configName}更新${response.code === 200 ? '成功' : '失败'}`)
})
},
changeMenu(name) {
if (name === undefined) {
name = this.menuList[0]
}
for (let key in this.form) {
this.form[key].active = this.form[key].configName === name
}
getConfig(this.currentMenu.configId).then(response => {
this.currentMenu.configValue = response.data.configValue
})
}
},
computed: {
currentMenu() {
return Object.values(this.form).find(item => item.active)
}
}
}

Loading…
Cancel
Save