Browse Source

删除空行

1178232204@qq.com 3 years ago
parent
commit
5ce2717f5b
1 changed files with 41 additions and 40 deletions
  1. 41 40
      src/components/cdssManage/hospital/AddHospital.vue

+ 41 - 40
src/components/cdssManage/hospital/AddHospital.vue

@@ -12,11 +12,7 @@
           <el-form ref="form" :model="form" label-width="110px" :rules="rules">
             <el-row :gutter="20">
               <el-col :span="12">
-                <el-form-item
-                  label="医院名称"
-                  prop="hospitalName"
-                  style="width:100%"
-                >
+                <el-form-item label="医院名称" prop="hospitalName" style="width:100%">
                   <el-input
                     v-model="form.hospitalName"
                     placeholder="2-30位,可输入汉字、字母、数字和下划线"
@@ -38,8 +34,10 @@
             <el-form-item label="医院地址" prop="address">
               <el-input v-model="form.address" placeholder="请输入医院地址"></el-input>
             </el-form-item>
-            <p style="text-align: center;padding-bottom: 14px;width: 100%;font-size:16px;font-weight: bold;">关联子医院</p>
-            <el-form-item >
+            <p
+              style="text-align: center;padding-bottom: 14px;width: 100%;font-size:16px;font-weight: bold;"
+            >关联子医院</p>
+            <el-form-item>
               <el-table
                 size="mini"
                 :data="form.hospitalRelationVOList"
@@ -88,7 +86,7 @@
                       <el-input
                         class="inp-name"
                         placeholder="请输入医院名称"
-                        maxlength="100"
+                        maxlength="50"
                         v-model.trim="form.hospitalRelationVOList[scope.$index].name"
                       ></el-input>
                     </el-form-item>
@@ -109,7 +107,7 @@
                       <el-input
                         class="inp-name"
                         placeholder="请输入编码"
-                        maxlength="100"
+                        maxlength="50"
                         v-model.trim="form.hospitalRelationVOList[scope.$index].code"
                       ></el-input>
                     </el-form-item>
@@ -160,53 +158,53 @@
 </template>
 
 <script>
