Files
template-nuxt4/app/pages/suggestions/index.vue
2026-04-29 01:33:33 +08:00

165 lines
3.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="suggestions-page">
<div class="page-header">
<h1 class="page-title">建言献策</h1>
<p class="page-desc">您的每一条建议都是我们进步的动力期待您的声音</p>
</div>
<div class="suggestions-content">
<div class="intro-section">
<h2>参与方式</h2>
<p>欢迎您对政策制定经济发展社会治理等方面提出宝贵意见和建议请您先登录或注册账号然后填写建言内容</p>
</div>
<a-form
v-if="isAuthed"
:model="formData"
:rules="rules"
class="suggestion-form"
layout="vertical"
>
<a-form-item label="建言标题" name="title">
<a-input v-model:value="formData.title" :maxlength="100" placeholder="请输入建言标题" show-count />
</a-form-item>
<a-form-item label="建言内容" name="content">
<a-textarea
v-model:value="formData.content"
:maxlength="2000"
:rows="8"
placeholder="请详细描述您的建议和意见..."
show-count
/>
</a-form-item>
<a-form-item label="联系方式(选填)" name="contact">
<a-input v-model:value="formData.contact" placeholder="请输入您的联系方式,方便我们与您联系" />
</a-form-item>
<a-form-item>
<a-space>
<a-button :loading="submitting" size="large" type="primary" @click="handleSubmit">
提交建言
</a-button>
<a-button size="large" @click="handleReset">
重置
</a-button>
</a-space>
</a-form-item>
</a-form>
<div v-else class="login-prompt">
<a-result
sub-title="登录后可提交建言献策"
title="请先登录"
>
<template #extra>
<a-button size="large" type="primary" @click="navigateTo('/login')">
去登录
</a-button>
</template>
</a-result>
</div>
</div>
</div>
</template>
<script lang="ts" setup>
import { message } from 'ant-design-vue'
import { getToken } from '@/utils/token-util'
useHead({ title: '建言献策 - 决策咨询网' })
const isAuthed = computed(() => !!getToken())
const submitting = ref(false)
const formData = reactive({
title: '',
content: '',
contact: '',
})
const rules = {
title: [{ required: true, message: '请输入建言标题' }],
content: [{ required: true, message: '请输入建言内容' }],
}
async function handleSubmit() {
try {
// TODO: 接入实际API提交建言
// await submitSuggestion(formData)
message.success('建言已提交,感谢您的参与!')
handleReset()
} catch (e: any) {
message.error(e?.message || '提交失败')
}
}
function handleReset() {
formData.title = ''
formData.content = ''
formData.contact = ''
}
</script>
<style scoped>
.suggestions-page {
max-width: 800px;
margin: 0 auto;
padding: 40px 20px;
}
.page-header {
text-align: center;
margin-bottom: 40px;
}
.page-title {
font-size: 32px;
font-weight: 700;
color: #1f2937;
margin: 0 0 12px;
}
.page-desc {
font-size: 16px;
color: #6b7280;
margin: 0;
}
.suggestions-content {
background: #fff;
border-radius: 16px;
padding: 40px;
box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.intro-section {
margin-bottom: 32px;
padding-bottom: 24px;
border-bottom: 1px solid #f0f0f0;
}
.intro-section h2 {
font-size: 18px;
font-weight: 600;
color: #1f2937;
margin: 0 0 8px;
}
.intro-section p {
font-size: 14px;
color: #6b7280;
margin: 0;
line-height: 1.6;
}
.suggestion-form {
max-width: 600px;
}
.login-prompt {
padding: 40px 0;
}
</style>