Browse Source

模板新增

zhangxc 5 years ago
parent
commit
129860c2e9

+ 1 - 0
src/api/config.js

@@ -296,6 +296,7 @@ export default {
       'saveOrUpdateQCTemp':'/api/mrman/qc/qcModuleInfo/saveOrUpdateModuleInfo', //新增或修改模板
       'saveOrUpdateQCTemp':'/api/mrman/qc/qcModuleInfo/saveOrUpdateModuleInfo', //新增或修改模板
       'delQCTemp':'/api/mrman/qc/qcModuleInfo/delete', //删除模板
       'delQCTemp':'/api/mrman/qc/qcModuleInfo/delete', //删除模板
       'getQCTempDetail':'/api/mrman/qc/qcModuleInfo/getById', //获取模板详情
       'getQCTempDetail':'/api/mrman/qc/qcModuleInfo/getById', //获取模板详情
+      'getQCName':'/api/mrman/qc/qcQuestionInfo/index', //获取字段名称
   },
   },
 	menuIconList: { //菜单对应图标
 	menuIconList: { //菜单对应图标
 		'YH-KZT': 'el-icon-menu',
 		'YH-KZT': 'el-icon-menu',

+ 3 - 0
src/api/qualityControl.js

@@ -27,5 +27,8 @@ export default {
   getQCTempDetail(param){ //获取模板详情
   getQCTempDetail(param){ //获取模板详情
     return axios.post(urls.getQCTempDetail,param);
     return axios.post(urls.getQCTempDetail,param);
   },
   },
+  getQCName(param){ //获取字段名称
+    return axios.post(urls.getQCName,param);
+  }
 
 
 }
 }

+ 221 - 108
src/components/qualityControl/AddQualityControlTemp.vue

@@ -4,25 +4,24 @@
         </crumbs>
         </crumbs>
         <div class="contentWrapper">
         <div class="contentWrapper">
             <div class="content">
             <div class="content">
-                <el-form :model="form" ref="ruleForm" class="selectHospital">
-                    <el-form-item label="模板名称:" prop="name" class="formItem">
+                <el-form :model="form" :rules="rules" ref="form" class="selectHospital">
+                    <el-form-item label="模板名称:" prop="tempName" class="formItem">
                         <el-input v-model="form.tempName"  placeholder="请输入模板名称"></el-input>
                         <el-input v-model="form.tempName"  placeholder="请输入模板名称"></el-input>
                     </el-form-item>
                     </el-form-item>
-                    <el-form-item label="所属医院:" prop="hospitalName" class="formItem">
+                    <el-form-item label="所属医院:" prop="hospital" class="formItem">
                         <el-select  v-model="form.hospital" placeholder="请选择医院"  class="selectHospital">
                         <el-select  v-model="form.hospital" placeholder="请选择医院"  class="selectHospital">
-                            <el-option v-for="item in hospitalList" :key="item.id" :label="item.name" :value="item.id"></el-option>
+                            <el-option v-for="item in hospitalList" :key="item.id" :label="item.name" :value="item.val"></el-option>
                         </el-select>
                         </el-select>
                     </el-form-item>
                     </el-form-item>
-                    <el-form-item label="选择模块:" prop="module" class="formItem">
-                        <el-select  v-model="form.module" placeholder="请选择模块"  class="selectModule">
-                            <el-option v-for="item in moduleList" :key="item.id" :label="item.name" :value="item.id"></el-option>
+                    <el-form-item label="选择模块:" prop="moduleName" class="formItem">
+                        <el-select  v-model="form.moduleName" placeholder="请选择模块"  class="selectModule">
+                            <el-option v-for="item in moduleList" :key="item.id" :label="item.name" :value="item.val"></el-option>
                         </el-select>
                         </el-select>
                     </el-form-item>
                     </el-form-item>
                      <el-form-item label="添加模块内容:" prop="moduleInfo" class="formItem">
                      <el-form-item label="添加模块内容:" prop="moduleInfo" class="formItem">
                         <div class="moduleInfoItem" v-for="(item,index) in moduleInfoList">
                         <div class="moduleInfoItem" v-for="(item,index) in moduleInfoList">
                             <div class="searchBox">
                             <div class="searchBox">
                                 <el-input v-model.trim="item.searchName"  placeholder="搜索字段单元" @input="searchFiled(index)">
                                 <el-input v-model.trim="item.searchName"  placeholder="搜索字段单元" @input="searchFiled(index)">
-
                                 </el-input>
                                 </el-input>
                                 <ul v-if="searchIndex == index &&  item.searchResult.length > 0" class="searchResultBox">
                                 <ul v-if="searchIndex == index &&  item.searchResult.length > 0" class="searchResultBox">
                                     <li class="searchItem" 
                                     <li class="searchItem" 
@@ -36,93 +35,115 @@
                             </div>
                             </div>
                             <div>
                             <div>
                                 <p>已选择字段:</p>
                                 <p>已选择字段:</p>
-                                <div class="selectFiled" v-for="(it,ii) in item.selectFiled">
-                                    <div class="orderBox">
-                                        <span v-if="ii !=0" class="el-icon-top order" :class="{lastItem:ii ==item.selectFiled.length}" @click="upFiled(ii,index)"></span>
-                                        <span v-if="ii !=item.selectFiled.length-1" class="el-icon-bottom order"  :class="{firstItem:ii == 0}" @click="downFiled(ii,index)"></span> 
+                                <div class="selectFiledBox">
+                                     <div class="orderBox">
+                                            <span class="el-icon-arrow-up order"  @click="upFiled(index)"></span>
+                                            <span  class="el-icon-arrow-down order" @click="downFiled(index)"></span> 
+                                        </div>
+                                    <div class="selectFiled" v-for="(it,ii) in item.selectFiled">
+                                        <span class="filedName" :class="{activeFiledName: item.activeIndex == ii}" @click="setActiveIndex(index,ii)">{{it.name}}
+                                            <span class="el-icon-circle-close delFiled" @click="delSelected(ii,index)"></span>
+                                        </span>
+                                    
                                     </div>
                                     </div>
-                                    <span class="filedName">{{it.name}}
-                                        <span class="el-icon-circle-close delFiled" @click="delSelected(ii,index)"></span>
-                                    </span>
-                                
                                 </div>
                                 </div>
+                                
                             </div>
                             </div>
                             <span class="el-icon-circle-close delUnit" @click="delUnit(index)"></span>
                             <span class="el-icon-circle-close delUnit" @click="delUnit(index)"></span>
                         </div>
                         </div>
-                        <span class="addUnit" @click="addUnit">+单元组</span>
+                        <span  class="addUnit" @click="addUnit">+单元组</span>
                     </el-form-item>
                     </el-form-item>
                 </el-form>
                 </el-form>
+                <el-button class="disclButn" size="small" type="primary" :disabled = 'saveDisable' @click="confirm('form')">确定</el-button>
             </div>
             </div>
         </div>
         </div>
         
         
     </div>
     </div>
 </template>
 </template>
 <script>
 <script>
-//   import api from '@api/safeControl.js';
+import api from '@api/qualityControl.js';
 export default {
 export default {
     name:"AddQualityControlTemp",
     name:"AddQualityControlTemp",
     data: function(){
     data: function(){
         return {
         return {
             title: "模板维护-添加",
             title: "模板维护-添加",
+            isEdit:false,
+            isCopy: false,
+            saveDisable: false,
             form:{
             form:{
                 tempName: "",
                 tempName: "",
                 hospital:"",
                 hospital:"",
                 module:"",
                 module:"",
             },
             },
+            rules:{
+                tempName:{ required: true, message: '请输入模块名称', trigger: ['blur', 'change']},
+                hospital:{ required: true, message: '请选择医院', trigger: ['blur', 'change']},
+                moduleName:{ required: true, message: '请输入选择模块', trigger: ['blur', 'change']},
+                /*name:[{ required: true, message: '请输入显示名称',trigger: ['blur', 'change'] }],*/
+            },
             searchIndex: -1,
             searchIndex: -1,
-            hospitalList:[  
-                    {
-                        id: 1,
-                        name:"台州"
-                    },
-                    {
-                        id: 2,
-                        name:"长兴"
-                    }
-                ],
-                moduleList:[
-                    {
-                        id: 1,
-                        name:"入院记录"
-                    },
-                    {
-                        id: 2,
-                        name:"出院小结"
-                    }
-                ],
-                moduleInfoList:[
-                    {   
-                        searchName:"",
-                        searchResult:[
-                            // {
-                            //     name: "4姓名"
-                            // },
-                            // {
-                            //     name: "5职业"
-                            // },
-                            // {
-                            //     name: "6年龄"
-                            // }
-                        ],
-                        selectFiled:[
-                            {
-                                name: "姓名"
-                            },
-                            {
-                                name: "职业"
-                            },
-                            {
-                                name: "年龄"
-                            }
-                        ]
-                    }
-                ]
+            
+            hospitalList:[],
+            moduleList:[ ],
+            moduleInfoList:[
+                {   
+                    searchName:"",
+                    activeIndex: -1,
+                    searchResult:[
+                        // {
+                        //     name: "4姓名"
+                        // },
+                        // {
+                        //     name: "5职业"
+                        // },
+                        // {
+                        //     name: "6年龄"
+                        // }
+                    ],
+                    selectFiled:[
+                        
+                    ]
+                }
+            ]
         }
         }
     },
     },
+    created(){
+        this.getAllTypes();
+        // if(isEdit){
+        //     // this.id = 
+        // }
+    },
     methods:{
     methods:{
+        getAllTypes(){
+        if(localStorage.getItem("qcModuleTypes")){
+            this.hospitalList = JSON.parse(localStorage.getItem("qcHospitalTypes"));
+            this.moduleList = JSON.parse(localStorage.getItem("qcModuleTypes"));
+            return ;
+        }
+        //获取枚举信息
+        api.getQcTypes().then((res)=>{
+            if(res.data.code==="0"){
+            const data = res.data.data;
+            localStorage.setItem("qcFieldTypes",JSON.stringify(data[11]));
+            localStorage.setItem("qcModuleTypes",JSON.stringify(data[12]));
+            localStorage.setItem("qcHospitalTypes",JSON.stringify(data[13]));
+            }else{
+            this.warning("获取枚举信息失败");
+            }
+        });
+        },
         addUnit(){
         addUnit(){
+            if(!this.form.hospital){
+                this.warning("请先选择所属医院")
+                return
+            }
+            if(!this.form.modeId){
+                this.warning("请先选择模块")
+                return
+            }
             this.moduleInfoList.push({   
             this.moduleInfoList.push({   
                         searchName:"",
                         searchName:"",
+                        activeIndex: -1,
                         searchResult:[
                         searchResult:[
                            
                            
                         ],
                         ],
@@ -140,54 +161,60 @@ export default {
                     })
                     })
         },
         },
         searchFiled(index){
         searchFiled(index){
-            console.log(index)
             this.searchIndex = index
             this.searchIndex = index
             const searchName = this.moduleInfoList[index].searchName
             const searchName = this.moduleInfoList[index].searchName
-            // api.searchFiled(param).then(res =>{
-            //     if(res.data.code == '0'){
-            //          this.moduleInfoList[index].searchResult = []
-            //          this.moduleInfoList[index].searchResult.push(res.data.data)
-            //     }
-            // }).catch(e =>{
-            //     console.log(e)
-            // })
-            if(this.moduleInfoList[index].searchName){
-                this.moduleInfoList[index].searchResult = []
-                this.moduleInfoList[index].searchResult.push([
-                    {
-                        name: "4姓名"
-                    },
-                    {
-                        name: "5职业"
-                    },
-                    {
-                        name: "6年龄"
-                    }
-                    ])
+            if(!searchName){
+                return
+            }
+            const param = {
+                tagName: searchName,
+                hospitalId: this.form.hospital,
+                modeId:  [this.form.moduleName],
             }
             }
+            api.getQCName(param).then(res =>{
+                if(res.data.code == '0'){
+                     this.moduleInfoList[index].searchResult = []
+                     this.moduleInfoList[index].searchResult.push(...res.data.data)
+                }
+            }).catch(e =>{
+                console.log(e)
+            })
+          
         },
         },
         selectSearchFiled(searchItem,index){
         selectSearchFiled(searchItem,index){
             this.moduleInfoList[index].selectFiled.push(searchItem)
             this.moduleInfoList[index].selectFiled.push(searchItem)
             this.searchIndex = -1
             this.searchIndex = -1
             this.moduleInfoList[index].searchName=""
             this.moduleInfoList[index].searchName=""
             this.moduleInfoList[index].searchResult = []
             this.moduleInfoList[index].searchResult = []
-            console.log(searchItem)
         },
         },
-        upFiled(ii,index){
-            if(ii == 0){
+        setActiveIndex(index, ii){
+             let activeIndex = this.moduleInfoList[index].activeIndex
+             if( ii === activeIndex) {
+                 this.moduleInfoList[index].activeIndex = -1
+             } else {
+                 this.moduleInfoList[index].activeIndex = ii
+             }
+             
+        },
+        upFiled(index){
+            let activeIndex = this.moduleInfoList[index].activeIndex
+            if(activeIndex == 0 || activeIndex == -1){
                 return
                 return
             }
             }
-            const current = this.moduleInfoList[index].selectFiled[ii]
-            const currentPre = this.moduleInfoList[index].selectFiled[ii-1]
-            this.moduleInfoList[index].selectFiled.splice(ii-1,2,current,currentPre)
+            const current = this.moduleInfoList[index].selectFiled[activeIndex]
+            const currentPre = this.moduleInfoList[index].selectFiled[activeIndex-1]
+            this.moduleInfoList[index].selectFiled.splice(activeIndex-1,2,current,currentPre)
+            this.moduleInfoList[index].activeIndex--
         },
         },
-        downFiled(ii,index){
-            if(ii == this.moduleInfoList[index].selectFiled.length -1){
+        downFiled(index){
+             let activeIndex = this.moduleInfoList[index].activeIndex
+            if(activeIndex == this.moduleInfoList[index].selectFiled.length -1 || activeIndex == -1){
                 return
                 return
             }
             }
-            const current = this.moduleInfoList[index].selectFiled[ii]
-            const currentNext = this.moduleInfoList[index].selectFiled[ii+1]
-            this.moduleInfoList[index].selectFiled.splice(ii,2,currentNext,current)
+            const current = this.moduleInfoList[index].selectFiled[activeIndex]
+            const currentNext = this.moduleInfoList[index].selectFiled[activeIndex+1]
+            this.moduleInfoList[index].selectFiled.splice(activeIndex,2,currentNext,current)
+             this.moduleInfoList[index].activeIndex++
 
 
         },
         },
         delSelected(ii,index){
         delSelected(ii,index){
@@ -197,6 +224,76 @@ export default {
         delUnit(index){
         delUnit(index){
              this.moduleInfoList.splice(index,1)
              this.moduleInfoList.splice(index,1)
         },
         },
+        confirm(form){
+            this.$refs[form].validate((valid) => {
+                if (valid) {
+                    const {tempName,hospital,moduleName} = this.form
+                    let moduleDetail = [], moduleInfoList = this.moduleInfoList
+                    for(let i = 0; i < moduleInfoList.length; i++){
+                       for(let j = 0; j < moduleInfoList[i].selectFiled.length; j++){
+                            let item ={
+                                groupId: i,
+                                questionId: moduleInfoList[i].selectFiled[j].id
+                            }
+                            moduleDetail.push(item)
+                       }
+                        
+                    }
+                     let param = {
+                        name: tempName,
+                        modeId: moduleName,
+                        hospitalId: hospital,
+                        moduleDetail: moduleDetail,
+                        remark:''
+                     }
+                     if(this.isEdit){
+                         param = Object.assign({}, param, {id: this.id})
+                     }
+                    if(this.id && !this.isCopy){//修改
+                   
+                        this.saveDisable = true  //提交保存按钮不可点击,返回结果时才可点击,防止频繁发送请求
+                        api.saveOrUpdateQCTemp(param).then((res)=>{
+                            if(res.data.code==0){
+                            this.$message({
+                                message:"修改成功",
+                                type:'success'
+                            });
+                            //返回带搜索条件的首页
+                            this.$router.push({
+                                name: 'QualityControlTemp',
+                                params: Object.assign({}, this.$route.params, {currentPage: 1})
+                            });
+                            }else{
+                            this.$message({
+                                message:res.data.msg,
+                                type:'warning'
+                            });
+                            }
+                            this.saveDisable = false
+                        })
+                    }else{//添加
+                        this.saveDisable = true;  //提交保存按钮不可点击,返回结果时才可点击,防止频繁发送请求
+                        api.saveOrUpdateQCTemp(param).then((res)=>{
+                            if(res.data.code==0){
+                            this.$message({
+                                message:"添加成功",
+                                type:'success'
+                            })
+                            this.$router.push({name: 'QualityControlTemp'});
+                            }else{
+                            this.$message({
+                                message:res.data.msg,
+                                type:'warning'
+                            });
+                            }
+                            this.saveDisable = false
+                        })
+                    }
+                } else {
+                    return false;
+                }
+            }); 
+        },
         warning(msg, type,time) {
         warning(msg, type,time) {
             this.$message({
             this.$message({
                 showClose: true,
                 showClose: true,
@@ -258,20 +355,25 @@ export default {
 }
 }
 .searchResultBox{
 .searchResultBox{
     position: absolute;
     position: absolute;
-    width: 100%;
-    padding: 0 20px;
+    width: 200px;
+    box-sizing: border-box;
+    max-height: 200px;
+    overflow-y: auto;
     background: #fff;
     background: #fff;
+    z-index: 2;
+    border: 1px solid #dcdfe6;
 }
 }
 .searchItem{
 .searchItem{
     height: 40px;
     height: 40px;
     line-height: 40px;
     line-height: 40px;
+    padding: 0 20px;
     cursor: pointer;
     cursor: pointer;
     overflow: hidden;
     overflow: hidden;
     white-space: nowrap;
     white-space: nowrap;
     text-overflow: ellipsis;
     text-overflow: ellipsis;
 }
 }
 .searchItem:hover{
 .searchItem:hover{
-    background-color: #abcdef;
+    background-color: #F5F7FA;
 }
 }
 .selectFiled{
 .selectFiled{
     position: relative;
     position: relative;
@@ -279,19 +381,24 @@ export default {
 .orderBox{
 .orderBox{
     position: absolute;
     position: absolute;
     left: -50px;
     left: -50px;
+    top: 50%;
+    width: 50px;
+    height: 84px;
+    margin-top: -42px;
+}
+.selectFiledBox{
+    position: relative;
+    min-height: 120px;
 }
 }
 .order{
 .order{
     display: inline-block;
     display: inline-block;
-    width: 16px;
-    height: 16px;
-    font-size: 16px;
+    width: 30px;
+    height: 30px;
+    font-size: 30px;
     margin-left: 5px;
     margin-left: 5px;
     border: 1px solid #dcdfe6;
     border: 1px solid #dcdfe6;
     cursor: pointer;
     cursor: pointer;
-    i{
-        width: 15px;
-        height: 15px;
-    }
+   
 }
 }
 .firstItem{
 .firstItem{
     margin-left: 28px;
     margin-left: 28px;
@@ -308,5 +415,11 @@ export default {
 }
 }
 .filedName{
 .filedName{
     position: relative;
     position: relative;
+    border: 1px solid #dcdfe6;
+    border-radius: 4px;
+    padding: 5px 10px;
+}
+.activeFiledName{
+    border: 1px solid #48C5D7;
 }
 }
 </style>
 </style>

+ 13 - 32
src/components/qualityControl/QualityControlTemp.vue

@@ -5,8 +5,10 @@
                  <el-form-item label="模板名称:">
                  <el-form-item label="模板名称:">
                     <el-input size="mini" v-model.trim="filter.modeName" placeholder="模板名称" clearable></el-input>
                     <el-input size="mini" v-model.trim="filter.modeName" placeholder="模板名称" clearable></el-input>
                 </el-form-item>
                 </el-form-item>
-                <el-form-item label="模板Id:">
-                    <el-input size="mini" v-model.trim="filter.modeId" placeholder="模板Id" clearable></el-input>
+                <el-form-item label="数据模块Id:">
+                     <el-select size="mini" v-model.trim="filter.hospitalName" @change="getValue"  placeholder="数据模块" clearable>
+                        <el-option v-for="item in hospitalList" :label="item.name" :value="item.val" :key="item.id" ></el-option>
+                    </el-select>
                 </el-form-item>
                 </el-form-item>
                 <el-form-item label="所属医院:">
                 <el-form-item label="所属医院:">
                     <el-select size="mini" v-model.trim="filter.hospitalName" @change="getValue"  placeholder="所属医院" clearable>
                     <el-select size="mini" v-model.trim="filter.hospitalName" @change="getValue"  placeholder="所属医院" clearable>
@@ -34,41 +36,20 @@
                 </el-table-column>
                 </el-table-column>
                 <el-table-column
                 <el-table-column
                         :resizable = "false"
                         :resizable = "false"
-                        prop="gmtModified"
-                        label="操作时间"
+                        prop="name"
+                        label="模板名称"
                         width="180">
                         width="180">
                 </el-table-column>
                 </el-table-column>
                 <el-table-column
                 <el-table-column
                         :resizable = "false"
                         :resizable = "false"
-                        prop="typeCn"
-                        label="标签归属">
-                </el-table-column>
-                <el-table-column
-                        :resizable = "false"
-                        prop="tagTypeCn"
-                        label="标签类型">
-                </el-table-column>
-                <el-table-column
-                        :resizable = "false"
-                        prop="tagName"
-                        label="标签系统名称">
-                </el-table-column>
-                <el-table-column
-                    :resizable = "false"
-                    label="是否存在于标准术语中">
-                    <template slot-scope="scope">
-                        <span v-if="scope.row.itemType == 0 && scope.row.type != 5">
-                            {{scope.row.exist ? "系统名称已存在" : "系统名称未存在"}}
-                        </span>
-                         <span v-if="scope.row.type == 5">
-                            {{scope.row.exist ? "界面名称已存在" : "界面名称未存在"}}
-                        </span>
-                    </template>
+                        prop="modeId"
+                        label="数据模块">
                 </el-table-column>
                 </el-table-column>
+                
                 <el-table-column
                 <el-table-column
                         :resizable = "false"
                         :resizable = "false"
-                        prop="modifier"
-                        label="操作人">
+                        prop="hospitalId"
+                        label="所属医院">
                 </el-table-column>
                 </el-table-column>
                 <el-table-column
                 <el-table-column
                         :resizable = "false"
                         :resizable = "false"
@@ -108,7 +89,7 @@
         searched: false,
         searched: false,
         filter: {
         filter: {
           modeName: '', //模板名称
           modeName: '', //模板名称
-          modeId: [],//模板Id
+          modeId: '',//模板Id
           hospitalName: '', //所属医院
           hospitalName: '', //所属医院
         },
         },
         currentPage: 1,
         currentPage: 1,
@@ -158,7 +139,7 @@
         api.getQCTemplist(param).then((res) => {
         api.getQCTemplist(param).then((res) => {
           loading.close()
           loading.close()
           console.log('res.', res)
           console.log('res.', res)
-          // this.list = list;
+          this.list = res.data.data.records;
           this.total = res.data.data.total;
           this.total = res.data.data.total;
           if(this.inCurrentPage!==undefined){
           if(this.inCurrentPage!==undefined){
             this.currentPage=this.inCurrentPage;
             this.currentPage=this.inCurrentPage;