Bläddra i källkod

1.修改文件管理样式

QuietShadow 3 år sedan
förälder
incheckning
b8870dc603
1 ändrade filer med 131 tillägg och 23 borttagningar
  1. 131 23
      src/views/energyOperationSupport/components/securitys/SecurityFile.vue

+ 131 - 23
src/views/energyOperationSupport/components/securitys/SecurityFile.vue

@@ -123,6 +123,7 @@
                         ref="upload"
                         :http-request="beforeUpload"
                         :auto-upload="false"
+                        :loading="loading"
                         >
                         <i class="el-icon-upload"></i>
                         <!-- <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> -->
@@ -133,21 +134,35 @@
                         ref="upload1"
                         action=""
                         :http-request="beforeUpload"
+                        :loading="loading"
                         :auto-upload="false">
                         <el-button
                         slot="trigger"
                         size="small"
                         type="primary"
+                        :loading="loading"
+                        icon="el-icon-plus"
                         >选取文件
                         </el-button>
                         </el-upload>
                         <el-button
-                        style="margin-left: 10px;"
-                        size="small" type="success"
+                        style="margin-left: 20px;"
+                        size="small"
+                        type="primary"
                         v-privilege="activeMenu + 'UPLOAD'"
                         @click="submitUpload"
+                        :loading="loading"
                         >上传到服务器
                         </el-button>
+                        <el-button
+                            class="button"
+                            type="primary"
+                            size="mini"
+                            icon="el-icon-edit-outline"
+                            v-privilege="activeMenu + 'UPDATA'"
+                            @click="but_edit_plural()"
+                            :loading="loading"
+                        >修改</el-button>
                         <el-button
                             class="button"
                             type="danger"
@@ -165,6 +180,7 @@
                                 icon="el-icon-search"
                                 v-privilege="activeMenu + 'QUERY'"
                                 @click="getTableData(1)"
+                                :loading="loading"
                             >查询</el-button>
                             <el-button
                                 size="mini"
@@ -237,15 +253,47 @@
                                 width="320px"
                                 :show-overflow-tooltip="true"
                             > <template slot-scope="scope">
-                                      <el-tag
-                                        effect="dark"
-                                        :disable-transitions="true"
-                                        v-for="(tag,key) in scope.row.fileType"
-                                        :key="key"
-                                        size="small">
-                                        {{ tag }}
-                                      </el-tag>
-                                </template>
+                                      <el-form-item
+                                          v-if="scope.row.isSelection"
+                                          :prop="scope.row.ID + '.fileType'"
+                                      >
+                                          <el-tag
+                                            effect="dark"
+                                            v-for="(tag,key) in tableFormDataObj[scope.row.ID].fileType"
+                                            :key="key"
+                                            closable
+                                            size="small"
+                                            :disable-transitions="true"
+                                            @close="rowhandleClose(tag, scope.row)">
+                                            {{tag}}
+                                          </el-tag>
+                                          <el-input
+                                            class="input-new-tag"
+                                            v-if="tableFormDataObj[scope.row.ID].showInput"
+                                            v-model="tableFormDataObj[scope.row.ID].inputValue"
+                                            ref="saveTagInput"
+                                            size="small"
+                                            @keyup.enter.native="rowhandleInputConfirm(scope.row)"
+                                            @blur="rowhandleInputConfirm(scope.row)"
+                                          >
+                                          </el-input>
+                                          <el-button
+                                          v-else
+                                          class="button-new-tag"
+                                          size="small"
+                                          @click="rowshowInput(scope.row)"
+                                          >+标签</el-button>
+                                      </el-form-item>
+                                      <template v-else>
+                                        <el-tag
+                                          effect="dark"
+                                          :disable-transitions="true"
+                                          v-for="(tag,key) in scope.row.fileType"
+                                          :key="key"
+                                          size="small">
+                                          {{ tag }}
+                                        </el-tag></template>
+                                  </template>
                             </el-table-column>
                             <el-table-column
                                 sortable
@@ -286,6 +334,7 @@
                             icon="el-icon-download"
                             v-privilege="activeMenu + 'DOWNLOAD'"
                             @click="downloadFile(scope.row)"
