index.vue 1.5 KB

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