<script setup lang="ts">
|
import { onMounted, ref, watch } from 'vue'
|
import { ElMessage } from 'element-plus'
|
import { getProtocolSetting, saveProtocolSetting } from '../api/admin'
|
import AdminRichTextEditor from '../components/AdminRichTextEditor.vue'
|
|
const protocols = [
|
{ key: 'talent_user_agreement', label: '用户协议-人才' },
|
{ key: 'merchant_user_agreement', label: '用户协议-商户' },
|
{ key: 'talent_privacy_policy', label: '隐私与权限-人才' },
|
{ key: 'merchant_privacy_policy', label: '隐私与权限-商户' },
|
]
|
|
const activeKey = ref(protocols[0].key)
|
const contentHtml = ref('')
|
const loading = ref(false)
|
const saving = ref(false)
|
|
async function loadProtocol() {
|
loading.value = true
|
try {
|
const result = await getProtocolSetting(activeKey.value)
|
contentHtml.value = String(result.contentHtml || '')
|
} finally {
|
loading.value = false
|
}
|
}
|
|
async function save() {
|
saving.value = true
|
try {
|
await saveProtocolSetting(activeKey.value, contentHtml.value)
|
ElMessage.success('协议已保存')
|
} finally {
|
saving.value = false
|
}
|
}
|
|
watch(activeKey, loadProtocol)
|
onMounted(loadProtocol)
|
</script>
|
|
<template>
|
<div v-loading="loading" class="protocol-settings-page">
|
<section class="protocol-panel">
|
<el-radio-group v-model="activeKey" class="protocol-tabs">
|
<el-radio-button v-for="item in protocols" :key="item.key" :label="item.key">{{ item.label }}</el-radio-button>
|
</el-radio-group>
|
<AdminRichTextEditor v-model="contentHtml" class="protocol-editor" placeholder="请输入协议内容" />
|
<el-button type="primary" :loading="saving" class="save-button" @click="save">保存</el-button>
|
</section>
|
</div>
|
</template>
|
|
<style scoped>
|
.protocol-settings-page { min-width: 1040px; }
|
.protocol-panel { min-height: 560px; padding: 20px 24px 32px; background: #fff; border: 1px solid #edf0f5; }
|
.protocol-tabs { display: flex; flex-wrap: wrap; }
|
.protocol-tabs :deep(.el-radio-button__inner) { min-width: 118px; }
|
.protocol-editor { margin-top: 40px; }
|
.protocol-editor :deep(.news-editor-body) { min-height: 300px; }
|
.save-button { min-width: 72px; margin-top: 16px; }
|
</style>
|