Browse Source

修改用印模块附件上传

jwyu 3 years ago
parent
commit
5df4cfde2f

+ 2 - 1
pages-approve/seal/addSeal.vue

@@ -75,7 +75,7 @@
 		</view>
 		<view class="section white-wrap" v-if="radioVal==='上传附件'">
 			<view class="section-title require">附件上传</view>
-			<div class="check-file-box" :style="'background-image:url('+file.url+')'" v-if="file.url" @click="handlePreviewFiles(file)">
+			<div class="check-file-box" :style="'background-image:url('+file.img+')'" v-if="file.url" @click="handlePreviewFiles(file)">
 				<image class="del-icon" src="../static/del-icon.png" @click.stop="handleDeleteCheckFile"></image>
 			</div>
 			<image v-else @click="handleUpload" src="../static/upload-icon.png" mode="aspectFill" style="width: 102rpx;height: 120rpx;"></image>
@@ -457,6 +457,7 @@
 		width: 102rpx;
 		height: 120rpx;
 		background-size: cover;
+		background-position: center;
 		position: relative;
 		.del-icon{
 			position: absolute;

+ 71 - 40
pages-approve/seal/detail.vue

@@ -32,25 +32,19 @@
 		<view class="section white-wrap" v-if="detail.ContractId>0">
 			<view class="section-title require">合同附件</view>
 			<image 
-				:src="item.img" 
+				:src="files.img" 
 				mode="aspectFill" 
-				style="width: 102rpx;height: 120rpx;margin:0 10rpx 10rpx 0" 
-				v-for="item in files" 
-				:key="item.url"
-				@click="handlepreViewFile(item)">
+				style="width: 102rpx;height: 120rpx" 
+				@click="handlepreViewFile(files)">
 			</image>
 		</view>
 		<view class="section white-wrap" v-else>
 			<view class="section-title require">合同附件</view>
 			<!-- 合规可修改上传 -->
-			<image 
-				:src="item.img" 
-				mode="aspectFill" 
-				style="width: 102rpx;height: 120rpx;margin:0 10rpx 10rpx 0" 
-				v-for="item in files" 
-				:key="item.url"
-				@click="handlepreViewFile(item)">
-			</image>
+			<div class="check-file-box" :style="'background-image:url('+files.img+')'" v-if="files.url" @click="handlepreViewFile(files)">
+				<image class="del-icon" src="../static/del-icon.png" @click.stop="handleDeleteCheckFile" v-if="opButton.CheckEdit"></image>
+			</div>
+			<image v-else @click="handleUpload" src="../static/upload-icon.png" mode="aspectFill" style="width: 102rpx;height: 120rpx;"></image>
 		</view>
 		<view class="section white-wrap" v-if="detail.Status==='已驳回'">
 			<view class="section-title">驳回理由</view>
@@ -153,6 +147,7 @@
 		} from '@/api/approve/seal.js'
 	import steps from '../components/steps.vue'
 	import {preViewFile} from '../utils/util.js'
