duy 2 сар өмнө
parent
commit
caf8d29a99

+ 119 - 35
src/views/codeRule/ruleManage.vue

@@ -223,7 +223,7 @@
                                       {{ item1.name }}
                                     </div>
                                     <div class="operation-icons">
-                                      <i class="el-icon-edit" @click.stop="handleEdit(item, index)"></i>
+                                      <i class="el-icon-edit" @click.stop="handleEditJs1(item, index)"></i>
                                       <i class="el-icon-delete" @click.stop="handleDelete(index)"></i>
                                     </div>
                                 </div>
@@ -244,7 +244,7 @@
                     <span  @click="showYpList">退出</span>
                 </div>
                 <div class="add-yp-title">
-                  <span>新增</span>
+                  <span>{{ isEditYp?'编辑':'新增' }}</span>
                 </div>
                 <div class="add-yp-detail">
                   <el-form label-position="left" label-width="80px" :model="ypDetail"  :rules="ypRuleForm" ref="ypFormRef">
@@ -269,30 +269,32 @@
             </el-card>
             <el-card v-if="isShowJsList&&!isShowYpList">
               <div slot="header" class="clearfix" >
-                    <i class="el-icon-arrow-left" style="margin-right: 5px; cursor: pointer;"  @click="showYpList"></i>
-                    <span  @click="showYpList">退出</span>
+                    <el-link type="primary"  @click="showYpList">
+                      <i class="el-icon-arrow-left" style="margin-right: 5px; cursor: pointer;" ></i>
+                      <span >退出</span>
+                    </el-link>
                 </div>
                 <div class="add-yp-title">
-                  <span>新增</span>
-                  <div>
+                  <span>{{ isEditJs?'编辑':'新增' }}</span>
+                  <div v-if="isEditJs">
                      <el-button  size="small" style="background: rgb(168, 86, 248);color: white;" icon="el-icon-office-building" @click="conditionsSet">条件设置</el-button>
                          <el-button  size="small" style="background:rgb(37, 80, 162);;color: white;" icon="el-icon-connection" @click="linkEle">关联元素</el-button>
                   </div>
                 </div>
                 <div class="add-yp-detail">
-                  <el-form label-position="left" label-width="80px" :model="jsDetail"  :rules="jsRuleForm">
+                  <el-form label-position="left" label-width="80px" :model="jsDetail"  :rules="jsRuleForm" ref="jsFormRef">
                     <el-form-item label="检测项" prop="name">
                       <el-input v-model="jsDetail.name"></el-input>
                     </el-form-item>
                     <el-form-item label="技术指标">
                       <div class="input-with-icon"  v-for="(item, index) in jsDetail.info" :key="index">
                         <el-input placeholder="请输入内容" v-model="item.name" class="input-with-select">
-                          <el-select v-model="item.select" slot="prepend" placeholder="请选择符号" style="width: 150px;">
-                            <el-option  v-for="(item1,index) in fqOptions" :key="index" :label="item1.label" :value="item1.value"></el-option>
+                          <el-select v-model="item.symbol" slot="prepend" placeholder="请选择符号" style="width: 150px;">
+                            <el-option  v-for="(item1,index) in fqOptions" :key="index" :label="item1.dictKey" :value="item1.dictKey"></el-option>
                           </el-select>
                           
                         </el-input>
-                        <i class="el-icon-circle-plus-outline" @click="addBasicInfo1"  ></i>
+                        <i class="el-icon-circle-plus-outline" @click="addBasicInfo1(index)"  ></i>
                         <i class="el-icon-remove-outline" @click="removeBasicInfo1(index)" v-if="index!==0"></i>
                       </div>
                     </el-form-item>
@@ -300,7 +302,7 @@
                   </el-form>
                 </div>
                 <div class="add-yp-footer">
-                   <el-button type="primary">保存</el-button>
+                   <el-button type="primary" @click="addJsForm" :loading="addJsFormLoad">保存</el-button>
                 </div>
             </el-card>
               
@@ -411,7 +413,7 @@ import LinkEle from "./LinkEle.vue";
 import PreviewResult from './PreviewResult.vue'
 import {getPage,edit,add,deleteItem,getById, addInfo,editInfo,getInfoPage } from "@/api/ruleManage/fileRule.js";
 import { getStore, setStore } from "@/util/store";
