reportList.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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.wei_tuo_lian_xi_r}}</view>
  13. <view class="title">报告状态:<text style="color: #7349ff;">{{item.zhuang_tai_}}</text></view>
  14. <view class="btn">
  15. <view>
  16. <u-button type="warning" size="mini" @click="goDe(item.id_)" style="margin-right: 10rpx;"
  17. v-if="item.zhuang_tai_ == '待编制' || item.zhuang_tai_ == '待审核'">修改信息</u-button>
  18. <u-button type="warning" size="mini" @click="goto(item.id_,'1')"
  19. v-if="item.zhuang_tai_ == '待编制' || item.zhuang_tai_ == '待审核'">预览报告</u-button>
  20. <u-button type="warning" size="mini" @click="goto(item.id_,'2')" style="margin-right: 10rpx;"
  21. v-if="item.zhuang_tai_ == '待发放' || item.zhuang_tai_ == '已完成'">查看报告</u-button>
  22. <u-button type="primary" size="mini" v-if="item.zhuang_tai_ == '已完成'"
  23. @click="getDe(item.id_,item)">
  24. 下载报告</u-button>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view v-else>
  30. <uni-card is-full :is-shadow="false">
  31. <text class="">暂无报告</text>
  32. </uni-card>
  33. </view>
  34. <u-popup v-model="show" mode="bottom" closeable>
  35. <apply ref="apply" :id="id" v-if="show" @saveSuccees='saveSuccees'></apply>
  36. </u-popup>
  37. </view>
  38. </template>
  39. <script>
  40. import md5 from "@/common/util/md5.js"
  41. import http from "@/common/service/http.js"
  42. import {
  43. ACCESS_TOKEN,
  44. USER_NAME,
  45. USER_INFO
  46. } from "@/common/util/constants"
  47. import apply from './apply.vue'
  48. export default {
  49. components: {
  50. apply
  51. },
  52. data() {
  53. return {
  54. id: '',
  55. yangPinBianHao: '',
  56. reportList: [],
  57. userid: '',
  58. time: '',
  59. show: false
  60. }
  61. },
  62. onLoad(option) {
  63. console.log(option)
  64. if (option.id) {
  65. this.yangPinBianHao = option.id
  66. this.getList(option.id)
  67. }
  68. },
  69. created() {
  70. this.getInit()
  71. },
  72. methods: {
  73. getInit() {
  74. let info = uni.getStorageSync(USER_INFO);
  75. if (info.employee.id) {
  76. this.userid = info.employee.id || ''
  77. }
  78. var nowDate = new Date((new Date).getTime() + 8 * 60 * 60 * 1000)
  79. var time = nowDate.toJSON().split('T').join(' ').substr(0, 19)
  80. this.time = time
  81. },
  82. /*
  83. 根据样品编号查询报告礼拜
  84. */
  85. getList(id) {
  86. uni.showLoading({
  87. mask: true,
  88. title: 'loading'
  89. });
  90. //'${id}'
  91. let sql =
  92. `select * from t_lhjcbgb where yang_pin_bian_hao = '${id}' ORDER BY create_time_ desc`
  93. let requestData = this.$sig(sql)
  94. this.$http.post("/ibps/business/v3/sys/universal/inputSqlSelectData", requestData).then(res => {
  95. if (res.data.state == 200) {
  96. const data = res.data.variables.data
  97. this.reportList = data
  98. uni.hideLoading()
  99. }
  100. })
  101. },
  102. /*
  103. 跳转页面在线查看文档页面
  104. */
  105. goto(id, type) {
  106. uni.navigateTo({ // 跳转页面
  107. url: "/pages/fileView/fileView?id=" + id + '&type=' + type
  108. })
  109. },
  110. //下载
  111. getDe(id, item) {
  112. let access_token = uni.getStorageSync('Access-Token')
  113. console.log(access_token)
  114. let sql =
  115. `select FILE_PATH_ from ibps_file_attachment WHERE id_ = (SELECT bao_gao_pdf_ FROM t_lhjcbgb WHERE id_ = '${id}')`
  116. let requestData = this.$sig(sql)
  117. this.$http.post("/ibps/business/v3/sys/universal/inputSqlSelectData", requestData).then(res => {
  118. if (res.data.state == 200) {
  119. const data = res.data.variables.data[0]
  120. let url =
  121. http.apiHosp + data.FILE_PATH_
  122. uni.getSystemInfo({
  123. success: (res) => {
  124. // windows | mac为pc端
  125. // android | ios为手机端
  126. if (res.platform == 'android' || res.platform == 'ios') {
  127. var iframe = document.createElement('iframe');
  128. iframe.style.display = 'none';
  129. iframe.src = "javascript: '<script>location.href=\"" + url +
  130. "\"<\/script>'";
  131. document.getElementsByTagName('body')[0].appendChild(iframe);
  132. } else {
  133. const blob = new Blob([
  134. url
  135. ]); //new Blob([res])中不加data就会返回下图中[objece objece]内容(少取一层)
  136. const fileName = item.bao_gao_bian_hao_ + '检测项目' + '.pdf'; //下载文件名称
  137. const elink = document.createElement('a');
  138. elink.download = fileName;
  139. elink.style.display = 'none';
  140. elink.href = URL.createObjectURL(blob);
  141. document.body.appendChild(elink);
  142. elink.click();
  143. URL.revokeObjectURL(elink.href); // 释放URL 对象
  144. }
  145. }
  146. });
  147. }
  148. })
  149. },
  150. goDe(id) {
  151. this.id = id
  152. this.show = true
  153. },
  154. saveSuccees() {
  155. this.reportList = []
  156. this.getDe(this.id)
  157. },
  158. /*
  159. md5加密
  160. */
  161. sig(sql) {
  162. let rul = (sql.length + 9) * 12 * 3 + 168
  163. let salt = "JinYuanXinTong"
  164. return md5(rul + '' + salt)
  165. },
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. .box {
  171. padding: 20rpx;
  172. .sinList {
  173. padding: 20rpx;
  174. margin-bottom: 20rpx;
  175. width: 100%;
  176. background: #fff;
  177. .title {
  178. line-height: 48rpx;
  179. }
  180. .btn {
  181. display: flex;
  182. justify-content: flex-end;
  183. }
  184. }
  185. }
  186. </style>