| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <template>
- <xn-form-container
- title="举报"
- :height="500"
- placement="bottom"
- :mask="false"
- style="width: 960px; left: calc(50% - 960px / 2)"
- :visible="visible"
- :destroy-on-close="true"
- @close="onClose"
- >
- <a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
- <a-row :gutter="16">
- <a-col :span="12">
- <a-form-item label="举报类型:" name="reportReasonType">
- <a-select
- v-model:value="formData.reportReasonType"
- placeholder="所有分类"
- style="width: 100%"
- :options="typeOptions"
- @change="handleChange"
- ></a-select>
- </a-form-item>
- </a-col>
- <a-col :span="12">
- <a-form-item label="证据图片:" name="evidenceScreenshot">
- <UpLoadImg ref="upLoadImgRef" urlType="2" @handlerUpImage="handlerUpImage"></UpLoadImg>
- </a-form-item>
- </a-col>
- <a-col :span="24">
- <a-form-item label="举报原因:" name="reportDetail">
- <a-textarea
- v-model:value="formData.reportDetail"
- placeholder="请输入举报原因"
- :rows="4"
- show-count
- :maxlength="500"
- />
- </a-form-item>
- </a-col>
- </a-row>
- </a-form>
- <template #footer>
- <a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
- <a-button type="primary" :loading="submitLoading" @click="onSubmit">保存</a-button>
- </template>
- </xn-form-container>
- </template>
- <script setup>
- import { required } from '@/utils/formRules'
- import SnowflakeId from 'snowflake-id'
- import tool from '@/utils/tool'
- import forumApi from '@/api/forum/forumApi'
- import XnEditor from '@/components/Editor/index.vue'
- // 默认是关闭状态
- const visible = ref(false)
- const emit = defineEmits({ successful: null })
- const formRef = ref()
- const treeData = ref([])
- // 表单数据,也就是默认给一些数据
- const formData = ref({})
- // 默认展开的节点(顶级)
- const submitLoading = ref(false)
- // 模块ID
- const moduleId = ref('')
- //回复ID
- const replyid = ref('')
- //类型
- const typeOptions = ref([
- {
- label: '垃圾广告',
- value: 0
- },
- {
- label: '色情内容',
- value: 1
- },
- {
- label: '人身攻击',
- value: 2
- },
- {
- label: '整治敏感',
- value: 3
- },
- {
- label: '其他',
- value: 4
- }
- ])
- const handleChange = (value) => {
- formData.value.reportReasonType = value
- }
- const filterOption = (input, option) => {
- return option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
- }
- const handlerUpImage = (id) => {
- formData.value.evidenceScreenshot = id
- }
- // 打开抽屉
- const onOpen = (record, module) => {
- moduleId.value = module
- visible.value = true
- }
- // 关闭抽屉
- const onClose = () => {
- formRef.value.resetFields()
- visible.value = false
- }
- // 默认要校验的
- const formRules = {
- reportReasonType: [required('请选择举报类型')],
- reportDetail: [required('请输入举报原因')],
- evidenceScreenshot: [required('请上传证据图片')]
- }
- const categoryOptions = tool.dictList('MENU_TYPE')
- const visibleOptions = tool.dictList('MENU_VISIBLE')
- // 验证并提交数据
- const onSubmit = () => {
- formRef.value.validate().then(() => {
- submitLoading.value = true
- forumApi
- .reportinfoAdd({
- ...formData.value,
- postId: moduleId.value
- })
- .then(() => {
- onClose()
- emit('successful')
- })
- .finally(() => {
- submitLoading.value = false
- })
- })
- }
- // 调用这个函数将子组件的一些数据和方法暴露出去
- defineExpose({
- onOpen
- })
- </script>
|