From e8f5dac4fea940d6714db9dea1dc475c2472b581 Mon Sep 17 00:00:00 2001
From: 刘淇 <290219706@qq.com>
Date: Sat, 10 Oct 2026 17:12:14 +0800
Subject: [PATCH] 三级联动
---
components/grouped-picker/grouped-picker.vue | 31 +++++++++++++++++++++++++++----
pages-sub/daily/maintain-manage/add-record.vue | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------
2 files changed, 93 insertions(+), 28 deletions(-)
diff --git a/components/grouped-picker/grouped-picker.vue b/components/grouped-picker/grouped-picker.vue
index 8f942a1..65dc144 100644
--- a/components/grouped-picker/grouped-picker.vue
+++ b/components/grouped-picker/grouped-picker.vue
@@ -23,9 +23,27 @@
-
+
+
+
+
+
+
+
+
+
@@ -111,7 +129,12 @@ const props = defineProps({
// 单选传字符串、多选传数组
value: { type: [String, Array], default: '' },
// { 选项值: 数量 }
- quantities: { type: Object, default: () => ({}) }
+ quantities: { type: Object, default: () => ({}) },
+ // 新增:父页面传入宽度(px),兜底默认 750
+ containerWidth: {
+ type: Number,
+ default: 750
+ }
})
const emit = defineEmits(['update:show', 'confirm'])
diff --git a/pages-sub/daily/maintain-manage/add-record.vue b/pages-sub/daily/maintain-manage/add-record.vue
index 5681e56..66685aa 100644
--- a/pages-sub/daily/maintain-manage/add-record.vue
+++ b/pages-sub/daily/maintain-manage/add-record.vue
@@ -1,6 +1,6 @@
-
+
@@ -66,10 +66,24 @@
- uploadFieldFiles(item, event)" @delete="(event) => deleteFieldFile(item, event)"
- multiple :max-count="pickCountOf(item, 5)" upload-text="选择图片" del-color="#ff4d4f"
- class="upload-wrap">
+
+
+ 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"
+>
+
+
@@ -106,15 +120,15 @@
-
+
-
+
@@ -132,6 +146,7 @@
@@ -206,7 +221,9 @@ export default {
value: '' as any,
quantities: {} as any,
// 数量单位不再传进弹层(原型列表行右侧只有步进器,没有单位),页面行内仍显示 item.unit
- unit: ''
+ unit: '',
+ // 新增:由父页面点击时赋值
+ containerWidth: 0
}
}
},
@@ -300,7 +317,15 @@ export default {
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] || {})
- this.groupPicker.show = true
+ // ========== 新增:点击打开弹窗瞬间,获取父表单容器宽度 ==========
+ 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()
},
/**
* 分层弹层确定回调。写入位置与原有两条路径完全一致(inspectForm/labelMap/qtyMap),
@@ -668,15 +693,30 @@ export default {
/**
* 7图片 上传(u-upload 的 after-read 回调)
*/
- uploadFieldFiles(item: any, event: any) {
- const rawFile = event && event.file
- const fileList = Array.isArray(rawFile) ? rawFile : [rawFile]
- return this.uploadToField(item, fileList.filter(file => file && file.url).map(file => ({
- url: file.url,
- name: file.name || '',
- size: file.size
- })))
- },
+ /**
+ * 7图片 上传(u-upload 的 after-read 回调)【对齐工单上传逻辑】
+ */
+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)
+
+ this.uploadToField(item, fileList.filter(file => file && file.url).map(file => ({
+ url: file.url,
+ name: file.name || '',
+ size: file.size
+ })))
+},
+
/**
* 8附件 选择并上传。
* 微信小程序没有通用文件选择器,只能从聊天记录里选(uni.chooseMessageFile)
@@ -818,10 +858,12 @@ export default {
fields.push(row)
} else if (type === 3) {
// 3枚举:单选取裸 value;历史「枚举+是否多选」存逗号分隔
- fields.push({
- fieldCode: code,
- valueText: item.multiple === 1 ? (value || []).join(',') : String(value)
- })
+ fields.push({
+ fieldCode: code,
+ valueText: item.multiple === 1
+ ? (Array.isArray(value) ? value.join(',') : String(value || ''))
+ : String(value)
+})
} else if (type === 6) {
const selected = (item.selectOptions || []).filter(opt => (value || []).indexOf(opt.value) > -1)
if (this.needQty(item)) {
--
libgit2 0.21.4