liyangzheng 1 年間 前
コミット
d159b5a022
1 ファイル変更98 行追加56 行削除
  1. 98 56
      src/pages/components/drawModal/LineDouble.vue

+ 98 - 56
src/pages/components/drawModal/LineDouble.vue

@@ -29,19 +29,19 @@
                     padding-bottom: 10px;
                     ">{{ endTxt }}</h1>
                     <div style="height: auto;">
-                        <!-- <div v-for="(item, index) in outList" :id="item.id">
+                        <div v-for="(item, index) in outList">
                             <el-checkbox-group v-model="checkList" @change="checkChange">
-                                <el-checkbox :label="item.id" :key="item.id">
+                                <el-checkbox :id="item.id" :label="item.id" :key="item.id">
                                     {{ item.fcda_name }}
                                 </el-checkbox>
                             </el-checkbox-group>
-                        </div> -->
-                        <div style="margin-bottom: 10px;" v-for="(item, index) in outList" :id="item.id" class="anthers">
+                        </div>
+                        <!-- <div style="margin-bottom: 10px;" v-for="(item, index) in outList" :id="item.id" class="anthers">
                             <el-radio-group v-if="item.from_ied_type==''" v-model="checkList" @change="checkChange">
                                 <el-radio :label="item.id" :key="item.id"> {{ item.fcda_name }}</el-radio>
                             </el-radio-group>
                             <span v-else >{{ item.fcda_name }}</span>
-                        </div>
+                        </div> -->
                     </div>
                 </div>
                 <div id="wrapper"></div>
