Commit 1d92efc40ec4f8e40e624430b4f3063a37ebc743

Authored by 刘淇
1 parent 638137f1

判断动态表单每一项必填?

pages-sub/daily/maintain-manage/add-record.vue
@@ -142,6 +142,19 @@ @@ -142,6 +142,19 @@
142 <text>提交并结束本次任务</text> 142 <text>提交并结束本次任务</text>
143 </view> 143 </view>
144 </view> 144 </view>
  145 +
  146 +
  147 + <!-- 强制弹窗:全部字段required=0,必须去平台配置至少一项必填 -->
  148 + <up-modal
  149 + :show="showNoRequiredModal"
  150 + title="配置校验提示"
  151 + content="请先去平台属性配置,至少配置一项为必填。"
  152 + :show-cancel-button="false"
  153 + :close-on-click-overlay="false"
  154 + @confirm="handleNoRequiredConfirm"
  155 + ></up-modal>
  156 +
  157 +
145 <!-- uview-plus 日期时间选择器(全局复用) --> 158 <!-- uview-plus 日期时间选择器(全局复用) -->
146 <up-datetime-picker :show="datePickerShow" v-model="datePickerValue" mode="datetime" close-on-click-overlay 159 <up-datetime-picker :show="datePickerShow" v-model="datePickerValue" mode="datetime" close-on-click-overlay
147 @confirm="onDateConfirm" @cancel="onDateClose" @close="onDateClose"></up-datetime-picker> 160 @confirm="onDateConfirm" @cancel="onDateClose" @close="onDateClose"></up-datetime-picker>
@@ -201,6 +214,7 @@ export default { @@ -201,6 +214,7 @@ export default {
201 } 214 }
202 ], 215 ],
203 }, 216 },
  217 + showNoRequiredModal: false,
204 // 动态字段列表 218 // 动态字段列表
205 dynamicFields: [] as any[], 219 dynamicFields: [] as any[],
206 // 日期时间选择器 220 // 日期时间选择器
@@ -502,15 +516,28 @@ export default { @@ -502,15 +516,28 @@ export default {
502 this.inspectFormRules[field.fieldCode] = [this.buildRequiredRule(field)] 516 this.inspectFormRules[field.fieldCode] = [this.buildRequiredRule(field)]
503 } 517 }
504 } 518 }
505 - this.dynamicFields = fields 519 + this.dynamicFields = fields
  520 +
  521 + // =========新增:校验全部字段required都等于0=========
  522 + const allNoRequired = this.dynamicFields.every(item => Number(item.required) === 0)
  523 + if(allNoRequired){
  524 + this.showNoRequiredModal = true
  525 + }
  526 +
506 this.$nextTick(() => { 527 this.$nextTick(() => {
507 this.$refs.inspectFormRef.setRules(this.inspectFormRules) 528 this.$refs.inspectFormRef.setRules(this.inspectFormRules)
508 }) 529 })
  530 +
509 } catch (err) { 531 } catch (err) {
510 console.error('获取动态表单字段失败:', err) 532 console.error('获取动态表单字段失败:', err)
511 uni.showToast({ title: '加载表单配置失败', icon: 'none' }) 533 uni.showToast({ title: '加载表单配置失败', icon: 'none' })
512 } 534 }
513 }, 535 },
  536 +
  537 + handleNoRequiredConfirm(){
  538 + // 弹窗只能点确定,直接退出页面,不允许继续填报
  539 + uni.navigateBack()
  540 + },
