Browse Source

Merge remote-tracking branch 'origin/master'

ZaiZai 8 months ago
parent
commit
7893755244

+ 16 - 0
src/api/modules/project/debit/contract/unit.js

@@ -137,4 +137,20 @@ export default {
                 params: form,
             }, msg)
     },
+    //复制节点,获取子树
+    async getCurrentNodeTree(form, msg = true) {
+        return HcApi({
+                url: '/api/blade-meter/tree/contract/getCurrentNodeTree',
+                method: 'get',
+                params: form,
+            }, msg)
+    },
+    //删除合同计量单元关联WBS节点
+    async copyNode(form, msg = true) {
+        return HcApi({
+            url: '/api/blade-meter/tree/contract/copyNode',
+            method: 'post',
+            data: form,
+        }, msg)
+    },
 }

+ 109 - 16
src/views/project/debit/contract/components/unit/tree-form.vue

@@ -1,17 +1,28 @@
 <template>
-    <hc-new-dialog v-model="isShow" is-table widths="95%" title="合同计量单元新增" :loading="addNodeLoading" @save="modalSave" @close="closeAddModal">
+    <hc-new-dialog v-model="isShow" is-table widths="95%" :title="title" :loading="addNodeLoading" @save="modalSave" @close="closeAddModal">
         <div class="relative h-full flex">
             <div :id="`hc_tree_card_${uuid}`">
                 <hc-new-card scrollbar>
                     <template #header>
                         <div class="text-sm text-orange">↓ 选择部位【点击新增】</div>
                     </template>
-                    <div class="tree-list">
+                    <div v-if="title === '合同计量单元新增'" class="tree-list">
                         <div v-for="(item, index) in treeDataList" :key="index" class="item" @click="treeListClick(item)">
                             <HcIcon name="box-3" fill />
                             <span class="ml-1">{{ item.nodeName }}</span>
                         </div>
                     </div>
+                    <div v-else>
+                        <HcDataTree 
+                            ref="leftTree"
+                            tree-key="id" 
+                            show-checkbox check-strictly  
+                            :datas="leftTreeData" 
+                            :h-props="lefttreeProps" 
+                            @node-tap="nodeElTreeClick"
+                            @check="treeNodeCheck"
+                        />
+                    </div>
                 </hc-new-card>
             </div>
             <div :id="`hc_table_card_${uuid}`" class="flex-1">
@@ -31,8 +42,8 @@
                         </template>
                         <template #isAddChildNode="{ row }">
                             <el-radio-group v-model="row.isAddChildNode">
-                                <el-radio :label="1">是</el-radio>
-                                <el-radio :label="0" class="ml-2">否</el-radio>
+                                <el-radio :value="1">是</el-radio>
+                                <el-radio :value="0" class="ml-2">否</el-radio>
                             </el-radio-group>
                         </template>
                         <template #action="{ index }">
@@ -64,6 +75,10 @@ const props = defineProps({
         type: [String, Number],
         default: '',
     },
+    title:{
+        type: [String],
+         default: '合同计量单元新增',
+    },
 })
 //事件
 const emit = defineEmits(['finish', 'close'])
@@ -73,6 +88,7 @@ const contractId = ref(useAppState.getContractId || '')
 const menuType = ref(props.menuType)
 const ids = ref(props.ids)
 const templateId = ref(props.templateId)
+const title = ref(props.title)
 const uuid = getRandom(4)
 
 //双向绑定
@@ -91,23 +107,72 @@ const getTreeDataList = async ()=>{
         treeDataList.value = []
     }
 }
+
+//表格数据
+const tableColumn = ref([
+    { key: 'nodeName', name: '名称' },
+    { key: 'startStake', name: '开始桩号' },
+    { key: 'endStake', name: '结束桩号' },
+    { key: 'contractPicture', name: '合同图号' },
+    { key: 'isAddChildNode', name: '是否划分子节点', width: 120, align: 'center' },
+    { key: 'action', name: '操作', width: 80, align: 'center' },
+])
+const leftTreeData = ref([])
+const treeLoading = ref(false)
+const getLeftTreeData = async (id) => {
+    treeLoading.value = true
+    const { error, code, data } = await unitApi.getCurrentNodeTree({
+        id,
+       contractId:contractId.value,
+  
+    })
+    treeLoading.value = false
+    if (!error && code === 200) {
+        leftTreeData.value = getArrValue(data)
+     
+    } else {
+        leftTreeData.value = []
+    
+    }
+}
 //监听
 watch(() => [
     props.ids,
     props.menuType,
     props.templateId,
-], ([Ids, Type, Tem]) => {
-    console.log(Type, 'Type')
+    props.title,
+], ([Ids, Type, Tem, til]) => {
     ids.value = Ids
     menuType.value = Type
     templateId.value = Tem
+    title.value = til
+    if (title.value === '合同计量单元复制') {
+            tableColumn.value = [
+            { key: 'nodeName', name: '名称' },
+            { key: 'startStake', name: '开始桩号' },
+            { key: 'endStake', name: '结束桩号' },
+            { key: 'contractPicture', name: '合同图号' },
+            ]
+    } else {
+        tableColumn.value = [
+            { key: 'nodeName', name: '名称' },
+            { key: 'startStake', name: '开始桩号' },
+            { key: 'endStake', name: '结束桩号' },
+            { key: 'contractPicture', name: '合同图号' },
+            { key: 'isAddChildNode', name: '是否划分子节点', width: 120, align: 'center' },
+            { key: 'action', name: '操作', width: 80, align: 'center' },
+        ]
+    }
     getTreeDataList()
+
 }, { immediate: true })
 
 //监听
 watch(isShow, (val) => {
     if (val) {
         setSplitRef()
+        getLeftTreeData(ids.value)
+       
       
     }
 })
