Browse Source

yqgwfy10151140

liuhj 10 months ago
parent
commit
54e45cdac6

+ 24 - 7
src/components/OP/InvitationOfficialActivities.vue

@@ -99,8 +99,8 @@
                             <span v-else-if="isPay.row.isPay == 0">未付款</span>
                             <span v-else-if="isPay.row.isPay == 0">未付款</span>
                         </template>
                         </template>
                     </el-table-column>
                     </el-table-column>
-                    <el-table-column prop="attachment" label="附件" width="122">
-                    </el-table-column>
+                    <!-- <el-table-column prop="attachment" label="附件" width="122">
+                    </el-table-column> -->
                     <el-table-column label="操作">
                     <el-table-column label="操作">
                         <template slot-scope="scope">
                         <template slot-scope="scope">
                             <el-button style="margin-left: 0px;" size="mini" @click="download(scope.$index, scope.row)"
                             <el-button style="margin-left: 0px;" size="mini" @click="download(scope.$index, scope.row)"
@@ -354,6 +354,7 @@ export default {
                         that.$message.error('删除失败!');
                         that.$message.error('删除失败!');
                     }
                     }
                     that.loading = false
                     that.loading = false
+
                 }).catch(function (error) {
                 }).catch(function (error) {
                     that.loading = false
                     that.loading = false
                     that.$message.error("网络错误,请稍后重试");
                     that.$message.error("网络错误,请稍后重试");
@@ -366,11 +367,27 @@ export default {
             }); 
             }); 
         },
         },
         download(index, row) {
         download(index, row) {
-            if (row.filePath != "") {
-                window.location.href = "http://132.232.92.186:24/Office/GrpFile/商邀相关文件/" + row.attachment
-            } else {
-                this.$message.error("暂未上传附件");
-            }
+            var that = this
+            this.$axios({
+                method: 'get',
+                url: "/api/Groups/InvitationOfficialActivitiesListDownFile/"+row.id,
+                headers: {
+                    Authorization: 'Bearer ' + this.token
+                },
+            }).then(function (res) {
+                if (res.data.code == 200) {
+                    window.open(res.data.data.url)
+                } else {
+                    that.$message.error(res.data.msg);
+                }
+            }).catch(function (error) {
+                that.$message.error("网络错误,请稍后重试");
+            });
+            // if (row.filePath != "") {
+            //     window.location.href = "http://132.232.92.186:24/Office/GrpFile/商邀相关文件/" + row.attachment
+            // } else {
+            //     this.$message.error("暂未上传附件");
+            // }
 
 
         }
         }
     },
     },

+ 147 - 121
src/components/OP/OpInvitationOfficialActivities.vue

@@ -357,10 +357,20 @@
                         </el-form-item>
                         </el-form-item>
                     </div>
                     </div>
                     <div style="width: 385px;">
                     <div style="width: 385px;">
-                        <el-form-item label="附件:" prop="fileUrl" label-width="160px">
-                            <el-upload :file-list="uploadFiles" multiple ref="upload" :on-success="upLoadSuccess"
-                                :on-error="upLoadError" :before-remove="beforeRemove" :on-change="onChange" :limit="10"
-                                :on-exceed="exceed" :action="uploadURL" :headers="headers" :auto-upload="false">
+                        <el-form-item style="position: relative;" label="附件:" prop="fileUrl" label-width="160px">
+                            <span style="position: absolute;top: 0;left: -50px;color: red;">*</span>
+                            <el-upload 
+                                :file-list="uploadFiles" 
+                                multiple ref="upload" 
+                                :on-success="upLoadSuccess"
+                                :on-error="upLoadError" 
+                                :on-remove="handleRemove" 
+                                :before-remove="beforeRemove" 
+                                :on-change="onChange" 
+                                :limit="10"
+                                :on-exceed="exceed" 
+                                action="" 
+                                :auto-upload="false">
                                 <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
                                 <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
                                 <!-- <el-button style="margin-left: 10px;" size="small" type="success"
                                 <!-- <el-button style="margin-left: 10px;" size="small" type="success"
                                     @click="submitUpload">上传到服务器</el-button> -->
                                     @click="submitUpload">上传到服务器</el-button> -->
