Преглед изворни кода

报告查阅从一份改成多份

linweizeng пре 2 година
родитељ
комит
e17c69e080
2 измењених фајлова са 156 додато и 105 уклоњено
  1. 4 71
      pages/fileView/fileView.vue
  2. 152 34
      pages/fileView/reportList.vue

+ 4 - 71
pages/fileView/fileView.vue

@@ -27,25 +27,15 @@
 
 		},
 		mounted() {
-			window.addEventListener('mousedown', this.handleonmousedown)
+			// window.addEventListener('mousedown', this.handleonmousedown)
 		},
 		onLoad(option) {
 			if (!option.url) {
-				if (option.type) {
-					this.type = option.type
-				}
-				if (this.type == 1) {
-					this.getDe(option.fileId)
-				} else {
-					this.getDe2(option.fileId)
-				}
+				this.getDe(option.fileId)
 			}
 
 		},
 		methods: {
-			handleonmousedown(e) {
-				console.log(e)
-			},
 			/**
 			 * 根据报告的id查询没有盖章文档路径
 			 */
@@ -54,10 +44,8 @@
 				console.log(access_token)
 
 				let sql =
-					`{"sql":"select FILE_PATH_  from ibps_file_attachment  WHERE id_ = (SELECT  bao_gao_pdf_ FROM t_lhjcbgb WHERE id_ = '${id}')"}`
-
-				let md5 = this.sig(sql) //加密, 获取md5密文
-				let requestData = sql.slice(0, 1) + '"sig":"' + md5 + '",' + sql.slice(1) //结果拼接
+					`select FILE_PATH_  from ibps_file_attachment where ID_ = '${id}'`
+				let requestData = this.$sig(sql)
 				this.$http.post("/ibps/business/v3/sys/universal/inputSqlSelectData", requestData).then(res => {
 					if (res.data.state == 200) {
 						const data = res.data.variables.data
@@ -71,61 +59,6 @@
 
 					}
 				})
-			},
-			/**
-			 * 根据报告的id查询有盖章文档路径
-			 */
-			getDe2(id) {
-				let access_token = uni.getStorageSync('Access-Token')
-				console.log(access_token)
-
-				let sql =
-					`{"sql":"select FILE_PATH_  from ibps_file_attachment  WHERE id_ = (SELECT bao_gao_pdf_ FROM t_lhjcbgb WHERE id_ = '${id}')"}`
-
-				let md5 = this.sig(sql) //加密, 获取md5密文
-				let requestData = sql.slice(0, 1) + '"sig":"' + md5 + '",' + sql.slice(1) //结果拼接
-				this.$http.post("/ibps/business/v3/sys/universal/inputSqlSelectData", requestData).then(res => {
-					if (res.data.state == 200) {
-						const data = res.data.variables.data
-						if (data.length > 0) {
-							let dataItem = data[0]
-							let url =
-								http.apiHosp + dataItem.FILE_PATH_
-							console.log(url)
-							this.pdfUrl = '/hybrid/html/web/viewer.html?file=' + encodeURIComponent(url)
-						}
-					}
-				})
-			},
-
-
-			/**
-			 * 下载情景
-			 */
-			downloadPdfClick() {
-				// 下载情景1:h5内嵌app,通过分享给朋友的方式进行下载
-				if (this.from == 'app') {
-					let item = http.apiHosp + 'h5/hybrid/html/web/pdf.html?shareUrl=' + encodeURIComponent(
-							this
-							.bgUrl) +
-						'&shareTitle=PDF文件';
-					window.open(item);
-					return;
-
-				} else if (this.from == 'wx wq') {
-					// 下载情景2:h5内嵌微信小程序,从h5页面跳转到小程序页面后,然后通过调用小程序原生API进行下载
-					// 注意: 先要引入微信jssdk  [命令: npm install jweixin-module]
-					// this.$wx.miniProgram.navigateTo({
-					// 	url: '/pages/pdf/pdf_download?pdf='+ encodeURIComponent(this.bgUrl) //小程序页面链接
-					// });
-				}
-
-			},
-
-			sig(sql) {
-				let rul = (sql.length + 9) * 12 * 3 + 168
-				let salt = "JinYuanXinTong"
-				return md5(rul + '' + salt)
 			}
 		}
 	}

+ 152 - 34
pages/fileView/reportList.vue

@@ -10,7 +10,7 @@
 				<view class="title">样品编号:{{item.yang_pin_bian_hao}}</view>
 				<view class="title">样品名称:{{item.yang_pin_ming_che}}</view>
 				<view class="title">送检批号:{{item.song_jian_pi_hao_}}</view>
