feat: 图片预览

This commit is contained in:
zhanghao 2026-02-04 13:54:52 +08:00
parent 6a9288a576
commit 05a48c4c14
2 changed files with 12 additions and 6 deletions

View File

@ -22,7 +22,6 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="上传图片"> <el-form-item label="上传图片">
<!-- <FileUpload v-model="imgUrl" :limit="1" :uploadUrl="'/system/file/upload'" :fileSize="5" :fileType="['png', 'jpg', 'jpeg']" /> -->
<el-upload <el-upload
v-model:file-list="uploadFileList" v-model:file-list="uploadFileList"
:action="`${data.baseUrl}/system/file/upload`" :action="`${data.baseUrl}/system/file/upload`"
@ -63,14 +62,13 @@
</template> </template>
</el-dialog> </el-dialog>
<el-dialog v-model="dialogVisible"> <el-dialog :width="800" v-model="dialogVisible">
<img :src="dialogImageUrl" alt="Preview Image" /> <img width="770" :src="dialogImageUrl" alt="Preview Image" />
</el-dialog> </el-dialog>
</template> </template>
<script setup> <script setup>
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
import FileUpload from '@/components/FileUpload/index'
import { useDict } from '@/utils/dict' import { useDict } from '@/utils/dict'
import {getToken} from "@/utils/auth.js"; import {getToken} from "@/utils/auth.js";
import {supportType} from "@/enum/index.js"; import {supportType} from "@/enum/index.js";
@ -155,6 +153,13 @@ watch(() => props.visible, (newVal) => {
visible.value = newVal visible.value = newVal
if (props.formData.iconUrl) { if (props.formData.iconUrl) {
imgUrl.value = props.formData.iconUrl imgUrl.value = props.formData.iconUrl
uploadFileList.value = [{
name: 'image',
url: props.formData.iconUrl,
response: {
msg: props.formData.iconUrl
}
}]
} }
}) })
@ -170,6 +175,7 @@ function handleConfirm() {
if (imgUrl.value && imgUrl.value.length > 0) { if (imgUrl.value && imgUrl.value.length > 0) {
obj.iconUrl = imgUrl.value obj.iconUrl = imgUrl.value
} }
uploadFileList.value = []
emit('confirm', valid, { ...obj }) emit('confirm', valid, { ...obj })
}) })
} }

View File

@ -317,11 +317,11 @@
<script setup> <script setup>
import TableSearch from "@/components/TableSearch/index.vue"; import TableSearch from "@/components/TableSearch/index.vue";
import { useContainerHeight } from "@/hooks/tableHeight"; import { useContainerHeight } from "@/hooks/tableHeight";
import { ElMessageBox } from "element-plus"; import { ElMessage, ElMessageBox } from "element-plus";
import { getTreeDataApi } from '@/api/is/func/index' import { getTreeDataApi } from '@/api/is/func/index'
import { getChildrenByParentIdWithLevelLimitApi } from "@/api/evaluate/indicator.js"; import { getChildrenByParentIdWithLevelLimitApi } from "@/api/evaluate/indicator.js";
import { getFunction } from "@/api/is/func/index.js"; import { getFunction } from "@/api/is/func/index.js";
import { addProject, getProjectList } from "@/api/is/project/index.js"; import { addProject, getProjectList, updateProject } from "@/api/is/project/index.js";
const topContainerRef = ref(); const topContainerRef = ref();
const containerHeight = useContainerHeight(topContainerRef); const containerHeight = useContainerHeight(topContainerRef);