@@ -756,6 +766,7 @@ export default {
                     that.InvitationOfficialActivities.email = res.data.data._InvitationData.email;
                     that.InvitationOfficialActivities.email = res.data.data._InvitationData.email;
                     that.InvitationOfficialActivities.fax = res.data.data._InvitationData.fax;
                     that.InvitationOfficialActivities.fax = res.data.data._InvitationData.fax;
                     that.InvitationOfficialActivities.otherInformation = res.data.data._InvitationData.remark;
                     that.InvitationOfficialActivities.otherInformation = res.data.data._InvitationData.remark;
+                    
                     if (that.InvitationOfficialActivities.attachment != null && that.InvitationOfficialActivities.attachment != undefined && that.InvitationOfficialActivities.attachment != "") {
                     if (that.InvitationOfficialActivities.attachment != null && that.InvitationOfficialActivities.attachment != undefined && that.InvitationOfficialActivities.attachment != "") {
                         for (let m = 0; m < that.InvitationOfficialActivities.attachment.length; m++) {
                         for (let m = 0; m < that.InvitationOfficialActivities.attachment.length; m++) {
                             that.uploadFiles.push({
                             that.uploadFiles.push({
@@ -763,9 +774,7 @@ export default {
                                 url: 'http://132.232.92.186:24/Office/GrpFile/商邀相关文件/'+that.InvitationOfficialActivities.attachment[m],
                                 url: 'http://132.232.92.186:24/Office/GrpFile/商邀相关文件/'+that.InvitationOfficialActivities.attachment[m],
                             })
                             })
                         }
                         }
-                    }
-                    console.log(that.uploadFiles);
-                    
+                    } 
                 }
                 }
 
 
             })
             })
