|
@@ -0,0 +1,175 @@
|
|
|
|
|
+<template>
|
|
|
|
|
+ <header>
|
|
|
|
|
+ <Navbar title="数据归档" :is-go-back="false" />
|
|
|
|
|
+ <label>业务名称:</label>
|
|
|
|
|
+ <a-select
|
|
|
|
|
+ v-model:value="value1"
|
|
|
|
|
+ style="width: 200px"
|
|
|
|
|
+ :options="businessNames"
|
|
|
|
|
+ @change="nameChange"
|
|
|
|
|
+ />
|
|
|
|
|
+ <a-divider />
|
|
|
|
|
+ </header>
|
|
|
|
|
+ <div class="content">
|
|
|
|
|
+ <label>开始时间:</label>
|
|
|
|
|
+ <a-date-picker
|
|
|
|
|
+ show-time
|
|
|
|
|
+ :locale="locale"
|
|
|
|
|
+ style="width: 200px"
|
|
|
|
|
+ placeholder="归档开始日期"
|
|
|
|
|
+ @change="startDateChange"
|
|
|
|
|
+ />
|
|
|
|
|
+ <label class="params">结束时间:</label>
|
|
|
|
|
+ <a-date-picker
|
|
|
|
|
+ show-time
|
|
|
|
|
+ :locale="locale"
|
|
|
|
|
+ style="width: 200px"
|
|
|
|
|
+ placeholder="归档结束日期"
|
|
|
|
|
+ @change="endDateChange"
|
|
|
|
|
+ />
|
|
|
|
|
+ <label class="params">文件行数:</label>
|
|
|
|
|
+ <a-input-number v-model:value="linCount" :min="0" style="width: 200px" />
|
|
|
|
|
+ <a-divider />
|
|
|
|
|
+ <a-button type="primary" @click="startArchive">执行归档</a-button>
|
|
|
|
|
+ <a-result
|
|
|
|
|
+ v-if="isShow"
|
|
|
|
|
+ status="success"
|
|
|
|
|
+ :title="`${businessName}业务归档成功`"
|
|
|
|
|
+ >
|
|
|
|
|
+ <template #subTitle>
|
|
|
|
|
+ <div>共创建了{{ createCount }}个可视数据</div>
|
|
|
|
|
+ <div v-for="(item, index) in tableMessages" :key="index">
|
|
|
|
|
+ <div>
|
|
|
|
|
+ {{ index + 1 }}、{{ item.tableName }}表成功归档{{
|
|
|
|
|
+ item.successExporterData
|
|
|
|
|
+ }}条,删除{{ item.deleteSuccess }}条
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <template #extra>
|
|
|
|
|
+ <a-button type="primary" @click="isShow = false">关闭</a-button>
|
|
|
|
|
+ <a-button @click="checkData">查看归档数据</a-button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </a-result>
|
|
|
|
|
+ </div>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<script setup>
|
|
|
|
|
+import dayjs from 'dayjs';
|
|
|
|
|
+import 'dayjs/locale/zh-cn';
|
|
|
|
|
+import { ref, onMounted } from 'vue';
|
|
|
|
|
+import Common from '../common/Common';
|
|
|
|
|
+import { message } from 'ant-design-vue';
|
|
|
|
|
+import { getBusinessName, execute } from './config';
|
|
|
|
|
+import locale from 'ant-design-vue/es/date-picker/locale/zh_CN';
|
|
|
|
|
+
|
|
|
|
|
+dayjs.locale('zh-cn');
|
|
|
|
|
+const businessName = ref(''); //业务名
|
|
|
|
|
+const startDate = ref(''); // 开始时间
|
|
|
|
|
+const endDate = ref(''); // 结束时间
|
|
|
|
|
+const linCount = ref(null); // 文件行数
|
|
|
|
|
+const filePath = ref(''); //下载路径
|
|
|
|
|
+const isShow = ref(false);
|
|
|
|
|
+const tableMessages = ref([]); //表
|
|
|
|
|
+const createCount = ref(''); //创建的可视数据个数
|
|
|
|
|
+const businessNames = ref([]); // 业务名数据
|
|
|
|
|
+onMounted(() => {
|
|
|
|
|
+ getName();
|
|
|
|
|
+});
|
|
|
|
|
+// 获取业务名
|
|
|
|
|
+const nameChange = (_, { name }) => {
|
|
|
|
|
+ businessName.value = name;
|
|
|
|
|
+};
|
|
|
|
|
+// 获取开始时间
|
|
|
|
|
+const startDateChange = (_, dateString) => {
|
|
|
|
|
+ startDate.value = dateString;
|
|
|
|
|
+};
|
|
|
|
|
+// 获取结束时间
|
|
|
|
|
+const endDateChange = (_, dateString) => {
|
|
|
|
|
+ endDate.value = dateString;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+// 获取业务名
|
|
|
|
|
+const getName = () => {
|
|
|
|
|
+ getBusinessName().then(
|
|
|
|
|
+ success => {
|
|
|
|
|
+ if (success.errorCode == 0) {
|
|
|
|
|
+ if (success.data) {
|
|
|
|
|
+ success.data.forEach(item => {
|
|
|
|
|
+ item.value = item.id;
|
|
|
|
|
+ item.label = item.name;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ businessNames.value = success.data;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ message.error(success.errorMessage);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ error => {
|
|
|
|
|
+ Common.processException(error);
|
|
|
|
|
+ },
|
|
|
|
|
+ );
|
|
|
|
|
+};
|
|
|
|
|
+// 开始执行
|
|
|
|
|
+const startArchive = () => {
|
|
|
|
|
+ const params = {
|
|
|
|
|
+ businessName: businessName.value,
|
|
|
|
|
+ startTime: startDate.value,
|
|
|
|
|
+ endTime: endDate.value,
|
|
|
|
|
+ maxLines: linCount.value,
|
|
|
|
|
+ };
|
|
|
|
|
+ execute(params).then(
|
|
|
|
|
+ success => {
|
|
|
|
|
+ if (success.errorCode == 0) {
|
|
|
|
|
+ if (success.data) {
|
|
|
|
|
+ isShow.value = true;
|
|
|
|
|
+ filePath.value = success.data.filePath;
|
|
|
|
|
+ tableMessages.value = success.data.tableMessage;
|
|
|
|
|
+ createCount.value = success.data.fileNames.length;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ message.error(success.errorMessage);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ error => {
|
|
|
|
|
+ Common.processException(error);
|
|
|
|
|
+ },
|
|
|
|
|
+ );
|
|
|
|
|
+};
|
|
|
|
|
+// 查看归档数据
|
|
|
|
|
+const checkData = () => {
|
|
|
|
|
+ const fileUrl = encodeURIComponent(filePath.value);
|
|
|
|
|
+ const xhr = new XMLHttpRequest();
|
|
|
|
|
+ xhr.open('get', `api/IArchiveResource/download?xlsxPath=${fileUrl}`, true);
|
|
|
|
|
+ const token = localStorage.getItem('#token');
|
|
|
|
|
+ xhr.setRequestHeader('token', token);
|
|
|
|
|
+ xhr.setRequestHeader('Content-type', 'application/json');
|
|
|
|
|
+ xhr.responseType = 'blob';
|
|
|
|
|
+ xhr.onreadystatechange = function () {
|
|
|
|
|
+ if (xhr.readyState === 4 && xhr.status === 200) {
|
|
|
|
|
+ let res = xhr.response;
|
|
|
|
|
+ let blob = new Blob([res]);
|
|
|
|
|
+ const blobUrl = URL.createObjectURL(blob);
|
|
|
|
|
+ const link = document.createElement('a');
|
|
|
|
|
+ link.download = '可视数据.zip';
|
|
|
|
|
+ link.style.display = 'none';
|
|
|
|
|
+ link.href = blobUrl;
|
|
|
|
|
+ document.body.appendChild(link);
|
|
|
|
|
+ link.click();
|
|
|
|
|
+ URL.revokeObjectURL(blobUrl);
|
|
|
|
|
+ document.body.removeChild(link);
|
|
|
|
|
+ message.success('下载成功');
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ xhr.send();
|
|
|
|
|
+};
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
|
|
+<style scoped>
|
|
|
|
|
+:deep(.ant-divider) {
|
|
|
|
|
+ margin: 8px 0;
|
|
|
|
|
+}
|
|
|
|
|
+.params {
|
|
|
|
|
+ margin-left: 8px;
|
|
|
|
|
+}
|
|
|
|
|
+</style>
|