浏览代码

修改上传回签附件

jwyu 3 年之前
父节点
当前提交
2d0782ca24
共有 4 个文件被更改,包括 212 次插入86 次删除
  1. 16 3
      api/approve/contract.js
  2. 16 3
      api/approve/seal.js
  3. 104 53
      pages-approve/contract/detail.vue
  4. 76 27
      pages-approve/seal/detail.vue

+ 16 - 3
api/approve/contract.js

@@ -2,7 +2,9 @@
  * 审批模块(合同)
  */
 import {httpGet,httpPost} from "@/utils/request.js"
-
+import {baseUrl} from '@/utils/config.js'
+import store from '@/store/index.js'
+import uniAsync from '@/utils/uni-async.js'// uni api async 化
 /**
  * 合同审批列表
  * @param {string} ContractType 合同类型,枚举值:’新签合同’,’续约合同’,’补充协议’
@@ -80,8 +82,19 @@ export const apiContractList=params=>{
 /**
  * 合同回签附件
  * @param {int}  ContractId 合同id
- * @param {string}  FileUrl  文件地址 多个用#隔开
+ * @param {string}  FileUrl  临时文件地址
  */
 export const apiContractSignBackFiles=params=>{
-	return httpPost('/contract/upload_check_back_file',params)
+	// return httpPost('/contract/upload_check_back_file',params)
+	return uniAsync.uploadFile({
+		url:baseUrl+'/contract/upload_check_back_file',
+		filePath:params.tempPath,
+		name:'file',
+		header:{
+			Authorization:store.state.token
+		},
+		formData:{
+			ContractId:params.ContractId
+		}
+	})
 }

+ 16 - 3
api/approve/seal.js

@@ -2,7 +2,9 @@
  * 审批模块(用印)
  */
 import {httpGet,httpPost} from "@/utils/request.js"
-
+import {baseUrl} from '@/utils/config.js'
+import store from '@/store/index.js'
+import uniAsync from '@/utils/uni-async.js'// uni api async 化
 /**
  * 获取审批流详情(目前crm1.0 只在发起用印申请时需要调用此接口)
  * @param {int} FlowId 审批流程id;1:ficc客户审批;2:权益客户审批;3:ficc合同审批,4:权益合同审批,5:用印审批
@@ -129,8 +131,19 @@ export const apiSealList=params=>{
 /** 
  * 上传用印签回附件
  * @param {int}  SealId 用印id
- * @param {string}  FileUrl  文件地址 多个用#隔开
+ * @param {string}  FileUrl  文件地址 临时地址
  */
 export const apiSealCheckBackFiles=params=>{
-	return httpPost('/seal/upload_check_back_file',params)
+	// return httpPost('/seal/upload_check_back_file',params)
+	return uniAsync.uploadFile({
+		url:baseUrl+'/seal/upload_check_back_file',
+		filePath:params.tempPath,
+		name:'file',
+		header:{
+			Authorization:store.state.token
+		},
+		formData:{
+			SealId:params.SealId
+		}
+	})
 }

+ 104 - 53
pages-approve/contract/detail.vue

@@ -153,21 +153,13 @@
 		</view>
 		<!-- 上传回签附件 -->
 		<view class="fix-bottom-wrap btns-wrap flex" v-if="opt.UploadFile">
-			<button class="pass-btn" style="width: 450rpx;" @click="handleUploadMethod('file')">{{detail.Status==='已审批'?'上传回签附件':'更新回签附件'}}</button>
+			<button class="pass-btn" style="width: 450rpx;" @click="handleUploadCheckFile">{{detail.Status==='已审批'?'上传回签附件':'更新回签附件'}}</button>
 		</view>
 		<!-- 作废合同 -->
 		<!-- <view class="fix-bottom-wrap btns-wrap flex" v-if="opt.Invalid">
 			<button class="refuse-btn" style="width: 450rpx;" >作废合同</button>
 		</view> -->
 		
