update
This commit is contained in:
parent
9a7052af78
commit
f495ebc06a
@ -56,7 +56,7 @@
|
||||
<span class="rate-value">{{ record.profit_sharing.partner_rate }}%</span>
|
||||
</div>
|
||||
<div class="profit-rate-item">
|
||||
<span class="rate-label">管理员</span>
|
||||
<span class="rate-label">服务商</span>
|
||||
<span class="rate-value">{{ record.profit_sharing.admin_rate }}%</span>
|
||||
<span class="rate-label">配送员</span>
|
||||
<span class="rate-value">{{ record.profit_sharing.delivery_rate }}%</span>
|
||||
@ -278,7 +278,7 @@
|
||||
</div>
|
||||
|
||||
<div class="profit-rate-row">
|
||||
<div class="profit-rate-label">管理员分润比例 (%)</div>
|
||||
<div class="profit-rate-label">服务商分润比例 (%)</div>
|
||||
<div class="profit-rate-input">
|
||||
<a-input-number
|
||||
v-model:value="profitSharingForm.admin_rate"
|
||||
@ -290,7 +290,7 @@
|
||||
@change="calculatePlatformRate"
|
||||
/>
|
||||
</div>
|
||||
<div class="profit-rate-tip">小区管理员获得的分润</div>
|
||||
<div class="profit-rate-tip">小区服务商获得的分润</div>
|
||||
</div>
|
||||
|
||||
<div class="profit-rate-row">
|
||||
|
||||
@ -72,24 +72,11 @@
|
||||
</template>
|
||||
</a-space>
|
||||
</template>
|
||||
<template v-if="column.key === 'commission'">
|
||||
<template v-if="record.delivery_commission_fixed > 0">
|
||||
<a-tag color="blue">固定金额</a-tag>
|
||||
<span>¥{{ record.delivery_commission_fixed }}</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
<a-tag color="orange">按比例</a-tag>
|
||||
<span>{{ record.delivery_commission_rate || 0 }}%</span>
|
||||
</template>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a-button type="link" @click="handleEditCommunity(record)">
|
||||
{{ record.community_name ? '修改小区' : '设置小区' }}
|
||||
</a-button>
|
||||
<a-button type="link" @click="showCommissionModal(record)">
|
||||
设置分佣
|
||||
</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
@ -123,88 +110,20 @@
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
|
||||
<!-- 设置分佣比例模态框 -->
|
||||
<a-modal
|
||||
v-model:visible="commissionModalVisible"
|
||||
title="设置分佣"
|
||||
:confirm-loading="commissionSubmitting"
|
||||
@ok="handleCommissionSubmit"
|
||||
@cancel="handleCommissionCancel"
|
||||
>
|
||||
<a-form
|
||||
ref="commissionFormRef"
|
||||
:model="commissionForm"
|
||||
:rules="commissionRules"
|
||||
layout="vertical"
|
||||
>
|
||||
<a-form-item
|
||||
label="分佣类型"
|
||||
name="commission_type"
|
||||
:rules="[{ required: true, message: '请选择分佣类型' }]"
|
||||
>
|
||||
<a-radio-group v-model:value="commissionForm.commission_type" @change="handleCommissionTypeChange">
|
||||
<a-radio value="rate">按比例分佣</a-radio>
|
||||
<a-radio value="fixed">固定金额分佣</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item
|
||||
v-if="commissionForm.commission_type === 'rate'"
|
||||
label="分佣比例"
|
||||
name="delivery_commission_rate"
|
||||
:rules="[{ required: commissionForm.commission_type === 'rate', message: '请输入分佣比例' }]"
|
||||
>
|
||||
<a-input-number
|
||||
v-model:value="commissionForm.delivery_commission_rate"
|
||||
:min="0"
|
||||
:max="100"
|
||||
:precision="2"
|
||||
:step="1"
|
||||
style="width: 100%"
|
||||
addon-after="%"
|
||||
/>
|
||||
<div class="form-help-text">
|
||||
配送员可获得订单金额的百分比作为佣金
|
||||
</div>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item
|
||||
v-if="commissionForm.commission_type === 'fixed'"
|
||||
label="固定金额"
|
||||
name="delivery_commission_fixed"
|
||||
:rules="[{ required: commissionForm.commission_type === 'fixed', message: '请输入固定金额' }]"
|
||||
>
|
||||
<a-input-number
|
||||
v-model:value="commissionForm.delivery_commission_fixed"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:step="1"
|
||||
style="width: 100%"
|
||||
addon-before="¥"
|
||||
/>
|
||||
<div class="form-help-text">
|
||||
配送员每单可获得的固定金额佣金
|
||||
</div>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</div>
|
||||
</page-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent, ref, onMounted, computed } from 'vue'
|
||||
import { message, Radio } from 'ant-design-vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import request from '@/utils/request'
|
||||
import PageContainer from '@/components/PageContainer.vue'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'DeliverymanList',
|
||||
components: {
|
||||
PageContainer,
|
||||
ARadio: Radio,
|
||||
ARadioGroup: Radio.Group
|
||||
PageContainer
|
||||
},
|
||||
setup() {
|
||||
const loading = ref(false)
|
||||
@ -242,15 +161,10 @@ export default defineComponent({
|
||||
key: 'community_name',
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
title: '分佣设置',
|
||||
key: 'commission',
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 200,
|
||||
width: 150,
|
||||
fixed: 'right'
|
||||
}
|
||||
]
|
||||
@ -363,99 +277,6 @@ export default defineComponent({
|
||||
currentUserId.value = null
|
||||
}
|
||||
|
||||
// 分佣相关状态和方法
|
||||
const commissionModalVisible = ref(false)
|
||||
const commissionSubmitting = ref(false)
|
||||
const commissionFormRef = ref(null)
|
||||
const commissionForm = ref({
|
||||
commission_type: 'rate',
|
||||
delivery_commission_rate: 0,
|
||||
delivery_commission_fixed: 0
|
||||
})
|
||||
const commissionRules = {
|
||||
commission_type: [
|
||||
{ required: true, message: '请选择分佣类型' }
|
||||
],
|
||||
delivery_commission_rate: [
|
||||
{ required: false, message: '请输入分佣比例' },
|
||||
{ type: 'number', min: 0, max: 100, message: '分佣比例必须在0-100之间' }
|
||||
],
|
||||
delivery_commission_fixed: [
|
||||
{ required: false, message: '请输入固定金额' },
|
||||
{ type: 'number', min: 0, message: '固定金额必须大于0' }
|
||||
]
|
||||
}
|
||||
|
||||
// 处理分佣类型变更
|
||||
const handleCommissionTypeChange = (e) => {
|
||||
const type = e.target.value
|
||||
if (type === 'rate') {
|
||||
commissionForm.value.delivery_commission_fixed = 0
|
||||
} else if (type === 'fixed') {
|
||||
commissionForm.value.delivery_commission_rate = 0
|
||||
}
|
||||
}
|
||||
|
||||
// 显示设置分佣模态框
|
||||
const showCommissionModal = (record) => {
|
||||
currentUserId.value = record.userid
|
||||
|
||||
// 根据已有数据判断分佣类型
|
||||
if (record.delivery_commission_fixed > 0) {
|
||||
commissionForm.value.commission_type = 'fixed'
|
||||
commissionForm.value.delivery_commission_fixed = record.delivery_commission_fixed
|
||||
commissionForm.value.delivery_commission_rate = 0
|
||||
} else {
|
||||
commissionForm.value.commission_type = 'rate'
|
||||
commissionForm.value.delivery_commission_rate = record.delivery_commission_rate || 0
|
||||
commissionForm.value.delivery_commission_fixed = 0
|
||||
}
|
||||
|
||||
commissionModalVisible.value = true
|
||||
}
|
||||
|
||||
// 提交分佣设置
|
||||
const handleCommissionSubmit = () => {
|
||||
commissionFormRef.value.validate().then(async () => {
|
||||
try {
|
||||
commissionSubmitting.value = true
|
||||
|
||||
// 根据分佣类型构建参数
|
||||
const params = {
|
||||
user_id: currentUserId.value,
|
||||
delivery_commission_rate: commissionForm.value.commission_type === 'rate' ? commissionForm.value.delivery_commission_rate : 0,
|
||||
delivery_commission_fixed: commissionForm.value.commission_type === 'fixed' ? commissionForm.value.delivery_commission_fixed : 0
|
||||
}
|
||||
|
||||
const res = await request.put('/api/user/delivery-commission', params)
|
||||
|
||||
if (res.code === 200) {
|
||||
message.success('分佣设置成功')
|
||||
commissionModalVisible.value = false
|
||||
fetchData()
|
||||
} else {
|
||||
message.error(res.message || '分佣设置失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('设置分佣失败:', error)
|
||||
message.error('分佣设置失败')
|
||||
} finally {
|
||||
commissionSubmitting.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 取消分佣设置
|
||||
const handleCommissionCancel = () => {
|
||||
commissionModalVisible.value = false
|
||||
currentUserId.value = null
|
||||
commissionForm.value = {
|
||||
commission_type: 'rate',
|
||||
delivery_commission_rate: 0,
|
||||
delivery_commission_fixed: 0
|
||||
}
|
||||
}
|
||||
|
||||
// 处理筛选变化
|
||||
const handleFilterChange = () => {
|
||||
pagination.value.current = 1 // 重置页码
|
||||
@ -496,15 +317,6 @@ export default defineComponent({
|
||||
handleEditCommunity,
|
||||
handleCommunitySave,
|
||||
handleCommunityCancel,
|
||||
commissionModalVisible,
|
||||
commissionSubmitting,
|
||||
commissionForm,
|
||||
commissionFormRef,
|
||||
commissionRules,
|
||||
showCommissionModal,
|
||||
handleCommissionSubmit,
|
||||
handleCommissionTypeChange,
|
||||
handleCommissionCancel,
|
||||
filterForm,
|
||||
handleFilterChange,
|
||||
handleSearch,
|
||||
@ -562,14 +374,4 @@ export default defineComponent({
|
||||
min-width: 80px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.form-help-text {
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
font-size: 12px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
:deep(.ant-input-number-group-addon) {
|
||||
padding: 0 8px;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user