view-report.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <hc-new-drawer v-model="isShow" ui="hc-view-report-drawer" to-id="hc-main-box">
  3. <div class="relative h-full flex">
  4. <div :id="`hc_tree_card_${uuid}`">
  5. <hc-new-card scrollbar>
  6. <div v-for="(item, index1) in pdfData" :key="index1" class="hc-pdf-view-report-item" :class="pdfIndex === index1 ? 'cur' : ''" @click="changePdf(item, index1)">
  7. <hc-icon name="printer" />
  8. <span class="name">{{ item.title }}</span>
  9. </div>
  10. </hc-new-card>
  11. </div>
  12. <div :id="`hc_table_card_${uuid}`" class="flex-1">
  13. <hc-new-card>
  14. <template #header>
  15. <div class="text-18px font-bold">工程进度款审核表</div>
  16. </template>
  17. <template #extra>
  18. <el-button hc-btn type="warning" @click="backClick">返回</el-button>
  19. </template>
  20. <hc-pdfs :url="pdfUrl" />
  21. </hc-new-card>
  22. </div>
  23. </div>
  24. </hc-new-drawer>
  25. </template>
  26. <script setup>
  27. import { getArrValue, getRandom } from 'js-fast-way'
  28. import { nextTick, ref, watch } from 'vue'
  29. const props = defineProps({
  30. index: {
  31. type: [String, Number],
  32. default: '0',
  33. },
  34. datas: {
  35. type: Array,
  36. default: () => ([]),
  37. },
  38. })
  39. const emit = defineEmits(['search'])
  40. defineOptions({
  41. name: 'HcViewReport',
  42. })
  43. const uuid = getRandom(4)
  44. //双向绑定
  45. // eslint-disable-next-line no-undef
  46. const isShow = defineModel('modelValue', {
  47. default: '',
  48. })
  49. //监听
  50. watch(isShow, (val) => {
  51. if (val) {
  52. setSplitRef()
  53. pdfIndex.value = 0
  54. }
  55. })
  56. //初始化设置拖动分割线
  57. const setSplitRef = () => {
  58. //配置参考: https://split.js.org/#/?direction=vertical&snapOffset=0
  59. nextTick(() => {
  60. window.$split(['#hc_tree_card_' + uuid, '#hc_table_card_' + uuid], {
  61. sizes: [20, 80],
  62. snapOffset: 0,
  63. minSize: [50, 500],
  64. })
  65. })
  66. }
  67. //深度监听数据
  68. const pdfData = ref(props.datas)
  69. watch(() => props.datas, (data) => {
  70. pdfData.value = getArrValue(data)
  71. console.log( pdfData.value, ' pdfData.value')
  72. pdfUrl.value = pdfData.value[0].url
  73. }, { deep: true })
  74. //深度监听索引
  75. const pdfIndex = ref(0)
  76. //返回
  77. const backClick = () => {
  78. isShow.value = false
  79. pdfIndex.value = 0
  80. }
  81. const pdfUrl = ref('')
  82. const changePdf = (item, index)=>{
  83. pdfIndex.value = index
  84. pdfUrl.value = item.url
  85. }
  86. </script>
  87. <style lang="scss" scoped>
  88. .hc-pdf-view-report-item {
  89. position: relative;
  90. padding: 8px;
  91. display: flex;
  92. align-items: center;
  93. cursor: pointer;
  94. border-radius: 2px;
  95. transition: background-color .2s;
  96. .name {
  97. margin-left: 5px;
  98. }
  99. &:hover {
  100. background-color: var(--el-color-primary-light-8);
  101. }
  102. &.cur {
  103. background-color: var(--el-color-primary-light-8);
  104. color: var(--el-color-primary);
  105. }
  106. }
  107. </style>
  108. <style lang="scss">
  109. .el-overlay .el-drawer.hc-view-report-drawer {
  110. background-color: #F1F5F8;
  111. }
  112. </style>