完善设置-协议

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"> <div class="app-container">
<el-row> <el-row>
<el-col :span="4"> <el-col :span="4">
<div v-for="item in menuList" :key="item" @click="currentMenu=item" <div v-for="item in menuList" :key="item" @click="changeMenu(item)"
:class="{'active':item===currentMenu,'inactive':item!==currentMenu}">{{ item }} :class="{'active':item===currentMenu.configName,'inactive':item!==currentMenu.configName}">{{ item }}
</div> </div>
</el-col> </el-col>
<el-col :span="18" :offset="2"> <el-col :span="18" :offset="2">
<Editor/> <Editor v-model="currentMenu.configValue"/>
</el-col> </el-col>
</el-row> </el-row>
<div class="text-center mt20"> <div class="text-center mt20">
<el-button type="primary">保存</el-button> <el-button type="primary" @click="update">保存</el-button>
<el-button>重置</el-button> <el-button>重置</el-button>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { getConfig, updateConfig } from '@/api/system/config'
export default { export default {
name: 'user_agreement', name: 'user_agreement',
mounted() {
this.changeMenu()
},
data() { 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 { return {
currentMenu: '用户协议', form,
menuList: ['用户协议', '隐私政策'] 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