tab-reform.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <hc-new-card>
  3. <template #extra>
  4. <HcNewSwitch :datas="tabData" :keys="tabKey" @change="tabChange" />
  5. </template>
  6. <HcTable ref="tableRef" :column="tableColumn" :datas="tableData" :loading="tableLoading" is-new :index-style="{ width: 60 }">
  7. <template #sourceType="{ row }">
  8. <span class="text-link" @click="tableRowName(row)">{{ row?.sourceType == 0 ? '巡检' : '验收' }}</span>
  9. </template>
  10. <template #fileName="{ row }">
  11. <span class="text-link" @click="tableRowName(row)">{{ row?.fileName }}</span>
  12. </template>
  13. </HcTable>
  14. <template #action>
  15. <HcPages :pages="searchForm" @change="pageChange" />
  16. </template>
  17. </hc-new-card>
  18. </template>
  19. <script setup>
  20. import { nextTick, ref, watch } from 'vue'
  21. import archiveFileApi from '~api/archiveFile/archiveFile'
  22. import earlyApi from '~api/custody/early'
  23. import { getArrValue } from 'js-fast-way'
  24. //参数
  25. const props = defineProps({
  26. projectId: {
  27. type: [String, Number],
  28. default: '',
  29. },
  30. contractId: {
  31. type: [String, Number],
  32. default: '',
  33. },
  34. treeData: {
  35. type: Object,
  36. default: () => ({}),
  37. },
  38. })
  39. //变量
  40. const projectId = ref(props.projectId)
  41. const contractId = ref(props.contractId)
  42. const nodeData = ref(props.treeData)
  43. //监听
  44. watch(() => [
  45. props.treeData,
  46. ], ([treeData]) => {
  47. nodeData.value = treeData
  48. setQueryData(treeData)
  49. },
  50. {
  51. deep: true,
  52. })
  53. //渲染完成
  54. nextTick(() => {
  55. // setQueryData(props.treeData)
  56. })
  57. //获取相关数据
  58. const setQueryData = (data) => {
  59. searchForm.value.nodeIds = data.id
  60. nodeData.value.id = data.id
  61. getTableData()
  62. /*const cid = data?.contractIdRelation || ''
  63. const wbsId = data['contractIdRelation'] ? data['id'] : data['primaryKeyId']
  64. if (wbsId) {
  65. searchInternalForm.value.contractId = cid ? cid : contractId.value;
  66. searchInternalForm.value.contractIdRelation = data['contractIdRelation']
  67. searchInternalForm.value.wbsIds = [wbsId]
  68. searchInternalClick()
  69. }*/
  70. }
  71. //搜索表单
  72. const searchForm = ref({
  73. current: 1, size: 20, total: 0,
  74. })
  75. //tab数据和相关处理
  76. const tabKey = ref('1')
  77. const tabData = ref([
  78. { key:'1', name: '需要整改的文件' },
  79. { key:'2', name: '已整改记录' },
  80. ])
  81. const tabChange = (item) => {
  82. tabKey.value = item?.key
  83. getTableData()
  84. }
  85. //名称被点击
  86. const tableRowName = (row) => {
  87. if (row['pdfFileUrl']) {
  88. window.open(row['pdfFileUrl'], '_blank')
  89. } else {
  90. window.$message?.warning('文件不存在')
  91. }
  92. }
  93. //分页被点击
  94. const pageChange = ({ current, size }) => {
  95. searchForm.value.current = current
  96. searchForm.value.size = size
  97. getTableData()
  98. }
  99. //内业台账表头
  100. const tableRef = ref(null)
  101. const tableColumn = ref([
  102. { key:'sourceType', name: '来源', width:150 },
  103. { key:'archiveName', name: '所属案卷' },
  104. { key:'fileName', name: '具体文件' },
  105. { key:'allopinion', name: '问题描述' },
  106. ])
  107. const tableData = ref([])
  108. //获取数据
  109. const tableLoading = ref(false)
  110. const getTableData = async () => {
  111. if (tabKey.value !== '1') {
  112. if (nodeData.value.id) {
  113. tableLoading.value = true
  114. const { error, code, data } = await archiveFileApi.getarchiveFilePage({
  115. ...searchForm.value,
  116. nodeIds: nodeData.value.id,
  117. projectId: projectId.value,
  118. contractId: contractId.value,
  119. rectification:tabKey.value,
  120. })
  121. tableLoading.value = false
  122. if (!error && code === 200) {
  123. tableData.value = getArrValue(data['records'])
  124. searchForm.value.total = data['total'] || 0
  125. } else {
  126. tableData.value = []
  127. searchForm.value.total = 0
  128. }
  129. }
  130. } else {
  131. tableLoading.value = true
  132. const { error, code, data } = await earlyApi.warningPage({
  133. ...searchForm.value,
  134. nodeIds: nodeData.value.id,
  135. projectId: projectId.value,
  136. contractId: contractId.value,
  137. rectification:tabKey.value,
  138. })
  139. tableLoading.value = false
  140. if (!error && code === 200) {
  141. tableData.value = getArrValue(data['records'])
  142. searchForm.value.total = data['total'] || 0
  143. } else {
  144. tableData.value = []
  145. searchForm.value.total = 0
  146. }
  147. }
  148. }
  149. // 暴露出去
  150. defineExpose({
  151. getTableData,
  152. })
  153. </script>