qualityRleation.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <!-- -->
  2. <template>
  3. <hc-new-dialog v-model="qualityMoadal" is-table title="关联质检资料" widths="1200px" @close="qulModalClose" @save="saveQualModal">
  4. <hc-new-card>
  5. <div class="relative h-full flex">
  6. <div :id="`hc_tree_card_${uuid}`" v-loading="treeLoading" class="hc_tree_card_border relative">
  7. <hc-body scrollbar padding="0px">
  8. <hc-lazy-tree tree-key="id" @load="treeLoadNode" @node-tap="nodeElTreeClick" />
  9. </hc-body>
  10. </div>
  11. <div :id="`hc_table_card_${uuid}`" class="relative flex-1">
  12. <HcTable :column="tableColumn" :datas="tableData" is-new is-check is-reserve-selection :loading="tableLoading" @selection-change="tableSelection">
  13. <template #appStatusName="{ row }">
  14. <el-tag
  15. v-if="row.appStatusName"
  16. :type="`${row.appStatusName === '已审批' ? 'success' : row.appStatusName === '待审批' ? 'warning' : row.appStatusName === '已废除' ? 'danger' : 'info'}`"
  17. class="mx-1" effect="dark"
  18. >
  19. {{ row.appStatusName }}
  20. </el-tag>
  21. </template>
  22. </HcTable>
  23. </div>
  24. </div>
  25. <template #action>
  26. <hc-pages :pages="searchForm" @change="pageChange" />
  27. </template>
  28. </hc-new-card>
  29. </hc-new-dialog>
  30. </template>
  31. <script setup>
  32. import { nextTick, ref, watch } from 'vue'
  33. import { getArrValue, getObjValue, getRandom } from 'js-fast-way'
  34. import { useAppStore } from '~src/store'
  35. import unitApi from '~api/project/debit/contract/unit'
  36. import { queryWbsTreeData } from '~api/other'
  37. const props = defineProps({
  38. qualityMoadal: {
  39. type: Boolean,
  40. default: false,
  41. },
  42. cid:{
  43. type:String,
  44. default:'',
  45. },
  46. periodId:{
  47. type:String,
  48. default:'',
  49. },
  50. })
  51. const emit = defineEmits([ 'close', 'finish'])
  52. const useAppState = useAppStore()
  53. const contractInfo = ref(useAppState.getContractInfo)
  54. const projectId = ref(useAppState.getProjectId || '')
  55. const { contractType } = contractInfo.value
  56. const classifyType = ref(contractType === 2 ? '2' : '1')
  57. const qualityMoadal = ref(props.qualityMoadal)
  58. const cid = ref(props.cid)
  59. const periodId = ref(props.periodId)
  60. watch(() => [
  61. props.qualityMoadal,
  62. props.cid,
  63. props.qualityMoadal,
  64. ], ([qual, Cid, Pid]) => {
  65. qualityMoadal.value = qual
  66. cid.value = Cid
  67. periodId.value = Pid
  68. })
  69. const uuid = getRandom(4)
  70. //监听
  71. watch(qualityMoadal, (val) => {
  72. if (val) {
  73. nextTick(() => {
  74. setSplitRef()
  75. tableData.value = []
  76. })
  77. }
  78. })
  79. //初始化设置拖动分割线
  80. const setSplitRef = () => {
  81. //配置参考: https://split.js.org/#/?direction=vertical&snapOffset=0
  82. try {
  83. window.$split(['#hc_tree_card_' + uuid, '#hc_table_card_' + uuid], {
  84. sizes: [20, 80],
  85. snapOffset: 0,
  86. minSize: [50, 500],
  87. })
  88. } catch (error) {
  89. console.log(error)
  90. }
  91. }
  92. //懒加载的数据
  93. const treeLoading = ref(false)
  94. const treeLoadNode = async ({ node, item, level }, resolve) => {
  95. let contractIdRelation = '', parentId = '', primaryKeyId = ''
  96. if (level !== 0) {
  97. const nodeData = getObjValue(item)
  98. contractIdRelation = nodeData?.contractIdRelation || ''
  99. parentId = contractIdRelation ? nodeData?.primaryKeyId : nodeData?.id
  100. primaryKeyId = nodeData?.id || ''
  101. }
  102. treeLoading.value = true
  103. //获取数据
  104. const { data } = await queryWbsTreeData({
  105. contractId: cid.value || '',
  106. contractIdRelation,
  107. primaryKeyId,
  108. parentId,
  109. classifyType: classifyType.value,
  110. tableOwner:classifyType.value,
  111. })
  112. treeLoading.value = false
  113. resolve(getArrValue(data))
  114. }
  115. const tableColumn = [
  116. { key: 'partName', name: '分/子分项部位' },
  117. { key: 'dataName', name: '资料名称' },
  118. { key: 'appStatusName', name: '资料审核状态' },
  119. ]
  120. const qulModalClose = ()=>{
  121. qualityMoadal.value = false
  122. emit('close')
  123. }
  124. //搜索表单
  125. const searchForm = ref({
  126. current: 1, size: 20, total: 0,
  127. })
  128. const pageChange = ({ current, size }) => {
  129. searchForm.value.current = current
  130. searchForm.value.size = size
  131. getTableData()
  132. }
  133. const tableData = ref([])
  134. const tableLoading = ref(false)
  135. const getTableData = async () => {
  136. tableData.value = []
  137. tableLoading.value = true
  138. const { data } = await unitApi.getCurrentNodeAllForm({
  139. ...searchForm.value,
  140. contractId:cid.value,
  141. projectId:projectId.value,
  142. nodeId:curTree.value.pKeyId,
  143. contractIdRelation:curTree.value?.contractIdRelation || '',
  144. })
  145. tableData.value = getArrValue(data['records'])
  146. searchForm.value.total = data.total || 0
  147. tableLoading.value = false
  148. }
  149. const curTree = ref(null)
  150. const nodeElTreeClick = ({ node, data, keys })=>{
  151. curTree.value = data
  152. getTableData()
  153. }
  154. //多选
  155. const tableKeys = ref([])
  156. const tableSelection = (rows) => {
  157. tableKeys.value = rows
  158. }
  159. const saveQualModal = ()=>{
  160. if ( tableKeys.value.length > 0) {
  161. qualityMoadal.value = false
  162. emit('close')
  163. emit('finish', tableKeys.value)
  164. } else {
  165. window.$message.warning('请先选择你要关联的质检资料')
  166. }
  167. }
  168. </script>
  169. <style lang='scss' scoped>
  170. </style>