瀏覽代碼

提示语优化

wyq 4 年之前
父節點
當前提交
5ce3064a25

+ 6 - 7
src/components/knowledgeExtra/AddNewRule.vue

@@ -218,11 +218,12 @@
               </el-select>
             </el-form-item>
           </div>
-          <div
+          <!-- <div
             class="table_cell"
             style="flex: 3; max-width: 50%"
             v-if="showMsg"
           >
+          
             <el-form-item
               label-width="130px"
               label="附加信息:"
@@ -236,7 +237,7 @@
                 v-model.trim="form.parMsg"
               ></el-input>
             </el-form-item>
-          </div>
+          </div> -->
         </div>
         <!-- 表格 -->
         <AddNewRuleTable
@@ -244,6 +245,7 @@
           v-if="form.parHasSub && tableShow"
           :klRuleByIdSub="form.klRuleByIdSub"
           :maxNum="subRuleMaxNum"
+          :showMsg="showMsg"
           @subTypeChange="subTypeChange"
           @searchConcept="searchConcept"
           @addGroup="addGroup"
@@ -299,7 +301,6 @@ export default {
         parLenName: "",
         parHasSub: undefined,
         parLenCode: "",
-        parMsg: "",
         klRuleByIdSub: []
       },
       rules: formRules
@@ -387,7 +388,6 @@ export default {
     },
     // 提交
     submitForm(formName) {
-      console.log(this.form);
       this.$refs[formName].validate((valid) => {
         if (valid) {
           let params = JSON.parse(JSON.stringify(this.form));
@@ -399,6 +399,7 @@ export default {
             } else {
               if (item.groupId == arr[i - 1].groupId) {
                 item.groupType = arr[i - 1].groupType;
+                item.subMsg = arr[i - 1].subMsg;
               } else {
                 item.groupType = arr[i - 1].groupType + 1;
               }
@@ -429,7 +430,6 @@ export default {
     // table_form 规则类型选中
     ruleTypeChange(val) {
       this.form.parLenCode = "";
-      this.form.parMsg = "";
       const obj = this.ruleTypeList.find((it) => it.id === val);
       this.ruleTermTypeList = obj.subMenuList;
       this.subRuleMaxNum = undefined;
@@ -437,7 +437,6 @@ export default {
     },
     // table_form 规则术语类型选中
     ruleTermChange(val) {
-      this.form.parMsg = "";
       const obj = this.ruleTermTypeList.find((it) => it.code === val);
       this.form.parLenName = obj.name;
       this.baseTypeList = obj.subMenuList;
@@ -775,7 +774,7 @@ export default {
       return Object.keys(this.firstPlace || {}).length > 0;
     },
     ruleTermCodeStr: function () {
-      const str = this.form.parRuleType + "-" + this.form.parLenCode;
+      const str = this.form.parRuleType + "-" + this.form.parLenCode+ "-" + 1;
       if (str.length <= 1) {
         return "";
       }

+ 97 - 102
src/components/knowledgeExtra/AddNewRuleTable.vue

@@ -69,7 +69,7 @@
   .custom_table_header {
     vertical-align: middle;
     &::before {
-      content: "*";
+      content: '*';
       color: red;
       font-size: 12px;
       margin-right: 4px;
@@ -123,22 +123,33 @@
         <template slot-scope="scope">
           <div class="btn_box">
             <div class="btn_div">
-              <img
-                @click="addGroup(scope)"
-                src="../../images/add-new-rule-sub.png"
-                alt=""
-              />
+              <img @click="addGroup(scope)" src="../../images/add-new-rule-sub.png" alt />
             </div>
             <div class="btn_div" v-if="!isLastDate(scope.row.groupId)">
               <img
                 @click="$emit('delGroup', scope.row.groupId)"
                 src="../../images/add-new-rule-del.png"
-                alt=""
+                alt
               />
             </div>
           </div>
         </template>
       </el-table-column>
+      <el-table-column width="170px" label="附加信息" prop="subMsg" fixed="left">
+        <template slot="header" slot-scope="scope">
+          <div :class="showMsg?'custom_table_header':''">附加信息</div>
+        </template>
+        <template slot-scope="scope">
+          <el-form-item :prop="`klRuleByIdSub[${scope.$index}].subMsg`" :rules="showMsg?rules.subMsg:[]">
+            <el-input
+              type="textarea"
+              :rows="1"
+              placeholder="请输入附加信息"
+              v-model.trim="scope.row.subMsg"
+            ></el-input>
+          </el-form-item>
+        </template>
+      </el-table-column>
       <el-table-column
         width="80px"
         v-if="maxNum && maxNum > 1"
@@ -149,20 +160,13 @@
         <template slot-scope="scope">
           <div class="btn_box">
             <div class="btn_div" v-if="!isMax(scope.row.groupId)">
-              <img
-                @click="addChildGroup(scope)"
-                src="../../images/add-new-rule-sub.png"
-                alt=""
-              />
+              <img @click="addChildGroup(scope)" src="../../images/add-new-rule-sub.png" alt />
             </div>
-            <div
-              class="btn_div"
-              v-if="klRuleByIdSub.length > 1 && !scope.row.disabled"
-            >
+            <div class="btn_div" v-if="klRuleByIdSub.length > 1 && !scope.row.disabled">
               <img
                 @click="$emit('delGroupChild', scope.row.groupChildId)"
                 src="../../images/add-new-rule-del.png"
-                alt=""
+                alt
               />
             </div>
           </div>
@@ -213,8 +217,7 @@
                 :key="item.id"
                 :label="item.name"
                 :value="item.type"
-              >
-              </el-option>
+              ></el-option>
             </el-select>
           </el-form-item>
         </template>
@@ -244,8 +247,7 @@
                 :key="item.id"
                 :label="item.name"
                 :value="item.code"
-              >
-              </el-option>
+              ></el-option>
             </el-select>
           </el-form-item>
         </template>
@@ -275,13 +277,12 @@
                 :key="item.conceptId"
                 :label="item.conceptName"
                 :value="item.conceptId"
-              >
-              </el-option>
+              ></el-option>
             </el-select>
           </el-form-item>
         </template>
       </el-table-column>
-      <el-table-column label="规则具体内容" min-width="900px" prop="">
+      <el-table-column label="规则具体内容" min-width="900px" prop>
         <template slot-scope="scope">
           <div class="type_content">
             <el-form-item
@@ -299,8 +300,8 @@
                 "
                 :ref="`klRuleByIdSub[${scope.$index}].dataType`"
               >
-                <el-option label="数值类型" value="1"> </el-option>
-                <el-option label="文本类型" value="2"> </el-option>
+                <el-option label="数值类型" value="1"></el-option>
+                <el-option label="文本类型" value="2"></el-option>
               </el-select>
             </el-form-item>
             <!-- v-if="klRuleByIdSub[scope.$index].dataType === '1'" -->
@@ -342,8 +343,7 @@
                         :key="item.key"
                         :label="item.name"
                         :value="item.key"
-                      >
-                      </el-option>
+                      ></el-option>
                     </el-select>
                   </el-form-item>
                 </el-col>
@@ -369,9 +369,7 @@
                   </el-form-item>
                 </el-col>
                 <el-col :span="6">
-                  <el-form-item
-                    :prop="`klRuleByIdSub[${scope.$index}].subMaxUnit`"
-                  >
+                  <el-form-item :prop="`klRuleByIdSub[${scope.$index}].subMaxUnit`">
                     <el-input
                       type="text"
                       @focus="setScrollRight"
@@ -420,8 +418,7 @@
                         :key="item.name"
                         :label="item.name"
                         :value="item.name"
-                      >
-                      </el-option>
+                      ></el-option>
                     </el-select>
                   </el-form-item>
                 </el-col>
@@ -447,9 +444,7 @@
                   </el-form-item>
                 </el-col>
                 <el-col :span="6">
-                  <el-form-item
-                    :prop="`klRuleByIdSub[${scope.$index}].subMinUnit`"
-                  >
+                  <el-form-item :prop="`klRuleByIdSub[${scope.$index}].subMinUnit`">
                     <el-input
                       type="text"
                       @focus="setScrollRight"
@@ -461,10 +456,7 @@
               </el-row>
             </el-form-item>
             <!-- v-if="klRuleByIdSub[scope.$index].subType !== 6 && klRuleByIdSub[scope.$index].dataType === '2'" -->
-            <div
-              style="flex: 2"
-              v-if="scope.row.subType != 6 && scope.row.dataType == '2'"
-            >
+            <div style="flex: 2" v-if="scope.row.subType != 6 && scope.row.dataType == '2'">
               <el-form-item
                 class="type_content_item"
                 style="width: 100%"
@@ -534,21 +526,21 @@
 </template>
 
 <script>
-import api from "@api/knowledgeLib.js";
-import { tableRules } from "./rules";
+import api from '@api/knowledgeLib.js';
+import { tableRules } from './rules';
 export default {
-  name: "AddNewRuleTable",
+  name: 'AddNewRuleTable',
   data() {
     return {
-      numTypes: "",
-      subConceptIdIndex: "",
+      numTypes: '',
+      subConceptIdIndex: '',
       operMaxList: [
-        { name: "<=", key: "<=" },
-        { name: "<", key: "<" }
+        { name: '<=', key: '<=' },
+        { name: '<', key: '<' }
       ],
       operMinList: [
-        { name: ">", key: ">" },
-        { name: ">=", key: ">=" }
+        { name: '>', key: '>' },
+        { name: '>=', key: '>=' }
       ],
       rules: tableRules,
       theRef: null
@@ -562,20 +554,20 @@ export default {
     },
     maxChange(e, val, type) {
       if (
-        type === "i" &&
+        type === 'i' &&
         this.klRuleByIdSub[val].subMaxOperator &&
-        this.klRuleByIdSub[val].subMaxOperator != ""
+        this.klRuleByIdSub[val].subMaxOperator != ''
       ) {
-        this.$emit("clearValidate", [
+        this.$emit('clearValidate', [
           `klRuleByIdSub[${val}].subMinValue`,
           `klRuleByIdSub[${val}].subMinOperator`
         ]);
       } else if (
-        type === "s" &&
+        type === 's' &&
         this.klRuleByIdSub[val].subMaxValue &&
-        this.klRuleByIdSub[val].subMaxValue != ""
+        this.klRuleByIdSub[val].subMaxValue != ''
       ) {
-        this.$emit("clearValidate", [
+        this.$emit('clearValidate', [
           `klRuleByIdSub[${val}].subMinValue`,
           `klRuleByIdSub[${val}].subMinOperator`
         ]);
@@ -584,20 +576,20 @@ export default {
     },
     minChange(e, val, type) {
       if (
-        type === "i" &&
+        type === 'i' &&
         this.klRuleByIdSub[val].subMinOperator &&
-        this.klRuleByIdSub[val].subMinOperator != ""
+        this.klRuleByIdSub[val].subMinOperator != ''
       ) {
-        this.$emit("clearValidate", [
+        this.$emit('clearValidate', [
           `klRuleByIdSub[${val}].subMaxOperator`,
           `klRuleByIdSub[${val}].subMaxValue`
         ]);
       } else if (
-        type === "s" &&
+        type === 's' &&
         this.klRuleByIdSub[val].subMinValue &&
-        this.klRuleByIdSub[val].subMinValue != ""
+        this.klRuleByIdSub[val].subMinValue != ''
       ) {
-        this.$emit("clearValidate", [
+        this.$emit('clearValidate', [
           `klRuleByIdSub[${val}].subMaxOperator`,
           `klRuleByIdSub[${val}].subMaxValue`
         ]);
@@ -605,11 +597,11 @@ export default {
       this.setScrollRight();
     },
     addGroup(scope) {
-      this.$emit("addGroup", null, { groupId: scope.row.groupId });
+      this.$emit('addGroup', null, { groupId: scope.row.groupId });
       this.$refs.table.bodyWrapper.scrollLeft = 0;
     },
     addChildGroup(scope) {
-      this.$emit("addGroup", scope.row.groupId, { index: scope.$index });
+      this.$emit('addGroup', scope.row.groupId, { index: scope.$index });
       this.$refs.table.bodyWrapper.scrollLeft = 0;
     },
     scrollFun() {
@@ -626,15 +618,16 @@ export default {
     // },
     // cellStyle
     cellStyle({ row, column, rowIndex, columnIndex }) {
-      if (column.label == "组" || column.label == "基础规则") return {};
-      return { "vertical-align": "top", "padding-top": "14px" };
+      if (column.label == '组' || column.label == '基础规则') return {};
+      if (column.label == '附加信息') return {'padding-top': '14px'};
+      return { 'vertical-align': 'top', 'padding-top': '14px' };
     },
     // 最大值 选择rule
     subMaxOperator(scope, rule, value, callback) {
       const { subMaxValue, subMinOperator, subMinValue } = scope.row;
       const val = value + subMinOperator + subMinValue + subMaxValue;
-      if (!val || (!value && subMaxValue !== "")) {
-        callback(new Error("最大值和最小值至少完整填写一个,单位不必填"));
+      if (!val || (!value && subMaxValue !== '')) {
+        callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
       } else {
         callback();
       }
@@ -644,10 +637,10 @@ export default {
       const { subMaxOperator, subMinOperator, subMinValue } = scope.row;
       const val = value + subMaxOperator + subMinValue + subMinOperator;
       const isNum = /^(\-|\+)?\d+(\.\d+)?$/.test(value);
-      if (!val || (value == "" && subMaxOperator)) {
-        callback(new Error("最大值和最小值至少完整填写一个,单位不必填"));
-      } else if (value !== "" && !isNum) {
-        callback(new Error("只能输入数字"));
+      if (!val || (value == '' && subMaxOperator)) {
+        callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
+      } else if (value !== '' && !isNum) {
+        callback(new Error('只能输入数字'));
       } else {
         callback();
       }
@@ -656,8 +649,8 @@ export default {
     subMinOperatorRule(scope, rule, value, callback) {
       const { subMaxValue, subMaxOperator, subMinValue } = scope.row;
       const val = value + subMaxOperator + subMinValue + subMaxValue;
-      if (!val || (!value && subMinValue !== "")) {
-        callback(new Error("最大值和最小值至少完整填写一个,单位不必填"));
+      if (!val || (!value && subMinValue !== '')) {
+        callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
       } else {
         callback();
       }
@@ -667,40 +660,39 @@ export default {
       const { subMaxValue, subMinOperator, subMaxOperator } = scope.row;
       const val = value + subMaxOperator + subMaxValue + subMinOperator;
       const isNum = /^(\-|\+)?\d+(\.\d+)?$/.test(value);
-      if (!val || (value == "" && subMinOperator)) {
-        callback(new Error("最大值和最小值至少完整填写一个,单位不必填"));
-      } else if (value !== "" && !isNum) {
-        callback(new Error("只能输入数字"));
+      if (!val || (value == '' && subMinOperator)) {
+        callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
+      } else if (value !== '' && !isNum) {
+        callback(new Error('只能输入数字'));
       } else {
         callback();
       }
     },
     // 医学内容rule
     subEqValue(scope, rule, value, callback) {
-      if (value === "") {
-        callback(new Error("请输入" + this.textName(scope.$index)));
+      if (value === '') {
+        callback(new Error('请输入' + this.textName(scope.$index)));
       } else if (value.length > 200) {
-        callback(new Error(this.textName(scope.$index) + "不能超过200字"));
+        callback(new Error(this.textName(scope.$index) + '不能超过200字'));
       } else {
         callback();
       }
     },
     // 判断是否为最后一条规则
     isLastDate(id) {
-      const tableLength = this.klRuleByIdSub.filter(
-        (item) => item.groupId !== id
-      ).length;
+      const tableLength = this.klRuleByIdSub.filter(item => item.groupId !== id)
+        .length;
       return tableLength === 0;
     },
     // 是否超出最大规则数
     isMax(id) {
-      const typeNum = this.klRuleByIdSub.filter((item) => item.groupId === id)
+      const typeNum = this.klRuleByIdSub.filter(item => item.groupId === id)
         .length;
       return typeNum >= this.maxNum;
     },
     // 基础规则类型选择
     subTypeChange(e, index) {
-      this.$emit("subTypeChange", e, index);
+      this.$emit('subTypeChange', e, index);
     },
     //
     setTheRef(e, val) {
@@ -709,17 +701,17 @@ export default {
     // 规则术语类型
     subCodeChange(val, index) {
       //基础规则术语类型修改
-      this.$emit("childSubCodeChange", val, index, this.numTypes);
+      this.$emit('childSubCodeChange', val, index, this.numTypes);
     },
     clearConcept(index) {
-      this.$emit("childClearConcept", index);
+      this.$emit('childClearConcept', index);
     },
     clearNumText(index) {
-      this.$emit("childClearNumText", index);
+      this.$emit('childClearNumText', index);
     },
     //医学标准术语change
     subConceptIdfocus(index) {
-      this.subConceptIdIndex = "";
+      this.subConceptIdIndex = '';
       this.subConceptIdIndex = index;
       this.setTheRef(1, `klRuleByIdSub[${index}].subConceptId`);
     },
@@ -734,18 +726,18 @@ export default {
       };
       api
         .searchConcept(param)
-        .then((res) => {
-          if (res.data.code == "0") {
+        .then(res => {
+          if (res.data.code == '0') {
             const data = res.data.data;
-            this.$emit("setFormData", this.subConceptIdIndex, data);
+            this.$emit('setFormData', this.subConceptIdIndex, data);
           }
         })
-        .catch((error) => {
+        .catch(error => {
           console.log(error);
         });
     },
     dataTypeChange(val, index) {
-      this.$emit("ChildDataTypeChange", val, index);
+      this.$emit('ChildDataTypeChange', val, index);
     },
     // 处理要合并相同行的列
     getSpanArr(data) {
@@ -778,7 +770,7 @@ export default {
     },
     // 合并单元格
     ObjectSpanMethod({ row, column, rowIndex, columnIndex }) {
-      if (columnIndex == 0) {
+      if (columnIndex == 0 || columnIndex == 1) {
         const _row = this.spanArr[rowIndex];
         const _col = _row > 0 ? 1 : 0;
         return {
@@ -789,19 +781,19 @@ export default {
     },
     showDataType(index) {
       return (
-        (this.numTypes + ",").indexOf(
-          this.klRuleByIdSub[index].subLenCode + ","
+        (this.numTypes + ',').indexOf(
+          this.klRuleByIdSub[index].subLenCode + ','
         ) === -1
       );
     },
     textName(index) {
       return this.klRuleByIdSub[index].subType !== 6 &&
-        this.klRuleByIdSub[index].dataType == "2"
-        ? "医学内容"
-        : "正则表达式";
+        this.klRuleByIdSub[index].dataType == '2'
+        ? '医学内容'
+        : '正则表达式';
     },
     blurRef() {
-      console.log("scroll");
+      console.log('scroll');
       console.log(this.$refs[this.theRef]);
       if (this.theRef) {
         this.$refs[this.theRef].blur();
@@ -823,7 +815,7 @@ export default {
     // );
   },
   created() {
-    this.numTypes = localStorage.getItem("zskNumDict");
+    this.numTypes = localStorage.getItem('zskNumDict');
     this.getSpanArr(this.klRuleByIdSub);
   },
   beforeUpdate() {
@@ -855,6 +847,9 @@ export default {
     },
     maxNum: {
       default: null
+    },
+    showMsg:{
+      default: null
     }
   }
 };

+ 5 - 4
src/components/knowledgeExtra/rules.js

@@ -24,6 +24,11 @@ export const formRules = {
   parHasSub: [
     { required: true, message: "请选择有无子条件", trigger: ["change"] }
   ],
+  
+
+}
+
+export const tableRules = {
   parMsg: [
     { required: true, message: "请输入附加信息", trigger: ["change"] },
     {
@@ -37,10 +42,6 @@ export const formRules = {
       trigger: "change"
     }
   ],
-
-}
-
-export const tableRules = {
   conceptId: [
     { required: true, message: '请输入疾病名称', trigger: ['change'] }
   ],