smart-bid-web/src/views/enterpriseLibrary/enterprise/components/EnterpriseForm.vue

385 lines
11 KiB
Vue
Raw Normal View History

2025-10-20 17:07:29 +08:00
<!-- 企业主体库表单 -->
<template>
2025-10-22 16:13:42 +08:00
<div class="app-container" :class="{ 'no-pointer-events': showUploadAnimation || showSaveAnimation }">
2025-10-21 18:15:48 +08:00
<!-- 全局上传动画 -->
<div v-if="showUploadAnimation" class="global-upload-animation">
<div class="animation-mask"></div>
<div class="animation-content">
<div class="spinner"></div>
<div class="animation-text">{{ animationText }}</div>
<div class="animation-subtext">正在处理文件请稍候...</div>
</div>
</div>
2025-10-22 16:13:42 +08:00
<!-- 保存动画 -->
<div v-if="showSaveAnimation" class="global-upload-animation">
<div class="animation-mask"></div>
<div class="animation-content">
<div class="spinner"></div>
<div class="animation-text">数据上传中</div>
<div class="animation-subtext">请稍后正在保存数据...</div>
</div>
</div>
2025-10-20 17:07:29 +08:00
<div class="content-header">
<el-button class="reset-btn" @click="handleClose()">返回</el-button>
2025-10-22 16:13:42 +08:00
<el-button class="search-btn" :loading="isSaving" @click="handleSave()">保存</el-button>
2025-10-20 17:07:29 +08:00
</div>
<div class="content-body">
<el-row :gutter="24" class="content-row">
<!-- 基本信息 -->
<el-col :span="6" class="pane-left">
<BasicInfo ref="basicInfo" />
</el-col>
<!-- 法人信息 -->
<el-col :span="6" class="pane-center">
<LegalPerson ref="legalPerson" />
</el-col>
<!-- 开户证明 -->
<el-col :span="6" class="pane-right">
<AccountOpeningCertificate ref="accountOpeningCertificate" />
</el-col>
</el-row>
</div>
</div>
</template>
2025-10-21 18:15:48 +08:00
2025-10-20 17:07:29 +08:00
<script>
import { decryptWithSM4 } from '@/utils/sm'
import BasicInfo from './child/BasicInfo.vue'
import LegalPerson from './child/LegalPerson.vue'
import AccountOpeningCertificate from './child/AccountOpeningCertificate.vue'
2025-10-21 18:15:48 +08:00
2025-10-20 17:07:29 +08:00
export default {
name: 'EnterpriseForm',
components: {
BasicInfo,
LegalPerson,
AccountOpeningCertificate
},
data() {
return {
id: decryptWithSM4(this.$route.query.id),
type: decryptWithSM4(this.$route.query.type),
2025-10-21 18:15:48 +08:00
showUploadAnimation: false,
2025-10-22 16:13:42 +08:00
showSaveAnimation: false, // 新增:保存动画状态
2025-10-21 18:15:48 +08:00
uploadQueue: 0, // 上传队列计数器
2025-10-22 16:13:42 +08:00
animationText: '识别中',
isSaving: false // 新增保存按钮loading状态
2025-10-20 17:07:29 +08:00
}
},
2025-10-22 16:13:42 +08:00
2025-10-20 17:07:29 +08:00
methods: {
2025-10-22 16:13:42 +08:00
2025-10-20 17:07:29 +08:00
// 返回
handleClose() {
const obj = { path: "/enterpriseLibrary/enterprise" }
this.$tab.closeOpenPage(obj)
},
// 保存
2025-10-21 18:15:48 +08:00
async handleSave() {
2025-10-22 16:13:42 +08:00
// 如果正在保存中,直接返回
if (this.isSaving) {
return
}
this.isSaving = true
this.showSaveAnimation = true
2025-10-20 17:07:29 +08:00
try {
// 并行校验所有表单
const [basicInfoData, legalPersonData, accountData] = await Promise.all([
this.$refs.basicInfo.validate(),
this.$refs.legalPerson.validate(),
this.$refs.accountOpeningCertificate.validate()
])
// 所有校验通过,组装完整数据
2025-10-22 16:13:42 +08:00
let formData = {
2025-10-20 17:07:29 +08:00
...basicInfoData,
...legalPersonData,
2025-10-22 16:13:42 +08:00
...accountData,
allFiles: [...basicInfoData.fileList, ...legalPersonData.fileList, ...legalPersonData.fileList2, ...accountData.fileList],
allFiles: [...basicInfoData.delFileList, ...legalPersonData.delFileList, ...accountData.delFileList]
2025-10-20 17:07:29 +08:00
}
console.log('所有表单校验通过,完整数据:', formData)
2025-10-22 16:13:42 +08:00
// 删除不必要的属性
delete formData.fileList;
delete formData.delFileList;
let allFiles = formData.allFiles.map(file => {
return {
...file.obj,
}
});
formData.allFiles = allFiles;
// 模拟保存请求(这里替换为您的实际保存接口)
await this.saveEnterprise(formData)
2025-10-20 17:07:29 +08:00
this.$message.success('保存成功')
2025-10-22 16:13:42 +08:00
// 保存成功后返回列表页
this.handleClose()
2025-10-20 17:07:29 +08:00
} catch (error) {
2025-10-22 16:13:42 +08:00
console.error('保存失败:', error)
this.$message.error(error.message || '保存失败,请重试')
} finally {
// 无论成功失败,都关闭动画
this.isSaving = false
this.showSaveAnimation = false
2025-10-20 17:07:29 +08:00
}
2025-10-21 18:15:48 +08:00
},
2025-10-22 16:13:42 +08:00
// 模拟保存接口
async saveEnterprise(formData) {
// 这里替换为您的实际保存接口
return new Promise((resolve, reject) => {
setTimeout(() => {
// 模拟保存成功
// 如果模拟失败,可以使用 reject(new Error('保存失败'))
resolve({ code: 200, message: '保存成功' })
}, 2000) // 模拟2秒的保存时间
})
},
2025-10-21 18:15:48 +08:00
// 开始上传
handleStartUpload(data) {
this.animationText = data
this.uploadQueue++
this.showUploadAnimation = true
},
// 结束上传
handleEndUpload(data) {
if (this.uploadQueue > 0) {
this.uploadQueue--
}
// 如果队列为空,隐藏动画
if (this.uploadQueue === 0) {
this.showUploadAnimation = false
}
2025-10-20 17:07:29 +08:00
}
2025-10-21 18:15:48 +08:00
},
mounted() {
// 监听上传开始事件
this.$bus.$on('startUpload', this.handleStartUpload)
// 监听上传结束事件
this.$bus.$on('endUpload', this.handleEndUpload)
},
beforeDestroy() {
// 移除所有事件监听
this.$bus.$off('startUpload', this.handleStartUpload)
this.$bus.$off('endUpload', this.handleEndUpload)
// 重置状态
this.showUploadAnimation = false
2025-10-22 16:13:42 +08:00
this.showSaveAnimation = false
2025-10-21 18:15:48 +08:00
this.uploadQueue = 0
this.animationText = '识别中'
2025-10-22 16:13:42 +08:00
this.isSaving = false
2025-10-21 18:15:48 +08:00
}
2025-10-20 17:07:29 +08:00
}
</script>
<style scoped lang="scss">
.app-container {
padding: 24px;
background: linear-gradient(180deg, #F1F6FF 20%, #E5EFFF 100%);
2025-10-20 18:29:12 +08:00
min-height: 100vh;
2025-10-20 17:07:29 +08:00
overflow-y: auto;
2025-10-21 18:15:48 +08:00
position: relative;
2025-10-21 18:18:44 +08:00
// 当显示动画时,禁用页面点击
&.no-pointer-events {
pointer-events: none;
// 子元素也继承禁用点击
* {
pointer-events: none;
}
}
2025-10-21 18:15:48 +08:00
}
// 全局上传动画样式
.global-upload-animation {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
2025-10-21 18:18:44 +08:00
// 动画区域本身可以有点击事件(如果需要)
pointer-events: auto;
2025-10-21 18:15:48 +08:00
.animation-mask {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
2025-10-21 18:18:44 +08:00
background: rgba(255, 255, 255, 0.6); // 添加半透明背景
2025-10-21 18:15:48 +08:00
backdrop-filter: blur(4px);
2025-10-21 18:18:44 +08:00
// 遮罩层阻止点击
pointer-events: auto;
2025-10-21 18:15:48 +08:00
}
.animation-content {
position: relative;
z-index: 10000;
text-align: center;
background: linear-gradient(135deg, #ffffff 0%, #f8faff 100%);
padding: 40px 50px;
border-radius: 20px;
box-shadow:
0 10px 40px rgba(31, 114, 234, 0.15),
0 0 0 1px rgba(31, 114, 234, 0.1);
min-width: 280px;
animation: slideInUp 0.3s ease-out;
2025-10-21 18:18:44 +08:00
// 动画内容可以有点击事件
pointer-events: auto;
2025-10-21 18:15:48 +08:00
.spinner {
width: 60px;
height: 60px;
border: 4px solid #f3f7ff;
border-top: 4px solid #1F72EA;
border-radius: 50%;
animation: spin 1.2s linear infinite;
margin: 0 auto 20px;
position: relative;
&::after {
content: '';
position: absolute;
top: -4px;
left: -4px;
right: -4px;
bottom: -4px;
border: 4px solid transparent;
border-top: 4px solid #4A8BFF;
border-radius: 50%;
animation: spin 0.8s linear infinite reverse;
}
}
.animation-text {
font-size: 20px;
font-weight: 600;
color: #1F72EA;
margin-bottom: 8px;
background: linear-gradient(135deg, #1F72EA 0%, #4A8BFF 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.animation-subtext {
font-size: 14px;
color: #666;
opacity: 0.8;
}
}
2025-10-20 17:07:29 +08:00
}
.content-body {
margin-top: 20px;
}
.content-row {
margin: 0;
display: flex;
flex-wrap: nowrap;
gap: 16px;
}
.pane-left,
.pane-center,
.pane-right {
background: #fff;
border-radius: 16px 16px 16px 16px;
min-height: 600px;
box-shadow: 0px 4px 20px 0px rgba(31, 35, 55, 0.1);
padding: 0;
margin-bottom: 20px;
flex: 1;
min-width: 0;
}
.content-header {
display: flex;
justify-content: flex-end;
align-items: center;
margin-bottom: 20px;
gap: 12px;
}
.search-btn {
2025-10-21 15:33:39 +08:00
width: 98px;
height: 36px;
background: #1F72EA;
box-shadow: 0px 4px 8px 0px rgba(51, 135, 255, 0.5);
border-radius: 4px;
border: none;
2025-10-20 17:07:29 +08:00
color: #fff;
font-size: 14px;
transition: all 0.3s ease;
&:hover {
2025-10-21 15:33:39 +08:00
background: #4A8BFF;
box-shadow: 0px 6px 12px 0px rgba(51, 135, 255, 0.6);
2025-10-20 17:07:29 +08:00
}
2025-10-22 16:13:42 +08:00
// 当按钮处于loading状态时的样式
&.is-loading {
opacity: 0.7;
pointer-events: none;
}
2025-10-20 17:07:29 +08:00
}
.reset-btn {
2025-10-21 15:33:39 +08:00
width: 98px;
height: 36px;
background: #FFFFFF;
box-shadow: 0px 4px 8px 0px rgba(76, 76, 76, 0.2);
border-radius: 4px;
border: none;
color: #666;
2025-10-20 17:07:29 +08:00
font-size: 14px;
transition: all 0.3s ease;
&:hover {
2025-10-21 15:33:39 +08:00
background: #f5f5f5;
2025-10-20 17:07:29 +08:00
color: #409EFF;
2025-10-21 15:33:39 +08:00
box-shadow: 0px 6px 12px 0px rgba(76, 76, 76, 0.3);
2025-10-20 17:07:29 +08:00
}
}
2025-10-21 18:15:48 +08:00
// 动画定义
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes slideInUp {
from {
opacity: 0;
transform: translateY(30px) scale(0.9);
}
to {
opacity: 1;
transform: translateY(0) scale(1);
}
}
2025-10-20 17:07:29 +08:00
</style>