docList.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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="success" @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. <!-- 主操作实心绿、次操作描边绿:「保存」是主操作,「返回」是次操作 -->
  24. <u-button @click="cancel" text="返回"></u-button>
  25. <u-button v-if="type!=='view'" type="success" @click="save" text="保存"></u-button>
  26. </view>
  27. <fileEdit ref="fileEditRef" @success="done"></fileEdit>
  28. <selectDoc ref="selectDocRef" @success="done"></selectDoc>
  29. </view>
  30. </u-popup>
  31. </template>
  32. <script>
  33. import {
  34. queryIds
  35. } from './api';
  36. import fileEdit from './file-edit';
  37. import selectDoc from './selectDoc';
  38. export default {
  39. components: {
  40. fileEdit,
  41. selectDoc
  42. },
  43. computed: {
  44. },
  45. data() {
  46. return {
  47. tableList: [],
  48. fileId: [],
  49. type: '',
  50. show: false,
  51. }
  52. },
  53. methods: {
  54. open(fileId, type) {
  55. this.type = type
  56. this.fileId = fileId
  57. this.show = true
  58. this.init()
  59. },
  60. cancel() {
  61. this.fileId = []
  62. this.show = false;
  63. this.$emit('close')
  64. },
  65. async init() {
  66. if (this.fileId.length > 0) {
  67. this.tableList = await queryIds({
  68. ids: "'" + this.fileId + "'"
  69. });
  70. } else {
  71. this.tableList = [];
  72. }
  73. },
  74. del(index) {
  75. this.tableList.splice(index, 1);
  76. this.fileId = this.tableList.map((item) => item.id);
  77. },
  78. save() {
  79. this.$emit('getFiles', this.fileId)
  80. this.cancel()
  81. },
  82. add(type) {
  83. if (type == 1) {
  84. this.$refs.fileEditRef.open()
  85. } else {
  86. this.$refs.selectDocRef.open(1,this.fileId)
  87. }
  88. },
  89. done(id) {
  90. this.fileId.push(...id);
  91. this.init()
  92. },
  93. preview(row) {
  94. const apiInfo = uni.getStorageSync('apiInfo')
  95. const orgin =
  96. apiInfo.hostname &&
  97. `${apiInfo.protocal || ''}${apiInfo.hostname || ''}:${apiInfo.port || ''}`
  98. let file = row.storagePath[0];
  99. let fileNames = file.storePath.split('/')
  100. let url = orgin + '/api/main/file/getFile?objectName=' + file.storePath +
  101. '&fullfilename=' + fileNames[fileNames.length - 1]
  102. let previewUrl = orgin + '/kkfile/onlinePreview?url=' + btoa(url);
  103. uni.navigateTo({
  104. url: `/pages/doc/browse?url=${previewUrl}`
  105. })
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss" scoped>
  111. .listTitle {
  112. width: 420rpx;
  113. white-space: nowrap;
  114. /* 防止文本换行 */
  115. overflow: hidden;
  116. /* 隐藏溢出的内容 */
  117. text-overflow: ellipsis;
  118. /* 显示省略符号来代表被修剪的文本 */
  119. }
  120. .topBtn {
  121. display: flex;
  122. margin-bottom: 20rpx;
  123. margin-top: 10rpx;
  124. uni-button {
  125. width: 180rpx;
  126. margin-left: 5px;
  127. margin-right: 5px;
  128. }
  129. }
  130. /* 文档组件统一绿色主题:
  131. uView 的 primary 是蓝色($u-primary #3c9cff),而本组件家族的
  132. 上传 / 浏览 / 删除按钮本来就是绿色 #157a2c。这里把「次要按钮」
  133. (未指定 type,走 uView 默认的 info 灰)也统一成绿字绿边,
  134. 避免同一个弹窗里蓝色 / 灰色 / 绿色三种按钮混用。 */
  135. .topBtn,
  136. .footerButton {
  137. /deep/.u-button--info {
  138. color: #157a2c;
  139. border-color: #157a2c;
  140. }
  141. }
  142. .listBtn {
  143. display: flex;
  144. uni-button {
  145. width: 100rpx;
  146. // height: 50rpx;
  147. margin-left: 10rpx;
  148. margin-right: 0;
  149. color: #fff !important;
  150. border: none;
  151. background: #157a2c !important;
  152. }
  153. }
  154. .footerButton {
  155. width: 100%;
  156. height: 84rpx;
  157. display: flex;
  158. position: fixed;
  159. bottom: 0;
  160. z-index: 10;
  161. /* 原来两个按钮贴屏边、且彼此紧贴;补左右留边 + 中间留缝 + 上分隔线 */
  162. padding: 0 24rpx;
  163. box-sizing: border-box;
  164. background: #fff;
  165. border-top: 1rpx solid #f2f3f5;
  166. /deep/.u-button {
  167. flex: 1;
  168. height: 100%;
  169. }
  170. /* 两个按钮之间留缝(比 gap 兼容性更稳) */
  171. /deep/.u-button + .u-button {
  172. margin-left: 20rpx;
  173. }
  174. >view {
  175. flex: 1;
  176. }
  177. }
  178. .item {
  179. display: flex;
  180. flex-direction: column;
  181. padding: 16rpx;
  182. >view {
  183. padding-top: 14rpx;
  184. }
  185. .item_title {
  186. font-size: 32rpx;
  187. font-weight: 800;
  188. }
  189. .item_list {
  190. display: flex;
  191. align-items: center;
  192. text {
  193. font-size: 28rpx;
  194. }
  195. .lable {
  196. color: #626060;
  197. }
  198. .value {
  199. color: #333;
  200. margin-left: 12rpx;
  201. flex: 1
  202. }
  203. }
  204. }
  205. /deep/.u-swipe-action-item__right__button__wrapper {
  206. background-color: #f56c6c !important;
  207. }
  208. /deep/.u-input {
  209. padding: 0 !important;
  210. }
  211. /deep/uni-textarea {
  212. padding: 0 !important;
  213. }
  214. </style>