@@ -845,96 +854,31 @@ export default {
                 const that = this;
                 const that = this;
                 that.$refs.InvitationOfficialActivities.validate((valid) => {
                 that.$refs.InvitationOfficialActivities.validate((valid) => {
                     if (valid) {
                     if (valid) {
-                        if (that.InvitationOfficialActivities.attachment == that.projectName) {
-                            if (that.DelfileName != null && that.DelfileName != "" && that.DelfileName != undefined) {
-                                that.$axios({
-                                    method: 'post',
-                                    url: "/api/Groups/DelFile",
-                                    headers: {
-                                        Authorization: 'Bearer ' + that.token
-                                    },
-                                    data: {
-                                        fileName: that.DelfileName,
-                                        id: that.id
-                                    }
-                                }).then(function (res) {
-                                    if (res.data.code == 200) {
-
-                                    }
-                                })
-                            }
-                            that.InvitationOfficialActivities.attachment = that.projectName
-                            that.InvitationOfficialActivities.diId = that.DiIdSelect;
-                            that.InvitationOfficialActivities.createUserId = that.userId;
-                            var url = "/api/Groups/OpInvitationOfficialActivities"
-                            that.$axios({
-                                method: 'post',
-                                url: url,
-                                headers: {
-                                    Authorization: 'Bearer ' + that.token
-                                },
-                                data: that.InvitationOfficialActivities
-                            }).then(function (res) {
-                                if (res.data.code == 200) {
-                                    that.$message({
-                                        message: res.data.msg,
-                                        type: 'success'
-                                    });
-                                    setTimeout(() => {
-                                        that.cancelbtn()
-                                    }, 500);
-                                } else {
-                                    that.$message.error(res.data.msg);
-                                }
-                            })
-                        } else {
-                            if (that.DelfileName != null && that.DelfileName != "" && that.DelfileName != undefined) {
-                                that.$axios({
-                                    method: 'post',
-                                    url: "/api/Groups/DelFile",
-                                    headers: {
-                                        Authorization: 'Bearer ' + that.token
-                                    },
-                                    data: {
-                                        fileName: that.DelfileName,
-                                        id: that.id
-                                    }
-                                }).then(function (res) {
-                                    if (res.data.code == 200) {
-
-                                    }
-                                })
-                            }
-                            if (that.projectName != "" && that.projectName != null && that.projectName != undefined) {
-                                that.$refs.upload.submit();//上传文件到服务器
+                        that.submitUpload()
+                        that.InvitationOfficialActivities.attachment = that.projectName
+                        that.InvitationOfficialActivities.diId = that.DiIdSelect;
+                        that.InvitationOfficialActivities.createUserId = that.userId;
+                        var url = "/api/Groups/OpInvitationOfficialActivities"
+                        that.$axios({
+                            method: 'post',
+                            url: url,
+                            headers: {
+                                Authorization: 'Bearer ' + that.token
+                            },
+                            data: that.InvitationOfficialActivities
+                        }).then(function (res) {
+                            if (res.data.code == 200) {
+                                that.$message({
+                                    message: res.data.msg,
+                                    type: 'success'
+                                });
+                                setTimeout(() => {
+                                    that.cancelbtn()
+                                }, 500);
                             } else {
                             } else {
-                                that.InvitationOfficialActivities.attachment = that.projectName
-                                that.InvitationOfficialActivities.diId = that.DiIdSelect;
-                                that.InvitationOfficialActivities.createUserId = that.userId;
-                                var url = "/api/Groups/OpInvitationOfficialActivities"
-                                that.$axios({
-                                    method: 'post',
-                                    url: url,
-                                    headers: {
-                                        Authorization: 'Bearer ' + that.token
-                                    },
-                                    data: that.InvitationOfficialActivities
-                                }).then(function (res) {
-                                    if (res.data.code == 200) {
-                                        that.$message({
-                                            message: res.data.msg,
-                                            type: 'success'
-                                        });
-                                        setTimeout(() => {
-                                            that.cancelbtn();
-                                        }, 500);
-                                    } else {
-                                        that.$message.error(res.data.msg);
-                                    }
-                                })
+                                that.$message.error(res.data.msg);
                             }
                             }
-
-                        }
+                        })
                     } else {
                     } else {
                         this.$message.error('请完善信息在保存!');
                         this.$message.error('请完善信息在保存!');
                         return false;
                         return false;
@@ -968,23 +912,23 @@ export default {
         //文件上传成功时的钩子
         //文件上传成功时的钩子
         upLoadSuccess(response, file, fileList) {
         upLoadSuccess(response, file, fileList) {
             if (response.code == 200) {
             if (response.code == 200) {
-                var that = this;
-                that.$axios({
-                    method: 'post',
-                    url: "/api/Groups/DelFile",
-                    headers: {
-                        Authorization: 'Bearer ' + that.token
-                    },
-                    data: {
-                        fileName: that.DelfileName,
-                        id: that.id
-                    }
-                }).then(function (res) {
-                    if (res.data.code == 200) {
+                // var that = this;
+                // that.$axios({
+                //     method: 'post',
+                //     url: "/api/Groups/DelFile",
+                //     headers: {
+                //         Authorization: 'Bearer ' + that.token
+                //     },
+                //     data: {
+                //         fileName: that.DelfileName,
+                //         id: that.id
+                //     }
+                // }).then(function (res) {
+                //     if (res.data.code == 200) {
 
 
-                    }
-                })
-                that.InvitationOfficialActivities.attachment = response.data
+                //     }
+                // })
+                // that.InvitationOfficialActivities.attachment = response.data
                 that.InvitationOfficialActivities.diId = that.DiIdSelect;
                 that.InvitationOfficialActivities.diId = that.DiIdSelect;
                 that.InvitationOfficialActivities.createUserId = that.userId;
                 that.InvitationOfficialActivities.createUserId = that.userId;
                 var url = "/api/Groups/OpInvitationOfficialActivities"
                 var url = "/api/Groups/OpInvitationOfficialActivities"
@@ -1003,7 +947,7 @@ export default {
                         });
                         });
                         that.loading = true;
                         that.loading = true;
                         setTimeout(() => {
                         setTimeout(() => {
-                            that.$router.push('/home/InvitationOfficialActivities')
+                            that.$router.push('/home/InvitationOfficialActivities?DiId='+that.DiIdSelect)
                         }, 500);
                         }, 500);
                     } else {
                     } else {
                         that.$message.error(res.data.msg);
                         that.$message.error(res.data.msg);
@@ -1015,23 +959,105 @@ export default {
             }
             }
 
 
         },
         },
+        //上传服务器
+        submitUpload(val) {
+            //判断是否有文件再上传
+            var verdict=false
+            if (this.uploadFiles.length === 0) {
+                return this.$message.warning('请选取文件后再上传');
+            }
+            // 下面的代码将创建一个空的FormData对象:
+            const formData = new FormData()
+            // 你可以使用FormData.append来添加键/值对到表单里面;
+            this.uploadFiles.forEach((file) => {
+                if(file.raw!=undefined){
+                    verdict=true;
+                    formData.append('files', file.raw);
+                }
+            })
+            if(!verdict){
+                return
+            }
+            var that = this;
+            var url = "/api/Groups/UploadProjects"
+            this.$axios({
+                method: 'post',
+                url: url,
+                headers: {
+                    Authorization: 'Bearer ' + that.token,
+                    TypeName: "B"
+                },
+                data:formData
+            }).then(function (res) {
+                if (res.data.code == 200) {
+                    
+                } else {
+                    that.$message.error(res.data.msg);
+                }
+            })
+        },
         //文件上传失败时的钩子
         //文件上传失败时的钩子
         upLoadError(response, file, fileList) {
         upLoadError(response, file, fileList) {
             console.log("项目添加失败");
             console.log("项目添加失败");
         },
         },
-        beforeRemove(file, fileList) {
-            console.log(file.name)
-            let id1 = this.uploadFiles.findIndex(item => {
-                if (item.name == file.name) {
-                    return true
+        //删除文件
+        beforeRemove(file,fileList){
+            if(file && file.status=="success"){
+                return this.$confirm('此文件已上传至服务器此操作将永久删除该文件, 是否继续?', '提示', {
+                    confirmButtonText: '确定',
+                    cancelButtonText: '取消',
+                    type: 'warning'
+                }).then(() => {
+                    
+                    
+                }).catch(() => {
+                    this.$message({
+                        type: 'info',
+                        message: '已取消删除'
+                    });     
+                    reject(false)     
+                });
+            }else{
+                let id1 = this.projectName.findIndex(item => {
+                    if (item.name == file.name) {
+                        return true
+                    }
+                })
+                this.projectName.splice(id1, 1)
+            }
+        },
+        handleRemove(file, fileList) {
+            var that = this;
+            that.$axios({
+                method: 'post',
+                url: "/api/Groups/DelFile",
+                headers: {
+                    Authorization: 'Bearer ' + that.token,
+                    typeName:'B'
+                },
+                data: {
+                    fileName: file.name,
+                    id: that.id,
+                }
+            }).then(function (res) {
+                if (res.data.code == 200) {
+                    let id1 = that.projectName.findIndex(item => {
+                        if (item.name == file.name) {
+                            return true
+                        }
+                    })
+                    that.projectName.splice(id1, 1)
+                    that.$message({
+                        type: 'success',
+                        message: res.data.msg
+                    });
                 }
                 }
             })
             })
-            this.uploadFiles.splice(id1, 1)
-            this.projectName = ""
-            this.DelfileName = file.name
+            
         },
         },
         onChange(file, fileList) { 
         onChange(file, fileList) { 
-            this.projectName.push(file.name);
+            this.uploadFiles = fileList;
+            this.projectName.push(file.name)
         },
         },
         QueryRate() {
         QueryRate() {
             var url = "/api/Business/PostGroupTeamRateByDiIdAndCTableId"
             var url = "/api/Business/PostGroupTeamRateByDiIdAndCTableId"