514 /** 541 /**
515 * 删除图片 542 * 删除图片
516 */ 543 */
@@ -1075,10 +1102,10 @@ if (type === 1) { @@ -1075,10 +1102,10 @@ if (type === 1) {
1075 } 1102 }
1076 uni.hideLoading() 1103 uni.hideLoading()
1077 // 后端 /create 只建草稿、不推进完成次数,必须再点「提交并结束」或在列表点「结束任务」才计数 1104 // 后端 /create 只建草稿、不推进完成次数,必须再点「提交并结束」或在列表点「结束任务」才计数
1078 - uni.showToast({ title: '已暂存,请记得结束本次养护', icon: 'none', duration: 1500 }) 1105 + uni.showToast({ title: '已暂存,请记得结束本次养护', icon: 'none', duration: 2500 })
1079 setTimeout(() => { 1106 setTimeout(() => {
1080 uni.reLaunch({ url: '/pages-sub/daily/maintain-manage/index' }) 1107 uni.reLaunch({ url: '/pages-sub/daily/maintain-manage/index' })
1081 - }, 1500) 1108 + }, 2500)
1082 } catch (error) { 1109 } catch (error) {
1083 uni.hideLoading() 1110 uni.hideLoading()
1084 // 表单校验失败时 error 是字段数组(uview-plus 已提示),不重复弹 1111 // 表单校验失败时 error 是字段数组(uview-plus 已提示),不重复弹
pages-sub/daily/maintain-manage/finish-plan-detail.vue
@@ -627,6 +627,7 @@ onLoad((options) =&gt; { @@ -627,6 +627,7 @@ onLoad((options) =&gt; {
627 display: flex; 627 display: flex;
628 flex-direction: column; 628 flex-direction: column;
629 align-items: flex-start; 629 align-items: flex-start;
  630 + overflow: hidden;
630 gap: 8rpx; 631 gap: 8rpx;
631 margin: 0 24rpx 24rpx; 632 margin: 0 24rpx 24rpx;
632 padding: 24rpx; 633 padding: 24rpx;
pages-sub/daily/maintain-manage/type-list-page.vue
@@ -62,7 +62,7 @@ @@ -62,7 +62,7 @@
62 <!-- 待完成:去作业;已完成:去查看 --> 62 <!-- 待完成:去作业;已完成:去查看 -->
63 <view v-if="activeStatus === '1'" class="mini-btn btn-brand-solid" @click.stop="handleGoWork(item)">去作业</view> 63 <view v-if="activeStatus === '1'" class="mini-btn btn-brand-solid" @click.stop="handleGoWork(item)">去作业</view>
64 <view v-else-if="activeStatus === '2'" class="mini-btn mini-btn--info" @click.stop="handleGoWorkLook(item)">去查看</view> 64 <view v-else-if="activeStatus === '2'" class="mini-btn mini-btn--info" @click.stop="handleGoWorkLook(item)">去查看</view>
65 - <view v-else-if="activeStatus === '3'" class="mini-btn mini-btn--info" @click.stop="handleGoWorkLook(item)">去查看</view> 65 + <!-- <view v-else-if="activeStatus === '3'" class="mini-btn mini-btn--info" @click.stop="handleGoWorkLook(item)">去查看</view> -->
66 </view> 66 </view>
67 </view> 67 </view>
68 </view> 68 </view>
@@ -89,7 +89,7 @@ @@ -89,7 +89,7 @@
89 <!-- ========== 结束任务二次确认弹窗 ========== --> 89 <!-- ========== 结束任务二次确认弹窗 ========== -->
90 <up-modal :show="endTaskModalShow" title="提示" :closeOnClickOverlay="false" :showConfirmButton="true" 90 <up-modal :show="endTaskModalShow" title="提示" :closeOnClickOverlay="false" :showConfirmButton="true"
91 :showCancelButton="true" @cancel="handleEndTaskModalCancel" @confirm="confirmEndTask"> 91 :showCancelButton="true" @cancel="handleEndTaskModalCancel" @confirm="confirmEndTask">
92 - <view class="end-task-modal-content" style="font-size: 14px;"> 92 + <view class="end-task-modal-content" style="font-size: 16px;">
93 <text>确定要结束吗?</text> 93 <text>确定要结束吗?</text>
94 </view> 94 </view>
95 </up-modal> 95 </up-modal>