repositoryDetails.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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 { useGoBack } from '@/share/useGoBack.js'
  24. useSetTitle();
  25. const { goBack } = useGoBack();
  26. // 故障类型
  27. const mutiCategory = ref(null)
  28. // 操作类型
  29. const operateType = ref(null)
  30. // tab类型
  31. const tabType = 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/assign/assign'
  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')}
  98. &introduceCount=${encodeURIComponent(dataInfo.data.introduceCount)}
  99. &tabType=${encodeURIComponent(tabType.value)}`
  100. })
  101. }
  102. // 获取附件
  103. function getHandlerImgs(type,id){
  104. uni.showLoading({
  105. title: "加载中",
  106. mask: true,
  107. });
  108. api_listAttachment(type, id).then(res => {
  109. uni.hideLoading();
  110. dataInfo.fileData = res.data
  111. })
  112. }
  113. // 获取列表信息
  114. function getList(){
  115. uni.showLoading({
  116. title: "加载中",
  117. mask: true,
  118. });
  119. let postData = {
  120. idx: dataInfo.idx,
  121. sum: 20,
  122. solution: {
  123. solutionnumber: dataInfo.solutionnumber,
  124. }
  125. }
  126. api_getSolution(postData).then(res => {
  127. uni.hideLoading();
  128. if(res.status == 200){
  129. let list = res.list || [];
  130. dataInfo.data = list[0]
  131. mutiCategory.value = list[0].category.mutiCategory
  132. getHandlerImgs('knowledge',list[0].id)
  133. }else{
  134. uni.showToast({
  135. icon: 'none',
  136. title: res.msg || '请求数据失败!'
  137. });
  138. }
  139. })
  140. }
  141. onLoad((option) => {
  142. dataInfo.incidentId = option.incidentId;
  143. dataInfo.solutionnumber = option.solutionnumber ;
  144. operateType.value = option.operateType;
  145. tabType.value = option.tabType;
  146. getList();
  147. })
  148. </script>
  149. <style lang="scss" scoped>
  150. .box{
  151. padding: 24rpx;
  152. .head{
  153. color: #000;
  154. font-size: 32rpx;
  155. font-weight: 600;
  156. }
  157. .sign{
  158. color: #686868;
  159. font-size: 24rpx;
  160. padding: 24rpx 0;
  161. text{
  162. margin-right: 40rpx;
  163. }
  164. }
  165. .theme{
  166. font-size: 26rpx;
  167. color: #49b856;
  168. padding: 0 0 24rpx 0;
  169. }
  170. .content{
  171. padding-bottom: 24rpx;
  172. border-bottom: 1px solid #eee;
  173. overflow-y: scroll;
  174. }
  175. .file-list{
  176. display: flex;
  177. margin-bottom: 10rpx;
  178. margin-top: 24rpx;
  179. .file-item{
  180. color: #00aaff;
  181. text-decoration: underline;
  182. }
  183. text{
  184. margin-left: 15rpx;
  185. margin-top: 8rpx;
  186. }
  187. }
  188. .btn-style{
  189. position: fixed;
  190. bottom: 40rpx;
  191. width: 93%;
  192. }
  193. }
  194. </style>