Browse Source

fix: 企微助手 - 群活码 - "人数上限"前端表单校验逻辑

zhengxy 2 years ago
parent
commit
a1e2b4b89f

+ 16 - 4
project/src/assets/js/common.js

@@ -247,8 +247,20 @@ export function judgePhone (num) {//判断手机号是否合格,1合格,0不
247 247
   // }
248 248
 }
249 249
 
250
-// 订单类型 MP & QDQ
251
-export const orderTypeOptions = {
252
-  MP: '1',
253
-  ADQ: '2',
250
+/**
251
+ * 获取整数
252
+ * @method getIntegerNumber
253
+ * @param  value - input组件输入的值
254
+ */
255
+export const getIntegerNumber = (value) => {
256
+  return String(value).replace(/[^\d]/g, '')
254 257
 }
258
+
259
+/**
260
+ * 获取非0整数
261
+ * @method getNot0IntegerNumber
262
+ * @param  value - input组件输入的值
263
+ */
264
+export const getNot0IntegerNumber = (value) => {
265
+  return Number(getIntegerNumber(value)) === 0 ? '' : getIntegerNumber(value)
266
+}

+ 5 - 0
project/src/assets/js/staticTypes.js

@@ -0,0 +1,5 @@
1
+// 订单类型 MP & QDQ
2
+export const orderTypeOptions = {
3
+  MP: '1',
4
+  ADQ: '2',
5
+}

+ 1 - 1
project/src/components/assembly/screen/switchMpAdq.vue

@@ -14,7 +14,7 @@
14 14
 </template>
15 15
 
16 16
 <script>
17
-import { orderTypeOptions } from '@/assets/js/common'
17
+import { orderTypeOptions } from '@/assets/js/staticTypes'
18 18
 export default {
19 19
   props: {
20 20
     value: {

+ 1 - 1
project/src/components/dataBoard/operateDayRetrieve.vue

@@ -37,7 +37,7 @@
37 37
 import datePicker from '@/components/assembly/screen/datePicker.vue'
38 38
 import selfChannel from '@/components/assembly/screen/channel.vue'
39 39
 import switchMpAdq from '@/components/assembly/screen/switchMpAdq.vue'
40
-import { orderTypeOptions } from '@/assets/js/common'
40
+import { orderTypeOptions } from '@/assets/js/staticTypes'
41 41
 
42 42
 export default {
43 43
   components: { datePicker, selfChannel, switchMpAdq },

+ 7 - 2
project/src/components/groupCode/createGroupCode.vue

@@ -84,8 +84,8 @@
84 84
             <template slot="header" slot-scope="scope">
85 85
               <em style="color: #ff0000;">*</em>人数上限
86 86
             </template>
87
-            <template slot-scope="{ row }">
88
-              <el-input size="mini" v-model="row.user_limit" />
87
+            <template slot-scope="{ row, $index }">
88
+              <el-input size="mini" v-model="row.user_limit" @input="onInputUserLimit($event, $index)" />
89 89
             </template>
90 90
           </el-table-column>
91 91
           <el-table-column label="状态" align="center">
@@ -160,6 +160,7 @@
160 160
 import dialogGroup from './components/dialogGroup.vue'
161 161
 import chatGroupOptions from './components/chatGroupOptions.vue'
162 162
 import selfCustomerservice from '@/components/assembly/screen/customerService.vue'
163
+import { getIntegerNumber } from '@/assets/js/common'
163 164
 import Sortable from 'sortablejs'
164 165
 import _lodash from 'lodash'
165 166
 
@@ -316,6 +317,10 @@ export default {
316 317
         this.loading = false
317 318
       }
318 319
     },
320
+    // 监听输入"人数上限"
321
+    onInputUserLimit(inputVal, idx) {
322
+      this.groupForm.chat_id_list[idx].user_limit = getIntegerNumber(inputVal)
323
+    },
319 324
     // 表单校验
320 325
     handleFormValidate() {
321 326
       const { name, chat_id_list, is_limit, user_list, leading_words } = this.groupForm