From d18f83e9a4dab959efad544ca9cd4b0cb0b0bc82 Mon Sep 17 00:00:00 2001
From: huababa1 <2037205722@qq.com>
Date: Tue, 15 Jul 2025 04:51:27 +0800
Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91mysql?=
=?UTF-8?q?=E5=87=BA=E9=A2=98=E5=89=8D=E7=AB=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/paper/audit/MysqlForm.vue | 97 +++++++++++++++++++-------
src/views/paper/question/MysqlForm.vue | 94 ++++++++++++++++++-------
2 files changed, 138 insertions(+), 53 deletions(-)
diff --git a/src/views/paper/audit/MysqlForm.vue b/src/views/paper/audit/MysqlForm.vue
index 5ee7b92..20bdc61 100644
--- a/src/views/paper/audit/MysqlForm.vue
+++ b/src/views/paper/audit/MysqlForm.vue
@@ -232,7 +232,24 @@
-
+
+
+
+
+
+
@@ -279,10 +296,13 @@
设置此考点
-
+
+
+ 导入考点
+
-
+
+
+
+
取消
确定
@@ -403,6 +426,7 @@ import * as QuestionApi from '@/api/paper/question'
import * as SpecialtyApi from '@/api/points'
import { defaultProps, handleTree } from '@/utils/tree'
import FileForm from './components/FileForm.vue';
+import { ArrowUp, ArrowDown, Delete } from '@element-plus/icons-vue'
defineOptions({ name: 'ChoiceForm' })
import type { TabPaneName } from 'element-plus'
import { useUpload } from '@/components/UploadFile/src/useUpload'
@@ -459,7 +483,8 @@ const kaodianData = ref({
const formRules = reactive({
// specialtyName: [{ required: true, message: '用户名称不能为空', trigger: 'blur' }]
- tname: [{ required: true, message: '数据库库名称不能为空', trigger: 'blur' }]
+ tname: [{ required: true, message: '数据库名称不能为空', trigger: 'blur' }]
+
})
const formRef = ref() // 表单 Ref
// 左侧试题描述
@@ -571,26 +596,27 @@ function confirmKao() {
}
-const handleUploadSuccessFile = (response: any) => {
- console.log('上传成功,返回:', response);
- const fileUrl = response.data; // 取决于你的后端返回结构
- if (fileUrl) {
- // 拿到URL后调用你要请求的方法
- fetchKaodianByUrl(fileUrl);
- } else {
- ElMessage.error('上传失败:没有返回文件地址');
- }
-};
-const fetchKaodianByUrl = async (url: string) => {
- try {
-
+
+const setKaodianRow =async () => {
+ const uploads = formData.value.fileUploads;
+console.log(uploads[0].url+"formData.value.fileUploads")
+ if (!uploads[0].url || !uploads[1].url) {
+ ElMessage.error('请先上传两个文件再导入考点');
+ return;
+ }
+
+ const fileUrl1 = uploads[0].url;
+ const fileUrl2 = uploads[1].url;
+
+ console.log('导入考点的文件地址为:', fileUrl1, fileUrl2);
const params = {
- answerPath: url,
- shucaiPath: "" // 如果不传可以是空字符串,也可以删除这个字段(根据后端是否必填)
+ shucaiPath: fileUrl1,
+ answerPath : fileUrl2 // 如果不传可以是空字符串,也可以删除这个字段(根据后端是否必填)
};
- const res = await QuestionApi.getMysqlPoint(params);
+ const res = await QuestionApi.getMysqlPoint(params);
+
// 根据返回更新 kaodianList 或弹出提示等
kaodianList.value = res || [];
@@ -608,12 +634,8 @@ const fetchKaodianByUrl = async (url: string) => {
-
- ElMessage.success('考点导入成功');
- } catch (err) {
- ElMessage.error('考点导入失败');
- }
};
+
const beforeUpload = (file: File) => {
const isTxt = file.type === 'text/plain';
const isLt5M = file.size / 1024 / 1024 < 5;
@@ -634,8 +656,29 @@ function removeKeyword(parentRow: any, keywordIndex: number) {
}
+ // 上移
+ function moveUp(index) {
+ if (index === 0) return;
+ const temp = this.kaodianList[index];
+ this.kaodianList.splice(index, 1);
+ this.kaodianList.splice(index - 1, 0, temp);
+ this.updateSort();
+ }
-
+ // 下移
+ function moveDown(index) {
+ if (index === this.kaodianList.length - 1) return;
+ const temp = this.kaodianList[index];
+ this.kaodianList.splice(index, 1);
+ this.kaodianList.splice(index + 1, 0, temp);
+ this.updateSort();
+ }
+ // 重新赋值 sort 字段(保持顺序)
+function updateSort() {
+ this.kaodianList.forEach((item, index) => {
+ item.sort = index + 1;
+ });
+ }
const radio = ref('A')
// 关键字
diff --git a/src/views/paper/question/MysqlForm.vue b/src/views/paper/question/MysqlForm.vue
index 8129a78..20bdc61 100644
--- a/src/views/paper/question/MysqlForm.vue
+++ b/src/views/paper/question/MysqlForm.vue
@@ -232,7 +232,24 @@
-
+
+
+
+
+
+
@@ -279,10 +296,13 @@
设置此考点
-
+
+
+ 导入考点
+
-
+
+
+
+
取消
确定
@@ -403,6 +426,7 @@ import * as QuestionApi from '@/api/paper/question'
import * as SpecialtyApi from '@/api/points'
import { defaultProps, handleTree } from '@/utils/tree'
import FileForm from './components/FileForm.vue';
+import { ArrowUp, ArrowDown, Delete } from '@element-plus/icons-vue'
defineOptions({ name: 'ChoiceForm' })
import type { TabPaneName } from 'element-plus'
import { useUpload } from '@/components/UploadFile/src/useUpload'
@@ -572,26 +596,27 @@ function confirmKao() {
}
-const handleUploadSuccessFile = (response: any) => {
- console.log('上传成功,返回:', response);
- const fileUrl = response.data; // 取决于你的后端返回结构
- if (fileUrl) {
- // 拿到URL后调用你要请求的方法
- fetchKaodianByUrl(fileUrl);
- } else {
- ElMessage.error('上传失败:没有返回文件地址');
- }
-};
-const fetchKaodianByUrl = async (url: string) => {
- try {
-
+
+const setKaodianRow =async () => {
+ const uploads = formData.value.fileUploads;
+console.log(uploads[0].url+"formData.value.fileUploads")
+ if (!uploads[0].url || !uploads[1].url) {
+ ElMessage.error('请先上传两个文件再导入考点');
+ return;
+ }
+
+ const fileUrl1 = uploads[0].url;
+ const fileUrl2 = uploads[1].url;
+
+ console.log('导入考点的文件地址为:', fileUrl1, fileUrl2);
const params = {
- answerPath: url,
- shucaiPath: "" // 如果不传可以是空字符串,也可以删除这个字段(根据后端是否必填)
+ shucaiPath: fileUrl1,
+ answerPath : fileUrl2 // 如果不传可以是空字符串,也可以删除这个字段(根据后端是否必填)
};
- const res = await QuestionApi.getMysqlPoint(params);
+ const res = await QuestionApi.getMysqlPoint(params);
+
// 根据返回更新 kaodianList 或弹出提示等
kaodianList.value = res || [];
@@ -609,12 +634,8 @@ const fetchKaodianByUrl = async (url: string) => {
-
- ElMessage.success('考点导入成功');
- } catch (err) {
- ElMessage.error('考点导入失败');
- }
};
+
const beforeUpload = (file: File) => {
const isTxt = file.type === 'text/plain';
const isLt5M = file.size / 1024 / 1024 < 5;
@@ -635,8 +656,29 @@ function removeKeyword(parentRow: any, keywordIndex: number) {
}
+ // 上移
+ function moveUp(index) {
+ if (index === 0) return;
+ const temp = this.kaodianList[index];
+ this.kaodianList.splice(index, 1);
+ this.kaodianList.splice(index - 1, 0, temp);
+ this.updateSort();
+ }
-
+ // 下移
+ function moveDown(index) {
+ if (index === this.kaodianList.length - 1) return;
+ const temp = this.kaodianList[index];
+ this.kaodianList.splice(index, 1);
+ this.kaodianList.splice(index + 1, 0, temp);
+ this.updateSort();
+ }
+ // 重新赋值 sort 字段(保持顺序)
+function updateSort() {
+ this.kaodianList.forEach((item, index) => {
+ item.sort = index + 1;
+ });
+ }
const radio = ref('A')
// 关键字