Bläddra i källkod

井筒-文件预览

xiaoqiao 10 månader sedan
förälder
incheckning
dc73c064ea

+ 4 - 4
src/main/java/com/bowintek/practice/controller/WellInfoController.java

@@ -129,19 +129,19 @@ public class WellInfoController {
         getParams.put("filePath", filePath);
 
         String reData = remoteHelper.getJson(getParams, appConfig.hdfshelperurl + "read", "UTF-8");
-        byte[] bytes = Base64.getDecoder().decode(reData);
+        byte[] bytes = Base64.getMimeDecoder().decode(reData);
         OutputStream os = response.getOutputStream();
 
-        if (isShow == null || 1 != isShow) {
+        /*if (isShow == null || 1 != isShow) {
             response.setContentType("application/force-download");// 设置强制下载不打开
-        }
+        }*/
         response.setContentType("multipart/form-data;charset=UTF-8");
         response.setHeader("Content-Length", String.valueOf(bytes.length));
         response.addHeader("Content-Disposition",
                 "attachment;fileName=" + URLEncoder.encode(fileName, "UTF-8"));// 设置文件名
 
         //os.write(reData.getBytes(StandardCharsets.UTF_8));
-        os.write(Base64.getDecoder().decode(reData));
+        os.write(bytes);
         if (null != os) {
             os.flush();
             os.close();

+ 1 - 1
vue/src/components/basic/file-preview/index.vue

@@ -43,7 +43,7 @@ export default defineComponent({
     const visible = ref<boolean>(false);
     const spinning = ref<boolean>(false);
     const previewUrl = ref<Blob>();
-    const fileSuffix = props.fileName?.substring(props.fileName?.lastIndexOf('.') + 1);
+    const fileSuffix = props.fileName?.substring(props.fileName?.lastIndexOf('.') + 1).toLowerCase();
 
     function loadFile() {
       if (props.accept?.indexOf(fileSuffix) < 0) {

+ 2 - 2
vue/src/views/wellinfo/detail.vue

@@ -197,7 +197,7 @@
                   &&(fileOptions.selectBusinessType.length==0||fileOptions.selectBusinessType.includes(item.file_business_type))">
                     <template #actions>
                       <filePreview :fileName="item.file_name" :filePath="item.storage_path"></filePreview>
-                      <a-button type="link" @click="downFile(item)" functioncode="T010502" danger>下载</a-button>
+                      <a-button type="link" @click="downFile(item)" functioncode="T010501" danger>下载</a-button>
                     </template>
                     <a-list-item-meta
                       :description="item.file_business_type">
@@ -434,7 +434,7 @@ export default defineComponent({
     }
 
     const downFile = (record: any) => {
-      download(record.file_business_type, record.file_name);
+      download(record.storage_path, record.file_name);
     };
 
     const onClose = () => {

+ 60 - 34
vue/src/views/wellinfo/index.vue

@@ -91,7 +91,7 @@
                   multiple
                   tree-line
                   :tree-data="subjectTrees.organizationTree"
-                  tree-node-filter-prop="label" >
+                  tree-node-filter-prop="label">
                 </a-tree-select>
               </a-form-item>
             </a-col>
@@ -106,7 +106,7 @@
                   multiple
                   tree-line
                   :tree-data="subjectTrees.constructUnitTree"
-                  tree-node-filter-prop="label" >
+                  tree-node-filter-prop="label">
                 </a-tree-select>
               </a-form-item>
             </a-col>
@@ -300,7 +300,7 @@
             <a-list-item v-if="item.file_name.indexOf(docKey)>-1||docKey==''">
               <template #actions>
                 <filePreview :fileName="item.file_name" :filePath="item.storage_path"></filePreview>
-                <a-button type="link" @click="downFile(item)" functioncode="T010502" danger>下载</a-button>
+                <a-button type="link" @click="downFile(item)" functioncode="T010501" danger>下载</a-button>
               </template>
               <a-list-item-meta
                 :description="item.file_business_type">
@@ -323,9 +323,9 @@
 import {ref, defineComponent, computed, watch} from 'vue';
 import type {FormInstance} from 'ant-design-vue';
 import {useRoute} from 'vue-router';
-import { get,postData} from "@/api/common";
+import {get, postData} from "@/api/common";
 import {getPaginationTotalTitle} from "@/utils/common";
-import { message } from 'ant-design-vue';
+import {message} from 'ant-design-vue';
 import type {TableProps} from "ant-design-vue";
 import {useTabsViewStore} from "@/store/modules/tabsView";
 import ChartCell from '@/components/basic/chart/chart-cell.vue'
@@ -355,8 +355,8 @@ export default defineComponent({
     const tabsViewStore = useTabsViewStore();
     const docKey = ref('');
     const docList = ref([]);
-    const wellTypeList = ref([{label: "直井", value: "直井"}, {label: "定向井", value: "定向井"}, {label: "分支井",value: "分支井"}]);
-    const wellPurposeList = ref([{label: "探井", value: "探井"}, {label: "开发井", value: "开发井"}, {label: "水井",value: "水井"}]);
+    const wellTypeList = ref([{label: "直井", value: "直井"}, {label: "定向井", value: "定向井"}, {label: "分支井", value: "分支井"}]);
+    const wellPurposeList = ref([{label: "探井", value: "探井"}, {label: "开发井", value: "开发井"}, {label: "水井", value: "水井"}]);
     const replaceFields = {
       children: 'children',
       title: 'label',
@@ -364,14 +364,14 @@ export default defineComponent({
     };
 
     const downFile = (record: any) => {
-      download(record.file_business_type, record.file_name);
+      download(record.storage_path, record.file_name);
     };
     const resetFields = function () {
       let keys: string[] = Object.keys(formState);
       keys.forEach(key => {
         if (typeof (formState[key]) == "string") {
           formState[key] = '';
-        }else if(typeof (formState[key]) == "object"){
+        } else if (typeof (formState[key]) == "object") {
           formState[key] = [];
         }
       })
@@ -379,33 +379,59 @@ export default defineComponent({
 
     filterColumns.value = [...columns];
 
-    watch(
-      () => showColumnType.value,
-      () => {
-        const filterValue = columns.filter((item: any) => {
-          if (!showColumnType.value.includes("oil")) {
-            if (["oil_prod_mon", "oil_prod_year", "oil"].includes(item.dataIndex)) {
-              return false
-            }
+    function showColumnTypeChange() {
+      const filterValue = columns.filter((item: any) => {
+        if (!showColumnType.value.includes("oil")) {
+          if (["oil_prod_mon", "oil_prod_year", "oil"].includes(item.dataIndex)) {
+            return false
           }
-          if (!showColumnType.value.includes("gas")) {
-            if (["gas_prod_mon", "gas_prod_year", "gas"].includes(item.dataIndex)) {
-              return false
-            }
+        }
+        if (!showColumnType.value.includes("gas")) {
+          if (["gas_prod_mon", "gas_prod_year", "gas"].includes(item.dataIndex)) {
+            return false
           }
-          if (!showColumnType.value.includes("water")) {
-            if (["water_prod_mon", "water_prod_year", "water"].includes(item.dataIndex)) {
-              return false
-            }
+        }
+        if (!showColumnType.value.includes("water")) {
+          if (["water_prod_mon", "water_prod_year", "water"].includes(item.dataIndex)) {
+            return false
           }
-          return true
+        }
+        return true
+      })
+      //拖拽后在显示隐藏列则需要按拖拽后的列排序
+      const sortedArray = filterValue.sort((a, b) => {
+        const indexA = filterColumns.value.findIndex(f=>f.key==a.key);
+        const indexB = filterColumns.value.findIndex(f=>f.key==b.key);
+        return (indexA==-1||indexB==-1)?1: indexA - indexB;
+      });
+      filterColumns.value = [...sortedArray];
+      setSettingColoumns();
+    }
+
+    function getSettingColoumns() {
+      let userColumnsJson = localStorage.getItem('userColumns');
+      let userShowColumnsType = localStorage.getItem('userShowColumnsType');
+      if (userColumnsJson != undefined) {
+        let array = new Array();
+        let userColumns = JSON.parse(userColumnsJson);
+        userColumns.forEach(it => {
+          array.push(columns.find(c => c.key == it.key));
         })
-        filterColumns.value = [...filterValue];
+        filterColumns.value = array;
+      }
+      if (userShowColumnsType != undefined) {
+        showColumnType.value = JSON.parse(userShowColumnsType);
       }
-    );
+    }
+
+    function setSettingColoumns() {
+      localStorage.setItem("userShowColumnsType", JSON.stringify(showColumnType.value));
+      localStorage.setItem("userColumns", JSON.stringify(filterColumns.value));
+    }
 
     const preCheckValues = ref(Object.assign(showColumnType.value));
     const onCheckboxChange = (checkValues: []) => {
+      showColumnTypeChange();
       setTimeout(() => {
         let tbody = document.getElementsByClassName("ant-table-body")[0];
         if (tbody) {
@@ -443,7 +469,7 @@ export default defineComponent({
 
     const loadData = async function () {
       loading.value = true;
-      const result: any = await postData('wellInfo/getList',formState);
+      const result: any = await postData('wellInfo/getList', formState);
 
       data.value = result.list;
       formState.total = result.total;
@@ -521,7 +547,7 @@ export default defineComponent({
         })
         .filter((item, i, self) => item && self.indexOf(item) === i);
 
-      if (expanded.length==0) {
+      if (expanded.length == 0) {
         message.warning('没有查询到相关目录');
       }
       subjectTrees.value.expandedKeys = expanded as string[];
@@ -580,7 +606,7 @@ export default defineComponent({
 
     return {
       route, selectedRowKeys, loading, activeTab, showTree, onSelectChange, data,
-      expand, onQuery, loadData, onRangeChange, showQuery, wellTypeList,wellPurposeList, replaceFields,
+      expand, onQuery, loadData, onRangeChange, showQuery, wellTypeList, wellPurposeList, replaceFields,
       formRef, viewModel, handleTableChange, detail,
       formState, isShowDoc, showDoc, docKey, docList, resetFields, showColumnType, filterColumns,
       labelCol, getTdColor, downFile,
@@ -588,11 +614,11 @@ export default defineComponent({
       treeOnExpand,
       subjectTrees,
       getSubjectTree, searchTree,
-      treeOnSelect, pagination,
+      treeOnSelect, pagination, getSettingColoumns,
     };
   },
-  created
-  () {
+  created() {
+    this.getSettingColoumns();
     this.loadData();
   }
   ,

+ 2 - 0
vue/src/views/wellinfo/table.ts

@@ -3,6 +3,7 @@ import dayjs from "dayjs";
 import type {GetComponentProps} from "ant-design-vue/lib/vc-table/interface";
 import {reactive, ref} from "vue";
 
+
 const state = reactive({
   dragIndex: 0
 });
@@ -63,6 +64,7 @@ const dragEnter = (e) => {
       filterColumns.value = newItems;
     }
     filterColumns.value = newItems;
+    localStorage.setItem("userColumns",JSON.stringify(filterColumns.value));
     state.dragIndex = index;
   }
 };