소스 검색

分站管理历史数据问题修改

bobo04052021@163.com 2 달 전
부모
커밋
4120571be3

+ 31 - 0
src/hooks/system/useMethods.ts

@@ -102,6 +102,36 @@ export function useMethods() {
       });
   }
 
+  async function exportXlsPost1(name, url, params, isXlsx = false) {
+    const data = await defHttp.get({ url: url, params: params, responseType: 'blob', timeout: 1000 * 1000 }, { isTransformResponse: false });
+    if (!data) {
+      createMessage.warning('文件下载失败');
+      return;
+    }
+    if (!name || typeof name != 'string') {
+      name = '导出文件';
+    }
+    const blobOptions = { type: 'application/vnd.ms-excel' };
+    let fileSuffix = '.xls';
+    if (isXlsx === true) {
+      blobOptions['type'] = XLSX_MIME_TYPE;
+      fileSuffix = XLSX_FILE_SUFFIX;
+    }
+    if (typeof window.navigator.msSaveBlob !== 'undefined') {
+      window.navigator.msSaveBlob(new Blob([data], blobOptions), name + fileSuffix);
+    } else {
+      const url = window.URL.createObjectURL(new Blob([data], blobOptions));
+      const link = document.createElement('a');
+      link.style.display = 'none';
+      link.href = url;
+      link.setAttribute('download', name + fileSuffix);
+      document.body.appendChild(link);
+      link.click();
+      document.body.removeChild(link); //下载完成移除元素
+      window.URL.revokeObjectURL(url); //释放掉blob对象
+    }
+  }
+
   /**
    * 导入xls
    * @param data 导入的数据
@@ -144,6 +174,7 @@ export function useMethods() {
   return {
     handleExportXls: (name: string, url: string, params?: object) => exportXls(name, url, params),
     handleExportXlsPost: (name: string, url: string, params?: object) => exportXlsPost(name, url, params),
+    exportXlsPost0: (name: string, url: string, params?: object) => exportXlsPost1(name, url, params),
     handleImportXls: (data, url, success) => importXls(data, url, success),
     handleExportXlsx: (name: string, url: string, params?: object) => exportXls(name, url, params, true),
   };

+ 1 - 1
src/views/vent/deviceManager/comment/HistoryTable.vue

@@ -153,7 +153,7 @@ async function getDataSource() {
   // } else {
   //   dataSource.value = [];
   // }
-  return result;
+  dataSource.value = result['records'];
 
   setLoading(false);
 }

+ 12 - 12
src/views/vent/deviceManager/substationTabel/substation.data.ts

@@ -289,36 +289,36 @@ export const formSchema: FormSchema[] = [
 export const historyColumns: BasicColumn[] = [
   {
     title: '名称',
-    dataIndex: 'strName',
-    key: 'strName',
+    dataIndex: 'devicename',
+    key: 'devicename',
     width: 120,
     align: 'center',
   },
   {
     title: '安装位置',
-    dataIndex: 'strinstallpos',
-    key: 'strinstallpos',
+    dataIndex: 'stationname',
+    key: 'stationname',
     width: 120,
     align: 'center',
   },
   {
-    title: '分站IP地址',
-    dataIndex: 'strip',
-    key: 'strip',
+    title: '开始报警时间',
+    dataIndex: 'starttime',
+    key: 'starttime',
     width: 120,
     align: 'center',
   },
   {
-    title: '开始报警时间',
-    dataIndex: 'starttime_begin',
-    key: 'starttime_begin',
+    title: '结束报警时间',
+    dataIndex: 'endtime',
+    key: 'endtime',
     width: 120,
     align: 'center',
   },
   {
     title: '报警状态',
-    dataIndex: 'status',
-    key: 'status',
+    dataIndex: 'nwartype_dictText',
+    key: 'nwartype_dictText',
     width: 120,
     align: 'center',
   },

+ 11 - 13
src/views/vent/safetyList/common/HistoryTable.vue

@@ -130,29 +130,27 @@ async function getDataSource() {
   dataSource.value = [];
   setLoading(true);
   const params = await resetFormParam();
-  const result = await defHttp.post({ url: '/safety/ventanalySubStation/get158StatusLog', params: params });
-  // if (result['datalist']['records'].length > 0) {
-  //   dataSource.value = result['datalist']['records'].map((item: any) => {
-  //     return Object.assign(item, item['readData']);
-  //   });
-  // } else {
+  const result = await defHttp.post(
+    { url: '/safety/ventanalySubStation/get158StatusLog', params: params },
+    { joinParamsToUrl: true, isTransformResponse: false }
+  );
   dataSource.value = result['records'];
-  // }
-  // return result;
-
   setLoading(false);
 }
 //导出
-// function onExportXlsFn() {
+// async function onExportXlsFn() {
+//   const params = await resetFormParam();
+//   await defHttp.post({ url: postExportXlsUrl, params: params }, { joinParamsToUrl: true, isTransformResponse: false });
+//   // dataSource.value = result['records'];
 //   // const params = resetFormParam();
 //   // // 判断时间间隔和查询时间区间,数据量下载大时进行提示
 //   // return onExportXlsPost(params);
 // }
 //导入导出方法
 function onExportXlsFn() {
-  const { handleExportXlsPost } = useMethods();
+  const { exportXlsPost0 } = useMethods();
   const params = resetFormParam();
-  handleExportXlsPost('历史数据', postExportXlsUrl, params);
+  exportXlsPost0('历史数据', postExportXlsUrl, params);
 }
 
 // 列表页面公共参数、方法
@@ -219,7 +217,7 @@ const { tableContext, onExportXlsPost } = useListPage({
                 label: '连接状态',
                 field: 'status',
                 component: 'Select',
-                defaultValue: '1',
+                defaultValue: 1,
                 componentProps: () => {
                   return {
                     options: [

+ 1 - 1
src/views/vent/safetyList/common/detail.vue

@@ -154,6 +154,7 @@
                   <span class="zd-close">{{ clsoeNum || 0 }}</span>
                 </span>
               </div>
+              <a-button type="primary" size="small" @click="getAllShow">显示全部</a-button>
             </div>
             <div class="left-content">
               <div class="card-box" v-for="(item, index) in cardList" :key="index">
@@ -169,7 +170,6 @@
                   ]"
                   @click="cardClick(item, index)"
                 >
-                  <a-button type="primary" size="small" @click="getAllShow">显示全部</a-button>
                   <div class="card-item-label">{{ item.strname }}</div>
                 </div>
                 <div :class="activeIndex % 4 == 3 ? 'card-modal1' : 'card-modal'" v-if="activeIndex == index && isShow">