Commit 1594be1c2fcfbcd4d75627da70bdc2a843c9e4e6

Authored by 刘淇
1 parent 06eeda54

type==1 改为数字加减器

pages-sub/daily/maintain-manage/add-record.vue
@@ -14,12 +14,8 @@ @@ -14,12 +14,8 @@
14 14
15 <!-- type 1 数值:用可空态的输入框,避免 u-number-box 把空值显示成 1 却不回写模型(未填写会被当成已填 1) --> 15 <!-- type 1 数值:用可空态的输入框,避免 u-number-box 把空值显示成 1 却不回写模型(未填写会被当成已填 1) -->
16 <view v-if="item.fieldType === 1" class="number-box-wrap"> 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 <text class="unit-text" v-if="item.unit">{{ item.unit }}</text> 20 <text class="unit-text" v-if="item.unit">{{ item.unit }}</text>
25 </view> 21 </view>
@@ -448,6 +444,10 @@ export default { @@ -448,6 +444,10 @@ export default {
448 } else { 444 } else {
449 this.inspectForm[field.fieldCode] = '' 445 this.inspectForm[field.fieldCode] = ''
450 } 446 }
  447 + if(field.fieldType === 1){
  448 + // 数值步进器默认0
  449 + this.qtyMap[field.fieldCode] = 0
  450 +}
451 // 初始化展示label为空 451 // 初始化展示label为空
452 this.labelMap[field.fieldCode] = '' 452 this.labelMap[field.fieldCode] = ''
453 // 7图片/8附件的文件列表(驱动 up-upload 与自绘文件列表展示) 453 // 7图片/8附件的文件列表(驱动 up-upload 与自绘文件列表展示)
@@ -661,6 +661,24 @@ export default { @@ -661,6 +661,24 @@ export default {
661 */ 661 */
662 buildRequiredRule(field: any) { 662 buildRequiredRule(field: any) {
663 const type = field.fieldType 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 if (type === 6 || type === 7 || type === 8) { 682 if (type === 6 || type === 7 || type === 8) {
665 const action = type === 6 ? '请选择' : '请上传' 683 const action = type === 6 ? '请选择' : '请上传'
666 return { 684 return {
@@ -881,7 +899,8 @@ export default { @@ -881,7 +899,8 @@ export default {
881 } 899 }
882 900
883 if (type === 1) { 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 } else if (type === 3 && item.optionSource === 3) { 904 } else if (type === 3 && item.optionSource === 3) {
886 // 物料:value_text 存物料ID;数量>0 才落物料三列(0 表示本次不领用) 905 // 物料:value_text 存物料ID;数量>0 才落物料三列(0 表示本次不领用)
887 const qty = Number(this.qtyMap[code] || 0) 906 const qty = Number(this.qtyMap[code] || 0)
@@ -1182,7 +1201,9 @@ export default { @@ -1182,7 +1201,9 @@ export default {
1182 display: flex; 1201 display: flex;
1183 align-items: center; 1202 align-items: center;
1184 gap: 16rpx; 1203 gap: 16rpx;
1185 - 1204 +:deep(.u-number-box__input) {
  1205 + width: 80px!important;
  1206 + }
1186 // 输入框占满剩余宽度(原 u-number-box 自带固定宽度,换成 up-input 后需显式撑开) 1207 // 输入框占满剩余宽度(原 u-number-box 自带固定宽度,换成 up-input 后需显式撑开)
1187 .number-input-wrap { 1208 .number-input-wrap {
1188 flex: 1; 1209 flex: 1;
@@ -1323,4 +1344,6 @@ export default { @@ -1323,4 +1344,6 @@ export default {
1323 font-weight: 500; 1344 font-weight: 500;
1324 } 1345 }
1325 } 1346 }
  1347 +
  1348 +
1326 </style> 1349 </style>
pages-sub/daily/maintain-manage/index.vue
@@ -43,9 +43,10 @@ @@ -43,9 +43,10 @@
43 box-shadow="0 4rpx 16rpx rgba(17, 24, 39, 0.06)" 43 box-shadow="0 4rpx 16rpx rgba(17, 24, 39, 0.06)"
44 v-for="(item,index) in currentList" 44 v-for="(item,index) in currentList"
45 :key="`${item.planNo}_${index}`" 45 :key="`${item.planNo}_${index}`"
  46 + @click="goToDetail(item)"
46 > 47 >
47 <!-- 卡片标题:道路名称 --> 48 <!-- 卡片标题:道路名称 -->
48 - <template #head> 49 + <template #head >
49 <view class="card-header"> 50 <view class="card-header">
50 <view class="common-card-title common-name u-line-1">{{ item.roadName || '无道路名称' }}</view> 51 <view class="common-card-title common-name u-line-1">{{ item.roadName || '无道路名称' }}</view>
51 </view> 52 </view>
@@ -66,7 +67,7 @@ @@ -66,7 +67,7 @@
66 </view> 67 </view>
67 <!-- 操作区:统一收底 --> 68 <!-- 操作区:统一收底 -->
68 <view class="card-action-row"> 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 </view> 71 </view>
71 </view> 72 </view>
72 </template> 73 </template>
@@ -230,6 +231,7 @@ onShow(() =&gt; { @@ -230,6 +231,7 @@ onShow(() =&gt; {
230 position: absolute; 231 position: absolute;
231 top: 50px; 232 top: 50px;
232 right: 20px; 233 right: 20px;
  234 + border-top: none;
233 } 235 }
234 } 236 }
235 /* 卡片体 */ 237 /* 卡片体 */