reportForm.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <xn-form-container
  3. title="回复"
  4. :height="500"
  5. placement="bottom"
  6. :mask="false"
  7. style="width: 960px; left: calc(50% - 960px / 2)"
  8. :visible="visible"
  9. :destroy-on-close="true"
  10. @close="onClose"
  11. >
  12. <a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
  13. <a-row :gutter="16">
  14. <a-col :span="12">
  15. <a-form-item label="举报类型:" name="reportReasonType">
  16. <a-select
  17. v-model:value="formData.reportReasonType"
  18. show-search
  19. placeholder="所有分类"
  20. style="width: 100%"
  21. :options="typeOptions"
  22. :filter-option="filterOption"
  23. @change="handleChange"
  24. ></a-select>
  25. </a-form-item>
  26. </a-col>
  27. <a-col :span="12">
  28. <a-form-item label="证据图片:" name="evidenceScreenshot">
  29. <UpLoadImg ref="upLoadImgRef" urlType="2" @handlerUpImage="handlerUpImage"></UpLoadImg>
  30. </a-form-item>
  31. </a-col>
  32. <a-col :span="24">
  33. <a-form-item label="举报原因:" name="reportDetail">
  34. <a-textarea v-model:value="formData.reportDetail" placeholder="请输入举报原因" :rows="4" />
  35. </a-form-item>
  36. </a-col>
  37. </a-row>
  38. </a-form>
  39. <template #footer>
  40. <a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
  41. <a-button type="primary" :loading="submitLoading" @click="onSubmit">保存</a-button>
  42. </template>
  43. </xn-form-container>
  44. </template>
  45. <script setup>
  46. import { required } from '@/utils/formRules'
  47. import SnowflakeId from 'snowflake-id'
  48. import tool from '@/utils/tool'
  49. import forumApi from '@/api/forum/forumApi'
  50. import XnEditor from '@/components/Editor/index.vue'
  51. // 默认是关闭状态
  52. const visible = ref(false)
  53. const emit = defineEmits({ successful: null })
  54. const formRef = ref()
  55. const treeData = ref([])
  56. // 表单数据,也就是默认给一些数据
  57. const formData = ref({})
  58. // 默认展开的节点(顶级)
  59. const submitLoading = ref(false)
  60. // 模块ID
  61. const moduleId = ref('')
  62. //回复ID
  63. const replyid = ref('')
  64. //类型
  65. const typeOptions = ref([
  66. {
  67. label: '垃圾广告',
  68. value: 0
  69. },
  70. {
  71. label: '色情内容',
  72. value: 1
  73. },
  74. {
  75. label: '人身攻击',
  76. value: 2
  77. },
  78. {
  79. label: '整治敏感',
  80. value: 3
  81. },
  82. {
  83. label: '其他',
  84. value: 4
  85. }
  86. ])
  87. const handleChange = (value) => {
  88. formData.value.reportReasonType = value
  89. }
  90. const filterOption = (input, option) => {
  91. return option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
  92. }
  93. const handlerUpImage = (id) => {
  94. formData.value.evidenceScreenshot = id
  95. }
  96. // 打开抽屉
  97. const onOpen = (record, module) => {
  98. moduleId.value = module
  99. visible.value = true
  100. }
  101. // 关闭抽屉
  102. const onClose = () => {
  103. formRef.value.resetFields()
  104. visible.value = false
  105. }
  106. // 默认要校验的
  107. const formRules = {
  108. reportReasonType: [required('请选择举报类型')],
  109. reportDetail: [required('请输入举报原因')],
  110. evidenceScreenshot: [required('请上传证据图片')]
  111. }
  112. const categoryOptions = tool.dictList('MENU_TYPE')
  113. const visibleOptions = tool.dictList('MENU_VISIBLE')
  114. // 验证并提交数据
  115. const onSubmit = () => {
  116. formRef.value
  117. .validate()
  118. .then(() => {
  119. submitLoading.value = true
  120. forumApi
  121. .reportinfoAdd({
  122. ...formData.value,
  123. postId: moduleId.value
  124. })
  125. .then(() => {
  126. onClose()
  127. emit('successful')
  128. })
  129. })
  130. .finally(() => {
  131. submitLoading.value = false
  132. })
  133. }
  134. // 调用这个函数将子组件的一些数据和方法暴露出去
  135. defineExpose({
  136. onOpen
  137. })
  138. </script>