8
0
Bläddra i källkod

关联清表修改

duy 2 veckor sedan
förälder
incheckning
72cbd46b49
2 ändrade filer med 130 tillägg och 95 borttagningar
  1. 16 1
      src/views/desk/test-collect.vue
  2. 114 94
      src/views/project/list/association-list.vue

+ 16 - 1
src/views/desk/test-collect.vue

@@ -7,7 +7,7 @@
             <template #action="{ row }">
                 <el-link type="primary" @click="editRowClick(row)">编辑</el-link>
                 <el-link type="warning" @click="partitioningClick(row)">配置划分</el-link>
-                <el-link type="success">关联清表</el-link>
+                <el-link type="success" @click="associationList(row)">关联清表</el-link>
                 <el-link type="info">数据映射配置</el-link>
                 <el-link type="danger" @click="delRowClick(row)">删除</el-link>
             </template>
@@ -30,6 +30,12 @@
         </hc-dialog>
         <!-- 配置划分 -->
         <HcPartitioning v-model="isPartitioningShow" :data="partitioningData" @close="partitioningClose" @finish="getTableData" />
+        <!-- 关联清表 -->
+        <HcAssociationList
+            v-model="isAssociationShow"
+            :info="associationInfo"
+            :type="3"
+        />
     </hc-card>
 </template>
 
@@ -39,6 +45,7 @@ import { deepClone, formValidate, getArrValue, isNullES } from 'js-fast-way'
 import { HcDelMsg } from 'hc-vue3-ui'
 import HcPartitioning from './test-collect/partitioning.vue'
 import mainApi from '~api/desk/test-collect'
+import HcAssociationList from '../project/list/association-list.vue'
 
 //激活
 onActivated(() => {
@@ -148,6 +155,14 @@ const partitioningClose = () => {
     isPartitioningShow.value = false
     partitioningData.value = {}
 }
+//关联清表
+const isAssociationShow = ref(false)
+const associationInfo = ref({})
+const associationList = async (item) => {
+    associationInfo.value = item
+    await nextTick()
+    isAssociationShow.value = true
+}
 </script>
 
 <style lang="scss">

+ 114 - 94
src/views/project/list/association-list.vue

@@ -59,16 +59,18 @@
                 type="primary"
                 :loading="submitLoading"
                 @click="dialogSubmit"
-                >提交</el-button
             >
+                提交
+            </el-button>
         </template>
     </hc-dialog>
 </template>
 
 <script setup>
-import { ref, watch } from "vue";
-import { deepClone, getArrValue, isNullES } from "js-fast-way";
-import excelApi from "~api/exctab/exceltab";
+import { ref, watch } from 'vue'
+import { deepClone, getArrValue, isNullES } from 'js-fast-way'
+import excelApi from '~api/exctab/exceltab'
+import testApi from '~api/desk/test-collect'
 
 const props = defineProps({
     info: {
@@ -77,177 +79,195 @@ const props = defineProps({
     },
     type: {
         type: [String, Number],
-        default: "", //默认没有,独立表单库类型为2
+        default: '', //默认没有,独立表单库类型为2,试验关联清表3
     },
-});
+})
 
 //事件
-const emit = defineEmits(["change", "close"]);
+const emit = defineEmits(['change', 'close'])
 
 //双向绑定
 // eslint-disable-next-line no-undef
-const isShow = defineModel("modelValue", {
+const isShow = defineModel('modelValue', {
     default: false,
-});
+})
 
 //监听数据
-const rows = ref(props.info);
-const type = ref(props.type);
+const rows = ref(props.info)
+const type = ref(props.type)
 
 watch(
     () => [props.info, props.type],
     ([info, tpe]) => {
-        rows.value = info;
-        type.value = tpe;
+        rows.value = info
+        type.value = tpe
     },
-    { deep: true }
-);
+    { deep: true },
+)
 
 //监听显示
 watch(isShow, (val) => {
     if (val) {
-        getDataInfo();
+        getDataInfo()
     } else {
-        emit("close");
+        emit('close')
     }
-});
+})
 
 //表单
-const formRef = ref(null);
-const formModel = ref({});
+const formRef = ref(null)
+const formModel = ref({})
 const getDataInfo = () => {
-    const form = deepClone(rows.value);
-    getExcelListData();
+    const form = deepClone(rows.value)
+    getExcelListData()
     formModel.value = {
         id: type.value === 2 ? form.primaryKeyId : form.pkeyId,
         ids: form.id,
-        excelId: type.value === 2 ? form.excelIds : form.excelId,
-        name: form.modeId,
+        excelId: type.value === 2 ? form.excelIds : type.value === 3 ? rows.value.excelId : form.excelId,
         initTableId: form.initTableId,
         initTableName: form.initTableName,
-    };
+    }
     setTimeout(() => {
-        const arr = formModel.value.excelId.split(",");
-        treeRef.value?.setCheckedKeys(arr);
-    }, 2000);
-};
+        const { excelId } = formModel.value
+        if (excelId) {
+            const arr = formModel.value.excelId.split(',')
+            treeRef.value?.setCheckedKeys(arr)
+        }
+       
+    }, 2000)
+}
 
 //获取清表列表
