docList.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="文档列表" @clickLeft="back">
  4. </uni-nav-bar>
  5. <view class="topBtn">
  6. <u-button v-if="type!=='view'" type="primary" @click="add" text="本地上传"></u-button>
  7. <u-button v-if="type!=='view'" @click="selectDoc" text="关联文档库"></u-button>
  8. </view>
  9. <u-cell-group>
  10. <u-cell v-for="(item, index) in tableList" :key="index">
  11. <view class="listTitle" slot="title">
  12. {{item.name}}
  13. </view>
  14. <view slot="value" class="listBtn">
  15. <u-button text="浏览" size='mini' @click="preview(item)"></u-button>
  16. <u-button v-if="type!=='view'" text="删除" size='mini' @click="del(index)"></u-button>
  17. </view>
  18. </u-cell>
  19. </u-cell-group>
  20. <view style="height: 84rpx;"></view>
  21. <view class="footerButton">
  22. <u-button type="primary" @click="back" text="返回"></u-button>
  23. <u-button v-if="type!=='view'" @click="save" text="保存"></u-button>
  24. </view>
  25. <fileEdit ref="fileEditRef" @success="done"></fileEdit>
  26. </view>
  27. </template>
  28. <script>
  29. import {
  30. queryIds
  31. } from './api';
  32. import fileEdit from './file-edit';
  33. export default {
  34. components: {
  35. fileEdit
  36. },
  37. computed: {
  38. },
  39. data() {
  40. return {
  41. tableList: [],
  42. fileId: [],
  43. type: ''
  44. }
  45. },
  46. onLoad({
  47. fileId,
  48. type
  49. }) {
  50. this.type = type
  51. console.log(type,fileId);
  52. if (fileId) {
  53. this.fileId = JSON.parse(fileId)
  54. }
  55. this.init()
  56. uni.$off('setDocList')
  57. uni.$on('setDocList', (id) => {
  58. this.fileId.push(...id);
  59. this.init()
  60. })
  61. },
  62. methods: {
  63. async init() {
  64. if (this.fileId.length > 0) {
  65. this.tableList = await queryIds({
  66. ids: "'" + this.fileId + "'"
  67. });
  68. } else {
  69. this.tableList = [];
  70. }
  71. },
  72. del(index) {
  73. this.tableList.splice(index, 1);
  74. this.fileId = this.tableList.map((item) => item.id);
  75. },
  76. selectDoc() {
  77. uni.navigateTo({
  78. url: '/pages/doc/selectDoc?isAll=' + 1 + '&fileId=' + JSON.stringify(this.fileId)
  79. })
  80. },
  81. save() {
  82. uni.$emit('getFiles', this.fileId)
  83. this.back()
  84. },
  85. onunload() {
  86. uni.$off('setDocList')
  87. },
  88. add() {
  89. this.$refs.fileEditRef.open()
  90. },
  91. done(id) {
  92. this.fileId.push(...id);
  93. this.init()
  94. },
  95. preview(row) {
  96. const apiInfo = uni.getStorageSync('apiInfo')
  97. const orgin =
  98. apiInfo.hostname &&
  99. `${apiInfo.protocal || ''}${apiInfo.hostname || ''}:${apiInfo.port || ''}`
  100. let file = row.storagePath[0];
  101. let fileNames = file.storePath.split('/')
  102. let url = orgin + '/api/main/file/getFile?objectName=' + file.storePath +
  103. '&fullfilename=' + fileNames[fileNames.length - 1]
  104. let previewUrl = orgin + '/kkfile/onlinePreview?url=' + btoa(url);
  105. uni.navigateTo({
  106. url: `/pages/doc/browse?url=${previewUrl}`
  107. })
  108. }
  109. }
  110. }
  111. </script>
  112. <style lang="scss" scoped>
  113. .listTitle {
  114. width: 420rpx;
  115. white-space: nowrap;
  116. /* 防止文本换行 */
  117. overflow: hidden;
  118. /* 隐藏溢出的内容 */
  119. text-overflow: ellipsis;
  120. /* 显示省略符号来代表被修剪的文本 */
  121. }
  122. .topBtn {
  123. display: flex;
  124. margin-bottom: 20rpx;
  125. margin-top: 10rpx;
  126. uni-button {
  127. width: 180rpx;
  128. margin-left: 5px;
  129. margin-right: 5px;
  130. }
  131. }
  132. .listBtn {
  133. display: flex;
  134. uni-button {
  135. width: 100rpx;
  136. // height: 50rpx;
  137. margin-left: 10rpx;
  138. margin-right: 0;
  139. color: #fff !important;
  140. border: none;
  141. background: #157a2c !important;
  142. }
  143. }
  144. .footerButton {
  145. width: 100%;
  146. height: 84rpx;
  147. display: flex;
  148. position: fixed;
  149. bottom: 0;
  150. z-index: 10;
  151. /deep/.u-button {
  152. height: 100%;
  153. }
  154. >view {
  155. flex: 1;
  156. }
  157. }
  158. .item {
  159. display: flex;
  160. flex-direction: column;
  161. padding: 16rpx;
  162. >view {
  163. padding-top: 14rpx;
  164. }
  165. .item_title {
  166. font-size: 32rpx;
  167. font-weight: 800;
  168. }
  169. .item_list {
  170. display: flex;
  171. align-items: center;
  172. text {
  173. font-size: 28rpx;
  174. }
  175. .lable {
  176. color: #626060;
  177. }
  178. .value {
  179. color: #333;
  180. margin-left: 12rpx;
  181. flex: 1
  182. }
  183. }
  184. }
  185. /deep/.u-swipe-action-item__right__button__wrapper {
  186. background-color: #f56c6c !important;
  187. }
  188. /deep/.u-input {
  189. padding: 0 !important;
  190. }
  191. /deep/uni-textarea {
  192. padding: 0 !important;
  193. }
  194. </style>