Browse Source

优化台账上传组件,及文件下载方法

zhangyu 4 years ago
parent
commit
2f5477e4d1

+ 5 - 5
src/components/business_space/dialogs/list/filesDialog.vue

@@ -10,11 +10,11 @@
   >
     <div class='max-height: 500px; overflow-y: auto;'>
       <upload-files
-          :readOnly="read"
-          :keysArr="keysArr"
-          :show-file-list="false"
-          @change="changeItem"
-          max="2"
+        :readOnly="read"
+        :keysArr="keysArr"
+        :show-file-list="false"
+        @change="changeItem"
+        max="2"
       />
     </div>
   </el-dialog>

+ 41 - 42
src/components/business_space/lib/uploadFiles.vue

@@ -11,41 +11,19 @@
   <div id="saga-upload">
     <div id="uploadFile">
       <el-upload
-          class="upload-file"
-          action
-          :http-request="uploadAndSubmit"
-          :show-file-list="false"
-          drag
-      >
-        <el-button
-          size="small"
-          :type="isShow ===1 ? 'text':'primary'"
-          v-if="!readOnly"
-        >点击上传</el-button>
-        <span v-if="isShow !== 1 || isShow == undefined">
-          <div
-            slot="tip"
-            class="el-upload__tip"
-            v-if="!readOnly"
-          >请上传文件,且不大于50M</div>
-        </span>
-
+        class="upload-file"
+        action drag
+        :http-request="uploadAndSubmit"
+        :show-file-list="false">
+        <el-button size="small" :type="isShow ===1 ? 'text':'primary'" v-if="!readOnly">点击上传</el-button>
+        <div slot="tip" class="el-upload__tip" v-if="(isShow !== 1 || isShow == undefined) && !readOnly">请上传文件,且不大于50M</div>
       </el-upload>
-      <div
-          v-if="item && filesArr.length"
-          v-for="(item,index) in filesArr"
-      >
-        <el-button
-            type="text"
-            @click="download(item.Key)"
-        >
-          {{delFile(item.Name)}}</el-button>
-        <i
-            v-if="!readOnly"
-            class="el-icon-close delete-icon"
-            style="margin-left:10px; cursor:pointer"
-            @click="deleteFile(index,item)"
-        ></i>
+      <div v-show="item && filesArr.length" v-for="(item,index) in filesArr" :key="item.Key">
+        <p class="file-list">
+          <span class="file-name" :title="item.Name">{{item.Name}}</span>
+          <i title="下载" class="el-icon-download" style="margin-left:10px; cursor:pointer" @click="download(item)"></i>
+          <i v-if="!readOnly" title="删除" class="el-icon-close delete-icon" style="margin-left:10px; cursor:pointer" @click="deleteFile(index,item)"></i>
+        </p>
       </div>
     </div>
   </div>
@@ -100,10 +78,6 @@
           this.filesArr = []
         }
       },
-      //处理地址
-      delFile(name) {
-        return name.length > 20 ? name.substring(0, 20) + "..." : name
-      },
 
       resetFile() {
         this.filesArr = []
@@ -111,9 +85,19 @@
 
 
       //点击下载
-      download(key) {
-        console.log(key)
-        window.open("/image-service/common/file_get/" + key + "?systemId=dataPlatform")
+      download(item) {
+        if (item.Key) {
+          let a = document.createElement("a");
+          a.href = `/image-service/common/file_get/${item.Key}?systemId=dataPlatform`;
+          a.download = `${item.Name}`;
+          a.click();
+          document.body.removeChild(a);
+        } else {
+          this.$message({
+            message: "无该获取该文件资源链接!",
+            type: "error"
+          });
+        }
       },
 
       //删除图片
@@ -241,13 +225,28 @@
     #uploadFile {
       .upload-file {
         overflow: hidden;
-
         .el-upload-dragger {
           width: inherit;
           height: inherit;
           border: none;
         }
       }
+      .file-list {
+        .file-name {
+          display: inline-block;
+          width: 400px;
+          font-size: 12px;
+          color: #409eff;
+          overflow: hidden;
+          white-space: nowrap;
+          text-overflow: ellipsis;
+          vertical-align: top;
+          cursor: pointer;
+        }
+        .file-name:hover {
+          color: #66b1ff;
+        }
+      }
     }
   }
 </style>

