Procházet zdrojové kódy

扫描库删除新增按钮增加

duy před 1 měsícem
rodič
revize
5ddd20aa70
2 změnil soubory, kde provedl 73 přidání a 26 odebrání
  1. 11 23
      src/views/file/MenuItem.vue
  2. 62 3
      src/views/file/scan.vue

+ 11 - 23
src/views/file/MenuItem.vue

@@ -42,10 +42,6 @@
     
     <!-- 右键菜单 -->
     <hc-context-menu ref="contextMenuRef" :datas="menuData" @item-click="handleMenuSelect" />
-    <!-- 新增节点 -->
-    <hc-new-dialog v-model="addModal" :loading="addLoading" is-table title="新增节点" @close="addModalClose" @save="addModalSave">
-        eeeeeeee
-    </hc-new-dialog>
 </template>
 
 <script setup>
@@ -72,7 +68,7 @@ const props = defineProps({
   },
 })
 
-const selectedKeyPath = ref(props.selectedKeyPath || []) // 传入的选中路径
+const emit = defineEmits(['menuTap']) ;const selectedKeyPath = ref(props.selectedKeyPath || []) // 传入的选中路径
 watch(() => props.selectedKeyPath, (newVal) => {
     selectedKeyPath.value = newVal || []
 }, { immediate: true })
@@ -85,32 +81,24 @@ const isParentActive = (parentIndex) => {
 // 右键菜单数据
 const contextMenuRef = ref(null)
 const menuData = ref([
-    { icon: 'add-circle', label: '新增节点', key: 'test-1' },
-    { icon: 'delete-bin', label: '删除节点', key: 'test-3' },
+    { icon: 'add-circle', label: '新增节点', key: 'add-node' },
+    { icon: 'delete-bin', label: '删除节点', key: 'del-node' },
 ])
-
+const curItem = ref(null)
 // 处理图标点击显示右键菜单(传递当前menuItemData)
 const handleIconClick = (event, data) => {
-    console.log(data, 'data')
-    
+
+    curItem.value = data
+
     event.preventDefault()
-    contextMenuRef.value?.showMenu(event, data)
+    contextMenuRef.value?.showMenu(event)
 }
-
 // 菜单被点击时输出当前menuItemData
-const handleMenuSelect = (item, data) => {
-    console.log('当前菜单项数据:', data) // 直接输出传递过来的menuItemData
-    console.log('点击的菜单选项:', item) // 可选:同时输出点击的菜单选项
-}
+const handleMenuSelect = (item) => {
+ 
 
-// 新增节点相关
-const addModal = ref(false)
-const addModalClose = () => {
-    addModal.value = false
-}
-const addModalSave = () => { 
+    emit('menuTap', item, curItem.value )
 }
-const addLoading = ref(false)
 </script>
 
 <style scoped>

+ 62 - 3
src/views/file/scan.vue

@@ -16,7 +16,7 @@
                     >
                         <!-- 渲染动态菜单 -->
                         <template v-for="item in folderData" :key="item.id">
-                            <MenuItem :menu-item-data="item" :selected-key-path="selectedKeyPath" />
+                            <MenuItem :menu-item-data="item" :selected-key-path="selectedKeyPath" @menu-tap="menuClick" />
                         </template>
                     </ElMenu>
                     <div v-else class="mt-40">
@@ -166,6 +166,15 @@
                 <!-- <el-button type="primary" size="large" class="split-confirm-btn" hc-btn @click="splitModalClose">好的,我知道了</el-button> -->
             </div>
         </hc-new-dialog>
+
+        <!-- 新增节点 -->
+        <hc-new-dialog v-model="addModal" :loading="addLoading" title="新增节点" @close="addModalClose" @save="addModalSave">
+            <el-form ref="addFormRef" :model="addFormData" :rules="addRules" label-width="110px">
+                <el-form-item label="节点名称" prop="nodeName">
+                    <el-input v-model="addFormData.nodeName" size="large" />
+                </el-form-item>
+            </el-form>
+        </hc-new-dialog>
     </div>
 </template>
 
@@ -174,12 +183,13 @@ import { onMounted, ref } from 'vue'
 import scanApi from '~api/archiveFile/scanning'
 import { useAppStore } from '~src/store'
 import HcTree from '~src/components/tree/hc-tree.vue'
-import { arrToId, deepClone, getArrValue, getObjValue } from 'js-fast-way'
+import { arrToId, deepClone, formValidate, getArrValue, getObjValue } from 'js-fast-way'
 import MenuItem from './MenuItem.vue' // 导入递归组件
 import { toPdfPage } from '~uti/btn-auth'
 
 import tasksApi from '~api/tasks/data'
-import { HcFirmMsg, HcUploadFileApi } from 'hc-vue3-ui'
+import { HcDelMsg, HcFirmMsg } from 'hc-vue3-ui'
+
 const useAppState = useAppStore()
 const contractId = ref(useAppState.getContractId)
 const projectId = ref(useAppState.getProjectId)
@@ -581,6 +591,55 @@ const splitModalClose = ()=>{
 //新增节点
 const addClick = ()=>{
     
+}
+const menuClick = (item, curItem)=>{
+    console.log(item, curItem, 'item2222222')
+    const { key } = item
+    if (key === 'add-node') {
+        addModal.value = true
+    }
+    
+}
+
+// 新增节点相关
+const addModal = ref(false)
+const addModalClose = () => {
+    addModal.value = false
+}
+const addFormRef = ref(null)
+const addModalSave = async () => { 
+        const isForm = await formValidate(addFormRef.value)
+    if (!isForm) return
+}
+
+const addFormData = ref({})
+const addLoading = ref(false)
+
+const addRules = ref({
+    nodeName: [{ required: true, message: '请输入节点名称', trigger: 'blur' }],
+
+})
+
+//删除节点
+const delModalClick = () => {
+    HcDelMsg(async (resolve) => {
+        await removeContractTreeNode(false)
+        resolve() //关闭弹窗的回调
+    })
+}
+
+const removeContractTreeNode = async (isBatch) => {
+    //    const { error, code } = await projectScanningApi.removeArchiveFile({
+    //     ids: ids,
+    // }, false)
+    // //判断状态
+    // CertLoading.value = false
+    // if (!error && code === 200) {
+    //     window.$message?.success('删除成功')
+    //     getTableData()
+    // } else {
+    //     window.$message?.error('删除失败')
+    // }
 }
 </script>