From 39e54367339902b8780ba107b15964b684e6c191 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期二, 26 十一月 2024 01:15:22 +0800
Subject: [PATCH] 误删恢复

---
 src/views/projectEngineering/component/FileDialog.vue |  176 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 176 insertions(+), 0 deletions(-)

diff --git a/src/views/projectEngineering/component/FileDialog.vue b/src/views/projectEngineering/component/FileDialog.vue
new file mode 100644
index 0000000..d06e5bd
--- /dev/null
+++ b/src/views/projectEngineering/component/FileDialog.vue
@@ -0,0 +1,176 @@
+
+<template>
+  <div>
+    <el-dialog
+      :visible.sync="fileDialogVisible"
+      ref="formDialogRef"
+      width="35%"
+      append-to-body
+      close-on-click-modal
+      @close="closeDialog"
+    >
+      <template slot="title">
+        <span style="padding-bottom: 18px">
+          {{ isImportOrExport ? '璇锋寜鐓ч渶姹傚鍑虹洰鏍囧唴瀹�' : '璇锋寜鐓фā鏉挎牱寮忎笂浼犻」鐩枃浠�' }}
+        </span>
+      </template>
+      <template slot="default">
+        <div v-if="!isImportOrExport" class="dialog-content">
+          <el-upload
+            ref="uploadRef"
+            class="upload-demo"
+            :action="uploadUrl"
+            :limit="1"
+            :accept="accept"
+            :headers=" uploadHeaders"
+            :disabled="uploadIsUploading"
+            :on-progress="handleFileUploadProgress"
+            :on-success="handleFileSuccess"
+            :auto-upload="false"
+            drag
+          >
+            <i class="el-icon-upload"></i>
+            <div class="el-upload__text">璇蜂笂浼�<em>Zip</em>鏂囦欢锛屽ぇ灏忓湪<em>100M</em>浠ュ唴</div>
+          </el-upload>
+          <span>浠呭厑璁稿鍏ip鏍煎紡鏂囦欢銆�</span>
+          <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="handleDownloadFile">涓嬭浇妯℃澘</el-link>
+        </div>
+        <div v-else-if="isImportOrExport" class="dialog-content">
+          <el-button class="export-button" @click="handleDownloadTargetList">瀵煎嚭鐩爣鍒楄〃鍐呭</el-button>
+          <el-button class="export-button">瀵煎嚭鎵�鏈夊垪琛ㄥ唴瀹�</el-button>
+          <el-button class="export-button">瀵煎嚭鐩爣椤圭洰璇︽儏</el-button>
+          <el-button class="export-button">瀵煎嚭鎵�鏈夐」鐩鎯�</el-button>
+        </div>
+      </template>
+      <template slot="footer">
+        <div v-if="!isImportOrExport" class="dialog-footer">
+          <el-button type="primary" @click="submitFileForm">纭� 瀹�</el-button>
+          <el-button @click="closeDialog">鍙� 娑�</el-button>
+        </div>
+        <div v-else-if="isImportOrExport"></div>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import { globalHeaders } from '@/utils/request';
+
+export default {
+  name: 'FileDialog',
+  props: {
+    isImportOrExport: {
+      type: Boolean,
+      default: false
+    },
+    fileDialogVisible: {
+      type: Boolean,
+      default: false
+    },
+    currentColumns: {
+      type: Array,
+      default: function () {
+        return [];
+      }
+    }
+  },
+  data() {
+    return {
+      uploadRef: null,
+      targetColumn: [],
+      accept: `.zip`,
+      uploadUrl: '/project/import',
+      uploadHeaders: globalHeaders(),
+      uploadIsUploading: false
+    };
+  },
+  methods: {
+    handleFileUploadProgress() {
+      this.uploadIsUploading = true;
+    },
+    handleFileSuccess(response, file) {
+      this.uploadIsUploading = false;
+      if (this.uploadRef) {
+        this.uploadRef.handleRemove(file);
+      }
+      if (response.code === 200) {
+        this.$emit('fileDialogCancel');
+        this.$message({
+          message: response.msg,
+          type: 'success'
+        });
+      } else {
+        this.$message.error(response.msg);
+      }
+    },
+    handleDownloadFile() {
+      const self = this;
+      // fetch(`${process.env.VITE_APP_BASE_API}/project/export/template`, {
+      //   method: 'GET',
+      //   headers: self.upload.headers
+      // })
+      //   .then(response => response.blob())
+      //   .then(blob => {
+      //     const url = window.URL.createObjectURL(blob);
+      //     const a = document.createElement('a');
+      //     a.style.display = 'none';
+      //     a.href = url;
+      //     a.download = `椤圭洰鏂囦欢妯℃澘_${new Date().getTime()}.zip`;
+      //     document.body.appendChild(a);
+      //     a.click();
+      //     window.URL.revokeObjectURL(url);
+      //   })
+      //   .catch(error => {
+      //     console.error('鏂囦欢涓嬭浇澶辫触:', error);
+      //   });
+    },
+    submitFileForm() {
+      if (this.uploadRef) {
+        this.uploadRef.submit();
+      }
+    },
+    closeDialog() {
+      this.$emit('fileDialogCancel');
+    },
+    handleDownloadTargetList() {
+      console.log('瀵煎嚭鐩爣鍒楄〃鍐呭', this.currentColumns);
+      this.targetColumn = this.currentColumns.filter(item => item.visible);
+    }
+  },
+  mounted() {
+    this.uploadRef = this.$refs.uploadRef;
+  },
+  created() {
+
+    this.isFileDialogVisible = this.fileDialogVisible;
+  }
+};
+</script>
+
+<style scoped lang="scss">
+.dialog-content {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  flex-direction: column;
+  height: 300px;
+
+  .export-button {
+    margin-left: 0;
+    margin-bottom: 10px;
+  }
+}
+.dialog-footer {
+  display: flex;
+  justify-content: center;
+}
+.upload-demo {
+  width: 100%;
+}
+::v-deep  .el-upload{
+  width: 100%;
+}
+::v-deep .el-upload .el-upload-dragger{
+  width: 100%;
+}
+</style>

--
Gitblit v1.8.0