瀏覽代碼

Merge branch 'scaleManage0527' into test

reaper 4 年之前
父節點
當前提交
8c184e402a

+ 10 - 8
src/components/knowledgeExtra/AddAssess/ScoreResultsTable.vue

@@ -147,15 +147,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 +177,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>
@@ -243,7 +245,7 @@
 
 <script>
 import rules from "./rules";
-import { numInputInput } from "./util";
+import { numInputChange } from "./util";
 export default {
   data() {
     return {
@@ -251,7 +253,7 @@ export default {
     };
   },
   methods: {
-    numInputInput,
+    numInputChange,
     handleInput(val, i) {
       // `scoreresultsdatas[${scope.$index}].content.min`
       this.$emit("clearValidate", [

+ 46 - 15
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>
@@ -365,12 +365,12 @@ it .ql-editor,
       />
     </el-form>
     <!-- 暂时用的按钮 -->
-    <!-- <button
+    <button
       style="position: fixed; bottom: 20px; right: 20px; font-size: 16px"
       @click="assessCommitTest"
     >
       暂时用的按钮
-    </button> -->
+    </button>
   </div>
 </template>
 
@@ -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

+ 14 - 12
src/components/knowledgeExtra/AddAssess/scale-table.vue

@@ -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>
@@ -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
                     );
                   "
@@ -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>
@@ -525,7 +527,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 +538,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;
 }