fb13622a
刘淇
养护计划列表 样式 差去一个卡片的头部
|
1
|
<template>
|
d433e7f6
刘淇
工单
|
2
|
<view class="page-container">
|
e8f5dac4
刘淇
三级联动
|
3
|
<view class="inspect-form-content commonPageLRpadding" ref="formContentRef">
|
de549a92
刘淇
养护。动态表单
|
4
5
6
|
<up-form label-position="left" :model="inspectForm" ref="inspectFormRef" label-width="140rpx">
<!-- ========== 动态表单区域 ========== -->
<template v-for="item in dynamicFields" :key="item.fieldCode">
|
7da61cdb
刘淇
养护计划
|
7
8
|
<up-form-item :label="item.fieldName" :prop="item.fieldCode" class="form-item"
@click="openPickerIfNeeded(item)">
|
13203a04
刘淇
首页 统计
|
9
|
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
10
|
<!-- type 1 数值:u-number-box,最多2位小数,min=0,max取item.length -->
|
de549a92
刘淇
养护。动态表单
|
11
|
<view v-if="item.fieldType === 1" class="number-box-wrap">
|
7da61cdb
刘淇
养护计划
|
12
13
14
15
16
|
<u-number-box v-model="inspectForm[item.fieldCode]" min="1" :step="1"
:max="item.length ? 10 ** Number(item.length) - 1 : null"
:placeholder="`请输入${item.fieldName}${item.unit} `" @change="valChange(item)" @blur="valChange(item)"
class="large-number-box">
</u-number-box>
|
13203a04
刘淇
首页 统计
|
17
|
|
de549a92
刘淇
养护。动态表单
|
18
19
|
<text class="unit-text" v-if="item.unit">{{ item.unit }}</text>
</view>
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
20
21
|
<!-- type 2 文本 -->
<up-input v-else-if="item.fieldType === 2" v-model="inspectForm[item.fieldCode]"
|
7da61cdb
刘淇
养护计划
|
22
|
:maxlength="item.length || 50" :placeholder="`请输入${item.fieldName}`"></up-input>
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
23
24
25
|
<!-- 分层选项(3枚举/6多选,且选项带 path):统一只读入口,点开分组弹层选择。
必须放在下面的 3/6 分支之前——v-else-if 短路,放后面就永远进不来 -->
<up-input v-else-if="isGroupedField(item)" v-model="labelMap[item.fieldCode]" readonly
|
7da61cdb
刘淇
养护计划
|
26
|
disabled-color="#ffffff" :placeholder="`请选择${item.fieldName}`" border="none">
|
de549a92
刘淇
养护。动态表单
|
27
28
29
30
|
<template #right>
<up-icon name="arrow-right" size="16"></up-icon>
</template>
</up-input>
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
31
32
|
<!-- type3 枚举:多选 multiple=1 使用复选框组(name 必须是 value,提交按逗号拼接 value,与值格式契约一致) -->
<u-checkbox-group v-else-if="item.fieldType === 3 && item.multiple === 1"
|
7da61cdb
刘淇
养护计划
|
33
|
v-model="inspectForm[item.fieldCode]">
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
34
|
<u-checkbox v-for="opt in item.selectOptions" :key="opt.value" :label="opt.label" :name="opt.value">
|
ee792d52
刘淇
动态表单
|
35
|
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
36
37
38
39
|
</u-checkbox>
</u-checkbox-group>
<!-- type3 枚举:单选 用up-action-sheet 底部选择 -->
<up-input v-else-if="item.fieldType === 3" v-model="labelMap[item.fieldCode]" readonly
|
7da61cdb
刘淇
养护计划
|
40
|
disabled-color="#ffffff" :placeholder="`请选择${item.fieldName}`" border="none">
|
ee792d52
刘淇
动态表单
|
41
42
43
44
|
<template #right>
<up-icon name="arrow-right" size="16"></up-icon>
</template>
</up-input>
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
45
46
47
48
49
50
51
52
53
54
55
56
57
|
<!-- type4 日期时间 -->
<view v-else-if="item.fieldType === 4" @click.stop="openDatePicker(item)" class="date-input-wrap">
<up-input v-model="inspectForm[item.fieldCode]" disabled placeholder="点击选择时间"></up-input>
</view>
<!-- type5 布尔单选 是/否 【重点修复】增加空label=""占位项 -->
<up-radio-group v-else-if="item.fieldType === 5" v-model="inspectForm[item.fieldCode]">
<up-radio label="是" name="是"></up-radio>
<up-radio label="否" name="否"></up-radio>
</up-radio-group>
<!-- type6 多选:复选框组;选项来源可为静态/字典/物料/数据表/SQL/接口(物料不再占用 6 号) -->
<view v-else-if="item.fieldType === 6" class="multi-wrap">
<u-checkbox-group v-model="inspectForm[item.fieldCode]" @change="onMultiChange(item)">
<u-checkbox v-for="opt in item.selectOptions" :key="opt.value" :label="opt.label" :name="opt.value"
|
7da61cdb
刘淇
养护计划
|
58
|
:disabled="isOptionLocked(item, opt)">
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
59
60
61
62
63
64
65
66
67
68
69
70
71
|
</u-checkbox>
</u-checkbox-group>
<!-- 有限上限时提示已选数。上限靠「禁用未选中项」实现:u-checkbox 的勾选态在组件内部,回写 v-model 撤不掉 -->
<text v-if="multiHint(item)" class="multi-hint">{{ multiHint(item) }}</text>
<!-- needQuantity:已选项各配一个数量输入,值按 {value,label,quantity} 提交。此形态仅记录用量、不扣库存 -->
<view v-if="needQty(item)" class="qty-list">
<view v-for="opt in checkedOptions(item)" :key="opt.value" class="qty-row">
<text class="qty-label">{{ opt.label }}</text>
<u-number-box v-model="qtyMap[item.fieldCode][opt.value]" :min="0" :step="1"></u-number-box>
</view>
</view>
</view>
<!-- type7 图片:多张上传,提交 JSON 数组(URL) -->
|
7da61cdb
刘淇
养护计划
|
72
73
74
75
76
77
|
<!-- type7 图片:多张上传,提交 JSON 数组(URL) -->
<!-- type7 图片:多张上传,提交 JSON 数组(URL)【对齐工单上传组件】 -->
<up-upload v-else-if="item.fieldType === 7" :file-list="fileListMap[item.fieldCode] || []"
@after-read="(event) => uploadFieldFiles(item, event)" @delete="(event) => deleteFieldFile(item, event)"
multiple width="70" height="70" :sizeType="['compressed']" :max-count="pickCountOf(item, 5)"
upload-text="选择图片" del-color="#ff4d4f" class="upload-wrap"></up-upload>
|
e8f5dac4
刘淇
三级联动
|
78
79
|
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
80
|
<!-- type8 附件:微信只能从聊天记录选文件(无通用文件选择器),提交 JSON 数组(URL) -->
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
81
|
<view v-else-if="item.fieldType === 8" class="file-wrap">
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
82
|
<view v-for="(file, idx) in fileListMap[item.fieldCode] || []" :key="idx" class="file-row">
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
83
|
<text class="file-name">{{ file.name || fileNameOf(file.url) }}</text>
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
84
|
<text class="file-del" @click.stop="deleteFieldFile(item, { index: idx })">删除</text>
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
85
|
</view>
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
86
|
<up-button size="small" type="primary" plain :text="fileButtonText(item)"
|
7da61cdb
刘淇
养护计划
|
87
|
@click.stop="chooseFieldFiles(item)"></up-button>
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
88
|
</view>
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
89
90
|
<!-- type9 关联记录:底部选择,提交 JSON 数组 [{id,name}] -->
<up-input v-else-if="item.fieldType === 9" v-model="labelMap[item.fieldCode]" readonly
|
7da61cdb
刘淇
养护计划
|
91
|
disabled-color="#ffffff" :placeholder="`请选择${item.fieldName}`" border="none">
|
de549a92
刘淇
养护。动态表单
|
92
93
94
95
|
<template #right>
<up-icon name="arrow-right" size="16"></up-icon>
</template>
</up-input>
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
96
97
|
<!-- type10 链接:URL 输入,提交裸 URL -->
<up-input v-else-if="item.fieldType === 10" v-model.trim="inspectForm[item.fieldCode]"
|
7da61cdb
刘淇
养护计划
|
98
|
:placeholder="`请输入${item.fieldName}(http/https 开头)`"></up-input>
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
99
100
|
<!-- type11 地理位置:uni.chooseLocation 选点,提交 JSON 对象 {lng,lat,address} -->
<up-input v-else-if="item.fieldType === 11" v-model="labelMap[item.fieldCode]" readonly
|
7da61cdb
刘淇
养护计划
|
101
|
disabled-color="#ffffff" :placeholder="`点击选择${item.fieldName}`" border="none">
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
102
103
104
105
|
<template #right>
<up-icon name="arrow-right" size="16"></up-icon>
</template>
</up-input>
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
106
107
108
|
<!-- 物料(fieldType=3 + optionSource=3):额外收领用数量;数量>0 才提交 materialId/materialName/quantity 触发扣库存。
必须放在 v-if/v-else-if 链末尾——插在中间会打断链导致编译报错 -->
<view v-if="item.fieldType === 3 && item.optionSource === 3" class="qty-row qty-row-material">
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
109
|
<text class="qty-label">领用数量</text>
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
110
|
<u-number-box v-model="qtyMap[item.fieldCode]" :min="0" :step="1"></u-number-box>
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
111
|
</view>
|
de549a92
刘淇
养护。动态表单
|
112
113
114
|
</up-form-item>
</template>
<!-- ========== 动态表单结束 ========== -->
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
115
|
<!-- 1. 养护描述(文本域) -->
|
e8f5dac4
刘淇
三级联动
|
116
|
<!-- <up-form-item prop="remark" class="form-item">
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
117
|
<up-textarea v-model.trim="inspectForm.remark" placeholder="请输入养护描述" maxlength="200" count></up-textarea>
|
e8f5dac4
刘淇
三级联动
|
118
|
</up-form-item> -->
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
119
|
<!-- 2. 上传图片 -->
|
e8f5dac4
刘淇
三级联动
|
120
|
<!-- <up-form-item label="上传图片" prop="images" required class="form-item">
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
121
122
123
|
<up-upload :file-list="imagesList" @after-read="(event) => uploadImgs(event)"
@delete="(event) => deleteImg(event)" @on-exceed="handleExceed" multiple :max-count="3" upload-text="选择图片"
del-color="#ff4d4f" class="upload-wrap"></up-upload>
|
e8f5dac4
刘淇
三级联动
|
124
|
</up-form-item> -->
|
fb13622a
刘淇
养护计划列表 样式 差去一个卡片的头部
|
125
126
|
</up-form>
</view>
|
7da61cdb
刘淇
养护计划
|
127
128
129
130
131
132
|
<!-- 底部双按钮 -->
<view v-if="dynamicFields.length === 0" class="empty-field-tip">
<text>请去平台配置业务类型字段</text>
</view>
<view class="fixed-bottom-btn-wrap" v-if="dynamicFields.length > 0">
<view class="btn-item btn-left" @click="submitInspect">
|
e0806267
王彪总
业务线 小程序不用写死,从后端接口获取
|
133
|
<text>暂存</text>
|
7da61cdb
刘淇
养护计划
|
134
135
136
137
138
|
</view>
<view class="btn-item btn-right" @click="submitAndFinish">
<text>提交并结束本次任务</text>
</view>
</view>
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
139
140
|
<!-- uview-plus 日期时间选择器(全局复用) -->
<up-datetime-picker :show="datePickerShow" v-model="datePickerValue" mode="datetime" close-on-click-overlay
|
7da61cdb
刘淇
养护计划
|
141
|
@confirm="onDateConfirm" @cancel="onDateClose" @close="onDateClose"></up-datetime-picker>
|
de549a92
刘淇
养护。动态表单
|
142
|
<!-- ActionSheet 底部选择弹窗 -->
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
143
|
<up-action-sheet :show="actionSheet.show" :actions="actionSheet.options" @select="onActionSheetSelect"
|
7da61cdb
刘淇
养护计划
|
144
|
@close="actionSheet.show = false" cancel-text="取消"></up-action-sheet>
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
145
146
|
<!-- 分层选项选择器(选项带 path 的动态字段) -->
<grouped-picker :show="groupPicker.show" :title="groupPicker.title" :options="groupPicker.options"
|
7da61cdb
刘淇
养护计划
|
147
148
149
|
:multiple="groupPicker.multiple" :max-count="groupPicker.maxCount" :need-quantity="groupPicker.needQuantity"
:value="groupPicker.value" :container-width="groupPicker.containerWidth" :quantities="groupPicker.quantities"
@update:show="groupPicker.show = $event" @confirm="onGroupedConfirm"></grouped-picker>
|
fb13622a
刘淇
养护计划列表 样式 差去一个卡片的头部
|
150
151
152
|
</view>
</template>
|
d433e7f6
刘淇
工单
|
153
154
|
<script lang="ts">
import { uploadImages } from '@/common/utils/upload'
|
7da61cdb
刘淇
养护计划
|
155
|
import { maintainCreate, maintainCreateFinish } from "@/api/maintain-manage/maintain-manage"
|
ee792d52
刘淇
动态表单
|
156
|
import { getByType, getOptionsByCode, getMaterialByCode, workRecordSubmit } from "@/api/common"
|
d433e7f6
刘淇
工单
|
157
158
159
|
export default {
data() {
return {
|
6847fb73
刘淇
置为失效
|
160
|
commitId:'',
|
7da61cdb
刘淇
养护计划
|
161
|
submitting: false,
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
162
|
imagesList: [],
|
d433e7f6
刘淇
工单
|
163
164
165
|
initProgress: 0,
inspectForm: {
remark: '',
|
d433e7f6
刘淇
工单
|
166
|
},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
167
|
// ========== 新增:用来存放展示文本label的映射对象 ==========
|
de549a92
刘淇
养护。动态表单
|
168
|
labelMap: {},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
169
|
// 类型7图片/8附件的每字段文件列表(fieldCode -> u-upload 兼容数组 {url,status,name})
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
170
|
fileListMap: {},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
171
|
// 数量收集:类型6+needQuantity 为 {选项值: 数量};类型3物料为标量(领用数量)
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
172
|
qtyMap: {},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
173
174
|
paramsOptins: {},
// 幂等流水号:本次填报页面生命周期内保持不变,重复提交(如网络超时后重试)只会落一条记录
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
175
|
clientSeq: '',
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
176
|
// 养护计划本体的 commit.id:取到后缓存,重试时不再重复创建养护记录
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
177
|
commitId: null,
|
d433e7f6
刘淇
工单
|
178
179
180
181
|
inspectFormRules: {
images: [
{
required: true,
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
182
|
message: '请上传图片',
|
d433e7f6
刘淇
工单
|
183
184
|
trigger: 'change',
validator: (rule, value, callback) => {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
185
186
187
188
189
190
|
const hasSuccessImg = this.imagesList.some(item => item.status === 'success')
const imgCount = this.imagesList.filter(item => item.status === 'success').length
if (!hasSuccessImg || imgCount < 1) {
callback(new Error('最少需要上传1张图片'))
} else if (imgCount > 3) {
callback(new Error('最多只能上传3张图片'))
|
d433e7f6
刘淇
工单
|
191
192
193
194
195
|
} else {
callback()
}
}
}
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
196
|
],
|
de549a92
刘淇
养护。动态表单
|
197
|
},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
198
199
200
|
// 动态字段列表
dynamicFields: [] as any[],
// 日期时间选择器
|
de549a92
刘淇
养护。动态表单
|
201
|
datePickerShow: false,
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
202
|
datePickerValue: Number(new Date()),
|
de549a92
刘淇
养护。动态表单
|
203
|
currentDateFieldCode: '',
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
204
205
206
207
208
209
210
211
212
|
// actionSheet配置
actionSheet: {
show: false,
fieldCode: '', // 当前操作的字段
options: [] as any[],
fieldItem: null // 保存当前点击的field对象,用于后面查找label
},
// 分层选项选择器配置(选项带 path 的 3/6 字段用,其余字段仍走上面的 actionSheet / 内联复选框)
groupPicker: {
|
50ad810a
王彪总
业务线 小程序不用写死,从后端接口获取
|
213
214
|
show: false,
fieldCode: '',
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
215
216
217
218
219
220
221
222
|
fieldItem: null as any,
title: '',
options: [] as any[],
multiple: false,
maxCount: Infinity,
needQuantity: false,
value: '' as any,
quantities: {} as any,
|
ecfadea2
王彪总
业务线 小程序不用写死,从后端接口获取
|
223
|
// 数量单位不再传进弹层(原型列表行右侧只有步进器,没有单位),页面行内仍显示 item.unit
|
e8f5dac4
刘淇
三级联动
|
224
225
|
unit: '',
// 新增:由父页面点击时赋值
|
7da61cdb
刘淇
养护计划
|
226
|
containerWidth: 0
|
d433e7f6
刘淇
工单
|
227
228
229
230
231
|
}
}
},
onLoad(option) {
console.log('页面参数:', option)
|
3c3d6799
刘淇
重点巡检区域
|
232
|
this.paramsOptins = option
|
6847fb73
刘淇
置为失效
|
233
|
const { businessType, planTypeId,commitId } = option
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
234
|
this.loadDynamicFields(businessType, planTypeId)
|
6847fb73
刘淇
置为失效
|
235
236
237
|
if(commitId){
this.commitId = commitId
}
|
d433e7f6
刘淇
工单
|
238
239
240
|
},
onReady() {
this.$refs.inspectFormRef.setRules(this.inspectFormRules)
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
241
|
console.log('巡查表单规则初始化完成')
|
d433e7f6
刘淇
工单
|
242
243
|
},
methods: {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
244
|
// number-box数值变更回调
|
de549a92
刘淇
养护。动态表单
|
245
|
valChange(item) {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
246
|
// 数值修改后触发表单校验
|
de549a92
刘淇
养护。动态表单
|
247
248
|
this.$refs.inspectFormRef.validateField(item.fieldCode)
},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
249
|
// ========== 日期时间相关方法 ==========
|
de549a92
刘淇
养护。动态表单
|
250
|
openDatePicker(field) {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
251
|
console.log('打开日期选择器', field)
|
de549a92
刘淇
养护。动态表单
|
252
253
|
this.currentDateFieldCode = field.fieldCode
const val = this.inspectForm[field.fieldCode]
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
254
|
this.datePickerValue = val ? new Date(val).getTime() : Number(new Date())
|
de549a92
刘淇
养护。动态表单
|
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
this.datePickerShow = true
uni.hideKeyboard()
},
onDateConfirm(e) {
const ts = e.value
const d = new Date(ts)
const y = d.getFullYear()
const m = String(d.getMonth() + 1).padStart(2, '0')
const day = String(d.getDate()).padStart(2, '0')
const h = String(d.getHours()).padStart(2, '0')
const mi = String(d.getMinutes()).padStart(2, '0')
const s = String(d.getSeconds()).padStart(2, '0')
this.inspectForm[this.currentDateFieldCode] = `${y}-${m}-${day} ${h}:${mi}:${s}`
this.datePickerShow = false
this.$refs.inspectFormRef.validateField(this.currentDateFieldCode)
},
onDateClose() {
this.datePickerShow = false
},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
/**
* 点击表单项时按类型决定弹出哪个选择器:
* 分层选项(带 path 的 3/6) → 分组弹层;3 枚举(单选) / 9 关联记录 → 底部 actionSheet;11 地理位置 → 微信地图选点
* 其余类型(多选、图片、附件、可输入的链接)不在这里处理,由控件自身响应
*/
openPickerIfNeeded(item: any) {
// 分层选项优先:它的只读入口是靠本方法打开弹层的(模板里 3/6 的原有分支已被 isGroupedField 挡在前面)
if (this.isGroupedField(item)) {
return this.openGroupedPicker(item)
}
// 条件与模板互补:模板用 multiple === 1 渲染复选框组,这里就必须用 !== 1 才打开弹窗,
// 否则 multiple 为 NULL/0 的存量单选枚举会既不渲染复选框、又点不开弹窗
if (item.fieldType === 3 && item.multiple !== 1) {
return this.openActionSheet(item)
}
if (item.fieldType === 9) {
return this.openActionSheet(item)
}
if (item.fieldType === 11) {
return this.openLocation(item)
}
},
/**
* 是否为「分层选项」字段:3枚举/6多选,且选项带了后端下发的 path。
* path 是纯增量字段,老字段(静态/字典/物料/数据表/接口/无 gN_ 别名的 SQL)没有它 → 走原路径,行为不变
*/
isGroupedField(item: any) {
if (!item || (item.fieldType !== 3 && item.fieldType !== 6)) {
return false
}
return (item.selectOptions || []).some((opt: any) => Array.isArray(opt.path) && opt.path.length > 0)
},
/**
* 打开分层选项弹层。单选/多选判定与模板同一口径:
* 6 → 多选;3 且 multiple===1 → 多选(提交按逗号拼接);3 其余 → 单选
*/
openGroupedPicker(item: any) {
const code = item.fieldCode
const multiple = item.fieldType === 6 || item.multiple === 1
this.groupPicker.fieldCode = code
this.groupPicker.fieldItem = item
this.groupPicker.title = item.fieldName
this.groupPicker.options = item.selectOptions || []
this.groupPicker.multiple = multiple
this.groupPicker.maxCount = this.maxCountOf(item, Infinity)
// 只有 6 多选需要每项数量;3 枚举没有这层语义
this.groupPicker.needQuantity = item.fieldType === 6 && this.needQty(item)
this.groupPicker.value = multiple ? (this.inspectForm[code] || []).slice() : (this.inspectForm[code] || '')
this.groupPicker.quantities = Object.assign({}, this.qtyMap[code] || {})
|
7da61cdb
刘淇
养护计划
|
323
324
325
326
327
328
329
330
331
|
// ========== 新增:点击打开弹窗瞬间,获取父表单容器宽度 ==========
const query = uni.createSelectorQuery().in(this)
query.select('.inspect-form-content').boundingClientRect((rect) => {
if (rect && rect.width) {
// rect.width 单位 px,直接传给子组件
this.groupPicker.containerWidth = rect.width
}
this.groupPicker.show = true
}).exec()
|
de549a92
刘淇
养护。动态表单
|
332
|
},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
|
/**
* 分层弹层确定回调。写入位置与原有两条路径完全一致(inspectForm/labelMap/qtyMap),
* 因此 buildDynamicFields() 一行都不用改
*/
onGroupedConfirm(payload: any) {
const code = this.groupPicker.fieldCode
this.inspectForm[code] = payload.values
this.labelMap[code] = payload.labelText
if (this.groupPicker.needQuantity) {
// 合并而不是替换:保留 loadDynamicFields 预建的选项键,避免非分层路径读到 undefined
this.qtyMap[code] = Object.assign({}, this.qtyMap[code] || {}, payload.quantities || {})
}
this.groupPicker.show = false
this.$refs.inspectFormRef.validateField(code)
},
/**
* 打开底部选择弹窗 actionSheet
*/
openActionSheet(item: any) {
this.actionSheet.fieldCode = item.fieldCode
this.actionSheet.fieldItem = item
// 选项统一挂在 selectOptions(静态来源直接用 field.options,物料来源调 materials 接口拿,其余调 options 接口)
// 物料带 currentNum 时在展示名后附库存余量(只影响展示名,提交的 materialName 仍取干净的 opt.label)
this.actionSheet.options = (item.selectOptions || []).map(opt => {
const stock = opt.currentNum === null || opt.currentNum === undefined || opt.currentNum === ''
|
7da61cdb
刘淇
养护计划
|
358
359
|
? NaN
: Number(opt.currentNum)
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
|
return {
name: isNaN(stock) ? opt.label : `${opt.label}(库存${stock}${opt.unit || ''})`,
value: opt.value
}
})
this.actionSheet.show = true
},
/**
* actionSheet选中回调
*/
onActionSheetSelect(selectedItem: any) {
const fieldItem = this.actionSheet.fieldItem
const fieldCode = this.actionSheet.fieldCode
// 1. 表单保存提交值:9 关联记录存 {id,name}(提交时转成 [{id,name}]),其余存裸 value
if (fieldItem && fieldItem.fieldType === 9) {
this.inspectForm[fieldCode] = { id: selectedItem.value, name: selectedItem.name }
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
376
|
} else {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
377
|
this.inspectForm[fieldCode] = selectedItem.value
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
378
|
}
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
379
380
381
382
|
// 2. labelMap保存label,给input展示
this.labelMap[fieldCode] = selectedItem.name
this.actionSheet.show = false
// 选中后触发表单校验
|
de549a92
刘淇
养护。动态表单
|
383
384
|
this.$refs.inspectFormRef.validateField(fieldCode)
},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
385
386
387
388
389
|
/**
* 类型11 地理位置:微信地图选点(无需地图 AK,manifest.json 已声明 requiredPrivateInfos)
* 提交形态 {lng,lat,address}
*/
openLocation(item: any) {
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
390
391
392
393
394
|
uni.chooseLocation({
success: (res) => {
this.inspectForm[item.fieldCode] = {
lng: res.longitude,
lat: res.latitude,
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
395
|
address: res.address || res.name || ''
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
396
|
}
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
397
|
this.labelMap[item.fieldCode] = res.address || res.name || `${res.latitude}, ${res.longitude}`
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
398
399
400
|
this.$refs.inspectFormRef.validateField(item.fieldCode)
},
fail: (err) => {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
401
402
403
|
console.error('地图选择失败', err)
if (err && err.errMsg && err.errMsg.indexOf('auth deny') > -1) {
uni.showToast({ title: '请授权位置权限', icon: 'none' })
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
404
405
406
407
|
}
}
})
},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
408
409
410
|
/**
* 加载动态字段
*/
|
de549a92
刘淇
养护。动态表单
|
411
412
|
async loadDynamicFields(businessType: string, workTypeId: string) {
if (!businessType || !workTypeId) {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
413
|
uni.showToast({ title: '缺少业务参数', icon: 'none' })
|
de549a92
刘淇
养护。动态表单
|
414
415
|
return
}
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
416
|
const bizType = 3
|
de549a92
刘淇
养护。动态表单
|
417
|
try {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
418
419
420
421
422
|
const res = await getByType({
businessType,
workTypeId,
bizType
})
|
de549a92
刘淇
养护。动态表单
|
423
424
|
let fields = res.fields || []
fields.sort((a, b) => a.sort - b.sort)
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
425
426
427
428
429
|
if (fields.length === 0) {
uni.showToast({ title: '暂无需填报项', icon: 'none' })
this.dynamicFields = []
return
}
|
de549a92
刘淇
养护。动态表单
|
430
|
for (const field of fields) {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
431
432
|
// 初值:多选为数组;9关联记录/11地理位置 为对象(未选为 null);7图片/8附件为 URL 数组;其余空字符串
if (field.fieldType === 6 || (field.fieldType === 3 && field.multiple === 1)) {
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
433
434
435
436
437
|
this.inspectForm[field.fieldCode] = []
} else if (field.fieldType === 7 || field.fieldType === 8) {
this.inspectForm[field.fieldCode] = []
} else if (field.fieldType === 9 || field.fieldType === 11) {
this.inspectForm[field.fieldCode] = null
|
de549a92
刘淇
养护。动态表单
|
438
|
} else {
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
439
|
this.inspectForm[field.fieldCode] = ''
|
de549a92
刘淇
养护。动态表单
|
440
|
}
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
441
|
// 初始化展示label为空
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
442
|
this.labelMap[field.fieldCode] = ''
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
443
|
// 7图片/8附件的文件列表(驱动 up-upload 与自绘文件列表展示)
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
444
445
|
if (field.fieldType === 7 || field.fieldType === 8) {
this.fileListMap[field.fieldCode] = []
|
de549a92
刘淇
养护。动态表单
|
446
|
}
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
447
448
449
|
// 选项装载:静态来源(1)直接用下发的 field.options,其余来源(2字典/3物料/4数据表/5SQL/6接口)调 options 接口,
// 由后端按 optionSource 分发。类型 3/6/9 需要选项,其余类型不需要
if (field.fieldType === 3 || field.fieldType === 6 || field.fieldType === 9) {
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
450
|
if (field.optionSource === 1 && Array.isArray(field.options)) {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
451
452
453
454
455
456
457
458
459
460
|
field.selectOptions = field.options.map(opt => ({ label: opt.label, value: String(opt.value), path: opt.path }))
} else if (field.optionSource === 3) {
// 物料来源:调 materials(比 options 多返回 currentNum 库存余量/unit),供选择时显示库存
const matRes = await getMaterialByCode({
businessType,
bizType,
workTypeId,
fieldCode: field.fieldCode
})
field.selectOptions = (matRes || []).map(mat => ({
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
461
|
label: mat.materialName,
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
462
463
464
|
value: String(mat.materialId),
currentNum: mat.currentNum,
unit: mat.unit
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
465
|
}))
|
de549a92
刘淇
养护。动态表单
|
466
|
} else {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
467
468
469
470
471
472
473
474
|
const optRes = await getOptionsByCode({
businessType,
bizType,
workTypeId,
fieldCode: field.fieldCode
})
// path 后端仅在 SQL 来源按 gN_key/gN_label 别名产出;透传后由 isGroupedField 判定是否走分层弹层
field.selectOptions = (optRes || []).map(opt => ({ label: opt.label, value: String(opt.value), path: opt.path }))
|
de549a92
刘淇
养护。动态表单
|
475
476
|
}
}
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
477
478
479
|
// 数量收集初始化(必须在 selectOptions 装载之后):
// 6多选+needQuantity 预建每个选项的键,避免模板 v-model 写到未定义的键上;
// 3物料为标量(领用数量),默认 0 = 本次不领用、不扣库存
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
480
|
if (field.fieldType === 6 && this.needQty(field)) {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
481
|
const qty = {}
|
7da61cdb
刘淇
养护计划
|
482
483
484
|
; (field.selectOptions || []).forEach(opt => {
qty[opt.value] = ''
})
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
485
|
this.qtyMap[field.fieldCode] = qty
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
486
|
}
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
487
|
if (field.fieldType === 3 && field.optionSource === 3) {
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
488
489
|
this.qtyMap[field.fieldCode] = 0
}
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
490
|
// 必填规则
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
491
|
if (field.required === 1) {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
492
|
this.inspectFormRules[field.fieldCode] = [this.buildRequiredRule(field)]
|
de549a92
刘淇
养护。动态表单
|
493
494
|
}
}
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
495
|
this.dynamicFields = fields
|
de549a92
刘淇
养护。动态表单
|
496
497
498
499
|
this.$nextTick(() => {
this.$refs.inspectFormRef.setRules(this.inspectFormRules)
})
} catch (err) {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
500
501
|
console.error('获取动态表单字段失败:', err)
uni.showToast({ title: '加载表单配置失败', icon: 'none' })
|
fb13622a
刘淇
养护计划列表 样式 差去一个卡片的头部
|
502
503
|
}
},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
|
/**
* 删除图片
*/
deleteImg(event) {
this.imagesList.splice(event.index, 1)
this.$refs.inspectFormRef.validateField('images')
uni.showToast({ title: '图片删除成功', icon: 'success' })
},
/**
* 上传图片
*/
async uploadImgs(event) {
const fileList = Array.isArray(event.file) ? event.file : [event.file]
const targetImgList = this.imagesList
const filePaths = fileList.map(item => item.url)
const tempItems = fileList.map(item => ({ ...item, status: 'uploading', message: '上传中' }))
const startIndex = targetImgList.length
targetImgList.push(...tempItems)
try {
const uploadResultUrls = await uploadImages({ filePaths, ignoreError: true })
uploadResultUrls.forEach((url, index) => {
if (targetImgList[startIndex + index]) {
targetImgList.splice(startIndex + index, 1, {
...fileList[index], status: 'success', message: '', url
})
}
})
if (uploadResultUrls.length < fileList.length) {
const failCount = fileList.length - uploadResultUrls.length
for (let i = uploadResultUrls.length; i < fileList.length; i++) {
if (targetImgList[startIndex + i]) {
targetImgList.splice(startIndex + i, 1, {
...fileList[i], status: 'failed', message: '上传失败'
})
}
}
uni.showToast({ title: `成功上传${uploadResultUrls.length}张,失败${failCount}张`, icon: 'none' })
} else {
uni.showToast({ title: `成功上传${fileList.length}张图片`, icon: 'success' })
}
this.$refs.inspectFormRef.validateField('images')
} catch (err) {
console.error('图片上传失败:', err)
for (let i = 0; i < fileList.length; i++) {
if (targetImgList[startIndex + i]) {
targetImgList.splice(startIndex + i, 1, {
...fileList[i], status: 'failed', message: '上传失败'
})
}
}
uni.showToast({ title: '图片上传失败,请重试', icon: 'none' })
this.$refs.inspectFormRef.validateField('images')
}
},
handleExceed() {
uni.showToast({ title: '最多只能上传3张图片', icon: 'none' })
},
getImgUrlList(imgList) {
return imgList.filter(item => item.status === 'success').map(item => item.url)
},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
564
565
566
567
568
569
|
// ========== 动态字段:渲染与取值辅助 ==========
/**
* 类型6 多选是否要求每项填「使用数量」(ext_config.needQuantity)
* 仅记录用量,不写物料三列 ⇒ 结构性不触发扣库存(扣减一律按值行 materialId 非空判定)
*/
needQty(item: any) {
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
570
571
|
return !!(item.extConfig && item.extConfig.needQuantity === true)
},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
|
/**
* 有效上限:ext_config.maxCount 的「填 0 表示不限」(PC 端提示语)在提交侧照此生效
* 未配置 → 类型默认值;配 0 → Infinity(不限);配正数 → 该数
*/
maxCountOf(item: any, defaultValue: number) {
const raw = item.extConfig ? item.extConfig.maxCount : undefined
if (raw === undefined || raw === null || raw === '') {
return defaultValue
}
const num = Number(raw)
if (isNaN(num)) {
return defaultValue
}
return num > 0 ? num : Infinity
},
/** 传给选择器的单次可选数量:上限为「不限」时用组件默认值 52(平台要求 count 是有限数) */
pickCountOf(item: any, defaultValue: number) {
const max = this.maxCountOf(item, defaultValue)
return max === Infinity ? 52 : max
},
/** 单文件大小上限(MB):ext_config.maxSizeMb,未配置时用默认值 */
maxSizeMbOf(item: any, defaultValue: number) {
const num = item.extConfig ? Number(item.extConfig.maxSizeMb) : NaN
return num > 0 ? num : defaultValue
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
596
|
},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
597
598
599
600
|
/** 类型8 允许的扩展名数组(ext_config.fileType,不含点) */
extensionsOf(item: any) {
const list = item.extConfig && item.extConfig.fileType
return Array.isArray(list) ? list : []
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
601
|
},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
602
603
604
|
fileButtonText(item: any) {
const exts = this.extensionsOf(item)
return exts.length ? `选择文件(${exts.join('/')})` : '选择文件'
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
605
|
},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
606
607
|
/** 从 URL 取末段当文件名(与 PC 端 FieldValueCell 同口径) */
fileNameOf(url: string) {
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
608
|
if (!url) return ''
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
609
|
const path = String(url).split('?')[0].split('#')[0]
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
610
611
|
const name = path.substring(path.lastIndexOf('/') + 1)
try {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
612
613
614
|
return decodeURIComponent(name) || url
} catch (err) {
return name || url
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
615
|
}
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
616
|
},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
|
/** 类型6 已勾选的选项(用于渲染每个已选项的数量输入行) */
checkedOptions(item: any) {
const values = this.inspectForm[item.fieldCode] || []
return (item.selectOptions || []).filter(opt => values.indexOf(opt.value) > -1)
},
/**
* 多选是否达到上限(用于禁用未选中项)。
* 不用「超限后回写 v-model 截断」:u-checkbox 的勾选态是组件内部状态(只受 checked prop 影响),
* 回写父级 v-model 撤不掉已经勾上的项,下一次点击还会按内部状态重新算一遍,等于没限住
*/
isOptionLocked(item: any, opt: any) {
const max = this.maxCountOf(item, Infinity)
if (max === Infinity) {
return false
}
const values = this.inspectForm[item.fieldCode] || []
return values.length >= max && values.indexOf(opt.value) === -1
},
/** 多选的「已选 x/上限」提示,不限时返回空串 */
multiHint(item: any) {
const max = this.maxCountOf(item, Infinity)
if (max === Infinity) {
return ''
}
return `已选 ${(this.inspectForm[item.fieldCode] || []).length}/${max}`
},
onMultiChange(item: any) {
// 上限由 isOptionLocked 禁用未选项保证,这里只负责触发必填校验
this.$refs.inspectFormRef.validateField(item.fieldCode)
},
/**
* 必填规则。
* 7/8/9/11 的值是数组或对象,async-validator 的 required 按默认 string 类型判定,
* 会放过「空数组」「null」⇒ 必须用 validator 显式判空,否则未选也能提交
*/
|
7da61cdb
刘淇
养护计划
|
652
653
654
655
656
657
658
659
660
661
662
|
buildRequiredRule(field: any) {
const type = field.fieldType
if (type === 6 || type === 7 || type === 8) {
const action = type === 6 ? '请选择' : '请上传'
return {
required: true,
trigger: ['change', 'blur'],
validator: (rule, value, callback) => {
Array.isArray(value) && value.length > 0 ? callback() : callback(new Error(`${action}${field.fieldName}`))
}
}
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
663
|
}
|
7da61cdb
刘淇
养护计划
|
664
665
666
667
668
669
670
671
|
if (type === 9 || type === 11) {
return {
required: true,
trigger: ['change', 'blur'],
validator: (rule, value, callback) => {
value ? callback() : callback(new Error(type === 9 ? `请选择${field.fieldName}` : `请选择${field.fieldName}的位置`))
}
}
|
13203a04
刘淇
首页 统计
|
672
|
}
|
7da61cdb
刘淇
养护计划
|
673
674
675
676
677
678
679
680
681
682
683
684
685
|
// ========= 新增:数值类型单独校验 =========
if (type === 1) {
return {
required: true,
trigger: ['change', 'blur'],
validator: (rule, value, callback) => {
// 空字符串、null、undefined 才是空;数字 1,7,100 全部合法
if (value === '' || value === null || value === undefined) {
callback(new Error(`请填写${field.fieldName}`))
} else {
callback()
}
}
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
686
687
|
}
}
|
7da61cdb
刘淇
养护计划
|
688
689
690
691
692
693
694
695
|
// 2文本 /4日期 /5布尔 /10链接
const action = type === 3 || type === 5 ? '请选择' : '请填写'
return {
required: true,
message: `${action}${field.fieldName}`,
trigger: ['change', 'blur']
}
},
|
13203a04
刘淇
首页 统计
|
696
|
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
697
698
699
|
/** 幂等流水号(后端按 userId+clientSeq 去重,命中则返回已存在的 recordId) */
genClientSeq() {
return `${Date.now()}-${Math.random().toString(16).slice(2, 10)}`
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
700
|
},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
701
702
703
704
705
706
707
708
709
|
// ========== 动态字段:7图片/8附件 ==========
/** 单文件是否超过 ext_config.maxSizeMb(超限即 toast 并返回 true 以便过滤掉) */
isOversize(file: any, maxSizeMb: number) {
if (!maxSizeMb || !file || !file.size) return false
const over = file.size / 1024 / 1024 > maxSizeMb
if (over) {
uni.showToast({ title: `单个文件不能超过${maxSizeMb}MB`, icon: 'none' })
}
return over
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
710
|
},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
711
712
713
714
|
/** 把已上传成功的 URL 同步进表单值(提交与校验都读 inspectForm) */
syncFileValue(item: any) {
const list = this.fileListMap[item.fieldCode] || []
this.inspectForm[item.fieldCode] = list.filter(file => file.status === 'success').map(file => file.url)
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
715
|
},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
716
717
718
|
/**
* 7图片 上传(u-upload 的 after-read 回调)
*/
|
e8f5dac4
刘淇
三级联动
|
719
720
721
|
/**
* 7图片 上传(u-upload 的 after-read 回调)【对齐工单上传逻辑】
*/
|
7da61cdb
刘淇
养护计划
|
722
723
724
725
726
727
728
729
730
731
732
733
734
|
uploadFieldFiles(item: any, event: any) {
console.log('动态图片上传', item.fieldName, event)
const rawFile = event && event.file
const fileList = Array.isArray(rawFile) ? rawFile : [rawFile]
const targetImgList = this.fileListMap[item.fieldCode] || (this.fileListMap[item.fieldCode] = [])
const filePaths = fileList.map(file => file.url)
// const tempItems = fileList.map(item => ({
// ...item,
// status: 'uploading',
// message: '上传中'
// }))
// const startIndex = targetImgList.length
// targetImgList.push(...tempItems)
|
e8f5dac4
刘淇
三级联动
|
735
|
|
7da61cdb
刘淇
养护计划
|
736
737
738
739
740
741
|
this.uploadToField(item, fileList.filter(file => file && file.url).map(file => ({
url: file.url,
name: file.name || '',
size: file.size
})))
},
|
e8f5dac4
刘淇
三级联动
|
742
|
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
|
/**
* 8附件 选择并上传。
* 微信小程序没有通用文件选择器,只能从聊天记录里选(uni.chooseMessageFile)
*/
chooseFieldFiles(item: any) {
const maxCount = this.maxCountOf(item, 5)
const remain = maxCount - (this.fileListMap[item.fieldCode] || []).length
if (remain <= 0) {
uni.showToast({ title: `最多只能上传${maxCount}个`, icon: 'none' })
return
}
const exts = this.extensionsOf(item)
const options: any = { count: Math.min(remain, this.pickCountOf(item, 5)), type: 'file' }
if (exts.length) {
options.extension = exts
}
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
759
|
uni.chooseMessageFile({
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
760
|
...options,
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
761
|
success: (res) => {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
762
763
764
765
766
767
|
const tempFiles = res.tempFiles || []
this.uploadToField(item, tempFiles.map(file => ({
url: file.path,
name: file.name || '',
size: file.size
})))
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
768
769
|
},
fail: (err) => {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
770
|
console.error('选择附件失败:', err)
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
771
772
773
|
}
})
},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
774
775
776
777
|
/**
* 把选中的本地文件逐个上传并把 http 地址回填到 fileListMap / inspectForm。
* 7图片与8附件共用(uploadImages 是通用 uni.uploadFile,不限图片类型)
*/
|
7da61cdb
刘淇
养护计划
|
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
|
async uploadToField(item: any, files: any[]) {
const code = item.fieldCode
const maxCount = this.maxCountOf(item, 5)
const maxSizeMb = this.maxSizeMbOf(item, 5)
const validFiles = (files || []).filter(file => file && file.url && !this.isOversize(file, maxSizeMb))
if (!validFiles.length) {
return
}
const targetList = this.fileListMap[code] || (this.fileListMap[code] = [])
if (targetList.length + validFiles.length > maxCount) {
uni.showToast({ title: `最多只能上传${maxCount}个`, icon: 'none' })
return
}
// 保存起始下标
const startIndex = targetList.length
// 只在这里push一次
targetList.push(...validFiles.map(file => ({
url: file.url, status: 'uploading', message: '上传中', name: file.name || ''
})))
try {
const uploadResultUrls = await uploadImages({
filePaths: validFiles.map(file => file.url),
ignoreError: true
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
801
|
})
|
7da61cdb
刘淇
养护计划
|
802
803
804
805
806
|
uploadResultUrls.forEach((url, index) => {
// 用startIndex + index 替换对应条目
if (targetList[startIndex + index]) {
targetList.splice(startIndex + index, 1, {
url, status: 'success', message: '', name: validFiles[index].name || ''
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
807
808
809
|
})
}
})
|
7da61cdb
刘淇
养护计划
|
810
811
812
813
|
for (let i = uploadResultUrls.length; i < validFiles.length; i++) {
if (targetList[startIndex + i]) {
targetList.splice(startIndex + i, 1, {
url: validFiles[i].url, status: 'failed', message: '上传失败', name: validFiles[i].name || ''
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
814
815
816
|
})
}
}
|
7da61cdb
刘淇
养护计划
|
817
818
819
820
|
if (uploadResultUrls.length < validFiles.length) {
uni.showToast({
title: `成功${uploadResultUrls.length}个,失败${validFiles.length - uploadResultUrls.length}个`,
icon: 'none'
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
821
822
823
|
})
}
} catch (err) {
|
7da61cdb
刘淇
养护计划
|
824
825
826
827
828
|
console.error(`【${code}】文件上传失败:`, err)
for (let i = 0; i < validFiles.length; i++) {
if (targetList[startIndex + i]) {
targetList.splice(startIndex + i, 1, {
url: validFiles[i].url, status: 'failed', message: '上传失败', name: validFiles[i].name || ''
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
829
830
831
|
})
}
}
|
7da61cdb
刘淇
养护计划
|
832
|
uni.showToast({ title: '上传失败,请重试', icon: 'none' })
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
833
|
}
|
7da61cdb
刘淇
养护计划
|
834
835
836
|
this.syncFileValue(item)
this.$refs.inspectFormRef.validateField(code)
},
|
3c3d6799
刘淇
重点巡检区域
|
837
|
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
838
839
840
841
|
/**
* 删除 7图片/8附件 的某一个已选文件
*/
deleteFieldFile(item: any, event: any) {
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
842
|
const list = this.fileListMap[item.fieldCode] || []
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
843
844
845
846
847
848
849
|
const index = Number(event && event.index)
if (isNaN(index) || index < 0 || index >= list.length) {
return
}
list.splice(index, 1)
this.syncFileValue(item)
this.$refs.inspectFormRef.validateField(item.fieldCode)
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
850
|
},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
851
852
853
854
855
856
857
858
|
// ========== 动态字段:组装提交体 ==========
/**
* 按值格式契约组装 fields[](见 docs/design/app-work-field-api.md §四)。
* 两条硬规则:
* ① 空值一律不出现在 fields[] 里(不提交 ''/'[]'/'null')
* ② 物料的数量>0 才写 materialId/materialName/quantity —— 非空 materialId 即触发扣库存,
* 因此 6多选+needQuantity(只记录用量)绝不能写这三列,只把 quantity 放进 valueText 的 JSON 里
*/
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
859
|
buildDynamicFields() {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
860
|
const fields: any[] = []
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
861
862
863
864
865
866
867
|
for (const item of this.dynamicFields) {
const code = item.fieldCode
const value = this.inspectForm[code]
const type = item.fieldType
if (type === 9 || type === 11) {
if (!value) continue
} else if (type === 6 || type === 7 || type === 8) {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
868
869
870
871
|
if (!Array.isArray(value) || value.length === 0) continue
} else if (value === '' || value === null || value === undefined) {
continue
}
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
872
873
874
|
if (type === 1) {
fields.push({ fieldCode: code, valueNumber: Number(value) })
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
875
876
|
} else if (type === 3 && item.optionSource === 3) {
// 物料:value_text 存物料ID;数量>0 才落物料三列(0 表示本次不领用)
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
877
|
const qty = Number(this.qtyMap[code] || 0)
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
878
879
880
881
882
|
const matched = (item.selectOptions || []).filter(opt => opt.value === String(value))[0]
const row: any = { fieldCode: code, valueText: String(value) }
if (qty > 0) {
row.materialId = Number(value)
row.materialName = matched ? matched.label : ''
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
883
884
885
886
|
row.quantity = qty
}
fields.push(row)
} else if (type === 3) {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
887
|
// 3枚举:单选取裸 value;历史「枚举+是否多选」存逗号分隔
|
7da61cdb
刘淇
养护计划
|
888
889
890
891
892
893
|
fields.push({
fieldCode: code,
valueText: item.multiple === 1
? (Array.isArray(value) ? value.join(',') : String(value || ''))
: String(value)
})
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
894
|
} else if (type === 6) {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
895
|
const selected = (item.selectOptions || []).filter(opt => (value || []).indexOf(opt.value) > -1)
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
896
|
if (this.needQty(item)) {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
897
898
|
// 元素 {value,label,quantity};数量留空的不带 quantity 键(不臆测成 0),label 作快照落库
const qtyMap = this.qtyMap[code] || {}
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
899
900
901
|
fields.push({
fieldCode: code,
valueText: JSON.stringify(selected.map(opt => {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
902
903
|
const raw = qtyMap[opt.value]
const row: any = { value: opt.value, label: opt.label }
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
904
|
if (raw !== '' && raw !== null && raw !== undefined) {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
905
|
row.quantity = Number(raw)
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
906
|
}
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
907
|
return row
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
908
909
910
|
}))
})
} else {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
911
|
fields.push({ fieldCode: code, valueText: JSON.stringify(value.map(v => String(v))) })
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
912
913
914
915
916
917
|
}
} else if (type === 7 || type === 8) {
fields.push({ fieldCode: code, valueText: JSON.stringify(value) })
} else if (type === 9) {
fields.push({ fieldCode: code, valueText: JSON.stringify([{ id: value.id, name: value.name }]) })
} else if (type === 11) {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
918
919
920
921
|
fields.push({
fieldCode: code,
valueText: JSON.stringify({ lng: value.lng, lat: value.lat, address: value.address || '' })
})
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
922
|
} else {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
923
|
// 2文本 / 4日期 / 5布尔 / 10链接 均为裸文本
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
924
925
926
927
928
|
fields.push({ fieldCode: code, valueText: String(value) })
}
}
return fields
},
|
7da61cdb
刘淇
养护计划
|
929
930
|
async submitAndFinish() {
|
c4409bc7
刘淇
养护计划
|
931
|
if (this.submitting) return
|
7da61cdb
刘淇
养护计划
|
932
933
934
935
936
937
938
|
try {
await this.$refs.inspectFormRef.validate()
const dynamicValues = this.buildDynamicFields()
if (!this.clientSeq) {
this.clientSeq = this.genClientSeq()
}
uni.showLoading({ title: '提交中...' })
|
c4409bc7
刘淇
养护计划
|
939
|
this.submitting = true
|
7da61cdb
刘淇
养护计划
|
940
|
|
073562dd
王彪总
业务线 小程序不用写死,从后端接口获取
|
941
942
943
944
945
946
947
948
|
// 后端 AppMaintainPlanCommitSaveReqVO:imgHost 是 String(必填),beginImg 才是图片列表
const submitData = {
planNo: this.paramsOptins.planNo,
imgHost: '1',
beginImg: this.getImgUrlList(this.imagesList),
commonUserList: [],
remark: this.inspectForm.remark.trim(),
}
|
e0806267
王彪总
业务线 小程序不用写死,从后端接口获取
|
949
950
951
952
953
954
955
956
957
|
// 子上报随结束一起提交:后端在同一事务里写 garden_work_record 并校验「至少一条子上报」。
// clientSeq 幂等,重复点击不会重复计次。
const workRecords = dynamicValues.length > 0
? [{
clientSeq: this.clientSeq,
remark: this.inspectForm.remark.trim(),
fields: dynamicValues
}]
: []
|
073562dd
王彪总
业务线 小程序不用写死,从后端接口获取
|
958
|
|
e0806267
王彪总
业务线 小程序不用写死,从后端接口获取
|
959
|
// ① /create-and-finish 必传 commitId:没有进行中的本次养护就先建一条草稿(/create 会复用已有草稿)
|
c4409bc7
刘淇
养护计划
|
960
|
if (!this.commitId) {
|
e0806267
王彪总
业务线 小程序不用写死,从后端接口获取
|
961
|
const commitRes: any = await maintainCreate(submitData)
|
073562dd
王彪总
业务线 小程序不用写死,从后端接口获取
|
962
|
// 兼容后端返回裸 id 或 {id:...} 两种形态
|
c4409bc7
刘淇
养护计划
|
963
964
|
this.commitId = commitRes && typeof commitRes === 'object' ? commitRes.id : commitRes
}
|
e0806267
王彪总
业务线 小程序不用写死,从后端接口获取
|
965
966
967
968
|
if (!this.commitId) {
uni.hideLoading()
uni.showToast({ title: '创建本次养护失败,请重试', icon: 'none' })
return
|
c4409bc7
刘淇
养护计划
|
969
|
}
|
7da61cdb
刘淇
养护计划
|
970
|
|
e0806267
王彪总
业务线 小程序不用写死,从后端接口获取
|
971
972
973
974
975
976
977
|
// ② 子上报 + 结束本次养护(同一事务,不会出现字段已存但任务未结束的中间态)
await maintainCreateFinish({
...submitData,
commitId: this.commitId,
workRecords
})
|
7da61cdb
刘淇
养护计划
|
978
979
980
981
982
983
984
|
uni.hideLoading()
uni.showToast({ title: '提交并结束任务成功', icon: 'success', duration: 1000 })
setTimeout(() => {
uni.reLaunch({ url: '/pages-sub/daily/maintain-manage/index' })
}, 1000)
} catch (error) {
uni.hideLoading()
|
c4409bc7
刘淇
养护计划
|
985
986
|
if (Array.isArray(error)) return
console.error('提交并结束失败', error)
|
e0806267
王彪总
业务线 小程序不用写死,从后端接口获取
|
987
988
989
|
// 业务错误 request.js 已弹过后端 msg(如「当前养护计划状态不允许此操作」),这里不重复弹
if (error && error.msg) return
uni.showToast({ title: '提交失败,请重试', icon: 'none', duration: 2000 })
|
7da61cdb
刘淇
养护计划
|
990
|
} finally {
|
c4409bc7
刘淇
养护计划
|
991
|
this.submitting = false
|
7da61cdb
刘淇
养护计划
|
992
993
994
|
}
},
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
995
|
/**
|
e0806267
王彪总
业务线 小程序不用写死,从后端接口获取
|
996
997
|
* 暂存养护记录(按钮文案「暂存」)—— 双写两条链路:
* ① maintain-plan-commit/create:养护计划本身(描述 + 图片 + 人员),返回 commit.id;后端只建草稿,不计数
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
998
|
* ② work-record/submit:动态字段值,bizId 用 ① 的 commit.id(旧接口的 VO 没有动态字段,会被 Jackson 静默丢弃)
|
e0806267
王彪总
业务线 小程序不用写死,从后端接口获取
|
999
|
* 计数只在「提交并结束」或列表「结束任务」时推进,见 submitAndFinish
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1000
1001
|
* 重试安全:commitId 一旦取到就缓存住,重试只补写 ②(② 自身按 clientSeq 幂等),避免重复创建养护记录
*/
|
d433e7f6
刘淇
工单
|
1002
|
async submitInspect() {
|
13203a04
刘淇
首页 统计
|
1003
|
// 调试打印,打开小程序控制台查看
|
7da61cdb
刘淇
养护计划
|
1004
1005
1006
1007
1008
1009
|
console.log('=====调试=====')
console.log('dynamicFields', this.dynamicFields)
if (this.submitting) return
this.dynamicFields.forEach(item => {
console.log(item.fieldCode, this.inspectForm[item.fieldCode], typeof this.inspectForm[item.fieldCode])
})
|
d433e7f6
刘淇
工单
|
1010
1011
|
try {
await this.$refs.inspectFormRef.validate()
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1012
|
const dynamicValues = this.buildDynamicFields()
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
1013
|
if (!this.clientSeq) {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1014
|
this.clientSeq = this.genClientSeq()
|
d433e7f6
刘淇
工单
|
1015
|
}
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1016
|
uni.showLoading({ title: '提交中...' })
|
7da61cdb
刘淇
养护计划
|
1017
|
this.submitting = true
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1018
|
// ① 养护计划本体:仅首次提交时写入
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
1019
1020
|
if (!this.commitId) {
const submitData = {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1021
|
planNo: this.paramsOptins.planNo,
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
1022
|
imgHost: "1",
|
3c3d6799
刘淇
重点巡检区域
|
1023
|
beginImg: this.getImgUrlList(this.imagesList),
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
1024
|
commonUserList: [],
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
|
remark: this.inspectForm.remark.trim(),
}
const commitRes: any = await maintainCreate(submitData)
// 兼容后端返回裸 id 或 {id:...} 两种形态
this.commitId = commitRes && typeof commitRes === 'object' ? commitRes.id : commitRes
}
// ② 动态字段值:无动态字段时不产生空的字段值记录
if (dynamicValues.length > 0) {
if (!this.commitId) {
console.warn('未取到养护计划的 commit.id,跳过动态字段提交')
} else {
await workRecordSubmit({
businessType: this.paramsOptins.businessType,
bizType: 3,
bizId: this.commitId,
workTypeId: Number(this.paramsOptins.planTypeId),
clientSeq: this.clientSeq,
remark: this.inspectForm.remark.trim(),
fields: dynamicValues
})
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
1045
|
}
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
1046
|
}
|
d433e7f6
刘淇
工单
|
1047
|
uni.hideLoading()
|
e0806267
王彪总
业务线 小程序不用写死,从后端接口获取
|
1048
1049
|
// 后端 /create 只建草稿、不推进完成次数,必须再点「提交并结束」或在列表点「结束任务」才计数
uni.showToast({ title: '已暂存,请记得结束本次养护', icon: 'none', duration: 1500 })
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1050
1051
|
setTimeout(() => {
uni.reLaunch({ url: '/pages-sub/daily/maintain-manage/index' })
|
e0806267
王彪总
业务线 小程序不用写死,从后端接口获取
|
1052
|
}, 1500)
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1053
|
} catch (error) {
|
d433e7f6
刘淇
工单
|
1054
|
uni.hideLoading()
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1055
1056
1057
1058
1059
1060
1061
|
// 表单校验失败时 error 是字段数组(uview-plus 已提示),不重复弹
if (Array.isArray(error)) {
return
}
console.error('养护记录提交失败:', error)
// request.js 已把后端 msg 弹过一次(如「库存不足」),此处不要用通用文案盖掉真实原因
const backendMsg = error && error.msg
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
1062
|
if (this.commitId) {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1063
1064
1065
1066
1067
1068
1069
1070
|
// 养护计划已落库,失败只发生在耗材字段。必须说清「已提交」,否则用户会以为整单没提交而重复填
uni.showToast({
title: backendMsg ? `养护记录已提交:${backendMsg}` : '养护记录已提交,耗材数据保存失败,请重试',
icon: 'none',
duration: 2500
})
} else if (!backendMsg) {
uni.showToast({ title: '提交失败,请重试', icon: 'none', duration: 2000 })
|
d433e7f6
刘淇
工单
|
1071
1072
|
}
}
|
fb13622a
刘淇
养护计划列表 样式 差去一个卡片的头部
|
1073
1074
1075
1076
1077
|
}
}
}
</script>
|
fb13622a
刘淇
养护计划列表 样式 差去一个卡片的头部
|
1078
|
<style lang="scss" scoped>
|
de549a92
刘淇
养护。动态表单
|
1079
|
.page-container {
|
de549a92
刘淇
养护。动态表单
|
1080
1081
|
padding-bottom: 120rpx;
}
|
7da61cdb
刘淇
养护计划
|
1082
|
|
d433e7f6
刘淇
工单
|
1083
|
.inspect-form-content {
|
fb13622a
刘淇
养护计划列表 样式 差去一个卡片的头部
|
1084
|
background: #fff;
|
d433e7f6
刘淇
工单
|
1085
1086
|
padding: 20rpx;
margin-bottom: 20rpx;
|
fb13622a
刘淇
养护计划列表 样式 差去一个卡片的头部
|
1087
|
}
|
7da61cdb
刘淇
养护计划
|
1088
|
|
de549a92
刘淇
养护。动态表单
|
1089
1090
1091
|
.date-input-wrap {
width: 100%;
}
|
3c3d6799
刘淇
重点巡检区域
|
1092
|
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1093
|
// 放大u-number-box输入框
|
de549a92
刘淇
养护。动态表单
|
1094
1095
1096
1097
1098
1099
|
.large-number-box {
:deep(.u-number-box__input) {
width: 264rpx !important;
height: 72rpx;
font-size: 32rpx;
}
|
7da61cdb
刘淇
养护计划
|
1100
|
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1101
1102
|
:deep(.u-number-box__btn) {
width: 64rpx;
|
de549a92
刘淇
养护。动态表单
|
1103
1104
1105
|
height: 72rpx;
}
}
|
7da61cdb
刘淇
养护计划
|
1106
|
|
de549a92
刘淇
养护。动态表单
|
1107
1108
1109
1110
|
.number-box-wrap {
display: flex;
align-items: center;
gap: 16rpx;
|
7da61cdb
刘淇
养护计划
|
1111
|
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1112
1113
1114
1115
|
.unit-text {
font-size: 28rpx;
color: #333;
}
|
fb13622a
刘淇
养护计划列表 样式 差去一个卡片的头部
|
1116
|
}
|
7da61cdb
刘淇
养护计划
|
1117
|
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1118
|
// 6多选:复选框组 + needQuantity 时每个已选项一行数量输入
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
1119
1120
|
.multi-wrap {
width: 100%;
|
7da61cdb
刘淇
养护计划
|
1121
|
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
1122
1123
1124
1125
1126
1127
|
.multi-hint {
display: block;
margin-top: 8rpx;
font-size: 24rpx;
color: #909399;
}
|
7da61cdb
刘淇
养护计划
|
1128
|
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
1129
1130
1131
1132
1133
1134
|
.qty-list {
margin-top: 16rpx;
padding-left: 20rpx;
border-left: 4rpx solid #f0f0f0;
}
}
|
7da61cdb
刘淇
养护计划
|
1135
|
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1136
|
// 数量行(6多选的每个已选项 / 3物料的领用数量共用)
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
1137
1138
1139
1140
1141
1142
|
.qty-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
padding: 8rpx 0;
|
7da61cdb
刘淇
养护计划
|
1143
|
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
1144
1145
1146
1147
1148
1149
1150
|
.qty-label {
flex: 1;
min-width: 0;
font-size: 28rpx;
color: #333;
}
}
|
7da61cdb
刘淇
养护计划
|
1151
|
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
1152
1153
1154
1155
1156
|
.qty-row-material {
margin-top: 12rpx;
padding-top: 12rpx;
border-top: 1rpx solid #f0f0f0;
}
|
7da61cdb
刘淇
养护计划
|
1157
|
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1158
|
// 8附件:自绘文件列表 + 选择按钮(微信无通用文件选择器,走 chooseMessageFile)
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
1159
1160
|
.file-wrap {
width: 100%;
|
7da61cdb
刘淇
养护计划
|
1161
|
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
1162
1163
1164
1165
|
.file-row {
display: flex;
align-items: center;
justify-content: space-between;
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1166
1167
|
gap: 16rpx;
padding: 8rpx 0;
|
7da61cdb
刘淇
养护计划
|
1168
|
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
1169
|
.file-name {
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1170
1171
|
flex: 1;
min-width: 0;
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
1172
1173
|
font-size: 28rpx;
color: #333;
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1174
1175
1176
|
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
|
ee792d52
刘淇
动态表单
|
1177
|
}
|
7da61cdb
刘淇
养护计划
|
1178
|
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1179
|
.file-del {
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
1180
|
font-size: 26rpx;
|
629df8b3
王彪总
业务线 小程序不用写死,从后端接口获取
|
1181
|
color: #ff4d4f;
|
71518877
王彪总
业务线 小程序不用写死,从后端接口获取
|
1182
1183
1184
|
}
}
}
|
13203a04
刘淇
首页 统计
|
1185
1186
1187
1188
1189
1190
1191
1192
|
.empty-field-tip {
padding: 80rpx 30rpx;
text-align: center;
font-size: 30rpx;
color: #999;
}
|
7da61cdb
刘淇
养护计划
|
1193
1194
1195
1196
1197
1198
|
.fixed-bottom-btn-wrap {
background-color: #ffffff;
display: flex;
.btn-item {
flex: 1;
height: 88rpx;
|
c4409bc7
刘淇
养护计划
|
1199
|
|
7da61cdb
刘淇
养护计划
|
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
|
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
color: #fff;
}
.btn-left {
background: #1989fa;
}
.btn-right {
background: #8b572a;
/* 褐色 */
}
}
// 页面底部预留空白,防止表单内容被固定按钮遮挡
.page-container {
padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
}
|
13203a04
刘淇
首页 统计
|
1221
|
|
7da61cdb
刘淇
养护计划
|
1222
1223
1224
1225
1226
1227
|
.empty-field-tip {
text-align: center;
padding: 80rpx 20rpx;
font-size: 30rpx;
color: #999;
}
|
d433e7f6
刘淇
工单
|
1228
|
</style>
|