fix : 修复页面细节功能及附件上传组件

This commit is contained in:
2024-05-20 00:29:31 +08:00
parent 1f4389eb5e
commit 9661cdbb2b
10 changed files with 268 additions and 157 deletions

View File

@@ -202,7 +202,7 @@
<el-input v-model="formData.economicEstimate" clearable></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-col :span="12">
<el-form-item label="其中申请公司总部科技创新专项资金(万元)" prop="specialFundAmount">
<el-input v-model="formData.specialFundAmount" clearable></el-input>
</el-form-item>
@@ -221,24 +221,27 @@
</el-form>
<AttachmentUpload ref="attachment" label="需求申请书附件" :showTable="showTable" :otherFileList="otherFileList"
@getAttachment="getAttachment"
@getOtherFile="getOtherFile" :showFileList="true"/>
@getOtherFile="getOtherFile" :showFileList="true" :formData="formData" :preview="router.currentRoute.value.name === 'Summary/edit'"/>
<!-- <fvForm :schema="schame" @getInstance="getInstance"></fvForm>-->
<div class="oper-page-btn">
<el-button type="primary" @click="staging">存为草稿</el-button>
<el-button type="primary" @click="handleSubmit(summaryForm)">发布</el-button>
<el-button color="#DED0B2" @click="handleResubmit">重新发布</el-button>
</div>
</div>
</template>
<script setup lang="jsx">
import {getProcessInfo, requirementReported} from "./api";
import {ElNotification} from "element-plus";
import {getDetail, getProcessInfo, requirementReported, resubmitReported} from "./api";
import {ElMessage, ElNotification} from "element-plus";
import {useTagsView} from '@/stores/tagsview.js'
import {useCacheStore} from '@/stores/cache.js'
import {getSubCompOpt} from "../../../api/user/user";
import {getSubCompOpt} from "@/api/user/user";
const cacheStore = useCacheStore()
const router = useRouter()
const route = useRoute()
const name=ref(router.currentRoute.value.name)
const tagsViewStore = useTagsView()
const companyOption = ref([])
const summaryForm = ref()
@@ -246,10 +249,8 @@ const attachment = ref()
const deploymentId = ref()
const showTable = ref(true)
const otherFileList = ref([])
const fileList = ref([])
const formData = ref({
specialFund: null
})
const file = ref({})
const formData = ref({})
const rules = reactive({
projectName: [{required: true, message: '请输入名称', trigger: 'blur'}],
specialFund: [{required: true, message: '请选择专项资金', trigger: 'blur'}],
@@ -278,29 +279,29 @@ const rules = reactive({
})
const compositeParam = (item, type) => {
let tag = ''
if (router.currentRoute.value.name === 'Summary/add') {
if ( name.value=== 'Summary/add'||name.value === 'Summary/edit') {
tag = '需求上报'
}
return {
fileId: item.id,
size: item.size,
type: type,
originalFileName: item.originalFilename,
fileType: item.fileType,
url: item.url,
processNodeTag: null,
tag: tag
}
}
const getEditOtherFile=(val)=>{
console.log('getEditOtherFile',val)
}
const getAttachment = (val) => {
console.log('上传文件getAttachment', val)
let fileObj = compositeParam(val, 1)
fileList.value.push(fileObj)
file.value = compositeParam(val)
}
const getOtherFile = (val) => {
console.log('上传文件getOtherFile', val)
showTable.value = false
let fileObj = compositeParam(val, 2)
let fileObj = compositeParam(val)
otherFileList.value.push(fileObj)
nextTick(() => {
showTable.value = true
@@ -308,14 +309,31 @@ const getOtherFile = (val) => {
}
const getFileParam = (item) => {
return {
fileId: item.fileId,
type: item.type
fileId: item.fileId
}
}
const handleSubmit = async (instance) => {
// if (!instance) return
// instance.validate(async (valid, fields) => {
// if(JSON.stringify(file.value) == "{}"){
// attachment.value.validate()
// } else {
// attachment.value.clearValidate()
// }
// if (!valid) return
let singleFile = {}
if (file.value.fileId !== undefined) {
singleFile = {
fileId: file.value.fileId
}
}
let otherFiles = []
otherFileList.value.forEach(item => {
otherFiles.push(getFileParam(item))
})
let params = {
"specialFund": "2",
"projectName": "3",
"projectName": "重新提交全流程测试",
"startTime": "2024-05-24 00:00:00",
"endTime": "2024-05-29 00:00:00",
"projectType": "3",
@@ -338,65 +356,104 @@ const handleSubmit = async (instance) => {
"serviceDescription": "3",
"contentDescription": "3",
"specialFundAmount": "3",
"deploymentId": "e75b2040-15b4-11ef-8cdf-f268fc747b04",
"files": [
{
"fileId": 207,
"type": 1
},
],
deploymentId: deploymentId.value,
"singleFile": singleFile,
"files": otherFiles,
// "requirementId":route.query.id,
"requirementId": 102
}
// if (!instance) return
// instance.validate(async (valid, fields) => {
// if (fileList.value.length === 0) {
// attachment.value.validate()
// } else {
// attachment.value.clearValidate()
// }
// if (!valid) return
let files = []
fileList.value.forEach(item => {
files.push(getFileParam(item))
// ...formData.value,
// deploymentId: deploymentId.value,
// files: files,
// requirementId:102
// }
let res = await requirementReported(params)
ElNotification({
title: '提示',
message: res.msg,
type: res.code === 1000 ? 'success' : 'error'
})
if (res.code === 1000) {
tagsViewStore.delVisitedViews(router.currentRoute.value.path)
await router.push({
name: 'Summary'
})
otherFileList.value.forEach(item => {
files.push(getFileParam(item))
})
// ...formData.value,
// deploymentId: deploymentId.value,
// files: files,
// requirementId:102
// }
let res = await requirementReported(params)
}
// })
}
const handleResubmit = () => {
let singleFile = {}
let otherFiles = []
let fileArray
if(name.value === 'Summary/edit'){
singleFile = {
fileId: attachment.value.singleFile.fileId
}
fileArray=attachment.value.allFileList
}else {
if (file.value.fileId !== undefined) {
singleFile = {
fileId: file.value.fileId
}
}
fileArray=otherFileList.value
}
fileArray.forEach(item => {
otherFiles.push(getFileParam(item))
})
let params={
...formData.value,
deploymentId: deploymentId.value,
files: otherFiles,
singleFile: singleFile,
requirementId: 102
}
console.log('重新提交params',params)
resubmitReported(params).then(res => {
if (res.code === 1000) {
ElMessage.success(res.msg)
tagsViewStore.delVisitedViews(router.currentRoute.value.path)
router.push({
name: 'Summary'
})
} else {
ElMessage.error(res.msg)
}
})
}
const getDetailInfo = async () => {
getDetail(route.query.projectId).then(res => {
ElNotification({
title: '提示',
message: res.msg,
type: res.code === 1000 ? 'success' : 'error'
})
if (res.code === 1000) {
tagsViewStore.delVisitedViews(router.currentRoute.value.path)
await router.push({
name: 'Summary'
})
formData.value = res.data.formData
}
// })
})
}
const init = async () => {
const res = await getSubCompOpt()
companyOption.value = res.data
getProcessInfo().then(res => {
ElNotification({
title: '提示',
message: res.msg,
type: res.code === 1000 ? 'success' : 'error'
})
// ElNotification({
// title: '提示',
// message: res.msg,
// type: res.code === 1000 ? 'success' : 'error'
// })
if (res.code === 1000) {
let data = res.data
deploymentId.value = data.deploymentId
}
})
}
init()
onMounted(async () => {
await init()
if (route.query.id) {
await getDetailInfo()
}
})
const staging = async () => {
}
</script>