|
@@ -4,12 +4,16 @@
|
|
|
@update:modelValue="$emit('update:modelValue', $event)"
|
|
|
title="文件选择"
|
|
|
width="460"
|
|
|
- height="430px"
|
|
|
+
|
|
|
@confirm="handleConfirm"
|
|
|
@cancel="handleCancel"
|
|
|
>
|
|
|
<el-form :model="form" label-position="left">
|
|
|
- <el-form-item label="添加文件:" :label-width="formLabelWidth3" style="width: 100%">
|
|
|
+ <el-form-item
|
|
|
+ label="添加文件:"
|
|
|
+ :label-width="formLabelWidth3"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
<el-row style="width: 100%">
|
|
|
<el-col :span="24">
|
|
|
<el-input
|
|
@@ -22,12 +26,15 @@
|
|
|
/>
|
|
|
</el-col>
|
|
|
<!-- 文件上传按钮部分 -->
|
|
|
- <el-col :span="1" style="display: flex; align-items: center; margin-left: -35px">
|
|
|
+ <el-col
|
|
|
+ :span="1"
|
|
|
+ style="display: flex; align-items: center; margin-left: -35px"
|
|
|
+ >
|
|
|
<fileUploads
|
|
|
- :projectId="projectId"
|
|
|
- :solverType="solverType"
|
|
|
+ :projectId="projectId"
|
|
|
+ :solverType="solverType"
|
|
|
accept=".plt"
|
|
|
- upId="cloud"
|
|
|
+ upId="cloud"
|
|
|
name="点击选择文件"
|
|
|
:imgSrc="meshFileImgSrc"
|
|
|
@upload-success="handleFileUploadSuccess"
|
|
@@ -38,40 +45,55 @@
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<!-- 进度条 -->
|
|
|
- <el-row v-if="showProgress" style="width: 100%; margin-top: 10px;">
|
|
|
+ <el-row v-if="showProgress" style="width: 100%; margin-top: 10px">
|
|
|
<el-col :span="20">
|
|
|
<el-progress :percentage="percentage"></el-progress>
|
|
|
</el-col>
|
|
|
<el-col :span="4">
|
|
|
- <div style="line-height: 15px">{{uploadStatus}}</div>
|
|
|
+ <div style="line-height: 15px">{{ uploadStatus }}</div>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</el-form-item>
|
|
|
-
|
|
|
- <div style="display: flex; flex-direction: row; width: 100%; margin-top: 20px;">
|
|
|
- <el-card shadow="hover" style="width: 70%; height: 200px; overflow-y: auto;" >
|
|
|
- <el-checkbox-group v-model="selectedFiles">
|
|
|
- <el-checkbox
|
|
|
- v-for="item in fileList"
|
|
|
- :key="item.value"
|
|
|
- :label="item.value"
|
|
|
+
|
|
|
+ <div
|
|
|
+ style="
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ width: 100%;
|
|
|
+ margin-top: 20px;
|
|
|
+ "
|
|
|
+ >
|
|
|
+ <el-card
|
|
|
+ shadow="hover"
|
|
|
+ style="width: 70%; height: 200px; overflow-y: auto"
|
|
|
+ >
|
|
|
+ <el-empty
|
|
|
+ v-if="!fileList.length"
|
|
|
+ description="暂无数据"
|
|
|
+ style="height: 150px;"
|
|
|
+ :image-size="80"
|
|
|
+ />
|
|
|
+ <el-checkbox-group v-else v-model="selectedFiles">
|
|
|
+ <el-checkbox
|
|
|
+ v-for="item in fileList"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.value"
|
|
|
style="display: block"
|
|
|
>
|
|
|
- <span style="font-size: 14px">{{ item.label }}</span>
|
|
|
-
|
|
|
+ <span style="font-size: 14px">{{ item.label }}</span>
|
|
|
</el-checkbox>
|
|
|
</el-checkbox-group>
|
|
|
</el-card>
|
|
|
-
|
|
|
- <div style="width: 30%; padding-left: 10px;">
|
|
|
- <el-button
|
|
|
- style="width: 100%; margin-bottom: 10px;"
|
|
|
+
|
|
|
+ <div style="width: 30%; padding-left: 10px">
|
|
|
+ <el-button
|
|
|
+ style="width: 100%; margin-bottom: 10px"
|
|
|
@click="deleteSelectedFiles"
|
|
|
>
|
|
|
删除选中文件
|
|
|
</el-button>
|
|
|
- <el-button
|
|
|
- style="width: 100%; background-color: transparent; margin-left: 0;"
|
|
|
+ <el-button
|
|
|
+ style="width: 100%; background-color: transparent; margin-left: 0"
|
|
|
@click="deleteAllFiles"
|
|
|
>
|
|
|
删除全部文件
|
|
@@ -83,9 +105,17 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref, defineProps, defineEmits, computed, watch } from 'vue'
|
|
|
-import SubDialog from './SubDialog.vue'
|
|
|
-import fileUploads from '@/views/components/fileuploads.vue'
|
|
|
+import { ref, defineProps, defineEmits, computed, watch } from "vue"
|
|
|
+import { request } from "@/utils/request"
|
|
|
+import { ElMessage } from "element-plus"
|
|
|
+import SubDialog from "./SubDialog.vue"
|
|
|
+import fileUploads from "@/views/components/fileuploads.vue"
|
|
|
+import { useProjectStore } from "@/store/modules/project"
|
|
|
+const projectStore = useProjectStore()
|
|
|
+
|
|
|
+let pid = computed(() => {
|
|
|
+ return projectStore.pid
|
|
|
+})
|
|
|
|
|
|
const props = defineProps({
|
|
|
modelValue: Boolean,
|
|
@@ -103,71 +133,71 @@ const props = defineProps({
|
|
|
}
|
|
|
})
|
|
|
|
|
|
-const emit = defineEmits(['update:modelValue', 'confirm', 'cancel'])
|
|
|
+const emit = defineEmits(["update:modelValue", "confirm", "cancel"])
|
|
|
|
|
|
// 表单数据
|
|
|
-const formLabelWidth = '100px'
|
|
|
-const cloudFileName = ref('')
|
|
|
+const formLabelWidth = "100px"
|
|
|
+const cloudFileName = ref("")
|
|
|
const selectedFiles = ref([])
|
|
|
// const fileList = ref([...props.initialFiles])
|
|
|
const fileList = ref([
|
|
|
- {
|
|
|
- value: 'file1',
|
|
|
- label: '测试文件1.cgns',
|
|
|
- raw: {
|
|
|
- name: '测试文件1.cgns',
|
|
|
- size: 1024 * 1024 * 5 // 5MB
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- value: 'file2',
|
|
|
- label: '测试文件2.xyz',
|
|
|
- raw: {
|
|
|
- name: '测试文件2.xyz',
|
|
|
- size: 1024 * 500 // 500KB
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- value: 'file3',
|
|
|
- label: '测试文件3.bdf',
|
|
|
- raw: {
|
|
|
- name: '测试文件3.bdf',
|
|
|
- size: 1024 * 1024 * 10 // 10MB
|
|
|
- }
|
|
|
- }
|
|
|
+ // {
|
|
|
+ // value: 'file1',
|
|
|
+ // label: '测试文件1.cgns',
|
|
|
+ // raw: {
|
|
|
+ // name: '测试文件1.cgns',
|
|
|
+ // size: 1024 * 1024 * 5 // 5MB
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // value: 'file2',
|
|
|
+ // label: '测试文件2.xyz',
|
|
|
+ // raw: {
|
|
|
+ // name: '测试文件2.xyz',
|
|
|
+ // size: 1024 * 500 // 500KB
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // value: 'file3',
|
|
|
+ // label: '测试文件3.bdf',
|
|
|
+ // raw: {
|
|
|
+ // name: '测试文件3.bdf',
|
|
|
+ // size: 1024 * 1024 * 10 // 10MB
|
|
|
+ // }
|
|
|
+ // }
|
|
|
])
|
|
|
const upId = ref(`file-upload-${Date.now()}`)
|
|
|
-const meshFileImgSrc = new URL("@/assets/img/open.png", import.meta.url).href;
|
|
|
+const meshFileImgSrc = new URL("@/assets/img/open.png", import.meta.url).href
|
|
|
let formLabelWidth3 = ref(80)
|
|
|
-let uploadStatus = ref('');
|
|
|
-let percentage = ref(0);
|
|
|
-let fid = ref('');
|
|
|
-
|
|
|
-watch(() => props.modelValue, (newVal) => {
|
|
|
- if (!newVal) {
|
|
|
- // 当modelValue变为false时,确保完全关闭
|
|
|
- emit('cancel')
|
|
|
+let uploadStatus = ref("")
|
|
|
+let percentage = ref(0)
|
|
|
+let fid = ref("")
|
|
|
+
|
|
|
+watch(
|
|
|
+ () => props.modelValue,
|
|
|
+ (newVal) => {
|
|
|
+ if (!newVal) {
|
|
|
+ // 当modelValue变为false时,确保完全关闭
|
|
|
+ emit("cancel")
|
|
|
+ }
|
|
|
}
|
|
|
-})
|
|
|
+)
|
|
|
|
|
|
// 文件上传成功处理
|
|
|
const handleFileUploadSuccess = (file) => {
|
|
|
+ console.log("文件上传成功:", file)
|
|
|
//隐藏进度条
|
|
|
setTimeout(() => {
|
|
|
- percentage.value = 0;
|
|
|
- }, 1000);
|
|
|
- const newFile = {
|
|
|
- value: file.id || file.name,
|
|
|
- label: file.name,
|
|
|
- raw: file
|
|
|
- }
|
|
|
- fileList.value.push(newFile)
|
|
|
- cloudFileName.value = file.name
|
|
|
+ percentage.value = 0
|
|
|
+ }, 1000)
|
|
|
+
|
|
|
+ cloudFileName.value = file.fname
|
|
|
+ bindFile(file.bfid, file.fname)
|
|
|
}
|
|
|
|
|
|
// 更新文件名
|
|
|
const updateFileName = (newValue) => {
|
|
|
- meshFileName.value = newValue
|
|
|
+ cloudFileName.value = newValue
|
|
|
}
|
|
|
|
|
|
// 更新进度条
|
|
@@ -181,39 +211,113 @@ const getUploadStatus = (newValue) => {
|
|
|
}
|
|
|
|
|
|
// 控制进度条显隐
|
|
|
-const showProgress = computed(() => percentage.value > 0 && percentage.value <= 100);
|
|
|
+const showProgress = computed(
|
|
|
+ () => percentage.value > 0 && percentage.value <= 100
|
|
|
+)
|
|
|
|
|
|
// 删除选中文件
|
|
|
const deleteSelectedFiles = () => {
|
|
|
+ if (selectedFiles.value.length === 0) {
|
|
|
+ ElMessage.warning("请先选择要删除的文件")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ selectedFiles.value.forEach((fileValue) => {
|
|
|
+ const file = fileList.value.find((f) => f.value === fileValue)
|
|
|
+ if (file) {
|
|
|
+ deleteFile(file.pfid)
|
|
|
+ }
|
|
|
+ })
|
|
|
fileList.value = fileList.value.filter(
|
|
|
- file => !selectedFiles.value.includes(file.value)
|
|
|
+ (file) => !selectedFiles.value.includes(file.value)
|
|
|
)
|
|
|
selectedFiles.value = []
|
|
|
+ cloudFileName.value = ""
|
|
|
}
|
|
|
|
|
|
// 删除全部文件
|
|
|
const deleteAllFiles = () => {
|
|
|
+ fileList.value.forEach((file) => {
|
|
|
+ deleteFile(file.pfid)
|
|
|
+ })
|
|
|
fileList.value = []
|
|
|
selectedFiles.value = []
|
|
|
- cloudFileName.value = ''
|
|
|
+ cloudFileName.value = ""
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// 确认选择
|
|
|
const handleConfirm = () => {
|
|
|
- emit('confirm', {
|
|
|
+ emit("confirm", {
|
|
|
// selectedFiles: fileList.value.filter(
|
|
|
// file => selectedFiles.value.includes(file.value)
|
|
|
// )
|
|
|
- fid: '9305c3e01b5d44e6a1964148d34e02f4'
|
|
|
+ fid: "9305c3e01b5d44e6a1964148d34e02f4"
|
|
|
})
|
|
|
- emit('update:modelValue', false)
|
|
|
+ emit("update:modelValue", false)
|
|
|
}
|
|
|
|
|
|
// 取消
|
|
|
const handleCancel = () => {
|
|
|
- emit('cancel')
|
|
|
- emit('update:modelValue', false)
|
|
|
+ emit("cancel")
|
|
|
+ emit("update:modelValue", false)
|
|
|
+}
|
|
|
+
|
|
|
+const initFileList = () => {
|
|
|
+ const params = {
|
|
|
+ transCode: "MDO0077",
|
|
|
+ pid: pid.value
|
|
|
+ }
|
|
|
+ request(params)
|
|
|
+ .then((res) => {
|
|
|
+ console.log("获取文件列表:", res)
|
|
|
+ fileList.value = res.rows.map((item) => ({
|
|
|
+ value: item.fid,
|
|
|
+ label: item.fname,
|
|
|
+ pfid: item.pfid
|
|
|
+ }))
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.error("获取文件列表失败:", err)
|
|
|
+ ElMessage.error("获取文件列表失败")
|
|
|
+ })
|
|
|
}
|
|
|
+
|
|
|
+const bindFile = (fid, fname) => {
|
|
|
+ const params = {
|
|
|
+ transCode: "MDO0078",
|
|
|
+ pid: pid.value,
|
|
|
+ fid: fid,
|
|
|
+ fname: fname
|
|
|
+ }
|
|
|
+ request(params)
|
|
|
+ .then((res) => {
|
|
|
+ console.log("绑定文件:", res)
|
|
|
+ initFileList()
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.error("绑定文件失败:", err)
|
|
|
+ ElMessage.error("绑定文件失败")
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const deleteFile = (pfid) => {
|
|
|
+ const params = {
|
|
|
+ transCode: "MDO0079",
|
|
|
+ pfid: pfid
|
|
|
+ }
|
|
|
+ request(params)
|
|
|
+ .then((res) => {
|
|
|
+ console.log("删除文件:", res)
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.error("删除文件失败:", err)
|
|
|
+ ElMessage.error("删除文件失败")
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ initFileList()
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|