-import api from "@api/cdss.js";
-import pinyin from "../../../js/Convert_Pinyin.js";
+import api from '@api/cdss.js';
+import pinyin from '../../../js/Convert_Pinyin.js';
 export default {
-  name: "AddHospital",
+  name: 'AddHospital',
   data() {
     var numreg = /^[a-zA-Z0-9_\u4e00-\u9fa5]+$/;
     var numreg1 = /^[0-9a-zA-Z_]{1,}$/;
     var validatePass = (rule, value, callback) => {
       if (!numreg.test(value)) {
-        callback(new Error("汉字、字母、数字和下划线"));
+        callback(new Error('汉字、字母、数字和下划线'));
       } else {
         callback();
       }
     };
     var validatePass1 = (rule, value, callback) => {
       if (!numreg1.test(value)) {
-        callback(new Error("字母、数字和下划线"));
+        callback(new Error('字母、数字和下划线'));
       } else {
         callback();
       }
     };
     return {
       form: {
-        hospitalName: "",
-        spell: "",
+        hospitalName: '',
+        spell: '',
         // hospitalCode: '',
-        address: "",
+        address: '',
         hospitalRelationVOList: []
       },
       tableData: [],
       rules: {
         hospitalName: [
-          { required: true, message: "医院名称不能为空", trigger: "change" },
-          { min: 2, max: 30, message: "长度2-30位", trigger: "blur" },
-          { required: true, validator: validatePass, trigger: "blur" }
+          { required: true, message: '医院名称不能为空', trigger: 'change' },
+          { min: 2, max: 30, message: '长度2-30位', trigger: 'blur' },
+          { required: true, validator: validatePass, trigger: 'blur' }
         ],
         // hospitalCode: [
         //   { required: true, message: '医院编码不能为空', trigger: 'change' },
         //   { min: 4, max: 15, message: '长度4-15位', trigger: 'blur' },
         //   { required: true, validator: validatePass1, trigger: 'blur' }
         // ],
-        address: [{ max: 200, message: "长度最多200字", trigger: "change" }],
+        address: [{ max: 200, message: '长度最多200字', trigger: 'change' }],
         spell: [
-          { max: 30, message: "医院名称拼音长度最多30位", trigger: "change" }
+          { max: 30, message: '医院名称拼音长度最多30位', trigger: 'change' }
         ]
       },
-      hospitalId: "",
+      hospitalId: '',
       isEdit: false,
       saveDisable: false,
       dialogVisible: false,
@@ -229,7 +227,7 @@ export default {
   methods: {
     getByhospitalInfoId(id) {
       api.getByhospitalInfoId({ id: id }).then(res => {
-        if (res.data.code === "0") {
+        if (res.data.code === '0') {
           const data = res.data.data;
           data.hospitalRelationDTOList.forEach((item, index) => {
             item.errorOther = false;
@@ -241,6 +239,13 @@ export default {
     },
     onSubmit() {
       this.$refs.form.validate(valid => {
+        this.form.hospitalRelationVOList.forEach((item, index) => {
+          if (item.name == '' && item.code == '') {
+            this.form.hospitalRelationVOList.splice(index, 1);
+          }
+          item.errorOther = false;
+          item.errorCurrent = false;
+        });
         if (valid) {
           this.saveDisable = true;
           let params = {
@@ -251,31 +256,27 @@ export default {
             hospitalRelationVOList: this.form.hospitalRelationVOList
             // code: this.form.hospitalCode
           };
-          this.form.hospitalRelationVOList.forEach((item, index) => {
-            item.errorOther = false;
-            item.errorCurrent = false;
-          });
           if (this.isEdit) {
             params = Object.assign({}, params, {
               id: this.hospitalId
             });
           }
           api.saveOrUpdateHosRecordCDSS(params).then(res => {
-            if (res.data.code === "0") {
+            if (res.data.code === '0') {
               this.$message({
                 showClose: true,
-                message: "保存成功",
-                type: "success",
+                message: '保存成功',
+                type: 'success',
                 duration: 1000
               });
               this.isSaveSuccess = true; // 保存成功,可正常退出
               this.$router.push({
-                name: "HospitalCDSS",
+                name: 'HospitalCDSS',
                 params: Object.assign({}, this.$route.params, {
                   currentPage: 1
                 })
               });
-            } else if (res.data.code === "20020009") {
+            } else if (res.data.code === '20020009') {
               const data = res.data.data;
               this.dialogVisible = true;
               let errorOtherList = [];
@@ -292,7 +293,7 @@ export default {
               this.$message({
                 showClose: true,
                 message: res.data.msg,
-                type: "error",
+                type: 'error',
                 duration: 1000
               });
             }
@@ -315,16 +316,16 @@ export default {
     },
     add() {
       this.form.hospitalRelationVOList.push({
-        name: "",
-        code: "",
+        name: '',
+        code: '',
         errorOther: false,
         errorCurrent: false
       });
     },
     addIndex(i) {
       this.form.hospitalRelationVOList.splice(i + 1, 0, {
-        name: "",
-        code: "",
+        name: '',
+        code: '',
         errorOther: false,
         errorCurrent: false
       });
@@ -465,7 +466,7 @@ export default {
     height: 32px;
     margin-bottom: 18px;
   }
-  /deep/ .is-error .el-form-item__error{
+  /deep/ .is-error .el-form-item__error {
     top: 34px;
   }
   .operation {
@@ -498,7 +499,7 @@ export default {
   .diag-title {
     font-size: 16px;
     margin-bottom: 5px;
-    color: #FF545B;
+    color: #ff545b;
   }
   .title-warning {
     display: block;