index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <view class="assistantMsg-v">
  3. <view class="u-p-l-20 u-p-r-20 u-p-t-20" v-if="statusList.length">
  4. <u-subsection :list="statusList" :current="subsectionIndex" active-color="#2979FF" inactive-color="#999999"
  5. bg-color="#F2F3F7" font-size="24" :bold="false" @change="subsection"></u-subsection>
  6. </view>
  7. <view v-if="tabData.data?.length">
  8. <view class="u-p-l-20 u-p-r-20 u-p-t-20 u-p-b-20" v-if="subsectionId == 1">
  9. <text>{{tabData.data}}</text>
  10. </view>
  11. <view v-if="subsectionId != 1">
  12. <view class="u-flex-col list-v">
  13. <view class="u-flex item" v-for="(item,index) in tabData.data" :key="index">
  14. <view v-if="subsectionId == 2" class="linkBox">
  15. <!-- #ifndef APP-HARMONY -->
  16. <u-link :href="item.urlAddress" under-line>{{item.fullName}}</u-link>
  17. <!-- #endif -->
  18. <!-- #ifdef APP-HARMONY -->
  19. <text @click="jumpLink(item.urlAddress)" class="linkColor">{{item.fullName}}</text>
  20. <!-- #endif -->
  21. </view>
  22. <view class="list-inner u-flex" v-if="subsectionId == 3">
  23. <view class="u-flex list-inner-box" @click="downLoad(item)">
  24. <view class="item-icon ">
  25. <u-image :src="getRecordImg(item.uploaderUrl)" width="84" height="84" />
  26. </view>
  27. <view class="u-flex-col r-content ">
  28. <view class="u-line-1 name">{{item.fileName}}</view>
  29. <text>
  30. {{item.fileDate ? $u.timeFormat(item.fileDate, 'yyyy-mm-dd hh:MM:ss'):''}}</text>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="group-box-inner" v-if="subsectionId == 4">
  35. <u-cell-group :border="false">
  36. <u-cell-item :border-bottom="false" :title="item.interfaceName"
  37. hover-class="cell-hover-class" @click="jump(item)"></u-cell-item>
  38. </u-cell-group>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="u-p-20" v-else>
  45. <NoData paddingTop="0" backgroundColor="#fff" zIndex="9"></NoData>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import resources from "@/libs/resources.js";
  51. import NoData from '@/components/noData'
  52. const wordTypeList = ['doc', 'docx'];
  53. const excelTypeList = ['xls', 'xlsx'];
  54. const pptTypeList = ['ppt', 'pptx'];
  55. const pdfTypeList = ['pdf'];
  56. const zipTypeList = ['rar', 'zip', 'arj', 'z', '7z'];
  57. const txtTypeList = ['txt', 'log'];
  58. const codeTypeList = ['html', 'cs', 'xml'];
  59. const imgTypeList = ['png', 'jpg', 'jpeg', 'bmp', 'gif'];
  60. const videoTypeList = ['avi', 'wmv', 'mpg', 'mpeg', 'mov', 'rm', 'ram', 'swf', 'flv', 'mp4', 'mp3', 'wma', 'avi', 'rm',
  61. 'rmvb', 'flv', 'mpg', 'mkv'
  62. ];
  63. import {
  64. packDownload,
  65. } from "@/api/workFlow/document";
  66. export default {
  67. components: {
  68. NoData
  69. },
  70. props: {
  71. auxiliaryInfo: {
  72. type: Array,
  73. default: () => []
  74. }
  75. },
  76. data() {
  77. return {
  78. subsectionIndex: 0,
  79. wordImg: resources.document.wordImg,
  80. excelImg: resources.document.excelImg,
  81. pptImg: resources.document.pptImg,
  82. pdfImg: resources.document.pdfImg,
  83. rarImg: resources.document.rarImg,
  84. txtImg: resources.document.txtImg,
  85. codeImg: resources.document.codeImg,
  86. imageImg: resources.document.imageImg,
  87. audioImg: resources.document.audioImg,
  88. blankImg: resources.document.blankImg,
  89. folderImg: resources.document.folderImg,
  90. }
  91. },
  92. computed: {
  93. baseURL() {
  94. return this.define.baseURL
  95. },
  96. statusList() {
  97. let list = this.auxiliaryInfo.filter(o => o && o.config && o.config.on);
  98. list = list.map(o => ({
  99. ...o,
  100. name: o.fullName
  101. }))
  102. return list
  103. },
  104. subsectionId() {
  105. return this.statusList[this.subsectionIndex]?.id
  106. },
  107. tabData() {
  108. const configKeyMap = {
  109. 1: 'content',
  110. 2: 'linkList',
  111. 3: 'fileList',
  112. 4: 'dataList'
  113. };
  114. const configKey = configKeyMap[this.subsectionId] || null;
  115. if (configKey) {
  116. return {
  117. data: this.statusList[this.subsectionIndex].config[configKey] || (configKey === 'content' ? '' :
  118. []),
  119. show: this.statusList[this.subsectionIndex].config.on
  120. };
  121. }
  122. return {};
  123. }
  124. },
  125. methods: {
  126. jumpLink(url) {
  127. if (!url.startsWith("https://")) return this.$u.toast('无效链接')
  128. uni.navigateTo({
  129. url: `/pages/workFlow/webView/index?data=${url}`
  130. })
  131. },
  132. getRecordImg(ext) {
  133. if (!ext) return this.folderImg;
  134. const match = ext.match(/\.([^\.]+)$/);
  135. if (match) ext = match[1]
  136. if (wordTypeList.includes(ext)) return this.wordImg;
  137. if (excelTypeList.includes(ext)) return this.excelImg;
  138. if (pptTypeList.includes(ext)) return this.pptImg;
  139. if (pdfTypeList.includes(ext)) return this.pdfImg;
  140. if (zipTypeList.includes(ext)) return this.rarImg;
  141. if (txtTypeList.includes(ext)) return this.txtImg;
  142. if (codeTypeList.includes(ext)) return this.codeImg;
  143. if (imgTypeList.includes(ext)) return this.imageImg;
  144. if (videoTypeList.includes(ext)) return this.audioImg;
  145. return this.blankImg;
  146. },
  147. subsection(e) {
  148. this.subsectionIndex = e
  149. },
  150. jump(item) {
  151. uni.navigateTo({
  152. url: "/pages/workFlow/assistantMsg/viewData?data=" + encodeURIComponent(JSON.stringify(item))
  153. })
  154. },
  155. downLoad(item) {
  156. let data = {
  157. ids: [item?.id]
  158. }
  159. packDownload(data).then(res => {
  160. // #ifdef H5
  161. const fileUrl = this.baseURL + res.data.url + '&name=' + encodeURI(res.data.name);
  162. window.location.href = fileUrl;
  163. // #endif
  164. // #ifdef MP
  165. this.previewFile(res.data)
  166. // #endif
  167. // #ifdef APP-PLUS
  168. this.downloadFile(res.data.url);
  169. // #endif
  170. })
  171. },
  172. previewFile(item) {
  173. let fileTypes = ['doc', 'xls', 'ppt', 'pdf', 'docx', 'xlsx', 'pptx']
  174. let url = item.url
  175. let fileType = url.split('.')[1]
  176. if (fileTypes.includes(fileType)) {
  177. uni.downloadFile({
  178. url: this.baseURL + url,
  179. success: (res) => {
  180. let filePath = res.tempFilePath;
  181. uni.openDocument({
  182. filePath: encodeURI(filePath),
  183. showMenu: true,
  184. fileType: fileType,
  185. success: (res) => {
  186. console.log('打开文档成功');
  187. },
  188. fail(err) {
  189. console.log('小程序', err);
  190. }
  191. });
  192. }
  193. });
  194. } else {
  195. this.$u.toast(
  196. '该文件类型无法打开'
  197. )
  198. }
  199. },
  200. downloadFile(url) {
  201. uni.downloadFile({
  202. url: this.baseURL + url,
  203. success: res => {
  204. if (res.statusCode === 200) {
  205. uni.saveFile({
  206. tempFilePath: res.tempFilePath,
  207. success: red => {
  208. uni.showToast({
  209. icon: 'none',
  210. mask: true,
  211. title: '文件已保存:' + red.savedFilePath, //保存路径
  212. duration: 3000,
  213. });
  214. setTimeout(() => {
  215. uni.openDocument({
  216. filePath: red.savedFilePath,
  217. success: ress => {},
  218. fail(err) {}
  219. });
  220. }, 500)
  221. }
  222. });
  223. }
  224. }
  225. });
  226. }
  227. }
  228. }
  229. </script>
  230. <style lang="scss">
  231. .list-v {
  232. .item {
  233. min-height: 80rpx;
  234. width: 100%;
  235. border-bottom: 1rpx solid #d7d7d7;
  236. padding: 20rpx;
  237. .linkBox {
  238. .linkColor {
  239. color: #007BFF;
  240. }
  241. }
  242. .list-inner {
  243. width: 100%;
  244. .list-inner-box {
  245. width: 100%;
  246. .item-icon {
  247. background-color: #FFFFFF;
  248. border-radius: 8rpx;
  249. }
  250. .r-content {
  251. max-width: 86%;
  252. margin-left: 14rpx;
  253. .name {
  254. text-align: left;
  255. }
  256. }
  257. }
  258. }
  259. .group-box-inner {
  260. width: 100%;
  261. ::v-deep {
  262. .u-cell {
  263. padding: 0;
  264. }
  265. }
  266. }
  267. }
  268. }
  269. </style>