@@ -136,15 +201,6 @@ const treeListClick = (item) => {
     })
 }
 
-//表格数据
-const tableColumn = ref([
-    { key: 'nodeName', name: '名称' },
-    { key: 'startStake', name: '开始桩号' },
-    { key: 'endStake', name: '结束桩号' },
-    { key: 'contractPicture', name: '合同图号' },
-    { key: 'isAddChildNode', name: '是否划分子节点', width: 120, align: 'center' },
-    { key: 'action', name: '操作', width: 80, align: 'center' },
-])
 const tableData = ref([])
 
 //删除
@@ -157,7 +213,8 @@ const modalSave = async () => {
         window.$message.warning('请选择部位点击新增')
         return
     }
-   
+    if (title.value === '合同计量单元新增') {
+
         const { error, code, msg } = await unitApi.addNode({
             contractId:contractId.value,
             projectId:projectId.value,
@@ -177,11 +234,47 @@ const modalSave = async () => {
              window.$message.error(msg)
          }
         emit('finish')
+    } else {
+
+        const { error, code, msg } = await unitApi.copyNode({
+            contractId:contractId.value,
+            id:ids.value,
+            vo2s:tableData.value,
+      
+        })
+        //判断状态
+        addNodeLoading.value = false
+        if (!error && code === 200) {
+            window?.$message?.success(msg)
+            tableData.value = []
+     
+        } else {
+             window.$message.error(msg)
+         }
+        emit('finish')
+    }
+
+   
     
 }
 const closeAddModal = ()=>{
     tableData.value = []
 }
+
+const lefttreeProps = {
+    label: 'nodeName',
+    children: 'children',
+    isLeaf: 'notExsitChild',
+}
+const nodeElTreeClick = (data)=>{
+
+}
+const treeNodeCheck = (_, { checkedNodes }) => {
+    console.log(checkedNodes, 'checkedNodes')
+    tableData.value = checkedNodes
+  
+}
+const leftTree = ref(null)
 </script>
 
 <style lang="scss" scoped>

+ 17 - 3
src/views/project/debit/contract/unit.vue

@@ -26,7 +26,7 @@
                 <template #extra>
                     <el-button hc-btn type="primary" @click="editModalShow = true">修改</el-button>
                     <el-button hc-btn type="danger">删除</el-button>
-                    <el-button hc-btn type="warning" @click="treeModalShow = true">增补单元</el-button>
+                    <el-button hc-btn type="warning" @click="supplyClick">增补单元</el-button>
                     <el-button hc-btn type="success" @click="leadModal">导入</el-button>
                 </template>
                 <div class="relative">
@@ -79,7 +79,8 @@
         <!-- 节点新增和编辑 -->
         <treeForm
             v-model="treeModalShow" :ids="curTreeData.id" :menu-type="menuType"
-            :template-id="curTreeData.templateId" @finish="finishForm"
+            :template-id="curTreeData.templateId" :title="treeModalShowTitle"
+            @finish="finishForm"
         />
 
         <!-- 修改合同计量单元 -->
@@ -369,6 +370,7 @@ const treeLoadMenu = ({ item, level }, resolve) => {
                 { icon: 'lock', label: '解锁', key: 'lock' },
                 { icon: 'upload-cloud', label: '导入', key: 'lead' },
                 { icon: 'add', label: '新增', key: 'add' },
+                { icon: 'file-copy', label: '复制', key: 'copy' },
                 { icon: 'pencil', label: '修改', key: 'edit' },
                 { icon: 'arrow-up-down-line', label: '排序', key: 'sort' },
                 { icon: 'close', label: '删除', key: 'del' },
@@ -378,6 +380,7 @@ const treeLoadMenu = ({ item, level }, resolve) => {
                 { icon: 'lock', label: '锁定', key: 'lock' },
                 { icon: 'upload-cloud', label: '导入', key: 'lead' },
                 { icon: 'add', label: '新增', key: 'add' },
+                { icon: 'file-copy', label: '复制', key: 'copy' },
                 { icon: 'pencil', label: '修改', key: 'edit' },
                 { icon: 'arrow-up-down-line', label: '排序', key: 'sort' },
                 { icon: 'close', label: '删除', key: 'del' },
@@ -402,11 +405,13 @@ const treeMenuTap = ({ key, node, data, keys }) => {
 
             } else {
                 treeModalShow.value = true
+                treeModalShowTitle.value = '合同计量单元新增'
             }
 
         }
         if (key === 'edit') {
             editModalShow.value = true
+      
         }
         if (key === 'sort') {
             let nodes = [], childNodes = []
@@ -433,6 +438,11 @@ const treeMenuTap = ({ key, node, data, keys }) => {
     if (key === 'lock') {
         handleLockNode()
     }
+    if (key === 'copy') {
+        console.log(node, 'node')
+        treeModalShow.value = true
+        treeModalShowTitle.value = '合同计量单元复制'
+    }
 }
 //锁定节点
 const handleLockNode = async () => {
@@ -513,6 +523,7 @@ const tableRowStyle = ({ row }) => {
 
 //弹窗
 const treeModalShow = ref(false)
+const treeModalShowTitle = ref('')
 const editModalShow = ref(false)
 const finishForm = () => {
     treeModalShow.value = false
@@ -521,7 +532,10 @@ const finishForm = () => {
         ishowTree.value = true
     }, 100)
 }
-
+const supplyClick = ()=>{
+    treeModalShow.value = true
+    treeModalShowTitle.value = '合同计量单元新增'
+}
 const finishEdit = () => {
     editModalShow.value = false
     ishowTree.value = false