|
@@ -42,25 +42,31 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
-import { nextTick, onMounted, ref, watch } from 'vue'
|
|
|
|
|
|
+import { onMounted, ref, watch } from 'vue'
|
|
import { useAppStore } from '~src/store'
|
|
import { useAppStore } from '~src/store'
|
|
import { deepClone, getArrValue, getObjValue, isNullES } from 'js-fast-way'
|
|
import { deepClone, getArrValue, getObjValue, isNullES } from 'js-fast-way'
|
|
-import mainApi from '~api/project/project'
|
|
|
|
-import treeApi from '~api/wbs/tree'
|
|
|
|
|
|
+import projectApi from '~api/project/project'
|
|
|
|
+import contractApi from '~api/project/contract'
|
|
|
|
+
|
|
|
|
+const props = defineProps({
|
|
|
|
+ data: {
|
|
|
|
+ type: Object,
|
|
|
|
+ default: () => ({}),
|
|
|
|
+ },
|
|
|
|
+})
|
|
|
|
+
|
|
|
|
+//事件
|
|
|
|
+const emit = defineEmits(['close', 'next'])
|
|
|
|
|
|
//缓存
|
|
//缓存
|
|
const store = useAppStore()
|
|
const store = useAppStore()
|
|
|
|
|
|
-//双向绑定
|
|
|
|
-const modelData = defineModel('modelValue', {
|
|
|
|
- default: {},
|
|
|
|
-})
|
|
|
|
-
|
|
|
|
//监听数据
|
|
//监听数据
|
|
-const formModel = ref({})
|
|
|
|
-watch(() => modelData.value, (data) => {
|
|
|
|
- formModel.value = data
|
|
|
|
-}, { immediate: true, deep: true })
|
|
|
|
|
|
+const dataInfo = ref(props.data)
|
|
|
|
+watch(() => props.data, (data) => {
|
|
|
|
+ dataInfo.value = data
|
|
|
|
+ getDataApi()
|
|
|
|
+}, { deep: true })
|
|
|
|
|
|
//监听
|
|
//监听
|
|
const userInfo = ref(store.getUserInfo)
|
|
const userInfo = ref(store.getUserInfo)
|
|
@@ -70,7 +76,7 @@ watch(() => store.getUserInfo, (info) => {
|
|
|
|
|
|
//渲染完成
|
|
//渲染完成
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
- getWbsTreeList()
|
|
|
|
|
|
+ getDataApi()
|
|
})
|
|
})
|
|
|
|
|
|
//树配置
|
|
//树配置
|
|
@@ -81,24 +87,55 @@ const treeProps = {
|
|
label: 'title',
|
|
label: 'title',
|
|
}
|
|
}
|
|
|
|
|
|
-//获取WBS树列表
|
|
|
|
-const wbsId = ref('')
|
|
|
|
-const wbsTreeList = ref([])
|
|
|
|
-const isLoading = ref(false)
|
|
|
|
-const getWbsTreeList = async () => {
|
|
|
|
|
|
+//获取数据
|
|
|
|
+const getDataApi = async () => {
|
|
|
|
+ await getProjectDeatil()
|
|
|
|
+ if (isNullES(wbsId.value)) return
|
|
|
|
+ await getLeftTreeApi()
|
|
|
|
+ await getRightTreeApi()
|
|
|
|
+}
|
|
|
|
|
|
|
|
+//获取项目详情
|
|
|
|
+const wbsId = ref('')
|
|
|
|
+const projectInfo = ref({})
|
|
|
|
+const getProjectDeatil = async () => {
|
|
|
|
+ wbsId.value = ''
|
|
|
|
+ projectInfo.value = {}
|
|
|
|
+ const { pid } = getObjValue(dataInfo.value)
|
|
|
|
+ if (isNullES(pid)) return
|
|
|
|
+ const { data } = await projectApi.detail(pid)
|
|
|
|
+ const res = getObjValue(data)
|
|
|
|
+ projectInfo.value = res
|
|
|
|
+ wbsId.value = res.referenceWbsTemplateId
|
|
}
|
|
}
|
|
|
|
|
|
-//左边树
|
|
|
|
|
|
+//获取WBS树列表
|
|
const leftLoading = ref(false)
|
|
const leftLoading = ref(false)
|
|
const leftTreeData = ref([])
|
|
const leftTreeData = ref([])
|
|
-
|
|
|
|
|
|
+const getLeftTreeApi = async () => {
|
|
|
|
+ leftLoading.value = true
|
|
|
|
+ const { pid } = getObjValue(dataInfo.value)
|
|
|
|
+ const { data } = await projectApi.findProjectTree({
|
|
|
|
+ projectId: pid,
|
|
|
|
+ wbsId: wbsId.value,
|
|
|
|
+ })
|
|
|
|
+ leftTreeData.value = getArrValue(data)
|
|
|
|
+ leftLoading.value = false
|
|
|
|
+}
|
|
|
|
|
|
//获取右边数据
|
|
//获取右边数据
|
|
const rightLoading = ref(false)
|
|
const rightLoading = ref(false)
|
|
const rightTreeData = ref([])
|
|
const rightTreeData = ref([])
|
|
const getRightTreeApi = async () => {
|
|
const getRightTreeApi = async () => {
|
|
-
|
|
|
|
|
|
+ rightLoading.value = true
|
|
|
|
+ const { pid, cid } = getObjValue(dataInfo.value)
|
|
|
|
+ const { data } = await contractApi.getContractInfoTree({
|
|
|
|
+ wbsId: wbsId.value,
|
|
|
|
+ projectId: pid,
|
|
|
|
+ contractId: cid,
|
|
|
|
+ })
|
|
|
|
+ rightTreeData.value = getArrValue(data)
|
|
|
|
+ rightLoading.value = false
|
|
}
|
|
}
|
|
|
|
|
|
//左边树被展开
|
|
//左边树被展开
|