Browse Source

合同计量单元树接口调用

duy 1 năm trước cách đây
mục cha
commit
cc4ac9e541

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

@@ -0,0 +1,77 @@
+import { HcApi } from '../../../../request/index'
+
+//  合同计量单元
+export default {
+    //懒加载系统树
+    async lazyTree(form, msg = true) {
+        return HcApi({
+            url: '/api/blade-meter/tree/contract/lazy',
+            method: 'get',
+            params: form,
+        }, msg)
+    },
+    //合同段树初始化(新增、增量同步)
+    async refresh(form, msg = true) {
+        return HcApi({
+            url: '/api/blade-meter/tree/contract/refresh',
+            method: 'get',
+            params: form,
+        }, msg)
+    },
+      //获取节点详情
+      async getNodeDetail(form, msg = true) {
+        return HcApi({
+            url: '/api/blade-meter/tree/contract/detail',
+            method: 'get',
+            params: form,
+        }, msg)
+    },
+    //修改节点
+   async updateForm(form, msg = true) {
+    return HcApi({
+        url: '/api/blade-meter/tree/contract/update',
+        method: 'post',
+        data: form,
+    }, msg)
+   },
+    //新增节点
+    async addNode(form, msg = true) {
+        return HcApi({
+            url: '/api/blade-meter/tree/contract/save',
+            method: 'post',
+            data: form,
+        }, msg)
+    },
+    //删除节点
+       async deleteNode(form, msg = true) {
+        return HcApi({
+            url: '/api/blade-meter/tree/contract/remove',
+            method: 'get',
+            params: form,
+        }, msg)
+    },
+    //调整排序
+    async sortForm(form, msg = true) {
+        return HcApi({
+            url: '/api/blade-meter/tree/contract/sort',
+            method: 'post',
+            params: form,
+        }, msg)
+    },
+      //合同段树节点锁定-解锁
+      async getLock(form, msg = true) {
+        return HcApi({
+            url: '/api/blade-meter/tree/contract/lock',
+            method: 'get',
+            params: form,
+        }, msg)
+    },
+    //合同段-新增-增补单元-左边节点列表
+    async getLeftList(form, msg = true) {
+    return HcApi({
+        url: '/api/blade-meter/tree/contract/left-list',
+        method: 'get',
+        params: form,
+    }, msg)
+},
+}

+ 1 - 1
src/views/project/debit/contract/check-list.vue

