Browse Source

必选符号问题合并

zhouna 4 years ago
parent
commit
b03808efdf

+ 12 - 12
src/components/knowledgeExtra/AddAssess/ScoreResultsTable.vue

@@ -101,7 +101,6 @@
     <div class="table_box">
       <el-table
         :data="list"
-        header-row-class-name="header_row_class_name"
         border
         style="width: 100%; margin: 20px 0"
       >
@@ -126,7 +125,7 @@
           </template>
         </el-table-column>
         <el-table-column prop="content" label="得分范围">
-          <template slot="header">
+          <template slot="header" slot-scope="scope">
             <div class="custom_table_header">得分范围</div>
           </template>
           <template slot-scope="scope">
@@ -147,15 +146,16 @@
                   ]"
                 >
                   <el-input
-                    type="number"
+                    type="text"
+                    maxlength="7"
                     :id="`scoreresultsdatas[${scope.$index}].content.min`"
                     @input="
                       handleInput($event, scope.$index);
-                      scope.row.content.min = numInputInput(
+                      scope.row.content.min = numInputChange(
                         scope.row.content.min
                       );
                     "
-                    v-model.number="scope.row.content.min"
+                    v-model="scope.row.content.min"
                     clearable
                     placeholder="请输入"
                   ></el-input>
@@ -176,15 +176,16 @@
                   ]"
                 >
                   <el-input
-                    type="number"
+                    type="text"
+                    maxlength="7"
                     :id="`scoreresultsdatas[${scope.$index}].content.max`"
                     @input="
                       handleInput($event, scope.$index);
