detail.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <hc-drawer v-model="isShow" to-id="hc-project-list" is-close @close="drawerClose">
  3. <div class="hc-contract-info-drawer relative h-full">
  4. <hc-tab-card :scrollbar="tabsKey === '1'" :tabs="tabsData" :tab-key="tabsKey" is-action-btn @change="tabsChange">
  5. 111111
  6. </hc-tab-card>
  7. </div>
  8. </hc-drawer>
  9. </template>
  10. <script setup>
  11. import { ref, watch } from 'vue'
  12. import { getObjValue, isNullES } from 'js-fast-way'
  13. import { getDictionaryData } from '~uti/tools'
  14. import mainApi from '~api/project/contract'
  15. import projectApi from '~api/project/project'
  16. const props = defineProps({
  17. data: {
  18. type: Object,
  19. default: () => ({}),
  20. },
  21. })
  22. //事件
  23. const emit = defineEmits(['close'])
  24. //双向绑定
  25. const isShow = defineModel('modelValue', {
  26. default: false,
  27. })
  28. //监听数据
  29. const dataInfo = ref(props.data)
  30. watch(() => props.data, (data) => {
  31. dataInfo.value = data
  32. }, { immediate: true, deep: true })
  33. //监听显示
  34. watch(isShow, (val) => {
  35. if (val) getDataApi()
  36. })
  37. //处理相关数据
  38. const tabsKey = ref('1')
  39. const tabsData = ref([])
  40. const getDataApi = async () => {
  41. const { cid, type, tab } = getObjValue(dataInfo.value)
  42. if (isNullES(cid)) {
  43. tabsData.value = [{ key: '1', name: '合同段信息' }]
  44. } else {
  45. tabsData.value = [{ key: '1', name: '合同段信息' }, { key: '2', name: '分配WBS' }, { key: '3', name: '分配项目人员' }]
  46. }
  47. await getContractTypeList()
  48. if (!isNullES(cid)) {
  49. if ([1, 4, 8].includes(type)) {
  50. await getContractInfo()
  51. } else if ([2, 3].includes(type)) {
  52. await getContractInfo2()
  53. await getContractRelation()
  54. }
  55. }
  56. await getProjectDeatil()
  57. if (!isNullES(tab)) {
  58. tabsKey.value = tab
  59. }
  60. getStoragePeriodList()
  61. getSecurityLevelList()
  62. setHeaders()
  63. }
  64. //获取项目详情
  65. const getProjectDeatil = async () => {
  66. //mainApi
  67. }
  68. //获取合同类型
  69. const contractTypeList = ref([])
  70. const getContractTypeList = async () => {
  71. contractTypeList.value = await getDictionaryData('contract_type')
  72. }
  73. //获取合同段基本信息
  74. const contractForm = ref({})
  75. const getContractInfo = async () => {
  76. const { cid } = getObjValue(dataInfo.value)
  77. contractForm.value = {}
  78. if (isNullES(cid)) return
  79. const { data } = await mainApi.detail(cid)
  80. contractForm.value = getObjValue(data)
  81. }
  82. //获取合同段基本信息
  83. const getContractInfo2 = async () => {
  84. const { cid, type } = getObjValue(dataInfo.value)
  85. contractForm.value = {}
  86. if (isNullES(cid)) return
  87. const { data } = await mainApi.detail2({
  88. id: cid,
  89. contractType: type,
  90. })
  91. contractForm.value = getObjValue(data)
  92. }
  93. //监理、业主关联施工
  94. const getContractRelation = async () => {
  95. const { cid } = getObjValue(dataInfo.value)
  96. if (isNullES(cid)) return
  97. const { data } = await projectApi.getContractRelation(cid)
  98. console.log(data)
  99. }
  100. //获取业务字典
  101. const getStoragePeriodList = async () => {
  102. }
  103. //获取安全等级
  104. const getSecurityLevelList = async () => {
  105. }
  106. const setHeaders = async () => {
  107. }
  108. //选项卡
  109. const tabsChange = ({ key }) => {
  110. tabsKey.value = key
  111. }
  112. //关闭抽屉
  113. const drawerClose = () => {
  114. isShow.value = false
  115. tabsKey.value = '1'
  116. emit('close')
  117. }
  118. </script>
  119. <style lang="scss">
  120. .hc-contract-info-drawer {
  121. }
  122. </style>