Explorar o código

上传多个文件

yuedefeng %!s(int64=6) %!d(string=hai) anos
pai
achega
d8f56f951c

+ 5 - 1
src/dashoo.cn/backend/api/controllers/oilsupplier/supplierfile.go

@@ -20,7 +20,7 @@ type SupplierfileController struct {
 }
 
 // @Title 文件上传
-// @Description get user by token
+// @Description get user by tokenaddsubfile
 // @Success 200 {object} models.Userblood
 // @router /filelist [get]
 func (this *SupplierfileController) FileList() {
@@ -64,6 +64,8 @@ func (this *SupplierfileController) AddSubfile() {
 
 	var jsonblob = this.Ctx.Input.RequestBody
 	json.Unmarshal(jsonblob, &model)
+	model.FileUrl = strings.Trim(model.FileUrl, "$")
+	model.FileName = strings.Trim(model.FileName, "$")
 	model.CreateBy = this.User.Realname
 	model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
 
@@ -138,6 +140,8 @@ func (this *SupplierfileController) EditSubfile() {
 	}
 
 	var entity supplierfile.OilSupplierFile
+	model.FileUrl = strings.Trim(model.FileUrl, "$")
+	model.FileName = strings.Trim(model.FileName, "$")
 	model.ModifiedBy = this.User.Realname
 	model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
 

+ 29 - 15
src/dashoo.cn/frontend_web/src/components/oilsupplier/subfilelist.vue

@@ -29,9 +29,11 @@
           </template>
         </el-table-column>
         <el-table-column prop="NeedFileType" label="资质名称" show-overflow-tooltip></el-table-column>
-        <el-table-column prop="FileName" label="资质文件" show-overflow-tooltip>
+        <el-table-column prop="FileUrlList" label="资质文件" show-overflow-tooltip>
           <template slot-scope="scope">
-            <a :href="'http://'+fileurlcut(scope.row.FileUrl)" target="_blank" class="buttonText">{{scope.row.FileName}}</a>
+            <div v-for="(tmpUrl, index) in scope.row.FileUrlList">
+              <a :href="'http://'+fileurlcut(scope.row.FileUrl, index)" target="_blank" class="buttonText"  >{{scope.row.FileName.split('$')[index]}}</a>
+            </div>
           </template>
         </el-table-column>
         <el-table-column prop="EffectDate" label="有效日期" show-overflow-tooltip>
@@ -81,13 +83,14 @@
           </el-col>
           <el-col :span="12">
             <el-form-item label="资质文件">
-              <el-upload style="margin-top: 10px;" action="" ref="refuploadattach" :http-request="uploadrequest"
+              <el-upload multiple style="margin-top: 10px;" action="" ref="refuploadattach" :http-request="uploadrequest"
                 class="attach-uploader" :before-upload="beforeAvatarUpload">
                 <i class="el-icon-plus attach-uploader-icon"></i>
+                <div slot="tip" class="el-upload__tip">大小为512KB-5MB</div>
               </el-upload>
             </el-form-item>
           </el-col>
-          <el-col :span="24">
+          <!--<el-col :span="24">
             <el-form-item class="maintainlog" label="" label-width="120px">
               <div style="overflow: auto;">
                 <template>
@@ -103,7 +106,7 @@
                 </template>
               </div>
             </el-form-item>
-          </el-col>
+          </el-col>-->
         </el-row>
       </el-form>
       <div slot="footer" class="dialog-footer" style="margin-top:-30px;">
@@ -179,7 +182,8 @@
           FileUrl: '',
           OtherRemark: '',
           Remark: '',
-          IsDelete: 0
+          IsDelete: 0,
+          FileUrlList: [],
         },
         visible: false,
         selfVisible: this.visible, // 避免vue双向绑定警告
@@ -208,7 +212,7 @@
           this.dynamicTableColumns=res.data.items
           })
         }
-       
+
       },
       getvalue(SupplierId, SupplierTypeCode, certId) {
         this.SupplierId = SupplierId
@@ -231,6 +235,11 @@
           .then(res => {
             _this.subfileList = res.data.items
             _this.currentItemCount = res.data.currentItemCount
+            for (let idx in _this.subfileList) {
+              console.log(_this.subfileList[idx])
+              _this.subfileList[idx].FileUrlList = _this.subfileList[idx].FileUrl.split('$')
+
+            }
           })
           .catch(err => {
             console.error(err)
@@ -442,10 +451,15 @@
         _this.doclist.push(params)
       },
 
-      beforeAvatarUpload(file) {
-        let isLt50m = file.size / 1024 / 1024 / 50 < 1
+      beforeAvatarUpload (file) {
+        /*let isLt512K = file.size / 1024 < 512
+        if (isLt512K) {
+          this.$message.error('上传文件大小不能小于 512KB!')
+          return false
+        }*/
+        let isLt50m = file.size / 1024 / 1024 / 5 < 1
         if (!isLt50m) {
-          this.$message.error('上传文件大小不能超过 50MB!')
+          this.$message.error('上传文件大小不能超过 5MB!')
           return false
         }
         return true
@@ -494,9 +508,9 @@
             if (this.$refs.refuploadattach.uploadFiles[i].status === 'success') {
               for (let j = 0; j < this.waituploads.length; j++) {
                 if (this.waituploads[j].uid === this.$refs.refuploadattach.uploadFiles[i].uid) {
-                  this.SubfileForm.FileUrl =
-                    `${this.waituploads[j].url}/${this.waituploads[j].fid}|${this.$refs.refuploadattach.uploadFiles[i].name}`
-                  this.SubfileForm.FileName = `${this.$refs.refuploadattach.uploadFiles[i].name}`
+                  this.SubfileForm.FileUrl +=
+                    `${this.waituploads[j].url}/${this.waituploads[j].fid}|${this.$refs.refuploadattach.uploadFiles[i].name}$`
+                  this.SubfileForm.FileName += `${this.$refs.refuploadattach.uploadFiles[i].name}$`
                 }
               }
             }
@@ -522,8 +536,8 @@
       seachdata() {
         this.initData()
       },
-      fileurlcut(val) {
-        let fileurlall = val
+      fileurlcut(val, index) {
+        let fileurlall = val.split('$')[index]
         let fileurl = fileurlall.split("|")
         return fileurl[0]
       },