Răsfoiți Sursa

pms 瑞都日报 填报 动态属性 保存与回显

zhangcl 6 zile în urmă
părinte
comite
517b0e0e54
1 a modificat fișierele cu 67 adăugiri și 12 ștergeri
  1. 67 12
      src/views/pms/iotrddailyreport/FillDailyReportForm.vue

+ 67 - 12
src/views/pms/iotrddailyreport/FillDailyReportForm.vue

@@ -13,7 +13,13 @@
           <div class="table-cell">
             <div class="cell-content">
               <span class="cell-label">甲方:</span>
-              <span class="cell-value">{{ dailyReportData.manufactureName || '-' }}</span>
+              <!-- 甲方字段:添加 single-line-ellipsis 类 + title 绑定完整内容 -->
+              <span
+                class="cell-value single-line-ellipsis"
+                :title="dailyReportData.manufactureName || '-'"
+              >
+              {{ dailyReportData.manufactureName || '-' }}
+            </span>
             </div>
           </div>
           <div class="table-cell">
@@ -98,7 +104,7 @@
           <div class="table-cell full-width">
             <div class="cell-content">
               <span class="cell-label">设备配置:</span>
-              <span class="cell-value">{{ dailyReportData.deviceNames || '-' }}</span>
+              <span class="cell-value indent-multiline">{{ dailyReportData.deviceNames || '-' }}</span>
             </div>
           </div>
         </div>
@@ -406,18 +412,35 @@ const submitForm = async () => {
     formData.value.endTime = endDate.format('HH:mm:ss')
   }
 
+  // 构建动态属性 extProperty 数组
+  const extProperties = dynamicAttrs.value.map(attr => {
+    return {
+      name: attr.name,
+      sort: attr.sort,
+      unit: attr.unit,
+      actualValue: formData.value.dynamicFields[attr.identifier] || '', // 从 dynamicFields 中获取用户填写的值
+      dataType: attr.dataType,
+      maxValue: attr.maxValue,
+      minValue: attr.minValue,
+      required: attr.required,
+      accessMode: attr.accessMode,
+      identifier: attr.identifier,
+      defaultValue: attr.defaultValue
+    }
+  })
+
   // 准备提交数据,包含动态字段
   const submitData = {
     ...formData.value,
-    // 将动态字段合并到提交数据中或单独处理,根据后端接口需求调整
-    dynamicFields: formData.value.dynamicFields
+    // 将动态字段组装成 extProperty 数组
+    extProperty: extProperties
   }
 
   // 提交请求
   formLoading.value = true
   try {
     // 调用更新接口
-    await IotRdDailyReportApi.updateIotRdDailyReport(formData.value)
+    await IotRdDailyReportApi.updateIotRdDailyReport(submitData)
     message.success(t('common.updateSuccess'))
     close()
     // 发送操作成功的事件
@@ -441,14 +464,26 @@ const initDynamicAttrs = (reportData: any) => {
 
     // 初始化动态字段的值
     const initialDynamicFields: Record<string, any> = {}
-    reportData.dailyReportAttrs.forEach((attr: any) => {
-      // 优先使用实际值,如果没有则使用默认值
-      const value = (attr.extProperty && attr.extProperty.actualValue !== undefined &&
-        attr.extProperty.actualValue !== null && attr.extProperty.actualValue !== '')
-        ? attr.extProperty.actualValue
-        : (attr.defaultValue || (attr.extProperty?.defaultValue || ''))
 
-      initialDynamicFields[attr.identifier] = value
+    // 优先从 extProperty 中获取实际值(编辑时)
+    if (reportData.extProperty && reportData.extProperty.length > 0) {
+      reportData.extProperty.forEach((extProp: any) => {
+        if (extProp.identifier) {
+          initialDynamicFields[extProp.identifier] = extProp.actualValue || ''
+        }
+      })
+    }
+
+    reportData.dailyReportAttrs.forEach((attr: any) => {
+      if (!initialDynamicFields.hasOwnProperty(attr.identifier)) {
+        // 优先使用实际值,如果没有则使用默认值
+        const value = (attr.extProperty && attr.extProperty.actualValue !== undefined &&
+          attr.extProperty.actualValue !== null && attr.extProperty.actualValue !== '')
+          ? attr.extProperty.actualValue
+          : (attr.defaultValue || (attr.extProperty?.defaultValue || ''))
+
+        initialDynamicFields[attr.identifier] = value
+      }
     })
 
     formData.value.dynamicFields = initialDynamicFields
@@ -756,5 +791,25 @@ onMounted(async () => {
   overflow: hidden;
 }
 
+/* 甲方字段:单行显示+超出省略 */
+.single-line-ellipsis {
+  /* 强制文本单行显示 */
+  white-space: nowrap;
+  /* 超出容器部分隐藏 */
+  overflow: hidden;
+  /* 超出部分显示省略号 */
+  text-overflow: ellipsis;
+  /* 避免文本被截断(可选,根据需求调整) */
+  word-break: normal;
+}
 
+/* 设备配置字段:换行缩进(与首行对齐) */
+.indent-multiline {
+  /* 首行及换行后缩进 2em(与 label 宽度匹配,可根据需求调整) */
+  text-indent: 0em;
+  /* 允许长文本换行(覆盖原有 cell-value 的 break-all,确保中文换行正常) */
+  word-break: break-word;
+  /* 保证换行后文本正常显示(可选,清除可能的 nowrap 影响) */
+  white-space: normal;
+}
 </style>