Explorar o código

关联维护-弹窗通用组件

zhouna %!s(int64=4) %!d(string=hai) anos
pai
achega
677d1a1fd9

+ 291 - 0
src/components/base/LinkContent.vue

@@ -0,0 +1,291 @@
+<!----关联维护弹窗内容组件---->
+<template>
+    <el-form
+            :model="form"
+            :rules="rules"
+            label-position="right"
+            label-width="110px"
+            ref="innerForm"
+    >
+        <div class="AddChemicalAndCommonMappingBox clearfix">
+            <div class="titleBox clearfix">
+                <p class="title">医院术语</p>
+                <p class="title">标准术语</p>
+            </div>
+            <div class="leftBox clearfix">
+                <el-form-item :label="labelName+':'" prop="hisName">
+                    <el-input v-model.trim="form.hisName" clearable></el-input>
+                </el-form-item>
+                <el-form-item :label="labelName+'预览:'">
+                    <span class="previewInfo">{{form.hisName}}</span>
+                </el-form-item>
+            </div>
+            <div class="midBox">
+                <img class="midLogo" src="../../images/relation.png" alt />
+                <p class="midTitle">相互关联</p>
+            </div>
+            <div class="rightBox">
+                <el-form-item :label="labelName+':'" prop="searchText">
+                    <el-select
+                            v-model="form.searchText"
+                            filterable
+                            remote
+                            clearable
+                            :loading="showDrop"
+                            loading-text="加载中..."
+                            @change="changeWord"
+                            @visible-change="handleVisible"
+                            placeholder="搜索"
+                            :remote-method="searchTerms"
+                            reserve-keyword
+                    >
+                        <el-option
+                                v-for="item in uniqueNameList"
+                                :key="item.icd10Code"
+                                :label="item.name"
+                                :value="item"
+                                :title="item.name"
+                        ></el-option>
+                    </el-select>
+                </el-form-item>
+                <el-form-item :label="labelName+'预览:'">
+                    <!-- <span class="previewInfo">{{!isEdit ? form.searchText.name : form.searchText}}</span> -->
+                    <span class="previewInfo" style="minWidth: 240px">{{form.searchText}}</span>
+                </el-form-item>
+                <el-form-item label="ICD编码:">
+                    <span class="previewInfo" style="minWidth: 240px">{{form.icdCode}}</span>
+                </el-form-item>
+            </div>
+        </div>
+        <div class="linked-words">
+            <label>已关联术语:</label>
+            <span>{{linkedWords}}</span>
+        </div>
+    </el-form>
+</template>
+<style lang="less" scoped>
+    .AddChemicalAndCommonMappingBox{
+    /deep/ .el-form-item{
+        height: 30px;
+        margin-bottom: 10px;
+    .el-form-item__content,.el-form-item__label,.el-input,.el-input__inner{
+        height: 30px;
+        line-height: initial;
+        border-radius: 0;
+    }
+    .el-form-item__label[for]{
+        line-height: 30px;
+    }
+    .el-form-item__content{
+        color: #333;
+    }
+    }
+    .leftBox /deep/ .el-input__suffix{
+        top:-4px;
+    }
+    .rightBox /deep/ .el-input__suffix{
+        top:5px;
+    }
+    }
+
+    .topBack {
+        top: 0;
+    }
+    .titleBox {
+        padding: 0 0 10px 0px;
+    }
+    .title {
+        width: 50%;
+        float: left;
+        font-size: 14px;
+    }
+    .leftBox,
+    .midBox,
+    .rightBox {
+        width: 336px;
+        float: left;
+        height: 330px;
+        font-size: 14px;
+    }
+    .midBox {
+        width: 59px;
+        padding: 50px 0 0 0;
+        text-align: center;
+    }
+    .midTitle {
+        width: 40px;
+        margin: 0 auto;
+        color: #8B8B8B;
+    }
+    .midLogo {
+        margin: 0 auto;
+    }
+    .leftBox,
+    .rightBox {
+        border: 1px solid #dcdfe6;
+        padding: 20px;
+    }
+    .itemLabel {
+        width: 100%;
+        min-height: 50px;
+        line-height: 50px;
+        position: relative;
+    }
+    .itemLabelName,
+    .searchInput,
+    .searchName {
+        float: left;
+        color: #606266;
+    }
+    .itemLabelName {
+        width: 150px;
+    }
+    .isRequired::before {
+        content: '*';
+        color: red;
+    }
+    .searchInput,
+    .mealNameItem {
+        padding: 0 5px;
+    }
+    .searchInput,
+    .searchName {
+        display: inline-block;
+        height: 32px;
+        line-height: 32px;
+        border: 1px solid #a9a9a9;
+        margin: 8px 0 0 0;
+    }
+
+    .searchName {
+        text-align: center;
+        border-left: none;
+        cursor: pointer;
+        padding: 0 12px;
+        font-size: 16px;
+    }
+    .itemList {
+        position: absolute;
+        background: #fff;
+        width: 162px;
+        max-height: 150px;
+        border: 1px solid #a9a9a9;
+        left: 150px;
+        top: 42px;
+        z-index: 2;
+        overflow-y: auto;
+    }
+    .itemList {
+        width: calc(100% - 131px);
+    }
+    .mealNameItem {
+        height: 30px;
+        line-height: 30px;
+        font-size: 14px;
+        cursor: pointer;
+    }
+    .mealNameItem:hover {
+        background: #f5f7fa;
+    }
+    .previewInfo {
+        padding-left: 4px;
+        display: inline-block;
+        overflow: hidden;
+        word-wrap: break-word;
+        word-break: break-all;
+    }
+    .sumbit {
+        position: absolute;
+        display: inline-block;
+        width: 80px;
+        height: 30px;
+        line-height: 30px;
+        border: 1px solid #a9a9a9;
+        text-align: center;
+        right: 100px;
+    }
+    .confirmRealation {
+    .cancelButton {
+        border: 1px solid #a9a9a9;
+    span {
+        color: #606266;
+    }
+    }
+    }
+    .linked-words{
+        font-size: 14px;
+        color: #333;
+        font-weight: bold;
+    }
+</style>
+<script>
+    import api from '@api/cdss.js';
+    export default {
+        props:['labelName','form'],
+        data:function () {
+            return {
+                linkedWords:'',   //已关联术语
+                isEdit: false,
+                editId: '',
+                uniqueNameList: [],
+                /*form: {
+                    searchText: '', //搜索字段
+                    hisName: '',
+                    icdCode: ''
+                },*/
+
+                rules: {
+                    hisName: [
+                        { required: true, message: '请输入诊断名称', trigger: 'change' },
+                        { max: 80, message: '诊断名称最多80字', trigger: 'change' }
+                    ],
+                    searchText: [
+                        { required: true, message: '请选择诊断名称', trigger: 'change' }
+                    ]
+                },
+                saveDisable: false, //保存按钮禁止点击
+                showDrop: false, //下拉框显示文字
+            }
+        },
+        methods:{
+
+            // 搜索列表
+            searchTerms(query) {
+                if (!query) {
+                    this.uniqueNameList = [];
+                    return;
+                }
+                this.showDrop = true;
+                let params = {
+                    type: 4, //诊断
+                    inputStr: query,
+                    sex: 3,
+                    age: 0
+                };
+                api.retrievalSearch(params).then(res => {
+                    this.showDrop = false;
+                    if (res.data.code === '0') {
+                        this.uniqueNameList = res.data.data.diseaseNames;
+                    }
+                });
+            },
+            changeWord(newValue) {
+                this.form.searchText = newValue.name;
+                this.form.icdCode = newValue.icd10Code;
+            },
+
+            handleVisible(flag) {
+                if (!flag) {
+                    this.uniqueNameList = [];
+                }
+            },
+            warning(msg, type) {
+                this.$message({
+                    showClose: true,
+                    message: msg,
+                    type: type || 'warning'
+                });
+            }
+        }
+    }
+</script>

