reportList.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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">报告名称:<text style="color: #7349ff;">{{item.FILE_NAME_ || ''}}</text></view>
  12. <view class="title">样品名称:{{item.yang_pin_ming_che}}</view>
  13. <!-- <view class="title">联系人:{{item.wei_tuo_lian_xi_r}}</view> -->
  14. <view class="title">报告状态:<text style="color: #7349ff;">{{item.zhuang_tai_}}</text></view>
  15. <view class="title" style="color: #ff9900;" v-if="item.zhuang_tai_ == '待审核' && item.EXT_ == 'docx'">
  16. <u-icon name="question-circle-fill" class="u-m-r-5"></u-icon>该报告是docx格式,需要下载才能预览
  17. </view>
  18. <view class="btn">
  19. <view>
  20. <u-button type="warning" size="mini" @click="goDe(item.id_)" style="margin-right: 10rpx;"
  21. v-if="item.zhuang_tai_ == '待编制' || item.zhuang_tai_ == '待审核'">修改信息</u-button>
  22. <u-button type="warning" size="mini" @click="goto(item.id_,'1')"
  23. v-if="item.zhuang_tai_ == '待审核' && item.EXT_ != 'docx'">预览报告</u-button>
  24. <u-button type="warning" size="mini" @click="goto(item.id_,'2')" style="margin-right: 10rpx;"
  25. v-if="item.zhuang_tai_ == '已完成'">查看报告</u-button>
  26. <u-button type="primary" size="mini"
  27. v-if="(item.zhuang_tai_ == '已完成') || (item.shi_fou_guo_shen_ == '已编制')"
  28. @click="geDownload(item.bao_gao_pdf_,item.FILE_NAME_, item.EXT_)">
  29. 下载报告</u-button>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <view v-else>
  35. <uni-card is-full :is-shadow="false">
  36. <text class="">暂无报告</text>
  37. </uni-card>
  38. </view>
  39. <u-popup v-model="show" mode="bottom" closeable>
  40. <apply ref="apply" :id="id" v-if="show" @saveSuccees='saveSuccees'></apply>
  41. </u-popup>
  42. </view>
  43. </template>
  44. <script>
  45. import md5 from "@/common/util/md5.js"
  46. import http from "@/common/service/http.js"
  47. import {
  48. ACCESS_TOKEN,
  49. USER_NAME,
  50. USER_INFO
  51. } from "@/common/util/constants"
  52. import apply from './apply.vue'
  53. export default {
  54. components: {
  55. apply
  56. },
  57. data() {
  58. return {
  59. id: '',
  60. yangPinBianHao: '',
  61. reportList: [],
  62. userid: '',
  63. time: '',
  64. show: false
  65. }
  66. },
  67. onLoad(option) {
  68. if (option.id) {
  69. this.yangPinBianHao = option.id
  70. this.getList(option.id)
  71. }
  72. },
  73. created() {
  74. this.getInit()
  75. },
  76. methods: {
  77. getInit() {
  78. let info = uni.getStorageSync(USER_INFO);
  79. if (info.employee.id) {
  80. this.userid = info.employee.id || ''
  81. }
  82. var nowDate = new Date((new Date).getTime() + 8 * 60 * 60 * 1000)
  83. var time = nowDate.toJSON().split('T').join(' ').substr(0, 19)
  84. this.time = time
  85. },
  86. /*
  87. 根据样品编号查询报告礼拜
  88. */
  89. getList(id) {
  90. uni.showLoading({
  91. mask: true,
  92. title: 'loading'
  93. });
  94. //'${id}'
  95. let sql =
  96. `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`
  97. let requestData = this.$sig(sql)
  98. this.$http.post("/ibps/business/v3/sys/universal/inputSqlSelectData", requestData).then(res => {
  99. if (res.data.state == 200) {
  100. const data = res.data.variables.data
  101. this.reportList = data
  102. uni.hideLoading()
  103. }
  104. })
  105. },
  106. /*
  107. 跳转页面在线查看文档页面
  108. */
  109. goto(id, type) {
  110. uni.navigateTo({ // 跳转页面
  111. url: "/pages/fileView/fileView?id=" + id + '&type=' + type
  112. })
  113. },
  114. //下载
  115. // getDe(id, item) {
  116. // uni.showLoading({
  117. // title: '下载中',
  118. // mask: true
  119. // })
  120. // let sql =
  121. // `select a.bao_gao_pdf_,b.FILE_NAME_,b.EXT_ FROM t_lhjcbgb a left join ibps_file_attachment b on a.bao_gao_pdf_ = b.id_ WHERE a.id_ = '${id}'`
  122. // let requestData = this.$sig(sql)
  123. // this.$http.post("/ibps/business/v3/sys/universal/inputSqlSelectData", requestData).then(res => {
  124. // if (res.data.state == 200) {
  125. // const data = res.data.variables.data[0]
  126. // this.geDownload(data.bao_gao_pdf_, data.FILE_NAME_, data.EXT_)
  127. // }
  128. // })
  129. // },
  130. geDownload(id, item, type) {
  131. uni.showLoading({
  132. title: '下载中',
  133. mask: true
  134. })
  135. let requestData = {
  136. attachmentId: id
  137. }
  138. this.$http.get(`/ibps/platform/v3/file/download?attachmentId=${id}`, {
  139. responseType: 'arraybuffer'
  140. }).then(res => {
  141. const blob = new Blob([
  142. res.data
  143. ], {
  144. type: 'application/octet-stream'
  145. })
  146. const url = window.URL.createObjectURL(blob)
  147. const link = document.createElement('a')
  148. link.style.display = 'none'
  149. link.href = url
  150. link.setAttribute('download', item + '.' + type)
  151. document.body.appendChild(link)
  152. link.click()
  153. window.URL.revokeObjectURL(link.href)
  154. document.body.removeChild(link)
  155. uni.hideLoading()
  156. })
  157. },
  158. goDe(id) {
  159. this.id = id
  160. this.show = true
  161. },
  162. saveSuccees() {
  163. this.show = false
  164. this.reportList = []
  165. this.getList(this.yangPinBianHao)
  166. },
  167. /*
  168. md5加密
  169. */
  170. sig(sql) {
  171. let rul = (sql.length + 9) * 12 * 3 + 168
  172. let salt = "JinYuanXinTong"
  173. return md5(rul + '' + salt)
  174. },
  175. }
  176. }
  177. </script>
  178. <style lang="scss" scoped>
  179. .box {
  180. padding: 20rpx;
  181. .sinList {
  182. padding: 20rpx;
  183. margin-bottom: 20rpx;
  184. width: 100%;
  185. background: #fff;
  186. .title {
  187. line-height: 48rpx;
  188. }
  189. .btn {
  190. display: flex;
  191. justify-content: flex-end;
  192. }
  193. }
  194. }
  195. </style>