Commit 5690aa84 by cen

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

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