Jelajahi Sumber

表单验证

zhouna 4 tahun lalu
induk
melakukan
03ec1f55d2

+ 8 - 1
src/api/utils.js

@@ -438,5 +438,12 @@ export default {
   getCurrentPage(currentChange, total, pageSize) {
     const currentPage =  currentChange > Math.ceil(total/pageSize) ? Math.ceil(total/pageSize) : currentChange
     return currentPage;
-  }
+  },
+  formatObj(data,key){
+        let obj={};
+        data.map((it)=>{
+            obj[it[key]]=it.subMenuList;
+        });
+        return obj;
+    },
 }

+ 15 - 0
src/api/zskDiagBase.js

@@ -6,8 +6,14 @@ const urls = {
     'zskStrDiagBase':'/api/cdssman/klDiagnose/startDiagnose',
     'zskStopDiagBase':'/api/cdssman/klDiagnose/disableDiagnose',
     'zskDiagBaseDetail':'/api/cdssman/klDiagnose/getByIdDiagnoseAll',
+    'zskTypeList':'/api/cdssman/klRulePlan/getMenu',//类型列表
+    'searchDiag':'/api/cdssman/klDiagnose/findDiaName',
+    'zskSearchConcept':'/api/cdssman/klDisease/searchConcept',//知识库搜索术语
 };
 export default {
+    getTypesList(param){
+        return axios.post(urls.zskTypeList,param);
+    },
     diagBasePage(param){
         return axios.post(urls.zskDiagBase, param)
     },
@@ -17,4 +23,13 @@ export default {
     diagBaseGetDetail(param){ //诊断依据--获取详情
         return axios.post(urls.zskDiagBaseDetail, param)
     },
+    saveDiagBase(param){
+        return axios.post(urls.zskAddDiagBase, param)
+    },
+    searchDiag(param){
+        return axios.post(urls.searchDiag, param)
+    },
+    searchConcept(param){
+        return axios.post(urls.zskSearchConcept,param);
+    },
 }

+ 109 - 226
src/components/knowledgeExtra/AddDiagBase.vue

@@ -3,24 +3,28 @@
         <crumbs :title="title" :param="$route.params" linkTo="ZskDiagBase"></crumbs>
         <div class="contents">
             <div class="content">
-                <el-form ref="form" :label-position="labelPosition" class="add-new-form" label-width="130px" :model="form" :rules="rules">
-                    <el-form-item label="疾病名称:" prop="conceptName">
-                        <el-input v-model.trim = "form.conceptName"></el-input>
+                <el-form ref="form" :label-position="labelPosition" class="add-new-form" label-width="150px" :model="form" :rules="rules">
+                    <el-form-item label="疾病名称:" prop="conceptId">
+                        <el-select clearable remote filterable :remote-method="searchDiag" v-model.trim="form.conceptId">
+                            <el-option
+                                    v-for="item in conceptList"
+                                    :key="item.conceptId"
+                                    :label="item.conceptName"
+                                    :value="item.conceptId">
+                            </el-option>
+                        </el-select>
                     </el-form-item>
                     <el-form-item label="诊断依据描述:" prop="description" class="description">
                         <el-input type="textarea" :rows="3" placeholder="请输入诊断依据描述" v-model.trim="form.description"></el-input>
                     </el-form-item>
                     <el-form-item label="诊断依据内容:" prop="remind" class="discDesc is-required">
-                        <DiagBaseType v-for="(group,i) in subGroups"
+                        <DiagBaseType v-for="(group,i) in form.klDiagnoseTypeVO"
                                        ref="groups"
                                        :data="group"
-                                       :baseTypes="baseTypeList"
                                        :inx="i"
-                                       :maxNum="subRuleMaxNum"
-                                       :firstPlace="firstPlace"
-                                       :isLast="subGroups.length===1"
-                                       @addGroup="addGroup"
-                                       @delGroup="delGroup"></DiagBaseType>
+                                       :isLast="form.klDiagnoseTypeVO.length===1"
+                                       @addDiag="addDiag"
+                                       @delDiag="delDiag"></DiagBaseType>
                     </el-form-item>
                     <el-button class="disclButn" size="small" type="primary" @click="confirm">保存</el-button>
                 </el-form>
@@ -29,54 +33,46 @@
     </div>
 </template>
 <script type="text/javascript">
-    import api from '@api/knowledgeLib.js';
+    import api from '@api/zskDiagBase.js';
     import DiagBaseType from './DiagBaseType'
     export default {
         name:'AddZskDiagBase',
         data(){
             return{
                 labelPosition:'left',
-                isFirst:true,
                 isCopy:false,
-                dict:'',        //规则内容固定的类型
-                msgDict:'',     //显示附加信息的类型
                 title:'诊断依据维护-添加诊断依据',
-                ruleTermTypeList:[],
-                ruleTypeList:[],
-                conceptList:[],
-                baseTypeList:[],
                 conceptName:'',
-                subRuleMaxNum:null,     //规则内容中规则的限制个数
-                firstPlace:null,
-                subGroups:[[{
-                    subDescription:'',
-                    parRuleType:'',
-                    subConceptId:'',
-                    subType:'',
-                    subMaxOperator:'',
-                    subMaxUnit:'',
-                    subMaxValue:'',
-                    subMinOperator:'',
-                    subMinUnit:'',
-                    subMinValue:'',
-                    subEqValue:'',
-                    subLenCode:'',
-                    dataType:'',
-                }]],
+                conceptList:[],
                 form:{
-                    parDescription:'',
-                    parRuleType:'',
-                    parConceptId:'',
-                    parlibName:'',
-                    parLenName:'',
-                    parHasSub:undefined,
-                    parLenCode:'',
-                    parMsg:'',
-                    klRuleInfoSaveSub:[],
+                    description:'',
+                    conceptId:'',
+                    klDiagnoseTypeVO:[{conditionType:'',groupVO:[{
+                            "baseGroup": '',
+                            "conditionGroup": '',
+                            "fitNo": '',
+                            "klDiagnoseDetail": [{
+                                "basConceptId": '',
+                                "basDescription": "",
+                                "basLename": "",
+                                "basLibName": "",
+                                "basLibType":null,
+                                "basType": '',
+                                "eqOperator": "",
+                                "eqUnit": "",
+                                "eqValue": "",
+                                "maxOperator": "",
+                                "maxUnit": "",
+                                "maxVal": "",
+                                "minOperator": "",
+                                "minUnit": "",
+                                "minVal": ""
+                            }]
+                        }]}],
                 },
-                parId:null,
+                id:null,
                 rules:{
-                    conceptName:[{ required: true, message: '请输入疾病名称',trigger: ['blur'] }],
+                    conceptId:[{ required: true, message: '请输入疾病名称',trigger: ['blur'] }],
                     description:[{ required: true, message: '请输入诊断依据描述',trigger: ['blur'] },{
                         validator: (rule,value,callback)=>{
                             if(value.length>100){
@@ -89,103 +85,59 @@
             }
         },
         created(){
-            this.getTypeList();
-            this.setDict();
             const param = this.$route.params;
             let info = param.data;
             if(info){
-                this.parId = info.parId;
+                this.id = info.id;
                 this.isCopy=param.copy;
                 this.title = "诊断依据维护-"+(this.isCopy?'复制':'修改')+"诊断依据";
                 this.form=Object.assign({},this.form,info);
-                this.conceptList=[{conceptName:this.form.parlibName,conceptId:this.form.parConceptId}];
-                this.subGroups=this.formatGroupDatas(info.klRuleByIdSub);
+                //this.DiagGroups=this.formatGroupDatas(info.klRuleByIdSub);
 
             }
+            this.setRules()
         },
         watch:{
-            'form.parRuleType':function(val){
-                const obj = this.ruleTypeList.find((it)=>it.id===val);
-                this.ruleTermTypeList = obj.subMenuList;
-            },
-            'form.parLenCode':function(val){
-                if(!val){
-                    this.baseTypeList = [];
-                    return ;
-                }
-                const obj = this.ruleTermTypeList.find((it)=>it.code===val);
-                this.baseTypeList = obj.subMenuList;
-                this.subRuleMaxNum=obj.number;
-            },
-            'form.parConceptId':function(val){
-                if(val&&this.checkFirstPlace&&this.conceptList) {
-                    this.firstPlace = this.conceptList.find((it) => it.conceptId === val);
-                    this.firstPlace['checkedType']=this.ruleTermCodeStr;
-                }else if(!val){
-                    this.setInitGroupData();
-                    this.firstPlace =null;
-                }else{
-                    this.firstPlace =null;
-                }
-            }
         },
         components:{
             DiagBaseType
         },
         computed:{
-            ruleTermCodeStr:function(){
-                return this.form.parRuleType+"-"+this.form.parLenCode
-            },
-            checkFirstPlace:function(){
-                return this.dict.indexOf(this.ruleTermCodeStr)>-1;
-            },
-            showMsg:function(){
-                return this.ruleTermCodeStr.length>1&&this.msgDict.indexOf(this.ruleTermCodeStr)>-1;
-            },
-            showHasSub:function(){
-                return this.subDict.indexOf(this.ruleTermCodeStr)>-1;
-            }
+
         },
         methods:{
-            hasSubChange(val){
-                if(val){
-                    this.setInitGroupData();
+            setRules(){
+                let that=this;
+                let list=this.form.klDiagnoseTypeVO;
+                if(list&&list.length>0){
+                    list.forEach((item,i)=>{
+                        let list1=list[i].groupVO;
+                        that.rules['klDiagnoseTypeVO.'+i+'.conditionType']=[{required: true, message: '请选择诊断依据类型',trigger: ['change'] }];
+                        list1.forEach((it,x)=>{
+                            that.rules['klDiagnoseTypeVO.'+i+'.groupVO.'+x+'.fitNo']=[{required: true, message: '请选择符合条件的数量',trigger: ['change'] }];
+                            let list2=list1[x].klDiagnoseDetail;
+                            list2.forEach((t,j)=>{
+                                that.rules['klDiagnoseTypeVO.'+i+'.groupVO.'+x+'.klDiagnoseDetail.'+j+'.basDescription']=[{required: true, message: '请输入基础依据名称',trigger: ['blur'] }];
+                                that.rules['klDiagnoseTypeVO.'+i+'.groupVO.'+x+'.klDiagnoseDetail.'+j+'.basType']=[{ required: true, message: '请选择基础依据类型',trigger: ['change'] }];
+                                that.rules['klDiagnoseTypeVO.'+i+'.groupVO.'+x+'.klDiagnoseDetail.'+j+'.basLibType']=[{ required: true, message: '请选择基础依据术语类型',trigger: ['change'] }];
+                                that.rules['klDiagnoseTypeVO.'+i+'.groupVO.'+x+'.klDiagnoseDetail.'+j+'.basConceptId']=[{ required: true, message: '请输入医学标准术语',trigger: ['blur'] }];
+                                that.rules['klDiagnoseTypeVO.'+i+'.groupVO.'+x+'.klDiagnoseDetail.'+j+'.dataType']=[{ required: true, message: '请选择类型',trigger: ['change'] }];
+
+                            });
+                        });
+                    })
                 }
-            },
-            setDict(){
-                this.dict = localStorage.getItem("zskDicts");
-                this.msgDict = localStorage.getItem("zskMsgDict");
-                this.subDict = localStorage.getItem("zskSubDict");
-            },
-            showConfirmDialog(msg,resolve){
-                this.$alert(msg, '提示', {
-                    confirmButtonText: '确定',
-                    type: 'warning'
-                }).then(() => {
-                    resolve();
-                }).catch(() => {});
+                console.log(this.rules)
             },
             formatGroupDatas(data){
                 let arr=[];
-                data.map((it)=>{
-                    if(!arr[it.groupType]){arr[it.groupType]=[];}
-                    if(it.subMaxOperator||it.subMinOperator){
-                        it.dataType='1';
-                    }else if(it.subEqValue){
-                        it.dataType='2';
-                    }
-                    arr[it.groupType].push(it);
-                });
-                arr = arr.filter((it)=>{if(it)return it});
                 return arr;
             },
-            searchConcept(val){
+            searchDiag(val){
                 const param = {
-                    excludedConceptIds:[this.form.parRuleType],
-                    libType:this.form.parLenCode,
-                    name:val,
+                    diseaseName:val,
                 };
-                api.searchConcept(param).then((res) => {
+                api.searchDiag(param).then((res) => {
                     if (res.data.code == '0') {
                         const data = res.data.data;
                         this.conceptList = data;
@@ -194,93 +146,49 @@
                     console.log(error);
                 });
             },
-            ruleTypeChange(val){       //规则类型选中
-                this.form.parRuleType=val;
-                this.form.parLenCode='';
-                const obj = this.ruleTypeList.find((it)=>it.id===val);//console.log(val)
-                this.ruleTermTypeList = obj.subMenuList;
-                this.setInitGroupData();
-            },
-            ruleTermChange(val){        //规则术语类型选中
-                this.form.parLenCode=val;
-                const obj = this.ruleTermTypeList.find((it)=>it.code===val);
-                this.form.parLenName=obj.name;
-                this.baseTypeList = obj.subMenuList;
-                this.subRuleMaxNum = obj.number;
-                this.setInitGroupData();
-                this.form.parHasSub=obj.subMenuList.length?1:0;
-            },
-            getTypeList(){
-                const typeListData = JSON.parse(localStorage.getItem("zskTypesList"));
-                this.ruleTypeList = typeListData;
+            getInitData(){
+                return {conditionType:'',groupVO:[{
+                        "baseGroup": '',
+                        "conditionGroup": '',
+                        "fitNo": '',
+                        "klDiagnoseDetail": [{
+                            "basConceptId": '',
+                            "basDescription": "",
+                            "basLename": "",
+                            "basLibName": "",
+                            "basLibType": null,
+                            "basType": '',
+                            "eqOperator": "",
+                            "eqUnit": "",
+                            "eqValue": "",
+                            "maxOperator": "",
+                            "maxUnit": "",
+                            "maxVal": "",
+                            "minOperator": "",
+                            "minUnit": "",
+                            "minVal": ""
+                        }]
+                    }]}
             },
             setInitGroupData(){
-                this.subGroups = [[{
-                    subDescription:'',
-                    parRuleType:'',
-                    subConceptId:'',
-                    subType:'',
-                    subMaxOperator:'',
-                    subMaxUnit:'',
-                    subMaxValue:'',
-                    subMinOperator:'',
-                    subMinUnit:'',
-                    subMinValue:'',
-                    subEqValue:'',
-                    subLenCode:'',
-                    dataType:'',
-                }]];
-                this.form.parConceptId='';//医学标准术语清空
-                this.conceptList=[];  //下拉列表清空
+                let temp = this.getInitData();
+                this.form.klDiagnoseTypeVO = [temp];
             },
-            addGroup(){
-                let temp = {
-                    subDescription:'',
-                    subConceptId:'',
-                    subType:'',
-                    subLenCode:'',
-                    dataType:'',
-                    subMaxOperator:'',
-                    subMaxUnit:'',
-                    subMaxValue:'',
-                    subMinOperator:'',
-                    subMinUnit:'',
-                    subMinValue:'',
-                    subEqValue:'',
-                };
-                if(this.checkFirstPlace){
-                    const obj=this.subGroups[0][0];
-                    temp = {
-                        subDescription:obj.subConceptName,
-                        subConceptId:obj.subConceptId,
-                        subConceptName:obj.subConceptName,
-                        subLenCode:this.form.parLenCode,
-                        subLenName: this.form.parLenName,
-                        subLibName: this.form.parlibName,
-                        subType:obj.subType,
-                        dataType:'',
-                        subMaxOperator:'',
-                        subMaxUnit:'',
-                        subMaxValue:'',
-                        subMinOperator:'',
-                        subMinUnit:'',
-                        subMinValue:'',
-                        subEqValue:'',
-                    };
-                }
-                this.subGroups.push([temp]);
+            addDiag(){
+                let temp = this.getInitData();
+                this.form.klDiagnoseTypeVO.push(temp);
             },
-            delGroup(i){
-                this.subGroups.splice(i,1);
+            delDiag(i){
+                this.form.klDiagnoseTypeVO.splice(i,1);
             },
-            saveRule(params){
-                api.saveRule(params).then((res)=>{
+            saveDiagBase(params){
+                api.saveDiagBase(params).then((res)=>{
                     if(res.data.code==0){
                         this.$message({
                             message:"操作成功",
                             type:'success'
                         });
-                        this.$router.push({name: 'ZskRuleManager'});
+                        this.$router.push({name: 'ZskDiagBase'});
                     }else{
                         this.$message({
                             message:res.data.msg,
@@ -291,35 +199,15 @@
             },
             formatGroups(){
                 let obj = [];
-                this.subGroups.map((item,i)=>{
-                    item.map((it)=>{
-                        obj.push({...it,groupType:i});
-                    })
-                });
+                /*this.form.klDiagnoseTypeVO.map((item,i)=>{
+
+                });*/
                 return obj
             },
             validateForms(callBack){
                 this.$refs['form'].validate((valid) => {
                     if (valid) {
-                        const groupsRef = this.$refs['groups'];
-                        if(!groupsRef||groupsRef.length===0){
-                            callBack();
-                            return;
-                        }
-                        let groupRef=null,goOn=true;
-                        for(let i=0;i<groupsRef.length;i++){
-                            groupRef=groupsRef[i].$refs['group'];
-                            for(let j=0;j<groupRef.length;j++){
-                                groupRef[j].$refs['groupData'].validate((valid)=>{
-                                    if(!valid){
-                                        goOn=false;
-                                    }
-                                })
-                            }
-                        }
-                        if(goOn){
-                            callBack();
-                        }
+                        callBack();
                     } else {
                         return false;
                     }
@@ -328,14 +216,9 @@
             confirm(){
                 const _this=this;
                 this.validateForms(function(){
-                    delete _this.form.klRuleByIdSub;
-                    _this.form.klRuleInfoSaveSub = _this.form.parHasSub?_this.formatGroups():undefined;
                     let params = _this.form;
-                    if(_this.parId){//修改/复制
-                        params = Object.assign({},_this.form,{parId:_this.isCopy?undefined:_this.parId,parStatus:_this.isCopy?1:_this.form.parStatus})
-                    }
-                    console.log(params)
-                    _this.saveRule(params);
+
+                    _this.saveDiagBase(params);
                 });
             },
         }

+ 3 - 13
src/components/knowledgeExtra/DiagBase.vue

@@ -122,7 +122,7 @@
         created() {
             const param = this.$route.params;
             if(param.currentPage){
-                this.inCurrentPage = param.currentPage
+                this.inCurrentPage = param.currentPage;
                 this.filter = param.filter
             }
             this.getTypeList();
@@ -148,21 +148,11 @@
         //     })
         // },
         methods: {
-            statusTrans(type){
-                const obj = this.ruleTypeList.find((it)=>it.type===type);
-                return obj&&obj.name;
-            },
             getTypeList(){
-                const typeListData = JSON.parse(localStorage.getItem("zskTypesList"));
-                if(typeListData){
-                    this.ruleTypeList = typeListData;
-                    return;
-                }
-                api.getTypesList({planCode:'rule'}).then((res) => {
+                api.getTypesList({planCode:'dis'}).then((res) => {
                     if (res.data.code == '0') {
                         const data = res.data.data;
-                        this.ruleTypeList = data;
-                        localStorage.setItem("zskTypesList",JSON.stringify(data));
+                        localStorage.setItem("zskDiagList",JSON.stringify(data));
                     }
                 }).catch((error) => {
                     console.log(error);

+ 43 - 24
src/components/knowledgeExtra/DiagBaseGroup.vue

@@ -1,36 +1,53 @@
 <template>
     <div class="sub-groups">
-        <DiagBaseItem v-for="(rules,i) in data"
-                       ref="group"
-                       :groupData="rules"
-                       :isLast="data.length===1"
-                       :ind="i"
-                       :showAdd="data.length<maxNum"
-                       :baseTypes="baseTypes"
-                       :firstPlace="firstPlace"
-                       :disabled="i===0&&disable"
-                       @changeVal="handleInput"
-                       @addRule="addRule"
-                       @delRule="delRule"></DiagBaseItem>
-        <div class="group-oper">
-            <el-button size="small" @click="addGroup">+新增分组</el-button>
-            <el-button :disabled="isLast" size="small" type="danger" plain @click="delGroup">-删除分组</el-button>
-        </div>
+        <!--<el-form ref="form" class="add-new-form" label-width="140px" :model="data" :rules="rules">-->
+            <el-form-item label="符合条件的数量:" :prop="'klDiagnoseTypeVO.'+parInx+'.groupVO.'+inx+'.fitNo'">
+                <el-select v-model="data.fitNo"
+                           placeholder="请选择"
+                           size="small">
+                    <el-option
+                            v-for="item in numArr"
+                            :key="item.id"
+                            :label="item.name"
+                            :value="item.id">
+                    </el-option>
+                </el-select>
+            </el-form-item>
+            <DiagBaseItem v-for="(rules,i) in data.klDiagnoseDetail"
+                           ref="group"
+                           :groupData="rules"
+                           :ind="i"
+                           :inx="inx"
+                           :parInx="parInx"
+                           :isLast="isLast&&data.klDiagnoseDetail.length===1"
+                           :baseTypes="diagTypeList"
+                           @changeVal="handleInput"
+                           @addRule="addRule"
+                           @delRule="delRule"></DiagBaseItem>
+            <div class="group-oper">
+                <el-button size="small" @click="addGroup">+新增分组</el-button>
+                <el-button :disabled="isLast" size="small" type="danger" plain @click="delGroup">-删除分组</el-button>
+            </div>
+        <!--</el-form>-->
     </div>
 </template>
 <script>
     import DiagBaseItem from './DiagBaseItem.vue';
     export default {
-        name:'SubRulesGroup',
-        props:['data','inx','isLast','baseTypes','maxNum','firstPlace'],
+        name:'DiagBaseGroup',
+        props:['data','inx','isLast','diagTypeList','parInx'],
         data(){
             return {
+                fitNo:'',
+                numArr:[{id:1,name:1},{id:2,name:2},{id:3,name:3},{id:4,name:4},{id:5,name:5},{id:6,name:6},{id:7,name:7},{id:8,name:8},{id:9,name:9},{id:10,name:10},],
+                /*rules:{
+                    fitNo:[{required: true, message: '请选择符合条件的数量',trigger: ['change']}]}*/
             }
         },
         computed:{
-            'disable':function(){
-                return Object.keys(this.firstPlace||{}).length>0;
-            }
+            baseTypeList:function(){
+
+            },
         },
         methods:{
             handleInput(val,i){
@@ -53,14 +70,14 @@
                     subEqValue:'',
                     dataType:'',
                 };
-                this.data.push(temp);
+                this.data.klDiagnoseDetail.push(temp);
             },
             delRule(i){
-                if(i===0&&this.data.length===1){
+                if(i===0&&this.data.klDiagnoseDetail.length===1){
                     this.$emit("delGroup",this.inx);
                     return;
                 }
-                this.data.splice(i,1);
+                this.data.klDiagnoseDetail.splice(i,1);
             },
             addGroup(){
                 this.$emit("addGroup");
@@ -95,6 +112,8 @@
     .sub-groups{
         background: #F5F5F5;
         padding: 20px;
+        border:1px #ccc dashed;
+        margin:20px 0 0 20px;
     }
     .group-oper{
         text-align: center;

+ 95 - 127
src/components/knowledgeExtra/DiagBaseItem.vue

@@ -1,16 +1,17 @@
 <template>
     <div class="groups-cont">
-        <el-form ref="groupData" label-width="150px" class="sub-condition-form" :model="groupData" :rules="rules">
-            <span v-if="!disabled&&!isLast" class="del-btn"  @click="delRule">删除</span><!--:class="isLast?'disable del-btn':'del-btn'"-->
-            <el-form-item label="基础依据名称:" prop="subDescription">
-                <el-input v-model.trim = "groupData.subDescription" :disabled="disabled"></el-input>
+        <!--<el-form ref="groupData" label-width="150px" class="sub-condition-form" :model="groupData" :rules="rules">-->
+        <div class="sub-condition-form">
+        <span v-if="!isLast" class="del-btn"  @click="delRule">删除</span><!--:class="isLast?'disable del-btn':'del-btn'"-->
+            <el-form-item label="基础依据名称:" :prop="ruleLine+ind+'.basDescription'">
+                <el-input v-model.trim = "groupData.basDescription"></el-input>
             </el-form-item>
-            <el-form-item label="基础依据类型:" prop="subType">
-                <el-select v-model="groupData.subType"
-                           :disabled="disabled"
+            <el-form-item label="基础依据类型:" prop="basType">
+                <el-select v-model="groupData.basType"
+                           id="basTypeRef"
                            placeholder="请选择"
                            size="small"
-                           @change="subTypeChange">
+                           @change="basTypeChange">
                     <el-option
                             v-for="item in baseTypes"
                             :key="item.id"
@@ -19,11 +20,11 @@
                     </el-option>
                 </el-select>
             </el-form-item>
-            <el-form-item label="基础依据术语类型:" prop="subLenCode">
-                <el-select v-model="groupData.subLenCode"
-                           :disabled="disabled"
+            <el-form-item v-if="!showRegx" label="基础依据术语类型:" :prop="ruleLine+ind+'.basLibType'">
+                <el-select v-model="groupData.basLibType"
                            placeholder="请选择"
-                           size="small" @change="subCodeChange">
+                           size="small"
+                           :disabled="showRegx">
                     <el-option
                             v-for="item in baseTermTypeList"
                             :key="item.id"
@@ -32,8 +33,11 @@
                     </el-option>
                 </el-select>
             </el-form-item>
-            <el-form-item  class="addDepartFormItem" label="医学标准术语:" prop="subConceptId">
-                <el-select clearable remote filterable :disabled="disabled" :remote-method="searchConcept" v-model.trim="groupData.subConceptId">
+            <el-form-item v-if="showRegx" label="基础依据术语类型:" class="is-required">
+                <el-input disabled v-model="basTypeName"></el-input>
+            </el-form-item>
+            <el-form-item v-if="!showRegx" class="addDepartFormItem" label="医学标准术语:" :prop="ruleLine+ind+'.basConceptId'">
+                <el-select clearable remote filterable :remote-method="searchConcept" v-model.trim="groupData.basConceptId">
                     <el-option
                             v-for="item in conceptList"
                             :key="item.conceptId"
@@ -42,7 +46,7 @@
                     </el-option>
                 </el-select>
             </el-form-item>
-            <el-form-item v-if="groupData.subType===2&&showDataType" label="选择类型:" prop="dataType">
+            <el-form-item v-if="groupData.basType===2&&showDataType" label="选择类型:" :prop="ruleLine+ind+'.dataType'">
                 <el-select v-model="groupData.dataType"
                            placeholder="请选择"
                            size="small" @change="dataTypeChange">
@@ -57,8 +61,8 @@
             <el-form-item class="min-margin" v-if="groupData.dataType==='1'" label="最大值:">
                 <div class="select-item clearfix">
                     <el-col :span="3">
-                        <el-form-item prop="subMaxOperator">
-                            <el-select v-model="groupData.subMaxOperator"
+                        <el-form-item prop="maxOperator">
+                            <el-select v-model="groupData.maxOperator"
                                        placeholder="请选择"
                                        size="small" clearable>
                                 <el-option
@@ -71,13 +75,13 @@
                         </el-form-item>
                     </el-col>
                     <el-col :span="3">
-                        <el-form-item prop="subMaxValue">
-                            <el-input type="text" v-model="groupData.subMaxValue" placeholder="填写数值"/>
+                        <el-form-item prop="maxVal">
+                            <el-input type="text" v-model="groupData.maxVal" placeholder="填写数值"/>
                         </el-form-item>
                     </el-col>
                     <el-col :span="3">
-                        <el-form-item prop="subMaxUnit">
-                            <el-input  type="text" v-model.trim="groupData.subMaxUnit" placeholder="填写单位"/>
+                        <el-form-item prop="maxUnit">
+                            <el-input  type="text" v-model.trim="groupData.maxUnit" placeholder="填写单位"/>
                         </el-form-item>
                     </el-col>
                 </div>
@@ -85,8 +89,8 @@
             <el-form-item class="min-margin" v-if="groupData.dataType==='1'" label="最小值:">
                 <div class="select-item clearfix">
                     <el-col :span="3">
-                        <el-form-item prop="subMinOperator">
-                            <el-select v-model="groupData.subMinOperator"
+                        <el-form-item prop="minOperator">
+                            <el-select v-model="groupData.minOperator"
                                        placeholder="请选择"
                                        size="small" clearable>
                                 <el-option
@@ -99,40 +103,42 @@
                         </el-form-item>
                     </el-col>
                     <el-col :span="3">
-                        <el-form-item prop="subMinValue">
-                            <el-input type="text" v-model="groupData.subMinValue" placeholder="填写数值"/>
+                        <el-form-item prop="minVal">
+                            <el-input type="text" v-model="groupData.minVal" placeholder="填写数值"/>
                         </el-form-item>
                     </el-col>
                     <el-col :span="3">
-                        <el-form-item prop="subMinUnit">
-                            <el-input  type="text" v-model.trim="groupData.subMinUnit" placeholder="填写单位"/>
+                        <el-form-item prop="minUnit">
+                            <el-input  type="text" v-model.trim="groupData.minUnit" placeholder="填写单位"/>
                         </el-form-item>
                     </el-col>
                 </div>
             </el-form-item>
-            <el-form-item v-if="groupData.subType!==6&&groupData.dataType==='2'" label="医学内容:" prop="subEqValue" class="discDesc is-required">
-                <el-input type="textarea" rows="3" placeholder="请输入医学内容" v-model.trim="groupData.subEqValue"></el-input>
+            <el-form-item v-if="groupData.dataType==='2'" label="医学内容:" :prop="ruleLine+ind+'.eqValue'" class="discDesc is-required">
+                <el-input type="textarea" rows="3" placeholder="请输入医学内容" v-model.trim="groupData.eqValue"></el-input>
             </el-form-item>
-            <el-form-item v-if="groupData.subType===6" label="正则表达式:" prop="subEqValue" class="discDesc is-required">
-                <el-input type="textarea" rows="3" placeholder="请输入正则表达式" v-model.trim="groupData.subEqValue"></el-input>
+            <el-form-item v-if="showRegx" label="正则表达式:" :prop="ruleLine+ind+'.eqValue'" class="discDesc is-required">
+                <el-input type="textarea" rows="3" placeholder="请输入正则表达式" v-model.trim="groupData.eqValue"></el-input>
             </el-form-item>
-        </el-form>
-        <div class="inner-oper" v-if="showAdd">
+        </div>
+        <!--</el-form>-->
+        <div class="inner-oper">
             <span>新增基础依据:</span>
             <span class="add-btn" @click="addRule"><img src="../../images/add.png" alt="新增基础依据"></span>
         </div>
     </div>
 </template>
 <script>
-    import api from '@api/knowledgeLib.js';
+    import api from '@api/zskDiagBase.js';
     export default {
         name:'DiagBaseItem',
-        props:['groupData','ind','isLast','baseTypes','firstPlace','disabled','showAdd'],
+        props:['groupData','ind','isLast','baseTypes','parInx','inx'],
         data(){
             return {
                 baseTermTypeList:[],
                 typeList:[],
                 numTypes:'',    //只有数值类型的类型id
+                basTypeName:'',
                 operMaxList:[
                     {name:'<=',key:'<='},
                     {name:'<',key:'<'},
@@ -143,44 +149,33 @@
                 dataTypes:[{id:'1',name:'数值类型'},{id:'2',name:'文本类型'}],
                 conceptList:[],
                 rules:{
-                    subDescription:[{ required: true, message: '请输入基础规则名称',trigger: ['blur'] },{
-                        validator: (rule,value,callback)=>{
-                            if(value.length>100){
-                                callback(new Error('规则名称不能超过100字'));
-                            }else{
-                                callback();
-                            }}, trigger: 'change'
-                    }],
-                    subType:[{ required: true, message: '请选择基础规则类型',trigger: ['change'] }],
-                    subLenCode:[{ required: true, message: '请选择基础规则术语类型',trigger: ['change'] }],
-                    subConceptId:[{ required: true, message: '请输入医学标准术语',trigger: ['blur'] }],
-                    dataType:[{ required: true, message: '请选择类型',trigger: ['change'] }],
-                    subMaxOperator:[{
+
+                    maxOperator:[{
                         validator: (rule,value,callback)=>{
-                            const {subMaxValue,subMinOperator,subMinValue}=this.groupData;
-                            const val=value+subMinOperator+subMinValue+subMaxValue;
-                            if(!val||(!value&&subMaxValue!=='')){
+                            const {maxVal,minOperator,minVal}=this.groupData;
+                            const val=value+minOperator+minVal+maxVal;
+                            if(!val||(!value&&maxVal!=='')){
                                 callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
                             }else{
                                 callback();
                             }}, trigger: 'blur'
                     }],
-                    subMinOperator:[{
+                    minOperator:[{
                         validator: (rule,value,callback)=>{
-                            const {subMaxValue,subMaxOperator,subMinValue}=this.groupData;
-                            const val=value+subMaxOperator+subMinValue+subMaxValue;
-                            if(!val||(!value&&subMinValue!=='')){
+                            const {maxVal,maxOperator,minVal}=this.groupData;
+                            const val=value+maxOperator+minVal+maxVal;
+                            if(!val||(!value&&minVal!=='')){
                                 callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
                             }else{
                                 callback();
                             }}, trigger: 'blur'
                     }],
-                    subMaxValue:[{
+                    maxVal:[{
                         validator: (rule,value,callback)=>{
-                            const {subMaxOperator,subMinOperator,subMinValue}=this.groupData;
-                            const val=value+subMaxOperator+subMinValue+subMinOperator;
+                            const {maxOperator,minOperator,minVal}=this.groupData;
+                            const val=value+maxOperator+minVal+minOperator;
                             const isNum=/^(\-|\+)?\d+(\.\d+)?$/.test(value);
-                            if(!val||(value==''&&subMaxOperator)){
+                            if(!val||(value==''&&maxOperator)){
                                 callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
                             }else if(value!==''&&!isNum){
                                 callback(new Error('只能输入数字'));
@@ -188,12 +183,12 @@
                                 callback();
                             }}, trigger: 'blur'
                     }],
-                    subMinValue:[{
+                    minVal:[{
                         validator: (rule,value,callback)=>{
-                            const {subMaxValue,subMinOperator,subMaxOperator}=this.groupData;
-                            const val=value+subMaxOperator+subMaxValue+subMinOperator;
+                            const {maxVal,minOperator,maxOperator}=this.groupData;
+                            const val=value+maxOperator+maxVal+minOperator;
                             const isNum=/^(\-|\+)?\d+(\.\d+)?$/.test(value);
-                            if(!val||(value==''&&subMinOperator)){
+                            if(!val||(value==''&&minOperator)){
                                 callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
                             }else if(value!==''&&!isNum){
                                 callback(new Error('只能输入数字'));
@@ -201,7 +196,7 @@
                                 callback();
                             }}, trigger: 'blur'
                     }],
-                    subEqValue:[{
+                    eqValue:[{
                         validator: (rule,value,callback)=>{
                             if(value===''){
                                 callback(new Error('请输入'+this.textName));
@@ -214,77 +209,56 @@
                 },
             }
         },
-        watch:{
-            'groupData':{
-                handler:function(val){
-                    this.$emit("changeVal",val,this.ind);
-                },
-                deep:true
-            },
-            'baseTypes':{
-                handler:function(val){
-                    if(!this.groupData.subType){
-                        this.baseTermTypeList =[];
-                        return;
-                    }
-                    const obj = val.find((it)=>it.type===this.groupData.subType);
-                    this.baseTermTypeList = obj.subMenuList;
+        watch: {
+            'groupData': {
+                handler: function (val) {
+                    this.$emit("changeVal", val, this.ind);
                 },
-                deep:true
+                deep: true
             },
-            'firstPlace':{
-                handler:function(val) {
-                    if (this.ind!==0||!val) return;
-                    const dict = localStorage.getItem("zskDicts").match(new RegExp(val.checkedType+'-\\d+','g'))||[];
-                    const types = dict[0].split("-");
-                    const sub = this.baseTypes.find((it) => it.ruleType === +types[0] && it.type === +types[2]);
-                    this.groupData.subType = sub.type;
-                    this.baseTermTypeList = sub.subMenuList;
-                    this.groupData.subLenCode = (this.baseTermTypeList.find((it) => it.ruleType === +types[0])||{}).code;
-                    this.conceptList = [val];
-                    this.groupData.subDescription = val.conceptName;
-                    this.groupData.subConceptId = val.conceptId;
-                    this.groupData.subConceptName = val.conceptName;
-                },
-                deep:true
-            }
         },
         created(){
             this.numTypes = localStorage.getItem("zskNumDict");
-            this.conceptList=[{conceptName:this.groupData.subLibName||this.groupData.subConceptName,conceptId:this.groupData.subConceptId}];
-            if(this.groupData.subLenCode){
-                this.baseTermTypeList=[{name:this.groupData.subLenName,code:this.groupData.subLenCode}];
+            this.conceptList=[{conceptName:this.groupData.subLibName||this.groupData.subConceptName,conceptId:this.groupData.basConceptId}];
+            if(this.groupData.basLibType){
+                this.baseTermTypeList=[{name:this.groupData.subLenName,code:this.groupData.basLibType}];
             }
         },
         computed:{
+            ruleLine:function(){
+              return 'klDiagnoseTypeVO.'+this.parInx+'.groupVO.'+this.inx+'.klDiagnoseDetail.';
+            },
             showDataType:function(){
-                return (this.numTypes+',').indexOf(this.groupData.subLenCode+',')===-1;
+                return (this.numTypes+',').indexOf(this.groupData.basLibType+',')===-1;
+            },
+            showRegx:function(){
+              return this.groupData.basType===3||this.groupData.basType===4;
             },
             textName:function(){
-                return this.groupData.subType!==6&&this.groupData.dataType==='2'?'医学内容':'正则表达式';
-            }
+                return this.showRegx?'正则表达式':'医学内容';
+            },
         },
         methods:{
             dataTypeChange(val){
-                this.groupData.subEqOperator=(val==='2'?'=':'');
+                this.groupData.eqOperator=(val==='2'?'=':'');
                 this.clearNumText();
                 delete this.groupData.dataType;     //触发更新
                 this.$set(this.groupData,'dataType',val);
             },
-            subTypeChange(val){        //基础规则类型修改
-                this.groupData.subLenCode='';
-                this.groupData.dataType='';
-                this.clearConcept();
-                this.clearNumText();
+            basTypeChange(val){        //基础规则类型修改
                 if(!val){
                     this.baseTermTypeList =[];
                     return;
                 }
+                this.basTypeName=this.baseTypes.find((it)=>it.type===val).name;
+                this.groupData.basLibType=this.groupData.basType;
+                this.clearConcept();
+                this.clearNumText();
                 const obj = this.baseTypes.find((it)=>it.type===val);
                 this.baseTermTypeList = obj.subMenuList;
             },
             subCodeChange(val){        //基础规则术语类型修改
-                this.groupData.subLenCode=val;
+                this.groupData.basLibType=val;
                 if((this.numTypes+',').indexOf(val+',')>-1){
                     this.groupData.dataType='1';
                 }else{
@@ -294,23 +268,23 @@
                 this.clearNumText();
             },
             clearConcept(){
-                this.groupData.subConceptId='';
+                this.groupData.basConceptId='';
                 this.conceptList=[];
             },
             clearNumText(){
-                this.groupData.subMaxOperator='';
-                this.groupData.subMaxValue='';
-                this.groupData.subMaxUnit='';
-                this.groupData.subMinOperator='';
-                this.groupData.subMinValue='';
-                this.groupData.subMinUnit='';
-                this.groupData.subEqValue='';
-                this.groupData.subEqOperator='';
+                this.groupData.maxOperator='';
+                this.groupData.maxVal='';
+                this.groupData.maxUnit='';
+                this.groupData.minOperator='';
+                this.groupData.minVal='';
+                this.groupData.minUnit='';
+                this.groupData.eqValue='';
+                this.groupData.eqOperator='';
             },
             searchConcept(val){
                 const param = {
-                    excludedConceptIds:[this.groupData.subType],
-                    libType:this.groupData.subLenCode,
+                    excludedConceptIds:[this.groupData.basType],
+                    libType:this.groupData.basLibType,
                     name:val,
                 };
                 api.searchConcept(param).then((res) => {
@@ -326,14 +300,7 @@
                 this.$emit("addRule");
             },
             delRule(){
-                if(this.isLast){
-                    this.warning("初始状态规则不能删除~");
-                    return;
-                }
-                //this.showConfirmDialog("是否删除该条规则,可能对现有系统会造成影响",()=>{
                 this.$emit("delRule",this.ind);
-                //});
-
             },
             warning(msg,type){
                 this.$message({
@@ -356,6 +323,7 @@
 <style lang="less">
     .groups-cont{
         background: #fff;
+        margin-top:20px;
         .conceptItem{
             padding: 0 10px;
             cursor: pointer;

+ 114 - 62
src/components/knowledgeExtra/DiagBaseType.vue

@@ -1,63 +1,115 @@
 <template>
-    <el-form ref="form" class="add-new-form" label-width="130px" :model="form" :rules="rules">
-            <el-form-item label="诊断依据类型:" prop="conditionType">
-                <el-select v-model="form.conditionType"
-                           placeholder="请选择"
-                           size="small" @change="typeChange">
-                    <el-option
-                            v-for="item in typeList"
-                            :key="item.id"
-                            :label="item.name"
-                            :value="item.id">
-                    </el-option>
-                </el-select>
-            </el-form-item>
-            <DiagBaseGroup v-for="(group,i) in subGroups"
-                       ref="groups"
-                       :data="group"
-                       :baseTypes="baseTypeList"
-                       :inx="i"
-                       :maxNum="subRuleMaxNum"
-                       :firstPlace="firstPlace"
-                       :isLast="subGroups.length===1"
-                       @addGroup="addGroup"
-                       @delGroup="delGroup"></DiagBaseGroup>
-    </el-form>
-</template>
-<script>
-    import DiagBaseGroup from './DiagBaseGroup';
-    export default {
-        name:'DiagBaseType',
-        props:['subGroups'],
-        data(){
-            return {
-                form:{},
-                conditionType:'',
-                typeList:[{name:'确诊',id:1},{name:'拟诊',id:2},{name:'警惕',id:3}],
-                baseTypeList:[],
-                subRuleMaxNum:'',
-                firstPlace:{},
-                rules:{}
-            }
-        },
-        methods:{
-            typeChange(){
-
-            },
-            addGroup(){
-
-            },
-            delGroup(){
-
-            }
-        },
-        components:{
-            DiagBaseGroup
-        }
-    }
-</script>
-<style lang="less" scoped>
-    .add-new-form{
-        background: #F5F5F5;
-    }
-</style>
+    <!--<el-form ref="form" class="add-new-form" label-width="130px" :model="data">-->
+   <div class="add-new-form">
+        <el-form-item label="诊断依据类型:" :prop="'klDiagnoseTypeVO.'+inx+'.conditionType'">
+            <el-select v-model="data.conditionType"
+                       placeholder="请选择"
+                       size="small">
+                <el-option
+                        v-for="item in typeList"
+                        :key="item.ruleType"
+                        :label="item.name"
+                        :value="item.ruleType">
+                </el-option>
+            </el-select>
+        </el-form-item>
+        <DiagBaseGroup v-for="(group,i) in data.groupVO"
+                   ref="groups"
+                   :data="group"
+                   :diagTypeList="baseTypeList"
+                   :inx="i"
+                   :parInx="inx"
+                   :isLast="isLast&&data.groupVO.length===1"
+                   @addGroup="addGroup"
+                   @delGroup="delGroup"></DiagBaseGroup>
+    <div class="group-oper">
+        <el-button size="small" @click="addDiag">+新增依据</el-button>
+        <el-button size="small" @click="copyDiag">复制依据</el-button>
+        <el-button :disabled="isLast" size="small" type="danger" plain @click="delGroup">-删除依据</el-button>
+    </div>
+          </div>
+       <!-- </el-form>-->
+      </template>
+      <script>
+          import DiagBaseGroup from './DiagBaseGroup';
+          import util from '../../api/utils.js'
+          export default {
+              name:'DiagBaseType',
+              props:['data','isLast','inx'],
+              data(){
+                  return {
+                      form:{},
+                      conditionType:'',
+                      typeObj:{},
+                      typeList:[],
+                      /*rules:{
+                          conditionType:[]
+                      }*/
+                  }
+              },
+              computed:{
+                baseTypeList:function(){
+                    return this.typeObj[this.data.conditionType];
+                }
+              },
+              created(){
+                  this.getTypeList();
+              },
+              methods:{
+                  getTypeList(){
+                      const typeListData = JSON.parse(localStorage.getItem("zskDiagList"));
+                      this.typeObj=util.formatObj(typeListData,'ruleType');
+                      this.typeList = typeListData;
+                  },
+                  addDiag(){
+                      this.$emit("addDiag");
+                  },
+                  delDiag(){
+                      this.$emit("delDiag",this.inx);
+                  },
+                  copyDiag(){
+                      this.$emit("copyDiag",this.inx);
+                  },
+                  addGroup(){
+                      const temp={
+                          "baseGroup": '',
+                          "conditionGroup": '',
+                          "fitNo": '',
+                          "klDiagnoseDetail": [{
+                              "basConceptId": '',
+                              "basDescription": "",
+                              "basLename": "",
+                              "basLibName": "",
+                              "basLibType": null,
+                              "basType": '',
+                              "eqOperator": "",
+                              "eqUnit": "",
+                              "eqValue": "",
+                              "maxOperator": "",
+                              "maxUnit": "",
+                              "maxVal": "",
+                              "minOperator": "",
+                              "minUnit": "",
+                              "minVal": ""
+                          }]
+                      };
+                      this.data.groupVO.push(temp);
+                  },
+                  delGroup(){
+                      this.data.groupVO.splice(this.inx,1);
+                  }
+              },
+              components:{
+                  DiagBaseGroup
+              }
+          }
+      </script>
+      <style lang="less" scoped>
+          .add-new-form{
+              background: #F5F5F5;
+              padding: 20px 0;
+          }
+          .group-oper{
+              margin:20px 0 0 20px;
+          }
+      </style>