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