Selaa lähdekoodia

论坛相关修改

canghailong 6 kuukautta sitten
vanhempi
sitoutus
04e5496d4f

+ 22 - 22
src/views/forum/addForum.vue

@@ -184,33 +184,33 @@
 	// 验证并提交数据
 	const onSubmit = () => {
 		submitLoading.value = true
-		formRef.value
-			.validate()
-			.then(() => {
-				if (formData.value.appointUserArr && formData.value.appointUserArr.length > 1) {
-					formData.value.appointUser = formData.value.appointUserArr.join(',')
-				}
-				let params = formData.value
-				if (route.query.postType == 1) {
-					params = {
-						...formData.value,
-						...browserObj.value
-					}
+		formRef.value.validate().then(() => {
+			if (formData.value.appointUserArr && formData.value.appointUserArr.length > 1) {
+				formData.value.appointUser = formData.value.appointUserArr.join(',')
+			}
+			let params = formData.value
+			if (route.query.postType == 1) {
+				params = {
+					...formData.value,
+					...browserObj.value
 				}
-				if (route.query.postType == 2) {
-					params = {
-						...formData.value,
-						...errorVal.value
-					}
+			}
+			if (route.query.postType == 2) {
+				params = {
+					...formData.value,
+					...errorVal.value
 				}
-				forumApi.submitForm(params).then(() => {
+			}
+			forumApi
+				.submitForm(params)
+				.then(() => {
 					onClose()
 					emit('successful')
 				})
-			})
-			.finally(() => {
-				submitLoading.value = false
-			})
+				.finally(() => {
+					submitLoading.value = false
+				})
+		})
 	}
 	const editContent = () => {
 		let videoUrl = route.query?.videoUrl ? decodeURIComponent(atob(route.query.videoUrl)) : ''

+ 20 - 13
src/views/forum/form.vue

@@ -14,7 +14,14 @@
 			<a-row :gutter="16">
 				<a-col :span="8">
 					<a-form-item label="标题:" name="postTitle">
-						<a-input v-model:value="formData.postTitle" placeholder="请输入标题" max allow-clear show-count :maxlength="100" />
+						<a-input
+							v-model:value="formData.postTitle"
+							placeholder="请输入标题"
+							max
+							allow-clear
+							show-count
+							:maxlength="100"
+						/>
 					</a-form-item>
 				</a-col>
 				<a-col :span="8">
@@ -92,7 +99,7 @@
 			userTotal.value = res.total
 			let userList = res.records.map((r) => {
 				return {
-					label: `${r.name}-${r.eduIdentityName??''}`,
+					label: `${r.name}-${r.eduIdentityName ?? ''}`,
 					value: r.id,
 					...r
 				}
@@ -148,20 +155,20 @@
 	// 验证并提交数据
 	const onSubmit = () => {
 		submitLoading.value = true
-		formRef.value
-			.validate()
-			.then(() => {
-				if (formData.value.appointUserArr && formData.value.appointUserArr.length > 1) {
-					formData.value.appointUser = formData.value.appointUserArr.join(',')
-				}
-				forumApi.submitForm(formData.value, formData.value.postId).then(() => {
+		formRef.value.validate().then(() => {
+			if (formData.value.appointUserArr && formData.value.appointUserArr.length > 1) {
+				formData.value.appointUser = formData.value.appointUserArr.join(',')
+			}
+			forumApi
+				.submitForm(formData.value, formData.value.postId)
+				.then(() => {
 					onClose()
 					emit('successful')
 				})
-			})
-			.finally(() => {
-				submitLoading.value = false
-			})
+				.finally(() => {
+					submitLoading.value = false
+				})
+		})
 	}
 
 	// 调用这个函数将子组件的一些数据和方法暴露出去

+ 34 - 21
src/views/forum/index.vue

@@ -61,7 +61,8 @@
 				:row-key="(record) => record.id"
 				:custom-row="customRow"
 				:pagination="false"
-				style="width: 100%;"
+				style="width: 100%"
+				:loading="tableLoading"
 			>
 				<template #bodyCell="{ column, record }">
 					<template v-if="column.dataIndex === 'postTitle'">
@@ -95,6 +96,7 @@
 	const route = useRoute()
 	const router = useRouter()
 	const formRef = ref()
+	const tableLoading = ref(false)
 	let searchFormState = reactive({
 		sortOrder: 0,
 		postTitle: '',
@@ -252,33 +254,44 @@
 		loadData(pagination.value)
 	}
 	const loadData = (parameter, a) => {
+		tableLoading.value = true
 		if (exType.value == 2) {
 			let postExtend = moduleTypeList.value.find((r) => r.id == searchFormState.sortOrder).state
-			return forumApi.moreList(Object.assign(parameter, searchFormState, { postExtend: postExtend })).then((data) => {
-				tableTotal.value = data.total
-				if (a) {
-					tableData.value = Object.assign(tableData.value, data.records)
-				} else {
-					if (data) {
-						tableData.value = data.records
+			return forumApi
+				.moreList(Object.assign(parameter, searchFormState, { postExtend: postExtend }))
+				.then((data) => {
+					tableTotal.value = data.total
+					if (a) {
+						tableData.value = Object.assign(tableData.value, data.records)
 					} else {
-						tableData.value = []
+						if (data) {
+							tableData.value = data.records
+						} else {
+							tableData.value = []
+						}
 					}
-				}
-			})
+				})
+				.finally(() => {
+					tableLoading.value = false
+				})
 		} else {
-			return forumApi.forumList(Object.assign(parameter, searchFormState)).then((data) => {
-				tableTotal.value = data.total
-				if (a) {
-					tableData.value = tableData.value.concat(data.records)
-				} else {
-					if (data) {
-						tableData.value = data.records
+			return forumApi
+				.forumList(Object.assign(parameter, searchFormState))
+				.then((data) => {
+					tableTotal.value = data.total
+					if (a) {
+						tableData.value = tableData.value.concat(data.records)
 					} else {
-						tableData.value = []
+						if (data) {
+							tableData.value = data.records
+						} else {
+							tableData.value = []
+						}
 					}
-				}
-			})
+				})
+				.finally(() => {
+					tableLoading.value = false
+				})
 		}
 	}
 

+ 20 - 20
src/views/forum/replyForm.vue

@@ -82,31 +82,31 @@
 	// 验证并提交数据
 	const onSubmit = () => {
 		submitLoading.value = true
-		formRef.value
-			.validate()
-			.then(() => {
-				let params = {}
-				if (formData.value.formType) {
-					params = {
-						...formData.value,
-						replyId: replyid.value
-					}
-				} else {
-					params = {
-						...formData.value,
-						postId: moduleId.value,
-						parentId: replyid.value
-					}
+		formRef.value.validate().then(() => {
+			let params = {}
+			if (formData.value.formType) {
+				params = {
+					...formData.value,
+					replyId: replyid.value
 				}
+			} else {
+				params = {
+					...formData.value,
+					postId: moduleId.value,
+					parentId: replyid.value
+				}
+			}
 
-				forumApi.submitPostreply(params, formData.value.formType).then(() => {
+			forumApi
+				.submitPostreply(params, formData.value.formType)
+				.then(() => {
 					onClose()
 					emit('successful')
 				})
-			})
-			.finally(() => {
-				submitLoading.value = false
-			})
+				.finally(() => {
+					submitLoading.value = false
+				})
+		})
 	}
 	// 调用这个函数将子组件的一些数据和方法暴露出去
 	defineExpose({

+ 21 - 17
src/views/forum/reportForm.vue

@@ -29,7 +29,13 @@
 				</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-textarea
+							v-model:value="formData.reportDetail"
+							placeholder="请输入举报原因"
+							:rows="4"
+							show-count
+							:maxlength="500"
+						/>
 					</a-form-item>
 				</a-col>
 			</a-row>
@@ -115,22 +121,20 @@
 	// 验证并提交数据
 	const onSubmit = () => {
 		submitLoading.value = true
-		formRef.value
-			.validate()
-			.then(() => {
-				forumApi
-					.reportinfoAdd({
-						...formData.value,
-						postId: moduleId.value
-					})
-					.then(() => {
-						onClose()
-						emit('successful')
-					})
-			})
-			.finally(() => {
-				submitLoading.value = false
-			})
+		formRef.value.validate().then(() => {
+			forumApi
+				.reportinfoAdd({
+					...formData.value,
+					postId: moduleId.value
+				})
+				.then(() => {
+					onClose()
+					emit('successful')
+				})
+				.finally(() => {
+					submitLoading.value = false
+				})
+		})
 	}
 	// 调用这个函数将子组件的一些数据和方法暴露出去
 	defineExpose({