-				<view class="title">报告名称:<text style="color: #7349ff;">{{item.FILE_NAME_ || ''}}</text></view>
+				<!-- <view class="title">报告名称:<text style="color: #7349ff;">{{item.FILE_NAME_ || ''}}</text></view> -->
 				<view class="title">版本号:<text style="color: #7349ff;">{{item.run_qian_lu_jing_ || ''}}</text></view>
 				<view class="title">报告类别:{{item.bao_gao_lei_bie_}}</view>
 				<view class="title">报告类型:{{item.bao_gao_lei_xing_}}</view>
@@ -22,9 +22,9 @@
 				<view class="btn">
 					<view>
 						<!-- <u-button type="warning" size="mini" @click="goDe(item.id_)" v-if="item.zhuang_tai_ == '待编制' || item.zhuang_tai_ == '待审核'">修改信息</u-button> -->
-						<u-button type="warning" size="mini" @click="goto(item.id_,'1')" style="margin-left: 10rpx;" v-if="(item.zhuang_tai_ == '待审核' || item.zhuang_tai_ == '待审批') && item.EXT_ != 'docx'">预览报告</u-button>
-						<u-button type="warning" size="mini" @click="goto(item.id_,'2')" style="margin-left: 10rpx;" v-if="item.zhuang_tai_ == '已完成'">查看报告</u-button>
-						<u-button type="primary" size="mini" @click="geDownload(item.bao_gao_pdf_,item.FILE_NAME_, item.EXT_)" style="margin-left: 10rpx;" v-if="(item.zhuang_tai_ == '已完成') || (item.shi_fou_guo_shen_ == '已编制') || (item.zhuang_tai_ == '待审批') || (item.zhuang_tai_ == '待审核')">
+						<u-button type="warning" size="mini" @click="getFileList(item.bao_gao_pdf_,item.qi_ta_bao_gao_,0)" style="margin-left: 10rpx;" v-if="(item.zhuang_tai_ == '待审核' || item.zhuang_tai_ == '待审批') && item.EXT_ != 'docx'">预览报告</u-button>
+						<u-button type="warning" size="mini" @click="getFileList(item.bao_gao_pdf_,item.qi_ta_bao_gao_,1)" style="margin-left: 10rpx;" v-if="item.zhuang_tai_ == '已完成'">查看报告</u-button>
+						<u-button type="primary" size="mini" @click="getFileList(item.bao_gao_pdf_,item.qi_ta_bao_gao_,2)" style="margin-left: 10rpx;" v-if="(item.zhuang_tai_ == '已完成') || (item.shi_fou_guo_shen_ == '已编制') || (item.zhuang_tai_ == '待审批') || (item.zhuang_tai_ == '待审核')">
 							下载报告</u-button>
 					</view>
 				</view>
@@ -39,6 +39,26 @@
 		<u-popup v-model="show" mode="bottom" closeable>
 			<apply ref="apply" :id="id" v-if="show" @saveSuccees='saveSuccees'></apply>
 		</u-popup>
+
+		<u-popup v-model="fileShow" mode="center" width="80%" border-radius="20" @close="fileClose">
+			<view class="fileClass">
+				<h3 class="fileTitle">{{fileNub == 0 ? '预览报告' : fileNub == 1 ? '查阅报告':'下载报告'}}</h3>
+				<view class="fileBox">
+					<view v-for="(item,index) in fileList" :key="item.ID_" @click="fileTypeClick(item)">
+						<view class="fileSin">
+							<u-icon name="coupon"></u-icon>
+							{{item.FILE_NAME_}}
+						</view>
+					</view>
+					<view v-for="(item,index) in qiFileList" :key="item.ID_" @click="fileTypeClick(item)">
+						<view class="fileSin">
+							<u-icon name="coupon"></u-icon>
+							{{item.FILE_NAME_}}
+						</view>
+					</view>
+				</view>
+			</view>
+		</u-popup>
 	</view>
 </template>
 
@@ -62,7 +82,11 @@
 				reportList: [],
 				userid: '',
 				time: '',
