Просмотр исходного кода

详情页面-子表单数据过滤优化

wu 4 месяцев назад
Родитель
Сommit
a61f57801e
1 измененных файлов с 56 добавлено и 1 удалено
  1. 56 1
      src/components/Generator/components/InputTable/index.vue

+ 56 - 1
src/components/Generator/components/InputTable/index.vue

@@ -37,7 +37,7 @@
         </template>
         <template slot-scope="scope">
           <template v-if="detailType === 'detail'">
-            {{ tableFormData[scope.$index][cindex].value }}
+            {{ detailGetValue(tableFormData[scope.$index][cindex],head) }}
           </template>
           <template v-else>
             <!-- 单选框组 多选框组 都替换成下拉 并添加options -->
@@ -726,6 +726,61 @@ export default {
       });
       this.$refs.relationTable.visible = false
     },
+    // 子表详情展示数据过滤
+    detailGetValue(data,scheme){
+      // 日期选择器
+      if (data.tag === 'el-date-picker'){
+        let filterVal = data.value
+        if (filterVal && g.getLen(String(filterVal)) === 10) {
+          try {
+            filterVal = filterVal * 1000
+          } catch (e) {}
+        }
+        return filterVal
+          ? XEUtils.toDateString(filterVal,scheme.format) !== 'Invalid Date'
+            ? XEUtils.toDateString(filterVal,scheme.format)
+            : filterVal
+          : ''
+      }
+      // 时间选择器
+      if (data.tag === 'el-time-picker') {
+        let filterVal = data.value
+        try {
+          return  filterVal
+            ? moment(Number(filterVal)).format(scheme.format) !== 'Invalid Date'
+              ? moment(Number(filterVal)).format(scheme.format)
+              : filterVal
+            : ''
+        } catch (e) {}
+      }
+      // 开关
+      if (data.tag === 'el-switch') {
+        if (data.value == scheme['active-value']) {
+          return scheme['active-text'] || '是'
+        } else {
+          return  scheme['inactive-text'] || '否'
+        }
+      }
+      // 下拉 多选 单选
+      if (['select', 'checkbox', 'radio'].includes(scheme.__config__.jnpfKey)){
+        if (data.ApiReturn && data.ApiReturn.length){
+          let activeObj = data.options.find(i=> i[data.apiProps.value] === data.value)
+          if (activeObj){
+            return activeObj[data.apiProps.label]
+          }else {
+            return data.value
+          }
+        }else {
+          let activeObj = data.options.find(i=> i[scheme.__config__.props.value] === data.value)
+          if (activeObj){
+            return activeObj[scheme.__config__.props.label]
+          }else {
+            return data.value
+          }
+        }
+      }
+      return data.value
+    },
   }
 }
 </script>