|
@@ -59,25 +59,51 @@
|
|
</div>
|
|
</div>
|
|
<div class="hc-page-content-box hc-division-page">
|
|
<div class="hc-page-content-box hc-division-page">
|
|
<div v-if="isTemplateType" style="height: 50px" class="mb-2">
|
|
<div v-if="isTemplateType" style="height: 50px" class="mb-2">
|
|
- <hc-card class="text-right">
|
|
|
|
- <el-button
|
|
|
|
|
|
+ <hc-card>
|
|
|
|
+ <div class="aligin-center flex justify-between">
|
|
|
|
+ <div>
|
|
|
|
+ <el-button
|
|
|
|
+ :loading="downloadLoading"
|
|
|
|
+ hc-btn
|
|
|
|
+ type="warning"
|
|
|
|
+ color="#1591E4"
|
|
|
|
+ class="text-white"
|
|
|
|
+ @click="divisionExportClick"
|
|
|
|
+ >
|
|
|
|
+ <HcIcon name="folder-download" />
|
|
|
|
+ <span>导出划分</span>
|
|
|
|
+ </el-button>
|
|
|
|
+ <el-button
|
|
|
|
+ hc-btn
|
|
|
|
+ color="#1591E4"
|
|
|
|
+ class="text-white"
|
|
|
|
+ @click="divisionImportCodeClick"
|
|
|
|
+ >
|
|
|
|
+ <HcIcon name="folder-upload" />
|
|
|
|
+ <span>导入划分编码</span>
|
|
|
|
+ </el-button>
|
|
|
|
+ </div>
|
|
|
|
+ <div>
|
|
|
|
+ <el-button
|
|
|
|
|
|
- hc-btn
|
|
|
|
- type="warning"
|
|
|
|
- @click="divisionClick"
|
|
|
|
- >
|
|
|
|
- <HcIcon name="git-merge" />
|
|
|
|
- <span>节点划分</span>
|
|
|
|
- </el-button>
|
|
|
|
- <el-button
|
|
|
|
- hc-btn
|
|
|
|
- type="primary"
|
|
|
|
|
|
+ hc-btn
|
|
|
|
+ type="warning"
|
|
|
|
+ @click="divisionClick"
|
|
|
|
+ >
|
|
|
|
+ <HcIcon name="git-merge" />
|
|
|
|
+ <span>节点划分</span>
|
|
|
|
+ </el-button>
|
|
|
|
+ <el-button
|
|
|
|
+ hc-btn
|
|
|
|
+ type="primary"
|
|
|
|
|
|
- @click="divisionImportClick"
|
|
|
|
- >
|
|
|
|
- <HcIcon name="folder-received" />
|
|
|
|
- <span>节点导入</span>
|
|
|
|
- </el-button>
|
|
|
|
|
|
+ @click="divisionImportClick"
|
|
|
|
+ >
|
|
|
|
+ <HcIcon name="folder-received" />
|
|
|
|
+ <span>节点导入</span>
|
|
|
|
+ </el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
</hc-card>
|
|
</hc-card>
|
|
</div>
|
|
</div>
|
|
<div class="basic-info">
|
|
<div class="basic-info">
|
|
@@ -940,6 +966,7 @@
|
|
<span>取消</span>
|
|
<span>取消</span>
|
|
</el-button>
|
|
</el-button>
|
|
<el-button
|
|
<el-button
|
|
|
|
+
|
|
:disabled="uploadLoading"
|
|
:disabled="uploadLoading"
|
|
:loading="uploadLoading"
|
|
:loading="uploadLoading"
|
|
hc-btn
|
|
hc-btn
|
|
@@ -1049,6 +1076,7 @@
|
|
:before-upload="beforeUpload"
|
|
:before-upload="beforeUpload"
|
|
:show-file-list="false"
|
|
:show-file-list="false"
|
|
:on-change="handleChange"
|
|
:on-change="handleChange"
|
|
|
|
+ :disabled="isCanClickImport"
|
|
>
|
|
>
|
|
<div class="mt-24px text-black">将文件拖动到此处,<span class="text-blue">或点击上传</span></div>
|
|
<div class="mt-24px text-black">将文件拖动到此处,<span class="text-blue">或点击上传</span></div>
|
|
<div class="mt-8px text-12px">支持的文件格式:.xls,.xlsx</div>
|
|
<div class="mt-8px text-12px">支持的文件格式:.xls,.xlsx</div>
|
|
@@ -1065,12 +1093,20 @@
|
|
</el-button>
|
|
</el-button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
- <div class="text-right">
|
|
|
|
- <el-button hc-btn type="success" :loading="downLoadTemplateLoading" @click="downLoadTemplate">
|
|
|
|
|
|
+ <div class="mt-2 text-right">
|
|
|
|
+ <el-button hc-btn type="primary" :loading="downLoadTemplateLoading" @click="downLoadTemplate">
|
|
<HcIcon name="download-2" />
|
|
<HcIcon name="download-2" />
|
|
导入模板
|
|
导入模板
|
|
</el-button>
|
|
</el-button>
|
|
</div>
|
|
</div>
|
|
|
|
+ <div v-if="progressData > 0" class="mt-4">
|
|
|
|
+ <el-progress
|
|
|
|
+ :text-inside="true"
|
|
|
|
+ :stroke-width="24"
|
|
|
|
+ :percentage="progressData"
|
|
|
|
+ status="success"
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<template #footer>
|
|
<template #footer>
|
|
@@ -1118,7 +1154,7 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
-import { computed, nextTick, onActivated, onMounted, ref, watch } from 'vue'
|
|
|
|
|
|
+import { computed, nextTick, onActivated, onMounted, onUnmounted, ref, watch } from 'vue'
|
|
import { useAppStore } from '~src/store'
|
|
import { useAppStore } from '~src/store'
|
|
import { useRouter } from 'vue-router'
|
|
import { useRouter } from 'vue-router'
|
|
import HcUpload from './components/division/HcUpload.vue'
|
|
import HcUpload from './components/division/HcUpload.vue'
|
|
@@ -1149,6 +1185,7 @@ import { HcDelMsg, getHeader } from 'hc-vue3-ui'
|
|
|
|
|
|
import { getChildList } from '~api/other'
|
|
import { getChildList } from '~api/other'
|
|
import { getDictionaryData } from '~uti/tools'
|
|
import { getDictionaryData } from '~uti/tools'
|
|
|
|
+import { HcUploadFileApi } from 'hc-vue3-ui'
|
|
|
|
|
|
//初始变量
|
|
//初始变量
|
|
const router = useRouter()
|
|
const router = useRouter()
|
|
@@ -2712,13 +2749,92 @@ const divisionSaveClick = ()=>{
|
|
divisionDialogShow.value = false
|
|
divisionDialogShow.value = false
|
|
window?.location?.reload() //刷新页面
|
|
window?.location?.reload() //刷新页面
|
|
}
|
|
}
|
|
|
|
+// 添加一个定时器引用
|
|
|
|
+const progressTimer = ref(null)
|
|
|
|
+//是否可以点击节点导入
|
|
|
|
+const isCanClickImport = ref(false)
|
|
|
|
+
|
|
|
|
+const getIsImportData = async () => {
|
|
|
|
+ const { error, code, data } = await divisionApi.getIsImport({
|
|
|
|
+ projectId: projectId.value,
|
|
|
|
+ contractId: contractId.value,
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ if (!error && code === 200) {
|
|
|
|
+ isCanClickImport.value = data
|
|
|
|
+ if (data) {
|
|
|
|
+ getImportProgressData()
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ isCanClickImport.value = false
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+const progressData = ref(0)
|
|
|
|
+const getImportProgressData = async () => {
|
|
|
|
+ const { error, code, data } = await divisionApi.getImportProgress({
|
|
|
|
+ projectId: projectId.value,
|
|
|
|
+ contractId: contractId.value,
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ if (!error && code === 200) {
|
|
|
|
+ progressData.value = Number(data)
|
|
|
|
+ // 如果进度到达100%,清除定时器
|
|
|
|
+ if (progressData.value >= 100) {
|
|
|
|
+ clearProgressTimer()
|
|
|
|
+ // 可以添加完成后的处理逻辑
|
|
|
|
+ window.$message.success('导入完成')
|
|
|
|
+ divisionImportDialog.value = false
|
|
|
|
+ window.location.reload()
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ progressData.value = 0
|
|
|
|
+ }
|
|
|
|
+}
|
|
//节点导入
|
|
//节点导入
|
|
const divisionImportDialog = ref(false)
|
|
const divisionImportDialog = ref(false)
|
|
|
|
+// 修改 divisionImportDialog 的监听
|
|
|
|
+watch(() => divisionImportDialog.value, (newVal) => {
|
|
|
|
+ if (newVal && isCanClickImport.value) {
|
|
|
|
+ // 弹窗打开且允许导入时,开启定时器
|
|
|
|
+ startProgressTimer()
|
|
|
|
+ } else {
|
|
|
|
+ // 弹窗关闭时清除定时器
|
|
|
|
+ clearProgressTimer()
|
|
|
|
+ }
|
|
|
|
+})
|
|
|
|
+// 开启进度查询定时器
|
|
|
|
+const startProgressTimer = () => {
|
|
|
|
+ // 确保先清除可能存在的定时器
|
|
|
|
+ clearProgressTimer()
|
|
|
|
+
|
|
|
|
+ // 立即执行一次
|
|
|
|
+ getImportProgressData()
|
|
|
|
+
|
|
|
|
+ // 设置定时器,每5秒执行一次
|
|
|
|
+ progressTimer.value = setInterval(() => {
|
|
|
|
+ getImportProgressData()
|
|
|
|
+ }, 5000)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 清除定时器
|
|
|
|
+const clearProgressTimer = () => {
|
|
|
|
+ if (progressTimer.value) {
|
|
|
|
+ clearInterval(progressTimer.value)
|
|
|
|
+ progressTimer.value = null
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+// 在组件销毁时清理定时器
|
|
|
|
+onUnmounted(() => {
|
|
|
|
+ clearProgressTimer()
|
|
|
|
+})
|
|
|
|
+
|
|
//上传文件
|
|
//上传文件
|
|
const dialogUploadRef = ref(null)
|
|
const dialogUploadRef = ref(null)
|
|
-const divisionImportClick = ()=>{
|
|
|
|
-
|
|
|
|
|
|
+const divisionImportClick = async ()=>{
|
|
|
|
+ await getIsImportData()
|
|
|
|
+ await nextTick()
|
|
divisionImportDialog.value = true
|
|
divisionImportDialog.value = true
|
|
|
|
+ fileList.value = []
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -2760,9 +2876,9 @@ const handleSuccess = (res) => {
|
|
|
|
|
|
divisionImportDialog.value = false
|
|
divisionImportDialog.value = false
|
|
|
|
|
|
- setTimeout(()=>{
|
|
|
|
- window?.location?.reload() //刷新页面
|
|
|
|
- }, 1000)
|
|
|
|
|
|
+// setTimeout(()=>{
|
|
|
|
+// window?.location?.reload() //刷新页面
|
|
|
|
+// }, 1000)
|
|
|
|
|
|
} else {
|
|
} else {
|
|
window.$message.error(res.msg || '上传失败')
|
|
window.$message.error(res.msg || '上传失败')
|
|
@@ -2778,10 +2894,19 @@ const handleError = (error) => {
|
|
} else {
|
|
} else {
|
|
window.$message.error(msg)
|
|
window.$message.error(msg)
|
|
}
|
|
}
|
|
|
|
+ fileList.value = []
|
|
|
|
+
|
|
}
|
|
}
|
|
-const confirmTap = ()=>{
|
|
|
|
|
|
+const confirmTap = async ()=>{
|
|
confirmLoading.value = true
|
|
confirmLoading.value = true
|
|
dialogUploadRef.value.submit()
|
|
dialogUploadRef.value.submit()
|
|
|
|
+ setTimeout(async ()=>{
|
|
|
|
+ await getIsImportData()
|
|
|
|
+ if ( isCanClickImport.value) {
|
|
|
|
+ startProgressTimer()
|
|
|
|
+ }
|
|
|
|
+ }, 3000)
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -2873,6 +2998,42 @@ const saveNodeNmeClick = async () => {
|
|
const contentStyle = computed(() => ({
|
|
const contentStyle = computed(() => ({
|
|
'--project-info-height': !isTemplateType.value ? 'calc(100% - 238px)' : 'calc(100% - 298px)',
|
|
'--project-info-height': !isTemplateType.value ? 'calc(100% - 238px)' : 'calc(100% - 298px)',
|
|
}))
|
|
}))
|
|
|
|
+const downloadLoading = ref(false)
|
|
|
|
+const divisionExportClick = async ()=>{
|
|
|
|
+
|
|
|
|
+ downloadLoading.value = true
|
|
|
|
+ const { error, disposition, res } = await divisionApi.exportTree({
|
|
|
|
+ contractId: contractId.value,
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ //处理数据
|
|
|
|
+ downloadLoading.value = false
|
|
|
|
+ if (!error) {
|
|
|
|
+ if (disposition) {
|
|
|
|
+ downloadBlob(res, disposition)
|
|
|
|
+ } else {
|
|
|
|
+ window.$message?.error('数据异常')
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+//导入划分模板
|
|
|
|
+const divisionImportCodeClick = ()=>{
|
|
|
|
+ HcUploadFileApi({
|
|
|
|
+ url: '/api/blade-manager/wbsTreeContract/importPartitionCode',
|
|
|
|
+ accept: '.xls,.xlsx,',
|
|
|
|
+ accept_tip: 'Excel(xls、xlsx)<br/>',
|
|
|
|
+
|
|
|
|
+ multiple: false,
|
|
|
|
+
|
|
|
|
+ success: ({ echoParams }, { data }) => {
|
|
|
|
+ window.$message.success(data?.msg || '上传成功')
|
|
|
|
+ },
|
|
|
|
+ error: () => {
|
|
|
|
+ window.$message.error('上传失败')
|
|
|
|
+ },
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+const uploadProgress = ref(false)
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|