Переглянути джерело

624文件查询删除绑定

tangjunhao 2 місяців тому
батько
коміт
34b096f335

+ 186 - 82
src/components/cloudChart/dialog/FileSelectDialog.vue

@@ -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>

+ 22 - 0
src/store/modules/project.js

@@ -0,0 +1,22 @@
+import { defineStore } from 'pinia'
+import { ref } from 'vue'
+
+export const useProjectStore = defineStore('project', () => {
+  const pid = ref('');
+
+  const setpid = (val) => {
+    pid.value = val
+  }
+
+  const clearproject = () => {
+    pid.value = ''
+  }
+  
+  return {
+    pid,
+    setpid,
+    clearproject,
+  }
+},{
+  persist: true, // 启用持久化
+})

+ 6 - 62
src/views/home.vue

@@ -1066,62 +1066,7 @@
           <cloundCharts 
             v-model="dialog.clouddialog"
             />
-          <el-dialog v-model="dialog.paretodialog" align-center :modal="false" :close-on-click-modal="false"
-            :append-to-body="true" draggable :fullscreen="false" :modal-append-to-body="false" modal-class="summary-dlg"
-            :before-close="handleClose" width="700" class="dialog_style bgcolor tianjia sel cloudChart" style="height: 500px;overflow: auto;">
-            <template #header>
-              <div class="my-header ">
-                <h4 :id="titleId" :class="titleClass">云图/等值线显示</h4>
-              </div>
-            </template>
-            <div>
-              <div class="cloudbox">
-                <el-row gutter="20">
-                  <el-col :span="2"></el-col>
-                  <el-col v-for="(item,index) in cloudbtnbox" :key="index" :span="4">
-                    <el-button style="width: 100%;" @click="openSeconddialog(item.btnname)">
-                      <el-image :src="getImgPath(item.url)" alt="img" fit="cover" style="width: 20px;margin-right: 4px;" />
-                      {{ item.btnname }}
-                    </el-button>
-                  </el-col>
-                </el-row>
-              </div>
-              <div style="height: 400px;overflow: auto;">
-                <cloudChart/>
-              </div>
-              
-            </div>
-          </el-dialog>
-          <!-- 云图二级弹窗 -->
-          <el-dialog v-model="seconddialogshow"
-          align-center
-          :modal="false"
-          :close-on-click-modal="false"
-          :append-to-body="true"
-          draggable
-          :fullscreen="false"
-          :modal-append-to-body="false"
-          modal-class="summary-dlg"
-          :before-close="handleClose"
-          width="500"
-          class="dialog_class bgcolor tianjia "
           
-          >
-            <template #header="{ titleId, titleClass }">
-              <div class="my-header">
-                <h4 :id="titleId" :class="titleClass">{{ cloudsedtitle }}</h4>
-              </div>
-            </template>
-            <cloudsecond  :activesd="activesd"/>
-            <template #footer>
-              <div class="dialog-footer">
-                <el-button @click="seconddialogshow = false">取消</el-button>
-                <el-button type="primary" @click="seconddialogshow = false">
-                确定
-                </el-button>
-            </div>
-            </template>
-          </el-dialog>
           <!-- 查看报告 -->
           <el-dialog v-model="dialog.lookover" align-center :modal="false" :close-on-click-modal="false"
             :append-to-body="true" draggable :fullscreen="false" :modal-append-to-body="false" modal-class="summary-dlgPdf"
@@ -1901,6 +1846,9 @@ import cloudChart from './threejsView/index.vue'; // 云图
 import emitter from "@/utils/emitter";
 import cloundCharts from '@/components/cloudChart/index.vue';
 
+import { useProjectStore } from "@/store/modules/project";
+const projectStore = useProjectStore()
+
 let Sidebarref = ref();
 let resource=ref(0);
 let cstnum=ref('');
@@ -2318,13 +2266,7 @@ let paretocheckbox = ref([
   {label:'cd',value:'cd'},
 ])
 
-let cloudbtnbox = ref([
-  {url:'meshFile.png',btnname:'文件选择'},
-  {url:'yu.png',btnname:'域'},
-  {url:'kk9.png',btnname:'云图'},
-  {url:'seka.png',btnname:'色卡'},
-  {url:'dengzx.png',btnname:'等值线'},
-])
+
 
 let dialog = ref({
   newdialog: false,
@@ -2474,6 +2416,7 @@ const mbdelete = (index, row) => {
 const init = () => {
 
   pid.value = route.query.pid;
+  projectStore.setpid(pid.value);
   console.log(route.query.pid);
 }
 const handleClick = (tab, event) => {
@@ -2484,6 +2427,7 @@ const handleClick = (tab, event) => {
     vuefval.value.logToObject1().then(() => {
       router.replace({ path: '/' });
       console.log('跳转到首页');
+      projectStore.clearproject();
     });
   } else {