ZaiZai 1 year ago
parent
commit
07a0307923
2 changed files with 110 additions and 1 deletions
  1. 19 1
      src/views/project/tree/drawer-temp.vue
  2. 91 0
      src/views/project/tree/tree-form.vue

+ 19 - 1
src/views/project/tree/drawer-temp.vue

@@ -32,6 +32,8 @@
                 1111
             </hc-card>
         </hc-body>
+        <!-- 树节点新增 -->
+        <HcTreeNodeForm v-model="isTreeFormShow" :info="dataInfo" :data="treeFormData" :node="treeFormNode" :type="treeFormType" @finish="pseudoRefresh" />
     </hc-drawer>
 </template>
 
@@ -39,6 +41,7 @@
 import { ref, watch } from 'vue'
 import { HcFirmMsg } from 'hc-vue3-ui'
 import { getArrValue, isNullES } from 'js-fast-way'
+import HcTreeNodeForm from './tree-form.vue'
 import mainApi from '~api/project/tree'
 
 const props = defineProps({
@@ -113,13 +116,25 @@ const treeMenuClick = ({ key, data, node }) => {
         if (Number(data.isStorageNode) !== 1) {
             window.$message.warning('该节点下不允许新增节点')
         } else {
-            console.log(data)
+            treeFormType.value = '新增'
+            treeFormData.value = data
+            treeFormNode.value = node
         }
+    } else if (key === 'edit') {
+        treeFormType.value = '编辑'
+        treeFormData.value = data
+        treeFormNode.value = node
     } else if (key === 'sync') {
         syncTreeNode(data.id)
     }
 }
 
+//树节点新增/编辑
+const isTreeFormShow = ref(false)
+const treeFormData = ref({})
+const treeFormNode = ref({})
+const treeFormType = ref('新增')
+
 //同步树节点
 const syncTreeNode = (id) => {
     HcFirmMsg({ text: '是否同步该节点?' }, async (resolve) => {
@@ -135,6 +150,9 @@ const syncTreeNode = (id) => {
 const pseudoRefresh = () => {
     const val = isTreeMode.value
     isTreeMode.value = 4
+    treeFormData.value = {}
+    treeFormNode.value = {}
+    treeFormType.value = ''
     setTimeout(()=> {
         isTreeMode.value = val
     }, 300)

+ 91 - 0
src/views/project/tree/tree-form.vue

@@ -0,0 +1,91 @@
+<template>
+    <hc-dialog v-model="isShow" ui="hc-project-tree-tree-form" :title="type" widths="400px" :padding="false" @close="dialogClose">
+        111111
+        <template #footer>
+            <el-button hc-btn @click="dialogClose">取消</el-button>
+            <el-button hc-btn type="primary" :loading="submitLoading" @click="dialogSubmit">提交</el-button>
+        </template>
+    </hc-dialog>
+</template>
+
+<script setup>
+import { ref, watch } from 'vue'
+import { getDictionaryData } from '~uti/tools'
+import { getObjValue } from 'js-fast-way'
+import mainApi from '~api/project/tree'
+
+const props = defineProps({
+    info: {
+        type: Object,
+        default: () => ({}),
+    },
+    data: {
+        type: Object,
+        default: () => ({}),
+    },
+    node: {
+        type: Object,
+        default: () => ({}),
+    },
+    type: {
+        type: String,
+        default: '新增',
+    },
+})
+
+//事件
+const emit = defineEmits(['finish', 'close'])
+
+//双向绑定
+const isShow = defineModel('modelValue', {
+    default: false,
+})
+
+//监听可否编辑
+const formInfo = ref(props.info)
+const dataInfo = ref(props.data)
+const nodeInfo = ref(props.node)
+watch(() => [props.info, props.data, props.node], ([info, data, node]) => {
+    formInfo.value = getObjValue(info)
+    dataInfo.value = getObjValue(data)
+    nodeInfo.value = getObjValue(node)
+}, { immediate: true, deep: true })
+
+//监听显示
+watch(isShow, (val) => {
+    if (val) getInfoData()
+})
+
+//获取数据详情
+const getInfoData = () => {
+
+}
+
+//提交
+const submitLoading = ref(false)
+const dialogSubmit = async () => {
+    submitLoading.value = true
+    //const { isRes } = await mainApi.addColByTabId(tableData.value)
+    submitLoading.value = false
+    //if (!isRes) return
+    window.$message.success('操作成功')
+    dialogClose()
+    emit('finish')
+}
+
+//关闭弹窗
+const dialogClose = () => {
+    isShow.value = false
+    submitLoading.value = false
+    dataInfo.value = {}
+    nodeInfo.value = {}
+    emit('close')
+}
+</script>
+
+<style lang="scss">
+.el-overlay-dialog .el-dialog.hc-new-dialog.hc-project-tree-tree-form .el-dialog__body{
+    height: 660px;
+    padding: 12px 0;
+}
+</style>