+ 10 - 7
src/components/base/LtModal.vue

@@ -1,3 +1,4 @@
+<!----通用弹窗组件---->
 <template>
     <div class="modal-container">
         <div class="cover"></div>
@@ -9,7 +10,7 @@
                 <slot></slot>
             </div>
             <div class="modal-footer">
-                <a class="confirm btn">确定</a>
+                <a class="confirm btn" @click="confirm()">确定</a>
                 <a class="cancel btn" @click="close()">取消</a>
             </div>
         </div>
@@ -20,12 +21,14 @@
         name:'lt-modal',
         data:function(){
             return{
-
             }
         },
         methods:{
             close(){
                 this.$emit("close");
+            },
+            confirm(){
+                this.$emit("confirm");
             }
         }
     }
@@ -46,13 +49,13 @@
     }
     .modal-box{
         width: 860px;
-        height: 514px;
+        height: 564px;
         background: #fff;
         position: absolute;
         left: 50%;
         top:50%;
         margin-left: -430px;
-        margin-top: -257px;
+        margin-top: -282px;
         .modal-title{
             height: 40px;
             background: #E3EAF4;
@@ -82,11 +85,11 @@
             margin-left: 40px;
         }
         .modal-body{
-            padding:34px 22px ;
+            padding:20px 22px ;
         }
         .modal-footer{
-            position: absolute;
-            bottom: 60px;
+            /*position: absolute;
+            bottom: 32px;*/
             width: 100%;
             text-align: center;
         }

+ 0 - 17
src/components/cdssManage/disease/AddDisease.vue

@@ -229,23 +229,6 @@ export default {
         this.saveDisable = false;
       });
     },