@@ -502,7 +502,7 @@ const handleLockNode = async ()=>{
     const { error, code, msg } = await lockNode({
     const { error, code, msg } = await lockNode({
         id: treeItem.value.id || '',
         id: treeItem.value.id || '',
         contractId:contractId.value,
         contractId:contractId.value,
-        status:treeItem.value?.isLock || '',
+        status:treeItem.value?.isLock === 1 ? 0 : 1 || '',
     })
     })
     if (!error && code === 200) {
     if (!error && code === 200) {
         window?.$message?.success(msg)
         window?.$message?.success(msg)

+ 32 - 13
src/views/project/debit/contract/components/unit/info-table.vue

@@ -2,39 +2,58 @@
     <hc-info-table>
     <hc-info-table>
         <tr>
         <tr>
             <hc-info-table-td center is-title width="120px">工程名称:</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">工程名称:</hc-info-table-td>
-            <hc-info-table-td width="auto">合同计量单元</hc-info-table-td>
+            <hc-info-table-td width="auto">{{ infoData?.nodeName }}</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">工程编号:</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">工程编号:</hc-info-table-td>
-            <hc-info-table-td width="auto">-</hc-info-table-td>
+            <hc-info-table-td width="auto">{{ infoData?.nodeCode }}</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">节点类型:</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">节点类型:</hc-info-table-td>
-            <hc-info-table-td width="auto">-</hc-info-table-td>
+            <hc-info-table-td width="auto">{{ infoData?.nodeType }}</hc-info-table-td>
         </tr>
         </tr>
         <tr>
         <tr>
             <hc-info-table-td center is-title width="120px">工程类型:</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">工程类型:</hc-info-table-td>
-            <hc-info-table-td width="auto">-</hc-info-table-td>
+            <hc-info-table-td width="auto">{{ infoData?.engineeringType }}</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">显示类型:</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">显示类型:</hc-info-table-td>
-            <hc-info-table-td width="auto">-</hc-info-table-td>
+            <hc-info-table-td width="auto">{{ infoData?.showType }}</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">起始桩号:</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">起始桩号:</hc-info-table-td>
-            <hc-info-table-td width="auto">-</hc-info-table-td>
+            <hc-info-table-td width="auto">{{ infoData?.startStake }}</hc-info-table-td>
         </tr>
         </tr>
         <tr>
         <tr>
             <hc-info-table-td center is-title width="120px">结束桩号:</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">结束桩号:</hc-info-table-td>
-            <hc-info-table-td width="auto">-</hc-info-table-td>
+            <hc-info-table-td width="auto">{{ infoData?.endStake }}</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">施工图金额:</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">施工图金额:</hc-info-table-td>
-            <hc-info-table-td width="auto">123123</hc-info-table-td>
+            <hc-info-table-td width="auto">{{ infoData?.buildPictureMoney }}</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">合同图号:</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">合同图号:</hc-info-table-td>
-            <hc-info-table-td width="auto">-</hc-info-table-td>
+            <hc-info-table-td width="auto">{{ infoData?.contractPicture }}</hc-info-table-td>
         </tr>
         </tr>
         <tr>
         <tr>
             <hc-info-table-td center is-title width="120px">变更合同图号:</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">变更合同图号:</hc-info-table-td>
-            <hc-info-table-td width="auto">-</hc-info-table-td>
+            <hc-info-table-td width="auto">{{ infoData?.changePicture }}</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">变更后金额:</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">变更后金额:</hc-info-table-td>
-            <hc-info-table-td width="auto">123123</hc-info-table-td>
+            <hc-info-table-td width="auto">{{ infoData?.changeMoney }}</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">是否增补:</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">是否增补:</hc-info-table-td>
-            <hc-info-table-td width="auto">否</hc-info-table-td>
+            <hc-info-table-td width="auto">{{ infoData?.isSupplement === 1 ? '是' : '' }}</hc-info-table-td>
         </tr>
         </tr>
         <tr>
         <tr>
             <hc-info-table-td center is-title width="120px">备注:</hc-info-table-td>
             <hc-info-table-td center is-title width="120px">备注:</hc-info-table-td>
-            <hc-info-table-td width="auto" colspan="5">-</hc-info-table-td>
+            <hc-info-table-td width="auto" colspan="5">{{ infoData?.remarks }}</hc-info-table-td>
         </tr>
         </tr>
     </hc-info-table>
     </hc-info-table>
 </template>
 </template>
+
+<script setup>
+import { ref, watch } from 'vue'
+//参数
+const props = defineProps({
+    infoData: {
+        type: Object,
+        default: () => ({}),
+    },
+})
+const infoData = ref(props.infoData)
+//监听
+watch(() => [
+    props.infoData,
+], ([InfoData]) => {
+    console.log(InfoData, 'InfoData')
+    infoData.value = InfoData
+})
+</script>

+ 43 - 20
src/views/project/debit/contract/components/unit/row-data.vue

@@ -1,28 +1,28 @@
 <template>
 <template>
-    <hc-new-dialog v-model="isShow" widths="90%" :is-table="isTable" :padding="false" title="合同计量单元修改" @save="modalSave">
+    <hc-new-dialog v-model="isShow" widths="90%" :is-table="isTable" :padding="false" title="合同计量单元修改" :loading="addNodeLoading" @save="modalSave">
         <hc-body scrollbar :contents="!isTable">
         <hc-body scrollbar :contents="!isTable">
             <el-form ref="formRef" label-position="left" label-width="auto" :model="formModel" :rules="formRules">
             <el-form ref="formRef" label-position="left" label-width="auto" :model="formModel" :rules="formRules">
                 <el-row :gutter="20">
                 <el-row :gutter="20">
                     <el-col :span="6">
                     <el-col :span="6">
                         <el-form-item label="工程名称:">
                         <el-form-item label="工程名称:">
-                            <el-input v-model="formModel.key1" placeholder="工程名称" />
+                            <el-input v-model="formModel.nodeName" placeholder="工程名称" />
                         </el-form-item>
                         </el-form-item>
                     </el-col>
                     </el-col>
                     <el-col :span="6">
                     <el-col :span="6">
                         <el-form-item label="工程编号:">
                         <el-form-item label="工程编号:">
-                            <el-input v-model="formModel.key2" placeholder="工程编号" />
+                            <el-input v-model="formModel.knodeCodeey2" placeholder="工程编号" />
                         </el-form-item>
                         </el-form-item>
                     </el-col>
                     </el-col>
                     <el-col :span="6">
                     <el-col :span="6">
                         <el-form-item label="节点类型:">
                         <el-form-item label="节点类型:">
-                            <el-select v-model="formModel.key3" placeholder="节点类型" block>
+                            <el-select v-model="formModel.nodeType" placeholder="节点类型" block>
                                 <el-option label="单位工程" :value="1" />
                                 <el-option label="单位工程" :value="1" />
                             </el-select>
                             </el-select>
                         </el-form-item>
                         </el-form-item>
                     </el-col>
                     </el-col>
                     <el-col :span="6">
                     <el-col :span="6">
                         <el-form-item label="工程类型:">
                         <el-form-item label="工程类型:">
-                            <el-select v-model="formModel.key4" placeholder="工程类型" disabled block>
+                            <el-select v-model="formModel.engineeringType" placeholder="工程类型" disabled block>
                                 <el-option label="总则" :value="1" />
                                 <el-option label="总则" :value="1" />
                             </el-select>
                             </el-select>
                         </el-form-item>
                         </el-form-item>
@@ -36,48 +36,49 @@
                     </el-col>
                     </el-col>
                     <el-col :span="6">
                     <el-col :span="6">
                         <el-form-item label="起始桩号:">
                         <el-form-item label="起始桩号:">
-                            <el-input v-model="formModel.key6" placeholder="起始桩号" />
+                            <el-input v-model="formModel.startStake" placeholder="起始桩号" />
                         </el-form-item>
                         </el-form-item>
                     </el-col>
                     </el-col>
                     <el-col :span="6">
                     <el-col :span="6">
                         <el-form-item label="结束桩号:">
                         <el-form-item label="结束桩号:">
-                            <el-input v-model="formModel.key7" placeholder="结束桩号" />
+                            <el-input v-model="formModel.endStake" placeholder="结束桩号" />
                         </el-form-item>
                         </el-form-item>
                     </el-col>
                     </el-col>
                     <el-col :span="6">
                     <el-col :span="6">
                         <el-form-item label="是否增补:">
                         <el-form-item label="是否增补:">
-                            <el-select v-model="formModel.key8" placeholder="是否增补" disabled block>
+                            <el-select v-model="formModel.isSupplement" placeholder="是否增补" disabled block>
                                 <el-option label="是" :value="1" />
                                 <el-option label="是" :value="1" />
+                                <el-option label="否" :value="0" />
                             </el-select>
                             </el-select>
                         </el-form-item>
                         </el-form-item>
                     </el-col>
                     </el-col>
                     <el-col :span="6">
                     <el-col :span="6">
                         <el-form-item label="施工金额:">
                         <el-form-item label="施工金额:">
-                            <el-input v-model="formModel.key9" placeholder="施工图金额" disabled>
+                            <el-input v-model="formModel.buildPictureMoney" placeholder="施工图金额" disabled>
                                 <template #suffix>元</template>
                                 <template #suffix>元</template>
                             </el-input>
                             </el-input>
                         </el-form-item>
                         </el-form-item>
                     </el-col>
                     </el-col>
                     <el-col :span="6">
                     <el-col :span="6">
                         <el-form-item label="变更金额:">
                         <el-form-item label="变更金额:">
-                            <el-input v-model="formModel.key9" placeholder="变更后金额" disabled>
+                            <el-input v-model="formModel.changeMoney" placeholder="变更后金额" disabled>
                                 <template #suffix>元</template>
                                 <template #suffix>元</template>
                             </el-input>
                             </el-input>
                         </el-form-item>
                         </el-form-item>
                     </el-col>
                     </el-col>
                     <el-col :span="6">
                     <el-col :span="6">
                         <el-form-item label="合同图号:">
                         <el-form-item label="合同图号:">
-                            <el-input v-model="formModel.key9" placeholder="合同图号" />
+                            <el-input v-model="formModel.contractPicture" placeholder="合同图号" />
                         </el-form-item>
                         </el-form-item>
                     </el-col>
                     </el-col>
                     <el-col :span="6">
                     <el-col :span="6">
                         <el-form-item label="变更图号:">
                         <el-form-item label="变更图号:">
-                            <el-input v-model="formModel.key9" placeholder="变更合同图号" />
+                            <el-input v-model="formModel.changePicture" placeholder="变更合同图号" />
                         </el-form-item>
                         </el-form-item>
                     </el-col>
                     </el-col>
                     <el-col :span="24">
                     <el-col :span="24">
                         <el-form-item label="备注:">
                         <el-form-item label="备注:">
-                            <el-input v-model="formModel.key10" :autosize="{ minRows: 4, maxRows: 8 }" type="textarea" />
+                            <el-input v-model="formModel.remarks" :autosize="{ minRows: 4, maxRows: 8 }" type="textarea" />
                         </el-form-item>
                         </el-form-item>
                     </el-col>
                     </el-col>
                 </el-row>
                 </el-row>
@@ -109,6 +110,8 @@
 <script setup>
 <script setup>
 import { ref, watch } from 'vue'
 import { ref, watch } from 'vue'
 import AddCheckList from './addCheckList.vue'
 import AddCheckList from './addCheckList.vue'
+import unitApi from '~api/project/debit/contract/unit.js'
+import { useAppStore } from '~src/store'
 
 
 const props = defineProps({
 const props = defineProps({
     ids: {
     ids: {
@@ -119,22 +122,32 @@ const props = defineProps({
         type: Boolean,
         type: Boolean,
         default: false,
         default: false,
     },
     },
+    curTreeData:{
+        default: () => ({}),
+    },
 })
 })
-
 //事件
 //事件
 const emit = defineEmits(['finish', 'close'])
 const emit = defineEmits(['finish', 'close'])
-
+const useAppState = useAppStore()
+const projectId = ref(useAppState.getProjectId || '')
+const contractId = ref(useAppState.getContractId || '')
 //双向绑定
 //双向绑定
 // eslint-disable-next-line no-undef
 // eslint-disable-next-line no-undef
 const isShow = defineModel('modelValue', {
 const isShow = defineModel('modelValue', {
     default: false,
     default: false,
 })
 })
 
 
+const ids = ref(props.ids)
+const curTreeData = ref(props.curTreeData)
+const formModel = ref({})
 //监听
 //监听
 watch(() => [
 watch(() => [
     props.ids,
     props.ids,
-], ([ids]) => {
-    console.log('ids', ids)
+    props.curTreeData,
+], ([Ids, cur]) => {
+    ids.value = Ids
+    curTreeData.value = cur
+    formModel.value = cur
 }, { immediate: true })
 }, { immediate: true })
 
 
 //监听
 //监听
@@ -146,7 +159,7 @@ watch(isShow, (val) => {
 
 
 //弹窗表单
 //弹窗表单
 const formRef = ref(null)
 const formRef = ref(null)
-const formModel = ref({})
+// const formModel = ref({})
 const formRules = ref({})
 const formRules = ref({})
 
 
 //列表
 //列表
@@ -165,8 +178,18 @@ const tableColumn = ref([
 const tableData = ref([
 const tableData = ref([
     { key1: '101-1-a' },
     { key1: '101-1-a' },
 ])
 ])
-
-const modalSave = () => {
+const addNodeLoading = ref(false)
+const modalSave = async () => {
+    const { error, code, msg } = await unitApi.updateForm({
+            ...formModel.value,
+      
+        })
+        //判断状态
+        addNodeLoading.value = false
+        if (!error && code === 200) {
+            window?.$message?.success(msg)
+     
+        }
     emit('finish')
     emit('finish')
 }
 }
 
 

+ 77 - 30
src/views/project/debit/contract/components/unit/tree-form.vue

@@ -1,5 +1,5 @@
 <template>
 <template>
-    <hc-new-dialog v-model="isShow" is-table widths="95%" title="合同计量单元新增" @save="modalSave">
+    <hc-new-dialog v-model="isShow" is-table widths="95%" title="合同计量单元新增" :loading="addNodeLoading" @save="modalSave">
         <div class="relative h-full flex">
         <div class="relative h-full flex">
             <div :id="`hc_tree_card_${uuid}`">
             <div :id="`hc_tree_card_${uuid}`">
                 <hc-new-card scrollbar>
                 <hc-new-card scrollbar>
@@ -9,7 +9,7 @@
                     <div class="tree-list">
                     <div class="tree-list">
                         <div v-for="(item, index) in treeDataList" :key="index" class="item" @click="treeListClick(item)">
                         <div v-for="(item, index) in treeDataList" :key="index" class="item" @click="treeListClick(item)">
                             <HcIcon name="box-3" fill />
                             <HcIcon name="box-3" fill />
-                            <span class="ml-1">{{ item.name }}</span>
+                            <span class="ml-1">{{ item.nodeName }}</span>
                         </div>
                         </div>
                     </div>
                     </div>
                 </hc-new-card>
                 </hc-new-card>
@@ -17,20 +17,20 @@
             <div :id="`hc_table_card_${uuid}`" class="flex-1">
             <div :id="`hc_table_card_${uuid}`" class="flex-1">
                 <hc-new-card scrollbar title="合同计量单元">
                 <hc-new-card scrollbar title="合同计量单元">
                     <hc-table :is-index="false" :column="tableColumn" :datas="tableData" is-new :index-style="{ width: 60 }">
                     <hc-table :is-index="false" :column="tableColumn" :datas="tableData" is-new :index-style="{ width: 60 }">
-                        <template #key1="{ row }">
-                            <hc-table-input v-model="row.key1" />
+                        <template #nodeName="{ row }">
+                            <hc-table-input v-model="row.nodeName" />
                         </template>
                         </template>
-                        <template #key2="{ row }">
-                            <hc-table-input v-model="row.key2" />
+                        <template #startStake="{ row }">
+                            <hc-table-input v-model="row.startStake" />
                         </template>
                         </template>
-                        <template #key3="{ row }">
-                            <hc-table-input v-model="row.key3" />
+                        <template #endStake="{ row }">
+                            <hc-table-input v-model="row.endStake" />
                         </template>
                         </template>
-                        <template #key4="{ row }">
-                            <hc-table-input v-model="row.key4" />
+                        <template #contractPicture="{ row }">
+                            <hc-table-input v-model="row.contractPicture" />
                         </template>
                         </template>
-                        <template #key5="{ row }">
-                            <el-radio-group v-model="row.key5">
+                        <template #isAddChildNode="{ row }">
+                            <el-radio-group v-model="row.isAddChildNode">
                                 <el-radio :label="1">是</el-radio>
                                 <el-radio :label="1">是</el-radio>
                                 <el-radio :label="2" class="ml-2">否</el-radio>
                                 <el-radio :label="2" class="ml-2">否</el-radio>
                             </el-radio-group>
                             </el-radio-group>
@@ -47,18 +47,32 @@
 
 
 <script setup>
 <script setup>
 import { nextTick, ref, watch } from 'vue'
 import { nextTick, ref, watch } from 'vue'
-import { getRandom } from 'js-fast-way'
+import { getArrValue, getRandom } from 'js-fast-way'
+import unitApi from '~api/project/debit/contract/unit.js'
+import { useAppStore } from '~src/store'
 
 
 const props = defineProps({
 const props = defineProps({
     ids: {
     ids: {
         type: [String, Number],
         type: [String, Number],
         default: '',
         default: '',
     },
     },
+    menuType:{
+        type: [String, Number],
+        default: '',
+    },
+    templateId:{
+        type: [String, Number],
+        default: '',
+    },
 })
 })
-
 //事件
 //事件
 const emit = defineEmits(['finish', 'close'])
 const emit = defineEmits(['finish', 'close'])
-
+const useAppState = useAppStore()
+const projectId = ref(useAppState.getProjectId || '')
+const contractId = ref(useAppState.getContractId || '')
+const menuType = ref(props.menuType)
+const ids = ref(props.ids)
+const templateId = ref(props.templateId)
 const uuid = getRandom(4)
 const uuid = getRandom(4)
 
 
 //双向绑定
 //双向绑定
@@ -70,14 +84,19 @@ const isShow = defineModel('modelValue', {
 //监听
 //监听
 watch(() => [
 watch(() => [
     props.ids,
     props.ids,
-], ([ids]) => {
-    console.log('ids', ids)
+    props.menuType,
+    props.templateId,
+], ([Ids, Type, Tem]) => {
+    ids.value = Ids
+    menuType.value = Type
+    templateId.value = Tem
 }, { immediate: true })
 }, { immediate: true })
 
 
 //监听
 //监听
 watch(isShow, (val) => {
 watch(isShow, (val) => {
     if (val) {
     if (val) {
         setSplitRef()
         setSplitRef()
+        getTreeDataList()
     }
     }
 })
 })
 
 
@@ -100,21 +119,31 @@ const treeDataList = ref([
 ])
 ])
 const treeListClick = (item) => {
 const treeListClick = (item) => {
     tableData.value.push({
     tableData.value.push({
-        key1: item.name,
-        key2: '',
-        key3: '',
-        key4: '',
-        key5: 1,
+        nodeName: item.nodeName,
+        startStake: '',
+        endStake: '',
+        contractPicture: '',
+        isAddChildNode: 1,
     })
     })
 }
 }
-
+const getTreeDataList = async ()=>{
+    const { error, code, data } = await unitApi.getLeftList({
+      id:ids.value,
+    })
+   
+    if (!error && code === 200) {
+        treeDataList.value = getArrValue(data)
+    } else {
+        treeDataList.value = []
+    }
+}
 //表格数据
 //表格数据
 const tableColumn = ref([
 const tableColumn = ref([
-    { key: 'key1', name: '名称' },
-    { key: 'key2', name: '开始桩号' },
-    { key: 'key3', name: '结束桩号' },
-    { key: 'key4', name: '合同图号' },
-    { key: 'key5', name: '是否划分子节点', width: 120, align: 'center' },
+    { 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' },
     { key: 'action', name: '操作', width: 80, align: 'center' },
 ])
 ])
 const tableData = ref([])
 const tableData = ref([])
@@ -123,9 +152,27 @@ const tableData = ref([])
 const delRowClick = (index) => {
 const delRowClick = (index) => {
     tableData.value.splice(index, 1)
     tableData.value.splice(index, 1)
 }
 }
+const addNodeLoading = ref(false)
+const modalSave = async () => {
 
 
-const modalSave = () => {
-    emit('finish')
+    if (menuType.value === 'add') {
+        const { error, code, msg } = await unitApi.addNode({
+            contractId:contractId.value,
+            projectId:projectId.value,
+            contractNodeId:ids.value,
+            requestType:1, //请求类型 1=节点新增 2=增补单元新增
+            templateId: templateId.value,
+            dataList:tableData.value,
+      
+        })
+        //判断状态
+        addNodeLoading.value = false
+        if (!error && code === 200) {
+            window?.$message?.success(msg)
+     
+        }
+        emit('finish')
+    }
 }
 }
 </script>
 </script>
 
 

+ 208 - 48
src/views/project/debit/contract/unit.vue

@@ -3,9 +3,19 @@
         <div :id="`hc_tree_card_${uuid}`">
         <div :id="`hc_tree_card_${uuid}`">
             <hc-new-card scrollbar>
             <hc-new-card scrollbar>
                 <template #header>
                 <template #header>
-                    <el-button hc-btn type="primary">重新设置treeCode</el-button>
+                    <el-button hc-btn type="primary" :loading="setLoading" @click="setTree">重新设置treeCode</el-button>
                 </template>
                 </template>
-                <hc-lazy-tree :h-props="treeProps" is-load-menu @load="treeLoadNode" @loadMenu="treeLoadMenu" @menuTap="treeMenuTap" @nodeTap="treeNodeTap" />
+                <hc-lazy-tree 
+                    v-if="ishowTree" 
+                    :auto-expand-keys="TreeAutoExpandKeys"
+                    tree-key="id" 
+                    :h-props="treeProps" 
+                    is-load-menu 
+                    @load="treeLoadNode" 
+                    @loadMenu="treeLoadMenu" 
+                    @menuTap="treeMenuTap"
+                    @nodeTap="treeNodeTap"
+                />
             </hc-new-card>
             </hc-new-card>
         </div>
         </div>
         <div :id="`hc_table_card_${uuid}`" class="flex-1">
         <div :id="`hc_table_card_${uuid}`" class="flex-1">
@@ -17,7 +27,7 @@
                     <el-button hc-btn type="success">导入</el-button>
                     <el-button hc-btn type="success">导入</el-button>
                 </template>
                 </template>
                 <div class="relative">
                 <div class="relative">
-                    <infoTable />
+                    <infoTable :info-data="curTreeData" />
                     <HcTitle title="清单分解汇总列表">
                     <HcTitle title="清单分解汇总列表">
                         <template #extra>
                         <template #extra>
                             <div class="text-sm text-orange">温馨提示:累计分解量 > 合同变更后量,整行文字红色</div>
                             <div class="text-sm text-orange">温馨提示:累计分解量 > 合同变更后量,整行文字红色</div>
@@ -33,13 +43,13 @@
         </div>
         </div>
 
 
         <!-- 节点新增和编辑 -->
         <!-- 节点新增和编辑 -->
-        <treeForm v-model="treeModalShow" />
+        <treeForm v-model="treeModalShow" :ids="curTreeData.id" :menu-type="menuType" :template-id="curTreeData.templateId" @finish="finishForm" />
 
 
         <!-- 修改合同计量单元 -->
         <!-- 修改合同计量单元 -->
-        <rowData v-model="editModalShow" :is-table="isInfoView" />
+        <rowData v-model="editModalShow" :is-table="isInfoView" :ids="curTreeData.id" :cur-tree-data="curTreeData" @finish="finishEdit" />
 
 
         <!-- 调整排序 -->
         <!-- 调整排序 -->
-        <hc-new-dialog v-model="sortModalShow" is-table widths="1100px" title="调整排序" @save="sortModalSave">
+        <hc-new-dialog v-model="sortModalShow" is-table widths="1100px" title="调整排序" :loading="sortNodeLoading" @save="sortModalSave">
             <hc-table
             <hc-table
                 ui="hc-table-row-drop"
                 ui="hc-table-row-drop"
                 :column="sortTableColumn" :datas="sortTableData" :loading="sortTableLoading"
                 :column="sortTableColumn" :datas="sortTableData" :loading="sortTableLoading"
@@ -64,11 +74,17 @@
 
 
 <script setup>
 <script setup>
 import { nextTick, onMounted, ref } from 'vue'
 import { nextTick, onMounted, ref } from 'vue'
-import { getRandom } from 'js-fast-way'
+import { arrToId, getArrValue, getObjValue, getRandom } from 'js-fast-way'
 import infoTable from './components/unit/info-table.vue'
 import infoTable from './components/unit/info-table.vue'
 import treeForm from './components/unit/tree-form.vue'
 import treeForm from './components/unit/tree-form.vue'
 import rowData from './components/unit/row-data.vue'
 import rowData from './components/unit/row-data.vue'
-
+import unitApi from '~api/project/debit/contract/unit.js'
+import { useAppStore } from '~src/store'
+import { getStoreValue, setStoreValue } from '~src/utils/storage'
+import { delMessageV2 } from '~com/message/index.js'
+const useAppState = useAppStore()
+const projectId = ref(useAppState.getProjectId || '')
+const contractId = ref(useAppState.getContractId || '')
 defineOptions({
 defineOptions({
     name: 'ProjectDebitContractUnit',
     name: 'ProjectDebitContractUnit',
 })
 })
@@ -97,66 +113,187 @@ const searchForm = ref({})
 
 
 //数据格式
 //数据格式
 const treeProps = {
 const treeProps = {
-    label: 'name',
+    label: 'nodeName',
     children: 'children',
     children: 'children',
     isLeaf: 'leaf',
     isLeaf: 'leaf',
 }
 }
-
+const ishowTree = ref(true)
+//重新设置树
+const setLoading = ref(false)
+const setTree = async ()=>{
+    const { error, code, msg } = await unitApi.refresh({
+        projectId: projectId.value,
+        contractId:contractId.value,
+    })
+    setLoading.value = false
+    if (!error && code === 200) {
+        window.$meaasge.sucess(msg)
+        ishowTree.value = false
+        setTimeout(() => {
+            ishowTree.value = true
+        }, 100)
+        } else {
+            // newlistdata.value = []
+        }
+}
 //懒加载的数据
 //懒加载的数据
-const treeLoadNode = ({ level }, resolve) => {
-    if (level === 0) {
-        return resolve([{ name: 'region' }])
-    }
-    if (level > 3) {
-        return resolve([])
+const TreeAutoExpandKeys = ref(getStoreValue('wbsTreeExpandKeys') || [])
+const treeLoadNode = async ({ node, item, level }, resolve) => {
+    let id = 0
+    if (level !== 0) {
+        const nodeData = getObjValue(item)
+        id = nodeData?.id || ''
     }
     }
-    setTimeout(() => {
-        resolve([
-            { name: 'leaf', leaf: true },
-            { name: 'zone' },
-        ])
-    }, 500)
+    //获取数据
+    const { error, code, data } = await unitApi.lazyTree({
+        contractId: contractId.value,
+        id:id,
+    })
+
+    resolve(getArrValue(data))
 }
 }
 
 
 //节点点击
 //节点点击
 const isInfoView = ref(false)
 const isInfoView = ref(false)
-const treeNodeTap = ({ node }) => {
+const treeNodeTap = ({ node, data, keys }) => {
     isInfoView.value = node.isLeaf
     isInfoView.value = node.isLeaf
+    TreeAutoExpandKeys.value = keys || []
+    setStoreValue('wbsTreeExpandKeys', keys)
+    getTreeNodeDetail(data)
+}
+//获取节点详情
+const curTreeData = ref({})
+const getTreeNodeDetail = async (node)=>{
+    const { id } = node
+    const { error, code, data } = await unitApi.getNodeDetail({
+       id,
+    })
+    if (!error && code === 200) {
+        curTreeData.value = getObjValue(data)
+        tableData.value = curTreeData.value['decompositionList']
+       
+   
+    } else {
+        curTreeData.value = {}
+        tableData.value = []
+       
+    }
 }
 }
-
 //菜单
 //菜单
 const treeLoadMenu = ({ item, level }, resolve) => {
 const treeLoadMenu = ({ item, level }, resolve) => {
+    console.log(item, 'item1111')
+    const { isLock } = item
     if (level === 1) {
     if (level === 1) {
-        return resolve([
-            { icon: 'lock', label: '锁定', key: 'lock' },
-            { icon: 'upload-cloud', label: '导入', key: 'lead' },
-            { icon: 'add', label: '新增', key: 'add' },
-            { icon: 'arrow-up-down-line', label: '排序', key: 'sort' },
-        ])
+        if (isLock === 1) {
+            return resolve([
+                { icon: 'lock', label: '解锁', key: 'lock' },
+                { icon: 'upload-cloud', label: '导入', key: 'lead' },
+                { icon: 'add', label: '新增', key: 'add' },
+                { icon: 'arrow-up-down-line', label: '排序', key: 'sort' },
+            ])
+        } else {
+            return resolve([
+                { icon: 'lock', label: '锁定', key: 'lock' },
+                { icon: 'upload-cloud', label: '导入', key: 'lead' },
+                { icon: 'add', label: '新增', key: 'add' },
+                { icon: 'arrow-up-down-line', label: '排序', key: 'sort' },
+            ])
+        }
+       
     } else {
     } else {
-        return resolve([
-            { icon: 'lock', label: '锁定', key: 'lock' },
-            { icon: 'upload-cloud', label: '导入', key: 'lead' },
-            { icon: 'add', label: '新增', key: 'add' },
-            { icon: 'pencil', label: '修改', key: 'edit' },
-            { icon: 'arrow-up-down-line', label: '排序', key: 'sort' },
-            { icon: 'close', label: '删除', key: 'del' },
-        ])
+        if (isLock === 1) {
+            return resolve([
+                { icon: 'lock', label: '解锁', key: 'lock' },
+                { icon: 'upload-cloud', label: '导入', key: 'lead' },
+                { icon: 'add', label: '新增', key: 'add' },
+                { icon: 'pencil', label: '修改', key: 'edit' },
+                { icon: 'arrow-up-down-line', label: '排序', key: 'sort' },
+                { icon: 'close', label: '删除', key: 'del' },
+            ])
+        } else {
+            return resolve([
+                { icon: 'lock', label: '锁定', key: 'lock' },
+                { icon: 'upload-cloud', label: '导入', key: 'lead' },
+                { icon: 'add', label: '新增', key: 'add' },
+                { icon: 'pencil', label: '修改', key: 'edit' },
+                { icon: 'arrow-up-down-line', label: '排序', key: 'sort' },
+                { icon: 'close', label: '删除', key: 'del' },
+            ])
+        }
     }
     }
 }
 }
-
-const treeMenuTap = ({ key, node, data }) => {
+const menuType = ref('')
+const treeMenuTap = ({ key, node, data, keys }) => {
+    menuType.value = key
+    getTreeNodeDetail(data)
+    setStoreValue('wbsTreeExpandKeys', keys)
+    TreeAutoExpandKeys.value = keys || []
     if (key === 'add') {
     if (key === 'add') {
         treeModalShow.value = true
         treeModalShow.value = true
     }
     }
     if (key === 'edit') {
     if (key === 'edit') {
-        treeModalShow.value = true
+        editModalShow.value = true
     }
     }
     if (key === 'sort') {
     if (key === 'sort') {
+        let nodes = [], childNodes = []
+        childNodes = node?.parent?.childNodes || node?.parent?.children || []
+        
+        for (let i = 0; i < childNodes.length; i++) {
+            const res = childNodes[i]?.data
+            nodes.push({
+                nodeName:res?.nodeName,
+                id:res?.id,
+            })
+        }
+        sortTableData.value = nodes
         sortModalShow.value = true
         sortModalShow.value = true
     }
     }
+    if (key === 'del') {
+        delModalClick()
+    }
+    if (key === 'lock') {
+        handleLockNode()
+    }
+}
+//锁定节点
+const handleLockNode = async ()=>{
+    const { error, code, msg } = await unitApi.getLock({
+        id: curTreeData.value.id || '',
+        lockStatus:curTreeData.value?.isLock === 1 ? 0 : 1,
+    })
+    if (!error && code === 200) {
+        window?.$message?.success(msg)
+        window?.location?.reload() //刷新页面
+    }
+}
+//删除节点
+const delModalClick = () => {
+    delMessageV2(async (action, instance, done) => {
+            if (action === 'confirm') {
+                instance.confirmButtonLoading = true
+                removeContractTreeNode()
+                instance.confirmButtonLoading = false
+                done()
+            } else {
+                done()
+            }
+    })
+}
+const removeContractTreeNode = async () => {
+    const loadingInstance = window.$loading.service({
+        fullscreen: true,
+        text: '删除节点中,请耐心等待...',
+        background: 'rgba(0, 0, 0, 0.7)',
+    })
+    const { error, code } = await unitApi.deleteNode({
+        id: curTreeData.value.id || '',
+    })
+    loadingInstance.close()
+    if (!error && code === 200) {
+        window?.$message?.success('删除成功')
+        window?.location?.reload() //刷新页面
+    }
 }
 }
-
 //表格数据
 //表格数据
 const tableLoading = ref(false)
 const tableLoading = ref(false)
 const tableColumn = ref([
 const tableColumn = ref([
@@ -176,18 +313,30 @@ const tableData = ref([
 //弹窗
 //弹窗
 const treeModalShow = ref(false)
 const treeModalShow = ref(false)
 const editModalShow = ref(false)
 const editModalShow = ref(false)
+const finishForm = ()=>{
+    treeModalShow.value = false
+    ishowTree.value = false
+    setTimeout(() => {
+        ishowTree.value = true
+    }, 100)
+}
 
 
+const finishEdit = ()=>{
+    editModalShow.value = false
+    ishowTree.value = false
+    setTimeout(() => {
+        ishowTree.value = true
+    }, 100)
+}
 //调整排序
 //调整排序
 const sortModalShow = ref(false)
 const sortModalShow = ref(false)
 //表格数据
 //表格数据
 const sortTableColumn = ref([
 const sortTableColumn = ref([
-    { key:'key1', name: '节点名称' },
+    { key:'nodeName', name: '节点名称' },
     { key:'action', name: '排序', width: 90 },
     { key:'action', name: '排序', width: 90 },
 ])
 ])
 const sortTableLoading = ref(false)
 const sortTableLoading = ref(false)
-const sortTableData = ref([
-    { key1: '1' }, { key1: '2' }, { key1: '3' },
-])
+const sortTableData = ref([])
 //拖动完成
 //拖动完成
 const sortTableRowDrop = (rows) => {
 const sortTableRowDrop = (rows) => {
     sortTableData.value = [] // 先清空,否则排序会异常
     sortTableData.value = [] // 先清空,否则排序会异常
@@ -218,7 +367,18 @@ const upSortClick = (index) => {
         window?.$message?.warning('已经处于置顶,无法上移')
         window?.$message?.warning('已经处于置顶,无法上移')
     }
     }
 }
 }
-const sortModalSave = () => {
-    sortModalShow.value = false
+const sortNodeLoading = ref(false)
+const sortModalSave = async () => {
+    const ids = arrToId(sortTableData.value)
+  //发起请求
+  sortNodeLoading.value = true
+    const { error, code } = await unitApi.sortForm({ ids })
+    sortNodeLoading.value = false
+    //判断状态
+    if (!error && code === 200) {
+        window?.$message?.success('保存成功')
+        sortModalShow.value = false
+        window?.location?.reload() //刷新页面
+    }
 }
 }
 </script>
 </script>

+ 3 - 2
src/views/project/debit/project/unit.vue

@@ -3,7 +3,7 @@
         <div :id="`hc_tree_card_${uuid}`">
         <div :id="`hc_tree_card_${uuid}`">
             <hc-new-card scrollbar>
             <hc-new-card scrollbar>
                 <template #header>
                 <template #header>
-                    <el-button hc-btn type="primary" @click="setTree">重新设置treeCode</el-button>
+                    <el-button hc-btn type="primary" :loading="setLoading" @click="setTree">重新设置treeCode</el-button>
                 </template>
                 </template>
                 <hc-lazy-tree 
                 <hc-lazy-tree 
                     v-if="ishowTree"
                     v-if="ishowTree"
@@ -166,11 +166,12 @@ const ishowTree = ref(true)
 //重新设置树
 //重新设置树
 const setLoading = ref(false)
 const setLoading = ref(false)
 const setTree = async ()=>{
 const setTree = async ()=>{
-    const { error, code, data } = await unitApi.refresh({
+    const { error, code, msg } = await unitApi.refresh({
         projectId: projectId.value,
         projectId: projectId.value,
     })
     })
     setLoading.value = false
     setLoading.value = false
     if (!error && code === 200) {
     if (!error && code === 200) {
+        window.$meaasge.sucess(msg)
         ishowTree.value = false
         ishowTree.value = false
         setTimeout(() => {
         setTimeout(() => {
             ishowTree.value = true
             ishowTree.value = true