tab.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <div class="normal-panel tab__panel">
  3. <div>
  4. <el-tabs v-model="activeName" @tab-click="handleClick">
  5. <el-tab-pane v-for="(tab,index) in tabs" :key="index" :label="tab" :name="'tab' + index"></el-tab-pane>
  6. <el-tab-pane label="附件" name="file"></el-tab-pane>
  7. <el-tab-pane label="操作记录" name="log"></el-tab-pane>
  8. </el-tabs>
  9. </div>
  10. <div v-show="'tab'+index === activeName" v-for="(item,index) in tabs" :key="index">
  11. <slot v-if="'tab'+index === activeName" :name="'slot' + index"></slot>
  12. </div>
  13. <div v-show="activeName === 'file'">
  14. <attachmentList v-if="activeName === 'file'" :attinfos="attinfo_attachment" @onSuccess="queryAttments" @cancelEdit="queryAttments">
  15. <upload slot="upload" :folderid="folderid"
  16. :bindData="{ ownertable: ownertable, ownerid: editData[idname], usetype: 'default' }"
  17. @onSuccess="queryAttments"></upload>
  18. </attachmentList>
  19. </div>
  20. <div v-show="activeName === 'log'">
  21. <datalog v-if="activeName === 'log'" :editData="editData" :idname="idname" :ownertable="ownertable"></datalog>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. import attachmentList from '@/components/attachment_list/index.vue'
  27. import upload from '@/components/upload/hw_obs_upload.vue'
  28. import datalog from '../datalog/index.vue'
  29. export default {
  30. props:['tabs','editData','ownertable','idname'],
  31. components:{
  32. attachmentList,
  33. upload,
  34. datalog
  35. },
  36. data () {
  37. return {
  38. activeName:'tab0',
  39. attinfo_attachment:[],
  40. folderid:JSON.parse(sessionStorage.getItem('folderid')).appfolderid,
  41. }
  42. },
  43. methods:{
  44. async queryAttments () {
  45. console.log(this.idname,'---')
  46. const res = await this.$api.requested({
  47. "classname": "system.attachment.Attachment",
  48. "method": "queryFileLink",
  49. "content": {
  50. "ownertable": this.ownertable,
  51. "ownerid": this.editData[this.idname],
  52. "usetype":""
  53. }
  54. })
  55. this.attinfo_attachment = res.data
  56. },
  57. handleClick(){
  58. console.log(this.activeName)
  59. this.$emit('onTabClick')
  60. }
  61. },
  62. mounted () {
  63. setTimeout(() => {
  64. if (!this.tabs) {this.activeName = 'file'} else {
  65. this.activeName = 'tab0'
  66. }
  67. }, 1000);
  68. },
  69. watch: {
  70. activeName (val) {
  71. val === 'file'?this.queryAttments():''
  72. }
  73. },
  74. }
  75. </script>
  76. <style>
  77. .tab__panel .el-tabs__item{
  78. color:#999
  79. }
  80. .tab__panel .el-tabs__item.is-active {
  81. color:#3874f6
  82. }
  83. </style>
  84. <style scoped>
  85. .tab__panel{
  86. padding:0 10px 10px 10px;
  87. border-radius:5px;
  88. }
  89. </style>