reportList.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <view class="container">
  3. <cu-custom bgColor="bg-luohu" :isBack="true">
  4. <block slot="backText">返回</block>
  5. <block slot="content">检测报告</block>
  6. </cu-custom>
  7. <view class="box" v-if="reportList.length > 0">
  8. <view class="sinList" v-for="(item,index) in reportList" :key="index">
  9. <view class="title">报告编号:{{item.bao_gao_bian_hao_}}</view>
  10. <view class="title">样品编号:{{item.yang_pin_bian_hao}}</view>
  11. <view class="title">样品名称:{{item.yang_pin_ming_che}}</view>
  12. <view class="title">送检批号:{{item.song_jian_pi_hao_}}</view>
  13. <!-- <view class="title">报告名称:<text style="color: #7349ff;">{{item.FILE_NAME_ || ''}}</text></view> -->
  14. <view class="title">版本号:<text style="color: #7349ff;">{{item.run_qian_lu_jing_ || ''}}</text></view>
  15. <view class="title">报告类别:{{item.bao_gao_lei_bie_}}</view>
  16. <view class="title">报告类型:{{item.bao_gao_lei_xing_}}</view>
  17. <!-- <view class="title">联系人:{{item.wei_tuo_lian_xi_r}}</view> -->
  18. <view class="title">报告状态:<text style="color: #7349ff;">{{item.zhuang_tai_}}</text></view>
  19. <view class="title" style="color: #ff9900;" v-if="item.zhuang_tai_ == '待审核' && item.EXT_ == 'docx'">
  20. <u-icon name="question-circle-fill" class="u-m-r-5"></u-icon>该报告是docx格式,需要下载才能预览
  21. </view>
  22. <view class="btn">
  23. <view>
  24. <!-- <u-button type="warning" size="mini" @click="goDe(item.id_)" v-if="item.zhuang_tai_ == '待编制' || item.zhuang_tai_ == '待审核'">修改信息</u-button> -->
  25. <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>
  26. <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>
  27. <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_ == '待审核')">
  28. 下载报告</u-button>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <view v-else>
  34. <uni-card is-full :is-shadow="false">
  35. <text class="">暂无报告</text>
  36. </uni-card>
  37. </view>
  38. <u-popup v-model="show" mode="bottom" closeable>
  39. <apply ref="apply" :id="id" v-if="show" @saveSuccees='saveSuccees'></apply>
  40. </u-popup>
  41. <u-popup v-model="fileShow" mode="center" width="80%" border-radius="20" @close="fileClose">
  42. <view class="fileClass">
  43. <h3 class="fileTitle">{{fileNub == 0 ? '预览报告' : fileNub == 1 ? '查阅报告':'下载报告'}}</h3>
  44. <view class="fileBox">
  45. <view v-for="(item,index) in fileList" :key="item.ID_" @click="fileTypeClick(item)">
  46. <view class="fileSin">
  47. <u-icon name="coupon"></u-icon>
  48. {{item.FILE_NAME_}}
  49. </view>
  50. </view>
  51. <view v-for="(item,index) in qiFileList" :key="item.ID_" @click="fileTypeClick(item)">
  52. <view class="fileSin">
  53. <u-icon name="coupon"></u-icon>
  54. {{item.FILE_NAME_}}
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </u-popup>
  60. </view>
  61. </template>
  62. <script>
  63. import md5 from "@/common/util/md5.js"
  64. import http from "@/common/service/http.js"
  65. import {
  66. ACCESS_TOKEN,
  67. USER_NAME,
  68. USER_INFO
  69. } from "@/common/util/constants"
  70. import apply from './apply.vue'
  71. export default {
  72. components: {
  73. apply
  74. },
  75. data() {
  76. return {
  77. id: '',
  78. yangPinBianHao: '',
  79. reportList: [],
  80. userid: '',
  81. time: '',
  82. show: false,
  83. fileNub: 0,
  84. fileShow: false,
  85. fileList: [],
  86. qiFileList: []
  87. }
  88. },
  89. onLoad(option) {
  90. if (option.reportId) {
  91. this.yangPinBianHao = option.reportId
  92. this.getList(option.reportId)
  93. }
  94. },
  95. created() {
  96. this.getInit()
  97. },
  98. methods: {
  99. getInit() {
  100. let info = uni.getStorageSync(USER_INFO);
  101. if (info.employee.id) {
  102. this.userid = info.employee.id || ''
  103. }
  104. var nowDate = new Date((new Date).getTime() + 8 * 60 * 60 * 1000)
  105. var time = nowDate.toJSON().split('T').join(' ').substr(0, 19)
  106. this.time = time
  107. },
  108. /*
  109. 根据样品编号查询报告礼拜
  110. */
  111. getList(id) {
  112. uni.showLoading({
  113. mask: true,
  114. title: 'loading'
  115. });
  116. //'${id}'
  117. let sql =
  118. `select a.*,b.FILE_NAME_,b.EXT_ from t_lhjcbgb a left join ibps_file_attachment b on a.bao_gao_pdf_ = b.id_ where a.yang_pin_bian_hao = '${id}' ORDER BY a.create_time_ desc`
  119. let requestData = this.$sig(sql)
  120. this.$http.post("/ibps/business/v3/sys/universal/inputSqlSelectData", requestData).then(res => {
  121. if (res.data.state == 200) {
  122. const data = res.data.variables.data
  123. this.reportList = data
  124. uni.hideLoading()
  125. }
  126. })
  127. },
  128. /*
  129. 跳转页面在线查看文档页面
  130. */
  131. goto(id, type) {
  132. uni.navigateTo({ // 跳转页面
  133. url: "/pages/fileView/fileView?fileId=" + id
  134. })
  135. },
  136. goDe(id) {
  137. this.id = id
  138. this.show = true
  139. },
  140. saveSuccees() {
  141. this.show = false
  142. this.reportList = []
  143. this.getList(this.yangPinBianHao)
  144. },
  145. getFileList(ids, itIds, type) {
  146. if (!ids) {
  147. return uni.showToast({
  148. title: '检测已结束,但是报告没有生成,请联系管理员查询,对你的不便,十分抱歉,请见谅',
  149. icon: 'none',
  150. duration: 2000
  151. })
  152. }
  153. this.fileNub = type
  154. let list = []
  155. if (ids) {
  156. let sql1 =
  157. `select ID_,FILE_NAME_,FILE_PATH_ from ibps_file_attachment where FIND_IN_SET(ID_,'${ids}')`
  158. let requestData1 = this.$sig(sql1)
  159. list.push(this.$http.post("/ibps/business/v3/sys/universal/inputSqlSelectData", requestData1))
  160. }
  161. if (itIds) {
  162. let sql2 =
  163. `select ID_,FILE_NAME_,FILE_PATH_ from ibps_file_attachment where FIND_IN_SET(ID_,'${itIds}')`
  164. let requestData2 = this.$sig(sql2)
  165. list.push(this.$http.post("/ibps/business/v3/sys/universal/inputSqlSelectData", requestData2))
  166. }
  167. Promise.all(list).then(res => {
  168. console.log(res)
  169. if (ids) {
  170. let datas = res[0].data.variables.data
  171. this.fileList = datas
  172. if (itIds) {
  173. let datas1 = res[1].data.variables.data
  174. this.qiFileList = datas1
  175. }
  176. } else {
  177. let datas = res[0].data.variables.data
  178. this.qiFileList = datas
  179. }
  180. this.fileShow = true
  181. })
  182. },
  183. fileClose() {
  184. this.fileList = []
  185. this.fileShow = false
  186. },
  187. fileTypeClick(item) {
  188. if (this.fileNub == '1') {
  189. this.goto(item.ID_)
  190. } else {
  191. this.getDe(item.ID_, item)
  192. }
  193. },
  194. getDe(id, item) {
  195. let access_token = uni.getStorageSync('Access-Token')
  196. let sql =
  197. `select FILE_PATH_ from ibps_file_attachment WHERE ID_ = '${id}'`
  198. let requestData = this.$sig(sql)
  199. this.$http.post("/ibps/business/v3/sys/universal/inputSqlSelectData", requestData).then(res => {
  200. if (res.data.state == 200) {
  201. const data = res.data.variables.data[0]
  202. let url =
  203. http.apiFile + data.FILE_PATH_
  204. uni.getSystemInfo({
  205. success: (res) => {
  206. // windows | mac为pc端
  207. // android | ios为手机端
  208. if (res.platform == 'android' || res.platform == 'ios') {
  209. var ua = window.navigator.userAgent.toLowerCase();
  210. if (ua.match(/MicroMessenger/i) == 'micromessenger') {
  211. var iframe = document.createElement('iframe');
  212. iframe.style.display = 'none';
  213. iframe.src = "javascript: '<script>location.href=\"" + url +
  214. "\"<\/script>'";
  215. document.getElementsByTagName('body')[0].appendChild(iframe);
  216. } else {
  217. let a = document.createElement('a')
  218. a.target = '_black'
  219. // a.download = item.FILE_NAME_ + '.pdf'
  220. a.download = item.bao_gao_bian_hao_ + '检测项目' + '.pdf'
  221. a.style.display = 'none'
  222. // 生成的base64编码
  223. a.href = url
  224. document.body.appendChild(a)
  225. a.click()
  226. document.body.removeChild(a)
  227. }
  228. } else {
  229. this.$uploades.download(id, item.FILE_NAME_ + '.pdf', this)
  230. }
  231. }
  232. });
  233. }
  234. })
  235. },
  236. /*
  237. md5加密
  238. */
  239. sig(sql) {
  240. let rul = (sql.length + 9) * 12 * 3 + 168
  241. let salt = "JinYuanXinTong"
  242. return md5(rul + '' + salt)
  243. },
  244. }
  245. }
  246. </script>
  247. <style lang="scss" scoped>
  248. .box {
  249. padding: 20rpx;
  250. .sinList {
  251. padding: 20rpx;
  252. margin-bottom: 20rpx;
  253. width: 100%;
  254. background: #fff;
  255. .title {
  256. line-height: 48rpx;
  257. }
  258. .btn {
  259. display: flex;
  260. justify-content: flex-end;
  261. }
  262. }
  263. }
  264. .fileClass {
  265. min-height: 800rpx;
  266. max-height: 1200rpx;
  267. .fileTitle {
  268. text-align: center;
  269. position: fixed;
  270. height: 80rpx;
  271. width: 80%;
  272. background-color: #fff;
  273. z-index: 999;
  274. border-radius: 20rpx 20rpx 0 0;
  275. }
  276. .fileBox {
  277. padding: 0 10px;
  278. position: relative;
  279. top: 80rpx;
  280. .fileSin {
  281. padding: 10rpx 0;
  282. font-size: 30rpx;
  283. }
  284. }
  285. }
  286. </style>