From 33b66bff619f997d5f64f6f75d97dcaf910a06bd Mon Sep 17 00:00:00 2001 From: maven <2163098428@qq.com> Date: 星期二, 12 八月 2025 14:23:36 +0800 Subject: [PATCH] yys 协同审批增加附件上传,预览 --- src/views/chatHome/chatHomeIndex/MobileChat.vue | 2 src/views/collaborativeApproval/approvalProcess/index.vue | 19 +++++ src/views/collaborativeApproval/approvalProcess/fileList.vue | 43 ++++++++++++++ src/views/collaborativeApproval/approvalProcess/components/infoFormDia.vue | 75 +++++++++++++++++++++++++ 4 files changed, 136 insertions(+), 3 deletions(-) diff --git a/src/views/chatHome/chatHomeIndex/MobileChat.vue b/src/views/chatHome/chatHomeIndex/MobileChat.vue index f8bc625..5b06e76 100644 --- a/src/views/chatHome/chatHomeIndex/MobileChat.vue +++ b/src/views/chatHome/chatHomeIndex/MobileChat.vue @@ -203,7 +203,7 @@ } chatList.value.push(replyMsg) scrollBottom() - + loading.value = false // 濡傛灉鏈夋煡璇㈠叧閿瓧锛屽垯妯℃嫙娴佸紡杈撳嚭 if (route.query.keyWord) { simulateStreamingOutput(replyMsg, route.query.keyWord) diff --git a/src/views/collaborativeApproval/approvalProcess/components/infoFormDia.vue b/src/views/collaborativeApproval/approvalProcess/components/infoFormDia.vue index 3aa58c5..52c7b85 100644 --- a/src/views/collaborativeApproval/approvalProcess/components/infoFormDia.vue +++ b/src/views/collaborativeApproval/approvalProcess/components/infoFormDia.vue @@ -112,6 +112,23 @@ </el-form-item> </el-col> </el-row> + <el-row :gutter="30"> + <el-col :span="24"> + <el-form-item label="闄勪欢鏉愭枡锛�" prop="remark"> + <el-upload v-model:file-list="fileList" :action="upload.url" multiple ref="fileUpload" auto-upload + :headers="upload.headers" :before-upload="handleBeforeUpload" :on-error="handleUploadError" + :on-success="handleUploadSuccess" :on-remove="handleRemove"> + <el-button type="primary" v-if="operationType !== 'view'">涓婁紶</el-button> + <template #tip v-if="operationType !== 'view'"> + <div class="el-upload__tip"> + 鏂囦欢鏍煎紡鏀寔 + doc锛宒ocx锛寈ls锛寈lsx锛宲pt锛宲ptx锛宲df锛宼xt锛寈ml锛宩pg锛宩peg锛宲ng锛実if锛宐mp锛宺ar锛寊ip锛�7z + </div> + </template> + </el-upload> + </el-form-item> + </el-col> + </el-row> </el-form> <template #footer> <div class="dialog-footer"> @@ -130,7 +147,11 @@ approveProcessUpdate, getDept } from "@/api/collaborativeApproval/approvalProcess.js"; +import { + delLedgerFile, +} from "@/api/salesManagement/salesLedger.js"; import {userListNoPageByTenantId} from "@/api/system/user.js"; +import { getToken } from "@/utils/auth"; const { proxy } = getCurrentInstance() const emit = defineEmits(['close']) import useUserStore from "@/store/modules/user"; @@ -138,6 +159,13 @@ const dialogFormVisible = ref(false); const operationType = ref('') +const fileList = ref([]); +const upload = reactive({ + // 涓婁紶鐨勫湴鍧� + url: import.meta.env.VITE_APP_BASE_API + "/file/upload", + // 璁剧疆涓婁紶鐨勮姹傚ご閮� + headers: { Authorization: "Bearer " + getToken() }, +}); const data = reactive({ form: { approveTime: "", @@ -146,6 +174,7 @@ approveDeptId: "", approveReason: "", checkResult: "", + tempFileIds: [], approverList: [] // 鏂板瀛楁锛屽瓨鍌ㄦ墍鏈夎妭鐐圭殑瀹℃壒浜篿d }, rules: { @@ -176,6 +205,7 @@ // 鎵撳紑寮规 const openDialog = (type, row) => { + console.log('openDialog', type, row) operationType.value = type; dialogFormVisible.value = true; userListNoPageByTenantId().then((res) => { @@ -192,6 +222,8 @@ // 鑾峰彇褰撳墠鐢ㄦ埛淇℃伅骞惰缃儴闂↖D form.value.approveDeptId = userStore.currentDeptId if (operationType.value === 'edit') { + fileList.value = row.commonFileList + form.value.tempFileIds = fileList.value.map(file => file.id) currentApproveStatus.value = row.approveStatus approveProcessGetInfo({id: row.approveId,approveReason: '1'}).then(res => { form.value = {...res.data} @@ -257,6 +289,7 @@ } // 鍏抽棴寮规 const closeDia = () => { + fileList.value = [] proxy.resetForm("formRef"); dialogFormVisible.value = false; emit('close') @@ -269,6 +302,48 @@ const day = String(today.getDate()).padStart(2, "0"); return `${year}-${month}-${day}`; } + +// 涓婁紶鍓嶆牎妫� +function handleBeforeUpload(file) { + // 鏍℃鏂囦欢澶у皬 + // if (file.size > 1024 * 1024 * 10) { + // proxy.$modal.msgError("涓婁紶鏂囦欢澶у皬涓嶈兘瓒呰繃10MB!"); + // return false; + // } + proxy.$modal.loading("姝e湪涓婁紶鏂囦欢锛岃绋嶅��..."); + return true; +} +// 涓婁紶澶辫触 +function handleUploadError(err) { + proxy.$modal.msgError("涓婁紶鏂囦欢澶辫触"); + proxy.$modal.closeLoading(); +} +// 涓婁紶鎴愬姛鍥炶皟 +function handleUploadSuccess(res, file, uploadFiles) { + proxy.$modal.closeLoading(); + if (res.code === 200) { + // 纭繚 tempFileIds 瀛樺湪涓斾负鏁扮粍 + if (!form.value.tempFileIds) { + form.value.tempFileIds = []; + } + form.value.tempFileIds.push(res.data.tempId); + proxy.$modal.msgSuccess("涓婁紶鎴愬姛"); + } else { + proxy.$modal.msgError(res.msg); + proxy.$refs.fileUpload.handleRemove(file); + } +} +// 绉婚櫎鏂囦欢 +function handleRemove(file) { + if (operationType.value === "edit") { + let ids = []; + ids.push(file.id); + delLedgerFile(ids).then((res) => { + proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛"); + }); + } +} + defineExpose({ openDialog, }); diff --git a/src/views/collaborativeApproval/approvalProcess/fileList.vue b/src/views/collaborativeApproval/approvalProcess/fileList.vue new file mode 100644 index 0000000..da37db2 --- /dev/null +++ b/src/views/collaborativeApproval/approvalProcess/fileList.vue @@ -0,0 +1,43 @@ +<template> + <el-dialog v-model="dialogVisible" title="闄勪欢" width="40%" :before-close="handleClose"> + <el-table :data="tableData" border height="40vh"> + <el-table-column label="闄勪欢鍚嶇О" prop="name" min-width="400" show-overflow-tooltip /> + <el-table-column fixed="right" label="鎿嶄綔" width="100" align="center"> + <template #default="scope"> + <el-button link type="primary" size="small" @click="downLoadFile(scope.row)">涓嬭浇</el-button> + <el-button link type="primary" size="small" @click="lookFile(scope.row)">棰勮</el-button> + </template> + </el-table-column> + </el-table> + </el-dialog> + <filePreview ref="filePreviewRef" /> +</template> + +<script setup> +import { ref } from 'vue' +import filePreview from '@/components/filePreview/index.vue' + +const dialogVisible = ref(false) +const tableData = ref([]) +const { proxy } = getCurrentInstance(); +const filePreviewRef = ref() +const handleClose = () => { + dialogVisible.value = false +} +const open = (list) => { + dialogVisible.value = true + tableData.value = list +} +const downLoadFile = (row) => { + proxy.$download.name(row.url); + +} +const lookFile = (row) => { + filePreviewRef.value.open(row.url) +} +defineExpose({ + open +}) +</script> + +<style></style> \ No newline at end of file diff --git a/src/views/collaborativeApproval/approvalProcess/index.vue b/src/views/collaborativeApproval/approvalProcess/index.vue index 79f358b..9630af3 100644 --- a/src/views/collaborativeApproval/approvalProcess/index.vue +++ b/src/views/collaborativeApproval/approvalProcess/index.vue @@ -44,10 +44,12 @@ </div> <info-form-dia ref="infoFormDia" @close="handleQuery"></info-form-dia> <approval-dia ref="approvalDia" @close="handleQuery"></approval-dia> + <FileList ref="fileListRef" /> </div> </template> <script setup> +import FileList from "./fileList.vue"; import { Search } from "@element-plus/icons-vue"; import {onMounted, ref} from "vue"; import {ElMessageBox} from "element-plus"; @@ -116,11 +118,12 @@ { label: "鐢宠浜�", prop: "approveUserName", + width: 120 }, { label: "鐢宠鏃ユ湡", prop: "approveTime", - width: 120 + width: 200 }, { label: "缁撴潫鏃ユ湡", @@ -137,7 +140,7 @@ label: "鎿嶄綔", align: "center", fixed: "right", - width: 150, + width: 230, operation: [ { name: "缂栬緫", @@ -162,6 +165,13 @@ openApprovalDia('view', row); }, }, + { + name: "闄勪欢", + type: "text", + clickFun: (row) => { + downLoadFile(row); + }, + }, ], }, ]); @@ -183,6 +193,11 @@ page.current = 1; getList(); }; +const fileListRef = ref(null) +const downLoadFile = (row) => { + fileListRef.value.open(row.commonFileList) + +} const pagination = (obj) => { page.current = obj.page; page.size = obj.limit; -- Gitblit v1.9.3