浏览代码

refactor: enhance order detail form with additional input fields and validation

Yannay 2 月之前
父节点
当前提交
22b7907b0c

+ 40 - 8
pages/orderDetailRefactored/components/PageThree.vue

@@ -9,7 +9,8 @@
9 9
           <u-input 
10 10
             v-model="paymentInfo.customName" 
11 11
             placeholder="请输入开户人姓名" 
12
-            class="info-input" 
12
+            class="info-input"
13
+            @blur="handleCustomNameInput" 
13 14
           />
14 15
         </u-col>
15 16
         <u-col span="5.8">
@@ -28,7 +29,9 @@
28 29
           <u-input 
29 30
             v-model="paymentInfo.bankAccount" 
30 31
             placeholder="请输入银行账号" 
31
-            class="info-input" 
32
+            class="info-input"
33
+            type="number"
34
+            @input="handleBankAccountInput" 
32 35
           />
33 36
         </u-col>
34 37
       </u-row>
@@ -38,7 +41,9 @@
38 41
           <u-input 
39 42
             v-model="paymentInfo.idNumber" 
40 43
             placeholder="请输入身份证号" 
41
-            class="info-input" 
44
+            class="info-input"
45
+            type="number"
46
+            @input="handleIdNumberInput" 
42 47
           />
43 48
         </u-col>
44 49
       </u-row>
@@ -363,12 +368,39 @@ export default {
363 368
     },
364 369
 
365 370
     /**
366
-     * 银行名称输入处理
371
+     * 开户人输入处理 - 只允许中文
372
+     */
373
+    handleCustomNameInput(value) {
374
+      // 只保留中文字符(包括中文标点)
375
+      const chineseReg = /[^\u4e00-\u9fa5]/g
376
+      this.paymentInfo.customName = String(value || '').replace(chineseReg, '')
377
+    },
378
+
379
+    /**
380
+     * 银行名称输入处理 - 只允许中文
381
+     */
382
+    handleBankNameInput(value) {
383
+      // 只保留中文字符(包括中文标点)
384
+      const chineseReg = /[^\u4e00-\u9fa5]/g
385
+      this.paymentInfo.bankName = String(value || '').replace(chineseReg, '')
386
+    },
387
+
388
+    /**
389
+     * 银行账号输入处理 - 只允许数字
390
+     */
391
+    handleBankAccountInput(value) {
392
+      // 只保留数字
393
+      const numberReg = /[^\d]/g
394
+      this.paymentInfo.bankAccount = String(value || '').replace(numberReg, '')
395
+    },
396
+
397
+    /**
398
+     * 身份证号输入处理 - 只允许数字
367 399
      */
