Commit 1594be1c2fcfbcd4d75627da70bdc2a843c9e4e6
1 parent
06eeda54
type==1 改为数字加减器
Showing
2 changed files
with
35 additions
and
10 deletions
pages-sub/daily/maintain-manage/add-record.vue
| ... | ... | @@ -14,12 +14,8 @@ |
| 14 | 14 | |
| 15 | 15 | <!-- type 1 数值:用可空态的输入框,避免 u-number-box 把空值显示成 1 却不回写模型(未填写会被当成已填 1) --> |
| 16 | 16 | <view v-if="item.fieldType === 1" class="number-box-wrap"> |
| 17 | - <view class="number-input-wrap"> | |
| 18 | - <up-input v-model="inspectForm[item.fieldCode]" type="number" | |
| 19 | - :maxlength="item.length || 10" | |
| 20 | - :placeholder="`请输入${item.fieldName}${item.unit || ''}`" | |
| 21 | - @blur="valChange(item)"></up-input> | |
| 22 | - </view> | |
| 17 | + <u-number-box v-model="qtyMap[item.fieldCode]" :min="0" :step="1"></u-number-box> | |
| 18 | + <text class="unit-text" v-if="item.unit">{{ item.unit }}</text> | |
| 23 | 19 | |
| 24 | 20 | <text class="unit-text" v-if="item.unit">{{ item.unit }}</text> |
| 25 | 21 | </view> |
| ... | ... | @@ -448,6 +444,10 @@ export default { |
| 448 | 444 | } else { |
| 449 | 445 | this.inspectForm[field.fieldCode] = '' |
| 450 | 446 | } |
| 447 | + if(field.fieldType === 1){ | |
| 448 | + // 数值步进器默认0 | |
| 449 | + this.qtyMap[field.fieldCode] = 0 | |
| 450 | +} | |
| 451 | 451 | // 初始化展示label为空 |
| 452 | 452 | this.labelMap[field.fieldCode] = '' |
| 453 | 453 | // 7图片/8附件的文件列表(驱动 up-upload 与自绘文件列表展示) |
| ... | ... | @@ -661,6 +661,24 @@ export default { |
| 661 | 661 | */ |
| 662 | 662 | buildRequiredRule(field: any) { |
| 663 | 663 | const type = field.fieldType |
| 664 | +// ========= 新增:数值类型单独校验 ========= | |
| 665 | +if (type === 1) { | |
| 666 | + return { | |
| 667 | + required: true, | |
| 668 | + trigger: ['change'], | |
| 669 | + validator: (rule, value, callback) => { | |
| 670 | + // 注意:type1现在模型在 qtyMap,value 不是表单模型!这里拿不到真实值 | |
| 671 | + const realVal = this.qtyMap[rule.field] | |
| 672 | + if (realVal === null || realVal === undefined) { | |
| 673 | + callback(new Error(`请填写${rule.fieldName}`)) | |
| 674 | + } else { | |
| 675 | + callback() | |
| 676 | + } | |
| 677 | + } | |
| 678 | + } | |
| 679 | +} | |
| 680 | + | |
| 681 | + | |
| 664 | 682 | if (type === 6 || type === 7 || type === 8) { |
| 665 | 683 | const action = type === 6 ? '请选择' : '请上传' |
| 666 | 684 | return { |
| ... | ... | @@ -881,7 +899,8 @@ export default { |
| 881 | 899 | } |
| 882 | 900 | |
| 883 | 901 | if (type === 1) { |
| 884 | - fields.push({ fieldCode: code, valueNumber: Number(value) }) | |
| 902 | + const numVal = this.qtyMap[code] | |
| 903 | + fields.push({ fieldCode: code, valueNumber: Number(numVal) }) | |
| 885 | 904 | } else if (type === 3 && item.optionSource === 3) { |
| 886 | 905 | // 物料:value_text 存物料ID;数量>0 才落物料三列(0 表示本次不领用) |
| 887 | 906 | const qty = Number(this.qtyMap[code] || 0) |
| ... | ... | @@ -1182,7 +1201,9 @@ export default { |
| 1182 | 1201 | display: flex; |
| 1183 | 1202 | align-items: center; |
| 1184 | 1203 | gap: 16rpx; |
| 1185 | - | |
| 1204 | +:deep(.u-number-box__input) { | |
| 1205 | + width: 80px!important; | |
| 1206 | + } | |
| 1186 | 1207 | // 输入框占满剩余宽度(原 u-number-box 自带固定宽度,换成 up-input 后需显式撑开) |
| 1187 | 1208 | .number-input-wrap { |
| 1188 | 1209 | flex: 1; |
| ... | ... | @@ -1323,4 +1344,6 @@ export default { |
| 1323 | 1344 | font-weight: 500; |
| 1324 | 1345 | } |
| 1325 | 1346 | } |
| 1347 | + | |
| 1348 | + | |
| 1326 | 1349 | </style> | ... | ... |
pages-sub/daily/maintain-manage/index.vue
| ... | ... | @@ -43,9 +43,10 @@ |
| 43 | 43 | box-shadow="0 4rpx 16rpx rgba(17, 24, 39, 0.06)" |
| 44 | 44 | v-for="(item,index) in currentList" |
| 45 | 45 | :key="`${item.planNo}_${index}`" |
| 46 | + @click="goToDetail(item)" | |
| 46 | 47 | > |
| 47 | 48 | <!-- 卡片标题:道路名称 --> |
| 48 | - <template #head> | |
| 49 | + <template #head > | |
| 49 | 50 | <view class="card-header"> |
| 50 | 51 | <view class="common-card-title common-name u-line-1">{{ item.roadName || '无道路名称' }}</view> |
| 51 | 52 | </view> |
| ... | ... | @@ -66,7 +67,7 @@ |
| 66 | 67 | </view> |
| 67 | 68 | <!-- 操作区:统一收底 --> |
| 68 | 69 | <view class="card-action-row"> |
| 69 | - <view class="mini-btn mini-btn--primary" @click="goToDetail(item)">执行任务</view> | |
| 70 | + <view class="mini-btn mini-btn--primary">执行任务</view> | |
| 70 | 71 | </view> |
| 71 | 72 | </view> |
| 72 | 73 | </template> |
| ... | ... | @@ -230,6 +231,7 @@ onShow(() => { |
| 230 | 231 | position: absolute; |
| 231 | 232 | top: 50px; |
| 232 | 233 | right: 20px; |
| 234 | + border-top: none; | |
| 233 | 235 | } |
| 234 | 236 | } |
| 235 | 237 | /* 卡片体 */ | ... | ... |