@@ -135,6 +135,7 @@ export default {
         })
         // 初始化函数
         async function reload() {
+            pastLoading.value = true
             dialogVisible.value = props.ldModal
             modelIds.value = props.modelId
             starts.value = props.startTarget
@@ -150,17 +151,18 @@ export default {
                 in_or_out: "输出"
             }).then(res => {
                 if (res.code == 0) {
-                    let tmpList=[];
+                    let tmpList = [];
                     //对结果进行重排排序:将已关联到输出装置的端子排在前面
                     res.data.forEach((item, index) => {
-                        if(item.to_ied_type==ends.value.ied_type){
+                        if (item.to_ied_type == ends.value.ied_type) {
                             tmpList.unshift(item)
-                        }else{
+                        } else {
                             //未关联的端子按原结果顺序排列
                             tmpList.push(item)
                         }
                     })
                     curList.value = tmpList
+                    console.log(curList.value, 'cur');
                 } else {
                     ElMessage({
                         message: res.msg,
@@ -176,11 +178,11 @@ export default {
             }).then(res => {
                 if (res.code == 0) {
                     //对结果进行重排排序:将已关联到输出装置的端子排在前面
-                    let tmpList=[];
+                    let tmpList = [];
                     res.data.forEach((item, index) => {
-                        if(item.from_ied_type==starts.value.ied_type){
+                        if (item.from_ied_type == starts.value.ied_type) {
                             tmpList.unshift(item)
-                        }else{
+                        } else {
                             //未关联的端子按原结果顺序排列
                             tmpList.push(item)
                         }
@@ -207,6 +209,7 @@ export default {
                                     endPlugSize: 2
                                 }));
                                 hiddenLine();
+                                pastLoading.value = false
                             } else {
                                 console.error(`Element with ID ${line.start} or ${line.end} not found.`);
                             }
@@ -229,32 +232,32 @@ export default {
         }
         // 确认关闭模态框
         function sureClose() {
-            if (leftFcda.value == '') {
-                leftFcda.value = curList.value[0].id
-            }
-            flow.saveModelOn({
-                model_id: modelIds.value - 0,
-                from_ied_type: starts.value.ied_type,
-                to_ied_type: ends.value.ied_type,
-                from_fcda_id: leftFcda.value - 0,
-                to_fcda_ids: fcdaIds.value,
-                goosesv: setGooseOrSv.value,
-            }).then(res => {
-                if (res.code == 0) {
-                    ElMessage({
-                        type: "success",
-                        message: "关联成功!"
-                    })
-                    dialogVisible.value = false
-                    removeLine3()
-                    emit("lineBack", dialogVisible.value)
-                } else {
-                    ElMessage({
-                        type: "error",
-                        message: res.msg
-                    })
-                }
-            })
+            // if (leftFcda.value == '') {
+            //     leftFcda.value = curList.value[0].id
+            // }
+            // flow.saveModelOn({
+            //     model_id: modelIds.value - 0,
+            //     from_ied_type: starts.value.ied_type,
+            //     to_ied_type: ends.value.ied_type,
+            //     from_fcda_id: leftFcda.value - 0,
+            //     to_fcda_ids: fcdaIds.value,
+            //     goosesv: setGooseOrSv.value,
+            // }).then(res => {
+            //     if (res.code == 0) {
+            //         ElMessage({
+            //             type: "success",
+            //             message: "关联成功!"
+            //         })
+            dialogVisible.value = false
+            removeLine3()
+            //         emit("lineBack", dialogVisible.value)
+            //     } else {
+            //         ElMessage({
+            //             type: "error",
+            //             message: res.msg
+            //         })
+            //     }
+            // })
         }
         // 返回goose还是sv
         const setGooseOrSv = computed(() => {
@@ -287,15 +290,18 @@ export default {
             if (row && num) {
                 leftFcda.value = row.id
                 leftIndex.value = num
-                /*
                 flow.getModelOn({
                     model_id: modelIds.value - 0,
                     from_fcda_id: row.id - 0
                 }).then(res => {
                     if (res.data != null) {
                         together.value = res.data
-                        checkList.value = together.value[0].to_fcda_id
-                        fcdaIds.value = res.data[0].to_fcda_id
+                        checkList.value = together.value.map(item => {
+                            return item.to_fcda_id
+                        })
+                        fcdaIds.value = res.data.map(item => {
+                            return item.to_fcda_id
+                        }).join(",")
                         loading.value = false
                     } else {
                         together.value = []
@@ -303,28 +309,30 @@ export default {
                         loading.value = false
                     }
                 })
-                */
+
             } else {
                 if (curList.value.length > 0) {
                     leftFcda.value = curList.value[0].id
                     leftIndex.value = 0
-                    /*
                     flow.getModelOn({
                         model_id: modelIds.value - 0,
                         from_fcda_id: curList.value[0].id - 0
                     }).then(res => {
                         if (res.data != null) {
-                            console.log(res.data, '初始选择');
                             together.value = res.data
-                            checkList.value = together.value[0].to_fcda_id
-                            fcdaIds.value = res.data[0].to_fcda_id
+                            checkList.value = together.value.map(item => {
+                                return item.to_fcda_id
+                            })
+                            fcdaIds.value = res.data.map(item => {
+                                return item.to_fcda_id
+                            }).join(",")
                             loading.value = false
                         } else {
                             together.value = []
                             checkList.value = []
                             loading.value = false
                         }
-                    })*/
+                    })
                 } else {
                     ElMessage({
                         type: "info",
@@ -335,7 +343,43 @@ export default {
             }
         }
         function checkChange(e) {
-            fcdaIds.value = e
+            if (e.length > 1) {
+                fcdaIds.value = e[0]
+                ElMessage({
+                    message: "只能选择一个端子,已保存上一次选择的端子",
+                    type: "error"
+                })
+            } else {
+                fcdaIds.value = e.join(",")
+                if (leftFcda.value == '') {
+                    leftFcda.value = curList.value[0].id
+                }
+                flow.saveModelOn({
+                    model_id: modelIds.value - 0,
+                    from_ied_type: starts.value.ied_type,
+                    to_ied_type: ends.value.ied_type,
+                    from_fcda_id: leftFcda.value - 0,
+                    to_fcda_ids: fcdaIds.value,
+                    goosesv: setGooseOrSv.value,
+                }).then(res => {
+                    if (res.code == 0) {
+                        ElMessage({
+                            type: "success",
+                            message: "关联成功!"
+                        })
+                        reload()
+                        setIndex()
+                        removeLine3()
+                        emit("lineBack", dialogVisible.value)
+                    } else {
+                        ElMessage({
+                            type: "error",
+                            message: res.msg
+                        })
+                    }
+                })
+            }
+
         }
         //弹窗打开后使得线条在指定区域中
         function hiddenLine() {
@@ -362,9 +406,7 @@ export default {
         };
         onMounted(async () => {
             await reload()
-            pastLoading.value = true
             setIndex()
-            pastLoading.value = false
         })
         onBeforeUnmount(() => {
             leaderLineList.value.forEach(line => line.remove());//离开当前组件时清除连线
@@ -412,7 +454,7 @@ export default {
 <style scoped>
 .masBox {
     width: 100%;
-    /* height: calc(100vh - 400px); */
+    height: calc(100vh - 400px);
     /* border: 1px solid red; */
     display: flex;
     justify-content: space-around;
@@ -428,8 +470,8 @@ export default {
     background-color: #F7F8FB;
     border: 2px dashed #A3ADE0;
     position: absolute;
-    top:2%;
-    left:5%;
+    top: 2%;
+    left: 5%;
 }
 
 .middleBox {
@@ -439,8 +481,8 @@ export default {
     justify-content: space-around;
     align-items: center;
     position: absolute;
-    top:5%;
-    left:39%;
+    top: 5%;
+    left: 39%;
 }
 
 .rightBox {
@@ -450,8 +492,8 @@ export default {
     background-color: #EDF3FF;
     border: 2px dashed #A3ADE0;
     position: absolute;
-    top:2%;
-    right:5%;
+    top: 2%;
+    right: 5%;
 }
 
 .result {