-
+ import { getDictionary } from "@/api/system/dict";
   export default {
   components: {
     ConditionsSet,
@@ -494,22 +496,19 @@ import { getStore, setStore } from "@/util/store";
         ],
         isShowJsList:false,
         isEditYp: false,
+        isEditJs: false,
+
         jsDetail: {
           name: '',
-          info: [{ name: '',select:[] }, ]
+          info: [{ name: '',symbol:'' }, ]
         },
+        addJsFormLoad: false,
         jsRuleForm: {
           name: [
             { required: true, message: '请输入技术指标名称', trigger: 'blur' }
           ],
         },
         fqOptions: [
-          { label: '>', value: '>', },
-          { label: '=', value: '=', },
-          { label: '<', value: '<' },
-          { label: '>=', value: '>=' },
-          { label: '<=', value: '<=' },
-          { label: '!=', value: '!=' },
         ],
         conditionsSetVisible:false//条件设置弹窗是否显示
 
@@ -518,7 +517,7 @@ import { getStore, setStore } from "@/util/store";
     },
 
     created(){
-        console.log(this.$route.query,'this.$route.query;');
+        this.getFqOptions()
         const { id, tenant_id,projectid} = this.$route.query;
         this.id = id;
         this.parentId = 0;
@@ -532,6 +531,14 @@ import { getStore, setStore } from "@/util/store";
         } 
     },
     methods: {
+      //获取符号字典
+      getFqOptions(){
+            getDictionary({
+                    code: "u_standard_symbol",
+                }).then((res) => {
+                    this.fqOptions = res.data.data;
+                });
+      },
       //获取规范文件夹数据
       getRuleItemOptions() {
         this.ruleLoading = true;
@@ -541,8 +548,6 @@ import { getStore, setStore } from "@/util/store";
           size:this.pageSize,
           type: 1,
         }).then((res) => {
-          console.log(res,'res');
-          
            this.ruleLoading = false;
           if (res.data.code === 200) {
             this.ruleItemOptions = res.data.data.records;
@@ -693,19 +698,30 @@ import { getStore, setStore } from "@/util/store";
             });
          },
          //获取规范数据详情
-         getRuleDataDetail1(item){
+         getRuleDataDetail1(item,type){
              getInfoPage({
                 current:1,
                 size:100,
-                type: 1, 
+                type, 
                 standardId: item.id,
               }).then((res) => {
                 this.ruleLoading = false;
                 if (res.data.code === 200) {
                   console.log(res.data.data.records,'res.data.data.records');
-                  this.ypList = res.data.data.records;
+                  // 
+                  if(type===1){
+                    this.ypList = res.data.data.records;
+                  }else if(type===2){
+                    this.jsList = res.data.data.records;
+                  }else{
+                     const records = res.data.data.records;
+                     // 根据 type 分类数据
+                    this.ypList = records.filter(record => record.type === 1);
+                    this.jsList = records.filter(record => record.type === 2);
+                  }
                 } else {
                  this.ypList = [];
+                    this.jsList = [];
                   this.$message.error(res.data.msg);
                 }
               });
@@ -784,6 +800,7 @@ import { getStore, setStore } from "@/util/store";
         };
 
 
+
       },
       showYpList() {
         this.isShowYpList = true;
@@ -804,6 +821,9 @@ import { getStore, setStore } from "@/util/store";
           return;
         }
         this.saveYpLoad = true;
