Pārlūkot izejas kodu

更改文件上传

sunyanqiang 3 gadi atpakaļ
vecāks
revīzija
8e850b6f2e

+ 54 - 22
src/components/FileUpload/index.vue

@@ -14,24 +14,48 @@
       ref="upload"
     >
       <!-- 上传按钮 -->
-      <el-button size="mini" type="primary" class="select_file">选取文件</el-button>
+      <el-button size="mini" type="primary" class="select_file"
+        >选取文件</el-button
+      >
       <!-- 上传提示 -->
       <div class="el-upload__tip" slot="tip" v-if="showTip">
         请上传
-        <template v-if="fileSize"> 大小不超过 <b style="color: #13CE66 ">{{ fileSize }}MB</b></template>
-        <template v-if="fileType"> 格式为 <b style="color: #13CE66">{{ fileType.join("/") }}</b></template>
+        <template v-if="fileSize">
+          大小不超过 <b style="color: #13ce66">{{ fileSize }}MB</b></template
+        >
+        <template v-if="fileType">
+          格式为
+          <b style="color: #13ce66">{{ fileType.join("/") }}</b></template
+        >
         的文件
       </div>
     </el-upload>
 
     <!-- 文件列表 -->
-    <transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
-      <li :key="file.uid" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList">
-        <el-link :href="`${baseUrl}${file.url}`" :underline="false" target="_blank">
+    <transition-group
+      class="upload-file-list el-upload-list el-upload-list--text"
+      name="el-fade-in-linear"
+      tag="ul"
+    >
+      <li
+        :key="file.uid"
+        class="el-upload-list__item ele-upload-list__item-content"
+        v-for="(file, index) in fileList"
+      >
+        <el-link
+          :href="`${baseUrl}${file.url}`"
+          :underline="false"
+          target="_blank"
+        >
           <span class="el-icon-document"> {{ file.name }}</span>
         </el-link>
         <div class="ele-upload-list__item-content-action">
-          <el-link :underline="false" @click="handleDelete(index)" type="danger" class="del"></el-link>
+          <el-link
+            :underline="false"
+            @click="handleDelete(index)"
+            type="danger"
+            class="del"
+          ></el-link>
         </div>
       </li>
     </transition-group>
@@ -39,7 +63,7 @@
 </template>
 
 <script>