-				show: false
+				show: false,
+				fileNub: 0,
+				fileShow: false,
+				fileList: [],
+				qiFileList: []
 			}
 		},
 		onLoad(option) {
@@ -109,35 +133,7 @@
 			*/
 			goto(id, type) {
 				uni.navigateTo({ // 跳转页面
-					url: "/pages/fileView/fileView?fileId=" + id + '&type=' + type
-				})
-			},
-			geDownload(id, item, type) {
-				uni.showLoading({
-					title: '下载中',
-					mask: true
-				})
-				let requestData = {
-					attachmentId: id
-				}
-				this.$http.get(`/ibps/platform/v3/file/download?attachmentId=${id}`, {
-					responseType: 'arraybuffer'
-				}).then(res => {
-					const blob = new Blob([
-						res.data
-					], {
-						type: 'application/octet-stream'
-					})
-					const url = window.URL.createObjectURL(blob)
-					const link = document.createElement('a')
-					link.style.display = 'none'
-					link.href = url
-					link.setAttribute('download', item + '.' + type)
-					document.body.appendChild(link)
-					link.click()
-					window.URL.revokeObjectURL(link.href)
-					document.body.removeChild(link)
-					uni.hideLoading()
+					url: "/pages/fileView/fileView?fileId=" + id
 				})
 			},
 			goDe(id) {
@@ -149,6 +145,102 @@
 				this.reportList = []
 				this.getList(this.yangPinBianHao)
 			},
+			getFileList(ids, itIds, type) {
+				if (!ids) {
+					return uni.showToast({
+						title: '检测已结束,但是报告没有生成,请联系管理员查询,对你的不便,十分抱歉,请见谅',
+						icon: 'none',
+						duration: 2000
+					})
+				}
+
+				this.fileNub = type
+				let list = []
+				if (ids) {
+					let sql1 =
+						`select ID_,FILE_NAME_,FILE_PATH_ from ibps_file_attachment where FIND_IN_SET(ID_,'${ids}')`
+					let requestData1 = this.$sig(sql1)
+					list.push(this.$http.post("/ibps/business/v3/sys/universal/inputSqlSelectData", requestData1))
+				}
+				if (itIds) {
+					let sql2 =
+						`select ID_,FILE_NAME_,FILE_PATH_  from ibps_file_attachment where FIND_IN_SET(ID_,'${itIds}')`
+					let requestData2 = this.$sig(sql2)
+					list.push(this.$http.post("/ibps/business/v3/sys/universal/inputSqlSelectData", requestData2))
+				}
+
+				Promise.all(list).then(res => {
+					console.log(res)
+					if (ids) {
+						let datas = res[0].data.variables.data
+						this.fileList = datas
+						if (itIds) {
+							let datas1 = res[1].data.variables.data
+							this.qiFileList = datas1
+						}
+					} else {
+						let datas = res[0].data.variables.data
+						this.qiFileList = datas
+					}
+					this.fileShow = true
+				})
+			},
+			fileClose() {
+				this.fileList = []
+				this.fileShow = false
+			},
+			fileTypeClick(item) {
+				if (this.fileNub == '1') {
+					this.goto(item.ID_)
+				} else {
+					this.getDe(item.ID_, item)
+				}
+			},
+			getDe(id, item) {
+				let access_token = uni.getStorageSync('Access-Token')
+
+				let sql =
+					`select FILE_PATH_  from ibps_file_attachment  WHERE ID_ = '${id}'`
+
+				let requestData = this.$sig(sql)
+				this.$http.post("/ibps/business/v3/sys/universal/inputSqlSelectData", requestData).then(res => {
+					if (res.data.state == 200) {
+						const data = res.data.variables.data[0]
+						let url =
+							http.apiFile + data.FILE_PATH_
+						uni.getSystemInfo({
+							success: (res) => {
+								// windows | mac为pc端
+								// android | ios为手机端
+								if (res.platform == 'android' || res.platform == 'ios') {
+									var ua = window.navigator.userAgent.toLowerCase();
+									if (ua.match(/MicroMessenger/i) == 'micromessenger') {
+										var iframe = document.createElement('iframe');
+										iframe.style.display = 'none';
+										iframe.src = "javascript: '<script>location.href=\"" + url +
+											"\"<\/script>'";
+										document.getElementsByTagName('body')[0].appendChild(iframe);
+									} else {
+										let a = document.createElement('a')
+										a.target = '_black'
+										// a.download = item.FILE_NAME_ + '.pdf'
+										a.download = item.bao_gao_bian_hao_ + '检测项目' + '.pdf'
+										a.style.display = 'none'
+										// 生成的base64编码
+										a.href = url
+										document.body.appendChild(a)
+										a.click()
+										document.body.removeChild(a)
+									}
+
+								} else {
+									this.$uploades.download(id, item.FILE_NAME_ + '.pdf', this)
+								}
+							}
+						});
+					}
+				})
+			},
 
 
 			/*
@@ -183,4 +275,30 @@
 			}
 		}
 	}
+
+	.fileClass {
+		min-height: 800rpx;
+		max-height: 1200rpx;
+
+		.fileTitle {
+			text-align: center;
+			position: fixed;
+			height: 80rpx;
+			width: 80%;
+			background-color: #fff;
+			z-index: 999;
+			border-radius: 20rpx 20rpx 0 0;
+		}
+
+		.fileBox {
+			padding: 0 10px;
+			position: relative;
+			top: 80rpx;
+
+			.fileSin {
+				padding: 10rpx 0;
+				font-size: 30rpx;
+			}
+		}
+	}
 </style>