|
|
@@ -110,19 +110,19 @@
|
|
|
<view class="panel panel-single">
|
|
|
<view class="row">
|
|
|
<text class="label required">售价 (元)</text>
|
|
|
- <input class="input" type="digit" :value="form.price" @input="onPriceInput('price', $event)" placeholder="请输入" placeholder-class="ph" />
|
|
|
+ <input class="input" type="digit" :value="form.price" @input="onPriceInput('price', $event)" @blur="onNonNegativeBlur('price', $event)" placeholder="请输入" placeholder-class="ph" />
|
|
|
</view>
|
|
|
<view class="row">
|
|
|
<text class="label required">原价 (元)</text>
|
|
|
- <input class="input" type="digit" :value="form.sellingPrice" @input="onPriceInput('sellingPrice', $event)" placeholder="请输入" placeholder-class="ph" />
|
|
|
+ <input class="input" type="digit" :value="form.sellingPrice" @input="onPriceInput('sellingPrice', $event)" @blur="onNonNegativeBlur('sellingPrice', $event)" placeholder="请输入" placeholder-class="ph" />
|
|
|
</view>
|
|
|
<view class="row">
|
|
|
<text class="label required">可售库存</text>
|
|
|
- <input class="input" type="number" :value="form.stock" @input="onPriceInput('stock', $event)" placeholder="请输入" placeholder-class="ph" />
|
|
|
+ <input class="input" type="number" :value="form.stock" @input="onPriceInput('stock', $event)" @blur="onNonNegativeBlur('stock', $event)" placeholder="请输入" placeholder-class="ph" />
|
|
|
</view>
|
|
|
<view class="row">
|
|
|
<text class="label">成本价 (元)</text>
|
|
|
- <input class="input" type="digit" :value="form.costPrice" @input="onPriceInput('costPrice', $event)" placeholder="请输入 (选填)" placeholder-class="ph" />
|
|
|
+ <input class="input" type="digit" :value="form.costPrice" @input="onPriceInput('costPrice', $event)" @blur="onNonNegativeBlur('costPrice', $event)" placeholder="请输入 (选填)" placeholder-class="ph" />
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="panel panel-multi">
|
|
|
@@ -403,8 +403,12 @@ export default {
|
|
|
if (this.specLocked && specMode !== 'single') return '当前仅支持单规格';
|
|
|
if (specMode === 'single') {
|
|
|
if (f.price === '') return '请填写售价';
|
|
|
+ if (Number(f.price) < 0) return '售价不能为负数';
|
|
|
if (f.sellingPrice === '') return '请填写原价';
|
|
|
+ if (Number(f.sellingPrice) < 0) return '原价不能为负数';
|
|
|
if (f.stock === '') return '请填写可售库存';
|
|
|
+ if (Number(f.stock) < 0) return '可售库存不能为负数';
|
|
|
+ if (f.costPrice !== '' && Number(f.costPrice) < 0) return '成本价不能为负数';
|
|
|
return '';
|
|
|
}
|
|
|
const hasSelected = (f.specs || []).some((s) => (s.values || []).some((v) => v.selected));
|
|
|
@@ -455,6 +459,11 @@ export default {
|
|
|
this.form[key] = val == null ? '' : String(val);
|
|
|
this.refreshNextEnabled();
|
|
|
},
|
|
|
+ onNonNegativeBlur(key, e) {
|
|
|
+ const val = e && e.detail ? e.detail.value : this.form[key];
|
|
|
+ this.form[key] = val == null ? '' : String(val).replace(/-/g, '');
|
|
|
+ this.refreshNextEnabled();
|
|
|
+ },
|
|
|
toggleSpecValue(v) {
|
|
|
v.selected = !v.selected;
|
|
|
this.refreshNextEnabled();
|