368
-    handleBankNameInput() {
369
-      const strValue = String(this.paymentInfo.bankName || '')
370
-      const reg = /[0-9]/g
371
-      this.paymentInfo.bankName = strValue.replace(reg, '')
400
+    handleIdNumberInput(value) {
401
+      // 只保留数字
402
+      const numberReg = /[^\d]/g
403
+      this.paymentInfo.idNumber = String(value || '').replace(numberReg, '')
372 404
     },
373 405
 
374 406
     /**

+ 71 - 8
pages/orderDetailRefactored/index.vue

@@ -44,14 +44,34 @@
44 44
       @confirm="handleAddOneConfirm"
45 45
     >
46 46
       <view class="add-one-modal-content">
47
-        <u-button 
48
-          type="primary" 
49
-          plain 
50
-          @click="showBrandSelector = true"
51
-          class="brand-select-btn"
52
-        >
53
-          {{ currentAddBrand.dictLabel || '点击请选择品牌' }}
54
-        </u-button>
47
+        <view class="add-one-form-item">
48
+          <text class="form-label">品牌<text class="required">*</text></text>
49
+          <u-button 
50
+            type="primary" 
51
+            plain 
52
+            @click="showBrandSelector = true"
53
+            class="brand-select-btn"
54
+          >
55
+            {{ currentAddBrand.dictLabel || '点击请选择品牌' }}
56
+          </u-button>
57
+        </view>
58
+        <view class="add-one-form-item">
59
+          <text class="form-label">型号</text>
60
+          <u-input 
61
+            v-model="currentAddModel" 
62
+            placeholder="请输入型号" 
63
+            class="form-input"
64
+          />
65
+        </view>
66
+        <view class="add-one-form-item">
67
+          <text class="form-label">价格</text>
68
+          <u-input 
69
+            v-model="currentAddPrice" 
70
+            placeholder="请输入价格" 
71
+            type="number"
72
+            class="form-input"
73
+          />
74
+        </view>
55 75
       </view>
56 76
     </u-modal>
57 77
 
@@ -122,6 +142,8 @@ export default {
122 142
       // 品牌选择相关
123 143
       brandColumns: [[]],
124 144
       currentAddBrand: {},
145
+      currentAddModel: '',
146
+      currentAddPrice: '',
125 147
       // 模态窗配置
126 148
       modalConfig: {
127 149
         title: '',
@@ -312,9 +334,17 @@ export default {
312 334
      * 确认加一单
313 335
      */
314 336
     async handleAddOneConfirm() {
337
+      // 验证品牌是否已选择(必选)
338
+      if (!this.currentAddBrand.dictValue) {
339
+        uni.$u.toast('请选择品牌')
340
+        return
341
+      }
342
+      
315 343
       try {
316 344
         await uni.$u.api.addReceiptForm({
317 345
           brand: this.currentAddBrand.dictValue,
346
+          model: this.currentAddModel || '',
347
+          sellingPrice: this.currentAddPrice || '',
318 348
           sendFormId: this.orderId,
319 349
           clueId: this.clueId
320 350
         })
@@ -326,6 +356,8 @@ export default {
326 356
       } finally {
327 357
         this.addOneModalVisible = false
328 358
         this.currentAddBrand = {}
359
+        this.currentAddModel = ''
360
+        this.currentAddPrice = ''
329 361
       }
330 362
     },
331 363
 
@@ -335,6 +367,8 @@ export default {
335 367
     handleAddOneCancel() {
336 368
       this.addOneModalVisible = false
337 369
       this.currentAddBrand = {}
370
+      this.currentAddModel = ''
371
+      this.currentAddPrice = ''
338 372
     }
339 373
   }
340 374
 }
@@ -397,7 +431,36 @@ export default {
397 431
   padding: 20rpx 0;
398 432
 }
399 433
 
434
+.add-one-form-item {
435
+  margin-bottom: 30rpx;
436
+  
437
+  &:last-child {
438
+    margin-bottom: 0;
439
+  }
440
+}
441
+
442
+.form-label {
443
+  display: block;
444
+  font-size: 28rpx;
445
+  color: #333;
446
+  margin-bottom: 15rpx;
447
+  font-weight: 500;
448
+}
449
+
450
+.required {
451
+  color: #f56c6c;
452
+  margin-left: 4rpx;
453
+}
454
+
400 455
 .brand-select-btn {
401 456
   width: 100%;
402 457
 }
458
+
459
+.form-input {
460
+  width: 100%;
461
+  border: 2rpx solid #e0e0e0;
462
+  border-radius: 10rpx;
463
+  padding: 20rpx;
464
+  font-size: 28rpx;
465
+}
403 466
 </style>

+ 3 - 3
pages/orderDetailRefactored/utils/imageUpload.js

@@ -25,10 +25,10 @@ export default {
25 25
       const rows = response.rows || []
26 26
       
27 27
       // 如果品牌包含逗号,说明是多个品牌,需要过滤
28
-      if (itemBrand && itemBrand.indexOf(',') !== -1) {
28
+      // if (itemBrand && itemBrand.indexOf(',') !== -1) {
29 29
         return rows.filter(item => item.sourceId === receiptId)
30
-      }
31
-      return rows
30
+      // }
31
+      // return rows
32 32
     } catch (error) {
33 33
       console.error('获取文件列表失败:', error)
34 34
       uni.$u.toast('获取文件列表失败')