Commit 5690aa84 by cen

refactor: 更新订单类型字段名为'djOrderType'

- 修改 OrderPopup、contant.js、CreateOrder.vue 和 OrderStrategy.vue 中的订单类型字段名,确保一致性
- 调整相关逻辑以适应新的字段名
1 parent befee03d
...@@ -384,7 +384,7 @@ const componentConfig = { ...@@ -384,7 +384,7 @@ const componentConfig = {
title: '订单类型', title: '订单类型',
hideSearch: true, hideSearch: true,
// 绑定 CreateOrder 中的字段名 // 绑定 CreateOrder 中的字段名
idKey: 'orderType', idKey: 'djOrderType',
cacheData: [], cacheData: [],
loadComplete: false loadComplete: false
} }
......
...@@ -356,10 +356,9 @@ export default { ...@@ -356,10 +356,9 @@ export default {
customerCouponCode: customerCouponCode customerCouponCode: customerCouponCode
}) })
this.$set(this.orderObj, 'couponInfo', couponName + customerCouponCode) this.$set(this.orderObj, 'couponInfo', couponName + customerCouponCode)
} else if (_typeValue.key == 'orderType') { } else if (_typeValue.key == 'djOrderType') {
// 订单类型 // 订单类型
// 保存显示文案和编码,方便后续接口使用 this.$set(this.orderObj, 'djOrderType', chooseContent.name)
this.$set(this.orderObj, 'orderType', chooseContent.name)
this.$set(this.orderObj, 'orderTypeCode', chooseContent.value) this.$set(this.orderObj, 'orderTypeCode', chooseContent.value)
} else if (productFields.includes(_typeValue.key)) { } else if (productFields.includes(_typeValue.key)) {
if (_typeValue.key == 'skuGoods') { if (_typeValue.key == 'skuGoods') {
......
...@@ -11,13 +11,13 @@ ...@@ -11,13 +11,13 @@
<view v-if="localState.mode === 'ratio' || localState.mode === 'amount'" class="input-box"> <view v-if="localState.mode === 'ratio' || localState.mode === 'amount'" class="input-box">
<!-- 折扣比例 --> <!-- 折扣比例 -->
<view v-if="localState.mode === 'ratio'" class="ratio-input"> <view v-if="localState.mode === 'ratio'" class="ratio-input">
<input class="ratio-input-inner" type="digit" :placeholder="ratioPlaceholder" placeholder-class="placeholder" :value="localState.discountRatio" @input="onInput('discountRatio', $event.detail.value)" /> <input class="ratio-input-inner" type="digit" :placeholder="ratioPlaceholder" placeholder-class="placeholder" v-model="localState.discountRatio" @blur="onBlur('discountRatio')" />
<text class="unit">折</text> <text class="unit">折</text>
</view> </view>
<!-- 折扣金额 --> <!-- 折扣金额 -->
<view v-else class="amount-input"> <view v-else class="amount-input">
<view class="unit">¥</view> <view class="unit">¥</view>
<input class="input amount-input-inner" type="digit" placeholder="请输入" placeholder-class="placeholder" :value="localState.discountAmount" @input="onInput('discountAmount', $event.detail.value)" /> <input class="input amount-input-inner" type="digit" placeholder="请输入" placeholder-class="placeholder" v-model="localState.discountAmount" @blur="onBlur('discountAmount')" />
</view> </view>
</view> </view>
</view> </view>
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
<view v-if="localState.mode === 'deduct'" class="input-box"> <view v-if="localState.mode === 'deduct'" class="input-box">
<view class="amount-input"> <view class="amount-input">
<view class="unit">¥</view> <view class="unit">¥</view>
<input class="input amount-input-inner" type="digit" placeholder="请输入" placeholder-class="placeholder" :value="localState.deductAmount" @input="onInput('deductAmount', $event.detail.value)" /> <input class="input amount-input-inner" type="digit" placeholder="请输入" placeholder-class="placeholder" v-model="localState.deductAmount" @blur="onBlur('deductAmount')" />
</view> </view>
</view> </view>
</view> </view>
...@@ -110,7 +110,8 @@ export default { ...@@ -110,7 +110,8 @@ export default {
giftOptions: [ giftOptions: [
{ label: '是', value: '1' }, { label: '是', value: '1' },
{ label: '否', value: '0' } { label: '否', value: '0' }
] ],
ratioPlaceholder: '请输入'
} }
}, },
computed: { computed: {
...@@ -246,54 +247,75 @@ export default { ...@@ -246,54 +247,75 @@ export default {
return Math.round(bp * 100) / 100 return Math.round(bp * 100) / 100
}, },
onInput(key, val) { // 失去焦点时格式化(跟价格输入框一样的逻辑)
let v = (val || '').replace(/[^\d.]/g, '') onBlur(key) {
const parts = v.split('.') let v = this.localState[key]
if (parts.length > 2) {
v = parts[0] + '.' + parts.slice(1).join('') if (key === 'discountAmount' || key === 'deductAmount') {
} // 折扣金额/抵扣金额:跟价格输入框一样的验证逻辑(直接截断,不四舍五入)
if (v.indexOf('.') > -1) { if (!v || (typeof v === 'string' && v.trim() === '')) {
const [intPart, decPart] = v.split('.') v = '0'
v = intPart + '.' + (decPart || '').slice(0, 2) }
} // 限制只能输入数字和小数点
v = String(v).replace(/[^\d.]/g, '')
// 限制只能有一个小数点
if (v.split('.').length > 2) {
v = v.slice(0, v.lastIndexOf('.')) + v.slice(v.lastIndexOf('.') + 1)
}
// 限制最多两位小数(直接截断,不四舍五入)
if (v.includes('.')) {
const parts = v.split('.')
if (parts[1] && parts[1].length > 2) {
parts[1] = parts[1].substring(0, 2)
v = parts.join('.')
}
}
const basePrice = parseFloat(this.basePrice || 0) const basePrice = parseFloat(this.basePrice || 0)
let amount = parseFloat(v)
// 限制输入值范围,直接修正而不是提示 // 限制最小值为0
if (key === 'discountRatio') { if (isNaN(amount) || amount < 0) {
// 折扣比例:限制在 1-10 之间 v = '0'
if (v) {
const ratio = parseFloat(v)
if (ratio < 1) {
v = '1'
} else if (ratio > 10) {
v = '10'
} else {
// 保留两位小数,但如果输入的是整数就不显示小数点
const rounded = Math.round(ratio * 100) / 100
v = rounded === Math.floor(rounded) ? rounded.toString() : rounded.toFixed(2)
}
} }
} else if (key === 'discountAmount' || key === 'deductAmount') { // 限制最大值为基础价格
// 折扣金额/抵扣金额:限制在 0 到基础价格之间 else if (basePrice > 0 && amount > basePrice) {
if (v) { // 如果超过基础价格,限制为基础价格
const amount = parseFloat(v) v = basePrice.toFixed(2)
if (isNaN(amount)) { }
v = ''
} else if (amount < 0) { this.$set(this.localState, key, v)
v = '0' } else if (key === 'discountRatio') {
} else if (basePrice > 0 && amount > basePrice) { // 折扣比例:限制在 1-10 之间(直接截断,不四舍五入)
// 直接限制为最大值,保留两位小数 if (!v || (typeof v === 'string' && v.trim() === '')) {
v = basePrice.toFixed(2) v = ''
} else { } else {
// 确保保留两位小数 // 限制只能输入数字和小数点
const rounded = Math.round(amount * 100) / 100 v = String(v).replace(/[^\d.]/g, '')
v = rounded === Math.floor(rounded) ? rounded.toString() : rounded.toFixed(2) // 限制只能有一个小数点
if (v.split('.').length > 2) {
v = v.slice(0, v.lastIndexOf('.')) + v.slice(v.lastIndexOf('.') + 1)
}
// 限制最多两位小数(直接截断,不四舍五入)
if (v.includes('.')) {
const parts = v.split('.')
if (parts[1] && parts[1].length > 2) {
parts[1] = parts[1].substring(0, 2)
v = parts.join('.')
}
}
const ratio = parseFloat(v)
if (!isNaN(ratio)) {
if (ratio < 1) {
v = '1'
} else if (ratio > 10) {
v = '10'
}
} }
} }
this.$set(this.localState, key, v)
} }
this.localState[key] = v
}, },
// 买赠单选框 change,保持与收款方式一致的事件风格 // 买赠单选框 change,保持与收款方式一致的事件风格
onGiftRadioChange(e) { onGiftRadioChange(e) {
...@@ -492,15 +514,16 @@ export default { ...@@ -492,15 +514,16 @@ export default {
.strategy-right { .strategy-right {
display: flex; display: flex;
align-items: center; align-items: center;
font-size: toRpx(26); font-size: toRpx(28);
color: #333; color: #333;
.price-label { .price-label {
margin-right: toRpx(8); margin-right: toRpx(8);
color: #222222;
} }
.price-value { .price-value {
color: #f45001; color: #ea6612;
} }
} }
</style> </style>
...@@ -128,7 +128,7 @@ const FORM_LIST = [ ...@@ -128,7 +128,7 @@ const FORM_LIST = [
}, },
{ {
label: '订单类型', label: '订单类型',
value: 'orderType', value: 'djOrderType',
type: 'select', type: 'select',
key: 'name', key: 'name',
required: true required: true
...@@ -621,7 +621,7 @@ const popupTypeEnum = { ...@@ -621,7 +621,7 @@ const popupTypeEnum = {
}, },
28: { 28: {
// 订单类型弹窗(OrderTypePopup) // 订单类型弹窗(OrderTypePopup)
key: 'orderType', key: 'djOrderType',
list: '' list: ''
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!