Browse Source

3.0.70 优化数据归档

liuyanpeng 2 years ago
parent
commit
cf1fee65b9
3 changed files with 154 additions and 59 deletions
  1. 1 1
      package.json
  2. 131 56
      src/archive/DataArchive.vue
  3. 22 2
      src/archive/config.js

+ 1 - 1
package.json

@@ -1,7 +1,7 @@
 {
   "name": "client-base-v4",
   "description": "Leanwo Prodog Client",
-  "version": "3.0.68",
+  "version": "3.0.70",
   "author": "yangzhijie1488 <yangzhijie1488@163.com>",
   "scripts": {
     "dev": "cross-env webpack serve --config ./webpack.dev.js",

+ 131 - 56
src/archive/DataArchive.vue

@@ -3,32 +3,52 @@
     <Navbar title="数据归档" :is-go-back="false" />
     <label>业务名称:</label>
     <a-select
-      v-model:value="value1"
+      v-model:value="selectValue"
       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" />
+  <div v-if="selectValue">
+    <div class="queryParams">
+      <ul class="ulStyle">
+        <li v-for="(item, index) in allParams" :key="index" class="liStyle">
+          <label> {{ item.viewName }}:</label>
+          <span v-if="item.displayType == 'DateTimeBoxEditor'">
+            <a-date-picker
+              v-model:value="item.dateValue"
+              show-time
+              :locale="locale"
+              class="commonWidth"
+              @change="
+                (_, dateString) => dateChange(_, dateString, item.paramName)
+              "
+            />
+          </span>
+          <span v-if="item.displayType == 'TextEditor'">
+            <a-input
+              v-model:value="item.defaultValue"
+              class="commonWidth"
+              @change="(e) => textChange(e, item.paramName)"
+            />
+          </span>
+          <span v-if="item.displayType == 'NumberEditor'">
+            <a-input-number
+              v-model:value="item.defaultValue"
+              class="commonWidth"
+              @change="(value) => numberChange(value, item.paramName)"
+            />
+          </span>
+          <span v-if="item.displayType == 'CheckBoxEditor'">
+            <a-checkbox
+              v-model:checked="item.defaultValue"
+              @change="(e) => checkChange(e, item.paramName)"
+            />
+          </span>
+        </li>
+      </ul>
+    </div>
     <a-divider />
     <a-button type="primary" @click="startArchive">执行归档</a-button>
     <a-result
@@ -38,11 +58,11 @@
     >
       <template #subTitle>
         <div>共创建了{{ createCount }}个可视数据</div>
-        <div v-for="(item, index) in tableMessages" :key="index">
-          <div>
+        <div style="text-align: left;margin-left: 36%;">
+          <div v-for="(item, index) in tableMessages" :key="index">
             {{ index + 1 }}、{{ item.tableName }}表成功归档{{
-              item.successExporterData
-            }}条,删除{{ item.deleteSuccess }}条
+              item.successExporterCount
+            }}条,删除{{ item.deleteSuccessCount }}条
           </div>
         </div>
       </template>
@@ -51,102 +71,147 @@
         <a-button @click="checkData">查看归档数据</a-button>
       </template>
     </a-result>
+    <Loading v-if="loading" />
   </div>
 </template>
 
 <script setup>
 import dayjs from 'dayjs';
 import 'dayjs/locale/zh-cn';
-import { ref, onMounted } from 'vue';
+import { ref, reactive, onMounted } from 'vue';
 import Common from '../common/Common';
 import { message } from 'ant-design-vue';
-import { getBusinessName, execute } from './config';
+import { getBusinessName, getBusinessParams, execute } from './config';
 import locale from 'ant-design-vue/es/date-picker/locale/zh_CN';
 
 dayjs.locale('zh-cn');
+const selectValue = ref('');
 const businessName = ref(''); //业务名
-const startDate = ref(''); // 开始时间
-const endDate = ref(''); // 结束时间
-const linCount = ref(null); // 文件行数
-const filePath = ref(''); //下载路径
+const archiveLogId = ref(''); //下载路径
 const isShow = ref(false);
 const tableMessages = ref([]); //表
 const createCount = ref(''); //创建的可视数据个数
 const businessNames = ref([]); // 业务名数据
+const allParams = ref([]);
+const archiveParams = reactive({});
+const loading = ref(false);
 onMounted(() => {
   getName();
 });
