index.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <view class="">
  3. <uni-menubar title="文件管理" />
  4. <tm-search v-model="param.keyword" color="blue" @confirm="getfileList"></tm-search>
  5. <tm-sticky>
  6. <tm-tabs color="blue" @change="tabClick" v-model="activeIndex" :list="list" range-key="name"
  7. align="left"></tm-tabs>
  8. </tm-sticky>
  9. <view v-if="list.length>0">
  10. <tm-grouplist title="文件列表" title-theme="blue">
  11. <view v-for="(item,index) in fileList" :key="index">
  12. <tm-listitem @click="fileDetail(item)" :title="`${item.name}(${item.ext})`"
  13. :label="item.update_time" left-icon="icon-folder-fill" left-icon-color="blue" show-left-icon
  14. show-right-icon>
  15. <template v-slot:left>
  16. <tm-icons color="orange" name="icon-folder-fill" size="40"></tm-icons>
  17. </template>
  18. <template v-slot:rightValue>
  19. <view v-if="item.is_edit">
  20. 我的<text v-if="item.showc==0">(私有)</text><text v-if="item.showc==1">(公开)</text>
  21. </view>
  22. <view v-else>公共</view>
  23. </template>
  24. </tm-listitem>
  25. </view>
  26. </tm-grouplist>
  27. </view>
  28. <tm-flotbutton v-if="user.card_id>0" @click="uploadFile" label="添加" :show-text="true" color="bg-gradient-blue-accent">
  29. </tm-flotbutton>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. return {
  36. activeIndex: 0,
  37. list: [{
  38. 'name': '全部',
  39. 'id': 0
  40. }],
  41. fileList: [],
  42. pid: 0,
  43. param:{
  44. cate_id:0,
  45. keyword:'',
  46. }
  47. }
  48. },
  49. computed: {
  50. user() {
  51. return this.$tm.vx.state().user.userInfo || {}
  52. }
  53. },
  54. onLoad () {
  55. this.getFileClass()
  56. this.getfileList()
  57. // uni.$once('refresh',this.getfileList(0))
  58. this.getfileList(0)
  59. },
  60. methods: {
  61. fileDetail(item) {
  62. uni.navigateTo({
  63. url: "/pages/file/fileDetail?fileId=" + item.id + "&card_id=" + uni.getStorageSync('card_id')
  64. })
  65. },
  66. getFileClass() {
  67. this.$tm.request.post('file/cate').then(res => {
  68. this.list = [...this.list, ...res.data]
  69. })
  70. },
  71. getfileList() {
  72. this.$tm.request.post('file/list', this.param).then(res => {
  73. this.fileList = res.data
  74. })
  75. },
  76. tabClick(e) {
  77. this.activeIndex = e
  78. this.param.cate_id = this.list[e].id
  79. this.getfileList()
  80. },
  81. uploadFile() {
  82. // console.log(this.pid)
  83. uni.navigateTo({
  84. url: '/pages/file/uploadFile?pid=' + this.pid
  85. })
  86. }
  87. }
  88. }
  89. </script>
  90. <style lang="scss" scoped>
  91. </style>