-import {getToken} from "@/utils/auth";
+import { getToken } from "@/utils/auth";
 
 export default {
   name: "FileUpload",
@@ -49,7 +73,7 @@ export default {
     // 数量限制
     limit: {
       type: Number,
-      default: 10,
+      default: 5,
     },
     // 大小限制(MB)
     fileSize: {
@@ -64,10 +88,10 @@ export default {
     // 是否显示提示
     isShowTip: {
       type: Boolean,
-      default: true
+      default: true,
     },
     // 文件名称
-    names: '',
+    names: "",
   },
   data() {
     return {
@@ -77,20 +101,23 @@ export default {
         Authorization: "Bearer " + getToken(),
       },
       fileList: [],
-      faith: null
+      faith: null,
     };
   },
+  created() {
+    console.log(this.limit);
+  },
   watch: {
     value: {
       handler(val) {
         if (val) {
           let temp = 1;
           // 首先将值转为数组
-          const list = Array.isArray(val) ? val : this.value.split(',');
+          const list = Array.isArray(val) ? val : this.value.split(",");
           // 然后将数组转为对象数组
-          this.fileList = list.map(item => {
+          this.fileList = list.map((item) => {
             if (typeof item === "string") {
-              item = {name: item, url: item};
+              item = { name: item, url: item };
             }
             item.uid = item.uid || new Date().getTime() + temp++;
             return item;
@@ -102,7 +129,7 @@ export default {
       },
       deep: true,
       immediate: true,
-    }
+    },
   },
   computed: {
     // 是否显示提示
@@ -150,14 +177,19 @@ export default {
     // 上传成功回调
     handleUploadSuccess(res, file) {
       this.$message.success("上传成功");
-      this.fileList.push({name: file.name, url: res.fileName,pageCount:res.pageCount,houZUI:res.houZUi,fileLength:res.fileLength});
+      this.fileList.push({
+        name: file.name,
+        url: res.fileName,
+        pageCount: res.pageCount,
+        houZUI: res.houZUi,
+        fileLength: res.fileLength,
+      });
       this.$emit("input", this.fileList);
     },
     // 删除文件
     handleDelete(index) {
       this.fileList.splice(index, 1);
       this.$emit("input", this.fileList);
-      
     },
     // 获取文件名称
     getFileName(name) {
@@ -174,9 +206,9 @@ export default {
       for (let i in list) {
         strs += list[i].url + separator;
       }
-      return strs != '' ? strs.substr(0, strs.length - 1) : '';
-    }
-  }
+      return strs != "" ? strs.substr(0, strs.length - 1) : "";
+    },
+  },
 };
 </script>
 
@@ -224,7 +256,7 @@ export default {
   left: 40px;
   background-image: url("../../images/delicon.png");
   background-repeat: no-repeat;
-  background-color: #FF4949;
+  background-color: #ff4949;
   background-position: center;
   margin-bottom: 2px;
   margin-left: -5px;

+ 5 - 2
src/components/ImageUpload/index.vue

@@ -54,7 +54,6 @@ export default {
     // 图片数量限制
     limit: {
       type: Number,
-      default: 5,
     },
     // 大小限制(MB)
     fileSize: {
@@ -111,6 +110,9 @@ export default {
       immediate: true,
     },
   },
+  created() {
+    console.log(this.limit);
+  },
   computed: {
     // 是否显示提示
     showTip() {
@@ -169,7 +171,8 @@ export default {
       });
     },
     // 文件个数超出
-    handleExceed() {
+    handleExceed(files, fileList) {
+      console.log(files, fileList);
       this.$message.error(`上传文件数量不能超过 ${this.limit} 个!`);
     },
     // 上传失败

+ 59 - 43
src/views/bdglregular/regularinfo/index.vue

@@ -345,9 +345,9 @@
             type="text"
             v-if="
               scope.row.caoZuoType == '0' &&
-                scope.row.isCaoZuoDept == 0 &&
-                (scope.row.currentState == '未通过' ||
-                  scope.row.currentState == '待处理')
+              scope.row.isCaoZuoDept == 0 &&
+              (scope.row.currentState == '未通过' ||
+                scope.row.currentState == '待处理')
             "
             @click="handleUpdate(scope.row)"
             >整改</el-button
@@ -358,8 +358,8 @@
             @click="shenpifun(scope.row)"
             v-if="
               queryParams.caoZuoType == 0 &&
-                scope.row.isShenPi == 0 &&
-                scope.row.currentState == '待验收'
+              scope.row.isShenPi == 0 &&
+              scope.row.currentState == '待验收'
             "
             >审批</el-button
           >
@@ -600,7 +600,11 @@
         </el-form-item>
         <div class="jiben" v-if="jiannum != 0">文件举证</div>
         <el-form-item label prop="documentProof" v-if="jiannum != 0">
-          <fileUpload v-model="form.documentProof" />
+          <fileUpload
+            v-model="form.documentProof"
+            :limit="1"
+            :class="{ active: isActive }"
+          />
         </el-form-item>
         <div class="jiben" v-if="currentState == 1">未通过原因</div>
         <el-form-item label prop="score" v-if="currentState == 1">
@@ -637,6 +641,7 @@
         <el-button @click="cancel" size="btn">取 消</el-button>
       </div>
     </el-dialog>
+
     <el-dialog
       :title="title"
       :visible.sync="open1"
@@ -775,7 +780,7 @@ import {
   editissuccess,
   editisfalse,
   bumenlist,
-  listRegularinfos
+  listRegularinfos,
 } from "@/api/bdglregular/regularinfo";
 import { getUserProfile } from "@/api/system/user";
 export default {
@@ -825,7 +830,7 @@ export default {
         correctiveAction: null,
         pictureProof: null,
         documentProof: null,
-        caoZuoType: 0
+        caoZuoType: 0,
       },
       // 用户
       user: {},
@@ -836,27 +841,27 @@ export default {
       // 表单校验
       rules: {
         unitCheck: [
-          { required: true, message: "检查单位不能为空", trigger: "change" }
+          { required: true, message: "检查单位不能为空", trigger: "change" },
         ],
         inspectedUnit: [
-          { required: true, message: "受检单位不能为空", trigger: "change" }
+          { required: true, message: "受检单位不能为空", trigger: "change" },
         ],
         inspectionType: [
-          { required: true, message: "类型不能为空", trigger: "change" }
+          { required: true, message: "类型不能为空", trigger: "change" },
         ],
         inspectionTime: [
-          { required: true, message: "检查时间不能为空", trigger: "change" }
+          { required: true, message: "检查时间不能为空", trigger: "change" },
         ],
         inspectionSite: [
-          { required: true, message: "检查地点不能为空", trigger: "blur" }
+          { required: true, message: "检查地点不能为空", trigger: "blur" },
         ],
         score: [{ required: true, message: "分值不能为空", trigger: "blur" }],
         rectificationTime: [
-          { required: true, message: "整改时间不能为空", trigger: "change" }
+          { required: true, message: "整改时间不能为空", trigger: "change" },
         ],
         chargePeople: [
-          { required: true, message: "负责人不能为空", trigger: "change" }
-        ]
+          { required: true, message: "负责人不能为空", trigger: "change" },
+        ],
       },
       //单位
       unitId: [],
@@ -872,7 +877,8 @@ export default {
       curr: null,
       isdisabled: false,
       open1: false,
-      zg: null
+      zg: null,
+      isActive: null,
     };
   },
   created() {
@@ -898,28 +904,28 @@ export default {
       correctiveAction: null,
       pictureProof: null,
       documentProof: null,
-      caoZuoType: 0
+      caoZuoType: 0,
     };
     // this.danWiess()
     //部门数据
-    getDept().then(res => {
+    getDept().then((res) => {
       if (res.code == 200) {
         this.unitId = res.data;
       }
     });
     //调动人员对象
-    listPeople().then(res => {
+    listPeople().then((res) => {
       if (res.code == 200) {
         this.peopleIds = res.rows;
       }
     });
     //检查类型
-    this.getDicts("inspectionType").then(response => {
+    this.getDicts("inspectionType").then((response) => {
       this.inspectionType = response.data;
     });
 
     if (this.$route.query.id) {
-      bumenlist(this.$route.query.id).then(res => {
+      bumenlist(this.$route.query.id).then((res) => {
         console.log(1);
         this.regularinfoList = res.rows;
         this.total = res.total;
@@ -952,10 +958,10 @@ export default {
         correctiveAction: null,
         pictureProof: null,
         documentProof: null,
-        caoZuoType: 0
+        caoZuoType: 0,
       };
       if (to.query.id) {
-        bumenlist(to.query.id).then(res => {
+        bumenlist(to.query.id).then((res) => {
           this.regularinfoList = res.rows;
           this.total = res.total;
           this.loading = false;
@@ -964,7 +970,7 @@ export default {
         this.queryParams.inspectedUnitId = to.query.obj.id + "";
         this.queryParams.currentState = to.query.obj.name + "";
 
-        listRegularinfos(this.queryParams).then(res => {
+        listRegularinfos(this.queryParams).then((res) => {
           console.log(res);
           this.regularinfoList = res.rows;
           this.total = res.total;
@@ -976,7 +982,7 @@ export default {
 
       // listRegularinfos
       // console.log(to.query.obj);
-    }
+    },
   },
   mounted() {
     console.log(0);
@@ -985,7 +991,7 @@ export default {
   methods: {
     danWiess() {
       // 获取当前用户接口
-      getUserProfile().then(response => {
+      getUserProfile().then((response) => {
         this.user = response.data;
         console.log(this.user);
         // console.log(response.data.dept.deptId+"这是")
@@ -996,7 +1002,7 @@ export default {
     /** 查询经常性检查列表 */
     getList() {
       this.loading = true;
-      listRegularinfo(this.queryParams).then(response => {
+      listRegularinfo(this.queryParams).then((response) => {
         this.regularinfoList = response.rows;
         this.total = response.total;
         this.loading = false;
@@ -1032,7 +1038,7 @@ export default {
         correctiveAction: null,
         pictureProof: null,
         documentProof: null,
-        reasonReturn: null
+        reasonReturn: null,
       };
       this.resetForm("form");
     },
@@ -1048,7 +1054,7 @@ export default {
     },
     // 多选框选中数据
     handleSelectionChange(selection) {
-      this.ids = selection.map(item => item.id);
+      this.ids = selection.map((item) => item.id);
       this.single = selection.length !== 1;
       this.multiple = !selection.length;
     },
@@ -1101,13 +1107,14 @@ export default {
       console.log(row);
       this.reset();
       const id = row.id || this.ids;
-      getRegularinfo(id).then(response => {
+      getRegularinfo(id).then((response) => {
         this.form = response.data;
         this.open = true;
         this.title = "修改经常性检查";
         this.jiannum = 1;
         this.btnnum = null;
         this.zg = 3;
+        this.isActive = null;
         if (this.form.currentState == "未通过") {
           this.currentState = 1;
           this.curr = true;
@@ -1119,7 +1126,7 @@ export default {
       this.isdisabled = true;
       this.reset();
       const id = row.id || this.ids;
-      getRegularinfo(id).then(response => {
+      getRegularinfo(id).then((response) => {
         this.form = response.data;
         this.open1 = true;
         this.title = "修改经常性检查";
@@ -1135,18 +1142,19 @@ export default {
     shenpifun(row) {
       this.reset();
       const id = row.id || this.ids;
-      getRegularinfo(id).then(response => {
+      getRegularinfo(id).then((response) => {
         this.disabled = true;
         this.form = response.data;
         this.open = true;
         this.title = "修改经常性检查";
         this.jiannum = 1;
         this.btnnum = 0;
+        this.isActive = 1;
       });
     },
     //通过
     tongguofun() {
-      editissuccess(this.form).then(res => {
+      editissuccess(this.form).then((res) => {
         if (res.code == 200) {
           this.$modal.msgSuccess("审批成功");
           this.open = false;
@@ -1170,14 +1178,16 @@ export default {
     },
     //未通过提交
     weitongguofun() {
-      editisfalse(this.form).then(res => {
+      editisfalse(this.form).then((res) => {
         this.$modal.msgSuccess("操作成功");
         this.open = false;
         this.getList();
       });
     },
     submitForm2() {
-      editquestion(this.form).then(response => {
+      this.form.documentProof = this.form.documentProof[0].url;
+      // console.log(this.form);
+      editquestion(this.form).then((response) => {
         this.$modal.msgSuccess("整改成功");
         this.open = false;
         this.open1 = false;
@@ -1187,7 +1197,7 @@ export default {
     /** 提交按钮 */
     submitForm() {
       // console.log(this.form)
-      this.$refs["form"].validate(valid => {
+      this.$refs["form"].validate((valid) => {
         if (valid) {
           if (this.form.documentProof) {
             this.form.documentProof = this.form.documentProof[0].url;
@@ -1195,7 +1205,7 @@ export default {
 
           if (this.form.id != null) {
             this.form.caoZuoType = this.queryParams.caoZuoType;
-            updateRegularinfo(this.form).then(response => {
+            updateRegularinfo(this.form).then((response) => {
               this.$modal.msgSuccess("修改成功");
               this.open = false;
               this.open1 = false;
@@ -1203,7 +1213,7 @@ export default {
             });
           } else {
             this.form.caoZuoType = this.queryParams.caoZuoType;
-            addRegularinfo(this.form).then(response => {
+            addRegularinfo(this.form).then((response) => {
               this.$modal.msgSuccess("新增成功");
               this.open = false;
               this.open1 = false;
@@ -1218,7 +1228,7 @@ export default {
       const ids = row.id || this.ids;
       this.$modal
         .confirm("是否确认删除经常性检查的数据项?")
-        .then(function() {
+        .then(function () {
           return delRegularinfo(ids);
         })
         .then(() => {
@@ -1236,7 +1246,7 @@ export default {
           this.exportLoading = true;
           return exportRegularinfo(queryParams);
         })
-        .then(response => {
+        .then((response) => {
           this.$download.name(response.msg);
           this.exportLoading = false;
         })
@@ -1265,8 +1275,8 @@ export default {
       if (this.form.score < 0) {
         this.form.score = null;
       }
-    }
-  }
+    },
+  },
 };
 </script>
 <style scoped>
@@ -1395,4 +1405,10 @@ hr {
   height: 1px;
   background-color: rgba(204, 204, 204, 0.5);
 }
+::v-deep img {
+  object-fit: cover;
+}
+::v-deep .active .upload-file-uploader .el-upload .el-button {
+  display: none;
+}
 </style>

+ 22 - 16
src/views/bdglregular/specialinfo/index.vue

@@ -136,7 +136,7 @@
           v-if="queryParams.caoZuoType == 0"
           @click="handleAdd"
           style="background: #1d96ff"
-            v-hasPermi="['bdglregular:specialinfo:jjan']"
+          v-hasPermi="['bdglregular:specialinfo:jjan']"
           >减分录入</el-button
         >
       </el-col>
@@ -146,7 +146,7 @@
           v-if="queryParams.caoZuoType == 1"
           @click="handleAdd"
           style="background: #1d96ff"
-            v-hasPermi="['bdglregular:specialinfo:jia']"
+          v-hasPermi="['bdglregular:specialinfo:jia']"
           >加分录入</el-button
         >
       </el-col>
@@ -339,12 +339,17 @@
             "
             >审批</el-button
           >
-          <el-button size="btu" type="text" @click="handleAdds(scope.row)"
-          v-if="scope.row.currentState=='待处理'&&scope.row.isShenPi==0"
+          <el-button
+            size="btu"
+            type="text"
+            @click="handleAdds(scope.row)"
+            v-if="scope.row.currentState == '待处理' && scope.row.isShenPi == 0"
             >修改</el-button
           >
-          <el-button size="btd" @click="handleDelete(scope.row)"
-          v-if="scope.row.isShenPi==0"
+          <el-button
+            size="btd"
+            @click="handleDelete(scope.row)"
+            v-if="scope.row.isShenPi == 0"
             >删除</el-button
           >
         </template>
@@ -381,7 +386,7 @@
             @change="inspectedUnitfun"
             clearable
             placeholder="请选择受检单位"
-            :disabled="disabled || this.isdisabled==true"
+            :disabled="disabled || this.isdisabled == true"
           >
             <el-option
               v-for="dict in unitId"
@@ -409,7 +414,7 @@
             type="datetime"
             value-format="yyyy-MM-dd HH:mm:ss"
             placeholder="选择检查时间"
-            :disabled="disabled || this.isdisabled==true"
+            :disabled="disabled || this.isdisabled == true"
           ></el-date-picker>
         </el-form-item>
         <el-form-item label="分值" prop="score" v-if="jiannum == 0">
@@ -499,7 +504,7 @@
         <div class="jiben" v-if="jiannum != 0">文件举证</div>
         <el-form-item label prop="documentProof" v-if="jiannum != 0">
           <!-- <fileUpload v-model="form.documentProof" /> -->
-          <fileUpload v-model="form.documentProof" />
+          <fileUpload v-model="form.documentProof" :limit="1" />
           <!-- <el-input v-model="form.documentProof" placeholder="请输入文件举证" /> -->
         </el-form-item>
         <div class="jiben" v-if="currentState == 1">未通过原因</div>
@@ -629,7 +634,7 @@ export default {
       currentState: null,
       curr: null,
       // 是否禁用
-      isdisabled:false
+      isdisabled: false,
     };
   },
   created() {
@@ -834,7 +839,7 @@ export default {
     },
     // 修改按钮
     handleAdds(row) {
-      this.isdisabled=true
+      this.isdisabled = true;
       this.reset();
       const id = row.id || this.ids;
       getSpecialinfo(id).then((response) => {
@@ -898,11 +903,12 @@ export default {
           }
           if (this.form.id != null) {
             this.form.caoZuoType = this.queryParams.caoZuoType;
-            editquestion(this.form).then((response) => {
-              this.$modal.msgSuccess("修改成功");
-              this.open = false;
-              this.getList();
-            });
+            console.log(this.form);
+            // editquestion(this.form).then((response) => {
+            //   this.$modal.msgSuccess("修改成功");
+            //   this.open = false;
+            //   this.getList();
+            // });
           } else {
             this.form.caoZuoType = this.queryParams.caoZuoType;
             addSpecialinfo(this.form).then((response) => {