1178232204@qq.com hace 3 años
padre
commit
6d8259103f

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 459 - 320
src/components/knowledgeExtra/AddNewRule.vue


+ 103 - 95
src/components/knowledgeExtra/AddNewRuleTable.vue

@@ -87,7 +87,7 @@
   .custom_table_header {
     vertical-align: middle;
     &::before {
-      content: '*';
+      content: "*";
       color: red;
       font-size: 12px;
       margin-right: 4px;
@@ -184,9 +184,10 @@
             <div class="btn_div" v-if="!isMax(scope.row.groupId)">
               <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">
               <img
-                @click="$emit('delGroupChild', scope.row.groupChildId)"
+                @click="$emit('delGroupChild', scope.row.groupChildId,scope.$index,scope.row.groupId,scope.row.del,scope.row.key,scope.row.baseTermTypeList.length)"
                 src="../../images/add-new-rule-del.png"
                 alt
               />
@@ -228,9 +229,9 @@
               v-model="scope.row.subType"
               :disabled="scope.row.disabled"
               placeholder="请选择"
-              @change="subTypeChange($event, scope.$index)"
+              @change="subTypeChange($event, scope.$index,scope.row.groupId,scope.row.key)"
               @focus="
-                setTheRef($event, `klRuleByIdSub[${scope.$index}].subType`)
+                setTheRef($event, `klRuleByIdSub[${scope.$index}].subType`,'')
               "
               :ref="`klRuleByIdSub[${scope.$index}].subType`"
             >
@@ -259,9 +260,9 @@
               v-model="scope.row.subLenCode"
               placeholder="请选择"
               :ref="`klRuleByIdSub[${scope.$index}].subLenCode`"
-              @change="subCodeChange($event, scope.$index)"
+              @change="subCodeChange($event, scope.$index,scope.row.groupId,scope.row.key,scope.row.baseTermTypeList.length)"
               @focus="
-                setTheRef($event, `klRuleByIdSub[${scope.$index}].subLenCode`)
+                setTheRef($event, `klRuleByIdSub[${scope.$index}].subLenCode`,scope.row.subLenCode,true)
               "
             >
               <el-option
@@ -319,7 +320,7 @@
                 placeholder="选择类型"
                 @change="dataTypeChange($event, scope.$index)"
                 @focus="
-                  setTheRef($event, `klRuleByIdSub[${scope.$index}].dataType`)
+                  setTheRef($event, `klRuleByIdSub[${scope.$index}].dataType`,'')
                 "
                 :ref="`klRuleByIdSub[${scope.$index}].dataType`"
               >
@@ -357,7 +358,7 @@
                         setTheRef(
                           $event,
                           `klRuleByIdSub[${scope.$index}].subMaxOperator`
-                        )
+                        ),''
                       "
                       :ref="`klRuleByIdSub[${scope.$index}].subMaxOperator`"
                     >
@@ -433,7 +434,7 @@
                         setTheRef(
                           $event,
                           `klRuleByIdSub[${scope.$index}].subMinOperator`
-                        )
+                        ),''
                       "
                     >
                       <el-option
@@ -549,24 +550,19 @@
 </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: '',
-      operMaxList: [
-        { name: '<=', key: '<=' },
-        { name: '<', key: '<' }
-      ],
-      operMinList: [
-        { name: '>', key: '>' },
-        { name: '>=', key: '>=' }
-      ],
+      numTypes: "",
+      subConceptIdIndex: "",
+      operMaxList: [{ name: "<=", key: "<=" }, { name: "<", key: "<" }],
+      operMinList: [{ name: ">", key: ">" }, { name: ">=", key: ">=" }],
       rules: tableRules,
