【修改】mysql出题前端
This commit is contained in:
@@ -232,7 +232,24 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="content" label="考点语句" />
|
<el-table-column prop="content" label="考点语句" />
|
||||||
|
<el-table-column label="操作" width="160">
|
||||||
|
<template #default="{ $index }">
|
||||||
|
<el-button
|
||||||
|
:icon="ArrowUp"
|
||||||
|
circle
|
||||||
|
size="small"
|
||||||
|
@click="moveUp($index)"
|
||||||
|
title="上移"
|
||||||
|
/>
|
||||||
|
<el-button
|
||||||
|
:icon="ArrowDown"
|
||||||
|
circle
|
||||||
|
size="small"
|
||||||
|
@click="moveDown($index)"
|
||||||
|
title="下移"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<!-- 展开行 -->
|
<!-- 展开行 -->
|
||||||
<el-table-column type="expand">
|
<el-table-column type="expand">
|
||||||
<template #default="props">
|
<template #default="props">
|
||||||
@@ -279,10 +296,13 @@
|
|||||||
设置此考点
|
设置此考点
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- 按钮放容器外 -->
|
||||||
|
<div style="margin-top: 12px; text-align: center;">
|
||||||
|
<el-button type="primary" @click="setKaodianRow">导入考点</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
|
<!--
|
||||||
<el-upload
|
<el-upload
|
||||||
ref="uploadRef"
|
ref="uploadRef"
|
||||||
class="upload"
|
class="upload"
|
||||||
@@ -294,7 +314,10 @@
|
|||||||
drag
|
drag
|
||||||
>
|
>
|
||||||
<el-button type="primary" style="margin-bottom: 16px;">上传文件</el-button>
|
<el-button type="primary" style="margin-bottom: 16px;">上传文件</el-button>
|
||||||
</el-upload>
|
</el-upload> -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<el-button @click="kaoDialogVisible = false">取消</el-button>
|
<el-button @click="kaoDialogVisible = false">取消</el-button>
|
||||||
<el-button type="primary" @click="confirmKao">确定</el-button>
|
<el-button type="primary" @click="confirmKao">确定</el-button>
|
||||||
</template>
|
</template>
|
||||||
@@ -403,6 +426,7 @@ import * as QuestionApi from '@/api/paper/question'
|
|||||||
import * as SpecialtyApi from '@/api/points'
|
import * as SpecialtyApi from '@/api/points'
|
||||||
import { defaultProps, handleTree } from '@/utils/tree'
|
import { defaultProps, handleTree } from '@/utils/tree'
|
||||||
import FileForm from './components/FileForm.vue';
|
import FileForm from './components/FileForm.vue';
|
||||||
|
import { ArrowUp, ArrowDown, Delete } from '@element-plus/icons-vue'
|
||||||
defineOptions({ name: 'ChoiceForm' })
|
defineOptions({ name: 'ChoiceForm' })
|
||||||
import type { TabPaneName } from 'element-plus'
|
import type { TabPaneName } from 'element-plus'
|
||||||
import { useUpload } from '@/components/UploadFile/src/useUpload'
|
import { useUpload } from '@/components/UploadFile/src/useUpload'
|
||||||
@@ -459,7 +483,8 @@ const kaodianData = ref({
|
|||||||
|
|
||||||
const formRules = reactive<FormRules>({
|
const formRules = reactive<FormRules>({
|
||||||
// specialtyName: [{ required: true, message: '用户名称不能为空', trigger: 'blur' }]
|
// specialtyName: [{ required: true, message: '用户名称不能为空', trigger: 'blur' }]
|
||||||
tname: [{ required: true, message: '数据库库名称不能为空', trigger: 'blur' }]
|
tname: [{ required: true, message: '数据库名称不能为空', trigger: 'blur' }]
|
||||||
|
|
||||||
})
|
})
|
||||||
const formRef = ref() // 表单 Ref
|
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 = {
|
const params = {
|
||||||
answerPath: url,
|
shucaiPath: fileUrl1,
|
||||||
shucaiPath: "" // 如果不传可以是空字符串,也可以删除这个字段(根据后端是否必填)
|
answerPath : fileUrl2 // 如果不传可以是空字符串,也可以删除这个字段(根据后端是否必填)
|
||||||
};
|
};
|
||||||
|
|
||||||
const res = await QuestionApi.getMysqlPoint(params);
|
const res = await QuestionApi.getMysqlPoint(params);
|
||||||
|
|
||||||
// 根据返回更新 kaodianList 或弹出提示等
|
// 根据返回更新 kaodianList 或弹出提示等
|
||||||
kaodianList.value = res || [];
|
kaodianList.value = res || [];
|
||||||
|
|
||||||
@@ -608,12 +634,8 @@ const fetchKaodianByUrl = async (url: string) => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ElMessage.success('考点导入成功');
|
|
||||||
} catch (err) {
|
|
||||||
ElMessage.error('考点导入失败');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const beforeUpload = (file: File) => {
|
const beforeUpload = (file: File) => {
|
||||||
const isTxt = file.type === 'text/plain';
|
const isTxt = file.type === 'text/plain';
|
||||||
const isLt5M = file.size / 1024 / 1024 < 5;
|
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')
|
const radio = ref('A')
|
||||||
|
|
||||||
// 关键字
|
// 关键字
|
||||||
|
@@ -232,7 +232,24 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="content" label="考点语句" />
|
<el-table-column prop="content" label="考点语句" />
|
||||||
|
<el-table-column label="操作" width="160">
|
||||||
|
<template #default="{ $index }">
|
||||||
|
<el-button
|
||||||
|
:icon="ArrowUp"
|
||||||
|
circle
|
||||||
|
size="small"
|
||||||
|
@click="moveUp($index)"
|
||||||
|
title="上移"
|
||||||
|
/>
|
||||||
|
<el-button
|
||||||
|
:icon="ArrowDown"
|
||||||
|
circle
|
||||||
|
size="small"
|
||||||
|
@click="moveDown($index)"
|
||||||
|
title="下移"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<!-- 展开行 -->
|
<!-- 展开行 -->
|
||||||
<el-table-column type="expand">
|
<el-table-column type="expand">
|
||||||
<template #default="props">
|
<template #default="props">
|
||||||
@@ -279,10 +296,13 @@
|
|||||||
设置此考点
|
设置此考点
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- 按钮放容器外 -->
|
||||||
|
<div style="margin-top: 12px; text-align: center;">
|
||||||
|
<el-button type="primary" @click="setKaodianRow">导入考点</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
|
<!--
|
||||||
<el-upload
|
<el-upload
|
||||||
ref="uploadRef"
|
ref="uploadRef"
|
||||||
class="upload"
|
class="upload"
|
||||||
@@ -294,7 +314,10 @@
|
|||||||
drag
|
drag
|
||||||
>
|
>
|
||||||
<el-button type="primary" style="margin-bottom: 16px;">上传文件</el-button>
|
<el-button type="primary" style="margin-bottom: 16px;">上传文件</el-button>
|
||||||
</el-upload>
|
</el-upload> -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<el-button @click="kaoDialogVisible = false">取消</el-button>
|
<el-button @click="kaoDialogVisible = false">取消</el-button>
|
||||||
<el-button type="primary" @click="confirmKao">确定</el-button>
|
<el-button type="primary" @click="confirmKao">确定</el-button>
|
||||||
</template>
|
</template>
|
||||||
@@ -403,6 +426,7 @@ import * as QuestionApi from '@/api/paper/question'
|
|||||||
import * as SpecialtyApi from '@/api/points'
|
import * as SpecialtyApi from '@/api/points'
|
||||||
import { defaultProps, handleTree } from '@/utils/tree'
|
import { defaultProps, handleTree } from '@/utils/tree'
|
||||||
import FileForm from './components/FileForm.vue';
|
import FileForm from './components/FileForm.vue';
|
||||||
|
import { ArrowUp, ArrowDown, Delete } from '@element-plus/icons-vue'
|
||||||
defineOptions({ name: 'ChoiceForm' })
|
defineOptions({ name: 'ChoiceForm' })
|
||||||
import type { TabPaneName } from 'element-plus'
|
import type { TabPaneName } from 'element-plus'
|
||||||
import { useUpload } from '@/components/UploadFile/src/useUpload'
|
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 = {
|
const params = {
|
||||||
answerPath: url,
|
shucaiPath: fileUrl1,
|
||||||
shucaiPath: "" // 如果不传可以是空字符串,也可以删除这个字段(根据后端是否必填)
|
answerPath : fileUrl2 // 如果不传可以是空字符串,也可以删除这个字段(根据后端是否必填)
|
||||||
};
|
};
|
||||||
|
|
||||||
const res = await QuestionApi.getMysqlPoint(params);
|
const res = await QuestionApi.getMysqlPoint(params);
|
||||||
|
|
||||||
// 根据返回更新 kaodianList 或弹出提示等
|
// 根据返回更新 kaodianList 或弹出提示等
|
||||||
kaodianList.value = res || [];
|
kaodianList.value = res || [];
|
||||||
|
|
||||||
@@ -609,12 +634,8 @@ const fetchKaodianByUrl = async (url: string) => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ElMessage.success('考点导入成功');
|
|
||||||
} catch (err) {
|
|
||||||
ElMessage.error('考点导入失败');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const beforeUpload = (file: File) => {
|
const beforeUpload = (file: File) => {
|
||||||
const isTxt = file.type === 'text/plain';
|
const isTxt = file.type === 'text/plain';
|
||||||
const isLt5M = file.size / 1024 / 1024 < 5;
|
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')
|
const radio = ref('A')
|
||||||
|
|
||||||
// 关键字
|
// 关键字
|
||||||
|
Reference in New Issue
Block a user