+	import {uploadFiles} from '@/utils/uploadFile.js'
 	export default{
 		components:{
 			steps
@@ -180,7 +175,11 @@
 				processData:null,
 				detail:{},
 				opButton:{},
-				files:[],
+				files:{
+					type:'',
+					img:'',
+					url:''
+				},//合同附件
 				
 				showPurpose:false,//显示用印用途选项
 				purposeArr:['销售合同','渠道合同','付款通知涵','招投标','战略合作协议'],
@@ -215,6 +214,34 @@
 			},1000)
 		},
 		methods: {
+			// 合规删除合同附件
+			handleDeleteCheckFile(){
+				this.files={
+					type:'',
+					img:'',
+					url:''
+				}
+			},
+
+			//合规上传附件
+			async handleUpload(){
+				const res=await uploadFiles({type:'all'})
+				const reg = /\.(pdf)$/;
+				if(reg.test(res[0])){
+					this.files={
+						type:'pdf',
+						url:res[0],
+						img:require('../static/pdf.png')
+					}
+				}else{
+					this.files={
+						type:'img',
+						url:res[0],
+						img:res[0]
+					}
+				}
+			},
+
 			// 撤回申请
 			handleCancelApply(){
 				this.$dialog.confirm({
@@ -282,7 +309,8 @@
 				const flag2=Number(this.oldFileNum)===Number(this.detail.FileNum)
 				const flag3=this.oldSealType===this.detail.SealType
 				const flag4=this.oldRemark===this.detail.Remark
-				if(flag1&&flag2&&flag3&&flag4){
+				const flag5=this.files.url===this.detail.FileUrl
+				if(flag1&&flag2&&flag3&&flag4&&flag5){
 					this.handleApprovalPass()
 				}else{
 					this.handleApprovePassModify()
@@ -296,7 +324,8 @@
 					Remark:this.oldRemark,
 					SealId:Number(this.detail.SealId),
 					SealType:this.oldSealType,
-					Use:this.oldUse
+					Use:this.oldUse,
+					FileUrl:this.files.url
 				})
 				if(res.code===200){
 					this.$dialog.alert({
@@ -324,8 +353,6 @@
 				}
 			},
 			
-			
-			
 			//驳回
 			handleApprovalReject(){
 				uni.navigateTo({
@@ -351,13 +378,6 @@
 				}
 			},
 			
-			//销售自己单独能修改的项
-			handleSelfOperation(key){
-				if(this.opButton.Edit){
-					this[key]=true
-				}
-			},
-			
 			// 客户搜索
 			// 先搜索出客户 再通过客户去请求出客户下面存在的合同
 			onSearchValChange(e){
@@ -426,28 +446,39 @@
 			//处理文件
 			handleFile(filesUrl){
 				const reg = /\.(pdf)$/;
-				let arr=filesUrl.split('#')
-				this.files=arr.map(item=>{
-					if (reg.test(item)) {
-						return {
-							type: "pdf",
-							url: item,
-							img: require("../static/pdf.png"),
-						};
-					} else {
-						return {
-							type: "img",
-							url: item,
-							img: item,
-						};
+				if(reg.test(filesUrl)){
+					this.files={
+						type: "pdf",
+						url: filesUrl,
+						img: require("../static/pdf.png"),
 					}
-				})
+				}else{
+					this.files={
+						type: "img",
+						url: filesUrl,
+						img: filesUrl,
+					}
+				}
 			},
 		},
 	}
 </script>
 
 <style lang="scss">
+	.check-file-box{
+		width: 102rpx;
+		height: 120rpx;
+		background-size: cover;
+		background-position: center;
+		position: relative;
+		.del-icon{
+			position: absolute;
+			width: 30rpx;
+			height: 30rpx;
+			top: -15rpx;
+			right: -15rpx;
+		}
+	}
 	.detail{
 		width: 100%;
 		min-height: 100vh;

+ 88 - 18
pages-approve/seal/edit.vue

@@ -62,14 +62,18 @@
 			<view class="section-title">备注</view>
 			<textarea type="text" v-model="remark" placeholder="请填写备注"></textarea>
 		</view>
-		<view class="section white-wrap" v-if="radioVal==='系统合同'&&ContractfileUrl">
+		<view class="section white-wrap" v-if="radioVal==='系统合同'&&file">
 			<view class="section-title require">合同附件</view>
-			<image src="../static/pdf.png" mode="aspectFill" style="width: 102rpx;height: 120rpx;"></image>
+			<image src="../static/pdf.png" mode="aspectFill" style="width: 102rpx;height: 120rpx;" @click="handlePreviewFiles(file)"></image>
 		</view>
 		<view class="section white-wrap" v-if="radioVal==='上传附件'">
 			<view class="section-title require">附件上传</view>
-			<image :src="img" mode="aspectFill" style="width: 102rpx;height: 120rpx;margin:0 10rpx 10rpx 0" v-for="img in fileUrlArr" :key="img"></image>
-			<image @click="handleUpload" src="../static/upload-icon.png" mode="aspectFill" style="width: 102rpx;height: 120rpx;margin:0 10rpx 10rpx 0"></image>
+			<!-- <image :src="img" mode="aspectFill" style="width: 102rpx;height: 120rpx;margin:0 10rpx 10rpx 0" v-for="img in fileUrlArr" :key="img"></image>
+			<image @click="handleUpload" src="../static/upload-icon.png" mode="aspectFill" style="width: 102rpx;height: 120rpx;margin:0 10rpx 10rpx 0"></image> -->
+			<div class="check-file-box" :style="'background-image:url('+file.img+')'" v-if="file.url" @click="handlePreviewFiles(file)">
+				<image class="del-icon" src="../static/del-icon.png" @click.stop="handleDeleteCheckFile"></image>
+			</div>
+			<image v-else @click="handleUpload" src="../static/upload-icon.png" mode="aspectFill" style="width: 102rpx;height: 120rpx;"></image>
 		</view>
 		
 		<!-- 流程模块 -->
@@ -151,7 +155,8 @@
 <script>
 	import steps from '../components/steps.vue'
 	import {apiFlowDetail,apiSealEdit,apiSearchCustome,apiSearchContract,apiSealDetail} from '@/api/approve/seal.js'
-	import {uploadImg} from '@/utils/uploadFile.js'
+	import {uploadFiles} from '@/utils/uploadFile.js'
+	import {preViewFile} from '../utils/util.js'
 	export default{ 
 		components:{
 			steps
@@ -180,9 +185,15 @@
 				
 				UseCompanyName:'',//实际使用方客户名称
 				ContractId:0,//合同id
-				ContractfileUrl:'',//合同文件地址 pdf
+				// ContractfileUrl:'',//合同文件地址 pdf
 				
-				fileUrlArr:[],//上传附件 文件地址
+				// fileUrlArr:[],//上传附件 文件地址
+
+				file:{
+					type:'',
+					img:'',
+					url:''
+				},
 				
 				processData:null,//流程数据
 				
@@ -199,6 +210,26 @@
 			this.getDetail({ContractApprovalId,ContractApprovalRecordId})
 		},
 		methods: {
+			//删除上传的附件
+			handleDeleteCheckFile(){
+				this.file={
+					type:'',
+					img:'',
+					url:''
+				}
+			},
+
+			//预览文件
+			handlePreviewFiles(e){
+				if (e.type === "pdf") {
+					preViewFile(e.url)
+				} else {
+					uni.previewImage({
+						urls: [e.url]
+					})
+				}
+			},
+
 			// 获取详情
 			async getDetail({ContractApprovalId,ContractApprovalRecordId}){
 				const res=await apiSealDetail({
@@ -208,7 +239,6 @@
 				if(res.code===200){
 					if(res.data.SealDetail.ContractId>0){
 						this.radioVal='系统合同'
-						
 					}else{
 						this.radioVal='上传附件'
 					}
@@ -221,16 +251,48 @@
 					this.remark=res.data.SealDetail.Remark
 					this.CreditCode=res.data.SealDetail.CreditCode
 					this.UseCompanyName=res.data.SealDetail.UseCompanyName
-					this.ContractfileUrl=res.data.SealDetail.FileUrl
+					// this.ContractfileUrl=res.data.SealDetail.FileUrl
+					this.handleFile(res.data.SealDetail.FileUrl)
 					this.ContractId=res.data.SealDetail.ContractId
 					this.getProcessData()
 				}
 			},
+
+			//处理文件
+			handleFile(filesUrl){
+				const reg = /\.(pdf)$/;
+				if(reg.test(filesUrl)){
+					this.file={
+						type: "pdf",
+						url: filesUrl,
+						img: require("../static/pdf.png"),
+					}
+				}else{
+					this.file={
+						type: "img",
+						url: filesUrl,
+						img: filesUrl,
+					}
+				}
+			},
 			
 			//上传附件
 			async handleUpload(){
-				const res=await uploadImg()
-				this.fileUrlArr=res
+				const res=await uploadFiles({type:'all'})
+				const reg = /\.(pdf)$/;
+				if(reg.test(res[0])){
+					this.file={
+						type:'pdf',
+						url:res[0],
+						img:require('../static/pdf.png')
+					}
+				}else{
+					this.file={
+						type:'img',
+						url:res[0],
+						img:res[0]
+					}
+				}
 			},
 			
 			// 客户搜索 
@@ -316,18 +378,12 @@
 			
 			// 提交申请
 			async handleSubmit(){
-				let fileUrl=''
-				if(this.radioVal==='系统合同'){
-					fileUrl=this.ContractfileUrl
-				}else{
-					fileUrl=this.fileUrlArr.join('#')
-				}
 				
 				let params={
 					CompanyName:this.customeName,
 					ContractId:this.ContractId,
 					CreditCode:this.CreditCode,
-					FileUrl:fileUrl,
+					FileUrl:this.file.url,
 					FileNum:Number(this.fileNum),
 					Remark:this.remark,
 					SealType:this.type,
@@ -412,6 +468,20 @@
 </script>
 
 <style lang="scss">
+	.check-file-box{
+		width: 102rpx;
+		height: 120rpx;
+		background-size: cover;
+		background-position: center;
+		position: relative;
+		.del-icon{
+			position: absolute;
+			width: 30rpx;
+			height: 30rpx;
+			top: -15rpx;
+			right: -15rpx;
+		}
+	}
 	.add-page{
 		width: 100%;
 		min-height: 100vh;

+ 1 - 1
pages-approve/seal/list.vue

@@ -131,7 +131,7 @@
 								saller:item.UserName,
 								submitTime:item.CreateTime,
 								approveTime:item.ApproveTime,
-								backTime:'',
+								backTime:item.ModifyTime,
 								cancelTime:item.InvalidTime,
 								status:item.Status,
 								applyType:item.SealType,

+ 5 - 1
pages-todomessages/list/list.vue

@@ -31,7 +31,11 @@
 	export default {
 		filters:{
 			formatTime(e){
-				return e.replace(/-/g,'.')
+				if(e==='0001-01-01T00:00:00Z'){
+					return ''
+				}else{
+					return e.replace(/T/g,' ').replace(/\+08:00/g,' ').replace(/-/g,'.')
+				}
 			}
 		},
 		data() {