+ 125 - 126
src/components/dialogs/list/filesDialog.vue

@@ -3,137 +3,136 @@
 -->
 
 <template>
-    <el-dialog
-        title="上传文件"
-        :visible.sync="dialog.uploadFiles"
-        width="500px">
-        <div class='max-height: 500px; overflow-y: auto;'>
-            <upload-files
-                :readOnly="read"
-                :keysArr="keysArr"
-                :firmDataType="firmDataType"
-                @change="changeItem"
-                max="2"
-            />
-        </div>
-    </el-dialog>
+  <el-dialog
+    title="上传文件"
+    :visible.sync="dialog.uploadFiles"
+    width="500px">
+    <div class='max-height: 500px; overflow-y: auto;'>
+      <upload-files
+        :readOnly="read"
+        :keysArr="keysArr"
+        :firmDataType="firmDataType"
+        @change="changeItem"
+        max="2"
+      />
+    </div>
+  </el-dialog>
 </template>
 <script>
-  import uploadFiles from "@/components/ledger/lib/uploadFiles";
+import uploadFiles from "@/components/ledger/lib/uploadFiles";
 
-  export default {
-    components: {
-      uploadFiles
+export default {
+  components: {
+    uploadFiles
+  },
+  props: {
+    dialog: {
+      type: Object,
+      default: function () {
+        return {
+          uploadFiles: false
+        };
+      }
     },
-    props: {
-      dialog: {
-        type: Object,
-        default: function () {
-          return {
-            uploadFiles: false
-          };
-        }
-      },
-      keysArr: {
-        type: Array,
-        default: function () {
-          return []
-        }
-      },
-      read: {
-        type: Boolean,
-                default: false
-            },
-            firmDataType: {
-                type: String
-            },
-            infoType: {
-                type: String
-            },
-            information: {
-                type: Object
-            }
-        },
-        data() {
-            return {};
-        },
-        created() {
-        },
-        computed: {
-
-        },
-        mounted() {
-        },
-        methods: {
-            changeItem(file) {
-                if (this.firmDataType === 'dialog') {
-                    let info = this.infoType;
-                  switch (info) {
-                    case 'archive':
-                      this.information.archive.Archive = file
-                      this.$emit("changeFile", this.information, this.firmDataType)
-                      break
-                    case 'checkReport':
-                      this.information.checkReport.CheckReport = file
-                      this.$emit("changeFile", this.information, this.firmDataType)
-                      break
-                    case 'insuranceFile':
-                      this.information.insuranceFile.InsuranceFile = file
-                      this.$emit("changeFile", this.information, this.firmDataType)
-                      break;
-                    case 'LedgerParam.InsuranceDoc.InsuranceFile': //保险文件
-                      this.$emit("changeFile", info, this.firmDataType,file)
-                      break
-                    case 'LedgerParam.PhotoDoc.Archive': //设备文档
-                      this.$emit("changeFile", info, this.firmDataType,file)
-                      break
-                    case 'LedgerParam.Siteinstall.CheckReport': //安装质检报告
-                      this.$emit("changeFile", info, this.firmDataType,file)
-                      break
-                    case 'LedgerParam.OperationMainte.MaintainManual': //维修保养手册
-                      this.$emit("changeFile", info, this.firmDataType,file)
-                      break
-                    case 'LedgerParam.SupplyPurchase.ApproachingAcceptance': //进场验收单
-                      this.$emit("changeFile", info, this.firmDataType,file)
-                      break
-                    case 'LedgerParam.SupplyPurchase.AcceptanceReport': //验收报告
-                      this.$emit("changeFile", info, this.firmDataType,file)
-                      break
-                    case 'LedgerParam.PhotoDoc.OperationManual': //操作说明书
-                      this.$emit("changeFile", info, this.firmDataType,file)
-                      break
-                    case 'LedgerParam.EquipManufactor.OriginalCertificate': //原厂证明
-                      this.$emit("changeFile", info, this.firmDataType,file)
-                      break
-                    case 'LedgerParam.EquipManufactor.TestReport': //检测报告
-                      this.$emit("changeFile", info, this.firmDataType,file)
-                      break
-                    case 'LedgerParam.PhotoDoc.ProductCertification': //产品合格证
-                      this.$emit("changeFile", info, this.firmDataType,file)
-                      break
-                    case 'LedgerParam.Siteinstall.InstallInstruction': //安装说明书
-                      this.$emit("changeFile", info, this.firmDataType,file)
-                      break
-                    case 'LedgerParam.PhotoDoc.Drawing': //设备图纸
-                      this.$emit("changeFile", info, this.firmDataType,file)
-                      break
-                    case 'LedgerParam.Siteinstall.InstallDrawing': //安装图纸
-                      this.$emit("changeFile", info, this.firmDataType,file)
-                      break
-                    case 'LedgerParam.SupplyPurchase.SupplierContract': //供应合同
-                      this.$emit("changeFile", info, this.firmDataType,file)
-                      break
-                  }
-                } else {
-                    this.$emit("changeFile", file, this.firmDataType)
+    keysArr: {
+      type: Array,
+      default: function () {
+        return []
+      }
+    },
+    read: {
+      type: Boolean,
+      default: false
+    },
+    firmDataType: {
+      type: String
+    },
+    infoType: {
+      type: String
+    },
+    information: {
+      type: Object
+    }
+  },
+  data() {
+    return {};
+  },
+  created() {
+  },
+  computed: {
 
-                }
-            },
-            deepCopy(obj) {
-                return JSON.parse((JSON.stringify(obj)))
-            }
-        },
-    };
+  },
+  mounted() {
+  },
+  methods: {
+    changeItem(file) {
+      if (this.firmDataType === 'dialog') {
+        let info = this.infoType;
+        switch (info) {
+          case 'archive':
+            this.information.archive.Archive = file
+            this.$emit("changeFile", this.information, this.firmDataType)
+            break
+          case 'checkReport':
+            this.information.checkReport.CheckReport = file
+            this.$emit("changeFile", this.information, this.firmDataType)
+            break
+          case 'insuranceFile':
+            this.information.insuranceFile.InsuranceFile = file
+            this.$emit("changeFile", this.information, this.firmDataType)
+            break;
+          case 'LedgerParam.InsuranceDoc.InsuranceFile': //保险文件
+            this.$emit("changeFile", info, this.firmDataType,file)
+            break
+          case 'LedgerParam.PhotoDoc.Archive': //设备文档
+            this.$emit("changeFile", info, this.firmDataType,file)
+            break
+          case 'LedgerParam.Siteinstall.CheckReport': //安装质检报告
+            this.$emit("changeFile", info, this.firmDataType,file)
+            break
+          case 'LedgerParam.OperationMainte.MaintainManual': //维修保养手册
+            this.$emit("changeFile", info, this.firmDataType,file)
+            break
+          case 'LedgerParam.SupplyPurchase.ApproachingAcceptance': //进场验收单
+            this.$emit("changeFile", info, this.firmDataType,file)
+            break
+          case 'LedgerParam.SupplyPurchase.AcceptanceReport': //验收报告
+            this.$emit("changeFile", info, this.firmDataType,file)
+            break
+          case 'LedgerParam.PhotoDoc.OperationManual': //操作说明书
+            this.$emit("changeFile", info, this.firmDataType,file)
+            break
+          case 'LedgerParam.EquipManufactor.OriginalCertificate': //原厂证明
+            this.$emit("changeFile", info, this.firmDataType,file)
+            break
+          case 'LedgerParam.EquipManufactor.TestReport': //检测报告
+            this.$emit("changeFile", info, this.firmDataType,file)
+            break
+          case 'LedgerParam.PhotoDoc.ProductCertification': //产品合格证
+            this.$emit("changeFile", info, this.firmDataType,file)
+            break
+          case 'LedgerParam.Siteinstall.InstallInstruction': //安装说明书
+            this.$emit("changeFile", info, this.firmDataType,file)
+            break
+          case 'LedgerParam.PhotoDoc.Drawing': //设备图纸
+            this.$emit("changeFile", info, this.firmDataType,file)
+            break
+          case 'LedgerParam.Siteinstall.InstallDrawing': //安装图纸
+            this.$emit("changeFile", info, this.firmDataType,file)
+            break
+          case 'LedgerParam.SupplyPurchase.SupplierContract': //供应合同
+            this.$emit("changeFile", info, this.firmDataType,file)
+            break
+        }
+      } else {
+        this.$emit("changeFile", file, this.firmDataType)
+      }
+    },
+    deepCopy(obj) {
+      return JSON.parse((JSON.stringify(obj)))
+    }
+  },
+};
 </script>
 <style>
 </style>

+ 2 - 2
src/components/ledger/handsontables/assets.vue

@@ -313,7 +313,7 @@
             this.tableHeader = res.Content;
             this.tableHeader.forEach(item => {
               if (item.Path && item.InputMode) {
-                this.inputMap[item.Path] = item.InputMode
+                this.inputMap[item.Path] = item
               }
             })
             this.getTableData()
@@ -996,7 +996,7 @@
           this.$message("该信息点的值为自动生成,不可人工维护!");
           return false;
         }
