docList.vue 4.2 KB

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