repositoryDetails.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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. <button @click="importData" type="default" class="primaryButton btn btn-style">引入</button>
  16. </view>
  17. </template>
  18. <script setup>
  19. import { ref, reactive} from 'vue'
  20. import { onLoad } from '@dcloudio/uni-app'
  21. import { api_getSolution, api_listAttachment} from "@/http/api.js"
  22. import { useSetTitle } from '@/share/useSetTitle.js'
  23. import { useGoBack } from '@/share/useGoBack.js'
  24. import { useHandlerStore } from '@/stores/handler'
  25. useSetTitle();
  26. const handlerStore = useHandlerStore();
  27. const { goBack } = useGoBack();
  28. // 故障类型
  29. const mutiCategory = ref(null)
  30. // 操作类型
  31. // const operateType = ref(null)
  32. // 关联故障分类的知识库数量
  33. const introduceCount = ref(0)
  34. // tab类型
  35. const tabType = ref('null')
  36. // 数据
  37. const dataInfo = reactive({
  38. data: [],//数据
  39. incidentId: undefined,//事件ID
  40. solutionnumber:undefined,
  41. fileData:[] //附件数据
  42. })
  43. // 下载附件
  44. function downloadFile(item){
  45. console.log(666,item)
  46. // 下载文件资源到本地
  47. uni.downloadFile({
  48. url: item.previewUrl, // 后端返回的线上文件路径
  49. success: function(res) {
  50. if (res.statusCode === 200) {
  51. // 文件到本地
  52. uni.saveFile({
  53. tempFilePath: res.tempFilePath, //临时路径
  54. success: function(data) {
  55. uni.showToast({
  56. icon: 'none',
  57. mask: true,
  58. title: '保存成功',
  59. duration: 2000
  60. })
  61. //ios手机直接打开文件,手动存储文件到手机,Android手机从根目录创建文件夹,保存文件并改名
  62. setTimeout(() => {
  63. //打开文档查看
  64. uni.openDocument({
  65. filePath: data.savedFilePath,
  66. success: function(ress) {
  67. console.log("成功打开文件")
  68. },
  69. fail() {
  70. console.log("打开文件失败")
  71. }
  72. })
  73. }, 1000)
  74. }
  75. })
  76. console.log('下载成功');
  77. }
  78. },
  79. fail: function(res) {
  80. console.log(res.errMsg);
  81. },
  82. complete: function(res) {
  83. console.log(res.statusCode);
  84. },
  85. progress: function(res) {
  86. console.log('下载进度' + res.progress);
  87. }
  88. });
  89. }
  90. // 引入
  91. function importData(){
  92. let url = null
  93. let type = handlerStore.handler.data.operateType
  94. let storeInfo = handlerStore.handler.data
  95. storeInfo.introduceCount = introduceCount.value
  96. storeInfo.handleDescription = dataInfo.data.content
  97. storeInfo.solutionId = dataInfo.data.id
  98. storeInfo.type = 'rep'
  99. storeInfo.isSummaryNext = 1
  100. handlerStore.setHandlerData(storeInfo,'assign', 'assign')
  101. if(type=='malfunction'){ //故障处理
  102. url = '/pages/handler/handler'
  103. }else if(type=='reissue'){ //补单
  104. url = '/pages/assign/assign'
  105. }
  106. uni.navigateTo({
  107. url: url
  108. })
  109. }
  110. // 获取附件
  111. function getHandlerImgs(type,id){
  112. uni.showLoading({
  113. title: "加载中",
  114. mask: true,
  115. });
  116. api_listAttachment(type, id).then(res => {
  117. uni.hideLoading();
  118. dataInfo.fileData = res.data
  119. })
  120. }
  121. // 获取列表信息
  122. function getList(){
  123. uni.showLoading({
  124. title: "加载中",
  125. mask: true,
  126. });
  127. let postData = {
  128. idx: dataInfo.idx,
  129. sum: 20,
  130. solution: {
  131. solutionnumber: dataInfo.solutionnumber,
  132. }
  133. }
  134. api_getSolution(postData).then(res => {
  135. uni.hideLoading();
  136. if(res.status == 200){
  137. let list = res.list || [];
  138. introduceCount.value = res.totalNum
  139. dataInfo.data = list[0]
  140. mutiCategory.value = list[0].category.mutiCategory
  141. getHandlerImgs('knowledge',list[0].id)
  142. }else{
  143. uni.showToast({
  144. icon: 'none',
  145. title: res.msg || '请求数据失败!'
  146. });
  147. }
  148. })
  149. }
  150. onLoad((option) => {
  151. dataInfo.incidentId = option.incidentId;
  152. dataInfo.solutionnumber = option.solutionnumber ;
  153. // operateType.value = decodeURIComponent(option.operateType);
  154. if(option.tabType){
  155. tabType.value = option.tabType;
  156. }
  157. getList();
  158. })
  159. </script>
  160. <style lang="scss" scoped>
  161. .box{
  162. padding: 24rpx;
  163. .head{
  164. color: #000;
  165. font-size: 32rpx;
  166. font-weight: 600;
  167. }
  168. .sign{
  169. color: #686868;
  170. font-size: 24rpx;
  171. padding: 24rpx 0;
  172. text{
  173. margin-right: 40rpx;
  174. }
  175. }
  176. .theme{
  177. font-size: 26rpx;
  178. color: #49b856;
  179. padding: 0 0 24rpx 0;
  180. }
  181. .content{
  182. padding-bottom: 24rpx;
  183. border-bottom: 1px solid #eee;
  184. overflow-y: scroll;
  185. }
  186. .file-list{
  187. display: flex;
  188. margin-bottom: 10rpx;
  189. margin-top: 24rpx;
  190. .file-item{
  191. color: #00aaff;
  192. text-decoration: underline;
  193. }
  194. text{
  195. margin-left: 15rpx;
  196. margin-top: 8rpx;
  197. }
  198. }
  199. .btn-style{
  200. position: fixed;
  201. bottom: 40rpx;
  202. width: 93%;
  203. }
  204. }
  205. </style>