detail.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <hc-drawer v-model="isShow" to-id="hc-project-list" is-close @close="drawerClose">
  3. <div class="hc-contract-info-drawer h-full">
  4. <hc-tab-card :scrollbar="tabsKey === '1'" :tabs="tabsData" :tab-key="tabsKey" is-action-btn @change="tabsChange">
  5. <HcInfo v-if="tabsKey === '1'" :data="dataInfo" @close="drawerClose" @next="dataInfoNext" />
  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 HcInfo from './info.vue'
  14. const props = defineProps({
  15. data: {
  16. type: Object,
  17. default: () => ({}),
  18. },
  19. })
  20. //事件
  21. const emit = defineEmits(['close'])
  22. //双向绑定
  23. const isShow = defineModel('modelValue', {
  24. default: false,
  25. })
  26. //监听数据
  27. const dataInfo = ref({})
  28. watch(() => props.data, (data) => {
  29. dataInfo.value = getObjValue(data)
  30. }, { immediate: true, deep: true })
  31. //监听显示
  32. watch(isShow, (val) => {
  33. if (val) getDataApi()
  34. })
  35. //处理相关数据
  36. const tabsKey = ref('1')
  37. const tabsData = ref([])
  38. const getDataApi = async () => {
  39. const { cid, tab } = getObjValue(dataInfo.value)
  40. if (isNullES(cid)) {
  41. tabsData.value = [{ key: '1', name: '合同段信息' }]
  42. } else {
  43. tabsData.value = [{ key: '1', name: '合同段信息' }, { key: '2', name: '分配WBS' }, { key: '3', name: '分配项目人员' }]
  44. }
  45. if (!isNullES(tab)) {
  46. tabsKey.value = tab
  47. }
  48. }
  49. //选项卡
  50. const tabsChange = ({ key }) => {
  51. tabsKey.value = key
  52. }
  53. //下一步
  54. const dataInfoNext = async (data) => {
  55. dataInfo.value = data
  56. await getDataApi()
  57. tabsKey.value = '2'
  58. }
  59. //关闭抽屉
  60. const drawerClose = () => {
  61. isShow.value = false
  62. tabsKey.value = '1'
  63. emit('close')
  64. }
  65. </script>
  66. <style lang="scss">
  67. .hc-contract-info-drawer {
  68. position: relative;
  69. }
  70. </style>