-    // 关联已存在模态框
-    showConfirmDialog(msg, resolve) {
-      this.$alert(msg, '提示', {
-        // customClass: 'confirmRealation',
-        confirmButtonText: '是',
-        // cancelButtonText: '否',
-        // cancelButtonClass: 'cancelButton',
-        type: 'warning'
-      })
-        .then(() => {
-          resolve();
-        })
-        .catch(() => {
-          this.saveDisable = false;
-          this.warning('建立失败', 'error');
-        });
-    },
     warning(msg, type) {
       this.$message({
         showClose: true,

+ 30 - 302
src/components/cdssManage/disease/Disease.vue

@@ -72,74 +72,7 @@
       </div>
     </div>
     <LtModal v-if="modalVisiable" :disabled="saveDisable" @confirm="submitForm" @close="closeModal">
-      <el-form
-              :model="form"
-              :rules="rules"
-              label-position="right"
-              label-width="120px"
-              ref="relationForm"
-      >
-        <div class="AddChemicalAndCommonMappingBox clearfix">
-          <div class="titleBox clearfix">
-            <p class="title">医院术语</p>
-            <p class="title">标准术语</p>
-          </div>
-          <div class="leftBox clearfix">
-            <el-row>
-              <el-col :span="16">
-                <el-form-item label="诊断名称:" prop="hisName">
-                  <el-input v-model.trim="form.hisName" clearable style="minWidth: 240px"></el-input>
-                </el-form-item>
-                <el-form-item label="诊断名称预览:">
-                  <span class="previewInfo" style="minWidth: 240px">{{form.hisName}}</span>
-                </el-form-item>
-              </el-col>
-            </el-row>
-          </div>
-          <div class="midBox">
-            <img class="midLogo" src="../../../images/relation.png" alt />
-            <p class="midTitle">相互关联</p>
-          </div>
-          <div class="rightBox">
-            <el-row>
-              <el-col :span="16">
-                <el-form-item label="诊断名称:" prop="searchText">
-                  <el-select
-                          style="width:100%;minWidth: 240px"
-                          v-model="form.searchText"
-                          filterable
-                          remote
-                          clearable
-                          :loading="showDrop"
-                          loading-text="加载中..."
-                          @change="changeWord"
-                          @focus="handleFocus"
-                          @visible-change="handleVisible"
-                          placeholder="搜索"
-                          :remote-method="searchTerms"
-                          reserve-keyword
-                  >
-                    <el-option
-                            v-for="item in uniqueNameList"
-                            :key="item.icd10Code"
-                            :label="item.name"
-                            :value="item"
-                            :title="item.name"
-                    ></el-option>
-                  </el-select>
-                </el-form-item>
-                <el-form-item label="诊断名称预览:">
-                  <!-- <span class="previewInfo">{{!isEdit ? form.searchText.name : form.searchText}}</span> -->
-                  <span class="previewInfo" style="minWidth: 240px">{{form.searchText}}</span>
-                </el-form-item>
-                <el-form-item label="ICD编码:">
-                  <span class="previewInfo" style="minWidth: 240px">{{form.icdCode}}</span>
-                </el-form-item>
-              </el-col>
-            </el-row>
-          </div>
-        </div>
-      </el-form>
+      <LinkContent :form="form" ref="relationForm" labelName="诊断名称"/>
     </LtModal>
   </div>
 </template>
@@ -149,6 +82,7 @@ import api from '@api/cdss.js';
 import config from '@api/config.js';
 import utils from '@api/utils.js';
 import LtModal from '@base/LtModal';
+import LinkContent from '@base/LinkContent';
 
 export default {
   name: 'Disease', //化验大小项和公表维护
@@ -168,33 +102,18 @@ export default {
       total: 0,
       uploadInfo: '导入',
       title: '诊断关联维护 | ',
-      hospitaiName: '',
-      hospitalId: '',
-      isEdit: false,
-      editId: '',
-      uniqueNameList: [],
-      form: {
+      modalVisiable:false,  //弹窗显示状态
+      saveDisable:false,    //确定按钮禁用状态
+      form:{
           searchText: '', //搜索字段
           hisName: '',
           icdCode: ''
-      },
-
-      rules: {
-          hisName: [
-              { required: true, message: '请输入诊断名称', trigger: 'change' },
-              { max: 80, message: '诊断名称最多80字', trigger: 'change' }
-          ],
-          searchText: [
-              { required: true, message: '请选择诊断名称', trigger: 'change' }
-          ]
-      },
-      saveDisable: false, //保存按钮禁止点击
-      showDrop: false, //下拉框显示文字
-      modalVisiable:false,
+      }
     };
   },
   components:{
-      LtModal
+      LtModal,
+      LinkContent
   },
   created() {
     const { data } = this.$route.params;
@@ -547,71 +466,31 @@ export default {
       let inp = document.getElementById('upFile');
       inp.value = '';
     },
-    /********新增编辑弹窗**********/
-
-    // 搜索列表
-    searchTerms(query) {
-        if (!query) {
-            this.uniqueNameList = [];
-            return;
-        }
-        this.showDrop = true;
-        let params = {
-            type: 4, //诊断
-            inputStr: query,
-            sex: 3,
-            age: 0
-        };
-        api.retrievalSearch(params).then(res => {
-            this.showDrop = false;
-            if (res.data.code === '0') {
-                this.uniqueNameList = res.data.data.diseaseNames;
+    showModal(){
+        this.modalVisiable=true
+    },
+    closeModal(){
+        this.modalVisiable=false
+    },
+    // 建立关联-参数处理
+    submitForm() {
+        console.log(this.$refs)
+        this.$refs.relationForm.$refs.innerForm.validate(valid => {
+            if (valid) {
+                const { searchText, hisName, icdCode } = this.form;
+                let params = {
+                    hisName: hisName,
+                    uniqueName: searchText,
+                    icdCode: icdCode,
+                    hospitalId: this.hospitalId
+                };
+                this.showSaveDialog(params);
+            } else {
+                console.log('error submit!!');
+                return false;
             }
         });
     },
-      changeWord(newValue) {
-          this.form.searchText = newValue.name;
-          this.form.icdCode = newValue.icd10Code;
-      },
-
-      handleVisible(flag) {
-          if (!flag) {
-              this.uniqueNameList = [];
-          }
-      },
-      // 获取焦点
-      handleFocus() {},
-
-      // 初始化表单数据
-      initForm() {
-          this.form.hisName = '';
-          this.form.searchText = '';
-          this.form.icdCode = '';
-      },
-      showModal(){
-          this.modalVisiable=true
-      },
-      closeModal(){
-        this.modalVisiable=false
-      },
-      // 建立关联-参数处理
-      submitForm() {
-          this.$refs.relationForm.validate(valid => {
-              if (valid) {
-                  const { searchText, hisName, icdCode } = this.form;
-                  let params = {
-                      hisName: hisName,
-                      uniqueName: searchText,
-                      icdCode: icdCode,
-                      hospitalId: this.hospitalId
-                  };
-                  this.showSaveDialog(params);
-              } else {
-                  console.log('error submit!!');
-                  return false;
-              }
-          });
-      },
       // 建立关联-映射关系是否已存在
       showSaveDialog(params) {
           this.saveDisable = true; //提交保存按钮不可点击,返回结果时才可点击,防止频繁发送请求
@@ -657,30 +536,6 @@ export default {
               this.saveDisable = false;
           });
       },
-      // 关联已存在模态框
-      showConfirmDialog(msg, resolve) {
-          this.$alert(msg, '提示', {
-              // customClass: 'confirmRealation',
-              confirmButtonText: '是',
-              // cancelButtonText: '否',
-              // cancelButtonClass: 'cancelButton',
-              type: 'warning'
-          })
-              .then(() => {
-                  resolve();
-              })
-              .catch(() => {
-                  this.saveDisable = false;
-                  this.warning('建立失败', 'error');
-              });
-      },
-      warning(msg, type) {
-          this.$message({
-              showClose: true,
-              message: msg,
-              type: type || 'warning'
-          });
-      }
   }
 };
 </script>
@@ -757,131 +612,4 @@ export default {
 .contentsOther {
   padding: 0 20px;
 }
-/*********新增编辑***********/
-  .topBack {
-    top: 0;
-  }
-  .titleBox {
-    padding: 0 0 10px 0px;
-  }
-  .title {
-    width: 50%;
-    float: left;
-    font-size: 14px;
-  }
-  .leftBox,
-  .midBox,
-  .rightBox {
-    width: 361px;
-    float: left;
-    min-height: 200px;
-    font-size: 14px;
-  }
-  .midBox {
-    width: 6%;
-    padding: 50px 0 0 0;
-    text-align: center;
-  }
-  .midTitle {
-    width: 40px;
-    margin: 0 auto;
-  }
-  .midLogo {
-    margin: 0 auto;
-  }
-  .leftBox,
-  .rightBox {
-    border: 1px solid #dcdfe6;
-    padding: 20px 10px;
-  }
-  .itemLabel {
-    width: 100%;
-    min-height: 50px;
-    line-height: 50px;
-    position: relative;
-  }
-  .itemLabelName,
-  .searchInput,
-  .searchName {
-    float: left;
-    color: #606266;
-  }
-  .itemLabelName {
-    width: 150px;
-  }
-  .isRequired::before {
-    content: '*';
-    color: red;
-  }
-  .searchInput,
-  .mealNameItem {
-    padding: 0 5px;
-  }
-  .searchInput,
-  .searchName {
-    display: inline-block;
-    height: 32px;
-    line-height: 32px;
-    border: 1px solid #a9a9a9;
-    margin: 8px 0 0 0;
-  }
-
-  .searchName {
-    text-align: center;
-    border-left: none;
-    cursor: pointer;
-    padding: 0 12px;
-    font-size: 16px;
-  }
-  .itemList {
-    position: absolute;
-    background: #fff;
-    width: 162px;
-    max-height: 150px;
-    border: 1px solid #a9a9a9;
-    left: 150px;
-    top: 42px;
-    z-index: 2;
-    overflow-y: auto;
-  }
-  .itemList {
-    width: calc(100% - 131px);
-  }
-  .mealNameItem {
-    height: 30px;
-    line-height: 30px;
-    font-size: 14px;
-    cursor: pointer;
-  }
-  .mealNameItem:hover {
-    background: #f5f7fa;
-  }
-  .previewInfo {
-    padding-left: 4px;
-    display: inline-block;
-    margin-top: 8px;
-    // width: calc(100% - 160px);s
-    line-height: 24px;
-    overflow: hidden;
-    word-wrap: break-word;
-    word-break: break-all;
-  }
-  .sumbit {
-    position: absolute;
-    display: inline-block;
-    width: 80px;
-    height: 30px;
-    line-height: 30px;
-    border: 1px solid #a9a9a9;
-    text-align: center;
-    right: 100px;
-  }
-.confirmRealation {
-  .cancelButton {
-    border: 1px solid #a9a9a9;
-    span {
-      color: #606266;
-    }
-  }
-}
 </style>

+ 89 - 18
src/components/cdssManage/drug/DrugManage.vue

@@ -61,6 +61,9 @@
         ></el-pagination>
       </div>
     </div>
+    <LtModal v-if="modalVisiable" :disabled="saveDisable" @confirm="submitForm" @close="closeModal">
+      <LinkContent :form="form" ref="relationForm" labelName="药品名称"/>
+    </LtModal>
   </div>
 </template>
 
@@ -68,9 +71,15 @@
 import api from '@api/cdss.js';
 import config from '@api/config.js';
 import utils from '@api/utils.js';
+import LtModal from '@base/LtModal';
+import LinkContent from '@base/LinkContent';
 
 export default {
   name: 'DrugManage', //化验大小项和公表维护
+  components:{
+      LtModal,
+      LinkContent
+  },
   data: function() {
     return {
       list: [],
@@ -87,7 +96,14 @@ export default {
       uploadInfo: '导入',
       title: '药品关联维护 | ',
       hospitaiName: '',
-      hospitalId: ''
+      hospitalId: '',
+      modalVisiable:false,  //弹窗显示状态
+      saveDisable:false,    //确定按钮禁用状态
+      form:{
+          searchText: '', //搜索字段
+          hisName: '',
+          icdCode: ''
+      }
     };
   },
   created() {
@@ -233,14 +249,7 @@ export default {
             filter: this.filter
           }
         : { currentPage: this.currentPage, pageSize: this.pageSize };
-      this.$router.push({
-        name: 'AddDrug',
-        params: Object.assign(pam, {
-          isEdit: false,
-          data: { hospitalId: this.hospitalId },
-          hospitaiName: this.hospitaiName
-        })
-      });
+        this.showModal()
     },
     // 修改诊断关联-跳转至编辑页面
     modifyRelation(row) {
@@ -252,14 +261,7 @@ export default {
             filter: this.filter
           }
         : { currentPage: this.currentPage, pageSize: this.pageSize };
-      this.$router.push({
-        name: 'AddDrug',
-        params: Object.assign(pam, {
-          isEdit: true,
-          data: { ...item, hospitalId: this.hospitalId },
-          hospitaiName: this.hospitaiName
-        })
-      });
+        this.showModal()
     },
     currentChange(next) {
       this.currentPage = next;
@@ -455,7 +457,76 @@ export default {
       //解决上传相同文件不触发change
       let inp = document.getElementById('upFile');
       inp.value = '';
-    }
+    },
+    showModal(){
+        this.modalVisiable=true
+    },
+    closeModal(){
+        this.modalVisiable=false
+    },
+    // 建立关联-参数处理
+    submitForm() {
+        this.$refs.relationForm.validate(valid => {
+            if (valid) {
+                const { searchText, hisName, form } = this.form;
+                let params = {
+                    hisName: hisName,
+                    uniqueName: searchText,
+                    form: form,
+                    hospitalId: this.hospitalId
+                };
+                this.showSaveDialog(params);
+            } else {
+                console.log('error submit!!');
+                return false;
+            }
+        });
+    },
+    // 建立关联-映射关系是否已存在
+    showSaveDialog(params) {
+        this.saveDisable = true; //提交保存按钮不可点击,返回结果时才可点击,防止频繁发送请求
+        api
+            .drugIsExistRecord(params)
+            .then(res => {
+                if (!res.data.data) {
+                    // 不存在,创建新的关联
+                    // 如果是编辑时,需要携带id
+                    if (this.isEdit) {
+                        params = { ...params, id: this.editId };
+                    }
+                    this.saveLisMapping(params, '保存成功', 'success');
+                } else {
+                    // 已存在,提示修改
+                    this.warning('该条关联已存在,无法添加');
+                    this.saveDisable = false;
+                }
+            })
+            .catch(err => {
+                if (err.code === '900010001') {
+                    return false;
+                }
+                this.warning(err);
+            });
+    },
+
+    // 映射关系不存在-建立关联
+    saveLisMapping(params, msg, type) {
+        api.saveOrUpdateDrugRecord(params).then(res => {
+            if (res.data.code === '0') {
+                this.warning(res.data.msg || msg, type);
+                this.initForm();
+                this.$router.push({
+                    name: 'DrugManage',
+                    params: Object.assign({}, this.$route.params, {
+                        currentPage: 1
+                    })
+                });
+            } else {
+                this.warning(res.data.msg);
+            }
+            this.saveDisable = false;
+        });
+    },
   }
 };
 </script>