form.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <xn-form-container
  3. :title="formData.reportId ? '编辑论坛-帖子举报信息表' : '增加论坛-帖子举报信息表'"
  4. :width="700"
  5. :visible="visible"
  6. :destroy-on-close="true"
  7. @close="onClose"
  8. >
  9. <a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
  10. <a-form-item label="帖子:" name="postId">
  11. <a-select
  12. v-model:value="formData.postId"
  13. show-search
  14. placeholder="请选择帖子"
  15. style="width: 100%"
  16. :options="invitationList"
  17. :filter-option="filterOption"
  18. ></a-select>
  19. </a-form-item>
  20. <!-- <a-form-item label="帖子类型:" name="postType">
  21. <a-select
  22. v-model:value="formData.postType"
  23. show-search
  24. placeholder="请选择帖子类型"
  25. style="width: 100%"
  26. :options="invitationType"
  27. :filter-option="filterOption"
  28. ></a-select>
  29. </a-form-item>
  30. <a-form-item label="帖子状态:" name="postStatus">
  31. <a-select
  32. v-model:value="formData.postStatus"
  33. show-search
  34. placeholder="请选择帖子状态"
  35. style="width: 100%"
  36. :options="invitationStatus"
  37. :filter-option="filterOption"
  38. ></a-select>
  39. </a-form-item> -->
  40. <a-form-item label="举报人:" name="userId">
  41. <a-select
  42. v-model:value="formData.userId"
  43. show-search
  44. placeholder="请选择用户"
  45. style="width: 100%"
  46. :options="usertypeOptions"
  47. :filter-option="filterOption"
  48. ></a-select>
  49. </a-form-item>
  50. <a-form-item label="举报原因类型:" name="reportReasonType">
  51. <a-select
  52. v-model:value="formData.reportReasonType"
  53. show-search
  54. placeholder="请选择类型"
  55. style="width: 100%"
  56. :options="reportType"
  57. :filter-option="filterOption"
  58. ></a-select>
  59. </a-form-item>
  60. <a-form-item label="举报信息描述:" name="reportDetail">
  61. <a-input v-model:value="formData.reportDetail" placeholder="请输入举报信息描述" allow-clear />
  62. </a-form-item>
  63. <a-form-item label="证据图片:" name="evidenceScreenshot">
  64. <UpLoadImg ref="upLoadImgRef" @handlerUpImage="handlerUpImage"></UpLoadImg>
  65. </a-form-item>
  66. <a-form-item label="举报处理状态:" name="reportStatus">
  67. <a-select
  68. v-model:value="formData.reportStatus"
  69. show-search
  70. placeholder="请选择分类"
  71. style="width: 100%"
  72. :options="statusType"
  73. :filter-option="filterOption"
  74. ></a-select>
  75. </a-form-item>
  76. </a-form>
  77. <template #footer>
  78. <a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
  79. <a-button type="primary" @click="onSubmit" :loading="submitLoading">保存</a-button>
  80. </template>
  81. </xn-form-container>
  82. </template>
  83. <script setup name="forumReportInfoForm">
  84. import { cloneDeep } from 'lodash-es'
  85. import { required } from '@/utils/formRules'
  86. import forumReportInfoApi from '@/api/forum/forumReportInfoApi'
  87. import forumApi from '@/api/forum/forumApi'
  88. // 抽屉状态
  89. const visible = ref(false)
  90. const emit = defineEmits({ successful: null })
  91. const formRef = ref()
  92. // 表单数据
  93. const formData = ref({})
  94. const submitLoading = ref(false)
  95. //用户
  96. const usertypeOptions = ref([])
  97. //帖子
  98. const invitationList = ref([])
  99. //举报原因
  100. const reportType = ref([
  101. {
  102. label: '垃圾广告',
  103. value: 0
  104. },
  105. {
  106. label: '色情内容',
  107. value: 1
  108. },
  109. {
  110. label: '人身攻击',
  111. value: 2
  112. },
  113. {
  114. label: '政治敏感',
  115. value: 3
  116. },
  117. {
  118. label: '其他',
  119. value: 4
  120. }
  121. ])
  122. //状态
  123. const statusType = ref([
  124. {
  125. label: '待处理',
  126. value: 0
  127. },
  128. {
  129. label: '已关闭帖子',
  130. value: 1
  131. },
  132. {
  133. label: '已驳回',
  134. value: 2
  135. }
  136. ])
  137. //帖子类型
  138. const invitationType = ref([
  139. {
  140. label:'普通帖子',
  141. value:0
  142. },
  143. {
  144. label:'技术支持',
  145. value:1
  146. },
  147. {
  148. label:'内容纠错',
  149. value:2
  150. },
  151. ])
  152. //帖子状态
  153. const invitationStatus = ref([
  154. {
  155. label:'正常',
  156. value:0
  157. },
  158. {
  159. label:'关闭',
  160. value:1
  161. }
  162. ])
  163. //筛选
  164. const filterOption = (input, option) => {
  165. return option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
  166. }
  167. // 打开抽屉
  168. const onOpen = (record) => {
  169. visible.value = true
  170. forumApi.allUserList().then((data) => {
  171. usertypeOptions.value = data.map((r) => {
  172. return {
  173. label: r.name,
  174. value: r.id,
  175. ...r
  176. }
  177. })
  178. })
  179. forumApi
  180. .forumList({
  181. current: 1,
  182. size: 999999999,
  183. sortOrder: 0
  184. })
  185. .then((data) => {
  186. invitationList.value = data.records.map((r) => {
  187. return {
  188. label: r.postTitle,
  189. value: r.postId,
  190. ...r
  191. }
  192. })
  193. })
  194. if (record) {
  195. let recordData = cloneDeep(record)
  196. formData.value = Object.assign({}, recordData)
  197. }
  198. }
  199. // 关闭抽屉
  200. const onClose = () => {
  201. formRef.value.resetFields()
  202. formData.value = {}
  203. visible.value = false
  204. }
  205. // 默认要校验的
  206. const formRules = {}
  207. // 验证并提交数据
  208. const onSubmit = () => {
  209. formRef.value.validate().then(() => {
  210. submitLoading.value = true
  211. const formDataParam = cloneDeep(formData.value)
  212. forumReportInfoApi
  213. .forumReportInfoSubmitForm(formDataParam, formDataParam.reportId)
  214. .then(() => {
  215. onClose()
  216. emit('successful')
  217. })
  218. .finally(() => {
  219. submitLoading.value = false
  220. })
  221. })
  222. }
  223. //选择图片
  224. const handlerUpImage = (id) => {
  225. formData.value.evidenceScreenshot = id
  226. }
  227. // 抛出函数
  228. defineExpose({
  229. onOpen
  230. })
  231. </script>