|
@@ -84,7 +84,7 @@
|
|
|
<view class="section-title">销售规格</view>
|
|
<view class="section-title">销售规格</view>
|
|
|
<view class="row">
|
|
<view class="row">
|
|
|
<text class="label required">销售规格</text>
|
|
<text class="label required">销售规格</text>
|
|
|
- <u-radio-group v-model="form.specMode">
|
|
|
|
|
|
|
+ <u-radio-group :value="form.specMode" @change="onSpecModeChange">
|
|
|
<u-radio name="single" active-color="#449AFF">单规格</u-radio>
|
|
<u-radio name="single" active-color="#449AFF">单规格</u-radio>
|
|
|
<u-radio name="multi" active-color="#449AFF" :disabled="specLocked">多规格</u-radio>
|
|
<u-radio name="multi" active-color="#449AFF" :disabled="specLocked">多规格</u-radio>
|
|
|
</u-radio-group>
|
|
</u-radio-group>
|
|
@@ -132,7 +132,13 @@
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
<view class="footer">
|
|
<view class="footer">
|
|
|
- <u-button type="primary" shape="circle" :disabled="!canNext" @click="onNext">下一步</u-button>
|
|
|
|
|
|
|
+ <u-button
|
|
|
|
|
+ :key="'next-' + form.specMode + '-' + (canNext ? 1 : 0)"
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ shape="circle"
|
|
|
|
|
+ :disabled="!canNext"
|
|
|
|
|
+ @click="onNext"
|
|
|
|
|
+ >下一步</u-button>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
<!-- 规格操作菜单 -->
|
|
<!-- 规格操作菜单 -->
|
|
@@ -160,10 +166,14 @@
|
|
|
编辑规格值
|
|
编辑规格值
|
|
|
<text class="dialog-close" @click="valueListShow = false">×</text>
|
|
<text class="dialog-close" @click="valueListShow = false">×</text>
|
|
|
</view>
|
|
</view>
|
|
|
- <view class="vp-item" v-for="(v, i) in editingValues" :key="v.id" @click="editOneValue(i)">
|
|
|
|
|
- <text>{{ v.name }}</text>
|
|
|
|
|
- <u-icon name="edit-pen" color="#999" size="32"></u-icon>
|
|
|
|
|
|
|
+ <view class="vp-item" v-for="(v, i) in editingValues" :key="v.id">
|
|
|
|
|
+ <text class="vp-name" @click="editOneValue(i)">{{ v.name }}</text>
|
|
|
|
|
+ <view class="vp-ops">
|
|
|
|
|
+ <u-icon name="edit-pen" color="#999" size="32" @click="editOneValue(i)"></u-icon>
|
|
|
|
|
+ <u-icon name="trash" color="#FF4D4F" size="32" @click="removeSpecValue(i)"></u-icon>
|
|
|
|
|
+ </view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
+ <view class="vp-add" @click="addSpecValue">+ 添加规格值</view>
|
|
|
<view class="vp-confirm" @click="confirmValues">确定</view>
|
|
<view class="vp-confirm" @click="confirmValues">确定</view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
@@ -279,7 +289,7 @@ export default {
|
|
|
categorySheet: [],
|
|
categorySheet: [],
|
|
|
typeSheet: PRODUCT_TYPES.map((i) => ({ text: i.label, value: i.value })),
|
|
typeSheet: PRODUCT_TYPES.map((i) => ({ text: i.label, value: i.value })),
|
|
|
specMenuShow: false,
|
|
specMenuShow: false,
|
|
|
- specMenuList: [{ text: '编辑规格名' }, { text: '编辑规格值' }],
|
|
|
|
|
|
|
+ specMenuList: [{ text: '编辑规格名' }, { text: '编辑规格值' }, { text: '删除规格', color: '#FF4D4F' }],
|
|
|
activeSpecIndex: 0,
|
|
activeSpecIndex: 0,
|
|
|
nameModal: false,
|
|
nameModal: false,
|
|
|
editingName: '',
|
|
editingName: '',
|
|
@@ -433,8 +443,14 @@ export default {
|
|
|
this.form.cover = item.productImage || '';
|
|
this.form.cover = item.productImage || '';
|
|
|
this.form.detail = item.detailImages || '';
|
|
this.form.detail = item.detailImages || '';
|
|
|
this.form.isCombo = Number(item.isPackage) === 1 ? 1 : 0;
|
|
this.form.isCombo = Number(item.isPackage) === 1 ? 1 : 0;
|
|
|
|
|
+ // 售价 price,原价 sellingPrice
|
|
|
this.form.price = item.price != null ? String(item.price) : '';
|
|
this.form.price = item.price != null ? String(item.price) : '';
|
|
|
- this.form.sellingPrice = item.sellingPrice != null ? String(item.sellingPrice) : '';
|
|
|
|
|
|
|
+ this.form.sellingPrice =
|
|
|
|
|
+ item.sellingPrice != null
|
|
|
|
|
+ ? String(item.sellingPrice)
|
|
|
|
|
+ : item.originalPrice != null
|
|
|
|
|
+ ? String(item.originalPrice)
|
|
|
|
|
+ : '';
|
|
|
this.form.stock = item.dailyStock != null ? String(item.dailyStock) : '';
|
|
this.form.stock = item.dailyStock != null ? String(item.dailyStock) : '';
|
|
|
this.form.costPrice = item.costPrice != null ? String(item.costPrice) : '';
|
|
this.form.costPrice = item.costPrice != null ? String(item.costPrice) : '';
|
|
|
this.form.specMode = Number(item.salesSpecType) === 2 ? 'multi' : 'single';
|
|
this.form.specMode = Number(item.salesSpecType) === 2 ? 'multi' : 'single';
|
|
@@ -500,9 +516,18 @@ export default {
|
|
|
this.form.isCombo = val === undefined ? this.form.isCombo : val;
|
|
this.form.isCombo = val === undefined ? this.form.isCombo : val;
|
|
|
this.applySpecLock();
|
|
this.applySpecLock();
|
|
|
},
|
|
},
|
|
|
|
|
+ onSpecModeChange(val) {
|
|
|
|
|
+ // 同步更新,避免 u-radio-group 双向绑定延迟导致下一步按钮置灰滞后
|
|
|
|
|
+ const mode = val || 'single';
|
|
|
|
|
+ if (this.specLocked && mode === 'multi') {
|
|
|
|
|
+ this.$set(this.form, 'specMode', 'single');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.$set(this.form, 'specMode', mode);
|
|
|
|
|
+ },
|
|
|
applySpecLock() {
|
|
applySpecLock() {
|
|
|
if (this.specLocked) {
|
|
if (this.specLocked) {
|
|
|
- this.form.specMode = 'single';
|
|
|
|
|
|
|
+ this.$set(this.form, 'specMode', 'single');
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
pickCategory() {
|
|
pickCategory() {
|
|
@@ -534,12 +559,28 @@ export default {
|
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
|
this.nameModal = true;
|
|
this.nameModal = true;
|
|
|
});
|
|
});
|
|
|
- } else {
|
|
|
|
|
|
|
+ } else if (index === 1) {
|
|
|
this.editingValues = JSON.parse(JSON.stringify(spec.values || []));
|
|
this.editingValues = JSON.parse(JSON.stringify(spec.values || []));
|
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
|
this.valueListShow = true;
|
|
this.valueListShow = true;
|
|
|
});
|
|
});
|
|
|
|
|
+ } else if (index === 2) {
|
|
|
|
|
+ this.deleteSpec();
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ deleteSpec() {
|
|
|
|
|
+ if ((this.form.specs || []).length <= 1) {
|
|
|
|
|
+ uni.showToast({ title: '至少保留一个规格', icon: 'none' });
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
+ uni.showModal({
|
|
|
|
|
+ content: '确定删除该规格?',
|
|
|
|
|
+ confirmColor: '#FF4D4F',
|
|
|
|
|
+ success: (res) => {
|
|
|
|
|
+ if (!res.confirm) return;
|
|
|
|
|
+ this.form.specs.splice(this.activeSpecIndex, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
saveSpecName() {
|
|
saveSpecName() {
|
|
|
if (!this.editingName.trim()) {
|
|
if (!this.editingName.trim()) {
|
|
@@ -554,6 +595,22 @@ export default {
|
|
|
this.editingValueName = (this.editingValues[i] && this.editingValues[i].name) || '';
|
|
this.editingValueName = (this.editingValues[i] && this.editingValues[i].name) || '';
|
|
|
this.valueEditModal = true;
|
|
this.valueEditModal = true;
|
|
|
},
|
|
},
|
|
|
|
|
+ addSpecValue() {
|
|
|
|
|
+ const id = `v${Date.now()}`;
|
|
|
|
|
+ this.editingValues.push({
|
|
|
|
|
+ id,
|
|
|
|
|
+ name: `选项${this.editingValues.length + 1}`,
|
|
|
|
|
+ selected: true
|
|
|
|
|
+ });
|
|
|
|
|
+ this.editOneValue(this.editingValues.length - 1);
|
|
|
|
|
+ },
|
|
|
|
|
+ removeSpecValue(i) {
|
|
|
|
|
+ if (this.editingValues.length <= 1) {
|
|
|
|
|
+ uni.showToast({ title: '至少保留一个规格值', icon: 'none' });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.editingValues.splice(i, 1);
|
|
|
|
|
+ },
|
|
|
saveOneValue() {
|
|
saveOneValue() {
|
|
|
if (!this.editingValueName.trim()) {
|
|
if (!this.editingValueName.trim()) {
|
|
|
uni.showToast({ title: '请输入规格值', icon: 'none' });
|
|
uni.showToast({ title: '请输入规格值', icon: 'none' });
|
|
@@ -563,6 +620,10 @@ export default {
|
|
|
this.valueEditModal = false;
|
|
this.valueEditModal = false;
|
|
|
},
|
|
},
|
|
|
confirmValues() {
|
|
confirmValues() {
|
|
|
|
|
+ if (!this.editingValues.length) {
|
|
|
|
|
+ uni.showToast({ title: '请至少添加一个规格值', icon: 'none' });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
this.form.specs[this.activeSpecIndex].values = this.editingValues;
|
|
this.form.specs[this.activeSpecIndex].values = this.editingValues;
|
|
|
this.valueListShow = false;
|
|
this.valueListShow = false;
|
|
|
},
|
|
},
|
|
@@ -811,9 +872,30 @@ export default {
|
|
|
border-bottom: 1rpx solid #f0f0f0;
|
|
border-bottom: 1rpx solid #f0f0f0;
|
|
|
font-size: 28rpx;
|
|
font-size: 28rpx;
|
|
|
color: #333;
|
|
color: #333;
|
|
|
|
|
+ .vp-name {
|
|
|
|
|
+ flex: 1;
|
|
|
|
|
+ min-width: 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ .vp-ops {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ gap: 28rpx;
|
|
|
|
|
+ margin-left: 20rpx;
|
|
|
|
|
+ flex-shrink: 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ .vp-add {
|
|
|
|
|
+ margin: 24rpx 40rpx 0;
|
|
|
|
|
+ height: 72rpx;
|
|
|
|
|
+ line-height: 72rpx;
|
|
|
|
|
+ text-align: center;
|
|
|
|
|
+ border: 1rpx dashed #449aff;
|
|
|
|
|
+ border-radius: 12rpx;
|
|
|
|
|
+ color: #449aff;
|
|
|
|
|
+ font-size: 28rpx;
|
|
|
}
|
|
}
|
|
|
.vp-confirm {
|
|
.vp-confirm {
|
|
|
- margin: 30rpx 40rpx 10rpx;
|
|
|
|
|
|
|
+ margin: 24rpx 40rpx 10rpx;
|
|
|
height: 80rpx;
|
|
height: 80rpx;
|
|
|
line-height: 80rpx;
|
|
line-height: 80rpx;
|
|
|
text-align: center;
|
|
text-align: center;
|