yeg
2 天以前 d8eaa16682cf180e9563d6be05fb43057daf6c07
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<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>