Explorar el Código

关联资料修改

duy hace 1 año
padre
commit
bc179489a9

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

@@ -121,4 +121,12 @@ export default {
             data: form,
         }, msg)
     },
+    //删除合同计量单元关联WBS节点
+    async deleteLinkWbsTree(form, msg = true) {
+        return HcApi({
+            url: '/api/blade-meter/tree/contract/deleteLinkWbsTree',
+            method: 'post',
+            data: form,
+        }, msg)
+    },
 }

+ 25 - 7
src/views/project/debit/contract/components/unit/link-data.vue

@@ -33,7 +33,7 @@
                 <div class="relative h-full flex">
                     <div v-loading="treeLoading" class="hc_tree_card_border relative w-full">
                         <hc-body scrollbar padding="0px">
-                            <HcDataTree tree-key="pkeyId" show-checkbox :datas="rightTreeData" :h-props="treeProps" @node-tap="nodeElTreeClickRight" @check="treeNodeCheckRight" />
+                            <HcDataTree tree-key="pkeyId" show-checkbox :datas="rightTreeData" :h-props="treeProps" :default-checked-keys="rightKeys" @node-tap="nodeElTreeClickRight" @check="treeNodeCheckRight" />
                         </hc-body>
                     </div>
                 </div>
@@ -79,15 +79,20 @@ const props = defineProps({
         type: [Number, String],
         default: '',
     },
+    rightTreeCheck:{
+        type: Array,
+        default: () => ([]),
+    },
   
 })
 //事件
-const emit = defineEmits(['close'])
+const emit = defineEmits(['close', 'save'])
 const useAppState = useAppStore()
 const contractId = ref(useAppState.getContractId)
 const projectId = ref(useAppState.getProjectId)
 const isCheckId = ref(props.isCheckId)
 const checkIds = ref(props.checkIds)