-		<!-- 上传回签附件选择上传文件类型弹窗 -->
-		<van-popup :show="show" @close="show=false" round>
-			<view style="width: 50vw;text-align: center;font-size: 16px;padding: 32rpx;line-height: 80rpx;">
-				<view @click="handleUploadMethod('img')">上传图片</view>
-				<view @click="handleUploadMethod('file')">上传文件</view>
-			</view>
-		</van-popup>
-		
 		<!-- 上传回签附件弹窗确认弹窗 -->
 		<van-popup :show="showUpload" @close="showUpload=false" position="bottom" round>
 			<view class="uploadfile-wrap">
@@ -178,7 +170,7 @@
 						<image class="contract-img" mode="aspectFill" :src="item.img"></image>
 					</view>
 				</view>
-				<button style="width: 450rpx;" @click='handleConfirmSignBack'>确定</button>
+				<button style="width: 450rpx;" @click='handleConfirmCheckFile'>确定</button>
 			</view>
 		</van-popup>
 		
@@ -312,9 +304,8 @@
 				detail:null,
 				flowNodeList:null,
 				opt:{},
-				show:false,
 				showUpload:false,
-				files:[],
+				files:[],//签回附件
 				varietyList:[],
 			}
 		},
@@ -342,13 +333,42 @@
 			},1000)
 		},
 		methods: {
+			// 点击上传回签附件
+			handleUploadCheckFile(){
+				wx.chooseMessageFile({
+					count:1,
+					type:'file',
+					success:(res)=>{
+						const tempFile=res.tempFiles[0]
+						const reg = /\.(pdf)$/;
+						const reg2=	/\.doc|\.docx$/
+						if(!reg.test(tempFile.path)&&!reg2.test(tempFile.path)){
+							uni.showToast({
+								title:'请上传pdf/word格式文件',
+								icon:"none"
+							})
+							return 
+						}
+						// pdf
+						if(reg.test(tempFile.path)){
+							this.files=[{type:'pdf',url:tempFile.path,img: require("@/pages-approve/static/pdf.png")}]
+						}
+						if(reg2.test(tempFile.path)){
+							this.files=[{type:'word',url:tempFile.path,img: require("@/pages-approve/static/word.png")}]
+						}
+
+						this.showUpload=true
+					}
+				})
+			},
+
 			//确认提交上传回签附件
-			async handleConfirmSignBack(){
-				let FileUrlarr=this.files.map(item=>item.url)
-				const res=await apiContractSignBackFiles({
+			async handleConfirmCheckFile(){
+				const temres=await apiContractSignBackFiles({
+					tempPath:this.files[0].url,
 					ContractId:Number(this.detail.ContractId),
-					FileUrl:FileUrlarr.join('#')
 				})
+				const res=JSON.parse(temres.data)
 				if(res.code===200){
 					uni.showToast({
 						title:'操作成功',
@@ -373,42 +393,73 @@
 					},1000)
 				}
 			},
+
+			// 签回修改 只允许上传一个pdf/word
+			// async handleConfirmSignBack(){
+			// 	let FileUrlarr=this.files.map(item=>item.url)
+			// 	const res=await apiContractSignBackFiles({
+			// 		ContractId:Number(this.detail.ContractId),
+			// 		FileUrl:FileUrlarr.join('#')
+			// 	})
+			// 	if(res.code===200){
+			// 		uni.showToast({
+			// 			title:'操作成功',
+			// 			icon:'none'
+			// 		})
+			// 		// 已审批上传签回附件更新列表
+			// 		if(this.detail.Status==='已审批'){
+			// 			uni.$emit('contractApproveListUpdate',{
+			// 				ContractApprovalId:this.ContractApprovalId,
+			// 				ContractApprovalRecordId:this.ContractApprovalRecordId,
+			// 				ContractId:this.ContractId
+			// 			})
+			// 		}
+			// 		setTimeout(()=>{
+			// 			this.showUpload=false
+			// 			this.files=[]
+			// 			if(this.ContractId!=0){
+			// 				this.getContractDetail()
+			// 			}else{
+			// 				this.getApprovalDetail()
+			// 			}
+			// 		},1000)
+			// 	}
+			// },
 			
-			// 上传回签附件文件
-			async handleUploadMethod(type){
-				let res=[]
-				if(type==='img'){
-					res=await uploadImg()
-				}else if(type==='file'){
-					res=await uploadFiles({type:'file'})
-				}
-				const reg = /\.(pdf)|\.doc|\.docx$/;
-				if(!reg.test(res[0])){
-					uni.showToast({
-						title:'请上传pdf/word格式文件',
-						icon:"none"
-					})
-					return 
-				}
-				this.files=[{type:'pdf',url:res[0],img: require("@/pages-approve/static/pdf.png")}]
-				// this.files=res.map((item) => {
-				// 	if (reg.test(item)) {
-				// 		return {
-				// 			type: "pdf",
-				// 			url: item,
-				// 			img: require("@/pages-approve/static/pdf.png"),
-				// 		};
-				// 	} else {
-				// 		return {
-				// 			type: "img",
-				// 			url: item,
-				// 			img: item,
-				// 		};
-				// 	}
-				// });
-				this.show=false
-				this.showUpload=true
-			},
+			// // 上传回签附件文件
+			// async handleUploadMethod(type){
+			// 	let res=[]
+			// 	if(type==='img'){
+			// 		res=await uploadImg()
+			// 	}else if(type==='file'){
+			// 		res=await uploadFiles({type:'file'})
+			// 	}
+			// 	const reg = /\.(pdf)|\.doc|\.docx$/;
+			// 	if(!reg.test(res[0])){
+			// 		uni.showToast({
+			// 			title:'请上传pdf/word格式文件',
+			// 			icon:"none"
+			// 		})
+			// 		return 
+			// 	}
+			// 	this.files=[{type:'pdf',url:res[0],img: require("@/pages-approve/static/pdf.png")}]
+			// 	// this.files=res.map((item) => {
+			// 	// 	if (reg.test(item)) {
+			// 	// 		return {
+			// 	// 			type: "pdf",
+			// 	// 			url: item,
+			// 	// 			img: require("@/pages-approve/static/pdf.png"),
+			// 	// 		};
+			// 	// 	} else {
+			// 	// 		return {
+			// 	// 			type: "img",
+			// 	// 			url: item,
+			// 	// 			img: item,
+			// 	// 		};
+			// 	// 	}
+			// 	// });
+			// 	this.showUpload=true
+			// },
 			
 			// 审批单详情
 			async getApprovalDetail() {
@@ -420,7 +471,7 @@
 					this.detail=res.data.ContractDetail
 					this.opt=res.data.OpButton
 					this.flowNodeList=res.data.FlowNodeList
-					this.handleVariety(res.data.ContractDetail.Service)
+					this.handleVariety(res.data.ContractDetail.Service||[])
 					// 代付合同时
 					if(res.data.ContractDetail.ContractBusinessType==='代付合同'){
 						this.detail.Service=res.data.ContractDetail.RelationContractDetailList[0].Service
@@ -435,7 +486,7 @@
 					this.detail=res.data.ContractDetail
 					this.opt=res.data.OpButton
 					this.flowNodeList=res.data.FlowNodeList
-					this.handleVariety(res.data.ContractDetail.PermissionLookList)
+					this.handleVariety(res.data.ContractDetail.PermissionLookList||[])
 					// 代付合同时
 					if(res.data.ContractDetail.ContractBusinessType==='代付合同'){
 						this.detail.Service=res.data.ContractDetail.RelationContractDetailList[0].Service

+ 76 - 27
pages-approve/seal/detail.vue

@@ -279,39 +279,65 @@
 		},
 		methods: {
 			// 上传(更新)签回附件
-			async handleUploadCheckFile(){
-				const res=await uploadFiles({type:'file'})
-				const reg = /\.(pdf)$/;
-				const reg2=	/\.doc|\.docx$/
-				if(reg.test(res[0])){
-					this.checkBackFiles=[{
-						type:'pdf',
-						url:res[0],
-						img:require('../static/pdf.png')
-					}]
-					this.showConfirmCheckBackfile=true
-				}else if(reg2.test(res[0])){
-					this.checkBackFiles=[{
-						type:'word',
-						url:res[0],
-						img:require('../static/word.png')
-					}]
-					this.showConfirmCheckBackfile=true
-				}else{
-					uni.showToast({
-						title:'请上传pdf/word格式文件',
-						icon:"none"
-					})
-				}
+			handleUploadCheckFile(){
+				wx.chooseMessageFile({
+					count:1,
+					type:'file',
+					success:(res)=>{
+						const tempFile=res.tempFiles[0]
+						const reg = /\.(pdf)$/;
+						const reg2=	/\.doc|\.docx$/
+						if(!reg.test(tempFile.path)&&!reg2.test(tempFile.path)){
+							uni.showToast({
+								title:'请上传pdf/word格式文件',
+								icon:"none"
+							})
+							return 
+						}
+						// pdf
+						if(reg.test(tempFile.path)){
+							this.checkBackFiles=[{type:'pdf',url:tempFile.path,img: require("@/pages-approve/static/pdf.png")}]
+						}
+						if(reg2.test(tempFile.path)){
+							this.checkBackFiles=[{type:'word',url:tempFile.path,img: require("@/pages-approve/static/word.png")}]
+						}
+
+						this.showConfirmCheckBackfile=true
+					}
+				})
+
+				// const res=await uploadFiles({type:'file'})
+				// const reg = /\.(pdf)$/;
+				// const reg2=	/\.doc|\.docx$/
+				// if(reg.test(res[0])){
+				// 	this.checkBackFiles=[{
+				// 		type:'pdf',
+				// 		url:res[0],
+				// 		img:require('../static/pdf.png')
+				// 	}]
+				// 	this.showConfirmCheckBackfile=true
+				// }else if(reg2.test(res[0])){
+				// 	this.checkBackFiles=[{
+				// 		type:'word',
+				// 		url:res[0],
+				// 		img:require('../static/word.png')
+				// 	}]
+				// 	this.showConfirmCheckBackfile=true
+				// }else{
+				// 	uni.showToast({
+				// 		title:'请上传pdf/word格式文件',
+				// 		icon:"none"
+				// 	})
+				// }
 			},
 
 			//确认上传的签回附件
 			async handleConfirmCheckBackFile(){
-				let FileUrlarr=this.checkBackFiles.map(item=>item.url)
-				const res=await apiSealCheckBackFiles({
+				const temres=await apiSealCheckBackFiles({
 					SealId:Number(this.detail.SealId),
-					FileUrl:FileUrlarr.join('#')
+					tempPath:this.checkBackFiles[0].url
 				})
+				const res=JSON.parse(temres.data)
 				if(res.code===200){
 					uni.showToast({
 						title:'操作成功',
@@ -327,6 +353,29 @@
 						this.getDetail()
 					},500)
 				}
+
+				
+				// let FileUrlarr=this.checkBackFiles.map(item=>item.url)
+				// const res=await apiSealCheckBackFiles({
+				// 	
+				// 	FileUrl:FileUrlarr.join('#')
+				// })
+				// if(res.code===200){
+
+				// 	uni.showToast({
+				// 		title:'操作成功',
+				// 		icon:'none'
+				// 	})
+				// 	// 如果是已审批上传回签附件则更新列表页
+				// 	if(this.detail.Status==='已审批'){
+				// 		this.handleUpdateList()
+				// 	}
+				// 	setTimeout(()=>{
+				// 		this.checkBackFiles=[]
+				// 		this.showConfirmCheckBackfile=false
+				// 		this.getDetail()
+				// 	},500)
+				// }
 			},
 
 			// 更新列表页