-const excelData = ref([]);
+const excelData = ref([])
 const getExcelListData = async () => {
     const { data } = await excelApi.getList({
         current: 1,
         size: 100000,
         parentId: 0,
-    });
-    excelData.value = getArrValue(data?.records);
-};
+    })
+    excelData.value = getArrValue(data?.records)
+}
 
 //清表列表被选择
 const nameChange = () => {
     if (!isNullES(formModel.value.name)) {
-        formModel.value.search = "";
-        getTabLazytreeAll();
+        formModel.value.search = ''
+        getTabLazytreeAll()
     }
-};
+}
 
 //清表树参数
-const treeRef = ref(null);
+const treeRef = ref(null)
 const tabTreeProps = {
-    label: "name",
-    children: "children",
-    disabled: "hasChildren",
+    label: 'name',
+    children: 'children',
+    disabled: 'hasChildren',
     isLeaf: function (data) {
-        let tag = false;
+        let tag = false
         if (!data.hasChildren) {
-            tag = true;
+            tag = true
         }
-        if (data.isExistForm == 1) {
-            tag = true;
+        if (Number(data.isExistForm) === 1) {
+            tag = true
         }
-        return tag;
+        return tag
     },
-};
+}
 
 //获取清表树
-const isLoading = ref(false);
-const tabTreeData = ref([]);
+const isLoading = ref(false)
+const tabTreeData = ref([])
 const getTabLazytreeAll = async () => {
-    const { name, search } = formModel.value;
-    isLoading.value = true;
+    const { name, search } = formModel.value
+    isLoading.value = true
     const { data } = await excelApi.tabLazyTreeAll({
         modeId: name,
         name: search,
-    });
-    tabTreeData.value = getArrValue(data);
-    isLoading.value = false;
-};
+    })
+    tabTreeData.value = getArrValue(data)
+    isLoading.value = false
+}
 
 //搜索筛选
 const filterNode = (value, data, node) => {
-    if (isNullES(value)) return true;
-    let _array = []; //这里使用数组存储 只是为了存储值。
-    getReturnNode2(node, _array, value);
-    let result = false;
+    if (isNullES(value)) return true
+    let _array = [] //这里使用数组存储 只是为了存储值。
+    getReturnNode2(node, _array, value)
+    let result = false
     _array.forEach((item) => {
-        result = result || item;
-    });
-    return result;
-};
+        result = result || item
+    })
+    return result
+}
 
 const getReturnNode2 = (node, _array, value) => {
-    let isPass =
-        node.data && node.data.name && node.data.name.indexOf(value) !== -1;
-    isPass ? _array.push(isPass) : "";
+    let isPass
+        = node.data && node.data.name && node.data.name.indexOf(value) !== -1
+    isPass ? _array.push(isPass) : ''
     if (!isPass && node.level !== 1 && node.parent) {
-        getReturnNode2(node.parent, _array, value);
+        getReturnNode2(node.parent, _array, value)
     }
-};
+}
 
 const checkChange = (data) => {
     //节点选中回调
     if (treeRef.value?.getCheckedNodes().length === 0) {
-        treeRef.value?.setCheckedKeys([]);
+        treeRef.value?.setCheckedKeys([])
     } else if (treeRef.value?.getCheckedNodes().length >= 1) {
-        treeRef.value?.setCheckedKeys([data.id]);
+        treeRef.value?.setCheckedKeys([data.id])
     }
-};
+}
 
 //提交表单
-const submitLoading = ref(false);
+const submitLoading = ref(false)
 const dialogSubmit = async () => {
-    let checkNodes = treeRef.value?.getCheckedNodes();
+    let checkNodes = treeRef.value?.getCheckedNodes()
     if (checkNodes.length <= 0) {
-        window?.$message?.warning("请先设置清表");
-        return;
+        window?.$message?.warning('请先设置清表')
+        return
     }
-    let node = checkNodes[checkNodes.length - 1];
+    let node = checkNodes[checkNodes.length - 1]
     if (Number(node.fileType) !== 3) {
-        window?.$message?.warning("请先上传Excel表");
-        return;
+        window?.$message?.warning('请先上传Excel表')
+        return
     }
-    submitLoading.value = true;
-    const { isRes } = await excelApi.saveLinkTab({
+    submitLoading.value = true
+    if (type.value === 3) {
+        const { isRes } = await testApi.relevancy({
+            excelId: node.id,
+            classId: rows.value.id,
+        })
+        
+        submitLoading.value = false
+        if (!isRes) return
+        dialogClose()
+        window?.$message?.success('关联清表成功')
+        emit('change')
+    } else {
+        const { isRes } = await excelApi.saveLinkTab({
         exceTabId: node.id,
         tabId: formModel.value.id,
-    });
-    submitLoading.value = false;
-    if (!isRes) return;
-    dialogClose();
-    window?.$message?.success("关联清表成功");
-    emit("change");
-};
+         })
+        submitLoading.value = false
+        if (!isRes) return
+        dialogClose()
+        window?.$message?.success('关联清表成功')
+        emit('change')
+    
+    }
+
+}
 
 //关闭弹窗
 const dialogClose = () => {
-    formModel.value.name = "";
-    formModel.value.search = "";
-    formModel.value.id = "";
-    tabTreeData.value = [];
-    treeRef.value?.setCheckedKeys([]);
-    isShow.value = false;
-    emit("close");
-};
+    formModel.value.name = ''
+    formModel.value.search = ''
+    formModel.value.id = ''
+    tabTreeData.value = []
+    treeRef.value?.setCheckedKeys([])
+    isShow.value = false
+    emit('close')
+}
 </script>
 
 <style lang="scss">