docList.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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 type="primary" @click="add" text="本地上传"></u-button>
  7. <u-button @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'></u-button>
  16. <u-button 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 @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. data() {
  38. return {
  39. tableList: [],
  40. fileId: []
  41. }
  42. },
  43. onLoad({
  44. fileId
  45. }) {
  46. if (fileId) {
  47. this.fileId = JSON.parse(fileId)
  48. }
  49. this.init()
  50. uni.$off('setDocList')
  51. uni.$on('setDocList', (id) => {
  52. this.fileId.push(...id);
  53. this.init()
  54. })
  55. },
  56. methods: {
  57. async init() {
  58. if (this.fileId.length > 0) {
  59. this.tableList = await queryIds({
  60. ids: "'" + this.fileId + "'"
  61. });
  62. } else {
  63. this.tableList = [];
  64. }
  65. },
  66. del(index) {
  67. this.tableList.splice(index, 1);
  68. this.fileId = this.tableList.map((item) => item.id);
  69. },
  70. selectDoc() {
  71. uni.navigateTo({
  72. url: '/pages/doc/selectDoc?isAll=' + 1 + '&fileId=' + JSON.stringify(this.fileId)
  73. })
  74. },
  75. save() {
  76. uni.$emit('getFiles', this.fileId)
  77. this.back()
  78. },
  79. onunload() {
  80. uni.$off('setDocList')
  81. },
  82. add() {
  83. this.$refs.fileEditRef.open()
  84. },
  85. done(id){
  86. this.fileId.push(...id);
  87. this.init()
  88. }
  89. }
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. .listTitle {
  94. width: 420rpx;
  95. white-space: nowrap;
  96. /* 防止文本换行 */
  97. overflow: hidden;
  98. /* 隐藏溢出的内容 */
  99. text-overflow: ellipsis;
  100. /* 显示省略符号来代表被修剪的文本 */
  101. }
  102. .topBtn {
  103. display: flex;
  104. margin-bottom: 20rpx;
  105. margin-top: 10rpx;
  106. uni-button {
  107. width: 180rpx;
  108. margin-left: 5px;
  109. margin-right: 5px;
  110. }
  111. }
  112. .listBtn {
  113. display: flex;
  114. uni-button {
  115. width: 100rpx;
  116. // height: 50rpx;
  117. margin-left: 10rpx;
  118. margin-right: 0;
  119. color: #fff !important;
  120. border: none;
  121. background: #157a2c !important;
  122. }
  123. }
  124. .footerButton {
  125. width: 100%;
  126. height: 84rpx;
  127. display: flex;
  128. position: fixed;
  129. bottom: 0;
  130. z-index: 10;
  131. /deep/.u-button {
  132. height: 100%;
  133. }
  134. >view {
  135. flex: 1;
  136. }
  137. }
  138. .item {
  139. display: flex;
  140. flex-direction: column;
  141. padding: 16rpx;
  142. >view {
  143. padding-top: 14rpx;
  144. }
  145. .item_title {
  146. font-size: 32rpx;
  147. font-weight: 800;
  148. }
  149. .item_list {
  150. display: flex;
  151. align-items: center;
  152. text {
  153. font-size: 28rpx;
  154. }
  155. .lable {
  156. color: #626060;
  157. }
  158. .value {
  159. color: #333;
  160. margin-left: 12rpx;
  161. flex: 1
  162. }
  163. }
  164. }
  165. /deep/.u-swipe-action-item__right__button__wrapper {
  166. background-color: #f56c6c !important;
  167. }
  168. /deep/.u-input {
  169. padding: 0 !important;
  170. }
  171. /deep/uni-textarea {
  172. padding: 0 !important;
  173. }
  174. </style>