Commit 1f6f9eab by 张立顺

feat 字段取值修改

1 parent c0afe93e
......@@ -2,15 +2,14 @@
## 背景
审核详情页的“订单信息”区域目前展示订单编号、订单类型、总价等字段,但没有展示订单是否属于低价单。接口详情数据已约定通过 `lowPriceFlag` 返回该信息。
审核详情页的“订单信息”区域目前展示订单编号、订单类型、总价等字段,但没有展示订单是否属于低价单。接口详情数据已约定通过 `goodsOrderDTO.lowPriceFlag` 返回该信息。
## 目标
在订单类型下方新增“订单归属”字段,并按接口枚举值展示:
- `lowPriceFlag = 0`:普通订单
- `lowPriceFlag = 1`:低价订单
- 字段缺失或返回未知值:显示 `-`
- `goodsOrderDTO.lowPriceFlag = 1`:低价订单
- 其他值(包括字段缺失或 `null`):显示 `-`
## 非目标
......@@ -23,22 +22,21 @@
沿用当前订单类型的声明式字段列表与映射表模式,为订单信息项增加通用格式映射能力:
1. 将现有订单类型配置标记为 `djOrderType` 格式。
2. 新增订单归属配置,字段键为 `lowPriceFlag`,格式标记为 `lowPriceFlag`,位置紧跟订单类型之后。
3. 在页面中通过格式标记选择对应的映射表,统一处理 `0`、`1`、缺失值和未知值。
2. 新增订单归属配置,数据源为 `goodsOrderDTO`,字段键和格式标记均为 `lowPriceFlag`,位置紧跟订单类型之后。
3. 在页面中通过格式标记选择对应的映射表,统一处理 `1` 和其他值。
4. 映射表只负责展示文案,不改变 `orderInfo` 中接口原始值。
## 数据流
接口返回详情数据后,页面现有逻辑将其保存到 `orderInfo`。渲染 `displayOrderForm` 时,订单归属项读取 `orderInfo.lowPriceFlag`,通过低价单映射表转换为“普通订单”或“低价订单”;没有可识别值时回退为 `-`。
接口返回详情数据后,页面现有逻辑将其保存到 `orderInfo`。渲染 `displayOrderForm` 时,订单归属项读取 `orderInfo.goodsOrderDTO.lowPriceFlag`;值为 `1` 时转换为“低价订单”,其他值回退为 `-`。
## 异常与兼容
接口不返回 `lowPriceFlag` 时页面仍正常渲染,并展示 `-`。使用显式存在性判断,避免把合法值 `0` 当成空值。
接口不返回 `goodsOrderDTO` 或其中的 `lowPriceFlag` 时页面仍正常渲染,并展示 `-`。
## 验收与测试
- 页面订单类型下方出现“订单归属”。
- `lowPriceFlag` 为 `0` 时显示“普通订单”。
- `lowPriceFlag` 为 `1` 时显示“低价订单”。
- 字段缺失、为 `null` 或为未知枚举值时显示 `-`。
- `goodsOrderDTO.lowPriceFlag` 为 `1` 时显示“低价订单”。
- 值为 `0`、字段缺失、为 `null` 或为其他值时显示 `-`。
- 现有项目构建或检查命令通过,且原有订单类型展示不回归。
......@@ -17,7 +17,7 @@
<div v-for="(item, index) in displayOrderForm" :key="index" class="info-item" :class="{ 'flex-start': item.flexStart }">
<span class="info-label">{{ item.label }}</span>
<template v-if="item.format">
<div class="info-value">{{ getFormattedFieldValue(orderInfo[item.key], item.format) }}</div>
<div class="info-value">{{ getFormattedFieldValue(getOrderFieldValue(item), item.format) }}</div>
</template>
<template v-else-if="item.arr">
<div class="info-value">
......@@ -134,7 +134,7 @@ export default {
orderForm: [
{ label: '订单编号', key: 'orderCode' },
{ label: '订单类型', key: 'djOrderType', format: 'djOrderType' },
{ label: '订单归属', key: 'lowPriceFlag', format: 'lowPriceFlag' },
{ label: '订单归属', sourceKey: 'goodsOrderDTO', key: 'lowPriceFlag', format: 'lowPriceFlag' },
{ label: '总价', key: 'finalPrice', unit: '¥' },
{ label: '提单人', key: ['sellerName', 'merchantName'], arr: true },
{ label: '提单时间', key: 'applyDate' },
......@@ -183,6 +183,10 @@ export default {
}
},
methods: {
getOrderFieldValue(item) {
const source = item.sourceKey ? this.orderInfo[item.sourceKey] : this.orderInfo
return source ? source[item.key] : undefined
},
getFormattedFieldValue(value, format) {
return formatFieldValue(value, format)
},
......@@ -206,7 +210,7 @@ export default {
})
},
getFieldValue(item) {
const val = this.orderInfo[item.key]
const val = this.getOrderFieldValue(item)
return val || val === 0 ? val : '-'
},
previewImage(urlList, index) {
......
......@@ -32,6 +32,7 @@ export default {
"thirdOrderCode": null,
"channelType": 1,
"djOrderType": 5,
"lowPriceFlag": 1,
"userId": "9d9a4784c97c4cb088c4a4bb3fb01220",
"merchantId": 44212556,
"merchantName": "0918测试1.1.2-门店",
......
......@@ -38,6 +38,7 @@
"thirdOrderCode" : null,
"channelType" : 1,
"djOrderType" : 5,
"lowPriceFlag" : 1,
"userId" : "9d9a4784c97c4cb088c4a4bb3fb01220",
"merchantId" : 44212556,
"merchantName" : "0918测试1.1.2-门店",
......@@ -950,4 +951,3 @@
......@@ -9,7 +9,6 @@ const orderFieldMaps = {
6: '内部结算'
},
lowPriceFlag: {
0: '普通订单',
1: '低价订单'
}
}
......
const assert = require('assert')
const { getFormattedFieldValue } = require('../src/views/orderApproval/orderApprovalFormat')
assert.strictEqual(getFormattedFieldValue(0, 'lowPriceFlag'), '普通订单')
assert.strictEqual(getFormattedFieldValue(0, 'lowPriceFlag'), '-')
assert.strictEqual(getFormattedFieldValue(1, 'lowPriceFlag'), '低价订单')
assert.strictEqual(getFormattedFieldValue(undefined, 'lowPriceFlag'), '-')
assert.strictEqual(getFormattedFieldValue(null, 'lowPriceFlag'), '-')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!