diff --git a/src/views/community/CommunityList.vue b/src/views/community/CommunityList.vue index bdd9304..292b259 100644 --- a/src/views/community/CommunityList.vue +++ b/src/views/community/CommunityList.vue @@ -47,6 +47,7 @@ @@ -152,6 +153,64 @@ + + + + + + +
每单基础配送费
+
+ + + +
超过该件数将收取超额配送费
+
+ + + +
超过临界数后,每件商品额外收取的费用
+
+
+
@@ -571,6 +630,63 @@ export default defineComponent({ } } + // 添加配送定价相关的状态 + const deliveryPriceModalVisible = ref(false) + const deliveryPriceSaving = ref(false) + const deliveryPriceForm = ref({ + base_price: 0, + extra_package_threshold: 1, + extra_package_price: 0 + }) + const currentCommunityId = ref(null) + + // 显示配送定价模态框 + const handleEditDeliveryPrice = (record) => { + currentCommunityId.value = record.id + deliveryPriceForm.value = { + base_price: record.base_price || 0, + extra_package_threshold: record.extra_package_threshold || 1, + extra_package_price: record.extra_package_price || 0 + } + deliveryPriceModalVisible.value = true + } + + // 保存配送定价 + const handleDeliveryPriceSave = async () => { + try { + deliveryPriceSaving.value = true + const res = await request.put(`/api/community/${currentCommunityId.value}`, { + base_price: deliveryPriceForm.value.base_price, + extra_package_threshold: deliveryPriceForm.value.extra_package_threshold, + extra_package_price: deliveryPriceForm.value.extra_package_price + }) + + if (res.code === 200) { + message.success('配送定价设置成功') + deliveryPriceModalVisible.value = false + fetchData() // 刷新列表 + } else { + message.error(res.message || '设置失败') + } + } catch (error) { + console.error('设置配送定价失败:', error) + message.error('设置失败') + } finally { + deliveryPriceSaving.value = false + } + } + + // 取消配送定价设置 + const handleDeliveryPriceCancel = () => { + deliveryPriceModalVisible.value = false + currentCommunityId.value = null + deliveryPriceForm.value = { + base_price: 0, + extra_package_threshold: 1, + extra_package_price: 0 + } + } + onMounted(() => { fetchData() }) @@ -605,7 +721,13 @@ export default defineComponent({ previewImage, previewTitle, handlePreviewCancel, - previewQRCode + previewQRCode, + deliveryPriceModalVisible, + deliveryPriceSaving, + deliveryPriceForm, + handleEditDeliveryPrice, + handleDeliveryPriceSave, + handleDeliveryPriceCancel } } }) @@ -697,7 +819,17 @@ export default defineComponent({ } :deep(.ant-form-item-label) { - text-align: right; + height: 32px; + line-height: 32px; + text-align: left; + padding-right: 12px; + + /* 调整必填星号的样式 */ + > label.ant-form-item-required:not(.ant-form-item-required-mark-optional)::before { + color: #ff4d4f; + font-size: 14px; + margin-right: 4px; + } } :deep(.ant-form-item) { @@ -738,7 +870,7 @@ export default defineComponent({ } :deep(.ant-modal-footer) { - text-align: right; + text-align: left; padding: 16px 24px; border-top: 1px solid #f0f0f0; } @@ -752,22 +884,9 @@ export default defineComponent({ margin-bottom: 24px !important; } -:deep(.ant-form-item-label) { - height: 32px; - line-height: 32px; - text-align: right; +:deep(.ant-form-item-control) { + text-align: left; padding-right: 12px; - - /* 调整必填星号的样式 */ - > label.ant-form-item-required:not(.ant-form-item-required-mark-optional)::before { - color: #ff4d4f; - font-size: 14px; - margin-right: 4px; - } -} - -:deep(.ant-form-item-control-input) { - min-height: 32px; } :deep(.ant-input),