Sfoglia il codice sorgente

后台管理技术帖子添加

canghailong 7 mesi fa
parent
commit
4246c484fe
1 ha cambiato i file con 84 aggiunte e 9 eliminazioni
  1. 84 9
      src/views/forum/postinfo/form.vue

+ 84 - 9
src/views/forum/postinfo/form.vue

@@ -33,7 +33,7 @@
 			<a-form-item label="帖子内容:" name="postContent">
 				<xn-editor v-model="formData.postContent" placeholder="请输入内容" :height="400"></xn-editor>
 			</a-form-item>
-			<a-form-item label="是否置顶:" name="isTop">
+			<!-- <a-form-item label="是否置顶:" name="isTop">
 				<a-select
 					v-model:value="formData.isTop"
 					placeholder="请选择是否置顶"
@@ -42,7 +42,7 @@
 					:filter-option="filterOption"
 				></a-select>
 			</a-form-item>
-			<!-- <a-form-item label="浏览次数:" name="viewCount">
+			<a-form-item label="浏览次数:" name="viewCount">
 				<a-input v-model:value="formData.viewCount" placeholder="请输入浏览次数" allow-clear />
 			</a-form-item>
 			<a-form-item label="回复次数:" name="replyCount">
@@ -55,13 +55,30 @@
 			<a-form-item label="帖子类型:" name="postType">
 				<a-select
 					v-model:value="formData.postType"
-					show-search
 					placeholder="请选择类型"
 					style="width: 100%"
 					:options="invitationOptions"
-					:filter-option="filterOption"
+					@change="selectType"
+				></a-select>
+			</a-form-item>
+			<a-form-item label="纠错类型:" name="contentCorrectionParam.resourceType" v-if="formData.postType==2">
+				<a-select
+					v-model:value="formData.contentCorrectionParam.resourceType"
+					placeholder="请选择类型"
+					style="width: 100%"
+					:options="errorType"
+					@change="selectErrorType"
 				></a-select>
 			</a-form-item>
+			<a-form-item label="选择目标:" name="contentCorrectionParam.resourceId" v-if="formData.postType==2">
+				<a-select
+					v-model:value="formData.contentCorrectionParam.resourceId"
+					placeholder="请选择类型"
+					style="width: 100%"
+					:options="targetList"
+				></a-select>
+			</a-form-item>
+
 			<a-form-item label="定向用户:" name="appointUserArr">
 				<a-select
 					v-model:value="formData.appointUserArr"
@@ -87,17 +104,35 @@
 	import forumPostInfoApi from '@/api/forum/forumPostInfoApi'
 	import forumApi from '@/api/forum/forumApi'
 	import XnEditor from '@/components/Editor/index.vue'
+	import Bowser from 'bowser'
 	// 抽屉状态
 	const visible = ref(false)
 	const emit = defineEmits({ successful: null })
 	const formRef = ref()
 	// 表单数据
-	const formData = ref({})
+	const formData = ref({
+		contentCorrectionParam:{}
+	})
 	const submitLoading = ref(false)
 	//分类
 	const typeOptions = ref([])
 	//用户
 	const usertypeOptions = ref([])
+	//纠错
+	const errorType = ref([
+		{
+			label: '课程章节',
+			value: 0
+		},
+		{
+			label: '作业',
+			value: 1
+		},
+		{
+			label: '考试',
+			value: 2
+		}
+	])
 	//置顶
 	const topOptions = ref([
 		{
@@ -119,10 +154,10 @@
 			label: '技术支持',
 			value: 1
 		},
-		{
-			label: '内容纠错',
-			value: 2
-		}
+		// {
+		// 	label: '内容纠错',
+		// 	value: 2
+		// }
 	])
 	// 打开抽屉
 	const onOpen = (record) => {
@@ -169,6 +204,9 @@
 	const onSubmit = () => {
 		formRef.value.validate().then(() => {
 			submitLoading.value = true
+			if (formData.value.postType == 1) {
+				formData.value = Object.assign(formData.value, browserObj.value)
+			}
 			const formDataParam = cloneDeep(formData.value)
 			forumPostInfoApi
 				.forumPostInfoSubmitForm(formDataParam, formDataParam.postId)
@@ -184,6 +222,43 @@
 				})
 		})
 	}
+	//选择类型
+	const selectType = (event) => {
+		if (event == 0) {
+			browserObj.value = {}
+			errorVal.value = {}
+		}
+		if (event == 1) {
+			getBower()
+		}
+	}
+	const targetList = ref([])
+	const selectErrorType = (event) => {
+		if (event == 0) {
+			
+		}
+		if (event == 1) {
+			
+		}
+		if (event == 2) {
+			
+		}
+	}
+	//获取操作系统/浏览器等信息
+	const browserObj = ref({})
+	function getBower() {
+		const browser = Bowser.getParser(window.navigator.userAgent)
+		let obj = browser.parsedResult
+		browserObj.value = {
+			forumSupportEnvParam: {
+				browserType: obj.browser.name,
+				browserVersion: obj.browser.version,
+				osType: obj.os.name,
+				osVersion: obj.os.version,
+				deviceType: 0
+			}
+		}
+	}
 	// 抛出函数
 	defineExpose({
 		onOpen