ZaiZai 1 年之前
父节点
当前提交
0b87340935
共有 2 个文件被更改,包括 96 次插入7 次删除
  1. 16 0
      src/api/modules/exctab/exceltab.js
  2. 80 7
      src/views/exctab/modules/add-excel.vue

+ 16 - 0
src/api/modules/exctab/exceltab.js

@@ -70,4 +70,20 @@ export default {
             params: form,
         })
     },
+    //wbs树获取表
+    async selectByNodeTable(form) {
+        return HcApi({
+            url: '/api/blade-manager/exceltab/selectByNodeTable',
+            method: 'get',
+            params: form,
+        })
+    },
+    //添加编辑清表
+    async savaDataInfo(form) {
+        return HcApi({
+            url: '/api/blade-manager/exceltab/sava-dataInfo',
+            method: 'post',
+            data: form,
+        })
+    },
 }

+ 80 - 7
src/views/exctab/modules/add-excel.vue

@@ -34,7 +34,7 @@
                 </el-col>
                 <el-col :span="12" class="h-full">
                     <div class="right-card h-full">
-                        <hc-table :column="tableColumn" :datas="tableData" :is-index="false">
+                        <hc-table :column="tableColumn" :datas="tableData" :is-index="false" :is-current-row="false">
                             <template #action="{ row }">
                                 <el-link v-if="row.isLinkTable !== 2" type="primary" @click="rowRelation(row)">关联</el-link>
                                 <el-link v-if="row.isLinkTable === 2" type="warning" @click="rowCancel(row)">取消关联</el-link>
@@ -52,10 +52,10 @@
 </template>
 
 <script setup>
-import { getArrValue, getObjValue } from 'js-fast-way'
 import { nextTick, ref, watch } from 'vue'
-import mainApi from '~api/exctab/exceltab'
 import { getDictionaryData } from '~uti/tools'
+import { formValidate, getArrValue, getObjValue, isNullES } from 'js-fast-way'
+import mainApi from '~api/exctab/exceltab'
 
 const props = defineProps({
     info: {
@@ -124,6 +124,7 @@ const isWbsTree = ref(false)
 const wbsModelChange = () => {
     isWbsTree.value = false
     tableData.value = []
+    tableList.value = []
     const wbsId = formModel.value.wbsId
     wbsModel.value.forEach(item => {
         if (item.id === wbsId) {
@@ -157,10 +158,40 @@ const wbsTreeLoad = async (node, resolve) => {
 }
 
 //树节点被点击
-const wbsTreeClick = (data) => {
-    console.log(data)
+const wbsForm = ref({})
+const wbsTreeClick = ({ id, type, nodeName }) => {
+    wbsForm.value = { id, wbsType: type, wbsName: nodeName }
+    const form = formModel.value
+    if (tableList.value.length <= 0) {
+        selectByNodeTable(id, type, form.id, form.wbsId)
+    } else {
+        let tag = true
+        tableList.value.forEach((item) => {
+            if (item.id === id) {
+                tableData.value = item.arrs
+                tag = false
+            }
+        })
+        if (tag) {
+            selectByNodeTable(id, type, form.id, form.wbsId)
+        }
+    }
 }
 
+//获取数据
+const selectByNodeTable = async (id, type, formId, wbsId) => {
+    const { data } = await mainApi.selectByNodeTable({
+        id,
+        wbsType: type ?? '',
+        liunxId: formId ?? '',
+        projectid: wbsId ?? '',
+    })
+    const res = getArrValue(data)
+    res.forEach(item => {
+        item.changeTable = item.isLinkTable
+    })
+    tableData.value = res
+}
 
 //基础表单
 const formRef = ref(null)
@@ -184,21 +215,63 @@ const tableColumn = [
     { key: 'action', name: '操作', width: 80, align: 'center' },
 ]
 const tableData = ref([])
-
+const tableList = ref([])
 
 //关联
 const rowRelation = (row) => {
-
+    row.isLinkTable = 2
+    setTableList()
 }
 
 //取消关联
 const rowCancel = (row) => {
+    row.isLinkTable = 1
+    setTableList()
+}
 
+//处理数据
+const setTableList = () => {
+    const form = wbsForm.value
+    let tap = tableList.value.find((item) => {
+        return item.id === form.id
+    })
+    if (!tap) {
+        tableList.value.push({
+            id: form.id,
+            wbsType: form.wbsType,
+            wbsName: form.wbsName,
+            arrs: tableData.value,
+        })
+    }
 }
 
 //提交
 const submitLoading = ref(false)
 const dialogSubmit = async () => {
+    const isValidate = await formValidate(formRef.value)
+    if (!isValidate) return false
+    submitLoading.value = true
+    let linkDataInfo = []
+    const list = tableList.value
+    if (list.length > 0) {
+        list.forEach(item => {
+            let linkIds = ''
+            item.arrs.forEach(data => {
+                if (data.isLinkTable !== data.changeTable) {
+                    linkIds = `${linkIds}${linkIds !== '' ? ',' : ''}${data.pkeyId}_${data.isLinkTable}`
+                }
+            })
+            if (!isNullES(linkIds)) {
+                linkDataInfo.push({
+                    id: item.id,
+                    linkIds: linkIds,
+                    wbsName: item.wbsName,
+                    wbsType: item.wbsType,
+                })
+            }
+        })
+    }
+    console.log(linkDataInfo)
     emit('finish')
 }