-        if (!this.onlyRead && showTools.InputModeArr.indexOf(inputMode) == '-1') {
+        if (!this.onlyRead && showTools.InputModeArr.indexOf(inputData.InputMode) == '-1') {
           this.updateInfoPoint = val;
           this.updateInput = tools.dataForKey(this.tableData[row.row], val);
           this.myDialog.update = true;

+ 9 - 3
src/components/ledger/handsontables/system.vue

@@ -154,7 +154,13 @@ export default {
       loading: false,
       addData: {}, //添加设备选择的设备类型
       inputMap: {
-        flowBuild: 'D1'
+        flowBuild: {
+          InputMode: 'D1',
+          Editable:true,
+          InfoPointCode:"flowBuild",
+          InfoPointName:"建筑楼层",
+          Path:"flowBuild"
+        }
       }, //信息点和输入方式映射表
       updateInputShow: false, //是否显示临时维护输入框
       updateInfoPoint: '',//临时维护信息点
@@ -185,7 +191,7 @@ export default {
           this.tableHeader = res.Content;
           this.tableHeader.forEach(item => {
             if (item.Path && item.InputMode) {
-              this.inputMap[item.Path] = item.InputMode
+              this.inputMap[item.Path] = item
             }
           })
           this.getTableData()
@@ -569,7 +575,7 @@ export default {
         this.$message("该信息点的值为自动生成,不可人工维护!");
         return false;
       }
-      if (!this.onlyRead && showTools.InputModeArr.indexOf(inputMode) == '-1') {
+      if (!this.onlyRead && showTools.InputModeArr.indexOf(inputData.InputMode) == '-1') {
         this.updateInfoPoint = val;
         this.updateInput = tools.dataForKey(this.tableData[row.row], val);
         this.myDialog.update = true;

+ 41 - 44
src/components/ledger/lib/uploadFiles.vue

@@ -11,42 +11,19 @@
   <div id="saga-upload" v-loading="loading">
     <div id="uploadFile">
       <el-upload
-          class="upload-file"
-          action
-          :show-file-list="false"
-          :http-request="uploadAndSubmit"
-          drag
-      >
-        <el-button
-            size="small"
-            type="primary"
-            v-if="!readOnly "
-        >点击上传
-        </el-button>
-        <div
-            slot="tip"
-            class="el-upload__tip"
-            v-if="!readOnly"
-        >请上传文件,且不大于50M
-        </div>
+        class="upload-file"
+        action drag
+        :show-file-list="false"
+        :http-request="uploadAndSubmit">
+        <el-button size="small" type="primary" v-if="!readOnly">点击上传</el-button>
+        <div slot="tip" class="el-upload__tip" v-if="!readOnly">请上传文件,且不大于50M</div>
       </el-upload>
-
-      <div
-          v-show="item && filesArr.length"
-          v-for="(item,index) in filesArr"
-      >
-        <el-button
-            type="text"
-            @click="download(item.Key)"
-        >
-          {{delFile(item.Name)}}
-        </el-button>
-        <i
-            v-if="!readOnly"
-            class="el-icon-close delete-icon"
-            style="margin-left:10px; cursor:pointer"
-            @click="deleteFile(index,item)"
-        ></i>
+      <div v-show="item && filesArr.length"  v-for="(item,index) in filesArr" :key="item.Key">
+        <p class="file-list">
+          <span class="file-name" :title="item.Name">{{item.Name}}</span>
+          <i title="下载" class="el-icon-download" style="margin-left:10px; cursor:pointer" @click="download(item)"></i>
+          <i v-if="!readOnly" title="删除" class="el-icon-close delete-icon" style="margin-left:10px; cursor:pointer" @click="deleteFile(index,item)"></i>
+        </p>
       </div>
     </div>
   </div>
@@ -117,20 +94,25 @@
           this.filesArr = []
         }
       },
-      //处理地址
-      delFile(name) {
-        return name.length > 20 ? name.substring(0, 20) + "..." : name
-      },
-
       resetFile() {
         this.filesArr = []
       },
 
 
       //点击下载
-      download(key) {
-        console.log(key)
-        window.open("/image-service/common/file_get/" + key + "?systemId=dataPlatform")
+      download(item) {
+        if (item.Key) {
+          let a = document.createElement("a");
+          a.href = `/image-service/common/file_get/${item.Key}?systemId=dataPlatform`;
+          a.download = `${item.Name}`;
+          a.click();
+          document.body.removeChild(a);
+        } else {
+          this.$message({
+            message: "无该获取该文件资源链接!",
+            type: "error"
+          });
+        }
       },
 
       //删除图片
@@ -253,13 +235,28 @@
     #uploadFile {
       .upload-file {
         overflow: hidden;
-
         .el-upload-dragger {
           width: inherit;
           height: inherit;
           border: none;
         }
       }
+      .file-list {
+        .file-name {
+          display: inline-block;
+          width: 400px;
+          font-size: 12px;
+          color: #409eff;
+          overflow: hidden;
+          white-space: nowrap;
+          text-overflow: ellipsis;
+          vertical-align: top;
+          cursor: pointer;
+        }
+        .file-name:hover {
+          color: #66b1ff;
+        }
+      }
     }
   }
 </style>

+ 1 - 1
src/components/ledger/system/dialog/addEquipDialog.vue

@@ -10,7 +10,7 @@
         <floor-cascader @change="changeFloor" style="margin-left:5px;"></floor-cascader>
       </el-col>
       <el-col :span="8.5" style="padding-right:0;">
-        <myCascader @change="changeDevice" :all="true" :params="childParams"></myCascader>
+        <myCascader @change="changeDevice" :params="childParams"></myCascader>
       </el-col>
     </el-row>
 

+ 1 - 1
src/components/ledger/system/lib/equipType.vue

@@ -67,7 +67,7 @@ export default {
       let param2 = {
         Distinct: true,
         PageNumber: 1,
-        PageSize: 500,
+        PageSize: 1000,
         Projection: [
           "Category"
         ]

+ 1 - 0
src/components/model/file/floorTable.vue

@@ -126,6 +126,7 @@ export default {
         a.href = url;
         a.download = `${this.modelFolderName}${item.FloorName}模型文件v${item.Version}.rvt`;
         a.click();
+        document.body.removeChild(a);
       } else {
         this.$message({
           message: "该文件夹下没有资源",

+ 1 - 1
src/views/ledger/facility/partsmanage/index.vue

@@ -751,7 +751,7 @@ export default {
         this.$message("该信息点的值为自动生成,不可人工维护!");
         return false;
       }
-      if (!this.onlyRead && showTools.InputModeArr.indexOf(inputMode) == '-1') {
+      if (!this.onlyRead && showTools.InputModeArr.indexOf(inputData.inputMode) == '-1') {
         this.updateInfoPoint = val;
         this.updateInput = tools.dataForKey(this.tableData[row.row], val);
         this.myDialog.update = true;