+const rightTreeCheck = ref(props.rightTreeCheck)
 
 const linkModal = defineModel('modelValue', {
     default: false,
@@ -147,28 +152,41 @@ const lefttreeProps = {
     disabled: 'disabled',
 }
 const defaultCheckedKeys = ref([])
+const rightKeys = ref([])
  const autoExpandKeys = ref([])
+ const meterIds = ref('')
+const wbsIds = ref('')
 //监听
 watch(() => [
 props.linkModal,
 props.isCheckId,
 props.checkIds,
-], ([link, check, ids]) => {
+props.rightTreeCheck,
+], ([link, check, ids, right]) => {
     linkModal.value = link
     isCheckId.value = check
     checkIds.value = ids
-    getTwotreeData()
-    console.log(getStoreValue('wbsTreeExpandKeys'), '111111')
+    rightTreeCheck.value = right
+    if (link) {
+        getTwotreeData()
+    }
+   
+  
 
     if (check === 2) {
         const keys = getStoreValue('wbsTreeExpandKeys')
         autoExpandKeys.value = keys
         defaultCheckedKeys.value = [ids]
+        wbsIds.value = right.join(',')
         meterIds.value = ids
+        rightKeys.value = right
      
     } else {
         autoExpandKeys.value = []
         defaultCheckedKeys.value = []
+        rightKeys.value = []
+        wbsIds.value = ''
+        meterIds.value = ''
     }
 }, { immediate: true })
 
@@ -193,6 +211,7 @@ const sureClick = async (type)=>{
      window.$message.success(msg)
    if (type === 1) {
     linkModal.value = false
+    emit('save')
    }
     
     } else {
@@ -204,8 +223,7 @@ const sureClick = async (type)=>{
 const nodeElTreeClick = ()=>{
     
 }
-const meterIds = ref('')
-const wbsIds = ref('')
+
 const treeNodeCheck = (_, { checkedNodes }) => {
     console.log(checkedNodes, 'checkedNodes')
     let arr = []

+ 44 - 11
src/views/project/debit/contract/unit.vue

@@ -49,13 +49,13 @@
                     <HcTitle title="质检关联清单">
                         <template #extra>
                             <el-button hc-btn type="primary" @click="linkDataClick(2)">关联</el-button>
-                            <el-button hc-btn type="primary">批量取消</el-button>
+                            <el-button hc-btn type="primary" :loading="batchCancleload" @click="batchCancle">批量取消</el-button>
                         </template>
                     </HcTitle>
                     <div style="height: calc(50vh - 250px);">
                         <hc-table
                             :is-stripe="false" :column="qualtableColumn" :datas="qualtableData" :loading="tableLoading"
-                            is-new :index-style="{ width: 60 }" :row-style="tableRowStyle"
+                            is-new :index-style="{ width: 60 }" 
                             is-check @selection-change="tableSelectionChange"
                         >
                             <template #appStatusName="{ row }">
@@ -67,8 +67,8 @@
                                     {{ row.appStatusName }}
                                 </el-tag>
                             </template>
-                            <template #extra>
-                                <el-button hc-btn type="primary">取消关联</el-button>
+                            <template #action="{ row }">
+                                <el-button hc-btn type="primary" size="small" :loading="row?.load" @click="cancleLink(row)">取消关联</el-button>
                             </template>
                         </hc-table>
                     </div>
@@ -177,13 +177,13 @@
         </hc-new-dialog>
         <!-- 
         关联资料 -->
-        <linkData :link-modal="linkModal" :is-check-id="isCheckId" :check-ids="checkTreeId" @close="closeLink" @save="saveLink" />
+        <linkData :link-modal="linkModal" :is-check-id="isCheckId" :check-ids="checkTreeId" :right-tree-check="rightTreeCheck" @close="closeLink" @save="saveLink" />
     </div>
 </template>
 
 <script setup>
 import { nextTick, onMounted, ref } from 'vue'
-import { arrToId, getArrValue, getObjValue, getRandom } from 'js-fast-way'
+import { arrToId, arrToKey, getArrValue, getObjValue, getRandom } from 'js-fast-way'
 import infoTable from './components/unit/info-table.vue'
 import treeForm from './components/unit/tree-form.vue'
 import rowData from './components/unit/row-data.vue'
@@ -285,7 +285,8 @@ const isInfoView = ref(false)
 const checkTreeId = ref('')
 const checkTreeLevel = ref('')
 const treeNodeTap = ({ node, data, keys }) => {
-
+    treeClickdata.value = data
+  
     const { level } = node
     checkTreeLevel.value = level
     checkTreeId.value = data.id
@@ -298,6 +299,8 @@ const treeNodeTap = ({ node, data, keys }) => {
 }
 
 //获取节点详情
+//选中的节点数组
+const rightTreeCheck = ref([])
 const curTreeData = ref({})
 const getTreeNodeDetail = async ({ id }) => {
     const { error, code, data } = await unitApi.getNodeDetail({ id })
@@ -305,6 +308,7 @@ const getTreeNodeDetail = async ({ id }) => {
         curTreeData.value = getObjValue(data)
         tableData.value = curTreeData.value['decompositionList']
         qualtableData.value = curTreeData.value['linkNodeList']
+        rightTreeCheck.value = arrToKey(qualtableData.value, 'wbsTreeId', ',').split(',')
         nodeOptions.value.forEach((ele) => {
             if (curTreeData.value.nodeType === ele.dictKey) {
                 curTreeData.value.nodeTypeName = ele.dictValue
@@ -366,7 +370,7 @@ const treeMenuTap = ({ key, node, data, keys }) => {
     isInfoView.value = node.isLeaf
     menuType.value = key
     getTreeNodeDetail(data)
-    treeClickdata.value = data
+
     setStoreValue('wbsTreeExpandKeys', keys)
     TreeAutoExpandKeys.value = keys || []
     if (data?.isLock !== 1) {
@@ -464,15 +468,17 @@ const tableColumn = ref([
 const tableData = ref([])
 //质检关联清单
 const qualtableColumn = ref([
-    { key: 'part	', name: '分/子分项部位', align: 'center' },
+    { key: 'part', name: '分/子分项部位', align: 'center' },
     { key: 'appStatusName', name: '审核状态', align: 'center' },
     { key: 'action', name: '操作', align: 'center' },
  
 ])
 const qualtableData = ref([])
+const cancelKeys = ref('')
 //多选事件
 const tableSelectionChange = (rows) => {
     console.log(rows)
+    cancelKeys.value = arrToKey(rows, 'wbsTreeId', ',')
 }
 //设置某一行的样式
 const tableRowStyle = ({ row }) => {
@@ -653,15 +659,42 @@ const isCheckId = ref(1)
 const linkLoading = ref(false)
 const linkModal = ref(false)
 const linkDataClick = (type)=>{
-    console.log(type, 'type1111111')
     linkModal.value = true
     isCheckId.value = type
 }
 const closeLink = ()=>{
     linkModal.value = false
+    getTreeNodeDetail(treeClickdata.value)
 }
 const saveLink = ()=>{
     linkModal.value = false
-    getTreeNodeDetail(treeClickdata)
+    getTreeNodeDetail(treeClickdata.value)
+}
+const cancleLink = async (row)=>{
+    row.load = true
+    const { error, code, msg } = await unitApi.deleteLinkWbsTree({ ids:row.wbsTreeId })
+    row.load = false
+    //判断状态
+    if (!error && code === 200) {
+        window?.$message?.success(msg)
+        console.log(treeClickdata.value, '11111111')
+        getTreeNodeDetail(treeClickdata.value)
+    } else {
+         window.$message.error(msg)
+     }
+}
+const batchCancleload = ref(false)
+const batchCancle = async ()=>{
+    batchCancleload.value = true
+    const { error, code, msg } = await unitApi.deleteLinkWbsTree({ ids:cancelKeys.value })
+    batchCancleload.value = false
+    //判断状态
+    if (!error && code === 200) {
+        window?.$message?.success(msg)
+        console.log(treeClickdata.value, '11111111')
+        getTreeNodeDetail(treeClickdata.value)
+    } else {
+         window.$message.error(msg)
+     }
 }
 </script>