管理平台功能升级
This commit is contained in:
@@ -200,6 +200,11 @@
|
||||
operateLabel="删除单选题"
|
||||
@requestOperate="requestOperate"
|
||||
/>
|
||||
<DownloadData
|
||||
ref="downloadDataRef"
|
||||
operateLabel="导出题目数据"
|
||||
@downloadData="executeDownloadData"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -209,6 +214,7 @@ import { ElMessage } from "element-plus";
|
||||
|
||||
import TabelTools from "../../operate/tabelTools.vue";
|
||||
import AddNewData from "../../operate/addNewData.vue";
|
||||
import DownloadData from "../../operate/downloadData.vue";
|
||||
import TabelSelect from "../../operate/tabelSelect.vue";
|
||||
import SearchKey from "../../search/searchKey.vue";
|
||||
import Pagination from "../../search/pagination.vue";
|
||||
@@ -226,6 +232,7 @@ import $url from "../../../api/url";
|
||||
import { encrypt } from "../../../utils/aes";
|
||||
import { judgment } from "../../../utils/judgment.js";
|
||||
import { hasNullOrEmptyPropertyWithTypeof } from "../../../utils/hasNullOrEmptyPropertyWithTypeof.js";
|
||||
import { downloadData } from "../../../utils/downloadData.js";
|
||||
|
||||
const choiceTopicMsgActive = choiceTopicActiveStore();
|
||||
|
||||
@@ -252,6 +259,7 @@ const SearchOptionsDKeyRef = ref(null);
|
||||
const SearchAnswerKeyRef = ref(null);
|
||||
const PaginationRef = ref(null);
|
||||
const addChoiceTopicFormRef = ref(null);
|
||||
const downloadDataRef = ref(null);
|
||||
const editChoiceTopicFormRef = ref(null);
|
||||
const delPasswordOauthRef = ref(null);
|
||||
const dialogSearchVisible = ref(false);
|
||||
@@ -314,6 +322,9 @@ const showTools = (operateType) => {
|
||||
dialogOperationVisible.value = !dialogOperationVisible.value;
|
||||
choiceTopicMsgActive.dialogOperationVisible = dialogOperationVisible.value;
|
||||
break;
|
||||
case "downloadData":
|
||||
downloadDataRef.value.downloadDataDialogVisible = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -481,6 +492,66 @@ const requestOperate = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const executeDownloadData = (form) => {
|
||||
// 根据数据量大小来决定在前端还是后端导出数据
|
||||
if (
|
||||
tableData.value == [] ||
|
||||
tableData.value == undefined ||
|
||||
PaginationRef.value.dataCount == 0 ||
|
||||
PaginationRef.value.dataCount == null
|
||||
) {
|
||||
ElMessage.error("暂无数据!");
|
||||
return;
|
||||
}
|
||||
let dataClone = JSON.parse(JSON.stringify(tableData.value));
|
||||
dataClone.forEach((item) => {
|
||||
delete item.origin_time;
|
||||
});
|
||||
const dataHeaders = [
|
||||
"题目",
|
||||
"选项A",
|
||||
"选项B",
|
||||
"选项C",
|
||||
"选项D",
|
||||
"答案"
|
||||
];
|
||||
downloadData(form, dataClone, dataHeaders);
|
||||
if (PaginationRef.value.dataCount <= PaginationRef.value.limit) {
|
||||
downloadData(form, dataClone, dataHeaders);
|
||||
} else {
|
||||
const data = {
|
||||
form,
|
||||
searchMsg: {
|
||||
searchOptions: searchOptions,
|
||||
sortOptions: sortOptions,
|
||||
},
|
||||
dataHeaders,
|
||||
};
|
||||
$http.post($url.downloadChoiceTopic, data).then((res) => {
|
||||
if (res.data.code === 200) {
|
||||
ElMessage({
|
||||
message: "数据导出成功!",
|
||||
type: "success",
|
||||
});
|
||||
// 创建一个隐藏的<a>标签
|
||||
const link = document.createElement("a");
|
||||
link.style.display = "none";
|
||||
link.href = res.data.fileUrl;
|
||||
// 设置下载的文件名
|
||||
link.download = res.data.fileName;
|
||||
// 触发点击事件来下载文件
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
// 清理
|
||||
document.body.removeChild(link);
|
||||
URL.revokeObjectURL(link.href);
|
||||
} else {
|
||||
ElMessage.error("数据导出失败!");
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
defineExpose({ choiceTopicMsg });
|
||||
|
||||
watch(searchOptions, (value) => {
|
||||
|
||||
Reference in New Issue
Block a user