repositoryDetails.vue 5.0 KB

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