+                            :loading="loading"
                             >点击下载
                             </el-button>
                             <el-button
@@ -294,6 +343,7 @@
                             icon="el-icon-view"
                             v-privilege="activeMenu + 'PREVIEW'"
                             @click="preview(scope.row)"
+                            :loading="loading"
                             >预览
                             </el-button>
                             </template>
@@ -556,7 +606,7 @@ export default {
             dialog: {
                 editorBox: {
                     show: false,
-                    type: '',
+                    fileType: '',
                     form: {
                         default: {
                             workprocid: ''
@@ -568,7 +618,8 @@ export default {
                             isprimary: '0',
                             unitid: '',
                             seqno: '',
-                            code: ''
+                            code: '',
+                            fileType: ''
                         },
                         rules: {
                             productid: [
@@ -777,7 +828,9 @@ export default {
                                 createMan: item.createMan,
                                 createTime: item.createTime,
                                 updateMan: item.updateMan,
-                                updateTime: item.updateTime
+                                updateTime: item.updateTime,
+                                showInput: false,
+                                inputValue: ''
                             })
                             }
                         }
@@ -818,7 +871,7 @@ export default {
             }
             for (let item of val) {
                 let obj = {};
-                let xId = item.itemid;
+                let xId = item.ID;
                 if (that.tableFormDataObj[xId]) {
                     tableFormDataObj[xId] = that.tableFormDataObj[xId];
                 } else {
@@ -829,7 +882,7 @@ export default {
                 }
                 item.isSelection = true;
             }
-            that.tableFormDataObj = tableFormDataObj;
+            that.tableFormDataObj = JSON.parse(JSON.stringify(tableFormDataObj));
             that.multipleSelection = val;
         },
         but_add () {
@@ -852,7 +905,9 @@ export default {
             }, 100);
         },
         beforeUpload (file) {
-          let that = this
+          let that = this;
+          that.tableLoading = true;
+          that.loading = true;
           let foorData = new FormData();
           foorData.append('file', file.file);
           foorData.append('type', this.filterForm.data.securityTypeid);
@@ -873,16 +928,50 @@ export default {
                 } else {
                 that.$message.error(res.message);
                 }
+                that.tableLoading = false;
+                that.loading = false;
           }).catch(function () {
+            that.$message({
+                 message: '上传失败,FTP服务器可能已断开连接',
+                 type: 'success'
+             });
+             that.tableLoading = false;
+             that.loading = false;
           });
         },
         submitUpload () {
+        let that = this;
         this.$refs.upload.submit();
         this.$refs.upload1.submit();
       },
       handleRemove (file, fileList) {
         console.log(file, fileList);
       },
+      // 行内标签删除
+      rowhandleClose (tag, row) {
+        let that = this;
+        that.tableFormDataObj[row.ID].fileType.splice(that.tableFormDataObj[row.ID].fileType.indexOf(tag), 1);
+      },
+      // 行内标签新增
+      rowhandleInputConfirm (row) {
+        let that = this;
+        let inputValue = that.tableFormDataObj[row.ID].inputValue;
+        if (inputValue) {
+          that.tableFormDataObj[row.ID].fileType.push(inputValue);
+        }
+        that.tableFormDataObj[row.ID].showInput = false;
+        that.tableFormDataObj[row.ID].inputValue = '';
+      },
+      // 行内input获取焦点
+      rowshowInput (row) {
+        let that = this;
+        that.tableFormDataObj[row.ID].showInput = true;
+        // setTimeout(function(){
+        //    that.$nextTick(_ => {
+        //      this.$refs.saveTagInput.$refs.input.focus();
+        //    });
+        // },500)
+      },
       handlePreview (file) {
         console.log(file);
       },
@@ -894,16 +983,22 @@ export default {
                     if (valid) {
                         let SubmitData = [];
                         for (let key in that.tableFormDataObj) {
+                          let fileTypes = '';
+                          for (let item in that.tableFormDataObj[key].fileType) {
+                              if (Number(item) === that.tableFormDataObj[key].fileType.length - 1) {
+                                  fileTypes += that.tableFormDataObj[key].fileType[item];
+                              } else {
+                                  fileTypes += that.tableFormDataObj[key].fileType[item] + ';';
+                              }
+                          }
                             SubmitData.push({
-                                itemid: that.tableFormDataObj[key].itemid,
-                                isprimary: that.tableFormDataObj[key].isprimary,
-                                unitid: that.tableFormDataObj[key].unitid,
-                                seqno: that.tableFormDataObj[key].seqno,
-                                code: that.tableFormDataObj[key].code
+                                Id: that.tableFormDataObj[key].ID,
+                                fileType: fileTypes,
+                                seqno: that.tableFormDataObj[key].seqno
                             });
                         }
                         that.loading = true;
-                        that.axios.put('pass/ems/v1/trmworkprocproducts/', SubmitData)
+                        that.axios.put('pass/ems/v1/uploadfiles/batchupdate', SubmitData)
                             .then(function (res) {
                                 if (res.code === '0') {
                                     that.$message({
@@ -928,6 +1023,7 @@ export default {
         // 批量删除
         but_del_plural () {
             let that = this;
+            that.loading = true;
             if (that.multipleSelection.length > 0) {
                 let ids = [];
                 let paths = [];
@@ -948,6 +1044,7 @@ export default {
                                     type: 'success'
                                 });
                                 that.getTableData();
+                                that.loading = false;
                             } else {
                                 if (res.code === '51') {
 
@@ -955,11 +1052,13 @@ export default {
                                 that.$message.error(res.message);
                             }
                         }).catch(function () {
+                          that.loading = false;
                         });
                 }).catch(() => {
                 });
             } else {
                 this.$message.error('至少要选择一条数据');
+                that.loading = false;
             }
         },
         dataSave () {
@@ -1079,6 +1178,7 @@ export default {
             //     }
             // };
             // xhr.send();
+            that.loading = true;
                 let urla = 'pass/ems/v1/uploadfiles/downloadFile/';
                 that.axios.get(urla, {
                 params: SubmitData,
@@ -1089,18 +1189,22 @@ export default {
                        message: '下载成功',
                        type: 'success'
                    });
+                   that.loading = false;
                 }).catch(function () {
                     that.$message.error('下载失败');
+                    that.loading = false;
                 })
         },
         // js实现文件下载而不直接打开
         saveAs (data, fileName) {
+            this.loading = true;
             let urlObject = window.URL || window.webkitURL || window;
             // 将二进制流转为blob
             let exportBlob = new Blob([data]);
             if (typeof window.navigator.msSaveBlob !== 'undefined') {
               // 兼容IE,window.navigator.msSaveBlob:以本地方式保存文件
               window.navigator.msSaveBlob(exportBlob, decodeURI(fileName));
+              this.loading = false;
             } else {
                 // 创建新的URL并指向File对象或者Blob对象的地址
                 let blobURL = urlObject.createObjectURL(exportBlob);
@@ -1116,6 +1220,7 @@ export default {
                 saveLink.click();
                 // 释放blob URL地址
                 urlObject.revokeObjectURL(exportBlob);
+                this.loading = false;
                 // let blob = new Blob([data])
                 // let fileURL = urlObject.createObjectURL(blob);
                 // 下载代码
@@ -1130,6 +1235,7 @@ export default {
         },
         preview (data) {
             let that = this;
+            that.loading = true;
             let SubmitData = {
                 fileName: data.fileName,
                 fileUrl: data.fileUrl
@@ -1163,6 +1269,7 @@ export default {
                 that.dialogVisible = true;
                 that.previewUrl = blobURL;
                 that.tableLoading = false;
+                that.loading = false;
                 // 'https://file.keking.cn/onlinePreview?url=' + encodeURIComponent(blobURL)
                 // http://view.officeapps.live.com/op/view.aspx?src' + blobURL;
                 // 创建a标签,用于跳转至下载链接
@@ -1187,6 +1294,7 @@ export default {
             }).catch(function () {
                 that.tableLoading = false;
                 that.$message.error('预览失败');
+                that.loading = false;
             })
         }
     }