+        this.ypDetail.info.forEach((item)=>{
+          item.type=1
+        })
         if(!this.isEditYp){
                addInfo({
           ...this.ypDetail,
@@ -814,7 +834,7 @@ import { getStore, setStore } from "@/util/store";
             if(res.data.code==200){
                 this.$message.success(res.data.msg)
                  this.getRuleDataDetail(this.ruleItemDetail);
-                  this.getRuleDataDetail1(this.ruleItemDetail);
+                  this.getRuleDataDetail1(this.ruleItemDetail,1);
                  this.isShowYpList= true;
                  this.isShowJsList=true
             }else{
@@ -833,7 +853,7 @@ import { getStore, setStore } from "@/util/store";
                     if(res.data.code==200){
                         this.$message.success(res.data.msg)
                         this.getRuleDataDetail(this.ruleItemDetail);
-                          this.getRuleDataDetail1(this.ruleItemDetail);
+                          this.getRuleDataDetail1(this.ruleItemDetail,1);
                         this.isShowYpList= true;
                         this.isShowJsList=true
                     }else{
@@ -935,13 +955,77 @@ import { getStore, setStore } from "@/util/store";
       },
       //新增技术指标
       addJs(){
-      
-         this.isShowJsList = true;
+        this.isShowJsList = true;
          this.isShowYpList = false;
+        this.isEditJs = false;
+        this.jsDetail = {
+          name: '',
+          info: [{ name: '',select:'' }]
+        };
         
       },
-      addBasicInfo1() {
-        this.jsDetail.basic.push({ name: '' });
+      handleEditJs1(item, index) {
+        // 处理编辑逻辑
+        this.jsDetail = JSON.parse(JSON.stringify(item));
+        this.isEditJs = true;
+          this.isShowJsList = true;
+         this.isShowYpList = false;
+      },
+      addBasicInfo1(index) {
+       this.jsDetail.info.splice(index + 1, 0, { name: '', select: '' });
+      },
+      addJsForm() {
+        const isValid = this.$refs.jsFormRef.validate();
+        if (!isValid) {
+          this.$message.error('请填写完整的技术指标信息');
+          return;
+        }
+        this.addJsFormLoad = true;
+        this.jsDetail.info.forEach((item)=>{
+          item.type=2
+        })
+        if(!this.isEditJs){
+             addInfo({
+          ...this.jsDetail,
+          type: 2,
+          standardId: this.ruleItemDetail.id,
+        }).then((res) => {
+          if(res.data.code==200){
+              this.$message.success(res.data.msg)
+              this.getRuleDataDetail(this.ruleItemDetail);
+              this.getRuleDataDetail1(this.ruleItemDetail,2);
+              this.isShowYpList= true;
+              this.isShowJsList=false
+               
+          }else{
+              this.$message.error(res.data.msg)
+          }
+          }).finally(() => {
+              this.addJsFormLoad = false;
+          });
+        }else{
+           editInfo({
+          ...this.jsDetail,
+          type: 2,
+          standardId: this.ruleItemDetail.id,
+        }).then((res) => {
+          if(res.data.code==200){
+              this.$message.success(res.data.msg)
+              this.getRuleDataDetail(this.ruleItemDetail);
+              this.getRuleDataDetail1(this.ruleItemDetail,2);
+              this.isShowYpList= true;
+              this.isShowJsList=false
+               
+          }else{
+              this.$message.error(res.data.msg)
+          }
+          }).finally(() => {
+              this.addJsFormLoad = false;
+          });
+        }
+          //新增技术指标
+          
+       
       },
     
     // 删除基础信息行
@@ -950,11 +1034,11 @@ import { getStore, setStore } from "@/util/store";
     },
     //条件设置
     conditionsSet(){
-      if(this.jsDetail.basic[0].name === ''|| this.jsDetail.basic[0].select.length === 0) {
+      if(this.jsDetail.info[0].name === '') {
         this.$message.error('请先添加技术指标内容');
         return;
       }
-      this.$refs.conditionsSetRef.show(this.jsDetail.basic)
+      this.$refs.conditionsSetRef.show(this.jsDetail.info)
 
     },
     // 添加确认取消处理方法
@@ -966,11 +1050,11 @@ import { getStore, setStore } from "@/util/store";
     },
     //关联元素
     linkEle() {
-      if(this.jsDetail.basic[0].name === ''|| this.jsDetail.basic[0].select.length === 0) {
+      if(this.jsDetail.info[0].name === '') {
         this.$message.error('请先添加技术指标内容');
         return;
       }
-        this.$refs.linkEleRef.show(this.jsDetail.basic, this.treeId,this.id,  this.projectid);
+        this.$refs.linkEleRef.show(this.jsDetail.info, this.treeId,this.id,  this.projectid);
     },
     confirmLinkEle() {
       console.log('确认关联元素')