-// 获取业务名
-const nameChange = (_, { name }) => {
-  businessName.value = name;
+
+// 获取时间类型值
+const dateChange = (_, dateString, paramName) => {
+  archiveParams[paramName] = dateString;
 };
-// 获取开始时间
-const startDateChange = (_, dateString) => {
-  startDate.value = dateString;
+// 获取文本框类型值
+const textChange = (e, paramName) => {
+  archiveParams[paramName] = e.target.value;
 };
-// 获取结束时间
-const endDateChange = (_, dateString) => {
-  endDate.value = dateString;
+// 获取数字框类型值
+const numberChange = (value, paramName) => {
+  archiveParams[paramName] = value;
+};
+// 获取Boolean类型值
+const checkChange = (e, paramName) => {
+  archiveParams[paramName] = e.target.checked;
 };
-
 // 获取业务名
 const getName = () => {
+  loading.value = true;
   getBusinessName().then(
     success => {
+      loading.value = false;
       if (success.errorCode == 0) {
-        if (success.data) {
-          success.data.forEach(item => {
-            item.value = item.id;
+        if (success.datas) {
+          success.datas.forEach(item => {
+            item.value = item.name;
             item.label = item.name;
           });
+          businessNames.value = success.datas;
         }
-        businessNames.value = success.data;
       } else {
         message.error(success.errorMessage);
       }
     },
     error => {
+      loading.value = false;
       Common.processException(error);
     },
   );
 };
+// 获取业务参数
+const nameChange = (_, { name }) => {
+  loading.value = true;
+  businessName.value = name;
+  getBusinessParams(name).then(
+    ({ errorCode, datas, errorMessage }) => {
+      loading.value = false;
+      if (errorCode == 0) {
+        if (datas) {
+          datas.forEach(item => {
+            if (item.displayType == 'DateTimeBoxEditor') {
+              item.dateValue = dayjs(item.defaultValue, 'YYYY-MM-DD HH:mm:ss');
+            }
+            archiveParams[item.paramName] = item.defaultValue;
+          });
+          allParams.value = datas;
+        }
+      } else {
+        message.error(errorMessage);
+      }
+    },
+    error => {
+      loading.value = false;
+      Common.processException(error);
+    },
+  );
+};
+
 // 开始执行
 const startArchive = () => {
+  loading.value = true;
   const params = {
     businessName: businessName.value,
-    startTime: startDate.value,
-    endTime: endDate.value,
-    maxLines: linCount.value,
+    archiveParams,
   };
   execute(params).then(
     success => {
+      loading.value = false;
       if (success.errorCode == 0) {
         if (success.data) {
           isShow.value = true;
-          filePath.value = success.data.visualizationFilePath;
-          tableMessages.value = success.data.tableMessage;
-          createCount.value = success.data.visualizationFileNames.length;
+          archiveLogId.value = success.data.archiveLogId;
+          tableMessages.value = success.data.archiveParams.tableMessages;
+          createCount.value =
+            success.data.archiveParams.visualizationFileNames.length;
         }
       } else {
         message.error(success.errorMessage);
       }
     },
     error => {
+      loading.value = false;
       Common.processException(error);
     },
   );
 };
 // 查看归档数据
 const checkData = () => {
-  const fileUrl = encodeURIComponent(filePath.value);
+  loading.value = true;
+  const fileUrl = encodeURIComponent(archiveLogId.value);
   const xhr = new XMLHttpRequest();
-  xhr.open('get', `api/IArchiveResource/download?xlsxPath=${fileUrl}`, true);
+  xhr.open(
+    'get',
+    `api/ArchivesResource/download?archiveLogId=${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) {
+      loading.value = false;
       let res = xhr.response;
       let blob = new Blob([res]);
       const blobUrl = URL.createObjectURL(blob);
@@ -166,10 +231,20 @@ const checkData = () => {
 </script>
 
 <style scoped>
-:deep(.ant-divider) {
-  margin: 8px 0;
+:deep(.ant-divider.ant-divider-horizontal) {
+  margin: 8px 0 !important;
+}
+.commonWidth {
+  width: 200px;
+}
+.ulStyle {
+  width: 100%;
+  display: flex;
+  flex-direction: row;
+  flex-wrap: wrap;
 }
-.params {
-  margin-left: 8px;
+.liStyle {
+  width: 25%;
+  margin-top: 8px;
 }
 </style>

+ 22 - 2
src/archive/config.js

@@ -2,7 +2,27 @@ import Common from '../common/Common';
 
 // 获取业务名
 export const getBusinessName = () => {
-  var requestUrl = 'IArchiveResource/getBusinessName';
+  var requestUrl = 'ArchivesResource/listBusinessName';
+  return new Promise((resolve, reject) => {
+    $.ajax({
+      url: Common.getApiURL(requestUrl),
+      type: 'get',
+      contentType: 'application/json',
+      beforeSend: function (request) {
+        Common.addTokenToRequest(request);
+      },
+      success: function (data) {
+        resolve(data);
+      },
+      error: function (XMLHttpRequest, textStatus, errorThrown) {
+        reject(XMLHttpRequest);
+      },
+    });
+  });
+};
+// 获取业务参数
+export const getBusinessParams = name => {
+  var requestUrl = 'ArchivesResource/listParameterDefines?businessName=' + name;
   return new Promise((resolve, reject) => {
     $.ajax({
       url: Common.getApiURL(requestUrl),
@@ -23,7 +43,7 @@ export const getBusinessName = () => {
 
 // 执行数据归档
 export const execute = params => {
-  var requestUrl = 'IArchiveResource/executeData';
+  var requestUrl = 'ArchivesResource/executeData';
 
   return new Promise((resolve, reject) => {
     $.ajax({