repositoryDetails.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <view class="box">
  3. <view class="head">{{dataInfo.data.title}}</view>
  4. <view class="sign">
  5. <text>引入次数:{{dataInfo.data.introduceCount?dataInfo.data.introduceCount: 0}}</text>
  6. <text>版本号:{{dataInfo.data.visionNumber}}</text>
  7. <text>{{dataInfo.data.createtime}}</text>
  8. </view>
  9. <view class="theme">{{mutiCategory}}</view>
  10. <view class="content" v-html="dataInfo.data.content"></view>
  11. <view class="file-list" v-for="item in dataInfo.fileData" :key="item">
  12. <view class="file-item" @click="downloadFile(item)">{{item.name}}</view>
  13. <text class="newicon newicon-xiazai" @click="downloadFile(item)"></text>
  14. </view>
  15. <view class="foot_common_btns btn-style">
  16. <button @click="goBack" type="default" class="cancelButton btn">返回</button>
  17. <button v-if="editType != 'view'" @click="importData" type="default" class="primaryButton btn">引入</button>
  18. </view>
  19. <uni-popup ref="popup" type="center">
  20. <img :src="fileUrl" alt="" class="view-img">
  21. </uni-popup>
  22. </view>
  23. </template>
  24. <script setup>
  25. import { ref, reactive} from 'vue'
  26. import { onLoad } from '@dcloudio/uni-app'
  27. import { api_getSolution, api_listAttachment} from "@/http/api.js"
  28. import { useSetTitle } from '@/share/useSetTitle.js'
  29. import { useGoBack } from '@/share/useGoBack.js'
  30. import { useHandlerStore } from '@/stores/handler'
  31. useSetTitle();
  32. const handlerStore = useHandlerStore();
  33. const { goBack } = useGoBack();
  34. // 故障类型
  35. const mutiCategory = ref(null)
  36. // 关联故障分类的知识库数量
  37. const introduceCount = ref(0)
  38. // tab类型
  39. const tabType = ref('null')
  40. // tab类型
  41. const editType = ref(null)
  42. // 附件图片预览
  43. const fileUrl = ref('null')
  44. // Popup状态
  45. const popup = ref(null)
  46. // 数据
  47. const dataInfo = reactive({
  48. data: [],//数据
  49. incidentId: undefined,//事件ID
  50. solutionnumber:undefined,
  51. fileData:[] //附件数据
  52. })
  53. // 下载附件
  54. function downloadFile(item){
  55. console.log(666,item)
  56. let url = location.origin + "/file" + item.relativeFilePath
  57. fileUrl.value = url
  58. let name = item.name //文件下载后的名称(带后缀)
  59. if(item.suffix=='png' || item.suffix=='jpg' || item.suffix=='gif'){
  60. popup.value.open()
  61. }else{
  62. var oA = document.createElement("a");
  63. oA.download = name;
  64. oA.href = url
  65. document.body.appendChild(oA);
  66. oA.click();
  67. oA.remove();
  68. }
  69. }
  70. // 引入
  71. function importData(){
  72. let url = null
  73. let type = handlerStore.handler.data.operateType
  74. let storeInfo = handlerStore.handler.data
  75. storeInfo.introduceCount = introduceCount.value
  76. storeInfo.handleDescription = dataInfo.data.content
  77. storeInfo.solutionId = dataInfo.data.id
  78. storeInfo.type = 'rep'
  79. storeInfo.isSummaryNext = 1
  80. handlerStore.setHandlerData(storeInfo,'assign', 'assign')
  81. if(type=='malfunction'){ //故障处理
  82. url = '/pages/handler/handler'
  83. }else if(type=='reissue'){ //补单
  84. url = '/pages/assign/assign'
  85. }
  86. uni.navigateTo({
  87. url: url
  88. })
  89. }
  90. // 获取附件
  91. function getHandlerImgs(type,id){
  92. uni.showLoading({
  93. title: "加载中",
  94. mask: true,
  95. });
  96. api_listAttachment(type, id).then(res => {
  97. uni.hideLoading();
  98. dataInfo.fileData = res.data
  99. })
  100. }
  101. // 获取列表信息
  102. function getList(){
  103. uni.showLoading({
  104. title: "加载中",
  105. mask: true,
  106. });
  107. let postData = {
  108. idx: dataInfo.idx,
  109. sum: 20,
  110. solution: {
  111. solutionnumber: dataInfo.solutionnumber,
  112. }
  113. }
  114. api_getSolution(postData).then(res => {
  115. uni.hideLoading();
  116. if(res.status == 200){
  117. let list = res.list || [];
  118. introduceCount.value = res.totalNum
  119. dataInfo.data = list[0]
  120. mutiCategory.value = list[0].category.mutiCategory
  121. getHandlerImgs('knowledge',list[0].id)
  122. }else{
  123. uni.showToast({
  124. icon: 'none',
  125. title: res.msg || '请求数据失败!'
  126. });
  127. }
  128. })
  129. }
  130. onLoad((option) => {
  131. dataInfo.incidentId = option.incidentId;
  132. dataInfo.solutionnumber = option.solutionnumber ;
  133. if(option.tabType){
  134. tabType.value = option.tabType;
  135. }
  136. if(option.editType){
  137. editType.value = option.editType
  138. }
  139. getList();
  140. })
  141. </script>
  142. <style lang="scss" scoped>
  143. .box{
  144. padding: 24rpx;
  145. .head{
  146. color: #000;
  147. font-size: 32rpx;
  148. font-weight: 600;
  149. }
  150. .sign{
  151. color: #686868;
  152. font-size: 24rpx;
  153. padding: 24rpx 0;
  154. text{
  155. margin-right: 40rpx;
  156. }
  157. }
  158. .theme{
  159. font-size: 26rpx;
  160. color: #49b856;
  161. padding: 0 0 24rpx 0;
  162. }
  163. .content{
  164. padding-bottom: 24rpx;
  165. border-bottom: 1px solid #eee;
  166. // overflow-y: scroll;
  167. }
  168. .file-list{
  169. display: flex;
  170. margin-bottom: 10rpx;
  171. margin-top: 24rpx;
  172. .file-item{
  173. color: #00aaff;
  174. text-decoration: underline;
  175. }
  176. text{
  177. margin-left: 15rpx;
  178. margin-top: 8rpx;
  179. }
  180. }
  181. .btn-style{
  182. position: fixed;
  183. left:0;
  184. bottom: 0;
  185. }
  186. .view-img{
  187. width: 100%;
  188. height: 100%;
  189. }
  190. }
  191. </style>