敲代码的猫 1 місяць тому
батько
коміт
24e451df41

Різницю між файлами не показано, бо вона завелика
+ 152 - 152
src/views/screen/building/cameraDataDialog.vue


+ 47 - 48
src/views/screen/engineering/issueDealDia.vue

@@ -36,18 +36,17 @@
         <el-input v-model="description" type="textarea" :rows=6 placeholder="请输入内容" resize="none" style="margin-bottom: 20px;width: 350px" readonly></el-input>
 
         <div style="width: 130px;height: 130px;background: rgba(15, 86, 86, 0.54);margin-bottom: 10px;border-radius: 8px;color: #00ffff;position: relative;font-size: 45px;display: flex;align-items: center;border: 1px solid #00ffff4d;">
-          <i v-if="!fileFlag" class="el-icon-plus" style="position: absolute;top: 50%;left: 50%;transform: translate(-50%, -50%);"></i>
-          <input v-if="!fileFlag" type="file" ref="fileInput" @change="handleFileChange" style="display: none;position: absolute;left: -1000px"/>
-          <div v-if="!fileFlag" @click="triggerFileInput" style="width: 100%;height: 100%;cursor: pointer;position: absolute;"></div>
-          <div class="sth" v-if="fileFlag">
-    <div style="width: 0;height: 0;border-left: 30px solid transparent;border-top: 30px solid #000000;position: absolute;top: 0;right: 0">
-    </div>
+          <i v-if="!fileFlag"  class="el-icon-plus" style="position: absolute;top: 50%;left: 50%;transform: translate(-50%, -50%);"></i>
+  <input type="file" ref="fileInput" @change="handleFileChange" style="display: none"  accept=".docx,.xlsx"/>
+  <div @click="triggerFileInput" style="width: 100%;height: 100%;cursor: pointer;position: absolute;"></div>
+  <div class="sth" v-if="fileFlag">
+    <div style="width: 0;height: 0;border-left: 30px solid transparent;border-top: 30px solid #000000;position: absolute;top: 0;right: 0"></div>
     <div class="close-icon" @click="handleRemove"></div>
     <div style="width: 100%;height: 100%;display: flex;align-items: center;justify-content: center">
       <div style="color: #00FFFF;font-size: 14px">{{ fileName }}</div>
     </div>
   </div>
-          <img width="100%" :src="dialogImageUrl" v-if="fileFlag" style="height: 100%;object-fit: cover;">
+          <!-- <img width="100%" :src="dialogImageUrl" v-if="fileFlag" style="height: 100%;object-fit: cover;"> -->
         </div>
 
         <div style="margin-bottom: 20px;color: #00ffff80;font-family: PingFangSC-Regular;font-weight: 400;font-size: 14px;">支持.docx、.xlsx格式</div>
@@ -102,58 +101,67 @@ export default {
       this.$refs.fileInput.click();
     },
     changeIssueStatus() {
-      if (!this.selectedFile) {
-        this.$message.error('请选择要上传的文件');
-        return;
+      if (this.file == null){
+        return
       }
+       // 添加二次校验
+  if (!this.fileName.endsWith('.docx') && !this.fileName.endsWith('.xlsx')) {
+    this.$message.error('文件格式不符合要求');
+    return;
+  }
+      const issueData = {
+        createDate:this.value,
+        title:this.title,
+        description:this.description,
+        id:this.getProList.id,
+        status: 1,
+      };
 
       const formData = new FormData();
-      formData.append('createDate', this.value);
-      formData.append('title', this.title);
-      formData.append('description', this.description);
-      formData.append('id', this.getProList.id);
-      formData.append('status', 1);
-      formData.append('file', this.selectedFile); 
+      formData.append("file", this.file);
+      formData.append("issue", new Blob([JSON.stringify(issueData)], { type: "application/json" }));
 
       changeIssueStatus(formData).then((res) => {
         if (Number(res.code) === 200) {
           this.close();
         }
       }).catch((err) => {
-        console.error("修改状态失败:", err);
+        console.error("提交失败:", err);
       });
     },
+ 
     handleFileChange(event) {
   const file = event.target.files[0];
   if (!file) return;
 
-  // 添加文件类型校验
-  const allowedTypes = [
-    'application/vnd.openxmlformats-officedocument.wordprocessingml.document', // .docx
-    'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' // .xlsx
-  ];
+  // 添加文件类型白名单
+  const allowedExtensions = ['.docx', '.xlsx'];
+  const fileName = file.name.toLowerCase();
   
-  if (!allowedTypes.includes(file.type)) {
+  // 校验文件后缀
+  const isValidFile = allowedExtensions.some(ext => fileName.endsWith(ext));
+  
+  if (!isValidFile) {
     this.$message.error('仅支持上传.docx和.xlsx格式文件');
-    this.handleRemove();
+    this.handleRemove(); // 清空错误文件
     return;
   }
 
+  // 更新文件状态
+  this.fileName = file.name;
+  this.file = file;
   this.fileFlag = true;
-  this.selectedFile = file; // 保存原始File对象
-  this.fileName = file.name; // 显示文件名
-},
-
 
+  // 移除图片预览相关代码
+   this.dialogImageUrl = URL.createObjectURL(file) // 删除这行
+},
    
-    handleRemove() {
-      this.fileFlag = false;
-      this.fileName = '';
-      this.selectedFile = null;
-      if (this.$refs.fileInput) {
-        this.$refs.fileInput.value = ''; // 清空文件输入
-      }
-    },
+handleRemove() {
+  this.fileFlag = false;
+  this.fileName = '';
+  this.selectedFile = null;
+  this.$refs.fileInput.value = ''; // 清空文件输入
+},
 
     // 移除图片预览相关方法
   
@@ -225,18 +233,9 @@ export default {
 .me::-webkit-scrollbar {
   display: none;
 }
-.sth{
-  width: 100%;
-  height: 100%;
-  position: absolute;
-  font-size: 22px;
-  cursor: pointer;
-  opacity: 0;
-  display: flex;
-  justify-content: center;
-  align-items: center;
-  flex-wrap: wrap;
-  transition: background-color 0.5s ease;
+.sth {
+  background: rgba(5, 28, 38, 0.78); // 加深背景提高文字可读性
+ 
 }
 .sth:hover{
   opacity: 1;

Деякі файли не було показано, через те що забагато файлів було змінено