fix : 修复页面细节

This commit is contained in:
2024-05-30 16:05:09 +08:00
parent 2ab4eb1a7e
commit 94528cfa06
18 changed files with 412 additions and 301 deletions

View File

@@ -1,22 +1,46 @@
<template>
<baseTitle title="标签名称"></baseTitle>
<el-input v-model="tagName" placeholder="请输入标签名称"/>
<el-form :model="formData" ref="tagForm" label-width="auto" :rules="rules">
<el-form-item label="标签名称" prop="tagName">
<el-input v-model="formData.tagName" placeholder="请输入标签名称" style="width: 400px"/>
</el-form-item>
</el-form>
<baseTitle title="其他文件"></baseTitle>
<el-card style="width: 100%;margin: 15px 0">
<file-upload @getFile="getOtherFile"/>
<file-upload @getFile="getFile"/>
<fvTable style="width: 100%;max-height: 250px;height: 250px" v-if="showTable" :tableConfig="tableConfig"
:data="otherFileList" :isSettingCol="false" :pagination="false">
:data="fileList" :isSettingCol="false" :pagination="false">
<template #empty>
<el-empty :image-size="90" description="暂无数据" style="padding: 0"/>
</template>
</fvTable>
</el-card>
<div class="oper-page-btn">
<el-button color="#DED0B2" @click="handleSubmit(tagForm)">提交</el-button>
</div>
</template>
<script setup lang="jsx">
const tagName = ref('')
const otherFileList = ref([])
import {uploadAttachment} from "@/api/project-manage";
import {ElNotification} from "element-plus";
import {useTagsView} from '@/stores/tagsview.js'
const tagsViewStore = useTagsView()
const route = useRoute()
const router = useRouter()
const fileList = ref([])
const formData = ref({
tagName:''
})
const tableConfig = reactive({
columns: [
{
prop: 'index',
type: 'index',
label: '序号',
align: 'center',
width: '80',
},
{
prop: 'originalFileName',
label: '附件名称',
@@ -47,8 +71,70 @@ const tableConfig = reactive({
]
})
const showTable = ref(true)
const getOtherFile = () => {
const tagForm = ref()
const name = ref(router.currentRoute.value.name)
const rules = reactive({
tagName: [{required: true, message: '请输入标签名称', trigger: 'blur'}],
})
const compositeParam = (item) => {
let tag = ''
if (name.value === 'Implementation/upload') {
tag = '项目实施'
}
return {
fileId: item.id,
size: item.size,
originalFileName: item.originalFilename,
fileType: item.fileType,
url: item.url,
tag: tag,
}
}
const getFile = (val) => {
console.log('上传文件', val)
showTable.value = false
let fileObj = compositeParam(val)
fileList.value.push(fileObj)
nextTick(() => {
showTable.value = true
})
}
const getFileParam = (item) => {
return {
fileId: item.fileId,
tag: item.tag
}
}
const handleSubmit = async (instance) => {
if (!instance) return
instance.validate(async (valid) => {
if (!valid) return
let files = []
fileList.value.forEach(item => {
files.push(getFileParam(item))
})
let params = {
fileList: files,
projectId: route.query.id,
tag: formData.value.tagName
}
console.log('params', params)
let res = await uploadAttachment(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: 'Implementation/attachment',
query:{
id: route.query.id
}
})
}
})
}
</script>