管理平台功能升级
This commit is contained in:
@@ -282,6 +282,11 @@
|
||||
operateLabel="删除用户单位"
|
||||
@requestOperate="requestOperate"
|
||||
/>
|
||||
<DownloadData
|
||||
ref="downloadDataRef"
|
||||
operateLabel="导出用户单位数据"
|
||||
@downloadData="executeDownloadData"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -291,6 +296,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 SortSearch from "../search/sortSearch.vue";
|
||||
@@ -310,6 +316,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 organizationMsgActive = organizationActiveStore();
|
||||
|
||||
@@ -342,6 +349,7 @@ const createdSortDateTimeRef = ref(null);
|
||||
const updatedSortDateTimeRef = ref(null);
|
||||
const PaginationRef = ref(null);
|
||||
const addOrganizationFormRef = ref(null);
|
||||
const downloadDataRef = ref(null);
|
||||
const editOrganizationFormRef = ref(null);
|
||||
const delPasswordOauthRef = ref(null);
|
||||
const dialogSearchVisible = ref(false);
|
||||
@@ -390,6 +398,9 @@ const showTools = (operateType) => {
|
||||
dialogOperationVisible.value = !dialogOperationVisible.value;
|
||||
organizationMsgActive.dialogOperationVisible = dialogOperationVisible.value;
|
||||
break;
|
||||
case "downloadData":
|
||||
downloadDataRef.value.downloadDataDialogVisible = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -574,6 +585,70 @@ 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 = [
|
||||
"单位uid",
|
||||
"单位名称",
|
||||
"通信地址",
|
||||
"联系人姓名",
|
||||
"联系人电话",
|
||||
"单位邮箱",
|
||||
"其他信息",
|
||||
"邮政编码",
|
||||
"添加时间",
|
||||
"上次信息变更时间"
|
||||
];
|
||||
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.downloadOrganization, 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({ organizationMsg });
|
||||
|
||||
watch(searchOptions, (value) => {
|
||||
|
||||
Reference in New Issue
Block a user