|
|
@@ -654,13 +654,21 @@ const initPlatformData = (reportData: any) => {
|
|
|
// 查找是否已有该平台井的数据
|
|
|
const existingData = reportData.platformWellPairs?.find((p: any) => p.taskId === platform.id)
|
|
|
|
|
|
+ // 确保 techniqueIds 是字符串数组格式
|
|
|
+ let techniqueIds = []
|
|
|
+ if (existingData && existingData.techniqueIds) {
|
|
|
+ techniqueIds = existingData.techniqueIds.map((id: any) => id.toString())
|
|
|
+ } else if (platform.techniqueIds) {
|
|
|
+ techniqueIds = platform.techniqueIds.map((id: any) => id.toString())
|
|
|
+ }
|
|
|
+
|
|
|
return existingData || {
|
|
|
taskId: platform.id,
|
|
|
reportId: platform.reportId, // 使用接口返回的 reportId
|
|
|
wellName: platform.wellName,
|
|
|
- rdStatus: '', // 初始为空
|
|
|
- techniqueIds: [], // 初始为空数组
|
|
|
- extProperty: [] // 初始为空数组
|
|
|
+ rdStatus: platform.rdStatus || '', // 初始为空
|
|
|
+ techniqueIds: techniqueIds, // 初始为空数组
|
|
|
+ extProperty: platform.extProperty || [] // 初始为空数组
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
@@ -1129,7 +1137,7 @@ const submitForm = async () => {
|
|
|
console.log('平台井模式提交数据:', JSON.stringify(submitDatas, null, 2))
|
|
|
} else {
|
|
|
// 非平台井模式:只提交当前数据
|
|
|
- submitDatas = [baseSubmitData]
|
|
|
+ submitDatas.push(baseSubmitData)
|
|
|
}
|
|
|
|
|
|
// 提交请求
|
|
|
@@ -1292,6 +1300,19 @@ const loadDynamicAttrs = async (newTechniqueIds: string[], oldTechniqueIds?: str
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 在 watch 监听平台井选择变化的部分附近,添加施工工艺转换函数
|
|
|
+// 添加施工工艺数值到标签的转换函数
|
|
|
+const convertTechniqueIdsToLabels = (techniqueIds: number[]): string[] => {
|
|
|
+ if (!techniqueIds || !Array.isArray(techniqueIds)) {
|
|
|
+ return []
|
|
|
+ }
|
|
|
+
|
|
|
+ return techniqueIds.map(id => {
|
|
|
+ const dict = techniqueOptions.value.find(option => option.value === id.toString())
|
|
|
+ return dict ? dict.label : id.toString()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
// 监听施工工艺变化
|
|
|
watch(() => formData.value.techniqueIds, async (newTechniqueIds, oldTechniqueIds) => {
|
|
|
if (newTechniqueIds && newTechniqueIds.length > 0) {
|
|
|
@@ -1385,7 +1406,14 @@ const loadPlatformData = (platformId: number) => {
|
|
|
if (platformData) {
|
|
|
// 更新表单字段
|
|
|
formData.value.rdStatus = platformData.rdStatus || ''
|
|
|
- formData.value.techniqueIds = platformData.techniqueIds ? [...platformData.techniqueIds] : []
|
|
|
+ // formData.value.techniqueIds = platformData.techniqueIds ? [...platformData.techniqueIds] : []
|
|
|
+ // 将施工工艺数值转换为对应的标签
|
|
|
+ if (platformData.techniqueIds && Array.isArray(platformData.techniqueIds)) {
|
|
|
+ // 如果是数字数组,转换为字符串数组(与数据字典格式匹配)
|
|
|
+ formData.value.techniqueIds = platformData.techniqueIds.map(id => id.toString())
|
|
|
+ } else {
|
|
|
+ formData.value.techniqueIds = platformData.techniqueIds ? [...platformData.techniqueIds] : []
|
|
|
+ }
|
|
|
|
|
|
// 更新动态属性
|
|
|
if (platformData.extProperty && platformData.extProperty.length > 0) {
|
|
|
@@ -1441,12 +1469,18 @@ const initFormData = (reportData: any) => {
|
|
|
remark: attachment.remark || ''
|
|
|
}))
|
|
|
|
|
|
+ // 确保 techniqueIds 是字符串数组格式
|
|
|
+ let techniqueIds = []
|
|
|
+ if (reportData.techniqueIds && Array.isArray(reportData.techniqueIds)) {
|
|
|
+ techniqueIds = reportData.techniqueIds.map((id: number) => id.toString())
|
|
|
+ }
|
|
|
+
|
|
|
formData.value = {
|
|
|
...formData.value,
|
|
|
id: reportData.id,
|
|
|
deptId: reportData.deptId,
|
|
|
rdStatus: reportData.rdStatus || '',
|
|
|
- techniqueIds: reportData.techniqueIds ? reportData.techniqueIds.map((id: number) => id.toString()) : [],
|
|
|
+ techniqueIds: techniqueIds,
|
|
|
productionStatus: reportData.productionStatus || '',
|
|
|
nextPlan: reportData.nextPlan || '',
|
|
|
externalRental: reportData.externalRental || '',
|
|
|
@@ -1467,19 +1501,20 @@ const initFormData = (reportData: any) => {
|
|
|
new Date(reportData.endTime[0])
|
|
|
]
|
|
|
}
|
|
|
+
|
|
|
+ // 初始化平台井数据
|
|
|
+ initPlatformData(reportData)
|
|
|
+
|
|
|
// 初始化动态属性
|
|
|
initDynamicAttrs(reportData)
|
|
|
|
|
|
// 初始化设备数据
|
|
|
initDeviceData(reportData)
|
|
|
|
|
|
- // 初始化平台井数据
|
|
|
- initPlatformData(reportData)
|
|
|
-
|
|
|
// 如果是平台井模式且有数据,初始化 platformWellPairs 中的第一个平台井数据
|
|
|
- if (reportData.platformWell === 1 && formData.value.platformId) {
|
|
|
+ /* if (reportData.platformWell === 1 && formData.value.platformId) {
|
|
|
loadPlatformData(formData.value.platformId)
|
|
|
- }
|
|
|
+ } */
|
|
|
|
|
|
}
|
|
|
|