-                      scope.row.content.max = numInputInput(
+                      scope.row.content.max = numInputChange(
                         scope.row.content.max
                       );
                     "
-                    v-model.number="scope.row.content.max"
+                    v-model="scope.row.content.max"
                     clearable
                     placeholder="请输入"
                   ></el-input>
@@ -194,7 +195,7 @@
           </template>
         </el-table-column>
         <el-table-column prop="result" label="结果">
-          <template slot="header">
+          <template slot="header" slot-scope="scope">
             <div class="custom_table_header">结果</div>
           </template>
           <template slot-scope="scope">
@@ -220,7 +221,6 @@
           <template slot-scope="scope">
             <el-form-item
               :prop="`scoreresultsdatas[${scope.$index}].pushInfo`"
-              :rules="rules.sourePushInfo"
               class="showScroll"
             >
               <el-input
@@ -243,7 +243,7 @@
 
 <script>
 import rules from "./rules";
-import { numInputInput } from "./util";
+import { numInputChange } from "./util";
 export default {
   data() {
     return {
@@ -251,7 +251,7 @@ export default {
     };
   },
   methods: {
-    numInputInput,
+    numInputChange,
     handleInput(val, i) {
       // `scoreresultsdatas[${scope.$index}].content.min`
       this.$emit("clearValidate", [

+ 44 - 13
src/components/knowledgeExtra/AddAssess/index.vue

@@ -231,10 +231,10 @@ it .ql-editor,
                 >
                   <el-input
                     :id="`klScaleParent[${tableIndex}].factor`"
-                    type="number"
-                    maxlength="6"
-                    v-model.number="table.factor"
-                    @input="table.factor = numInputInput(table.factor)"
+                    type="text"
+                    maxlength="7"
+                    v-model="table.factor"
+                    @input="table.factor = numInputChange(table.factor)"
                   />
                 </el-form-item>
                 <el-form-item
@@ -247,10 +247,10 @@ it .ql-editor,
                   <el-input
                     :ref="`klScaleParent[${tableIndex}].constant`"
                     :id="`klScaleParent[${tableIndex}].constant`"
-                    type="number"
-                    maxlength="6"
-                    v-model.number="table.constant"
-                    @input="table.constant = numInputInput(table.constant)"
+                    type="text"
+                    maxlength="7"
+                    v-model="table.constant"
+                    @input="table.constant = numInputChange(table.constant)"
                   />
                 </el-form-item>
               </div>
@@ -386,7 +386,7 @@ import { container, ImageExtend, QuillWatch } from "quill-image-extend-module";
 Quill.register("modules/ImageExtend", ImageExtend);
 import ScoreResultsTable from "./ScoreResultsTable.vue";
 import rules from "./rules";
-import { numInputInput } from "./util";
+import { numInputChange } from "./util";
 const defaultDate = {
   groupId: new Date().valueOf().toString(),
   issueId: new Date().valueOf().toString() + "-" + new Date().valueOf(),
@@ -479,7 +479,7 @@ export default {
             remark: "string",
             resultType: 1,
             ruleCode: "string",
-            score: "",
+            score: null,
             status: 1,
             textType: 11
           }
@@ -555,7 +555,7 @@ export default {
     };
   },
   methods: {
-    numInputInput,
+    numInputChange,
     clearValidate(data) {
       this.$refs.ScoreResultsRef.clearValidate(data);
     },
@@ -784,14 +784,45 @@ export default {
       }
       // 14  提交数据设置新的orderNo,删除issueId
       params.klScaleParent.forEach((tableItem, tableIndex) => {
-        tableItem.orderNo = tableIndex;
+        // tableItem.orderNo = tableIndex;
+        // console.log(
+        //   "????",
+        //   typeof tableItem.constant + tableItem.constant,
+        //   typeof tableItem.factor + tableItem.factor,
+        //   typeof tableItem.score + tableItem.score
+        // );
+        typeof tableItem.constant == "string" &&
+          (tableItem.constant = parseFloat(tableItem.constant));
+        typeof tableItem.factor == "string" &&
+          (tableItem.factor = parseFloat(tableItem.factor));
+        typeof tableItem.score == "string" &&
+          (tableItem.score = parseFloat(tableItem.score));
         tableItem.klScaleSaveGroup.forEach((groupItem, groupIndex) => {
           groupItem.groupNum = groupIndex;
           groupItem.klScaleSub.forEach((issueItem, issueIndex) => {
             issueItem.orderNo = issueIndex;
             issueItem.issueId && delete issueItem.issueId;
+            // console.log(
+            //   "issueItem",
+            //   typeof issueItem.constant == "string" + issueItem.constant,
+            //   typeof issueItem.factor == "string" + issueItem.factor,
+            //   typeof issueItem.score == "string" + issueItem.score
+            // );
+            typeof issueItem.constant == "string" &&
+              (issueItem.constant = parseFloat(issueItem.constant));
+            typeof issueItem.factor == "string" &&
+              (issueItem.factor = parseFloat(issueItem.factor));
+            typeof issueItem.score == "string" &&
+              (issueItem.score = parseFloat(issueItem.score));
+
             issueItem.klScaleDetail.forEach((optionItem, optionIndex) => {
               optionItem.orderNo = optionIndex;
+              // console.log(
+              //   "optionItem.score",
+              //   typeof optionItem.score == "string" + optionItem.score
+              // );
+              typeof optionItem.score == "string" &&
+                (optionItem.score = parseFloat(optionItem.score));
             });
           });
         });
@@ -1164,7 +1195,7 @@ export default {
   watch: {
     scaleData: {
       handler() {
-        console.log("监听");
+        console.log("监听", this.scaleData);
         this.resizeTable();
       },
       deep: true

+ 25 - 24
src/components/knowledgeExtra/AddAssess/scale-table.vue

@@ -238,7 +238,7 @@
           </template>
         </el-table-column>
         <el-table-column prop="two_content" label="问题内容">
-          <template slot="header">
+          <template slot="header" slot-scope="scope">
             <div class="custom_table_header">问题内容</div>
           </template>
           <template slot-scope="scope">
@@ -266,11 +266,11 @@
         </el-table-column>
         <el-table-column
           prop="two_factor"
-          label="系数"
           width="60px"
           v-if="tableResultType === 1"
+          label="系数"
         >
-          <template slot="header">
+          <template slot="header" slot-scope="scope">
             <div class="custom_table_header">系数</div>
           </template>
           <template slot-scope="scope">
@@ -282,8 +282,9 @@
               >
                 <el-input
                   :id="`klScaleParent[${tableIndex}].klScaleSaveGroup[${scope.$index}].two_factor`"
-                  type="number"
-                  v-model.number="scope.row.two_factor"
+                  type="text"
+                  maxlength="7"
+                  v-model="scope.row.two_factor"
                   placeholder="请输入"
                   title=""
                   @input="
@@ -293,7 +294,7 @@
                       scope.$index,
                       'two_factor'
                     );
-                    scope.row.two_factor = numInputInput(scope.row.two_factor);
+                    scope.row.two_factor = numInputChange(scope.row.two_factor);
                   "
                 ></el-input>
               </el-form-item>
@@ -302,11 +303,11 @@
         </el-table-column>
         <el-table-column
           prop="two_constant"
-          label="常数"
           width="60px"
           v-if="tableResultType === 1"
+          label="常数"
         >
-          <template slot="header">
+          <template slot="header" slot-scope="scope">
             <div class="custom_table_header">常数</div>
           </template>
           <template slot-scope="scope">
@@ -317,9 +318,10 @@
                 :show-message="false"
               >
                 <el-input
-                  type="number"
+                  type="text"
+                  maxlength="7"
                   :id="`klScaleParent[${tableIndex}].klScaleSaveGroup[${scope.$index}].two_constant`"
-                  v-model.number="scope.row.two_constant"
+                  v-model="scope.row.two_constant"
                   placeholder="请输入"
                   style="text-align: center"
                   @input="
@@ -329,7 +331,7 @@
                       scope.$index,
                       'two_constant'
                     );
-                    scope.row.two_constant = numInputInput(
+                    scope.row.two_constant = numInputChange(
                       scope.row.two_constant
                     );
                   "
@@ -386,10 +388,10 @@
         </el-table-column>
         <el-table-column
           prop="content"
-          label="选项内容"
           :width="tableResultType === 1 ? '200px' : ''"
+          label="选项内容"
         >
-          <template slot="header">
+          <template slot="header" slot-scope="scope">
             <div class="custom_table_header">选项内容</div>
           </template>
           <template slot-scope="scope">
@@ -441,11 +443,11 @@
         </el-table-column>
         <el-table-column
           prop="content"
-          label="分值"
           width="90px"
           v-if="tableResultType === 1"
+          label="分值"
         >
-          <template slot="header">
+          <template slot="header" slot-scope="scope">
             <div class="custom_table_header">分值</div>
           </template>
           <template slot-scope="scope">
@@ -455,10 +457,10 @@
             >
               <el-input
                 :id="`klScaleParent[${tableIndex}].klScaleSaveGroup[${scope.$index}].score`"
-                type="number"
-                maxlength="6"
-                @input="scope.row.score = numInputInput(scope.row.score)"
-                v-model.number="scope.row.score"
+                type="text"
+                maxlength="7"
+                @input="scope.row.score = numInputChange(scope.row.score)"
+                v-model="scope.row.score"
                 clearable
                 placeholder="请输入"
               ></el-input>
@@ -467,11 +469,11 @@
         </el-table-column>
         <el-table-column
           prop="result"
-          label="结果"
           width="200px"
           v-if="tableResultType === 2"
+          label="结果"
         >
-          <template slot="header">
+          <template slot="header" slot-scope="scope">
             <div class="custom_table_header">结果</div>
           </template>
           <template slot-scope="scope">
@@ -501,7 +503,6 @@
           <template slot-scope="scope">
             <el-form-item
               :prop="`klScaleParent[${tableIndex}].klScaleSaveGroup[${scope.$index}].pushInfo`"
-              :rules="rules.pushInfo"
               class="showScroll"
             >
               <el-input
@@ -525,7 +526,7 @@
 <script>
 import rules from "./rules";
 import api from "@api/knowledgeTree.js";
-import { numInputInput } from "./util";
+import { numInputChange } from "./util";
 export default {
   name: "scaleTable",
   data() {
@@ -536,7 +537,7 @@ export default {
     };
   },
   methods: {
-    numInputInput,
+    numInputChange,
     changeDataFun(val, tableIndex, rowIndex, name) {
       this.$emit("CHANGE_ISSUE_CONTENT", {
         value: val,

+ 21 - 7
src/components/knowledgeExtra/AddAssess/util.js

@@ -1,21 +1,35 @@
-export const numInputInput = (value, len = 5, decimals = 1) => {
+export const numInputChange = (value, len = 5, decimals = 1) => {
   // value:修改的数字  len 总长度   decimals:允许小数点后几位
   //todo 5位整数数加一位小数
+  let isMinus = false;
   value += "";
-  if (value.length == 0) return null;
+  if (value[0] == '-') {
+    isMinus = true;
+    len = len - 1;
+  }
+  value = value.replace(/[^\d.]/g, '');
   let index = value.lastIndexOf(".");
+
   if (index != -1) {
     let [int, dec] = value.split(".");
     if (dec.length > decimals) {
       dec = dec.slice(0, dec.length - 1);
     }
+
     if (int.length > len) {
       int = int.slice(0, int.length - 1);
     }
-    return parseFloat(int + "." + dec);
-  }
-  if (value.length > len) {
-    value = value.slice(0, value.length - 1);
+    if (int.length == 0) {
+      int = 0;
+    }
+    value = int + "." + dec;
+  } else {
+    if (value.length > len) {
+      value = value.slice(0, value.length - 1);
+    }
   }
-  return parseFloat(value);
+  let res = value
+  if (isMinus) { res = '-' + res };
+  if (parseFloat(res) == 'NaN') res = 0;
+  return res;
 }