Commit 6bbe241c by yuzhenWang

先提交测试

parent 20e7b750
...@@ -159,3 +159,41 @@ export function importExcel(data) { ...@@ -159,3 +159,41 @@ export function importExcel(data) {
data: data data: data
}) })
} }
// 上传获取材料列表
export function uploadMaterialList(data) {
return request({
url: '/oss/api/material/list',
data: data,
method: 'post'
})
}
// 删除上传文件
export function delUploadFile(fileBizId) {
return request({
url: `/oss/api/ossFile/del?fileBizId=${fileBizId}`,
method: 'delete'
})
}
// 上传获取材料列表2
export function uploadRelObjectMaterialList(data) {
return request({
url: '/oss/api/relObjectMaterial/page',
data: data,
method: 'post'
})
}
// 删除材料
export function delMaterial(relObjectMaterialBizId) {
return request({
url: `/oss/api/relObjectMaterial/del?relObjectMaterialBizId=${relObjectMaterialBizId}`,
method: 'delete'
})
}
// 获取文件详情
export function uploadOssFileList(data) {
return request({
url: '/oss/api/ossFile/list',
data: data,
method: 'post'
})
}
...@@ -379,7 +379,9 @@ const getDictsData = async () => { ...@@ -379,7 +379,9 @@ const getDictsData = async () => {
'wj_question_second_category', 'wj_question_second_category',
'csf_ap_policy_transfer', 'csf_ap_policy_transfer',
'md_bank', 'md_bank',
'csf_property_type' 'csf_property_type',
'oss_data_type',
'oss_data_person'
]) ])
} }
......
...@@ -262,6 +262,7 @@ ...@@ -262,6 +262,7 @@
@handleSuccessEdit="getAppointmentInfo(idsObj.appointmentBizId)" @handleSuccessEdit="getAppointmentInfo(idsObj.appointmentBizId)"
:pageSource="pageSource" :pageSource="pageSource"
:showSubmitBtn="showSubmitBtn" :showSubmitBtn="showSubmitBtn"
ref="appointmentAccessoriesRef"
/> />
</div> </div>
<div v-if="tab.name === 'policyInfo'"> <div v-if="tab.name === 'policyInfo'">
...@@ -418,6 +419,7 @@ const insuredInfoRef = ref(null) ...@@ -418,6 +419,7 @@ const insuredInfoRef = ref(null)
const secondHolderInfoRef = ref(null) const secondHolderInfoRef = ref(null)
const beneficiaryInfoRef = ref(null) const beneficiaryInfoRef = ref(null)
const policyTransferRef = ref(null) const policyTransferRef = ref(null)
const appointmentAccessoriesRef = ref(null)
const questionnairesInfoRef = ref(null) const questionnairesInfoRef = ref(null)
const customerInfo = ref({}) const customerInfo = ref({})
const idsObj = ref({}) //各个模块的bizId const idsObj = ref({}) //各个模块的bizId
...@@ -815,7 +817,9 @@ const getDictsData = async () => { ...@@ -815,7 +817,9 @@ const getDictsData = async () => {
'wj_question_first_category', 'wj_question_first_category',
'wj_question_second_category', 'wj_question_second_category',
'csf_ap_status', 'csf_ap_status',
'md_bank' 'md_bank',
'oss_data_type',
'oss_data_person'
]) ])
} }
// Tab切换前的验证 // Tab切换前的验证
...@@ -868,15 +872,20 @@ const handleSubmit = async type => { ...@@ -868,15 +872,20 @@ const handleSubmit = async type => {
// await secondHolderInfoRef.value[0].handleFormValues() // await secondHolderInfoRef.value[0].handleFormValues()
// if (!submitAppointmentObj.value.apiSecondHolderInfoDto) return // if (!submitAppointmentObj.value.apiSecondHolderInfoDto) return
// } // }
if (beneficiaryInfoRef.value) { // if (beneficiaryInfoRef.value) {
submitAppointmentObj.value.apiBeneficiaryInfoFzDto = // submitAppointmentObj.value.apiBeneficiaryInfoFzDto =
await beneficiaryInfoRef.value[0].handleFormValues() // await beneficiaryInfoRef.value[0].handleFormValues()
if (!submitAppointmentObj.value.apiBeneficiaryInfoFzDto) return // if (!submitAppointmentObj.value.apiBeneficiaryInfoFzDto) return
} // }
if (questionnairesInfoRef.value && questionnairesInfoRef.value[0].questionLength > 0) { // if (questionnairesInfoRef.value && questionnairesInfoRef.value[0].questionLength > 0) {
submitAppointmentObj.value.questionnairesDetailResponse = // submitAppointmentObj.value.questionnairesDetailResponse =
await questionnairesInfoRef.value[0].handleFormValues() // await questionnairesInfoRef.value[0].handleFormValues()
if (!submitAppointmentObj.value.questionnairesDetailResponse) return // if (!submitAppointmentObj.value.questionnairesDetailResponse) return
// }
if (appointmentAccessoriesRef.value) {
submitAppointmentObj.value.materialDtoList =
appointmentAccessoriesRef.value[0].handleFormValues()
if (!submitAppointmentObj.value.materialDtoList) return
} }
console.log('大提交', submitAppointmentObj.value) console.log('大提交', submitAppointmentObj.value)
return return
......
<template> <template>
<!-- :limit="limit" :on-exceed="handleExceed"--> <div class="uploadContainer">
<div> <CardOne title="材料信息">
<!-- 来自新单跟进的不需要上传预约附件,只能看预约附件 --> <template #content>
<div v-if="props.pageSource !== 'policyList'"> <el-table v-loading="loading" :data="fileTableList" boder>
<div class="fileUploadBox"> <el-table-column label="序号" type="index" width="55" />
<el-upload <el-table-column label="资料人" align="center" prop="dataPerson" width="200">
:action="uploadImgUrl" <template #default="scope">
:headers="headers" <dict-tag :options="fetchDictData('oss_data_person')" :value="scope.row.dataPerson" />
:show-file-list="false" </template>
:on-success="uploadSuccess" </el-table-column>
:before-upload="handleBeforeUpload"
<el-table-column label="资料类型" align="center" prop="dataType" width="200">
<template #default="scope">
<dict-tag :options="fetchDictData('oss_data_type')" :value="scope.row.dataType" />
</template>
</el-table-column>
<el-table-column label="注意事项" align="center" prop="precautions" />
<el-table-column
label="上传状态"
align="center"
prop="status"
v-if="fileTableList.length > 0 && fileTableList[0].relObjectMaterialBizId"
> >
<div class="uploadBox">
<el-icon size="20"><DocumentAdd /></el-icon>
<div class="file">选择文件</div>
</div>
</el-upload>
</div>
<div class="tip">(支持Word,Excel,PDF,图片格式)</div>
</div>
<el-table v-loading="loading" :data="fileTableList">
<!-- <el-table-column type="selection" width="55" /> -->
<el-table-column label="序号" type="index" width="50" />
<el-table-column label="文件名" align="center" prop="fileName" width="200" />
<!-- sortable -->
<el-table-column label="上传时间" align="center" prop="createTime" width="200">
<template #default="scope"> <template #default="scope">
<span>{{ parseTime(scope.row.createTime) }}</span> <span v-if="scope.row.status === 1">已上传</span>
<span v-if="scope.row.status === 0" style="color: red">待上传</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="上传人" align="center" prop="creatorName" />
<el-table-column label="文件类型" align="center" prop="fileType" />
<el-table-column <el-table-column
label="操作" label="操作"
align="center" align="center"
width="250" width="180"
class-name="small-padding fixed-width" class-name="small-padding fixed-width"
fixed="right" fixed="right"
> >
<template #default="scope"> <template #default="scope">
<el-button type="primary" link @click="downloadFile(scope.row)">下载</el-button> <!-- <el-button type="primary" link @click="downloadFile(scope.row)">下载</el-button> -->
<el-button <el-button
v-if="isImageFile(scope.row.fileName)"
type="primary" type="primary"
link link
@click="handleView(scope.row)" @click="handleUploadFile(scope.row)"
v-if="scope.row.fileBizIdList.length == 0"
> >
查看 上传
</el-button> </el-button>
<el-button <el-button
v-if="props.pageSource !== 'policyList'" v-if="props.pageSource !== 'policyList' && scope.row.fileBizIdList.length > 0"
type="primary" type="primary"
link link
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
>修改</el-button >查看</el-button
> >
<el-button <el-button
v-if="props.pageSource !== 'policyList'" v-if="props.pageSource !== 'policyList'"
...@@ -65,32 +61,62 @@ ...@@ -65,32 +61,62 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination </template>
v-show="total >= 0" </CardOne>
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getFileList"
/>
<el-dialog title="重命名文件" v-model="editVisible" width="800px" append-to-body>
<el-form>
<el-row>
<el-col :span="12">
<el-form-item label="文件名">
<el-input v-model="form.fileName" placeholder="请输入文件名" maxlength="300" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer> <CommonDialog
<div class="dialog-footer"> dialogTitle="上传附件"
<el-button type="primary" @click="submitForm">确 定</el-button> cancleText="取消"
<el-button @click="canelEdit">取 消</el-button> confirmText="确认"
dialogWidth="70%"
:openDialog="editVisible"
@close="editVisible = false"
@confirm="handleSubmitUpload"
:showClose="true"
>
<div class="dialogBox">
<div class="dialogLeft">
<div class="fileUploadBox">
<el-upload
:action="uploadImgUrl"
:headers="headers"
multiple
:limit="limit"
:show-file-list="false"
:on-exceed="handleExceed"
:on-success="uploadSuccess"
:before-upload="handleBeforeUpload"
>
<div class="uploadBox">
<el-icon size="20"><DocumentAdd /></el-icon>
<div class="file">选择文件</div>
</div> </div>
</template> </el-upload>
</el-dialog> </div>
<!-- 图片查看器 --> <div class="tip">(支持Word,Excel,PDF,图片格式)</div>
</div>
<div class="dialogRight">
<div
v-if="uploadedFiles.length === 0"
style="color: #999; padding: 20px; text-align: center"
>
暂无上传文件
</div>
<el-scrollbar max-height="300px">
<div
v-for="(file, index) in uploadedFiles"
:key="file.fileBizId"
class="uploaded-file-item"
>
<div class="fileName">{{ file.originalName }}</div>
<el-icon color="red" size="18" @click="removeUploadedFile(file, index)"
><Delete
/></el-icon>
</div>
</el-scrollbar>
</div>
</div>
</CommonDialog>
<el-dialog v-model="imageViewerVisible" title="图片预览" width="60%"> <el-dialog v-model="imageViewerVisible" title="图片预览" width="60%">
<div style="text-align: center"> <div style="text-align: center">
<el-image :src="imageUrl" fit="contain" /> <el-image :src="imageUrl" fit="contain" />
...@@ -100,60 +126,96 @@ ...@@ -100,60 +126,96 @@
</template> </template>
<script setup name="FileUpload"> <script setup name="FileUpload">
import CommonDialog from '@/components/commonDialog'
import CardOne from '@/components/formCard/cardOne'
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
import { addFile, getAppointmentFile, delFile, editAppointmentFile } from '@/api/sign/appointment' import { addFile, getAppointmentFile, delFile, editAppointmentFile } from '@/api/sign/appointment'
import useDictStore from '@/store/modules/dict'
import {
uploadMaterialList,
delUploadFile,
uploadRelObjectMaterialList,
uploadOssFileList
} from '@/api/common'
const props = defineProps({ const props = defineProps({
activeName: { type: String, default: '' }, //tab名称 activeName: { type: String, default: '' }, //tab名称
idsObj: { type: Object, default: () => ({}) }, //父组件传递过来的id对象 idsObj: { type: Object, default: () => ({}) }, //父组件传递过来的id对象
pageSource: { type: String, default: '' } //页面来源 pageSource: { type: String, default: '' } //页面来源
}) })
const dictStore = useDictStore() //获取字典数据
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const editVisible = ref(false) const editVisible = ref(false)
const loading = ref(true) const loading = ref(true)
const total = ref(0) const total = ref(0)
const fileTableList = ref([]) const fileTableList = ref([])
const limit = ref(2) const limit = ref(10)
const fileSize = ref(10) const fileSize = ref(10)
const headers = ref({ Authorization: 'Bearer ' + getToken() }) const headers = ref({ Authorization: 'Bearer ' + getToken() })
const uploadImgUrl = ref(import.meta.env.VITE_APP_BASE_API + '/oss/api/oss/upload') // 上传的服务器地址 const uploadImgUrl = ref(import.meta.env.VITE_APP_BASE_API + '/oss/api/oss/upload') // 上传的服务器地址
// 图片查看相关状态 // 图片查看相关状态
const imageViewerVisible = ref(false) const imageViewerVisible = ref(false)
const imageUrl = ref('') const imageUrl = ref('')
const tempFileTableList = ref([])
const data = reactive({ const data = reactive({
form: {}, form: {},
queryParams: { queryParams: {
pageNo: 1, objectType: 'appointment'
pageSize: 4,
startTime: '',
endTime: '',
appointmentBizId: props.idsObj.appointmentBizId
} }
}) })
const { queryParams, form } = toRefs(data) const { queryParams, form } = toRefs(data)
const canelEdit = () => { // 新增:用于存储已上传成功的文件列表
const uploadedFiles = ref([])
const currentUploadRow = ref([])
const handleSubmitUpload = () => {
if (uploadedFiles.value.length > 0) {
fileTableList.value.forEach(item => {
if (item.materialBizId == currentUploadRow.value.materialBizId) {
item.fileBizIdList = JSON.parse(JSON.stringify(uploadedFiles.value))
}
})
}
editVisible.value = false editVisible.value = false
form.value = {}
console.log('fileTableList', fileTableList.value)
} }
const submitForm = () => { // 获取字典数据
let obj = { const fetchDictData = dictType => {
appointmentFileBizId: form.value.appointmentFileBizId, let options = []
fileName: form.value.fileName try {
dictStore.dictTypeLists.forEach(item => {
if (item.dictType == 'sys_no_yes') {
item.dictItemList.forEach(item2 => {
item2.value = String(item2.itemValue)
})
} }
editAppointmentFile(obj).then(response => { if (item.dictType == dictType) {
if (response.code == 200) { options = item.dictItemList
proxy.$modal.msgSuccess('文件名修改成功')
editVisible.value = false
getFileList()
} }
}) })
return options
} catch (error) {
console.error('获取字典数据失败:', error)
return []
}
}
// 重置上传列表(比如关闭弹窗时清空)
const resetUploadedList = () => {
uploadedFiles.value = []
} }
const handleUploadFile = row => {
currentUploadRow.value = JSON.parse(JSON.stringify(row))
editVisible.value = true
}
const handleDetele = row => { const handleDetele = row => {
proxy.$modal proxy.$modal
.confirm('是否确认删除名称为"' + row.fileName + '"的文件?') .confirm('是否确认删除此行数据?')
.then(function () { .then(function () {
return delFile(row.appointmentFileBizId) if (row.relObjectMaterialBizId) {
return delMaterial(row.relObjectMaterialBizId)
} else {
fileTableList.value.splice(row.index, 1)
}
}) })
.then(res => { .then(res => {
if (res.code == 200) { if (res.code == 200) {
...@@ -167,8 +229,22 @@ const isImageFile = fileName => { ...@@ -167,8 +229,22 @@ const isImageFile = fileName => {
return /\.(jpg|jpeg|png|gif|bmp|webp|svg|ico)$/i.test(fileName || '') return /\.(jpg|jpeg|png|gif|bmp|webp|svg|ico)$/i.test(fileName || '')
} }
const handleUpdate = row => { const handleUpdate = row => {
currentUploadRow.value = JSON.parse(JSON.stringify(row))
if (row.relObjectMaterialBizId) {
try {
uploadOssFileList({ objectBizId: row.relObjectMaterialBizId }).then(response => {
uploadedFiles.value = response.data
editVisible.value = true
})
} catch (error) {
uploadedFiles.value = []
proxy.$message.error('文件获取失败')
}
} else {
editVisible.value = true editVisible.value = true
form.value = JSON.parse(JSON.stringify(row)) uploadedFiles.value = JSON.parse(JSON.stringify(row.fileBizIdList))
}
} }
const handleView = row => { const handleView = row => {
imageUrl.value = row.fileUrl imageUrl.value = row.fileUrl
...@@ -208,57 +284,104 @@ function handleBeforeUpload(file) { ...@@ -208,57 +284,104 @@ function handleBeforeUpload(file) {
function handleExceed() { function handleExceed() {
proxy.$modal.msgError(`一次只能上传${limit.value}个文件!`) proxy.$modal.msgError(`一次只能上传${limit.value}个文件!`)
} }
const uploadSuccess = res => { // 文件上传成功回调
console.log('上传成功', res) const uploadSuccess = (res, file, fileList) => {
if (res.code == 200) { console.log('上传成功', res, file)
if (props.idsObj.appointmentBizId) { if (res.code === 200) {
let submitObj = { // 构造前端使用的文件对象(保留原始 file 信息 + 后端返回的 url 等)
appointmentBizId: props.idsObj.appointmentBizId, const uploadedFile = {
fileUrl: res.data.url, fileBizId: res.data.fileBizId, // 用于唯一标识
fileName: res.data.originalName, originalName: res.data.originalName || file.name,
ossFileBizId: res.data.fileBizId url: res.data.url,
size: file.size,
raw: file.raw // 原始 File 对象(如需后续操作)
} }
addFile(submitObj).then(res => { uploadedFiles.value.push(uploadedFile)
if (res.code == 200) {
proxy.$message.success('文件上传成功') proxy.$message.success('文件上传成功')
queryParams.value.pageNo = 1 } else {
getFileList() proxy.$message.error(res.msg || '上传失败')
// emit('handleSuccessEdit')
} }
}
// 删除已上传的文件(仅从列表移除,不调用后端删除)
const removeUploadedFile = (file, index) => {
try {
delUploadFile(file.fileBizId).then(response => {
uploadedFiles.value.splice(index, 1)
}) })
} } catch (error) {
proxy.$message.error('文件删除失败')
} }
} }
const getFileList = () => { const getFileList = () => {
loading.value = true loading.value = true
try { try {
getAppointmentFile(queryParams.value).then(response => { if (!props.idsObj.appointmentBizId) {
total.value = response.data.total uploadMaterialList(queryParams.value).then(response => {
fileTableList.value = response.data.records fileTableList.value = response.data
if (fileTableList.value.length > 0) { if (fileTableList.value.length > 0) {
for (const item of fileTableList.value) { fileTableList.value.forEach(item => {
item.fileType = '预约文件' item.fileBizIdList = []
})
} }
loading.value = false
})
} else {
let obj = {
objectType: 'appointment',
objectBizId: props.idsObj.appointmentBizId
} }
uploadRelObjectMaterialList(obj).then(response => {
fileTableList.value = response.data
loading.value = false loading.value = false
}) })
}
if (tempFileTableList.value.length > 0) {
fileTableList.value = JSON.parse(JSON.stringify(tempFileTableList.value))
}
} catch (error) { } catch (error) {
fileTableList.value = [] fileTableList.value = []
} finally { } finally {
loading.value = false loading.value = false
} }
} }
const handleFormValues = () => {
let submitData = []
fileTableList.value.forEach(item => {
if (item.fileBizIdList.length > 0) {
submitData.push({
materialBizId: item.materialBizId,
fileBizIdList: item.fileBizIdList.map(item => item.fileBizId)
})
}
})
return submitData
}
// 关闭弹窗时清空已上传列表
watch(editVisible, newVal => {
if (!newVal) {
resetUploadedList()
}
})
watch( watch(
() => props.activeName, () => props.activeName,
newVal => { newVal => {
tempFileTableList.value = JSON.parse(JSON.stringify(fileTableList.value))
if (newVal === 'accessories') { if (newVal === 'accessories') {
queryParams.value.pageNo = 1
getFileList() getFileList()
} }
} }
) )
// 暴露给父组件
defineExpose({
handleFormValues
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.uploadContainer {
padding-left: 10px;
padding-top: 10px;
}
.fileUploadBox { .fileUploadBox {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
...@@ -267,12 +390,14 @@ watch( ...@@ -267,12 +390,14 @@ watch(
width: 100%; width: 100%;
padding: 20px 0; padding: 20px 0;
border: 1px dashed #dcdfe6; border: 1px dashed #dcdfe6;
height: 200px;
} }
.uploadBox { .uploadBox {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
height: 100%;
.file { .file {
font-size: 14px; font-size: 14px;
margin-top: 10px; margin-top: 10px;
...@@ -284,4 +409,26 @@ watch( ...@@ -284,4 +409,26 @@ watch(
color: #909399; color: #909399;
margin: 10px 0 20px 0; margin: 10px 0 20px 0;
} }
.dialogBox {
width: 100%;
display: flex;
justify-content: space-between;
}
.dialogLeft {
width: 40%;
}
.dialogRight {
width: 55%;
}
.uploaded-file-item {
width: 100%;
background: rgba(247, 248, 250, 1);
border-radius: 4px;
padding: 10px;
margin-bottom: 5px;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 16px;
}
</style> </style>
...@@ -454,30 +454,7 @@ const handleFormValues = () => { ...@@ -454,30 +454,7 @@ const handleFormValues = () => {
}) })
}) })
} }
// 表单提交
const submitForm = () => {
proxy.$refs['heathFormRef'].validate((valid, fields) => {
if (valid) {
let submitObj = handleFormValues()
saveQuestionnaires(submitObj).then(res => {
if (res.code == 200) {
handleEditStatus(true)
proxy.$message.success('健康信息修改成功')
// emit('handleSuccessEdit')
getQuestionnairesInfo()
}
})
errorFields.value = [] // 清空错误信息
} else {
// 获取校验失败的字段信息
errorFields.value = getInvalidFields(fields)
if (errorFields.value.length > 0) {
proxy.$message.error(errorFields.value[0].message)
}
}
})
}
const getQuestionnairesInfo = () => { const getQuestionnairesInfo = () => {
loading.value = true loading.value = true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment