Browse Source

数字验证,字典回显

liusungtsun 1 year ago
parent
commit
32429d5b11
2 changed files with 36 additions and 8 deletions
  1. 28 6
      src/views/GATHER/index.vue
  2. 8 2
      src/views/norm/dataSubmission.vue

+ 28 - 6
src/views/GATHER/index.vue

@@ -350,7 +350,7 @@
           :label="item.normName"
           :name="item.normName"
         >
-          <el-form :model="form">
+          <el-form :model="form" >
             <!-- :rules="rules" ref="form" -->
             <el-form-item
               v-for="(listItem, listIndex) in form.feeLists"
@@ -384,27 +384,32 @@
           </el-form> -->
         </el-tab-pane>
       </el-tabs>
-
+     <template  v-else-if="this.form.type == 1">
       <el-form
-        :model="form"
-        v-else-if="this.form.type == 1"
+        v-for="(listItem, listIndex) in form.feeLists"
+        :model="listItem"
+        :ref="'form' + listIndex"
+        :rules="rules"
+       
       >
         <!-- :rules="rules" ref="form" -->
         <el-form-item
-          v-for="(listItem, listIndex) in form.feeLists"
           :key="listItem.normfeeId"
           :label="listItem.normfeeName"
           :required="true"
+          prop="collCalue"
+          
         >
           <!-- 这里科研失败!想动态绑定校验规则的 -->
           <!-- :prop="listItem.normfeeId" -->
           <!-- :rules="rules.listItem.normfeeId" -->
           <el-input
             v-model="listItem.collCalue"
-            :placeholder="'请输入' + listItem.normfeeName"
+            :placeholder="'请输入' + listItem.normfeeName" 
           ></el-input>
         </el-form-item>
       </el-form>
+    </template>
       <div slot="footer" class="dialog-footer">
         <el-button type="primary" @click="submitForm('add')">确 定</el-button>
         <el-button @click="cancel">取 消</el-button>
@@ -519,6 +524,7 @@ import axios from "axios";
 export default {
   name: "GATHER",
   data() {
+    
     return {
       edit: Boolean, //false 查看  true修改
       tabList: [],
@@ -589,6 +595,9 @@ export default {
       // 表单校验
       rules: {
         // id: [{ required: true, message: "$comment不能为空", trigger: "blur" }],
+        collCalue: [{ required: true, message: "不能为空", trigger: "blur" },
+                    { trigger: "blur", validator: this.validator }
+                    ]
       },
       //设置文件名字
       setFileName: "",
@@ -603,6 +612,19 @@ export default {
     this.getList();
   },
   methods: {
+    validator(rule, value, callback) {
+      let reg = /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g;
+      if (!reg.test(value)) {
+                callback(new Error('请输入数字'));
+            }else if(value.split(".").length > 2) {
+	             callback(new Error("输入正确格式的金额")); //防止输入多个小数点
+	          }else if (value.indexOf(".") != -1 && value.split('.')[1].length > 2) {
+               callback(new Error('只能输入两位小数')) //小数点后两位
+            }else {
+              callback()
+            }
+
+    },
     submitUpload() {
       this.$refs.upload.submit();
     },

+ 8 - 2
src/views/norm/dataSubmission.vue

@@ -24,11 +24,14 @@
       </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
-
     <el-table  :data="GIVEList" @selection-change="handleSelectionChange">
       <el-table-column type="selection" width="55" align="center" />
       <el-table-column label="报送参数名称" align="center" prop="fname"></el-table-column>
-      <el-table-column label="计量单位" align="center" prop="funit"></el-table-column>
+      <el-table-column label="计量单位" align="center" prop="funit">
+        <template slot-scope="scope">
+          <dict-tag :options="dict.type.norm_uint" :value="scope.row.funit" />
+        </template>
+      </el-table-column>
       <el-table-column label="分类占比" align="center" prop="normRatio"></el-table-column>
       <el-table-column label="权数" align="center" prop="fnumber"></el-table-column>
       <el-table-column label="是否启用" align="center" prop="status">
@@ -133,8 +136,11 @@ import { listData } from '@/api/system/dict/data';
 import { formatDate } from '@/utils/index';
 export default {
   name: 'GIVE',
+  dicts: ['norm_uint'],
   data() {
+    
     return {
+      listData,
       // 根路径
       baseURL: process.env.VUE_APP_BASE_API,
       // 遮罩层