-      theRef: null
+      theRef: null,
+      code: "",
     };
   },
   methods: {
@@ -577,54 +573,54 @@ 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`
+          `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`
+          `klRuleByIdSub[${val}].subMinOperator`,
         ]);
       }
       this.setScrollRight();
     },
     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`
+          `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`
+          `klRuleByIdSub[${val}].subMaxValue`,
         ]);
       }
       this.setScrollRight();
     },
     addGroup(scope) {
-      this.$emit('addGroup', null, { groupId: scope.row.groupId });
+      this.$emit("addGroup", null,scope.row.key, { 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,scope.row.key, { index: scope.$index });
       this.$refs.table.bodyWrapper.scrollLeft = 0;
     },
     scrollFun() {
@@ -641,16 +637,16 @@ export default {
     // },
     // cellStyle
     cellStyle({ row, column, rowIndex, columnIndex }) {
-      if (column.label == '组' || column.label == '基础规则') return {};
-      if (column.label == '附加信息') return { 'padding-top': '14px' };
-      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();
       }
@@ -660,10 +656,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();
       }
@@ -672,8 +668,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();
       }
@@ -683,84 +679,97 @@ 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);
+    subTypeChange(e, index, groupId, key) {
+      this.$emit("subTypeChange", e, index, groupId, key);
     },
     //
-    setTheRef(e, val) {
+    setTheRef(e, val, code, type) {
       this.theRef = val;
+      if (type) {
+        this.code = code ? code : "";
+      }
     },
     // 规则术语类型
-    subCodeChange(val, index) {
+    subCodeChange(val, index, groupId, key,lens) {
       //基础规则术语类型修改
-      this.$emit('childSubCodeChange', val, index, this.numTypes);
+      this.$emit(
+        "childSubCodeChange",
+        val,
+        index,
+        this.numTypes,
+        groupId,
+        key,
+        this.code,
+        lens
+      );
     },
     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`);
+      this.setTheRef(1, `klRuleByIdSub[${index}].subConceptId`, "");
     },
     // 医学标准术语
     searchConcept(val) {
       const param = {
         excludedConceptIds: [
-          this.klRuleByIdSub[this.subConceptIdIndex].subType
+          this.klRuleByIdSub[this.subConceptIdIndex].subType,
         ],
         libType: this.klRuleByIdSub[this.subConceptIdIndex].subLenCode,
         name: val,
       };
       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) {
@@ -793,13 +802,13 @@ export default {
     },
     // 合并单元格
     ObjectSpanMethod({ row, column, rowIndex, columnIndex }) {
-      if (this.ruleTermCodeStr == '3-108-1') {
+      if (this.ruleTermCodeStr == "3-108-1") {
         if (columnIndex == 0) {
           const _row = this.spanArr[rowIndex];
           const _col = _row > 0 ? 1 : 0;
           return {
             rowspan: _row,
-            colspan: _col
+            colspan: _col,
           };
         }
       } else {
@@ -808,23 +817,23 @@ export default {
           const _col = _row > 0 ? 1 : 0;
           return {
             rowspan: _row,
-            colspan: _col
+            colspan: _col,
           };
         }
       }
     },
     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() {
       if (this.theRef) {
@@ -833,7 +842,7 @@ export default {
         // document.getElementById(this.theRef).focus()
         // document.getElementById(this.theRef).value = 123
       }
-    }
+    },
   },
   components: {},
   mounted() {
@@ -847,7 +856,7 @@ export default {
     // );
   },
   created() {
-    this.numTypes = localStorage.getItem('zskNumDict');
+    this.numTypes = localStorage.getItem("zskNumDict");
     this.getSpanArr(this.klRuleByIdSub);
   },
   beforeUpdate() {
@@ -875,21 +884,20 @@ export default {
   props: {
     klRuleByIdSub: {
       type: Array,
-      required: true
+      required: true,
     },
     maxNum: {
-      default: null
+      default: null,
     },
     showMsg: {
-      default: null
+      default: null,
     },
-    showMsg2:{
-      default: null
+    showMsg2: {
+      default: null,
     },
     ruleTermCodeStr: {
-      default: null
+      default: null,
     },
-  }
+  },
 };
 </script>
-