index.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. let type=this.type
  56. console.log(this.type);
  57. console.log(JSON.stringify(this.selectVal));
  58. console.log('1111111')
  59. // return
  60. uni.navigateTo({
  61. url: '/pages/doc/docList?fileId=' + JSON.stringify(this.selectVal) + '&type=' + type
  62. })
  63. },
  64. getFiles(val = []) {
  65. this.$emit('updateVal', val);
  66. }
  67. }
  68. };
  69. </script>
  70. <style scoped lang="scss">
  71. .doc {
  72. position: relative;
  73. .box {
  74. position: absolute;
  75. right: -20rpx;
  76. top: -15rpx;
  77. width: 40rpx;
  78. z-index: 999;
  79. }
  80. uni-button {
  81. width: 100rpx;
  82. // height: 50rpx;
  83. margin-left: 10rpx;
  84. margin-right: 0;
  85. color: #fff !important;
  86. border: none;
  87. background: #157a2c !important;
  88. }
  89. }
  90. </style>