docList.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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'></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);
  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. }
  96. }
  97. </script>
  98. <style lang="scss" scoped>
  99. .listTitle {
  100. width: 420rpx;
  101. white-space: nowrap;
  102. /* 防止文本换行 */
  103. overflow: hidden;
  104. /* 隐藏溢出的内容 */
  105. text-overflow: ellipsis;
  106. /* 显示省略符号来代表被修剪的文本 */
  107. }
  108. .topBtn {
  109. display: flex;
  110. margin-bottom: 20rpx;
  111. margin-top: 10rpx;
  112. uni-button {
  113. width: 180rpx;
  114. margin-left: 5px;
  115. margin-right: 5px;
  116. }
  117. }
  118. .listBtn {
  119. display: flex;
  120. uni-button {
  121. width: 100rpx;
  122. // height: 50rpx;
  123. margin-left: 10rpx;
  124. margin-right: 0;
  125. color: #fff !important;
  126. border: none;
  127. background: #157a2c !important;
  128. }
  129. }
  130. .footerButton {
  131. width: 100%;
  132. height: 84rpx;
  133. display: flex;
  134. position: fixed;
  135. bottom: 0;
  136. z-index: 10;
  137. /deep/.u-button {
  138. height: 100%;
  139. }
  140. >view {
  141. flex: 1;
  142. }
  143. }
  144. .item {
  145. display: flex;
  146. flex-direction: column;
  147. padding: 16rpx;
  148. >view {
  149. padding-top: 14rpx;
  150. }
  151. .item_title {
  152. font-size: 32rpx;
  153. font-weight: 800;
  154. }
  155. .item_list {
  156. display: flex;
  157. align-items: center;
  158. text {
  159. font-size: 28rpx;
  160. }
  161. .lable {
  162. color: #626060;
  163. }
  164. .value {
  165. color: #333;
  166. margin-left: 12rpx;
  167. flex: 1
  168. }
  169. }
  170. }
  171. /deep/.u-swipe-action-item__right__button__wrapper {
  172. background-color: #f56c6c !important;
  173. }
  174. /deep/.u-input {
  175. padding: 0 !important;
  176. }
  177. /deep/uni-textarea {
  178. padding: 0 !important;
  179. }
  180. </style>