index.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <div class="doc">
  3. <view class="box">
  4. <u-badge :value="value.length">
  5. </u-badge>
  6. </view>
  7. <view class="upload-row">
  8. <u-button :plain="true" :hairline="true" v-if="type != 'view'" size='mini' text="上传"
  9. @click="handleUpload"></u-button>
  10. <u-button :plain="true" :hairline="true" v-else size='mini' text="查看" @click="handleUpload"></u-button>
  11. </view>
  12. <docList ref="docListRef" @getFiles="getFiles"></docList>
  13. </div>
  14. </template>
  15. <script>
  16. import docList from './docList.vue';
  17. export default {
  18. name: 'index',
  19. components: {
  20. docList
  21. },
  22. model: {
  23. prop: 'value',
  24. event: 'updateVal'
  25. },
  26. props: {
  27. type: {
  28. type: String,
  29. default: ''
  30. },
  31. value: {
  32. type: Array,
  33. default: () => {
  34. return [];
  35. }
  36. }
  37. },
  38. data() {
  39. return {
  40. selectVal: ''
  41. };
  42. },
  43. watch: {
  44. value: {
  45. handler(newVal) {
  46. this.selectVal = newVal || [];
  47. },
  48. immediate: true
  49. }
  50. },
  51. created() {
  52. // uni.$off('getFiles')
  53. // uni.$on('getFiles', (id) => {
  54. // this.getFiles(id)
  55. // })
  56. },
  57. destroyed() {
  58. // uni.$off('getFiles')
  59. },
  60. methods: {
  61. handleUpload() {
  62. let type = this.type
  63. this.$refs.docListRef.open(this.selectVal,type)
  64. // uni.navigateTo({
  65. // url: '/pages/doc/docList?fileId=' + JSON.stringify(this.selectVal) + '&type=' + type
  66. // })
  67. },
  68. getFiles(val = []) {
  69. this.$emit('updateVal', val);
  70. }
  71. }
  72. };
  73. </script>
  74. <style scoped lang="scss">
  75. .doc {
  76. position: relative;
  77. .upload-row {
  78. display: flex;
  79. justify-content: flex-end;
  80. }
  81. .box {
  82. position: absolute;
  83. right: -20rpx;
  84. top: -15rpx;
  85. width: 40rpx;
  86. z-index: 999;
  87. }
  88. uni-button {
  89. width: 100rpx;
  90. // height: 50rpx;
  91. margin-left: 10rpx;
  92. margin-right: 0;
  93. color: #fff !important;
  94. border: none;
  95. background: #157a2c !important;
  96. }
  97. }
  98. </style>