feat(dealer): 添加经销商申请管理功能
- 新增经销商申请页面,支持申请列表展示和分页查询 - 添加搜索组件,支持按客户名称、联系电话、审核状态等条件筛选 - 实现申请状态管理,包括跟进中、已签约、已取消三种状态 - 开发编辑弹窗功能,支持新增和修改申请信息 - 添加审核功能,支持批量通过和单个驳回操作 - 集成跟进记录管理,可查看历史记录并添加新的跟进内容 - 完善表单验证,包含必填字段校验和格式验证 - 优化模型定义,在相关实体中增加头像、昵称、真实姓名等字段 - 调整商品模型,将isShow字段从数字类型改为布尔类型 - 新增分销佣金相关字段,支持固定金额和百分比两种分佣类型
This commit is contained in:
@@ -8,6 +8,8 @@ export interface ShopDealerCapital {
|
||||
id?: number;
|
||||
// 分销商用户ID
|
||||
userId?: number;
|
||||
// 分销商昵称
|
||||
nickName?: string;
|
||||
// 订单ID
|
||||
orderId?: number;
|
||||
// 订单编号
|
||||
|
||||
@@ -12,6 +12,8 @@ export interface ShopDealerOrder {
|
||||
title?: string;
|
||||
// 买家用户昵称
|
||||
nickname?: string;
|
||||
// 真实姓名
|
||||
realName?: string;
|
||||
// 订单编号
|
||||
orderNo?: string;
|
||||
// 订单总金额(不含运费)
|
||||
|
||||
@@ -6,8 +6,12 @@ import type { PageParam } from '@/api';
|
||||
export interface ShopDealerUser {
|
||||
// 主键ID
|
||||
id?: number;
|
||||
// 类型 0经销商 1企业 2集团
|
||||
type?: number;
|
||||
// 自增ID
|
||||
userId?: number;
|
||||
// 头像
|
||||
avatar?: string;
|
||||
// 姓名
|
||||
realName?: string;
|
||||
// 手机号
|
||||
|
||||
@@ -94,7 +94,7 @@ export interface ShopGoods {
|
||||
supplierMerchantId?: number;
|
||||
supplierName?: string;
|
||||
// 状态(0:未上架,1:上架)
|
||||
isShow?: number;
|
||||
isShow?: boolean;
|
||||
// 状态, 0上架 1待上架 2待审核 3审核不通过
|
||||
status?: number;
|
||||
// 备注
|
||||
@@ -124,6 +124,19 @@ export interface ShopGoods {
|
||||
canUseDate?: string;
|
||||
ensureTag?: string;
|
||||
expiredDay?: number;
|
||||
|
||||
// --- 分销/佣金(新字段,后端保持 snake_case)---
|
||||
// 是否开启分销佣金:0关闭 1开启
|
||||
isOpenCommission?: number;
|
||||
// 分佣类型:10固定金额 20百分比
|
||||
commissionType?: number;
|
||||
// 一级/二级/三级分销佣金(单位以服务端为准)
|
||||
firstMoney?: number;
|
||||
secondMoney?: number;
|
||||
thirdMoney?: number;
|
||||
// 一级/二级分红(单位以服务端为准)
|
||||
firstDividend?: number;
|
||||
secondDividend?: number;
|
||||
}
|
||||
|
||||
export interface BathSet {
|
||||
|
||||
158
src/views/glt/shopDealerApply/components/search.vue
Normal file
158
src/views/glt/shopDealerApply/components/search.vue
Normal file
@@ -0,0 +1,158 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<div class="search-container">
|
||||
<!-- 搜索表单 -->
|
||||
<a-form
|
||||
:model="searchForm"
|
||||
layout="inline"
|
||||
class="search-form"
|
||||
@finish="handleSearch"
|
||||
>
|
||||
<a-form-item label="客户名称">
|
||||
<a-input
|
||||
v-model:value="searchForm.dealerName"
|
||||
placeholder="请输入客户名称"
|
||||
allow-clear
|
||||
style="width: 160px"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="联系电话">
|
||||
<a-input
|
||||
v-model:value="searchForm.mobile"
|
||||
placeholder="客户联系电话"
|
||||
allow-clear
|
||||
style="width: 160px"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="审核状态">
|
||||
<a-select
|
||||
v-model:value="searchForm.applyStatus"
|
||||
placeholder="全部状态"
|
||||
allow-clear
|
||||
style="width: 120px"
|
||||
>
|
||||
<a-select-option :value="10">跟进中</a-select-option>
|
||||
<a-select-option :value="20">已签约</a-select-option>
|
||||
<a-select-option :value="30">已取消</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="添加时间">
|
||||
<a-range-picker
|
||||
v-model:value="searchForm.dateRange"
|
||||
style="width: 240px"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item>
|
||||
<a-space>
|
||||
<a-button type="primary" html-type="submit" class="ele-btn-icon">
|
||||
<template #icon>
|
||||
<SearchOutlined />
|
||||
</template>
|
||||
搜索
|
||||
</a-button>
|
||||
<a-button @click="resetSearch"> 重置 </a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive } from 'vue';
|
||||
import { SearchOutlined } from '@ant-design/icons-vue';
|
||||
import type { ShopDealerApplyParam } from '@/api/shop/shopDealerApply/model';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的数据
|
||||
selection?: any[];
|
||||
}>(),
|
||||
{
|
||||
selection: () => []
|
||||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: ShopDealerApplyParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'batchApprove'): void;
|
||||
(e: 'export'): void;
|
||||
}>();
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive<any>({
|
||||
realName: '',
|
||||
mobile: '',
|
||||
applyType: undefined,
|
||||
applyStatus: undefined,
|
||||
dateRange: undefined
|
||||
});
|
||||
|
||||
// 搜索
|
||||
const handleSearch = () => {
|
||||
const searchParams: ShopDealerApplyParam = {};
|
||||
|
||||
if (searchForm.realName) {
|
||||
searchParams.realName = searchForm.realName;
|
||||
}
|
||||
if (searchForm.mobile) {
|
||||
searchParams.mobile = searchForm.mobile;
|
||||
}
|
||||
if (searchForm.applyType) {
|
||||
searchParams.applyType = searchForm.applyType;
|
||||
}
|
||||
if (searchForm.applyStatus) {
|
||||
searchParams.applyStatus = searchForm.applyStatus;
|
||||
}
|
||||
if (searchForm.dateRange && searchForm.dateRange.length === 2) {
|
||||
searchParams.startTime = dayjs(searchForm.dateRange[0]).format(
|
||||
'YYYY-MM-DD'
|
||||
);
|
||||
searchParams.endTime = dayjs(searchForm.dateRange[1]).format(
|
||||
'YYYY-MM-DD'
|
||||
);
|
||||
}
|
||||
if (searchForm.dealerName) {
|
||||
searchParams.dealerName = searchForm.dealerName;
|
||||
}
|
||||
|
||||
emit('search', searchParams);
|
||||
};
|
||||
|
||||
// 重置搜索
|
||||
const resetSearch = () => {
|
||||
searchForm.realName = '';
|
||||
searchForm.mobile = '';
|
||||
searchForm.applyType = undefined;
|
||||
searchForm.applyStatus = undefined;
|
||||
searchForm.dateRange = undefined;
|
||||
emit('search', {});
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.search-container {
|
||||
background: #fff;
|
||||
padding: 16px;
|
||||
border-radius: 6px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
.search-form {
|
||||
margin-bottom: 16px;
|
||||
|
||||
:deep(.ant-form-item) {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
border-top: 1px solid #f0f0f0;
|
||||
padding-top: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
645
src/views/glt/shopDealerApply/components/shopDealerApplyEdit.vue
Normal file
645
src/views/glt/shopDealerApply/components/shopDealerApplyEdit.vue
Normal file
@@ -0,0 +1,645 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="900"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '编辑客户' : '新增客户'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<!-- 客户信息 -->
|
||||
<a-divider orientation="left">
|
||||
<span style="color: #1890ff; font-weight: 600">客户信息</span>
|
||||
</a-divider>
|
||||
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="客户名称" name="dealerName">
|
||||
<a-input
|
||||
placeholder="请输入客户名称"
|
||||
v-model:value="form.dealerName"
|
||||
:disabled="form.applyStatus == 20"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="联系人" name="realName">
|
||||
<a-input
|
||||
placeholder="请输入联系人"
|
||||
v-model:value="form.realName"
|
||||
:disabled="form.applyStatus == 20"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="手机号码" name="mobile">
|
||||
<a-input
|
||||
placeholder="请输入手机号码"
|
||||
:disabled="form.applyStatus == 20"
|
||||
v-model:value="form.mobile"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="收益基数" name="rate">
|
||||
<a-input-number
|
||||
placeholder="0.007"
|
||||
:min="0"
|
||||
:max="1"
|
||||
step="0.01"
|
||||
:disabled="!hasRole('superAdmin')"
|
||||
v-model:value="form.rate"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<!-- 报备人信息 -->
|
||||
<a-divider orientation="left">
|
||||
<span style="color: #1890ff; font-weight: 600">报备人信息</span>
|
||||
</a-divider>
|
||||
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="报备人ID" name="userId">
|
||||
<a-input-number
|
||||
:min="1"
|
||||
placeholder="请输入报备人ID"
|
||||
:disabled="isUpdate"
|
||||
v-model:value="form.userId"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="报备人" name="nickName">
|
||||
<a-input-number
|
||||
:min="1"
|
||||
placeholder="请输入报备人名称"
|
||||
:disabled="isUpdate"
|
||||
v-model:value="form.nickName"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="推荐人ID" name="refereeId">
|
||||
<a-input-number
|
||||
:min="1"
|
||||
placeholder="请输入推荐人用户ID"
|
||||
:disabled="isUpdate"
|
||||
v-model:value="form.refereeId"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="推荐人名称" name="refereeName">
|
||||
<a-input-number
|
||||
:min="1"
|
||||
placeholder="请输入推荐人名称"
|
||||
:disabled="isUpdate"
|
||||
v-model:value="form.refereeName"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<!-- 审核信息 -->
|
||||
<a-divider orientation="left">
|
||||
<span style="color: #1890ff; font-weight: 600">审核状态</span>
|
||||
</a-divider>
|
||||
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="审核状态" name="applyStatus">
|
||||
<a-select
|
||||
v-model:value="form.applyStatus"
|
||||
placeholder="请选择审核状态"
|
||||
@change="handleStatusChange"
|
||||
>
|
||||
<a-select-option :value="10">
|
||||
<a-tag color="orange">跟进中</a-tag>
|
||||
<span style="margin-left: 8px">正在跟进中</span>
|
||||
</a-select-option>
|
||||
<a-select-option :value="20">
|
||||
<a-tag color="success">已签约</a-tag>
|
||||
<span style="margin-left: 8px">客户已签约</span>
|
||||
</a-select-option>
|
||||
<a-select-option :value="30">
|
||||
<a-tag color="error">已取消</a-tag>
|
||||
<span style="margin-left: 8px">客户已取消</span>
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12" v-if="form.applyStatus === 30">
|
||||
<a-form-item label="取消原因" name="rejectReason">
|
||||
<a-textarea
|
||||
v-model:value="form.rejectReason"
|
||||
placeholder="请输入取消原因"
|
||||
style="width: 100%"
|
||||
:rows="3"
|
||||
:maxlength="200"
|
||||
show-count
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<!-- 跟进情况 -->
|
||||
<a-divider orientation="left" v-if="form.applyStatus == 10">
|
||||
<span style="color: #1890ff; font-weight: 600">跟进情况</span>
|
||||
</a-divider>
|
||||
|
||||
<!-- 历史跟进记录 -->
|
||||
<div v-if="form.applyStatus == 10 && historyRecords.length > 0">
|
||||
<a-divider orientation="left" style="font-size: 14px; color: #666">
|
||||
历史跟进记录
|
||||
</a-divider>
|
||||
<div
|
||||
v-for="(record, index) in historyRecords"
|
||||
:key="record.id"
|
||||
style="
|
||||
margin-bottom: 16px;
|
||||
padding: 12px;
|
||||
background-color: #f5f5f5;
|
||||
border-radius: 4px;
|
||||
"
|
||||
>
|
||||
<div
|
||||
class="flex justify-between"
|
||||
style="font-weight: 500; margin-bottom: 8px"
|
||||
>
|
||||
<div
|
||||
>跟进 #{{ historyRecords.length - index }}
|
||||
<span class="text-gray-400 px-4">{{
|
||||
record.createTime
|
||||
}}</span></div
|
||||
>
|
||||
<a-tag color="#f50" class="cursor-pointer" @click="remove(record)"
|
||||
>删除</a-tag
|
||||
>
|
||||
</div>
|
||||
<div style="white-space: pre-wrap">
|
||||
{{ record.content }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 新增跟进记录 -->
|
||||
<div v-if="form.applyStatus == 10">
|
||||
<a-divider orientation="left" style="font-size: 14px; color: #666">
|
||||
新增跟进记录
|
||||
</a-divider>
|
||||
<a-form-item :wrapper-col="{ span: 24 }">
|
||||
<div class="flex flex-col gap-2">
|
||||
<a-textarea
|
||||
v-model:value="newFollowUpContent"
|
||||
placeholder="请输入本次跟进内容"
|
||||
:rows="4"
|
||||
:maxlength="500"
|
||||
style="width: 80%"
|
||||
show-count
|
||||
/>
|
||||
<div class="btn">
|
||||
<a-button
|
||||
type="primary"
|
||||
@click="saveFollowUpRecord"
|
||||
:loading="followUpLoading"
|
||||
:disabled="!newFollowUpContent.trim()"
|
||||
>
|
||||
保存跟进记录
|
||||
</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</a-form-item>
|
||||
</div>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
import {
|
||||
addShopDealerApply,
|
||||
updateShopDealerApply
|
||||
} from '@/api/shop/shopDealerApply';
|
||||
import {
|
||||
listShopDealerRecord,
|
||||
addShopDealerRecord,
|
||||
removeShopDealerRecord
|
||||
} from '@/api/shop/shopDealerRecord';
|
||||
import { ShopDealerApply } from '@/api/shop/shopDealerApply/model';
|
||||
import { ShopDealerRecord } from '@/api/shop/shopDealerRecord/model';
|
||||
import { FormInstance, RuleObject } from 'ant-design-vue/es/form';
|
||||
import { messageLoading } from 'ele-admin-pro';
|
||||
import { hasRole } from '@/utils/permission';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: ShopDealerApply | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 跟进记录保存状态
|
||||
const followUpLoading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
// 表格选中数据
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
// 历史跟进记录
|
||||
const historyRecords = ref<ShopDealerRecord[]>([]);
|
||||
|
||||
// 新的跟进内容
|
||||
const newFollowUpContent = ref('');
|
||||
|
||||
// 表单数据
|
||||
const form = reactive<ShopDealerApply>({
|
||||
applyId: undefined,
|
||||
userId: undefined,
|
||||
nickName: undefined,
|
||||
realName: '',
|
||||
mobile: '',
|
||||
dealerName: '',
|
||||
rate: 0.007,
|
||||
refereeId: undefined,
|
||||
refereeName: undefined,
|
||||
applyType: 10,
|
||||
applyTime: undefined,
|
||||
applyStatus: 10,
|
||||
auditTime: undefined,
|
||||
rejectReason: '',
|
||||
tenantId: undefined,
|
||||
createTime: undefined,
|
||||
updateTime: undefined
|
||||
});
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
userId: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入用户ID',
|
||||
trigger: 'blur'
|
||||
} as RuleObject
|
||||
],
|
||||
realName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入客户名称',
|
||||
trigger: 'blur'
|
||||
} as RuleObject,
|
||||
{
|
||||
min: 2,
|
||||
max: 20,
|
||||
message: '姓名长度应在2-20个字符之间',
|
||||
trigger: 'blur'
|
||||
} as RuleObject
|
||||
],
|
||||
rate: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入收益基数',
|
||||
trigger: 'blur'
|
||||
} as RuleObject
|
||||
],
|
||||
mobile: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入手机号码',
|
||||
trigger: 'blur'
|
||||
} as RuleObject,
|
||||
{
|
||||
pattern: /^1[3-9]\d{9}$/,
|
||||
message: '请输入正确的手机号码',
|
||||
trigger: 'blur'
|
||||
} as RuleObject
|
||||
],
|
||||
applyType: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择申请方式',
|
||||
trigger: 'change'
|
||||
} as RuleObject
|
||||
],
|
||||
applyStatus: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择审核状态',
|
||||
trigger: 'change'
|
||||
} as RuleObject
|
||||
],
|
||||
rejectReason: [
|
||||
{
|
||||
required: true,
|
||||
message: '驳回时必须填写驳回原因',
|
||||
trigger: 'blur'
|
||||
} as RuleObject
|
||||
],
|
||||
auditTime: [
|
||||
{
|
||||
required: true,
|
||||
message: '审核时请选择审核时间',
|
||||
trigger: 'change'
|
||||
} as RuleObject
|
||||
]
|
||||
});
|
||||
|
||||
/* 获取历史跟进记录 */
|
||||
const fetchHistoryRecords = async (dealerId: number) => {
|
||||
try {
|
||||
// 先通过list接口获取所有记录,然后过滤
|
||||
const allRecords = await listShopDealerRecord({});
|
||||
const records = allRecords.filter(
|
||||
(record) => record.dealerId === dealerId
|
||||
);
|
||||
|
||||
// 按创建时间倒序排列(最新的在前面)
|
||||
historyRecords.value = records.sort((a, b) => {
|
||||
if (a.createTime && b.createTime) {
|
||||
return (
|
||||
new Date(b.createTime).getTime() - new Date(a.createTime).getTime()
|
||||
);
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('获取历史跟进记录失败:', error);
|
||||
message.error('获取历史跟进记录失败');
|
||||
historyRecords.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
/* 保存新的跟进记录 */
|
||||
const saveFollowUpRecord = async () => {
|
||||
// 检查是否有客户ID
|
||||
if (!form.applyId) {
|
||||
message.warning('请先保存客户信息');
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否有跟进内容
|
||||
if (!newFollowUpContent.value.trim()) {
|
||||
message.warning('请输入跟进内容');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
followUpLoading.value = true;
|
||||
const recordData: any = {
|
||||
content: newFollowUpContent.value.trim(),
|
||||
dealerId: form.applyId,
|
||||
userId: form.userId,
|
||||
status: 1, // 默认设置为已完成
|
||||
sortNumber: 100
|
||||
};
|
||||
|
||||
// 新增逻辑
|
||||
await addShopDealerRecord(recordData);
|
||||
message.success('跟进记录保存成功');
|
||||
// 保存最后跟进内容到主表
|
||||
await updateShopDealerApply({
|
||||
...form,
|
||||
comments: newFollowUpContent.value.trim()
|
||||
});
|
||||
|
||||
// 清空输入框
|
||||
newFollowUpContent.value = '';
|
||||
|
||||
// 重新加载历史记录
|
||||
await fetchHistoryRecords(form.applyId);
|
||||
} catch (error) {
|
||||
console.error('保存跟进记录失败:', error);
|
||||
message.error('保存跟进记录失败');
|
||||
} finally {
|
||||
followUpLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const { resetFields } = useForm(form, rules);
|
||||
|
||||
/* 处理审核状态变化 */
|
||||
const handleStatusChange = (value: number) => {
|
||||
// 当状态改为审核通过或驳回时,自动设置审核时间为当前时间
|
||||
if ((value === 20 || value === 30) && !form.auditTime) {
|
||||
form.auditTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
||||
}
|
||||
// 当状态改为待审核时,清空审核时间和驳回原因
|
||||
if (value === 10) {
|
||||
form.auditTime = undefined;
|
||||
form.rejectReason = '';
|
||||
}
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: ShopDealerRecord) => {
|
||||
const hide = messageLoading('请求中..', 0);
|
||||
removeShopDealerRecord(row.id)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
// 重新加载历史记录
|
||||
if (props.data?.applyId) {
|
||||
fetchHistoryRecords(props.data?.applyId);
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 动态验证规则
|
||||
const validateFields: string[] = [
|
||||
'userId',
|
||||
'realName',
|
||||
'mobile',
|
||||
'applyStatus'
|
||||
];
|
||||
|
||||
// 如果是驳回状态,需要验证驳回原因
|
||||
if (form.applyStatus === 30) {
|
||||
validateFields.push('rejectReason');
|
||||
}
|
||||
|
||||
// 如果是审核通过或驳回状态,需要验证审核时间
|
||||
if (form.applyStatus === 20 || form.applyStatus === 30) {
|
||||
validateFields.push('auditTime');
|
||||
}
|
||||
|
||||
formRef.value
|
||||
.validate(validateFields)
|
||||
.then(async () => {
|
||||
loading.value = true;
|
||||
const formData = {
|
||||
...form
|
||||
};
|
||||
|
||||
// 处理时间字段转换 - 转换为ISO字符串格式
|
||||
if (formData.applyTime) {
|
||||
if (dayjs.isDayjs(formData.applyTime)) {
|
||||
formData.applyTime = formData.applyTime.format(
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
);
|
||||
} else if (typeof formData.applyTime === 'number') {
|
||||
formData.applyTime = dayjs(formData.applyTime).format(
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (formData.auditTime) {
|
||||
if (dayjs.isDayjs(formData.auditTime)) {
|
||||
formData.auditTime = formData.auditTime.format(
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
);
|
||||
} else if (typeof formData.auditTime === 'number') {
|
||||
formData.auditTime = dayjs(formData.auditTime).format(
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 当审核状态为通过或驳回时,确保有审核时间
|
||||
if (
|
||||
(formData.applyStatus === 20 || formData.applyStatus === 30) &&
|
||||
!formData.auditTime
|
||||
) {
|
||||
formData.auditTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
||||
}
|
||||
|
||||
// 当状态为待审核时,清空审核时间
|
||||
if (formData.applyStatus === 10) {
|
||||
formData.auditTime = undefined;
|
||||
}
|
||||
|
||||
const saveOrUpdate = isUpdate.value
|
||||
? updateShopDealerApply
|
||||
: addShopDealerApply;
|
||||
try {
|
||||
const msg = await saveOrUpdate(formData);
|
||||
message.success(msg);
|
||||
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
} catch (e: any) {
|
||||
message.error(e.message);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
async (visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
assignObject(form, props.data);
|
||||
isUpdate.value = true;
|
||||
|
||||
// 如果是修改且状态为跟进中,获取历史跟进记录
|
||||
if (props.data.applyId && props.data.applyStatus === 10) {
|
||||
await fetchHistoryRecords(props.data.applyId);
|
||||
}
|
||||
} else {
|
||||
// 重置为默认值
|
||||
Object.assign(form, {
|
||||
applyId: undefined,
|
||||
userId: undefined,
|
||||
realName: '',
|
||||
mobile: '',
|
||||
refereeId: undefined,
|
||||
applyType: 10,
|
||||
applyTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
applyStatus: 10,
|
||||
auditTime: undefined,
|
||||
rejectReason: '',
|
||||
tenantId: undefined,
|
||||
createTime: undefined,
|
||||
updateTime: undefined
|
||||
});
|
||||
isUpdate.value = false;
|
||||
|
||||
// 重置历史记录和新内容
|
||||
historyRecords.value = [];
|
||||
newFollowUpContent.value = '';
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
:deep(.ant-divider-horizontal.ant-divider-with-text-left) {
|
||||
margin: 24px 0 16px 0;
|
||||
|
||||
.ant-divider-inner-text {
|
||||
padding: 0 16px 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-form-item) {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
:deep(.ant-radio) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
|
||||
.ant-radio-inner {
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-select-selection-item) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
458
src/views/glt/shopDealerApply/index.vue
Normal file
458
src/views/glt/shopDealerApply/index.vue
Normal file
@@ -0,0 +1,458 @@
|
||||
<template>
|
||||
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
|
||||
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="applyId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:customRow="customRow"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-org-table"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@add="openEdit"
|
||||
@batchApprove="batchApprove"
|
||||
@export="exportData"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'applyStatus'">
|
||||
<a-tag v-if="record.applyStatus === 10" color="orange"
|
||||
>跟进中</a-tag
|
||||
>
|
||||
<a-tag v-if="record.applyStatus === 20" color="green">已签约</a-tag>
|
||||
<a-tag v-if="record.applyStatus === 30" color="red">已取消</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'customer'">
|
||||
<div class="flex flex-col">
|
||||
<span class="font-medium">{{ record.dealerName }}</span>
|
||||
<span class="text-gray-400">联系人:{{ record.realName }}</span>
|
||||
<span class="text-gray-400">联系电话:{{ record.mobile }}</span>
|
||||
<span class="text-gray-400">户号:{{ record.dealerCode }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'applicantInfo'">
|
||||
<div class="text-gray-600">{{ record.nickName }}</div>
|
||||
<div class="text-gray-400">{{ record.phone }}</div>
|
||||
<div class="text-gray-400">{{ record.rate }}</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'comments'">
|
||||
<div class="text-gray-400">{{ record.comments }}</div>
|
||||
<div class="text-gray-400" v-if="record.comments">{{
|
||||
record.updateTime
|
||||
}}</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'createTime'">
|
||||
<div class="flex flex-col">
|
||||
<span>{{ record.createTime }}</span>
|
||||
<span>保护期:7天</span>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a @click="openEdit(record)" class="ele-text-primary">
|
||||
<EditOutlined />
|
||||
编辑
|
||||
</a>
|
||||
<template v-if="record.applyStatus !== 20">
|
||||
<a-divider type="vertical" />
|
||||
<a @click="approveApply(record)" class="ele-text-success">
|
||||
<CheckOutlined />
|
||||
已签约
|
||||
</a>
|
||||
<a-divider type="vertical" />
|
||||
<a @click="rejectApply(record)" class="ele-text-warning">
|
||||
<CloseOutlined />
|
||||
驳回
|
||||
</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
v-if="record.applyStatus != 20"
|
||||
title="确定要删除此申请记录吗?"
|
||||
@confirm="remove(record)"
|
||||
placement="topRight"
|
||||
>
|
||||
<a class="ele-text-danger">
|
||||
<DeleteOutlined />
|
||||
删除
|
||||
</a>
|
||||
</a-popconfirm>
|
||||
</template>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<ShopDealerApplyEdit
|
||||
v-model:visible="showEdit"
|
||||
:data="current"
|
||||
@done="reload"
|
||||
/>
|
||||
</a-page-header>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import {
|
||||
ExclamationCircleOutlined,
|
||||
CheckOutlined,
|
||||
CloseOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import Search from './components/search.vue';
|
||||
import { getPageTitle } from '@/utils/common';
|
||||
import ShopDealerApplyEdit from './components/shopDealerApplyEdit.vue';
|
||||
import {
|
||||
pageShopDealerApply,
|
||||
removeShopDealerApply,
|
||||
removeBatchShopDealerApply,
|
||||
batchApproveShopDealerApply,
|
||||
updateShopDealerApply
|
||||
} from '@/api/shop/shopDealerApply';
|
||||
import type {
|
||||
ShopDealerApply,
|
||||
ShopDealerApplyParam
|
||||
} from '@/api/shop/shopDealerApply/model';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<ShopDealerApply[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<ShopDealerApply | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.status = filters.status;
|
||||
}
|
||||
where.type = 4;
|
||||
return pageShopDealerApply({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: '用户ID',
|
||||
dataIndex: 'userId',
|
||||
key: 'userId',
|
||||
align: 'center',
|
||||
width: 90,
|
||||
fixed: 'left'
|
||||
},
|
||||
{
|
||||
title: '客户名称',
|
||||
dataIndex: 'customer',
|
||||
key: 'customer'
|
||||
},
|
||||
{
|
||||
title: '最后跟进情况',
|
||||
dataIndex: 'comments',
|
||||
key: 'comments',
|
||||
align: 'left'
|
||||
},
|
||||
// {
|
||||
// title: '收益基数',
|
||||
// dataIndex: 'rate',
|
||||
// key: 'rate',
|
||||
// align: 'left'
|
||||
// },
|
||||
{
|
||||
title: '报备人信息',
|
||||
dataIndex: 'applicantInfo',
|
||||
key: 'applicantInfo',
|
||||
align: 'left',
|
||||
fixed: 'left',
|
||||
customRender: ({ record }) => {
|
||||
return `${record.nickName || '-'} (${record.phone || '-'})`;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'applyStatus',
|
||||
key: 'applyStatus',
|
||||
align: 'center',
|
||||
width: 120
|
||||
},
|
||||
// {
|
||||
// title: '申请时间',
|
||||
// dataIndex: 'applyTime',
|
||||
// key: 'applyTime',
|
||||
// align: 'center',
|
||||
// width: 120,
|
||||
// customRender: ({ text }) => text ? toDateString(new Date(text), 'yyyy-MM-dd HH:mm') : '-'
|
||||
// },
|
||||
// {
|
||||
// title: '审核时间',
|
||||
// dataIndex: 'auditTime',
|
||||
// key: 'auditTime',
|
||||
// align: 'center',
|
||||
// customRender: ({ text }) => text ? toDateString(new Date(text), 'yyyy-MM-dd HH:mm') : '-'
|
||||
// },
|
||||
{
|
||||
title: '添加时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
align: 'center',
|
||||
sorter: true,
|
||||
ellipsis: true
|
||||
}
|
||||
// {
|
||||
// title: '操作',
|
||||
// key: 'action',
|
||||
// fixed: 'right',
|
||||
// align: 'center',
|
||||
// width: 380,
|
||||
// hideInSetting: true
|
||||
// }
|
||||
]);
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: ShopDealerApplyParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
/* 审核通过 */
|
||||
const approveApply = (row: ShopDealerApply) => {
|
||||
Modal.confirm({
|
||||
title: '审核通过确认',
|
||||
content: `确定要通过 ${row.realName} 的经销商申请吗?`,
|
||||
icon: createVNode(CheckOutlined),
|
||||
okText: '确认通过',
|
||||
okType: 'primary',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
const hide = message.loading('正在处理审核...', 0);
|
||||
try {
|
||||
await updateShopDealerApply({
|
||||
...row,
|
||||
applyId: row.applyId,
|
||||
applyStatus: 20
|
||||
});
|
||||
hide();
|
||||
message.success('审核通过成功');
|
||||
reload();
|
||||
} catch (error: any) {
|
||||
hide();
|
||||
message.error(error.message || '审核失败,请重试');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 审核驳回 */
|
||||
const rejectApply = (row: ShopDealerApply) => {
|
||||
let rejectReason = '';
|
||||
Modal.confirm({
|
||||
title: '审核驳回',
|
||||
content: createVNode('div', null, [
|
||||
createVNode('p', null, `申请人: ${row.realName} (${row.mobile})`),
|
||||
createVNode('p', { style: 'margin-top: 12px;' }, '请输入驳回原因:'),
|
||||
createVNode('textarea', {
|
||||
placeholder: '请输入驳回原因...',
|
||||
style:
|
||||
'width: 100%; height: 80px; margin-top: 8px; padding: 8px; border: 1px solid #d9d9d9; border-radius: 4px;',
|
||||
onInput: (e: any) => {
|
||||
rejectReason = e.target.value;
|
||||
}
|
||||
})
|
||||
]),
|
||||
icon: createVNode(CloseOutlined),
|
||||
okText: '确认驳回',
|
||||
okType: 'danger',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
if (!rejectReason.trim()) {
|
||||
message.error('请输入驳回原因');
|
||||
return Promise.reject();
|
||||
}
|
||||
const hide = message.loading('正在处理审核...', 0);
|
||||
try {
|
||||
await updateShopDealerApply({
|
||||
...row,
|
||||
applyStatus: 30,
|
||||
rejectReason: rejectReason.trim()
|
||||
});
|
||||
hide();
|
||||
message.success('审核驳回成功');
|
||||
reload();
|
||||
} catch (error: any) {
|
||||
hide();
|
||||
message.error(error.message || '审核失败,请重试');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: ShopDealerApply) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: ShopDealerApply) => {
|
||||
if (!row.applyId) {
|
||||
message.error('删除失败:缺少必要参数');
|
||||
return;
|
||||
}
|
||||
|
||||
const hide = message.loading('正在删除申请记录...', 0);
|
||||
removeShopDealerApply(row.applyId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg || '删除成功');
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message || '删除失败');
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
|
||||
const validIds = selection.value
|
||||
.filter((d) => d.applyId)
|
||||
.map((d) => d.applyId);
|
||||
if (!validIds.length) {
|
||||
message.error('选中的数据中没有有效的ID');
|
||||
return;
|
||||
}
|
||||
|
||||
Modal.confirm({
|
||||
title: '批量删除确认',
|
||||
content: `确定要删除选中的 ${validIds.length} 条申请记录吗?此操作不可恢复。`,
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
okText: '确认删除',
|
||||
okType: 'danger',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
const hide = message.loading(
|
||||
`正在删除 ${validIds.length} 条记录...`,
|
||||
0
|
||||
);
|
||||
removeBatchShopDealerApply(validIds)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg || `成功删除 ${validIds.length} 条记录`);
|
||||
selection.value = [];
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message || '批量删除失败');
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量通过 */
|
||||
const batchApprove = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
|
||||
const pendingApplies = selection.value.filter(
|
||||
(item) => item.applyStatus === 10
|
||||
);
|
||||
if (!pendingApplies.length) {
|
||||
message.error('所选申请中没有待审核的记录');
|
||||
return;
|
||||
}
|
||||
|
||||
Modal.confirm({
|
||||
title: '批量通过确认',
|
||||
content: `确定要通过选中的 ${pendingApplies.length} 个申请吗?`,
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
okText: '确认通过',
|
||||
okType: 'primary',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
const hide = message.loading('正在批量通过...', 0);
|
||||
try {
|
||||
const ids = pendingApplies.map((item) => item.applyId);
|
||||
await batchApproveShopDealerApply(ids);
|
||||
hide();
|
||||
message.success(`成功通过 ${pendingApplies.length} 个申请`);
|
||||
selection.value = [];
|
||||
reload();
|
||||
} catch (error: any) {
|
||||
hide();
|
||||
message.error(error.message || '批量审核失败,请重试');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 导出数据 */
|
||||
const exportData = () => {
|
||||
const hide = message.loading('正在导出申请数据...', 0);
|
||||
// 这里调用导出API
|
||||
setTimeout(() => {
|
||||
hide();
|
||||
message.success('申请数据导出成功');
|
||||
}, 2000);
|
||||
};
|
||||
|
||||
/* 查询 */
|
||||
const query = () => {
|
||||
loading.value = true;
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: ShopDealerApply) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
query();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'ShopDealerApply'
|
||||
};
|
||||
</script>
|
||||
221
src/views/glt/shopDealerApplyRs/components/search.vue
Normal file
221
src/views/glt/shopDealerApplyRs/components/search.vue
Normal file
@@ -0,0 +1,221 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<div class="search-container">
|
||||
<!-- 搜索表单 -->
|
||||
<a-form
|
||||
:model="searchForm"
|
||||
layout="inline"
|
||||
class="search-form"
|
||||
@finish="handleSearch"
|
||||
>
|
||||
<a-form-item label="申请人姓名">
|
||||
<a-input
|
||||
v-model:value="searchForm.realName"
|
||||
placeholder="请输入申请人姓名"
|
||||
allow-clear
|
||||
style="width: 160px"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="手机号码">
|
||||
<a-input
|
||||
v-model:value="searchForm.mobile"
|
||||
placeholder="请输入手机号码"
|
||||
allow-clear
|
||||
style="width: 160px"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="申请方式">
|
||||
<a-select
|
||||
v-model:value="searchForm.applyType"
|
||||
placeholder="全部方式"
|
||||
allow-clear
|
||||
style="width: 120px"
|
||||
>
|
||||
<a-select-option :value="10">需要审核</a-select-option>
|
||||
<a-select-option :value="20">免审核</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="审核状态">
|
||||
<a-select
|
||||
v-model:value="searchForm.applyStatus"
|
||||
placeholder="全部状态"
|
||||
allow-clear
|
||||
style="width: 120px"
|
||||
>
|
||||
<a-select-option :value="10">待审核</a-select-option>
|
||||
<a-select-option :value="20">审核通过</a-select-option>
|
||||
<a-select-option :value="30">审核驳回</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="申请时间">
|
||||
<a-range-picker
|
||||
v-model:value="searchForm.dateRange"
|
||||
style="width: 240px"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item>
|
||||
<a-space>
|
||||
<a-button type="primary" html-type="submit" class="ele-btn-icon">
|
||||
<template #icon>
|
||||
<SearchOutlined />
|
||||
</template>
|
||||
搜索
|
||||
</a-button>
|
||||
<a-button @click="resetSearch"> 重置 </a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<div class="action-buttons">
|
||||
<a-space>
|
||||
<!-- <a-button type="primary" @click="add" class="ele-btn-icon">-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <PlusOutlined />-->
|
||||
<!-- </template>-->
|
||||
<!-- 新增申请-->
|
||||
<!-- </a-button>-->
|
||||
<a-button
|
||||
type="primary"
|
||||
ghost
|
||||
:disabled="!selection?.length"
|
||||
@click="batchApprove"
|
||||
class="ele-btn-icon"
|
||||
>
|
||||
<template #icon>
|
||||
<CheckOutlined />
|
||||
</template>
|
||||
批量通过
|
||||
</a-button>
|
||||
<a-button
|
||||
:disabled="!selection?.length"
|
||||
@click="exportData"
|
||||
class="ele-btn-icon"
|
||||
>
|
||||
<template #icon>
|
||||
<ExportOutlined />
|
||||
</template>
|
||||
导出数据
|
||||
</a-button>
|
||||
</a-space>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive } from 'vue';
|
||||
import {
|
||||
PlusOutlined,
|
||||
SearchOutlined,
|
||||
CheckOutlined,
|
||||
ExportOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { ShopDealerApplyParam } from '@/api/shop/shopDealerApply/model';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的数据
|
||||
selection?: any[];
|
||||
}>(),
|
||||
{
|
||||
selection: () => []
|
||||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: ShopDealerApplyParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'batchApprove'): void;
|
||||
(e: 'export'): void;
|
||||
}>();
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive<any>({
|
||||
realName: '',
|
||||
mobile: '',
|
||||
applyType: undefined,
|
||||
applyStatus: undefined,
|
||||
dateRange: undefined
|
||||
});
|
||||
|
||||
// 搜索
|
||||
const handleSearch = () => {
|
||||
const searchParams: ShopDealerApplyParam = {};
|
||||
|
||||
if (searchForm.realName) {
|
||||
searchParams.realName = searchForm.realName;
|
||||
}
|
||||
if (searchForm.mobile) {
|
||||
searchParams.mobile = searchForm.mobile;
|
||||
}
|
||||
if (searchForm.applyType) {
|
||||
searchParams.applyType = searchForm.applyType;
|
||||
}
|
||||
if (searchForm.applyStatus) {
|
||||
searchParams.applyStatus = searchForm.applyStatus;
|
||||
}
|
||||
if (searchForm.dateRange && searchForm.dateRange.length === 2) {
|
||||
searchParams.startTime = dayjs(searchForm.dateRange[0]).format(
|
||||
'YYYY-MM-DD'
|
||||
);
|
||||
searchParams.endTime = dayjs(searchForm.dateRange[1]).format(
|
||||
'YYYY-MM-DD'
|
||||
);
|
||||
}
|
||||
|
||||
emit('search', searchParams);
|
||||
};
|
||||
|
||||
// 重置搜索
|
||||
const resetSearch = () => {
|
||||
searchForm.realName = '';
|
||||
searchForm.mobile = '';
|
||||
searchForm.applyType = undefined;
|
||||
searchForm.applyStatus = undefined;
|
||||
searchForm.dateRange = undefined;
|
||||
emit('search', {});
|
||||
};
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 批量通过
|
||||
const batchApprove = () => {
|
||||
emit('batchApprove');
|
||||
};
|
||||
|
||||
// 导出数据
|
||||
const exportData = () => {
|
||||
emit('export');
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.search-container {
|
||||
background: #fff;
|
||||
padding: 16px;
|
||||
border-radius: 6px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
.search-form {
|
||||
margin-bottom: 16px;
|
||||
|
||||
:deep(.ant-form-item) {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
border-top: 1px solid #f0f0f0;
|
||||
padding-top: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,9 +1,9 @@
|
||||
<!-- 分销商用户导入弹窗 -->
|
||||
<!-- 经销商申请批量导入弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="520"
|
||||
:footer="null"
|
||||
title="分销商用户批量导入"
|
||||
title="经销商申请批量导入"
|
||||
:visible="visible"
|
||||
@update:visible="updateVisible"
|
||||
>
|
||||
@@ -21,20 +21,13 @@
|
||||
</a-upload-dragger>
|
||||
</a-spin>
|
||||
<div class="ele-text-center">
|
||||
<span>只能上传xls、xlsx文件,导入模板和导出模板格式一致</span>
|
||||
</div>
|
||||
<div class="import-tips" style="margin-top: 16px">
|
||||
<a-alert message="导入说明" type="info" show-icon>
|
||||
<template #description>
|
||||
<div>
|
||||
<p>1. 请按照导出的Excel格式准备数据</p>
|
||||
<p>2. 必填字段:用户ID、姓名、手机号</p>
|
||||
<p>3. 佣金字段请填写数字,不要包含货币符号</p>
|
||||
<p>4. 状态字段:正常 或 已删除</p>
|
||||
<p>5. 推荐人ID必须是已存在的用户ID</p>
|
||||
</div>
|
||||
</template>
|
||||
</a-alert>
|
||||
<span>只能上传xls、xlsx文件,</span>
|
||||
<a
|
||||
href="https://cms-api.websoft.top/api/shop/shop-dealer-apply/import/template"
|
||||
download="经销商申请导入模板.xlsx"
|
||||
>
|
||||
下载导入模板
|
||||
</a>
|
||||
</div>
|
||||
</ele-modal>
|
||||
</template>
|
||||
@@ -43,7 +36,7 @@
|
||||
import { ref } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import { CloudUploadOutlined } from '@ant-design/icons-vue';
|
||||
import { importShopDealerUsers } from '@/api/shop/shopDealerUser';
|
||||
import { importShopDealerApplies } from '@/api/shop/shopDealerApply';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
@@ -74,7 +67,7 @@
|
||||
return false;
|
||||
}
|
||||
loading.value = true;
|
||||
importShopDealerUsers(file)
|
||||
importShopDealerApplies(file)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
@@ -93,14 +86,3 @@
|
||||
emit('update:visible', value);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.import-tips {
|
||||
:deep(.ant-alert-description) {
|
||||
p {
|
||||
margin: 4px 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,298 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="600"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '编辑企业' : '新增企业'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="{ span: 4 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<a-form-item label="企业名称" name="dealerName">
|
||||
<a-input placeholder="请输入企业名称" v-model:value="form.dealerName" />
|
||||
</a-form-item>
|
||||
<a-form-item label="入市状态" name="applyStatus">
|
||||
<a-select
|
||||
v-model:value="form.applyStatus"
|
||||
placeholder="请选择入市状态"
|
||||
@change="handleStatusChange"
|
||||
>
|
||||
<a-select-option :value="10">
|
||||
<a-tag>未入市</a-tag>
|
||||
<span style="margin-left: 8px">未入市</span>
|
||||
</a-select-option>
|
||||
<a-select-option :value="20">
|
||||
<a-tag color="success">已入市</a-tag>
|
||||
<span style="margin-left: 8px">已入市</span>
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
import {
|
||||
addShopDealerApply,
|
||||
updateShopDealerApply
|
||||
} from '@/api/shop/shopDealerApply';
|
||||
import { ShopDealerApply } from '@/api/shop/shopDealerApply/model';
|
||||
import { FormInstance } from 'ant-design-vue/es/form';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: ShopDealerApply | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
// 表格选中数据
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
// 表单数据
|
||||
const form = reactive<ShopDealerApply>({
|
||||
applyId: undefined,
|
||||
type: 3,
|
||||
userId: undefined,
|
||||
dealerName: '',
|
||||
realName: '',
|
||||
mobile: '',
|
||||
refereeId: undefined,
|
||||
applyType: 10,
|
||||
applyTime: undefined,
|
||||
applyStatus: 10,
|
||||
auditTime: undefined,
|
||||
rejectReason: '',
|
||||
tenantId: undefined,
|
||||
createTime: undefined,
|
||||
updateTime: undefined
|
||||
});
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
dealerName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入经销商名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
realName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入企业名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
applyStatus: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择审核状态',
|
||||
trigger: 'change'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const { resetFields } = useForm(form, rules);
|
||||
|
||||
/* 处理审核状态变化 */
|
||||
const handleStatusChange = (value: number) => {
|
||||
// 当状态改为审核通过或驳回时,自动设置审核时间为当前时间
|
||||
if ((value === 20 || value === 30) && !form.auditTime) {
|
||||
form.auditTime = dayjs();
|
||||
}
|
||||
// 当状态改为待审核时,清空审核时间和驳回原因
|
||||
if (value === 10) {
|
||||
form.auditTime = undefined;
|
||||
form.rejectReason = '';
|
||||
}
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 动态验证规则
|
||||
const validateFields: string[] = [
|
||||
'userId',
|
||||
'realName',
|
||||
'mobile',
|
||||
'applyStatus'
|
||||
];
|
||||
|
||||
// 如果是驳回状态,需要验证驳回原因
|
||||
if (form.applyStatus === 30) {
|
||||
validateFields.push('rejectReason');
|
||||
}
|
||||
|
||||
// 如果是审核通过或驳回状态,需要验证审核时间
|
||||
if (form.applyStatus === 20 || form.applyStatus === 30) {
|
||||
validateFields.push('auditTime');
|
||||
}
|
||||
|
||||
formRef.value
|
||||
.validate(validateFields)
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const formData = {
|
||||
...form
|
||||
};
|
||||
|
||||
// 处理时间字段转换 - 转换为ISO字符串格式
|
||||
if (formData.applyTime) {
|
||||
if (dayjs.isDayjs(formData.applyTime)) {
|
||||
formData.applyTime = formData.applyTime.format(
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
);
|
||||
} else if (typeof formData.applyTime === 'number') {
|
||||
formData.applyTime = dayjs(formData.applyTime).format(
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (formData.auditTime) {
|
||||
if (dayjs.isDayjs(formData.auditTime)) {
|
||||
formData.auditTime = formData.auditTime.format(
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
);
|
||||
} else if (typeof formData.auditTime === 'number') {
|
||||
formData.auditTime = dayjs(formData.auditTime).format(
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 当审核状态为通过或驳回时,确保有审核时间
|
||||
if (
|
||||
(formData.applyStatus === 20 || formData.applyStatus === 30) &&
|
||||
!formData.auditTime
|
||||
) {
|
||||
formData.auditTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
||||
}
|
||||
|
||||
// 当状态为待审核时,清空审核时间
|
||||
if (formData.applyStatus === 10) {
|
||||
formData.auditTime = undefined;
|
||||
}
|
||||
|
||||
const saveOrUpdate = isUpdate.value
|
||||
? updateShopDealerApply
|
||||
: addShopDealerApply;
|
||||
saveOrUpdate(formData)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
assignObject(form, props.data);
|
||||
// 处理时间字段 - 确保转换为dayjs对象
|
||||
if (props.data.applyTime) {
|
||||
form.applyTime = dayjs(props.data.applyTime);
|
||||
}
|
||||
if (props.data.auditTime) {
|
||||
form.auditTime = dayjs(props.data.auditTime);
|
||||
}
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
// 重置为默认值
|
||||
Object.assign(form, {
|
||||
applyId: undefined,
|
||||
userId: undefined,
|
||||
realName: '',
|
||||
mobile: '',
|
||||
refereeId: undefined,
|
||||
applyType: 10,
|
||||
applyTime: dayjs(),
|
||||
applyStatus: 10,
|
||||
auditTime: undefined,
|
||||
rejectReason: '',
|
||||
tenantId: undefined,
|
||||
createTime: undefined,
|
||||
updateTime: undefined
|
||||
});
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
:deep(.ant-divider-horizontal.ant-divider-with-text-left) {
|
||||
margin: 24px 0 16px 0;
|
||||
|
||||
.ant-divider-inner-text {
|
||||
padding: 0 16px 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-form-item) {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
:deep(.ant-radio) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
|
||||
.ant-radio-inner {
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-select-selection-item) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
301
src/views/glt/shopDealerApplyRs/index.vue
Normal file
301
src/views/glt/shopDealerApplyRs/index.vue
Normal file
@@ -0,0 +1,301 @@
|
||||
<template>
|
||||
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="applyId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
class="sys-org-table"
|
||||
:scroll="{ x: 1300 }"
|
||||
:where="defaultWhere"
|
||||
:customRow="customRow"
|
||||
cache-key="proSystemShopDealerApplyTable"
|
||||
>
|
||||
<template #toolbar>
|
||||
<a-space>
|
||||
<a-button type="primary" class="ele-btn-icon" @click="openEdit()">
|
||||
<template #icon>
|
||||
<plus-outlined />
|
||||
</template>
|
||||
<span>添加</span>
|
||||
</a-button>
|
||||
<a-button class="ele-btn-icon" @click="openImport()">
|
||||
<template #icon>
|
||||
<cloud-upload-outlined />
|
||||
</template>
|
||||
<span>导入</span>
|
||||
</a-button>
|
||||
<!-- <a-button class="ele-btn-icon" @click="exportData()" :loading="exportLoading">-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <download-outlined/>-->
|
||||
<!-- </template>-->
|
||||
<!-- <span>导出</span>-->
|
||||
<!-- </a-button>-->
|
||||
<a-input-search
|
||||
allow-clear
|
||||
v-model:value="searchText"
|
||||
placeholder="请输入关键词"
|
||||
@search="reload"
|
||||
@pressEnter="reload"
|
||||
/>
|
||||
</a-space>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'applyStatus'">
|
||||
<span class="text-green-500" v-if="record.applyStatus == 20"
|
||||
>已入市</span
|
||||
>
|
||||
<span class="text-gray-300" v-else>未入市</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<div>
|
||||
<a @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
placement="topRight"
|
||||
title="确定要删除此用户吗?"
|
||||
@confirm="remove(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
<!-- 编辑弹窗 -->
|
||||
<ShopDealerApplyEdit
|
||||
v-model:visible="showEdit"
|
||||
:data="current"
|
||||
:organization-list="data"
|
||||
@done="reload"
|
||||
/>
|
||||
<!-- 导入弹窗 -->
|
||||
<ShopDealerApplyImport v-model:visible="showImport" @done="reload" />
|
||||
</a-page-header>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import { PlusOutlined, CloudUploadOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro/es';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { messageLoading } from 'ele-admin-pro/es';
|
||||
import ShopDealerApplyEdit from './components/shopDealerApplyEdit.vue';
|
||||
import ShopDealerApplyImport from './components/shop-dealer-apply-import.vue';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import { utils, writeFile } from 'xlsx';
|
||||
import dayjs from 'dayjs';
|
||||
import { Organization } from '@/api/system/organization/model';
|
||||
import { getPageTitle } from '@/utils/common';
|
||||
import router from '@/router';
|
||||
import {
|
||||
listShopDealerApply,
|
||||
pageShopDealerApply,
|
||||
removeShopDealerApply
|
||||
} from '@/api/shop/shopDealerApply';
|
||||
import {
|
||||
ShopDealerApply,
|
||||
ShopDealerApplyParam
|
||||
} from '@/api/shop/shopDealerApply/model';
|
||||
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
// 树形数据
|
||||
const data = ref<Organization[]>([]);
|
||||
// 树展开的key
|
||||
const expandedRowKeys = ref<number[]>([]);
|
||||
// 树选中的key
|
||||
const selectedRowKeys = ref<number[]>([]);
|
||||
// 表格选中数据
|
||||
const selection = ref<ShopDealerApply[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<ShopDealerApply | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 是否显示用户导入弹窗
|
||||
const showImport = ref(false);
|
||||
// 导出加载状态
|
||||
const exportLoading = ref(false);
|
||||
const searchText = ref('');
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
// {
|
||||
// title: 'ID',
|
||||
// dataIndex: 'userId',
|
||||
// width: 90,
|
||||
// showSorterTooltip: false
|
||||
// },
|
||||
{
|
||||
title: '企业名称',
|
||||
dataIndex: 'dealerName',
|
||||
align: 'dealerName',
|
||||
showSorterTooltip: false
|
||||
},
|
||||
{
|
||||
title: '入市情况',
|
||||
dataIndex: 'applyStatus',
|
||||
key: 'applyStatus',
|
||||
align: 'center',
|
||||
sorter: true
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
sorter: true,
|
||||
align: 'center',
|
||||
showSorterTooltip: false,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd HH:mm:ss')
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
align: 'center'
|
||||
}
|
||||
]);
|
||||
|
||||
// 默认搜索条件
|
||||
const defaultWhere = reactive({
|
||||
username: '',
|
||||
nickname: ''
|
||||
});
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
|
||||
where = {};
|
||||
where.keywords = searchText.value;
|
||||
where.type = 3;
|
||||
return pageShopDealerApply({ page, limit, ...where, ...orders });
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: ShopDealerApplyParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where });
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: ShopDealerApply) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
/* 打开编辑弹窗 */
|
||||
const openImport = () => {
|
||||
showImport.value = true;
|
||||
};
|
||||
|
||||
/* 导出数据 */
|
||||
const exportData = async () => {
|
||||
exportLoading.value = true;
|
||||
|
||||
try {
|
||||
// 定义表头
|
||||
const array: (string | number)[][] = [
|
||||
['ID', '企业名称', '联系方式', '入市状态', '创建时间']
|
||||
];
|
||||
|
||||
// 构建查询参数,使用当前搜索条件
|
||||
const params = {
|
||||
keywords: searchText.value,
|
||||
isAdmin: 0
|
||||
};
|
||||
|
||||
// 获取用户列表数据
|
||||
const list = await listShopDealerApply(params);
|
||||
|
||||
if (!list || list.length === 0) {
|
||||
message.warning('没有数据可以导出');
|
||||
exportLoading.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// 将数据转换为Excel行
|
||||
list.forEach((user: ShopDealerApply) => {
|
||||
array.push([
|
||||
`${user.applyId || ''}`,
|
||||
`${user.realName || ''}`,
|
||||
`${user.mobile || ''}`,
|
||||
`${user.applyStatus === 20 ? '通过' : '未通过'}`,
|
||||
`${user.createTime || ''}`
|
||||
]);
|
||||
});
|
||||
|
||||
// 生成Excel文件
|
||||
const sheetName = `导出企业入市${dayjs(new Date()).format('YYYYMMDD')}`;
|
||||
const workbook = {
|
||||
SheetNames: [sheetName],
|
||||
Sheets: {}
|
||||
};
|
||||
const sheet = utils.aoa_to_sheet(array);
|
||||
workbook.Sheets[sheetName] = sheet;
|
||||
|
||||
// 设置列宽
|
||||
sheet['!cols'] = [];
|
||||
|
||||
message.loading('正在生成Excel文件...', 0);
|
||||
|
||||
setTimeout(() => {
|
||||
writeFile(workbook, `${sheetName}.xlsx`);
|
||||
exportLoading.value = false;
|
||||
message.destroy();
|
||||
message.success(`成功导出 ${list.length} 条记录`);
|
||||
}, 1000);
|
||||
} catch (error: any) {
|
||||
exportLoading.value = false;
|
||||
message.error(error.message || '导出失败');
|
||||
}
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: ShopDealerApply) => {
|
||||
const hide = messageLoading('请求中..', 0);
|
||||
removeShopDealerApply(row.applyId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: ShopDealerApply) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
watch(
|
||||
() => router.currentRoute.value.query,
|
||||
() => {},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'ShopDealerApplyRs'
|
||||
};
|
||||
</script>
|
||||
117
src/views/glt/shopDealerCapital/components/search.vue
Normal file
117
src/views/glt/shopDealerCapital/components/search.vue
Normal file
@@ -0,0 +1,117 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-input-search
|
||||
allow-clear
|
||||
placeholder="用户ID|订单编号"
|
||||
style="width: 240px"
|
||||
v-model:value="where.keywords"
|
||||
@search="reload"
|
||||
/>
|
||||
<a-button type="dashed" @click="handleExport">导出xls</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { utils, writeFile } from 'xlsx';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { pageShopDealerCapital } from '@/api/shop/shopDealerCapital';
|
||||
import {
|
||||
ShopDealerCapital,
|
||||
ShopDealerCapitalParam
|
||||
} from '@/api/shop/shopDealerCapital/model';
|
||||
import { getTenantId } from '@/utils/domain';
|
||||
import useSearch from '@/utils/use-search';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: ShopDealerCapitalParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
(e: 'batchMove'): void;
|
||||
}>();
|
||||
|
||||
const reload = () => {
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const { where } = useSearch<ShopDealerCapitalParam>({
|
||||
keywords: '',
|
||||
userId: undefined,
|
||||
toUserId: undefined,
|
||||
limit: 5000
|
||||
});
|
||||
|
||||
const list = ref<ShopDealerCapital[]>([]);
|
||||
|
||||
// 导出
|
||||
const handleExport = async () => {
|
||||
const array: (string | number)[][] = [
|
||||
[
|
||||
'用户ID',
|
||||
'流动类型',
|
||||
'金额',
|
||||
'订单编号',
|
||||
'对方用户ID',
|
||||
`创建时间`,
|
||||
'租户ID'
|
||||
]
|
||||
];
|
||||
|
||||
// 按搜索结果导出
|
||||
await pageShopDealerCapital(where)
|
||||
.then((data) => {
|
||||
list.value = data?.list || [];
|
||||
list.value?.forEach((d: ShopDealerCapital) => {
|
||||
array.push([
|
||||
`${d.userId}`,
|
||||
`${d.flowType == 10 ? '佣金收入' : ''}`,
|
||||
`${d.money}`,
|
||||
`${d.orderNo}`,
|
||||
`${d.toUserId}`,
|
||||
`${d.createTime}`,
|
||||
`${d.tenantId}`
|
||||
]);
|
||||
});
|
||||
const sheetName = `bak_shop_dealer_capital_${getTenantId()}`;
|
||||
const workbook = {
|
||||
SheetNames: [sheetName],
|
||||
Sheets: {}
|
||||
};
|
||||
const sheet = utils.aoa_to_sheet(array);
|
||||
workbook.Sheets[sheetName] = sheet;
|
||||
// 设置列宽
|
||||
sheet['!cols'] = [
|
||||
{ wch: 10 },
|
||||
{ wch: 20 },
|
||||
{ wch: 20 },
|
||||
{ wch: 15 },
|
||||
{ wch: 10 },
|
||||
{ wch: 10 },
|
||||
{ wch: 20 }
|
||||
];
|
||||
message.loading('正在导出...');
|
||||
setTimeout(() => {
|
||||
writeFile(workbook, `${sheetName}.xlsx`);
|
||||
}, 1000);
|
||||
})
|
||||
.catch((msg) => {
|
||||
message.error(msg);
|
||||
})
|
||||
.finally(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
@@ -0,0 +1,406 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="900"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '编辑资金流动记录' : '新增资金流动记录'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<!-- 基本信息 -->
|
||||
<a-divider orientation="left">
|
||||
<span style="color: #1890ff; font-weight: 600">基本信息</span>
|
||||
</a-divider>
|
||||
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="分销商用户ID" name="userId">
|
||||
<a-input-number
|
||||
:min="1"
|
||||
placeholder="请输入分销商用户ID"
|
||||
v-model:value="form.userId"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="订单ID" name="orderId">
|
||||
<a-input-number
|
||||
:min="1"
|
||||
placeholder="请输入订单ID(可选)"
|
||||
v-model:value="form.orderId"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<!-- 资金流动信息 -->
|
||||
<a-divider orientation="left">
|
||||
<span style="color: #1890ff; font-weight: 600">资金流动信息</span>
|
||||
</a-divider>
|
||||
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="流动类型" name="flowType">
|
||||
<a-select
|
||||
v-model:value="form.flowType"
|
||||
placeholder="请选择资金流动类型"
|
||||
>
|
||||
<a-select-option :value="10">
|
||||
<div class="flow-type-option">
|
||||
<a-tag color="success">佣金收入</a-tag>
|
||||
<span>获得分销佣金</span>
|
||||
</div>
|
||||
</a-select-option>
|
||||
<a-select-option :value="20">
|
||||
<div class="flow-type-option">
|
||||
<a-tag color="warning">提现支出</a-tag>
|
||||
<span>申请提现</span>
|
||||
</div>
|
||||
</a-select-option>
|
||||
<a-select-option :value="30">
|
||||
<div class="flow-type-option">
|
||||
<a-tag color="error">转账支出</a-tag>
|
||||
<span>转账给他人</span>
|
||||
</div>
|
||||
</a-select-option>
|
||||
<a-select-option :value="40">
|
||||
<div class="flow-type-option">
|
||||
<a-tag color="processing">转账收入</a-tag>
|
||||
<span>收到转账</span>
|
||||
</div>
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="金额" name="money">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
placeholder="请输入金额"
|
||||
v-model:value="form.money"
|
||||
style="width: 100%"
|
||||
>
|
||||
<template #addonAfter>元</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<a-form-item label="流动描述" name="comments">
|
||||
<a-textarea
|
||||
v-model:value="form.comments"
|
||||
placeholder="请输入资金流动描述"
|
||||
:rows="3"
|
||||
:maxlength="200"
|
||||
show-count
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<!-- 关联信息 -->
|
||||
<a-divider orientation="left">
|
||||
<span style="color: #1890ff; font-weight: 600">关联信息</span>
|
||||
</a-divider>
|
||||
|
||||
<a-form-item
|
||||
label="对方用户ID"
|
||||
name="toUserId"
|
||||
v-if="form.flowType === 30 || form.flowType === 40"
|
||||
>
|
||||
<a-input-number
|
||||
:min="1"
|
||||
placeholder="请输入对方用户ID"
|
||||
v-model:value="form.toUserId"
|
||||
style="width: 300px"
|
||||
/>
|
||||
<span style="margin-left: 12px; color: #999; font-size: 12px">
|
||||
转账相关操作需要填写对方用户ID
|
||||
</span>
|
||||
</a-form-item>
|
||||
|
||||
<!-- 金额预览 -->
|
||||
<div class="amount-preview" v-if="form.money && form.flowType">
|
||||
<a-alert
|
||||
:type="getAmountAlertType()"
|
||||
:message="getAmountPreviewText()"
|
||||
show-icon
|
||||
style="margin-top: 16px"
|
||||
/>
|
||||
</div>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject, uuid } from 'ele-admin-pro';
|
||||
import {
|
||||
addShopDealerCapital,
|
||||
updateShopDealerCapital
|
||||
} from '@/api/shop/shopDealerCapital';
|
||||
import { ShopDealerCapital } from '@/api/shop/shopDealerCapital/model';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { FormInstance } from 'ant-design-vue/es/form';
|
||||
import { FileRecord } from '@/api/system/file/model';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: ShopDealerCapital | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
// 表格选中数据
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
const images = ref<ItemType[]>([]);
|
||||
|
||||
// 表单数据
|
||||
const form = reactive<ShopDealerCapital>({
|
||||
id: undefined,
|
||||
userId: undefined,
|
||||
orderId: undefined,
|
||||
flowType: undefined,
|
||||
money: undefined,
|
||||
comments: '',
|
||||
toUserId: undefined,
|
||||
tenantId: undefined,
|
||||
createTime: undefined,
|
||||
updateTime: undefined
|
||||
});
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
userId: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入分销商用户ID',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
flowType: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择资金流动类型',
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
money: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入金额',
|
||||
trigger: 'blur'
|
||||
},
|
||||
{
|
||||
validator: (rule: any, value: any) => {
|
||||
if (value && value <= 0) {
|
||||
return Promise.reject('金额必须大于0');
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
comments: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入流动描述',
|
||||
trigger: 'blur'
|
||||
},
|
||||
{
|
||||
min: 2,
|
||||
max: 200,
|
||||
message: '描述长度应在2-200个字符之间',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
toUserId: [
|
||||
{
|
||||
validator: (rule: any, value: any) => {
|
||||
if ((form.flowType === 30 || form.flowType === 40) && !value) {
|
||||
return Promise.reject('转账操作必须填写对方用户ID');
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
/* 获取金额预览提示类型 */
|
||||
const getAmountAlertType = () => {
|
||||
if (!form.flowType) return 'info';
|
||||
|
||||
switch (form.flowType) {
|
||||
case 10: // 佣金收入
|
||||
case 40: // 转账收入
|
||||
return 'success';
|
||||
case 20: // 提现支出
|
||||
case 30: // 转账支出
|
||||
return 'warning';
|
||||
default:
|
||||
return 'info';
|
||||
}
|
||||
};
|
||||
|
||||
/* 获取金额预览文本 */
|
||||
const getAmountPreviewText = () => {
|
||||
if (!form.money || !form.flowType) return '';
|
||||
|
||||
const amount = parseFloat(form.money.toString()).toFixed(2);
|
||||
const flowTypeMap = {
|
||||
10: '佣金收入',
|
||||
20: '提现支出',
|
||||
30: '转账支出',
|
||||
40: '转账收入'
|
||||
};
|
||||
|
||||
const flowTypeName = flowTypeMap[form.flowType] || '未知类型';
|
||||
const symbol = form.flowType === 10 || form.flowType === 40 ? '+' : '-';
|
||||
|
||||
return `${flowTypeName}:${symbol}¥${amount}`;
|
||||
};
|
||||
|
||||
const { resetFields } = useForm(form, rules);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const formData = {
|
||||
...form
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value
|
||||
? updateShopDealerCapital
|
||||
: addShopDealerCapital;
|
||||
saveOrUpdate(formData)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
assignObject(form, props.data);
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
// 重置为默认值
|
||||
Object.assign(form, {
|
||||
id: undefined,
|
||||
userId: undefined,
|
||||
orderId: undefined,
|
||||
flowType: undefined,
|
||||
money: undefined,
|
||||
comments: '',
|
||||
toUserId: undefined,
|
||||
tenantId: undefined,
|
||||
createTime: undefined,
|
||||
updateTime: undefined
|
||||
});
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.flow-type-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.ant-tag {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
span {
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.amount-preview {
|
||||
:deep(.ant-alert) {
|
||||
.ant-alert-message {
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-divider-horizontal.ant-divider-with-text-left) {
|
||||
margin: 24px 0 16px 0;
|
||||
|
||||
.ant-divider-inner-text {
|
||||
padding: 0 16px 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-form-item) {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
:deep(.ant-select-selection-item) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
:deep(.ant-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
295
src/views/glt/shopDealerCapital/index.vue
Normal file
295
src/views/glt/shopDealerCapital/index.vue
Normal file
@@ -0,0 +1,295 @@
|
||||
<template>
|
||||
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
|
||||
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="id"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:customRow="customRow"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-org-table"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
@batchMove="openMove"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'image'">
|
||||
<a-image :src="record.image" :width="50" />
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
|
||||
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
title="确定要删除此记录吗?"
|
||||
@confirm="remove(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<ShopDealerCapitalEdit
|
||||
v-model:visible="showEdit"
|
||||
:data="current"
|
||||
@done="reload"
|
||||
/>
|
||||
</a-page-header>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import Search from './components/search.vue';
|
||||
import { getPageTitle } from '@/utils/common';
|
||||
import ShopDealerCapitalEdit from './components/shopDealerCapitalEdit.vue';
|
||||
import {
|
||||
pageShopDealerCapital,
|
||||
removeShopDealerCapital,
|
||||
removeBatchShopDealerCapital
|
||||
} from '@/api/shop/shopDealerCapital';
|
||||
import type {
|
||||
ShopDealerCapital,
|
||||
ShopDealerCapitalParam
|
||||
} from '@/api/shop/shopDealerCapital/model';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<ShopDealerCapital[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<ShopDealerCapital | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 是否显示批量移动弹窗
|
||||
const showMove = ref(false);
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.status = filters.status;
|
||||
}
|
||||
return pageShopDealerCapital({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id',
|
||||
key: 'id',
|
||||
align: 'center',
|
||||
width: 80,
|
||||
fixed: 'left'
|
||||
},
|
||||
{
|
||||
title: '用户ID',
|
||||
dataIndex: 'userId',
|
||||
key: 'userId',
|
||||
align: 'center',
|
||||
fixed: 'left'
|
||||
},
|
||||
{
|
||||
title: '流动类型',
|
||||
dataIndex: 'flowType',
|
||||
key: 'flowType',
|
||||
align: 'center',
|
||||
customRender: ({ text }) => {
|
||||
const typeMap = {
|
||||
10: { text: '佣金收入', color: 'success' },
|
||||
20: { text: '提现支出', color: 'warning' },
|
||||
30: { text: '转账支出', color: 'error' },
|
||||
40: { text: '转账收入', color: 'processing' },
|
||||
50: { text: '新人注册奖', color: 'processing' }
|
||||
};
|
||||
const type = typeMap[text] || { text: '未知', color: 'default' };
|
||||
return {
|
||||
type: 'tag',
|
||||
props: { color: type.color },
|
||||
children: type.text
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '金额',
|
||||
dataIndex: 'money',
|
||||
key: 'money',
|
||||
align: 'center',
|
||||
customRender: ({ text, record }) => {
|
||||
const amount = parseFloat(text || '0').toFixed(2);
|
||||
const isIncome =
|
||||
record.flowType === 10 ||
|
||||
record.flowType === 40 ||
|
||||
record.flowType === 50;
|
||||
return {
|
||||
type: 'span',
|
||||
props: {
|
||||
style: {
|
||||
color: isIncome ? '#424242' : '#ff4d4f'
|
||||
}
|
||||
},
|
||||
children: `${isIncome ? '' : '-'} ${amount}`
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '关联订单',
|
||||
dataIndex: 'orderNo',
|
||||
key: 'orderNo',
|
||||
align: 'center',
|
||||
customRender: ({ text }) => text || '-'
|
||||
},
|
||||
{
|
||||
title: '对方用户',
|
||||
dataIndex: 'toUserId',
|
||||
key: 'toUserId',
|
||||
align: 'center',
|
||||
customRender: ({ text }) => (text ? `ID: ${text}` : '-')
|
||||
},
|
||||
{
|
||||
title: '描述',
|
||||
dataIndex: 'describe',
|
||||
key: 'describe',
|
||||
align: 'left',
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => text || '-'
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
align: 'center',
|
||||
sorter: true
|
||||
}
|
||||
// {
|
||||
// title: '操作',
|
||||
// key: 'action',
|
||||
// width: 180,
|
||||
// fixed: 'right',
|
||||
// align: 'center',
|
||||
// hideInSetting: true
|
||||
// }
|
||||
]);
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: ShopDealerCapitalParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: ShopDealerCapital) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开批量移动弹窗 */
|
||||
const openMove = () => {
|
||||
showMove.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: ShopDealerCapital) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeShopDealerCapital(row.id)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchShopDealerCapital(selection.value.map((d) => d.id))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 查询 */
|
||||
const query = () => {
|
||||
loading.value = true;
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: ShopDealerCapital) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
query();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'ShopDealerCapital'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
89
src/views/glt/shopDealerOrder/components/Import.vue
Normal file
89
src/views/glt/shopDealerOrder/components/Import.vue
Normal file
@@ -0,0 +1,89 @@
|
||||
<!-- 经销商订单导入弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="520"
|
||||
:footer="null"
|
||||
title="导入分销订单"
|
||||
:visible="visible"
|
||||
@update:visible="updateVisible"
|
||||
>
|
||||
<a-spin :spinning="loading">
|
||||
<a-upload-dragger
|
||||
accept=".xls,.xlsx"
|
||||
:show-upload-list="false"
|
||||
:customRequest="doUpload"
|
||||
style="padding: 24px 0; margin-bottom: 16px"
|
||||
>
|
||||
<p class="ant-upload-drag-icon">
|
||||
<cloud-upload-outlined />
|
||||
</p>
|
||||
<p class="ant-upload-hint">将文件拖到此处,或点击上传</p>
|
||||
</a-upload-dragger>
|
||||
<div class="ant-upload-text text-gray-400">
|
||||
<div
|
||||
>1、必须按<a
|
||||
href="https://oss.wsdns.cn/20251018/408b805ec3cd4084a4dc686e130af578.xlsx"
|
||||
target="_blank"
|
||||
>导入模版</a
|
||||
>的格式上传</div
|
||||
>
|
||||
<div>2、导入成功确认结算完成佣金的发放</div>
|
||||
</div>
|
||||
</a-spin>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import { CloudUploadOutlined } from '@ant-design/icons-vue';
|
||||
import { importSdyDealerOrder } from '@/api/sdy/sdyDealerOrder';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
defineProps<{
|
||||
// 是否打开弹窗
|
||||
visible: boolean;
|
||||
}>();
|
||||
|
||||
// 导入请求状态
|
||||
const loading = ref(false);
|
||||
|
||||
/* 上传 */
|
||||
const doUpload = ({ file }) => {
|
||||
if (
|
||||
![
|
||||
'application/vnd.ms-excel',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
].includes(file.type)
|
||||
) {
|
||||
message.error('只能选择 excel 文件');
|
||||
return false;
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 10) {
|
||||
message.error('大小不能超过 10MB');
|
||||
return false;
|
||||
}
|
||||
loading.value = true;
|
||||
importSdyDealerOrder(file)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
return false;
|
||||
};
|
||||
|
||||
/* 更新 visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
</script>
|
||||
182
src/views/glt/shopDealerOrder/components/search.vue
Normal file
182
src/views/glt/shopDealerOrder/components/search.vue
Normal file
@@ -0,0 +1,182 @@
|
||||
<template>
|
||||
<div class="flex items-center gap-20">
|
||||
<!-- 搜索表单 -->
|
||||
<a-form
|
||||
:model="where"
|
||||
layout="inline"
|
||||
class="search-form"
|
||||
@finish="handleSearch"
|
||||
>
|
||||
<a-form-item>
|
||||
<a-space>
|
||||
<a-button
|
||||
danger
|
||||
class="ele-btn-icon"
|
||||
v-if="selection.length > 0"
|
||||
:disabled="selection?.length === 0"
|
||||
@click="removeBatch"
|
||||
>
|
||||
<template #icon>
|
||||
<DeleteOutlined />
|
||||
</template>
|
||||
<span>批量删除</span>
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
|
||||
<!-- <a-form-item label="订单状态">-->
|
||||
<!-- <a-select-->
|
||||
<!-- v-model:value="where.isInvalid"-->
|
||||
<!-- placeholder="全部"-->
|
||||
<!-- allow-clear-->
|
||||
<!-- style="width: 120px"-->
|
||||
<!-- >-->
|
||||
<!-- <a-select-option :value="0">有效</a-select-option>-->
|
||||
<!-- <a-select-option :value="1">失效</a-select-option>-->
|
||||
<!-- </a-select>-->
|
||||
<!-- </a-form-item>-->
|
||||
|
||||
<!-- <a-form-item label="结算状态">-->
|
||||
<!-- <a-select-->
|
||||
<!-- v-model:value="where.isSettled"-->
|
||||
<!-- placeholder="全部"-->
|
||||
<!-- allow-clear-->
|
||||
<!-- style="width: 120px"-->
|
||||
<!-- >-->
|
||||
<!-- <a-select-option :value="0">未结算</a-select-option>-->
|
||||
<!-- <a-select-option :value="1">已结算</a-select-option>-->
|
||||
<!-- </a-select>-->
|
||||
<!-- </a-form-item>-->
|
||||
|
||||
<a-form-item>
|
||||
<a-space>
|
||||
<a-input-search
|
||||
allow-clear
|
||||
placeholder="请输入关键词"
|
||||
style="width: 240px"
|
||||
v-model:value="where.keywords"
|
||||
@search="handleSearch"
|
||||
/>
|
||||
<!-- <a-button type="primary" html-type="submit" class="ele-btn-icon">-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <SearchOutlined/>-->
|
||||
<!-- </template>-->
|
||||
<!-- 搜索-->
|
||||
<!-- </a-button>-->
|
||||
<a-button @click="resetSearch"> 重置 </a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
<a-divider type="vertical" />
|
||||
<a-space>
|
||||
<!-- <a-button @click="exportData" class="ele-btn-icon">-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <ExportOutlined />-->
|
||||
<!-- </template>-->
|
||||
<!-- 导出数据-->
|
||||
<!-- </a-button>-->
|
||||
<a-button @click="openImport" class="ele-btn-icon">
|
||||
<template #icon>
|
||||
<UploadOutlined />
|
||||
</template>
|
||||
导入数据
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
danger
|
||||
@click="batchSettle"
|
||||
:disabled="selection?.length === 0"
|
||||
>
|
||||
<template #icon>
|
||||
<DollarOutlined />
|
||||
</template>
|
||||
批量结算
|
||||
</a-button>
|
||||
</a-space>
|
||||
</div>
|
||||
|
||||
<!-- 导入弹窗 -->
|
||||
<Import v-model:visible="showImport" @done="emit('importDone')" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import {
|
||||
DollarOutlined,
|
||||
UploadOutlined,
|
||||
DeleteOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { ShopDealerOrderParam } from '@/api/shop/shopDealerOrder/model';
|
||||
import Import from './Import.vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
// 选中的数据
|
||||
selection?: any[];
|
||||
}>(),
|
||||
{
|
||||
selection: () => []
|
||||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: ShopDealerOrderParam): void;
|
||||
(e: 'batchSettle'): void;
|
||||
(e: 'export'): void;
|
||||
(e: 'importDone'): void;
|
||||
(e: 'remove'): void;
|
||||
}>();
|
||||
|
||||
// 是否显示导入弹窗
|
||||
const showImport = ref(false);
|
||||
|
||||
// 搜索表单
|
||||
const { where, resetFields } = useSearch<ShopDealerOrderParam>({
|
||||
orderNo: '',
|
||||
productName: '',
|
||||
isInvalid: undefined,
|
||||
isSettled: undefined
|
||||
});
|
||||
|
||||
// 搜索
|
||||
const handleSearch = () => {
|
||||
const searchParams = { ...where };
|
||||
// 清除空值
|
||||
Object.keys(searchParams).forEach((key) => {
|
||||
if (searchParams[key] === '' || searchParams[key] === undefined) {
|
||||
delete searchParams[key];
|
||||
}
|
||||
});
|
||||
emit('search', searchParams);
|
||||
};
|
||||
|
||||
// 重置搜索
|
||||
const resetSearch = () => {
|
||||
// Object.keys(searchForm).forEach(key => {
|
||||
// searchForm[key] = key === 'orderId' ? undefined : '';
|
||||
// });
|
||||
resetFields();
|
||||
emit('search', {});
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
// 批量结算
|
||||
const batchSettle = () => {
|
||||
emit('batchSettle');
|
||||
};
|
||||
|
||||
// 导出数据
|
||||
const exportData = () => {
|
||||
emit('export');
|
||||
};
|
||||
|
||||
// 打开导入弹窗
|
||||
const openImport = () => {
|
||||
showImport.value = true;
|
||||
};
|
||||
</script>
|
||||
363
src/views/glt/shopDealerOrder/components/shopDealerOrderEdit.vue
Normal file
363
src/views/glt/shopDealerOrder/components/shopDealerOrderEdit.vue
Normal file
@@ -0,0 +1,363 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="900"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '分销订单' : '分销订单'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
:okText="`立即结算`"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<!-- 订单基本信息 -->
|
||||
<a-divider orientation="left">
|
||||
<span style="color: #1890ff; font-weight: 600">基本信息</span>
|
||||
</a-divider>
|
||||
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="客户名称" name="title">
|
||||
{{ form.title }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="订单编号" name="orderNo">
|
||||
{{ form.orderNo }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="结算电量" name="orderPrice">
|
||||
{{ parseFloat(form.orderPrice || 0).toFixed(2) }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="换算成度" name="dealerPrice">
|
||||
{{ parseFloat(form.degreePrice || 0).toFixed(2) }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="税率" name="rate">
|
||||
{{ form.rate }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="单价" name="price">
|
||||
{{ form.price }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="结算金额" name="payPrice">
|
||||
{{ parseFloat(form.settledPrice || 0).toFixed(2) }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="实发金额" name="payPrice">
|
||||
{{ parseFloat(form.payPrice || 0).toFixed(2) }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<div class="font-bold text-gray-400 bg-gray-50">开发调试</div>
|
||||
<div class="text-gray-400 bg-gray-50">
|
||||
<div>业务员({{ form.userId }}):{{ form.nickname }}</div>
|
||||
<div
|
||||
>一级分销商({{ form.firstUserId }}):{{
|
||||
form.firstNickname
|
||||
}},一级佣金30%:{{ form.firstMoney }}</div
|
||||
>
|
||||
<div
|
||||
>二级分销商({{ form.secondUserId }}):{{
|
||||
form.secondNickname
|
||||
}},二级佣金10%:{{ form.secondMoney }}</div
|
||||
>
|
||||
<div
|
||||
>三级分销商({{ form.thirdUserId }}):{{
|
||||
form.thirdNickname
|
||||
}},三级佣金60%:{{ form.thirdMoney }}</div
|
||||
>
|
||||
</div>
|
||||
<!-- 分销商信息 -->
|
||||
<a-divider orientation="left">
|
||||
<span style="color: #1890ff; font-weight: 600">收益计算</span>
|
||||
</a-divider>
|
||||
|
||||
<!-- 一级分销商 -->
|
||||
<div class="dealer-section">
|
||||
<h4 class="dealer-title">
|
||||
<a-tag color="orange">一级佣金30%</a-tag>
|
||||
</h4>
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="用户ID" name="firstUserId">
|
||||
{{ form.firstUserId }}
|
||||
</a-form-item>
|
||||
<a-form-item label="昵称" name="firstNickname">
|
||||
{{ form.firstNickname }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="占比" name="rate">
|
||||
{{ '30%' }}
|
||||
</a-form-item>
|
||||
<a-form-item label="获取收益" name="firstMoney">
|
||||
{{ form.firstMoney }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
|
||||
<!-- 二级分销商 -->
|
||||
<div class="dealer-section">
|
||||
<h4 class="dealer-title">
|
||||
<a-tag color="orange">二级佣金10%</a-tag>
|
||||
</h4>
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="用户ID" name="secondUserId">
|
||||
{{ form.secondUserId }}
|
||||
</a-form-item>
|
||||
<a-form-item label="昵称" name="nickname">
|
||||
{{ form.secondNickname }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="占比" name="rate"> 10% </a-form-item>
|
||||
<a-form-item label="获取收益" name="firstMoney">
|
||||
{{ form.secondMoney }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
|
||||
<!-- 三级分销商 -->
|
||||
<div class="dealer-section" v-if="form.thirdUserId > 0">
|
||||
<h4 class="dealer-title">
|
||||
<a-tag color="orange">三级佣金60%</a-tag>
|
||||
</h4>
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="用户ID" name="thirdUserId">
|
||||
{{ form.thirdUserId }}
|
||||
</a-form-item>
|
||||
<a-form-item label="昵称" name="thirdNickname">
|
||||
{{ form.thirdNickname }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="占比" name="rate">
|
||||
{{ '60%' }}
|
||||
</a-form-item>
|
||||
<a-form-item label="获取收益" name="thirdMoney">
|
||||
{{ form.thirdMoney }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
|
||||
<a-form-item
|
||||
label="结算时间"
|
||||
name="settleTime"
|
||||
v-if="form.isSettled === 1"
|
||||
>
|
||||
{{ form.settleTime }}
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
import { ShopDealerOrder } from '@/api/shop/shopDealerOrder/model';
|
||||
import { FormInstance } from 'ant-design-vue/es/form';
|
||||
import { updateSdyDealerOrder } from '@/api/sdy/sdyDealerOrder';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: ShopDealerOrder | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
// 表格选中数据
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
// 表单数据
|
||||
const form = reactive<ShopDealerOrder>({
|
||||
id: undefined,
|
||||
userId: undefined,
|
||||
nickname: undefined,
|
||||
orderNo: undefined,
|
||||
title: undefined,
|
||||
orderPrice: undefined,
|
||||
settledPrice: undefined,
|
||||
degreePrice: undefined,
|
||||
price: undefined,
|
||||
month: undefined,
|
||||
payPrice: undefined,
|
||||
firstUserId: undefined,
|
||||
secondUserId: undefined,
|
||||
thirdUserId: undefined,
|
||||
firstMoney: undefined,
|
||||
secondMoney: undefined,
|
||||
thirdMoney: undefined,
|
||||
firstNickname: undefined,
|
||||
secondNickname: undefined,
|
||||
thirdNickname: undefined,
|
||||
rate: undefined,
|
||||
comments: undefined,
|
||||
isInvalid: 0,
|
||||
isSettled: 0,
|
||||
settleTime: undefined,
|
||||
tenantId: undefined,
|
||||
createTime: undefined,
|
||||
updateTime: undefined
|
||||
});
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
userId: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择用户ID',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const { resetFields } = useForm(form, rules);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
if (form.isSettled == 1) {
|
||||
message.error('请勿重复结算');
|
||||
return;
|
||||
}
|
||||
if (form.userId == 0) {
|
||||
message.error('未签约');
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const formData = {
|
||||
...form,
|
||||
isSettled: 1
|
||||
};
|
||||
updateSdyDealerOrder(formData)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
console.log(localStorage.getItem(''));
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
assignObject(form, props.data);
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
// 重置为默认值
|
||||
Object.assign(form, {
|
||||
id: undefined,
|
||||
userId: undefined,
|
||||
orderNo: undefined,
|
||||
orderPrice: undefined,
|
||||
firstUserId: undefined,
|
||||
secondUserId: undefined,
|
||||
thirdUserId: undefined,
|
||||
firstMoney: undefined,
|
||||
secondMoney: undefined,
|
||||
thirdMoney: undefined,
|
||||
isInvalid: 0,
|
||||
isSettled: 0,
|
||||
settleTime: undefined
|
||||
});
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.dealer-section {
|
||||
margin-bottom: 24px;
|
||||
padding: 16px;
|
||||
background: #fafafa;
|
||||
border-radius: 6px;
|
||||
border-left: 3px solid #1890ff;
|
||||
|
||||
.dealer-title {
|
||||
margin: 0 0 16px 0;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
|
||||
.ant-tag {
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-divider-horizontal.ant-divider-with-text-left) {
|
||||
margin: 24px 0 16px 0;
|
||||
|
||||
.ant-divider-inner-text {
|
||||
padding: 0 16px 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-form-item) {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
:deep(.ant-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
448
src/views/glt/shopDealerOrder/index.vue
Normal file
448
src/views/glt/shopDealerOrder/index.vue
Normal file
@@ -0,0 +1,448 @@
|
||||
<template>
|
||||
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
|
||||
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="id"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:customRow="customRow"
|
||||
v-model:selection="selection"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-org-table"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@batchSettle="batchSettle"
|
||||
@export="handleExport"
|
||||
@remove="removeBatch"
|
||||
@importDone="reload"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'title'">
|
||||
<div>{{ record.title }}</div>
|
||||
<div class="text-gray-400">用户ID:{{ record.userId }}</div>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'orderPrice'">
|
||||
{{ record.orderPrice.toFixed(2) }}
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'degreePrice'">
|
||||
{{ record.degreePrice.toFixed(2) }}
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'price'">
|
||||
{{ record.price }}
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'settledPrice'">
|
||||
{{ record.settledPrice.toFixed(2) }}
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'payPrice'">
|
||||
{{ record.payPrice.toFixed(2) }}
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'dealerInfo'">
|
||||
<div class="dealer-info">
|
||||
<div v-if="record.firstUserId" class="dealer-level">
|
||||
<a-tag color="red">一级</a-tag>
|
||||
用户{{ record.firstUserId }} - ¥{{
|
||||
parseFloat(record.firstMoney || '0').toFixed(2)
|
||||
}}
|
||||
</div>
|
||||
<div v-if="record.secondUserId" class="dealer-level">
|
||||
<a-tag color="orange">二级</a-tag>
|
||||
用户{{ record.secondUserId }} - ¥{{
|
||||
parseFloat(record.secondMoney || '0').toFixed(2)
|
||||
}}
|
||||
</div>
|
||||
<div v-if="record.thirdUserId" class="dealer-level">
|
||||
<a-tag color="gold">三级</a-tag>
|
||||
用户{{ record.thirdUserId }} - ¥{{
|
||||
parseFloat(record.thirdMoney || '0').toFixed(2)
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'isInvalid'">
|
||||
<a-tag v-if="record.isInvalid === 0" color="success">已签约</a-tag>
|
||||
<a-tag v-if="record.isInvalid === 1" color="error">未签约</a-tag>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'isSettled'">
|
||||
<a-tag v-if="record.isSettled === 0" color="orange">未结算</a-tag>
|
||||
<a-tag v-if="record.isSettled === 1" color="success">已结算</a-tag>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'createTime'">
|
||||
<div class="flex flex-col">
|
||||
<a-tooltip title="创建时间">
|
||||
<span class="text-gray-500">{{ record.createTime }}</span>
|
||||
</a-tooltip>
|
||||
<a-tooltip title="结算时间">
|
||||
<span class="text-purple-500">{{ record.settleTime }}</span>
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'action'">
|
||||
<template v-if="record.isSettled === 0 && record.isInvalid === 0">
|
||||
<a @click="openEdit(record)" class="ele-text-success"> 结算 </a>
|
||||
<a-divider type="vertical" />
|
||||
</template>
|
||||
<a-popconfirm
|
||||
v-if="record.isSettled === 0"
|
||||
title="确定要删除吗?"
|
||||
@confirm="remove(record)"
|
||||
placement="topRight"
|
||||
>
|
||||
<a class="text-red-500"> 删除 </a>
|
||||
</a-popconfirm>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<ShopDealerOrderEdit
|
||||
v-model:visible="showEdit"
|
||||
:data="current"
|
||||
@done="reload"
|
||||
/>
|
||||
</a-page-header>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import Search from './components/search.vue';
|
||||
import { getPageTitle } from '@/utils/common';
|
||||
import ShopDealerOrderEdit from './components/shopDealerOrderEdit.vue';
|
||||
import {
|
||||
pageShopDealerOrder,
|
||||
removeShopDealerOrder,
|
||||
removeBatchShopDealerOrder
|
||||
} from '@/api/shop/shopDealerOrder';
|
||||
import type {
|
||||
ShopDealerOrder,
|
||||
ShopDealerOrderParam
|
||||
} from '@/api/shop/shopDealerOrder/model';
|
||||
import { exportSdyDealerOrder } from '@/api/sdy/sdyDealerOrder';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<ShopDealerOrder[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<ShopDealerOrder | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
|
||||
// 当前搜索条件
|
||||
const currentWhere = ref<ShopDealerOrderParam>({});
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.status = filters.status;
|
||||
}
|
||||
// 保存当前搜索条件用于导出
|
||||
currentWhere.value = { ...where };
|
||||
// 未结算订单
|
||||
where.isSettled = 0;
|
||||
where.myOrder = 1;
|
||||
return pageShopDealerOrder({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: '订单编号',
|
||||
dataIndex: 'orderNo',
|
||||
key: 'orderNo'
|
||||
},
|
||||
{
|
||||
title: '客户名称',
|
||||
dataIndex: 'title',
|
||||
key: 'title',
|
||||
width: 220
|
||||
},
|
||||
{
|
||||
title: '结算电量',
|
||||
dataIndex: 'orderPrice',
|
||||
key: 'orderPrice',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '换算成度',
|
||||
dataIndex: 'degreePrice',
|
||||
key: 'degreePrice',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '结算单价',
|
||||
dataIndex: 'price',
|
||||
key: 'price',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '结算金额',
|
||||
dataIndex: 'settledPrice',
|
||||
key: 'settledPrice',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '税费',
|
||||
dataIndex: 'rate',
|
||||
key: 'rate',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '实发金额',
|
||||
dataIndex: 'payPrice',
|
||||
key: 'payPrice',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '签约状态',
|
||||
dataIndex: 'isInvalid',
|
||||
key: 'isInvalid',
|
||||
align: 'center',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '月份',
|
||||
dataIndex: 'month',
|
||||
key: 'month',
|
||||
align: 'center',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '结算状态',
|
||||
dataIndex: 'isSettled',
|
||||
key: 'isSettled',
|
||||
align: 'center',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
}
|
||||
]);
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: ShopDealerOrderParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
/* 批量结算 */
|
||||
const batchSettle = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
|
||||
const validOrders = selection.value.filter(
|
||||
(order) => order.isSettled === 0 && order.isInvalid === 0
|
||||
);
|
||||
|
||||
if (!validOrders.length) {
|
||||
message.error('所选订单中没有可结算的订单');
|
||||
return;
|
||||
}
|
||||
|
||||
const totalCommission = validOrders
|
||||
.reduce((sum, order) => {
|
||||
return (
|
||||
sum +
|
||||
parseFloat(order.firstMoney || '0') +
|
||||
parseFloat(order.secondMoney || '0') +
|
||||
parseFloat(order.thirdMoney || '0')
|
||||
);
|
||||
}, 0)
|
||||
.toFixed(2);
|
||||
|
||||
Modal.confirm({
|
||||
title: '批量结算确认',
|
||||
content: `确定要结算选中的 ${validOrders.length} 个订单吗?总佣金金额:¥${totalCommission}`,
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
okText: '确认结算',
|
||||
okType: 'primary',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
const hide = message.loading('正在批量结算...', 0);
|
||||
// 这里调用批量结算API
|
||||
setTimeout(() => {
|
||||
hide();
|
||||
message.success(`成功结算 ${validOrders.length} 个订单`);
|
||||
reload();
|
||||
}, 1500);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 导出数据 */
|
||||
const handleExport = () => {
|
||||
// 调用导出API,传入当前搜索条件
|
||||
exportSdyDealerOrder(currentWhere.value);
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: ShopDealerOrder) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: ShopDealerOrder) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeShopDealerOrder(row.id)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchShopDealerOrder(selection.value.map((d) => d.id))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 查询 */
|
||||
const query = () => {
|
||||
loading.value = true;
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: ShopDealerOrder) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
query();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'ShopDealerOrder'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.order-info {
|
||||
.order-id {
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.order-price {
|
||||
color: #ff4d4f;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.dealer-info {
|
||||
.dealer-level {
|
||||
margin-bottom: 6px;
|
||||
font-size: 12px;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.detail-section) {
|
||||
h4 {
|
||||
color: #1890ff;
|
||||
margin-bottom: 12px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 4px 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-table-tbody > tr > td) {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
:deep(.ant-tag) {
|
||||
margin: 2px 4px 2px 0;
|
||||
}
|
||||
</style>
|
||||
79
src/views/glt/shopDealerOrder2/components/Import.vue
Normal file
79
src/views/glt/shopDealerOrder2/components/Import.vue
Normal file
@@ -0,0 +1,79 @@
|
||||
<!-- 经销商订单导入弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="520"
|
||||
:footer="null"
|
||||
title="导入分销订单"
|
||||
:visible="visible"
|
||||
@update:visible="updateVisible"
|
||||
>
|
||||
<a-spin :spinning="loading">
|
||||
<a-upload-dragger
|
||||
accept=".xls,.xlsx"
|
||||
:show-upload-list="false"
|
||||
:customRequest="doUpload"
|
||||
style="padding: 24px 0; margin-bottom: 16px"
|
||||
>
|
||||
<p class="ant-upload-drag-icon">
|
||||
<cloud-upload-outlined />
|
||||
</p>
|
||||
<p class="ant-upload-hint">将文件拖到此处,或点击上传</p>
|
||||
</a-upload-dragger>
|
||||
</a-spin>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import { CloudUploadOutlined } from '@ant-design/icons-vue';
|
||||
import { importSdyDealerOrder } from '@/api/sdy/sdyDealerOrder';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
defineProps<{
|
||||
// 是否打开弹窗
|
||||
visible: boolean;
|
||||
}>();
|
||||
|
||||
// 导入请求状态
|
||||
const loading = ref(false);
|
||||
|
||||
/* 上传 */
|
||||
const doUpload = ({ file }) => {
|
||||
if (
|
||||
![
|
||||
'application/vnd.ms-excel',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
].includes(file.type)
|
||||
) {
|
||||
message.error('只能选择 excel 文件');
|
||||
return false;
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 10) {
|
||||
message.error('大小不能超过 10MB');
|
||||
return false;
|
||||
}
|
||||
loading.value = true;
|
||||
importSdyDealerOrder(file)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
return false;
|
||||
};
|
||||
|
||||
/* 更新 visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
</script>
|
||||
143
src/views/glt/shopDealerOrder2/components/search.vue
Normal file
143
src/views/glt/shopDealerOrder2/components/search.vue
Normal file
@@ -0,0 +1,143 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-input-search
|
||||
allow-clear
|
||||
placeholder="客户名称|订单编号"
|
||||
style="width: 240px"
|
||||
v-model:value="where.keywords"
|
||||
@search="reload"
|
||||
/>
|
||||
<a-button type="dashed" @click="handleExport">导出xls</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { GradeParam } from '@/api/user/grade/model';
|
||||
import { ref, watch } from 'vue';
|
||||
import { utils, writeFile } from 'xlsx';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { ShopDealerCapital } from '@/api/shop/shopDealerCapital/model';
|
||||
import { getTenantId } from '@/utils/domain';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import {
|
||||
ShopDealerOrder,
|
||||
ShopDealerOrderParam
|
||||
} from '@/api/sdy/sdyDealerOrder/model';
|
||||
import { pageShopDealerOrder } from '@/api/shop/shopDealerOrder';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: GradeParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
(e: 'batchMove'): void;
|
||||
}>();
|
||||
|
||||
const reload = () => {
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const { where } = useSearch<ShopDealerOrderParam>({
|
||||
keywords: '',
|
||||
userId: undefined,
|
||||
orderNo: undefined,
|
||||
limit: 5000
|
||||
});
|
||||
|
||||
const list = ref<ShopDealerCapital[]>([]);
|
||||
|
||||
// 导出
|
||||
const handleExport = async () => {
|
||||
const array: (string | number)[][] = [
|
||||
[
|
||||
'客户名称',
|
||||
'业务员',
|
||||
'订单编号',
|
||||
'结算电量',
|
||||
'换算成度',
|
||||
'结算单价',
|
||||
'结算金额',
|
||||
'税费',
|
||||
'实发金额',
|
||||
'一级佣金30%',
|
||||
'一级佣金收益',
|
||||
'二级佣金10%',
|
||||
'二级佣金收益',
|
||||
'三级佣金60%',
|
||||
'三级佣金收益',
|
||||
'月份',
|
||||
'创建时间',
|
||||
'结算时间',
|
||||
'租户ID'
|
||||
]
|
||||
];
|
||||
|
||||
// 按搜索结果导出
|
||||
await pageShopDealerOrder(where)
|
||||
.then((data) => {
|
||||
list.value = data?.list || [];
|
||||
list.value?.forEach((d: ShopDealerOrder) => {
|
||||
array.push([
|
||||
`${d.title}`,
|
||||
`${d.nickname}(${d.userId})`,
|
||||
`${d.orderNo}`,
|
||||
`${d.orderPrice}`,
|
||||
`${d.degreePrice}`,
|
||||
`${d.price}`,
|
||||
`${d.settledPrice}`,
|
||||
`${d.rate}`,
|
||||
`${d.payPrice}`,
|
||||
`${d.firstNickname}(${d.firstUserId})`,
|
||||
`${d.firstMoney}`,
|
||||
`${d.secondNickname}(${d.secondUserId})`,
|
||||
`${d.secondMoney}`,
|
||||
`${d.thirdNickname}(${d.thirdUserId})`,
|
||||
`${d.thirdMoney}`,
|
||||
`${d.month}`,
|
||||
`${d.createTime}`,
|
||||
`${d.settleTime}`,
|
||||
`${d.tenantId}`
|
||||
]);
|
||||
});
|
||||
const sheetName = `bak_shop_dealer_order_${getTenantId()}`;
|
||||
const workbook = {
|
||||
SheetNames: [sheetName],
|
||||
Sheets: {}
|
||||
};
|
||||
const sheet = utils.aoa_to_sheet(array);
|
||||
workbook.Sheets[sheetName] = sheet;
|
||||
// 设置列宽
|
||||
sheet['!cols'] = [
|
||||
{ wch: 10 },
|
||||
{ wch: 20 },
|
||||
{ wch: 20 },
|
||||
{ wch: 15 },
|
||||
{ wch: 10 },
|
||||
{ wch: 10 },
|
||||
{ wch: 20 }
|
||||
];
|
||||
message.loading('正在导出...');
|
||||
setTimeout(() => {
|
||||
writeFile(workbook, `${sheetName}.xlsx`);
|
||||
}, 1000);
|
||||
})
|
||||
.catch((msg) => {
|
||||
message.error(msg);
|
||||
})
|
||||
.finally(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
@@ -0,0 +1,333 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="900"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '分销订单' : '分销订单'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
:okText="`立即结算`"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<!-- 订单基本信息 -->
|
||||
<a-divider orientation="left">
|
||||
<span style="color: #1890ff; font-weight: 600">基本信息</span>
|
||||
</a-divider>
|
||||
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="订单编号" name="orderNo">
|
||||
{{ form.orderNo }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="订单金额" name="payPrice">
|
||||
{{ parseFloat(form.payPrice || 0).toFixed(2) }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<!-- <div class="font-bold text-gray-400 bg-gray-50">开发调试</div>-->
|
||||
<!-- <div class="text-gray-400 bg-gray-50">-->
|
||||
<!-- <div>业务员({{ form.userId }}):{{ form.nickname }}</div>-->
|
||||
<!-- <div-->
|
||||
<!-- >一级分销商({{ form.firstUserId }}):{{-->
|
||||
<!-- form.firstNickname-->
|
||||
<!-- }},一级佣金30%:{{ form.firstMoney }}</div-->
|
||||
<!-- >-->
|
||||
<!-- <div-->
|
||||
<!-- >二级分销商({{ form.secondUserId }}):{{-->
|
||||
<!-- form.secondNickname-->
|
||||
<!-- }},二级佣金10%:{{ form.secondMoney }}</div-->
|
||||
<!-- >-->
|
||||
<!-- <div-->
|
||||
<!-- >三级分销商({{ form.thirdUserId }}):{{-->
|
||||
<!-- form.thirdNickname-->
|
||||
<!-- }},三级佣金60%:{{ form.thirdMoney }}</div-->
|
||||
<!-- >-->
|
||||
<!-- </div>-->
|
||||
<!-- 分销商信息 -->
|
||||
<a-divider orientation="left">
|
||||
<span style="color: #1890ff; font-weight: 600">收益计算</span>
|
||||
</a-divider>
|
||||
|
||||
<!-- 一级分销商 -->
|
||||
<div class="dealer-section">
|
||||
<h4 class="dealer-title">
|
||||
<a-tag color="orange">一级佣金10%</a-tag>
|
||||
</h4>
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="用户ID" name="firstUserId">
|
||||
{{ form.firstUserId }}
|
||||
</a-form-item>
|
||||
<a-form-item label="昵称" name="firstNickname">
|
||||
{{ form.firstNickname }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="占比" name="rate">
|
||||
{{ '10%' }}
|
||||
</a-form-item>
|
||||
<a-form-item label="获取收益" name="firstMoney">
|
||||
{{ form.firstMoney }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
|
||||
<!-- 二级分销商 -->
|
||||
<div class="dealer-section">
|
||||
<h4 class="dealer-title">
|
||||
<a-tag color="orange">二级佣金10%</a-tag>
|
||||
</h4>
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="用户ID" name="secondUserId">
|
||||
{{ form.secondUserId }}
|
||||
</a-form-item>
|
||||
<a-form-item label="昵称" name="nickname">
|
||||
{{ form.secondNickname }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="占比" name="rate"> 10% </a-form-item>
|
||||
<a-form-item label="获取收益" name="firstMoney">
|
||||
{{ form.secondMoney }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
|
||||
<!-- 三级分销商 -->
|
||||
<div class="dealer-section" v-if="form.thirdUserId > 0">
|
||||
<h4 class="dealer-title">
|
||||
<a-tag color="orange">三级佣金60%</a-tag>
|
||||
</h4>
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="用户ID" name="thirdUserId">
|
||||
{{ form.thirdUserId }}
|
||||
</a-form-item>
|
||||
<a-form-item label="昵称" name="thirdNickname">
|
||||
{{ form.thirdNickname }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="占比" name="rate">
|
||||
{{ '60%' }}
|
||||
</a-form-item>
|
||||
<a-form-item label="获取收益" name="thirdMoney">
|
||||
{{ form.thirdMoney }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
|
||||
<a-form-item
|
||||
label="结算时间"
|
||||
name="settleTime"
|
||||
v-if="form.isSettled === 1"
|
||||
>
|
||||
{{ form.settleTime }}
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
import { ShopDealerOrder } from '@/api/shop/shopDealerOrder/model';
|
||||
import { FormInstance } from 'ant-design-vue/es/form';
|
||||
import { updateSdyDealerOrder } from '@/api/sdy/sdyDealerOrder';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: ShopDealerOrder | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
// 表格选中数据
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
// 表单数据
|
||||
const form = reactive<ShopDealerOrder>({
|
||||
id: undefined,
|
||||
userId: undefined,
|
||||
nickname: undefined,
|
||||
orderNo: undefined,
|
||||
title: undefined,
|
||||
orderPrice: undefined,
|
||||
settledPrice: undefined,
|
||||
degreePrice: undefined,
|
||||
price: undefined,
|
||||
month: undefined,
|
||||
payPrice: undefined,
|
||||
firstUserId: undefined,
|
||||
secondUserId: undefined,
|
||||
thirdUserId: undefined,
|
||||
firstMoney: undefined,
|
||||
secondMoney: undefined,
|
||||
thirdMoney: undefined,
|
||||
firstNickname: undefined,
|
||||
secondNickname: undefined,
|
||||
thirdNickname: undefined,
|
||||
rate: undefined,
|
||||
comments: undefined,
|
||||
isInvalid: 0,
|
||||
isSettled: 0,
|
||||
settleTime: undefined,
|
||||
tenantId: undefined,
|
||||
createTime: undefined,
|
||||
updateTime: undefined
|
||||
});
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
userId: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择用户ID',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const { resetFields } = useForm(form, rules);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
if (form.isSettled == 1) {
|
||||
message.error('请勿重复结算');
|
||||
return;
|
||||
}
|
||||
if (form.userId == 0) {
|
||||
message.error('未签约');
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const formData = {
|
||||
...form,
|
||||
isSettled: 1
|
||||
};
|
||||
updateSdyDealerOrder(formData)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
console.log(localStorage.getItem(''));
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
assignObject(form, props.data);
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
// 重置为默认值
|
||||
Object.assign(form, {
|
||||
id: undefined,
|
||||
userId: undefined,
|
||||
orderNo: undefined,
|
||||
orderPrice: undefined,
|
||||
firstUserId: undefined,
|
||||
secondUserId: undefined,
|
||||
thirdUserId: undefined,
|
||||
firstMoney: undefined,
|
||||
secondMoney: undefined,
|
||||
thirdMoney: undefined,
|
||||
isInvalid: 0,
|
||||
isSettled: 0,
|
||||
settleTime: undefined
|
||||
});
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.dealer-section {
|
||||
margin-bottom: 24px;
|
||||
padding: 16px;
|
||||
background: #fafafa;
|
||||
border-radius: 6px;
|
||||
border-left: 3px solid #1890ff;
|
||||
|
||||
.dealer-title {
|
||||
margin: 0 0 16px 0;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
|
||||
.ant-tag {
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-divider-horizontal.ant-divider-with-text-left) {
|
||||
margin: 24px 0 16px 0;
|
||||
|
||||
.ant-divider-inner-text {
|
||||
padding: 0 16px 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-form-item) {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
:deep(.ant-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
500
src/views/glt/shopDealerOrder2/index.vue
Normal file
500
src/views/glt/shopDealerOrder2/index.vue
Normal file
@@ -0,0 +1,500 @@
|
||||
<template>
|
||||
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
|
||||
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="id"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:customRow="customRow"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-org-table"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@batchSettle="batchSettle"
|
||||
@export="handleExport"
|
||||
@remove="removeBatch"
|
||||
@importDone="reload"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'title'">
|
||||
<div>{{ record.title }}</div>
|
||||
<div class="text-gray-400"
|
||||
>{{ record.nickname }}({{ record.userId }})</div
|
||||
>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'orderPrice'">
|
||||
{{ parseFloat(record.orderPrice).toFixed(2) }}
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'degreePrice'">
|
||||
{{ record.degreePrice.toFixed(2) }}
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'price'">
|
||||
{{ record.price || 0 }}
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'settledPrice'">
|
||||
{{ record.settledPrice.toFixed(2) }}
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'payPrice'">
|
||||
{{ record.payPrice.toFixed(2) }}
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'firstNickname'">
|
||||
<div>{{ record.firstMoney }}</div>
|
||||
<div class="text-gray-400">{{ record.firstNickname || '-' }}</div>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'secondNickname'">
|
||||
<div>{{ record.secondMoney }}</div>
|
||||
<div class="text-gray-400">{{ record.secondNickname || '-' }}</div>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'thirdNickname'">
|
||||
<div class="text-gray-400"
|
||||
>{{ record.thirdNickname || '-' }} {{ record.thirdMoney }}</div
|
||||
>
|
||||
<!-- <div class="text-gray-400" v-if="record.thirdNickname"-->
|
||||
<!-- >{{ record.thirdNickname }} {{ record.thirdMoney }}</div-->
|
||||
<!-- >-->
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'dealerInfo'">
|
||||
<div class="dealer-info">
|
||||
<div v-if="record.firstUserId" class="dealer-level">
|
||||
<a-tag color="red">一级</a-tag>
|
||||
用户{{ record.firstUserId }} - ¥{{
|
||||
parseFloat(record.firstMoney || '0').toFixed(2)
|
||||
}}
|
||||
</div>
|
||||
<div v-if="record.secondUserId" class="dealer-level">
|
||||
<a-tag color="orange">二级</a-tag>
|
||||
用户{{ record.secondUserId }} - ¥{{
|
||||
parseFloat(record.secondMoney || '0').toFixed(2)
|
||||
}}
|
||||
</div>
|
||||
<div v-if="record.thirdUserId" class="dealer-level">
|
||||
<a-tag color="gold">三级</a-tag>
|
||||
用户{{ record.thirdUserId }} - ¥{{
|
||||
parseFloat(record.thirdMoney || '0').toFixed(2)
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'isInvalid'">
|
||||
<a-tag v-if="record.isInvalid === 0" color="success">已签约</a-tag>
|
||||
<a-tag v-if="record.isInvalid === 1" color="error">未签约</a-tag>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'isSettled'">
|
||||
<a-tag v-if="record.isSettled === 0" color="orange">未结算</a-tag>
|
||||
<a-tag v-if="record.isSettled === 1" color="success">已结算</a-tag>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'createTime'">
|
||||
<div class="flex flex-col">
|
||||
<a-tooltip title="创建时间">
|
||||
<span class="text-gray-500">{{ record.createTime }}</span>
|
||||
</a-tooltip>
|
||||
<a-tooltip title="结算时间">
|
||||
<span class="text-purple-500">{{ record.settleTime }}</span>
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'action'">
|
||||
<template v-if="record.isSettled === 0 && record.isInvalid === 0">
|
||||
<a @click="settleOrder(record)" class="ele-text-success">
|
||||
结算
|
||||
</a>
|
||||
<a-divider type="vertical" />
|
||||
</template>
|
||||
<!-- <template v-if="record.isInvalid === 0">-->
|
||||
<!-- <a-popconfirm-->
|
||||
<!-- title="确定要标记此订单为失效吗?"-->
|
||||
<!-- @confirm="invalidateOrder(record)"-->
|
||||
<!-- placement="topRight"-->
|
||||
<!-- >-->
|
||||
<!-- <a class="text-purple-500">-->
|
||||
<!-- 验证-->
|
||||
<!-- </a>-->
|
||||
<!-- </a-popconfirm>-->
|
||||
<!-- </template>-->
|
||||
<a-popconfirm
|
||||
v-if="record.isSettled === 0"
|
||||
title="确定要删除吗?"
|
||||
@confirm="remove(record)"
|
||||
placement="topRight"
|
||||
>
|
||||
<a class="text-red-500"> 删除 </a>
|
||||
</a-popconfirm>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<ShopDealerOrderEdit
|
||||
v-model:visible="showEdit"
|
||||
:data="current"
|
||||
@done="reload"
|
||||
/>
|
||||
</a-page-header>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import {
|
||||
ExclamationCircleOutlined,
|
||||
DollarOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import Search from './components/search.vue';
|
||||
import { getPageTitle } from '@/utils/common';
|
||||
import ShopDealerOrderEdit from './components/shopDealerOrderEdit.vue';
|
||||
import {
|
||||
pageShopDealerOrder,
|
||||
removeShopDealerOrder,
|
||||
removeBatchShopDealerOrder
|
||||
} from '@/api/shop/shopDealerOrder';
|
||||
import type {
|
||||
ShopDealerOrder,
|
||||
ShopDealerOrderParam
|
||||
} from '@/api/shop/shopDealerOrder/model';
|
||||
import {
|
||||
exportSdyDealerOrder,
|
||||
updateSdyDealerOrder
|
||||
} from '@/api/sdy/sdyDealerOrder';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<ShopDealerOrder[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<ShopDealerOrder | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
|
||||
// 当前搜索条件
|
||||
const currentWhere = ref<ShopDealerOrderParam>({});
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.status = filters.status;
|
||||
}
|
||||
// 保存当前搜索条件用于导出
|
||||
currentWhere.value = { ...where };
|
||||
// 已结算订单
|
||||
where.isSettled = 1;
|
||||
return pageShopDealerOrder({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
key: 'index',
|
||||
width: 48,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true,
|
||||
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
{
|
||||
title: '订单编号',
|
||||
dataIndex: 'orderNo',
|
||||
key: 'orderNo',
|
||||
align: 'center',
|
||||
width: 200
|
||||
},
|
||||
{
|
||||
title: '买家',
|
||||
dataIndex: 'title',
|
||||
key: 'title'
|
||||
},
|
||||
{
|
||||
title: '订单金额',
|
||||
dataIndex: 'orderPrice',
|
||||
key: 'orderPrice',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '一级佣金',
|
||||
dataIndex: 'firstNickname',
|
||||
key: 'firstNickname',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '二级佣金',
|
||||
dataIndex: 'secondNickname',
|
||||
key: 'secondNickname',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '门店分红',
|
||||
dataIndex: 'thirdNickname',
|
||||
key: 'thirdNickname',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '结算状态',
|
||||
dataIndex: 'isSettled',
|
||||
key: 'isSettled',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
align: 'center',
|
||||
width: 180
|
||||
}
|
||||
// {
|
||||
// title: '操作',
|
||||
// key: 'action',
|
||||
// width: 180,
|
||||
// fixed: 'right',
|
||||
// align: 'center',
|
||||
// hideInSetting: true
|
||||
// }
|
||||
]);
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: ShopDealerOrderParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
/* 结算单个订单 */
|
||||
const settleOrder = (row: ShopDealerOrder) => {
|
||||
const totalCommission = (
|
||||
parseFloat(row.firstMoney || '0') +
|
||||
parseFloat(row.secondMoney || '0') +
|
||||
parseFloat(row.thirdMoney || '0')
|
||||
).toFixed(2);
|
||||
|
||||
Modal.confirm({
|
||||
title: '确认结算',
|
||||
content: `确定要结算此订单吗?总佣金金额:¥${totalCommission}`,
|
||||
icon: createVNode(DollarOutlined),
|
||||
okText: '确认结算',
|
||||
okType: 'primary',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
const hide = message.loading('正在结算...', 0);
|
||||
// 这里调用结算API
|
||||
updateSdyDealerOrder({
|
||||
...row,
|
||||
isSettled: 1
|
||||
});
|
||||
setTimeout(() => {
|
||||
hide();
|
||||
message.success('结算成功');
|
||||
reload();
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量结算 */
|
||||
const batchSettle = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
|
||||
const validOrders = selection.value.filter(
|
||||
(order) => order.isSettled === 0 && order.isInvalid === 0
|
||||
);
|
||||
|
||||
if (!validOrders.length) {
|
||||
message.error('所选订单中没有可结算的订单');
|
||||
return;
|
||||
}
|
||||
|
||||
const totalCommission = validOrders
|
||||
.reduce((sum, order) => {
|
||||
return (
|
||||
sum +
|
||||
parseFloat(order.firstMoney || '0') +
|
||||
parseFloat(order.secondMoney || '0') +
|
||||
parseFloat(order.thirdMoney || '0')
|
||||
);
|
||||
}, 0)
|
||||
.toFixed(2);
|
||||
|
||||
Modal.confirm({
|
||||
title: '批量结算确认',
|
||||
content: `确定要结算选中的 ${validOrders.length} 个订单吗?总佣金金额:¥${totalCommission}`,
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
okText: '确认结算',
|
||||
okType: 'primary',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
const hide = message.loading('正在批量结算...', 0);
|
||||
// 这里调用批量结算API
|
||||
setTimeout(() => {
|
||||
hide();
|
||||
message.success(`成功结算 ${validOrders.length} 个订单`);
|
||||
reload();
|
||||
}, 1500);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 导出数据 */
|
||||
const handleExport = () => {
|
||||
// 调用导出API,传入当前搜索条件
|
||||
exportSdyDealerOrder(currentWhere.value);
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: ShopDealerOrder) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: ShopDealerOrder) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeShopDealerOrder(row.id)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchShopDealerOrder(selection.value.map((d) => d.id))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 查询 */
|
||||
const query = () => {
|
||||
loading.value = true;
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: ShopDealerOrder) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
query();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'ShopDealerOrder'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.order-info {
|
||||
.order-id {
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.order-price {
|
||||
color: #ff4d4f;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.dealer-info {
|
||||
.dealer-level {
|
||||
margin-bottom: 6px;
|
||||
font-size: 12px;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.detail-section) {
|
||||
h4 {
|
||||
color: #1890ff;
|
||||
margin-bottom: 12px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 4px 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-table-tbody > tr > td) {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
:deep(.ant-tag) {
|
||||
margin: 2px 4px 2px 0;
|
||||
}
|
||||
</style>
|
||||
204
src/views/glt/shopDealerReferee/components/RefereeTree.vue
Normal file
204
src/views/glt/shopDealerReferee/components/RefereeTree.vue
Normal file
@@ -0,0 +1,204 @@
|
||||
<template>
|
||||
<a-modal
|
||||
:visible="visible"
|
||||
:title="title"
|
||||
:width="1000"
|
||||
:footer="null"
|
||||
@cancel="handleCancel"
|
||||
>
|
||||
<div class="tree-container">
|
||||
<v-chart
|
||||
ref="chartRef"
|
||||
class="chart"
|
||||
:option="chartOption"
|
||||
:loading="loading"
|
||||
autoresize
|
||||
/>
|
||||
</div>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, watch, computed } from 'vue';
|
||||
import { use } from 'echarts/core';
|
||||
import { CanvasRenderer } from 'echarts/renderers';
|
||||
import { TreeChart } from 'echarts/charts';
|
||||
import { TooltipComponent, TitleComponent } from 'echarts/components';
|
||||
import VChart from 'vue-echarts';
|
||||
import type { ShopDealerReferee } from '@/api/shop/shopDealerReferee/model';
|
||||
|
||||
// 注册 echarts 组件
|
||||
use([CanvasRenderer, TreeChart, TooltipComponent, TitleComponent]);
|
||||
|
||||
// 定义组件属性
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
visible: boolean;
|
||||
data?: ShopDealerReferee[];
|
||||
title?: string;
|
||||
}>(),
|
||||
{
|
||||
visible: false,
|
||||
data: () => [],
|
||||
title: '推荐关系树'
|
||||
}
|
||||
);
|
||||
|
||||
// 定义事件
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', value: boolean): void;
|
||||
(e: 'cancel'): void;
|
||||
}>();
|
||||
|
||||
// 图表引用
|
||||
const chartRef = ref<InstanceType<typeof VChart> | null>(null);
|
||||
|
||||
// 加载状态
|
||||
const loading = ref(false);
|
||||
|
||||
// 处理取消事件
|
||||
const handleCancel = () => {
|
||||
emit('update:visible', false);
|
||||
emit('cancel');
|
||||
};
|
||||
|
||||
// 转换数据为树形结构
|
||||
const transformToTreeData = (data: ShopDealerReferee[]) => {
|
||||
if (!data || data.length === 0) {
|
||||
return { name: '暂无数据', children: [] };
|
||||
}
|
||||
|
||||
// 构建节点映射
|
||||
const nodeMap = new Map<number, any>();
|
||||
const rootNodes: any[] = [];
|
||||
|
||||
// 创建所有节点
|
||||
data.forEach((item) => {
|
||||
// 推荐人节点
|
||||
if (item.dealerId && !nodeMap.has(item.dealerId)) {
|
||||
nodeMap.set(item.dealerId, {
|
||||
id: item.dealerId,
|
||||
name: `推荐人\nID:${item.dealerId}\n${item.dealerName || ''}`,
|
||||
level: 'dealer',
|
||||
children: []
|
||||
});
|
||||
}
|
||||
|
||||
// 被推荐人节点
|
||||
if (item.userId && !nodeMap.has(item.userId)) {
|
||||
nodeMap.set(item.userId, {
|
||||
id: item.userId,
|
||||
name: `被推荐人\nID:${item.userId}\n${item.nickname || ''}`,
|
||||
level: 'user',
|
||||
children: []
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 构建关系树
|
||||
data.forEach((item) => {
|
||||
if (!item.dealerId || !item.userId) return;
|
||||
|
||||
const dealerNode = nodeMap.get(item.dealerId);
|
||||
const userNode = nodeMap.get(item.userId);
|
||||
|
||||
if (dealerNode && userNode) {
|
||||
// 添加层级标签
|
||||
const levelText =
|
||||
{ 1: '一级', 2: '二级', 3: '三级' }[item.level || 0] ||
|
||||
`${item.level || 0}级`;
|
||||
userNode.name += `\n${levelText}推荐`;
|
||||
dealerNode.children.push(userNode);
|
||||
}
|
||||
});
|
||||
|
||||
// 查找根节点(没有被推荐关系的节点)
|
||||
const referencedIds = new Set(
|
||||
data.map((item) => item.userId).filter((id) => id)
|
||||
);
|
||||
data.forEach((item) => {
|
||||
if (item.dealerId && !referencedIds.has(item.dealerId)) {
|
||||
const rootNode = nodeMap.get(item.dealerId);
|
||||
if (rootNode) {
|
||||
rootNodes.push(rootNode);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 如果没有明确的根节点,使用第一个节点作为根
|
||||
if (rootNodes.length === 0 && data.length > 0 && data[0].dealerId) {
|
||||
const firstNode = nodeMap.get(data[0].dealerId);
|
||||
if (firstNode) {
|
||||
rootNodes.push(firstNode);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果还是没有根节点,返回默认节点
|
||||
if (rootNodes.length === 0) {
|
||||
return { name: '暂无数据', children: [] };
|
||||
}
|
||||
|
||||
return rootNodes[0];
|
||||
};
|
||||
|
||||
// 图表配置
|
||||
const chartOption = computed(() => {
|
||||
const treeData = transformToTreeData(props.data || []);
|
||||
|
||||
return {
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
triggerOn: 'mousemove'
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'tree',
|
||||
data: [treeData],
|
||||
top: '1%',
|
||||
left: '7%',
|
||||
bottom: '1%',
|
||||
right: '20%',
|
||||
symbolSize: 12,
|
||||
symbol: 'circle',
|
||||
orient: 'LR', // 从左到右
|
||||
expandAndCollapse: true,
|
||||
label: {
|
||||
position: 'left',
|
||||
verticalAlign: 'middle',
|
||||
align: 'right',
|
||||
fontSize: 12,
|
||||
backgroundColor: '#fff',
|
||||
padding: [2, 4],
|
||||
borderRadius: 4,
|
||||
borderWidth: 1,
|
||||
borderColor: '#ccc'
|
||||
},
|
||||
leaves: {
|
||||
label: {
|
||||
position: 'right',
|
||||
verticalAlign: 'middle',
|
||||
align: 'left'
|
||||
}
|
||||
},
|
||||
emphasis: {
|
||||
focus: 'descendant'
|
||||
},
|
||||
animationDuration: 500,
|
||||
animationDurationUpdate: 750
|
||||
}
|
||||
]
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.tree-container {
|
||||
height: 600px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.chart {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
185
src/views/glt/shopDealerReferee/components/search.vue
Normal file
185
src/views/glt/shopDealerReferee/components/search.vue
Normal file
@@ -0,0 +1,185 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<!-- 搜索表单 -->
|
||||
<a-form
|
||||
:model="searchForm"
|
||||
layout="inline"
|
||||
class="search-form"
|
||||
@finish="handleSearch"
|
||||
>
|
||||
<a-form-item label="推荐人ID">
|
||||
<a-input-number
|
||||
v-model:value="searchForm.dealerId"
|
||||
placeholder="请输入推荐人ID"
|
||||
:min="1"
|
||||
style="width: 160px"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="被推荐人ID">
|
||||
<a-input-number
|
||||
v-model:value="searchForm.userId"
|
||||
placeholder="请输入被推荐人ID"
|
||||
:min="1"
|
||||
style="width: 160px"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="建立时间">
|
||||
<a-range-picker
|
||||
v-model:value="searchForm.dateRange"
|
||||
style="width: 240px"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item>
|
||||
<a-space>
|
||||
<a-button type="primary" html-type="submit" class="ele-btn-icon">
|
||||
<template #icon>
|
||||
<SearchOutlined />
|
||||
</template>
|
||||
搜索
|
||||
</a-button>
|
||||
<a-button @click="resetSearch"> 重置 </a-button>
|
||||
<a-button @click="exportData" class="ele-btn-icon">
|
||||
<template #icon>
|
||||
<ExportOutlined />
|
||||
</template>
|
||||
导出
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<!-- <div class="action-buttons">-->
|
||||
<!-- <a-space>-->
|
||||
<!-- <a-button type="primary" @click="add" class="ele-btn-icon">-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <PlusOutlined/>-->
|
||||
<!-- </template>-->
|
||||
<!-- 建立推荐关系-->
|
||||
<!-- </a-button>-->
|
||||
<!-- <a-button @click="viewTree" class="ele-btn-icon">-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <ApartmentOutlined/>-->
|
||||
<!-- </template>-->
|
||||
<!-- 推荐关系树-->
|
||||
<!-- </a-button>-->
|
||||
<!-- <a-button @click="exportData" class="ele-btn-icon">-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <ExportOutlined/>-->
|
||||
<!-- </template>-->
|
||||
<!-- 导出数据-->
|
||||
<!-- </a-button>-->
|
||||
<!-- </a-space>-->
|
||||
<!-- </div>-->
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive } from 'vue';
|
||||
import {
|
||||
PlusOutlined,
|
||||
SearchOutlined,
|
||||
ApartmentOutlined,
|
||||
ExportOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { ShopDealerRefereeParam } from '@/api/shop/shopDealerReferee/model';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的数据
|
||||
selection?: any[];
|
||||
}>(),
|
||||
{
|
||||
selection: () => []
|
||||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: ShopDealerRefereeParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'viewTree'): void;
|
||||
(e: 'export'): void;
|
||||
}>();
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive<any>({
|
||||
dealerId: undefined,
|
||||
userId: undefined,
|
||||
level: undefined,
|
||||
dateRange: undefined
|
||||
});
|
||||
|
||||
// 搜索
|
||||
const handleSearch = () => {
|
||||
const searchParams: ShopDealerRefereeParam = {};
|
||||
|
||||
if (searchForm.dealerId) {
|
||||
searchParams.dealerId = searchForm.dealerId;
|
||||
}
|
||||
if (searchForm.userId) {
|
||||
searchParams.userId = searchForm.userId;
|
||||
}
|
||||
if (searchForm.level) {
|
||||
searchParams.level = searchForm.level;
|
||||
}
|
||||
if (searchForm.dateRange && searchForm.dateRange.length === 2) {
|
||||
searchParams.startTime = dayjs(searchForm.dateRange[0]).format(
|
||||
'YYYY-MM-DD'
|
||||
);
|
||||
searchParams.endTime = dayjs(searchForm.dateRange[1]).format(
|
||||
'YYYY-MM-DD'
|
||||
);
|
||||
}
|
||||
|
||||
emit('search', searchParams);
|
||||
};
|
||||
|
||||
// 重置搜索
|
||||
const resetSearch = () => {
|
||||
searchForm.dealerId = undefined;
|
||||
searchForm.userId = undefined;
|
||||
searchForm.level = undefined;
|
||||
searchForm.dateRange = undefined;
|
||||
emit('search', {});
|
||||
};
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 查看推荐树
|
||||
const viewTree = () => {
|
||||
emit('viewTree');
|
||||
};
|
||||
|
||||
// 导出数据
|
||||
const exportData = () => {
|
||||
emit('export');
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.search-container {
|
||||
background: #fff;
|
||||
padding: 16px;
|
||||
border-radius: 6px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
.search-form {
|
||||
margin-bottom: 16px;
|
||||
|
||||
:deep(.ant-form-item) {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
border-top: 1px solid #f0f0f0;
|
||||
padding-top: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,158 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="800"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '编辑推荐' : '添加推荐关系'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
|
||||
:wrapper-col="
|
||||
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-form-item label="推荐人信息" name="dealerId">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入分销商用户ID"
|
||||
v-model:value="form.dealerId"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="被推荐人信息" name="userId">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入用户id(被推荐人)"
|
||||
v-model:value="form.userId"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
import {
|
||||
addShopDealerReferee,
|
||||
updateShopDealerReferee
|
||||
} from '@/api/shop/shopDealerReferee';
|
||||
import { ShopDealerReferee } from '@/api/shop/shopDealerReferee/model';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { FormInstance } from 'ant-design-vue/es/form';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: ShopDealerReferee | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
// 表格选中数据
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
const images = ref<ItemType[]>([]);
|
||||
|
||||
// 用户信息
|
||||
const form = reactive<ShopDealerReferee>({
|
||||
id: undefined,
|
||||
dealerId: undefined,
|
||||
userId: undefined,
|
||||
level: undefined,
|
||||
tenantId: undefined,
|
||||
createTime: undefined,
|
||||
updateTime: undefined
|
||||
});
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
shopDealerRefereeName: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写分销商推荐关系表名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const { resetFields } = useForm(form, rules);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const formData = {
|
||||
...form
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value
|
||||
? updateShopDealerReferee
|
||||
: addShopDealerReferee;
|
||||
saveOrUpdate(formData)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
images.value = [];
|
||||
if (props.data) {
|
||||
assignObject(form, props.data);
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
563
src/views/glt/shopDealerReferee/index.vue
Normal file
563
src/views/glt/shopDealerReferee/index.vue
Normal file
@@ -0,0 +1,563 @@
|
||||
<template>
|
||||
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
|
||||
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="id"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:customRow="customRow"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-org-table"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@viewTree="viewRefereeTree"
|
||||
@export="exportData"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'dealerInfo'">
|
||||
<div class="user-info">
|
||||
<div class="user-id"
|
||||
>{{ record.dealerName }}({{ record.dealerId }})</div
|
||||
>
|
||||
<div class="user-id"></div>
|
||||
<div class="user-role">
|
||||
<a-tag color="blue">推荐人</a-tag>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'relationship'">
|
||||
<ArrowRightOutlined />
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'userInfo'">
|
||||
<div class="user-info">
|
||||
<div class="user-id"
|
||||
>{{ record.nickname }}({{ record.userId }})</div
|
||||
>
|
||||
<div class="user-role">
|
||||
<a-tag color="green">被推荐人</a-tag>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'level'">
|
||||
<a-tag :color="getLevelColor(record.level || 0)" class="level-tag">
|
||||
{{ getLevelText(record.level || 0) }}
|
||||
</a-tag>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'relationChain'">
|
||||
<a-button
|
||||
type="link"
|
||||
size="small"
|
||||
@click="viewRelationChain(record)"
|
||||
class="chain-btn"
|
||||
>
|
||||
<TeamOutlined /> 查看关系链
|
||||
</a-button>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="openEdit(record)" class="ele-text-primary">
|
||||
<EditOutlined /> 编辑
|
||||
</a>
|
||||
<!-- <a-divider type="vertical" />-->
|
||||
<!-- <a-popconfirm-->
|
||||
<!-- title="确定要解除此推荐关系吗?"-->
|
||||
<!-- @confirm="remove(record)"-->
|
||||
<!-- placement="topRight"-->
|
||||
<!-- >-->
|
||||
<!-- <a class="ele-text-danger">-->
|
||||
<!-- <DisconnectOutlined /> 解除-->
|
||||
<!-- </a>-->
|
||||
<!-- </a-popconfirm>-->
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<ShopDealerRefereeEdit
|
||||
v-model:visible="showEdit"
|
||||
:data="current"
|
||||
@done="reload"
|
||||
/>
|
||||
|
||||
<!-- 树状图弹窗 -->
|
||||
<RefereeTree
|
||||
v-model:visible="showTree"
|
||||
:data="treeData"
|
||||
:title="'推荐关系树'"
|
||||
@cancel="showTree = false"
|
||||
/>
|
||||
</a-page-header>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import {
|
||||
ExclamationCircleOutlined,
|
||||
TeamOutlined,
|
||||
EditOutlined,
|
||||
ArrowRightOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import Search from './components/search.vue';
|
||||
import { getPageTitle } from '@/utils/common';
|
||||
import ShopDealerRefereeEdit from './components/shopDealerRefereeEdit.vue';
|
||||
import RefereeTree from './components/RefereeTree.vue';
|
||||
import { utils, writeFile } from 'xlsx';
|
||||
import {
|
||||
pageShopDealerReferee,
|
||||
removeShopDealerReferee,
|
||||
removeBatchShopDealerReferee,
|
||||
listShopDealerReferee
|
||||
} from '@/api/shop/shopDealerReferee';
|
||||
import type {
|
||||
ShopDealerReferee,
|
||||
ShopDealerRefereeParam
|
||||
} from '@/api/shop/shopDealerReferee/model';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<ShopDealerReferee[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<ShopDealerReferee | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 是否显示树状图弹窗
|
||||
const showTree = ref(false);
|
||||
// 树状图数据
|
||||
const treeData = ref<ShopDealerReferee[]>([]);
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.status = filters.status;
|
||||
}
|
||||
return pageShopDealerReferee({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: '推荐人信息',
|
||||
key: 'dealerInfo',
|
||||
align: 'left',
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
title: '',
|
||||
key: 'relationship',
|
||||
align: 'center',
|
||||
width: 50
|
||||
},
|
||||
{
|
||||
title: '被推荐人信息',
|
||||
key: 'userInfo',
|
||||
align: 'left',
|
||||
width: 150
|
||||
},
|
||||
// {
|
||||
// title: '推荐层级',
|
||||
// key: 'level',
|
||||
// align: 'center',
|
||||
// width: 120,
|
||||
// filters: [
|
||||
// { text: '一级推荐', value: 1 },
|
||||
// { text: '二级推荐', value: 2 },
|
||||
// { text: '三级推荐', value: 3 }
|
||||
// ]
|
||||
// },
|
||||
{
|
||||
title: '建立时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
align: 'center',
|
||||
width: 120,
|
||||
sorter: true,
|
||||
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd HH:mm')
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 200,
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
}
|
||||
]);
|
||||
|
||||
/* 获取层级颜色 */
|
||||
const getLevelColor = (level: number) => {
|
||||
const colors = {
|
||||
1: 'red',
|
||||
2: 'orange',
|
||||
3: 'gold'
|
||||
};
|
||||
return colors[level] || 'default';
|
||||
};
|
||||
|
||||
/* 获取层级文本 */
|
||||
const getLevelText = (level: number) => {
|
||||
const texts = {
|
||||
1: '一级推荐',
|
||||
2: '二级推荐',
|
||||
3: '三级推荐'
|
||||
};
|
||||
return texts[level] || `${level}级推荐`;
|
||||
};
|
||||
|
||||
/* 查看关系链 */
|
||||
const viewRelationChain = (record: ShopDealerReferee) => {
|
||||
// 这里可以调用API获取完整的推荐关系链
|
||||
Modal.info({
|
||||
title: '推荐关系链',
|
||||
width: 800,
|
||||
content: createVNode('div', { class: 'relation-chain' }, [
|
||||
createVNode('div', { class: 'chain-item' }, [
|
||||
createVNode('div', { class: 'chain-node dealer' }, [
|
||||
createVNode('div', { class: 'node-title' }, '推荐人'),
|
||||
createVNode(
|
||||
'div',
|
||||
{ class: 'node-id' },
|
||||
`用户ID: ${record.dealerId}`
|
||||
),
|
||||
createVNode('div', { class: 'node-level' }, '分销商')
|
||||
]),
|
||||
createVNode('div', { class: 'chain-arrow' }, '→'),
|
||||
createVNode('div', { class: 'chain-node user' }, [
|
||||
createVNode('div', { class: 'node-title' }, '被推荐人'),
|
||||
createVNode(
|
||||
'div',
|
||||
{ class: 'node-id' },
|
||||
`用户ID: ${record.userId}`
|
||||
),
|
||||
createVNode(
|
||||
'div',
|
||||
{ class: 'node-level' },
|
||||
getLevelText(record.level || 0)
|
||||
)
|
||||
])
|
||||
]),
|
||||
createVNode('div', { class: 'chain-info' }, [
|
||||
createVNode(
|
||||
'p',
|
||||
null,
|
||||
`推荐关系建立于: ${toDateString(
|
||||
record.createTime,
|
||||
'yyyy-MM-dd HH:mm:ss'
|
||||
)}`
|
||||
),
|
||||
createVNode('p', null, '点击可查看更多上下级关系')
|
||||
])
|
||||
]),
|
||||
okText: '关闭'
|
||||
});
|
||||
};
|
||||
|
||||
/* 查看推荐树 */
|
||||
const viewRefereeTree = () => {
|
||||
// 加载所有数据用于树状图展示
|
||||
loading.value = true;
|
||||
pageShopDealerReferee({ page: 1, limit: 10000 }) // 获取所有数据
|
||||
.then((result) => {
|
||||
treeData.value = result?.list || [];
|
||||
showTree.value = true;
|
||||
loading.value = false;
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error('加载数据失败: ' + e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 导出数据 */
|
||||
const exportData = async () => {
|
||||
try {
|
||||
// 定义表头
|
||||
const array: (string | number)[][] = [
|
||||
[
|
||||
'推荐人',
|
||||
'推荐人ID',
|
||||
'推荐人电话',
|
||||
'被推荐人',
|
||||
'被推荐人ID',
|
||||
'被推荐人电话',
|
||||
'创建时间'
|
||||
]
|
||||
];
|
||||
|
||||
// 获取用户列表数据
|
||||
const list = await listShopDealerReferee({});
|
||||
|
||||
if (!list || list.length === 0) {
|
||||
message.warning('没有数据可以导出');
|
||||
return;
|
||||
}
|
||||
|
||||
// 将数据转换为Excel行
|
||||
list.forEach((user: ShopDealerReferee) => {
|
||||
array.push([
|
||||
`${user.dealerName}`,
|
||||
`${user.dealerId}`,
|
||||
`${user.dealerPhone}`,
|
||||
`${user.nickname}`,
|
||||
`${user.userId}`,
|
||||
`${user.phone}`,
|
||||
`${user.createTime}`
|
||||
]);
|
||||
});
|
||||
|
||||
// 生成Excel文件
|
||||
const sheetName = `shop_dealer_referee`;
|
||||
const workbook = {
|
||||
SheetNames: [sheetName],
|
||||
Sheets: {}
|
||||
};
|
||||
const sheet = utils.aoa_to_sheet(array);
|
||||
workbook.Sheets[sheetName] = sheet;
|
||||
|
||||
// 设置列宽
|
||||
sheet['!cols'] = [
|
||||
{ wch: 10 }, // 用户ID
|
||||
{ wch: 15 } // 账号
|
||||
];
|
||||
|
||||
message.loading('正在生成Excel文件...', 0);
|
||||
|
||||
setTimeout(() => {
|
||||
writeFile(workbook, `${sheetName}.xlsx`);
|
||||
message.destroy();
|
||||
message.success(`成功导出 ${list.length} 条记录`);
|
||||
}, 1000);
|
||||
} catch (error: any) {
|
||||
message.error(error.message || '导出失败');
|
||||
}
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: ShopDealerRefereeParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: ShopDealerReferee) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: ShopDealerReferee) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeShopDealerReferee(row.id)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchShopDealerReferee(selection.value.map((d) => d.id))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 查询 */
|
||||
const query = () => {
|
||||
loading.value = true;
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: ShopDealerReferee) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
query();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'ShopDealerReferee'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.user-info {
|
||||
.user-id {
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.user-role {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.level-tag {
|
||||
font-weight: 600;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.chain-btn {
|
||||
padding: 0;
|
||||
height: auto;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
:deep(.referee-detail) {
|
||||
.detail-section {
|
||||
h4 {
|
||||
color: #1890ff;
|
||||
margin-bottom: 12px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 8px 0;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.level-badge {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.relation-chain) {
|
||||
.chain-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.chain-node {
|
||||
padding: 16px;
|
||||
border-radius: 8px;
|
||||
text-align: center;
|
||||
min-width: 120px;
|
||||
|
||||
&.dealer {
|
||||
background: #e6f7ff;
|
||||
border: 2px solid #1890ff;
|
||||
}
|
||||
|
||||
&.user {
|
||||
background: #f6ffed;
|
||||
border: 2px solid #52c41a;
|
||||
}
|
||||
|
||||
.node-title {
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.node-id {
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.node-level {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
|
||||
.chain-arrow {
|
||||
font-size: 24px;
|
||||
color: #1890ff;
|
||||
margin: 0 20px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.chain-info {
|
||||
background: #fafafa;
|
||||
padding: 12px;
|
||||
border-radius: 6px;
|
||||
margin-top: 16px;
|
||||
|
||||
p {
|
||||
margin: 4px 0;
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-table-tbody > tr > td) {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
:deep(.ant-tag) {
|
||||
margin: 2px 4px 2px 0;
|
||||
}
|
||||
</style>
|
||||
221
src/views/glt/shopDealerUser/components/search.vue
Normal file
221
src/views/glt/shopDealerUser/components/search.vue
Normal file
@@ -0,0 +1,221 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<div class="search-container">
|
||||
<!-- 搜索表单 -->
|
||||
<a-form
|
||||
:model="searchForm"
|
||||
layout="inline"
|
||||
class="search-form"
|
||||
@finish="handleSearch"
|
||||
>
|
||||
<a-form-item label="申请人姓名">
|
||||
<a-input
|
||||
v-model:value="searchForm.realName"
|
||||
placeholder="请输入申请人姓名"
|
||||
allow-clear
|
||||
style="width: 160px"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="手机号码">
|
||||
<a-input
|
||||
v-model:value="searchForm.mobile"
|
||||
placeholder="请输入手机号码"
|
||||
allow-clear
|
||||
style="width: 160px"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="申请方式">
|
||||
<a-select
|
||||
v-model:value="searchForm.applyType"
|
||||
placeholder="全部方式"
|
||||
allow-clear
|
||||
style="width: 120px"
|
||||
>
|
||||
<a-select-option :value="10">需要审核</a-select-option>
|
||||
<a-select-option :value="20">免审核</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="审核状态">
|
||||
<a-select
|
||||
v-model:value="searchForm.applyStatus"
|
||||
placeholder="全部状态"
|
||||
allow-clear
|
||||
style="width: 120px"
|
||||
>
|
||||
<a-select-option :value="10">待审核</a-select-option>
|
||||
<a-select-option :value="20">审核通过</a-select-option>
|
||||
<a-select-option :value="30">审核驳回</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="申请时间">
|
||||
<a-range-picker
|
||||
v-model:value="searchForm.dateRange"
|
||||
style="width: 240px"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item>
|
||||
<a-space>
|
||||
<a-button type="primary" html-type="submit" class="ele-btn-icon">
|
||||
<template #icon>
|
||||
<SearchOutlined />
|
||||
</template>
|
||||
搜索
|
||||
</a-button>
|
||||
<a-button @click="resetSearch"> 重置 </a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<div class="action-buttons">
|
||||
<a-space>
|
||||
<!-- <a-button type="primary" @click="add" class="ele-btn-icon">-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <PlusOutlined />-->
|
||||
<!-- </template>-->
|
||||
<!-- 新增申请-->
|
||||
<!-- </a-button>-->
|
||||
<a-button
|
||||
type="primary"
|
||||
ghost
|
||||
:disabled="!selection?.length"
|
||||
@click="batchApprove"
|
||||
class="ele-btn-icon"
|
||||
>
|
||||
<template #icon>
|
||||
<CheckOutlined />
|
||||
</template>
|
||||
批量通过
|
||||
</a-button>
|
||||
<a-button
|
||||
:disabled="!selection?.length"
|
||||
@click="exportData"
|
||||
class="ele-btn-icon"
|
||||
>
|
||||
<template #icon>
|
||||
<ExportOutlined />
|
||||
</template>
|
||||
导出数据
|
||||
</a-button>
|
||||
</a-space>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive } from 'vue';
|
||||
import {
|
||||
PlusOutlined,
|
||||
SearchOutlined,
|
||||
CheckOutlined,
|
||||
ExportOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { ShopDealerApplyParam } from '@/api/shop/shopDealerApply/model';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的数据
|
||||
selection?: any[];
|
||||
}>(),
|
||||
{
|
||||
selection: () => []
|
||||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: ShopDealerApplyParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'batchApprove'): void;
|
||||
(e: 'export'): void;
|
||||
}>();
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive<any>({
|
||||
realName: '',
|
||||
mobile: '',
|
||||
applyType: undefined,
|
||||
applyStatus: undefined,
|
||||
dateRange: undefined
|
||||
});
|
||||
|
||||
// 搜索
|
||||
const handleSearch = () => {
|
||||
const searchParams: ShopDealerApplyParam = {};
|
||||
|
||||
if (searchForm.realName) {
|
||||
searchParams.realName = searchForm.realName;
|
||||
}
|
||||
if (searchForm.mobile) {
|
||||
searchParams.mobile = searchForm.mobile;
|
||||
}
|
||||
if (searchForm.applyType) {
|
||||
searchParams.applyType = searchForm.applyType;
|
||||
}
|
||||
if (searchForm.applyStatus) {
|
||||
searchParams.applyStatus = searchForm.applyStatus;
|
||||
}
|
||||
if (searchForm.dateRange && searchForm.dateRange.length === 2) {
|
||||
searchParams.startTime = dayjs(searchForm.dateRange[0]).format(
|
||||
'YYYY-MM-DD'
|
||||
);
|
||||
searchParams.endTime = dayjs(searchForm.dateRange[1]).format(
|
||||
'YYYY-MM-DD'
|
||||
);
|
||||
}
|
||||
|
||||
emit('search', searchParams);
|
||||
};
|
||||
|
||||
// 重置搜索
|
||||
const resetSearch = () => {
|
||||
searchForm.realName = '';
|
||||
searchForm.mobile = '';
|
||||
searchForm.applyType = undefined;
|
||||
searchForm.applyStatus = undefined;
|
||||
searchForm.dateRange = undefined;
|
||||
emit('search', {});
|
||||
};
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 批量通过
|
||||
const batchApprove = () => {
|
||||
emit('batchApprove');
|
||||
};
|
||||
|
||||
// 导出数据
|
||||
const exportData = () => {
|
||||
emit('export');
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.search-container {
|
||||
background: #fff;
|
||||
padding: 16px;
|
||||
border-radius: 6px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
.search-form {
|
||||
margin-bottom: 16px;
|
||||
|
||||
:deep(.ant-form-item) {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
border-top: 1px solid #f0f0f0;
|
||||
padding-top: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
517
src/views/glt/shopDealerUser/index.vue
Normal file
517
src/views/glt/shopDealerUser/index.vue
Normal file
@@ -0,0 +1,517 @@
|
||||
<template>
|
||||
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
|
||||
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="applyId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:customRow="customRow"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-org-table"
|
||||
v-model:selection="selection"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@add="openEdit"
|
||||
@batchApprove="batchApprove"
|
||||
@export="exportData"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'applyStatus'">
|
||||
<a-tag v-if="record.applyStatus === 10" color="orange"
|
||||
>待审核</a-tag
|
||||
>
|
||||
<a-tag v-if="record.applyStatus === 20" color="green">已通过</a-tag>
|
||||
<a-tag v-if="record.applyStatus === 30" color="red">已驳回</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a @click="openEdit(record)" class="ele-text-primary">
|
||||
<EditOutlined />
|
||||
编辑
|
||||
</a>
|
||||
<template v-if="record.applyStatus !== 20">
|
||||
<a-divider type="vertical" />
|
||||
<a @click="approveApply(record)" class="ele-text-success">
|
||||
<CheckOutlined />
|
||||
通过
|
||||
</a>
|
||||
<a-divider type="vertical" />
|
||||
<a @click="rejectApply(record)" class="ele-text-warning">
|
||||
<CloseOutlined />
|
||||
驳回
|
||||
</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
v-if="record.applyStatus != 20"
|
||||
title="确定要删除此申请记录吗?"
|
||||
@confirm="remove(record)"
|
||||
placement="topRight"
|
||||
>
|
||||
<a class="ele-text-danger">
|
||||
<DeleteOutlined />
|
||||
删除
|
||||
</a>
|
||||
</a-popconfirm>
|
||||
</template>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<ShopDealerApplyEdit
|
||||
v-model:visible="showEdit"
|
||||
:data="current"
|
||||
@done="reload"
|
||||
/>
|
||||
</a-page-header>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import {
|
||||
ExclamationCircleOutlined,
|
||||
CheckOutlined,
|
||||
CloseOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import Search from './components/search.vue';
|
||||
import { getPageTitle } from '@/utils/common';
|
||||
import ShopDealerApplyEdit from './components/shopDealerApplyEdit.vue';
|
||||
import {
|
||||
pageShopDealerApply,
|
||||
removeShopDealerApply,
|
||||
removeBatchShopDealerApply,
|
||||
batchApproveShopDealerApply,
|
||||
updateShopDealerApply
|
||||
} from '@/api/shop/shopDealerApply';
|
||||
import type {
|
||||
ShopDealerApply,
|
||||
ShopDealerApplyParam
|
||||
} from '@/api/shop/shopDealerApply/model';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<ShopDealerApply[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<ShopDealerApply | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.status = filters.status;
|
||||
}
|
||||
where.type = 4;
|
||||
where.applyStatus = 20;
|
||||
return pageShopDealerApply({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'applyId',
|
||||
key: 'applyId',
|
||||
align: 'center',
|
||||
width: 80,
|
||||
fixed: 'left'
|
||||
},
|
||||
{
|
||||
title: '申请人信息',
|
||||
key: 'applicantInfo',
|
||||
align: 'left',
|
||||
fixed: 'left',
|
||||
customRender: ({ record }) => {
|
||||
return `${record.realName || '-'} (${record.mobile || '-'})`;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '申请方式',
|
||||
dataIndex: 'applyType',
|
||||
key: 'applyType',
|
||||
align: 'center',
|
||||
width: 120,
|
||||
customRender: ({ text }) => {
|
||||
const typeMap = {
|
||||
10: { text: '需审核', color: 'orange' },
|
||||
20: { text: '免审核', color: 'green' }
|
||||
};
|
||||
const type = typeMap[text] || { text: '未知', color: 'default' };
|
||||
return {
|
||||
type: 'tag',
|
||||
props: { color: type.color },
|
||||
children: type.text
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '审核状态',
|
||||
dataIndex: 'applyStatus',
|
||||
key: 'applyStatus',
|
||||
align: 'center',
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
title: '推荐人',
|
||||
dataIndex: 'refereeId',
|
||||
key: 'refereeId',
|
||||
align: 'center',
|
||||
width: 100,
|
||||
customRender: ({ text }) => (text ? `ID: ${text}` : '无')
|
||||
},
|
||||
// {
|
||||
// title: '申请时间',
|
||||
// dataIndex: 'applyTime',
|
||||
// key: 'applyTime',
|
||||
// align: 'center',
|
||||
// width: 120,
|
||||
// customRender: ({ text }) => text ? toDateString(new Date(text), 'yyyy-MM-dd HH:mm') : '-'
|
||||
// },
|
||||
// {
|
||||
// title: '审核时间',
|
||||
// dataIndex: 'auditTime',
|
||||
// key: 'auditTime',
|
||||
// align: 'center',
|
||||
// customRender: ({ text }) => text ? toDateString(new Date(text), 'yyyy-MM-dd HH:mm') : '-'
|
||||
// },
|
||||
{
|
||||
title: '驳回原因',
|
||||
dataIndex: 'rejectReason',
|
||||
key: 'rejectReason',
|
||||
align: 'left',
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => text || '-'
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
align: 'center',
|
||||
sorter: true,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
width: 380,
|
||||
hideInSetting: true
|
||||
}
|
||||
]);
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: ShopDealerApplyParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
/* 审核通过 */
|
||||
const approveApply = (row: ShopDealerApply) => {
|
||||
Modal.confirm({
|
||||
title: '审核通过确认',
|
||||
content: `确定要通过 ${row.realName} 的经销商申请吗?`,
|
||||
icon: createVNode(CheckOutlined),
|
||||
okText: '确认通过',
|
||||
okType: 'primary',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
const hide = message.loading('正在处理审核...', 0);
|
||||
try {
|
||||
await updateShopDealerApply({
|
||||
...row,
|
||||
applyId: row.applyId,
|
||||
applyStatus: 20
|
||||
});
|
||||
hide();
|
||||
message.success('审核通过成功');
|
||||
reload();
|
||||
} catch (error: any) {
|
||||
hide();
|
||||
message.error(error.message || '审核失败,请重试');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 审核驳回 */
|
||||
const rejectApply = (row: ShopDealerApply) => {
|
||||
let rejectReason = '';
|
||||
Modal.confirm({
|
||||
title: '审核驳回',
|
||||
content: createVNode('div', null, [
|
||||
createVNode('p', null, `申请人: ${row.realName} (${row.mobile})`),
|
||||
createVNode('p', { style: 'margin-top: 12px;' }, '请输入驳回原因:'),
|
||||
createVNode('textarea', {
|
||||
placeholder: '请输入驳回原因...',
|
||||
style:
|
||||
'width: 100%; height: 80px; margin-top: 8px; padding: 8px; border: 1px solid #d9d9d9; border-radius: 4px;',
|
||||
onInput: (e: any) => {
|
||||
rejectReason = e.target.value;
|
||||
}
|
||||
})
|
||||
]),
|
||||
icon: createVNode(CloseOutlined),
|
||||
okText: '确认驳回',
|
||||
okType: 'danger',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
if (!rejectReason.trim()) {
|
||||
message.error('请输入驳回原因');
|
||||
return Promise.reject();
|
||||
}
|
||||
const hide = message.loading('正在处理审核...', 0);
|
||||
try {
|
||||
await updateShopDealerApply({
|
||||
...row,
|
||||
applyStatus: 30,
|
||||
rejectReason: rejectReason.trim()
|
||||
});
|
||||
hide();
|
||||
message.success('审核驳回成功');
|
||||
reload();
|
||||
} catch (error: any) {
|
||||
hide();
|
||||
message.error(error.message || '审核失败,请重试');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: ShopDealerApply) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: ShopDealerApply) => {
|
||||
if (!row.applyId) {
|
||||
message.error('删除失败:缺少必要参数');
|
||||
return;
|
||||
}
|
||||
|
||||
const hide = message.loading('正在删除申请记录...', 0);
|
||||
removeShopDealerApply(row.applyId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg || '删除成功');
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message || '删除失败');
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
|
||||
const validIds = selection.value
|
||||
.filter((d) => d.applyId)
|
||||
.map((d) => d.applyId);
|
||||
if (!validIds.length) {
|
||||
message.error('选中的数据中没有有效的ID');
|
||||
return;
|
||||
}
|
||||
|
||||
Modal.confirm({
|
||||
title: '批量删除确认',
|
||||
content: `确定要删除选中的 ${validIds.length} 条申请记录吗?此操作不可恢复。`,
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
okText: '确认删除',
|
||||
okType: 'danger',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
const hide = message.loading(
|
||||
`正在删除 ${validIds.length} 条记录...`,
|
||||
0
|
||||
);
|
||||
removeBatchShopDealerApply(validIds)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg || `成功删除 ${validIds.length} 条记录`);
|
||||
selection.value = [];
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message || '批量删除失败');
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量通过 */
|
||||
const batchApprove = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
|
||||
const pendingApplies = selection.value.filter(
|
||||
(item) => item.applyStatus === 10
|
||||
);
|
||||
if (!pendingApplies.length) {
|
||||
message.error('所选申请中没有待审核的记录');
|
||||
return;
|
||||
}
|
||||
|
||||
Modal.confirm({
|
||||
title: '批量通过确认',
|
||||
content: `确定要通过选中的 ${pendingApplies.length} 个申请吗?`,
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
okText: '确认通过',
|
||||
okType: 'primary',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
const hide = message.loading('正在批量通过...', 0);
|
||||
try {
|
||||
const ids = pendingApplies.map((item) => item.applyId);
|
||||
await batchApproveShopDealerApply(ids);
|
||||
hide();
|
||||
message.success(`成功通过 ${pendingApplies.length} 个申请`);
|
||||
selection.value = [];
|
||||
reload();
|
||||
} catch (error: any) {
|
||||
hide();
|
||||
message.error(error.message || '批量审核失败,请重试');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 导出数据 */
|
||||
const exportData = () => {
|
||||
const hide = message.loading('正在导出申请数据...', 0);
|
||||
// 这里调用导出API
|
||||
setTimeout(() => {
|
||||
hide();
|
||||
message.success('申请数据导出成功');
|
||||
}, 2000);
|
||||
};
|
||||
|
||||
/* 查询 */
|
||||
const query = () => {
|
||||
loading.value = true;
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: ShopDealerApply) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
query();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'ShopDealerApply'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.sys-org-table {
|
||||
:deep(.ant-table-thead > tr > th) {
|
||||
background-color: #fafafa;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
:deep(.ant-table-tbody > tr:hover > td) {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
}
|
||||
|
||||
.detail-item {
|
||||
p {
|
||||
margin: 4px 0;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
strong {
|
||||
color: #1890ff;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.ele-text-primary {
|
||||
color: #1890ff;
|
||||
|
||||
&:hover {
|
||||
color: #40a9ff;
|
||||
}
|
||||
}
|
||||
|
||||
.ele-text-info {
|
||||
color: #13c2c2;
|
||||
|
||||
&:hover {
|
||||
color: #36cfc9;
|
||||
}
|
||||
}
|
||||
|
||||
.ele-text-success {
|
||||
color: #52c41a;
|
||||
|
||||
&:hover {
|
||||
color: #73d13d;
|
||||
}
|
||||
}
|
||||
|
||||
.ele-text-warning {
|
||||
color: #faad14;
|
||||
|
||||
&:hover {
|
||||
color: #ffc53d;
|
||||
}
|
||||
}
|
||||
|
||||
.ele-text-danger {
|
||||
color: #ff4d4f;
|
||||
|
||||
&:hover {
|
||||
color: #ff7875;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
89
src/views/glt/shopDealerWithdraw/components/Import.vue
Normal file
89
src/views/glt/shopDealerWithdraw/components/Import.vue
Normal file
@@ -0,0 +1,89 @@
|
||||
<!-- 经销商订单导入弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="520"
|
||||
:footer="null"
|
||||
title="导入分销订单"
|
||||
:visible="visible"
|
||||
@update:visible="updateVisible"
|
||||
>
|
||||
<a-spin :spinning="loading">
|
||||
<a-upload-dragger
|
||||
accept=".xls,.xlsx"
|
||||
:show-upload-list="false"
|
||||
:customRequest="doUpload"
|
||||
style="padding: 24px 0; margin-bottom: 16px"
|
||||
>
|
||||
<p class="ant-upload-drag-icon">
|
||||
<cloud-upload-outlined />
|
||||
</p>
|
||||
<p class="ant-upload-hint">将文件拖到此处,或点击上传</p>
|
||||
</a-upload-dragger>
|
||||
<div class="ant-upload-text text-gray-400">
|
||||
<div
|
||||
>1、必须按<a
|
||||
href="https://oss.wsdns.cn/20251018/408b805ec3cd4084a4dc686e130af578.xlsx"
|
||||
target="_blank"
|
||||
>导入模版</a
|
||||
>的格式上传</div
|
||||
>
|
||||
<div>2、导入成功确认结算完成佣金的发放</div>
|
||||
</div>
|
||||
</a-spin>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import { CloudUploadOutlined } from '@ant-design/icons-vue';
|
||||
import { importSdyDealerOrder } from '@/api/sdy/sdyDealerOrder';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
defineProps<{
|
||||
// 是否打开弹窗
|
||||
visible: boolean;
|
||||
}>();
|
||||
|
||||
// 导入请求状态
|
||||
const loading = ref(false);
|
||||
|
||||
/* 上传 */
|
||||
const doUpload = ({ file }) => {
|
||||
if (
|
||||
![
|
||||
'application/vnd.ms-excel',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
].includes(file.type)
|
||||
) {
|
||||
message.error('只能选择 excel 文件');
|
||||
return false;
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 10) {
|
||||
message.error('大小不能超过 10MB');
|
||||
return false;
|
||||
}
|
||||
loading.value = true;
|
||||
importSdyDealerOrder(file)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
return false;
|
||||
};
|
||||
|
||||
/* 更新 visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
</script>
|
||||
101
src/views/glt/shopDealerWithdraw/components/search.vue
Normal file
101
src/views/glt/shopDealerWithdraw/components/search.vue
Normal file
@@ -0,0 +1,101 @@
|
||||
<template>
|
||||
<div class="flex items-center gap-20">
|
||||
<!-- 搜索表单 -->
|
||||
<a-form
|
||||
:model="where"
|
||||
layout="inline"
|
||||
class="search-form"
|
||||
@finish="handleSearch"
|
||||
>
|
||||
<a-form-item>
|
||||
<a-space>
|
||||
<a-button
|
||||
danger
|
||||
class="ele-btn-icon"
|
||||
v-if="selection.length > 0"
|
||||
:disabled="selection?.length === 0"
|
||||
@click="removeBatch"
|
||||
>
|
||||
<template #icon>
|
||||
<DeleteOutlined />
|
||||
</template>
|
||||
<span>批量删除</span>
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item>
|
||||
<a-space>
|
||||
<a-input-search
|
||||
allow-clear
|
||||
placeholder="请输入用户ID"
|
||||
style="width: 240px"
|
||||
v-model:value="where.keywords"
|
||||
@search="handleSearch"
|
||||
/>
|
||||
<a-button @click="resetSearch"> 重置 </a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
|
||||
<!-- 导入弹窗 -->
|
||||
<Import v-model:visible="showImport" @done="emit('importDone')" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { DeleteOutlined } from '@ant-design/icons-vue';
|
||||
import Import from './Import.vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import { ShopDealerWithdrawParam } from '@/api/shop/shopDealerWithdraw/model';
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
// 选中的数据
|
||||
selection?: any[];
|
||||
}>(),
|
||||
{
|
||||
selection: () => []
|
||||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: ShopDealerWithdrawParam): void;
|
||||
(e: 'batchSettle'): void;
|
||||
(e: 'export'): void;
|
||||
(e: 'importDone'): void;
|
||||
(e: 'remove'): void;
|
||||
}>();
|
||||
|
||||
// 是否显示导入弹窗
|
||||
const showImport = ref(false);
|
||||
|
||||
// 搜索表单
|
||||
const { where, resetFields } = useSearch<ShopDealerWithdrawParam>({
|
||||
keywords: ''
|
||||
});
|
||||
|
||||
// 搜索
|
||||
const handleSearch = () => {
|
||||
const searchParams = { ...where };
|
||||
// 清除空值
|
||||
Object.keys(searchParams).forEach((key) => {
|
||||
if (searchParams[key] === '' || searchParams[key] === undefined) {
|
||||
delete searchParams[key];
|
||||
}
|
||||
});
|
||||
emit('search', searchParams);
|
||||
};
|
||||
|
||||
// 重置搜索
|
||||
const resetSearch = () => {
|
||||
resetFields();
|
||||
emit('search', {});
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,697 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="1000"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '编辑提现申请' : '新增提现申请'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<!-- 基本信息 -->
|
||||
<a-divider orientation="left">
|
||||
<span style="color: #1890ff; font-weight: 600">基本信息</span>
|
||||
</a-divider>
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="备注" name="comments">
|
||||
<div class="text-red-500">{{ form.comments }}</div>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<!-- 收款信息 -->
|
||||
<a-divider orientation="left">
|
||||
<span style="color: #1890ff; font-weight: 600">收款信息</span>
|
||||
</a-divider>
|
||||
|
||||
<!-- 微信收款信息 -->
|
||||
<div v-if="form.payType === 10" class="payment-info wechat-info">
|
||||
<a-alert
|
||||
message="微信收款信息"
|
||||
description="请确保微信账号信息准确,以免影响到账"
|
||||
type="success"
|
||||
show-icon
|
||||
style="margin-bottom: 16px"
|
||||
/>
|
||||
<a-form-item label="微信号" name="wechatAccount">
|
||||
<a-input
|
||||
placeholder="请输入微信号"
|
||||
v-model:value="form.wechatAccount"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="微信昵称" name="wechatName">
|
||||
<a-input
|
||||
placeholder="请输入微信昵称"
|
||||
v-model:value="form.wechatName"
|
||||
/>
|
||||
</a-form-item>
|
||||
</div>
|
||||
|
||||
<!-- 支付宝收款信息 -->
|
||||
<div v-if="form.payType === 20" class="payment-info alipay-info">
|
||||
<a-alert
|
||||
message="支付宝收款信息"
|
||||
description="请确保支付宝账号信息准确,姓名需与实名认证一致"
|
||||
type="info"
|
||||
show-icon
|
||||
style="margin-bottom: 16px"
|
||||
/>
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="支付宝姓名" name="alipayName">
|
||||
<a-input
|
||||
placeholder="请输入支付宝实名姓名"
|
||||
disabled
|
||||
v-model:value="form.alipayName"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="支付宝账号" name="alipayAccount">
|
||||
<a-input
|
||||
placeholder="请输入支付宝账号"
|
||||
disabled
|
||||
v-model:value="form.alipayAccount"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
|
||||
<!-- 银行卡收款信息 -->
|
||||
<div v-if="form.payType === 30" class="payment-info bank-info">
|
||||
<a-alert
|
||||
message="银行卡收款信息"
|
||||
description="请确保银行卡信息准确,开户名需与身份证姓名一致"
|
||||
type="warning"
|
||||
show-icon
|
||||
style="margin-bottom: 16px"
|
||||
/>
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="开户行名称" name="bankName">
|
||||
{{ form.bankName }}
|
||||
</a-form-item>
|
||||
<a-form-item label="银行开户名" name="bankAccount">
|
||||
{{ form.bankAccount }}
|
||||
</a-form-item>
|
||||
<a-form-item label="银行卡号" name="bankCard">
|
||||
{{ form.bankCard }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
|
||||
<!-- 审核信息 -->
|
||||
<a-divider orientation="left">
|
||||
<span style="color: #1890ff; font-weight: 600">审核信息</span>
|
||||
</a-divider>
|
||||
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="申请状态" name="applyStatus">
|
||||
<a-select
|
||||
v-model:value="form.applyStatus"
|
||||
:disabled="form.applyStatus == 40 || form.applyStatus == 30"
|
||||
placeholder="请选择申请状态"
|
||||
>
|
||||
<a-select-option :value="10">
|
||||
<div class="status-option">
|
||||
<a-tag color="orange">待审核</a-tag>
|
||||
<span>等待审核</span>
|
||||
</div>
|
||||
</a-select-option>
|
||||
<a-select-option :value="20">
|
||||
<div class="status-option">
|
||||
<a-tag color="success">审核通过</a-tag>
|
||||
<span>审核通过</span>
|
||||
</div>
|
||||
</a-select-option>
|
||||
<a-select-option :value="30">
|
||||
<div class="status-option">
|
||||
<a-tag color="error">审核驳回</a-tag>
|
||||
<span>审核驳回</span>
|
||||
</div>
|
||||
</a-select-option>
|
||||
<a-select-option :value="40">
|
||||
<div class="status-option">
|
||||
<a-tag>已打款</a-tag>
|
||||
<span>已完成打款</span>
|
||||
</div>
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item
|
||||
label="驳回原因"
|
||||
name="rejectReason"
|
||||
v-if="form.applyStatus === 30"
|
||||
>
|
||||
<a-textarea
|
||||
v-model:value="form.rejectReason"
|
||||
placeholder="请输入驳回原因"
|
||||
:rows="3"
|
||||
:maxlength="200"
|
||||
show-count
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="上传支付凭证"
|
||||
name="image"
|
||||
v-if="form.applyStatus === 40"
|
||||
>
|
||||
<SelectFile
|
||||
:placeholder="`请选择图片`"
|
||||
:limit="2"
|
||||
:data="files"
|
||||
@done="chooseFile"
|
||||
@del="onDeleteFile"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<!-- 提现预览 -->
|
||||
<div class="withdraw-preview" v-if="form.money && form.payType">
|
||||
<a-alert
|
||||
:type="getPreviewAlertType()"
|
||||
:message="getPreviewText()"
|
||||
show-icon
|
||||
style="margin-top: 16px"
|
||||
/>
|
||||
</div>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject, uuid } from 'ele-admin-pro';
|
||||
import {
|
||||
addShopDealerWithdraw,
|
||||
updateShopDealerWithdraw
|
||||
} from '@/api/shop/shopDealerWithdraw';
|
||||
import { ShopDealerWithdraw } from '@/api/shop/shopDealerWithdraw/model';
|
||||
import { FormInstance } from 'ant-design-vue/es/form';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import dayjs from 'dayjs';
|
||||
import { FileRecord } from '@/api/system/file/model';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: ShopDealerWithdraw | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref<boolean>(false);
|
||||
const isSuccess = ref<boolean>(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
const files = ref<ItemType[]>([]);
|
||||
// 表格选中数据
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
// 表单数据
|
||||
const form = reactive<ShopDealerWithdraw>({
|
||||
id: undefined,
|
||||
userId: undefined,
|
||||
realName: undefined,
|
||||
nickname: undefined,
|
||||
phone: undefined,
|
||||
avatar: undefined,
|
||||
money: undefined,
|
||||
payType: undefined,
|
||||
// 微信相关
|
||||
wechatAccount: '',
|
||||
wechatName: '',
|
||||
// 支付宝相关
|
||||
alipayName: '',
|
||||
alipayAccount: '',
|
||||
// 银行卡相关
|
||||
bankName: '',
|
||||
bankAccount: '',
|
||||
bankCard: '',
|
||||
// 审核相关
|
||||
applyStatus: 10,
|
||||
auditTime: undefined,
|
||||
rejectReason: '',
|
||||
platform: '',
|
||||
comments: '',
|
||||
tenantId: undefined,
|
||||
createTime: undefined,
|
||||
updateTime: undefined
|
||||
});
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
userId: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入分销商用户ID',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
money: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入提现金额',
|
||||
trigger: 'blur'
|
||||
},
|
||||
{
|
||||
validator: (rule: any, value: any) => {
|
||||
if (value && value <= 0) {
|
||||
return Promise.reject('提现金额必须大于0');
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
payType: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择打款方式',
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
platform: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择来源平台',
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
// 微信验证
|
||||
wechatAccount: [
|
||||
{
|
||||
validator: (rule: any, value: any) => {
|
||||
if (form.payType === 10 && !value) {
|
||||
return Promise.reject('请输入微信号');
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
wechatName: [
|
||||
{
|
||||
validator: (rule: any, value: any) => {
|
||||
if (form.payType === 10 && !value) {
|
||||
return Promise.reject('请输入微信昵称');
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
// 支付宝验证
|
||||
alipayName: [
|
||||
{
|
||||
validator: (rule: any, value: any) => {
|
||||
if (form.payType === 20 && !value) {
|
||||
return Promise.reject('请输入支付宝姓名');
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
alipayAccount: [
|
||||
{
|
||||
validator: (rule: any, value: any) => {
|
||||
if (form.payType === 20 && !value) {
|
||||
return Promise.reject('请输入支付宝账号');
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
// 银行卡验证
|
||||
bankName: [
|
||||
{
|
||||
validator: (rule: any, value: any) => {
|
||||
if (form.payType === 30 && !value) {
|
||||
return Promise.reject('请输入开户行名称');
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
bankAccount: [
|
||||
{
|
||||
validator: (rule: any, value: any) => {
|
||||
if (form.payType === 30 && !value) {
|
||||
return Promise.reject('请输入银行开户名');
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
bankCard: [
|
||||
{
|
||||
validator: (rule: any, value: any) => {
|
||||
if (form.payType === 30 && !value) {
|
||||
return Promise.reject('请输入银行卡号');
|
||||
}
|
||||
if (form.payType === 30 && value && !/^\d{16,19}$/.test(value)) {
|
||||
return Promise.reject('银行卡号格式不正确');
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
applyStatus: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择申请状态',
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
rejectReason: [
|
||||
{
|
||||
validator: (rule: any, value: any) => {
|
||||
if (form.applyStatus === 30 && !value) {
|
||||
return Promise.reject('驳回时必须填写驳回原因');
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
image: [
|
||||
{
|
||||
required: true,
|
||||
message: '请上传打款凭证',
|
||||
trigger: 'change'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
/* 打款方式改变时的处理 */
|
||||
const onPayTypeChange = (e: any) => {
|
||||
const payType = e.target.value;
|
||||
|
||||
// 清空其他支付方式的信息
|
||||
if (payType !== 10) {
|
||||
form.alipayAccount = '';
|
||||
form.alipayName = '';
|
||||
}
|
||||
if (payType !== 20) {
|
||||
form.alipayName = '';
|
||||
form.alipayAccount = '';
|
||||
}
|
||||
if (payType !== 30) {
|
||||
form.bankName = '';
|
||||
form.bankAccount = '';
|
||||
form.bankCard = '';
|
||||
}
|
||||
};
|
||||
|
||||
const chooseFile = (data: FileRecord) => {
|
||||
files.value.push({
|
||||
uid: data.id,
|
||||
url: data.url,
|
||||
status: 'done'
|
||||
});
|
||||
form.image = JSON.stringify(files.value.map((d) => d.url));
|
||||
};
|
||||
|
||||
const onDeleteFile = (index: number) => {
|
||||
files.value.splice(index, 1);
|
||||
};
|
||||
|
||||
/* 获取预览提示类型 */
|
||||
const getPreviewAlertType = () => {
|
||||
if (!form.applyStatus) return 'info';
|
||||
|
||||
switch (form.applyStatus) {
|
||||
case 10:
|
||||
return 'processing';
|
||||
case 20:
|
||||
return 'success';
|
||||
case 30:
|
||||
return 'error';
|
||||
case 40:
|
||||
return 'success';
|
||||
default:
|
||||
return 'info';
|
||||
}
|
||||
};
|
||||
|
||||
/* 获取预览文本 */
|
||||
const getPreviewText = () => {
|
||||
if (!form.money || !form.payType) return '';
|
||||
|
||||
const amount = parseFloat(form.money.toString()).toFixed(2);
|
||||
const payTypeMap = {
|
||||
10: '微信',
|
||||
20: '支付宝',
|
||||
30: '银行卡'
|
||||
};
|
||||
const statusMap = {
|
||||
10: '待审核',
|
||||
20: '审核通过',
|
||||
30: '审核驳回',
|
||||
40: '已打款'
|
||||
};
|
||||
|
||||
const payTypeName = payTypeMap[form.payType] || '未知方式';
|
||||
const statusName = statusMap[form.applyStatus] || '未知状态';
|
||||
|
||||
return `提现金额:¥${amount},打款方式:${payTypeName},当前状态:${statusName}`;
|
||||
};
|
||||
|
||||
const { resetFields } = useForm(form, rules);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
if (isSuccess.value) {
|
||||
console.log('isSuccess');
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
return;
|
||||
}
|
||||
if (form.realName == '' || form.realName == null) {
|
||||
message.error('该用户未完成实名认证!');
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const formData = {
|
||||
...form
|
||||
};
|
||||
|
||||
// 处理时间字段转换
|
||||
if (formData.auditTime && dayjs.isDayjs(formData.auditTime)) {
|
||||
formData.auditTime = formData.auditTime.valueOf();
|
||||
}
|
||||
|
||||
// 根据支付方式清理不相关字段
|
||||
if (formData.payType !== 10) {
|
||||
delete formData.wechatAccount;
|
||||
delete formData.wechatName;
|
||||
}
|
||||
if (formData.payType !== 20) {
|
||||
delete formData.alipayName;
|
||||
delete formData.alipayAccount;
|
||||
}
|
||||
if (formData.payType !== 30) {
|
||||
delete formData.bankName;
|
||||
delete formData.bankAccount;
|
||||
delete formData.bankCard;
|
||||
}
|
||||
|
||||
const saveOrUpdate = isUpdate.value
|
||||
? updateShopDealerWithdraw
|
||||
: addShopDealerWithdraw;
|
||||
saveOrUpdate(formData)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
files.value = [];
|
||||
if (props.data) {
|
||||
assignObject(form, props.data);
|
||||
// 处理时间字段
|
||||
if (props.data.auditTime) {
|
||||
form.auditTime = dayjs(props.data.auditTime);
|
||||
}
|
||||
if (props.data.image) {
|
||||
const arr = JSON.parse(props.data.image);
|
||||
arr.map((url: string) => {
|
||||
files.value.push({
|
||||
uid: uuid(),
|
||||
url: url,
|
||||
status: 'done'
|
||||
});
|
||||
});
|
||||
isSuccess.value = true;
|
||||
}
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
// 重置为默认值
|
||||
Object.assign(form, {
|
||||
id: undefined,
|
||||
userId: undefined,
|
||||
money: undefined,
|
||||
payType: undefined,
|
||||
wechatAccount: '',
|
||||
wechatName: '',
|
||||
alipayName: '',
|
||||
alipayAccount: '',
|
||||
bankName: '',
|
||||
bankAccount: '',
|
||||
bankCard: '',
|
||||
applyStatus: 10,
|
||||
auditTime: undefined,
|
||||
rejectReason: '',
|
||||
platform: '',
|
||||
image: '',
|
||||
tenantId: undefined,
|
||||
createTime: undefined,
|
||||
updateTime: undefined
|
||||
});
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.platform-option,
|
||||
.status-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.ant-tag {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
span {
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.payment-info {
|
||||
background: #fafafa;
|
||||
padding: 16px;
|
||||
border-radius: 6px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
&.wechat-info {
|
||||
border-left: 3px solid #52c41a;
|
||||
}
|
||||
|
||||
&.alipay-info {
|
||||
border-left: 3px solid #1890ff;
|
||||
}
|
||||
|
||||
&.bank-info {
|
||||
border-left: 3px solid #faad14;
|
||||
}
|
||||
}
|
||||
|
||||
.withdraw-preview {
|
||||
:deep(.ant-alert) {
|
||||
.ant-alert-message {
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-divider-horizontal.ant-divider-with-text-left) {
|
||||
margin: 24px 0 16px 0;
|
||||
|
||||
.ant-divider-inner-text {
|
||||
padding: 0 16px 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-form-item) {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
:deep(.ant-radio) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
|
||||
.ant-radio-inner {
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-select-selection-item) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
:deep(.ant-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(.ant-alert) {
|
||||
.ant-alert-message {
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
464
src/views/glt/shopDealerWithdraw/index.vue
Normal file
464
src/views/glt/shopDealerWithdraw/index.vue
Normal file
@@ -0,0 +1,464 @@
|
||||
<template>
|
||||
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
|
||||
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="shopDealerWithdrawId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:customRow="customRow"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-org-table"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
@batchMove="openMove"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'applyStatus'">
|
||||
<a-tag v-if="record.applyStatus === 10" color="orange"
|
||||
>待审核</a-tag
|
||||
>
|
||||
<a-tag v-if="record.applyStatus === 20" color="success"
|
||||
>审核通过</a-tag
|
||||
>
|
||||
<a-tag v-if="record.applyStatus === 30" color="error">已驳回</a-tag>
|
||||
<a-tag v-if="record.applyStatus === 40">已打款</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'userInfo'">
|
||||
<a-space>
|
||||
<a-avatar :src="record.avatar" />
|
||||
<div class="flex flex-col">
|
||||
<span>{{ record.realName || '未实名认证' }}</span>
|
||||
<span class="text-gray-400">{{ record.phone }}</span>
|
||||
</div>
|
||||
</a-space>
|
||||
</template>
|
||||
<template v-if="column.key === 'paymentInfo'">
|
||||
<template v-if="record.payType === 10">
|
||||
<a-space direction="vertical">
|
||||
<a-tag color="blue">微信</a-tag>
|
||||
<span>{{ record.wechatName }}</span>
|
||||
<span>{{ record.wechatName }}</span>
|
||||
</a-space>
|
||||
</template>
|
||||
<template v-if="record.payType === 20">
|
||||
<a-space direction="vertical">
|
||||
<a-tag color="blue">支付宝</a-tag>
|
||||
<span>{{ record.alipayName }}</span>
|
||||
<span>{{ record.alipayAccount }}</span>
|
||||
</a-space>
|
||||
</template>
|
||||
<template v-if="record.payType === 30">
|
||||
<a-space direction="vertical">
|
||||
<a-tag color="blue">银行卡</a-tag>
|
||||
<span>{{ record.bankName }}</span>
|
||||
<span>{{ record.bankAccount }}</span>
|
||||
<span>{{ record.bankCard }}</span>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
<template v-if="column.key === 'comments'">
|
||||
<template v-if="record.applyStatus === 30">
|
||||
<div class="text-red-500"
|
||||
>驳回原因:{{ record.rejectReason }}</div
|
||||
>
|
||||
</template>
|
||||
<template v-if="record.applyStatus === 40 && record.image">
|
||||
<a-image
|
||||
v-for="(item, index) in JSON.parse(record.image)"
|
||||
:key="index"
|
||||
:src="item"
|
||||
:width="50"
|
||||
:height="50"
|
||||
/>
|
||||
</template>
|
||||
</template>
|
||||
<template v-if="column.key === 'createTime'">
|
||||
<a-space direction="vertical">
|
||||
<a-tooltip title="创建时间">{{ record.createTime }}</a-tooltip>
|
||||
<a-tooltip title="审核/打款时间" class="text-green-500">{{
|
||||
record.auditTime
|
||||
}}</a-tooltip>
|
||||
</a-space>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<template v-if="record.applyStatus !== 40">
|
||||
<a @click="openEdit(record)" class="ele-text-primary">
|
||||
<EditOutlined />
|
||||
编辑
|
||||
</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
title="确定要删除此提现记录吗?"
|
||||
@confirm="remove(record)"
|
||||
placement="topRight"
|
||||
>
|
||||
<a class="ele-text-danger">
|
||||
<DeleteOutlined />
|
||||
删除
|
||||
</a>
|
||||
</a-popconfirm>
|
||||
</template>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<ShopDealerWithdrawEdit
|
||||
v-model:visible="showEdit"
|
||||
:data="current"
|
||||
@done="reload"
|
||||
/>
|
||||
</a-page-header>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import {
|
||||
ExclamationCircleOutlined,
|
||||
CheckOutlined,
|
||||
CloseOutlined,
|
||||
DollarOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import Search from './components/search.vue';
|
||||
import { getPageTitle } from '@/utils/common';
|
||||
import ShopDealerWithdrawEdit from './components/shopDealerWithdrawEdit.vue';
|
||||
import {
|
||||
pageShopDealerWithdraw,
|
||||
removeShopDealerWithdraw,
|
||||
removeBatchShopDealerWithdraw,
|
||||
updateShopDealerWithdraw
|
||||
} from '@/api/shop/shopDealerWithdraw';
|
||||
import type {
|
||||
ShopDealerWithdraw,
|
||||
ShopDealerWithdrawParam
|
||||
} from '@/api/shop/shopDealerWithdraw/model';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<ShopDealerWithdraw[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<ShopDealerWithdraw | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 是否显示批量移动弹窗
|
||||
const showMove = ref(false);
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.status = filters.status;
|
||||
}
|
||||
return pageShopDealerWithdraw({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: '用户ID',
|
||||
dataIndex: 'userId',
|
||||
key: 'userId',
|
||||
align: 'center',
|
||||
width: 90,
|
||||
fixed: 'left'
|
||||
},
|
||||
{
|
||||
title: '提现金额',
|
||||
dataIndex: 'money',
|
||||
key: 'money',
|
||||
align: 'center',
|
||||
width: 150,
|
||||
customRender: ({ text }) => {
|
||||
const amount = parseFloat(text || '0').toFixed(2);
|
||||
return {
|
||||
type: 'span',
|
||||
children: `¥${amount}`
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '用户信息',
|
||||
dataIndex: 'userInfo',
|
||||
key: 'userInfo'
|
||||
},
|
||||
{
|
||||
title: '收款信息',
|
||||
dataIndex: 'paymentInfo',
|
||||
key: 'paymentInfo'
|
||||
},
|
||||
// {
|
||||
// title: '审核时间',
|
||||
// dataIndex: 'auditTime',
|
||||
// key: 'auditTime',
|
||||
// align: 'center',
|
||||
// width: 120,
|
||||
// customRender: ({ text }) => text ? toDateString(new Date(text), 'yyyy-MM-dd HH:mm') : '-'
|
||||
// },
|
||||
// {
|
||||
// title: '驳回原因',
|
||||
// dataIndex: 'rejectReason',
|
||||
// key: 'rejectReason',
|
||||
// align: 'left',
|
||||
// ellipsis: true,
|
||||
// customRender: ({ text }) => text || '-'
|
||||
// },
|
||||
// {
|
||||
// title: '来源平台',
|
||||
// dataIndex: 'platform',
|
||||
// key: 'platform',
|
||||
// align: 'center',
|
||||
// width: 100,
|
||||
// customRender: ({ text }) => text || '-'
|
||||
// },
|
||||
{
|
||||
title: '备注',
|
||||
dataIndex: 'comments',
|
||||
key: 'comments'
|
||||
},
|
||||
{
|
||||
title: '申请状态',
|
||||
dataIndex: 'applyStatus',
|
||||
key: 'applyStatus',
|
||||
align: 'center',
|
||||
width: 150
|
||||
},
|
||||
// {
|
||||
// title: '驳回原因',
|
||||
// dataIndex: 'rejectReason',
|
||||
// key: 'rejectReason',
|
||||
// align: 'center',
|
||||
// },
|
||||
// {
|
||||
// title: '来源客户端',
|
||||
// dataIndex: 'platform',
|
||||
// key: 'platform',
|
||||
// align: 'center',
|
||||
// },
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
align: 'center',
|
||||
width: 180,
|
||||
sorter: true,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd HH:mm:ss')
|
||||
}
|
||||
// {
|
||||
// title: '操作',
|
||||
// key: 'action',
|
||||
// width: 180,
|
||||
// fixed: 'right',
|
||||
// align: 'center',
|
||||
// hideInSetting: true
|
||||
// }
|
||||
]);
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: ShopDealerWithdrawParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
/* 审核通过 */
|
||||
const approveWithdraw = (row: ShopDealerWithdraw) => {
|
||||
Modal.confirm({
|
||||
title: '审核通过确认',
|
||||
content: `已核对信息进行核对,正确无误!`,
|
||||
icon: createVNode(CheckOutlined),
|
||||
okText: '确认通过',
|
||||
okType: 'primary',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
const hide = message.loading('正在处理审核...', 0);
|
||||
// 这里需要调用审核通过的API
|
||||
setTimeout(() => {
|
||||
hide();
|
||||
updateShopDealerWithdraw({
|
||||
id: row.id,
|
||||
applyStatus: 20
|
||||
});
|
||||
message.success('审核通过成功');
|
||||
reload();
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 审核驳回 */
|
||||
const rejectWithdraw = (row: ShopDealerWithdraw) => {
|
||||
let rejectReason = '';
|
||||
Modal.confirm({
|
||||
title: '审核驳回',
|
||||
content: createVNode('div', null, [
|
||||
createVNode('p', null, `用户ID: ${row.userId}`),
|
||||
createVNode(
|
||||
'p',
|
||||
null,
|
||||
`提现金额: ¥${parseFloat(row.money || '0').toFixed(2)}`
|
||||
),
|
||||
createVNode('p', { style: 'margin-top: 12px;' }, '请输入驳回原因:'),
|
||||
createVNode('textarea', {
|
||||
placeholder: '请输入驳回原因...',
|
||||
style:
|
||||
'width: 100%; height: 80px; margin-top: 8px; padding: 8px; border: 1px solid #d9d9d9; border-radius: 4px;',
|
||||
onInput: (e: any) => {
|
||||
rejectReason = e.target.value;
|
||||
}
|
||||
})
|
||||
]),
|
||||
icon: createVNode(CloseOutlined),
|
||||
okText: '确认驳回',
|
||||
okType: 'danger',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
if (!rejectReason.trim()) {
|
||||
message.error('请输入驳回原因');
|
||||
return Promise.reject();
|
||||
}
|
||||
const hide = message.loading('正在处理审核...', 0);
|
||||
setTimeout(() => {
|
||||
hide();
|
||||
message.success('审核驳回成功');
|
||||
reload();
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 确认打款 */
|
||||
const confirmPayment = (row: ShopDealerWithdraw) => {
|
||||
Modal.confirm({
|
||||
title: '确认打款',
|
||||
content: `确定已向用户${row.bankAccount}完成打款?此操作不可撤销`,
|
||||
icon: createVNode(DollarOutlined),
|
||||
okText: '确认打款',
|
||||
okType: 'primary',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
const hide = message.loading('正在确认打款...', 0);
|
||||
setTimeout(() => {
|
||||
updateShopDealerWithdraw({
|
||||
id: row.id,
|
||||
applyStatus: 40
|
||||
});
|
||||
hide();
|
||||
message.success('打款确认成功');
|
||||
reload();
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: ShopDealerWithdraw) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开批量移动弹窗 */
|
||||
const openMove = () => {
|
||||
showMove.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: ShopDealerWithdraw) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeShopDealerWithdraw(row.id)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchShopDealerWithdraw(selection.value.map((d) => d.id))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 查询 */
|
||||
const query = () => {
|
||||
loading.value = true;
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: ShopDealerWithdraw) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
query();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'ShopDealerWithdraw'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
221
src/views/shop/shopDealerApplyRs/components/search.vue
Normal file
221
src/views/shop/shopDealerApplyRs/components/search.vue
Normal file
@@ -0,0 +1,221 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<div class="search-container">
|
||||
<!-- 搜索表单 -->
|
||||
<a-form
|
||||
:model="searchForm"
|
||||
layout="inline"
|
||||
class="search-form"
|
||||
@finish="handleSearch"
|
||||
>
|
||||
<a-form-item label="申请人姓名">
|
||||
<a-input
|
||||
v-model:value="searchForm.realName"
|
||||
placeholder="请输入申请人姓名"
|
||||
allow-clear
|
||||
style="width: 160px"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="手机号码">
|
||||
<a-input
|
||||
v-model:value="searchForm.mobile"
|
||||
placeholder="请输入手机号码"
|
||||
allow-clear
|
||||
style="width: 160px"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="申请方式">
|
||||
<a-select
|
||||
v-model:value="searchForm.applyType"
|
||||
placeholder="全部方式"
|
||||
allow-clear
|
||||
style="width: 120px"
|
||||
>
|
||||
<a-select-option :value="10">需要审核</a-select-option>
|
||||
<a-select-option :value="20">免审核</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="审核状态">
|
||||
<a-select
|
||||
v-model:value="searchForm.applyStatus"
|
||||
placeholder="全部状态"
|
||||
allow-clear
|
||||
style="width: 120px"
|
||||
>
|
||||
<a-select-option :value="10">待审核</a-select-option>
|
||||
<a-select-option :value="20">审核通过</a-select-option>
|
||||
<a-select-option :value="30">审核驳回</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="申请时间">
|
||||
<a-range-picker
|
||||
v-model:value="searchForm.dateRange"
|
||||
style="width: 240px"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item>
|
||||
<a-space>
|
||||
<a-button type="primary" html-type="submit" class="ele-btn-icon">
|
||||
<template #icon>
|
||||
<SearchOutlined />
|
||||
</template>
|
||||
搜索
|
||||
</a-button>
|
||||
<a-button @click="resetSearch"> 重置 </a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<div class="action-buttons">
|
||||
<a-space>
|
||||
<!-- <a-button type="primary" @click="add" class="ele-btn-icon">-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <PlusOutlined />-->
|
||||
<!-- </template>-->
|
||||
<!-- 新增申请-->
|
||||
<!-- </a-button>-->
|
||||
<a-button
|
||||
type="primary"
|
||||
ghost
|
||||
:disabled="!selection?.length"
|
||||
@click="batchApprove"
|
||||
class="ele-btn-icon"
|
||||
>
|
||||
<template #icon>
|
||||
<CheckOutlined />
|
||||
</template>
|
||||
批量通过
|
||||
</a-button>
|
||||
<a-button
|
||||
:disabled="!selection?.length"
|
||||
@click="exportData"
|
||||
class="ele-btn-icon"
|
||||
>
|
||||
<template #icon>
|
||||
<ExportOutlined />
|
||||
</template>
|
||||
导出数据
|
||||
</a-button>
|
||||
</a-space>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive } from 'vue';
|
||||
import {
|
||||
PlusOutlined,
|
||||
SearchOutlined,
|
||||
CheckOutlined,
|
||||
ExportOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { ShopDealerApplyParam } from '@/api/shop/shopDealerApply/model';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的数据
|
||||
selection?: any[];
|
||||
}>(),
|
||||
{
|
||||
selection: () => []
|
||||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: ShopDealerApplyParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'batchApprove'): void;
|
||||
(e: 'export'): void;
|
||||
}>();
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive<any>({
|
||||
realName: '',
|
||||
mobile: '',
|
||||
applyType: undefined,
|
||||
applyStatus: undefined,
|
||||
dateRange: undefined
|
||||
});
|
||||
|
||||
// 搜索
|
||||
const handleSearch = () => {
|
||||
const searchParams: ShopDealerApplyParam = {};
|
||||
|
||||
if (searchForm.realName) {
|
||||
searchParams.realName = searchForm.realName;
|
||||
}
|
||||
if (searchForm.mobile) {
|
||||
searchParams.mobile = searchForm.mobile;
|
||||
}
|
||||
if (searchForm.applyType) {
|
||||
searchParams.applyType = searchForm.applyType;
|
||||
}
|
||||
if (searchForm.applyStatus) {
|
||||
searchParams.applyStatus = searchForm.applyStatus;
|
||||
}
|
||||
if (searchForm.dateRange && searchForm.dateRange.length === 2) {
|
||||
searchParams.startTime = dayjs(searchForm.dateRange[0]).format(
|
||||
'YYYY-MM-DD'
|
||||
);
|
||||
searchParams.endTime = dayjs(searchForm.dateRange[1]).format(
|
||||
'YYYY-MM-DD'
|
||||
);
|
||||
}
|
||||
|
||||
emit('search', searchParams);
|
||||
};
|
||||
|
||||
// 重置搜索
|
||||
const resetSearch = () => {
|
||||
searchForm.realName = '';
|
||||
searchForm.mobile = '';
|
||||
searchForm.applyType = undefined;
|
||||
searchForm.applyStatus = undefined;
|
||||
searchForm.dateRange = undefined;
|
||||
emit('search', {});
|
||||
};
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 批量通过
|
||||
const batchApprove = () => {
|
||||
emit('batchApprove');
|
||||
};
|
||||
|
||||
// 导出数据
|
||||
const exportData = () => {
|
||||
emit('export');
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.search-container {
|
||||
background: #fff;
|
||||
padding: 16px;
|
||||
border-radius: 6px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
.search-form {
|
||||
margin-bottom: 16px;
|
||||
|
||||
:deep(.ant-form-item) {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
border-top: 1px solid #f0f0f0;
|
||||
padding-top: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,88 @@
|
||||
<!-- 经销商申请批量导入弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="520"
|
||||
:footer="null"
|
||||
title="经销商申请批量导入"
|
||||
:visible="visible"
|
||||
@update:visible="updateVisible"
|
||||
>
|
||||
<a-spin :spinning="loading">
|
||||
<a-upload-dragger
|
||||
accept=".xls,.xlsx"
|
||||
:show-upload-list="false"
|
||||
:customRequest="doUpload"
|
||||
style="padding: 24px 0; margin-bottom: 16px"
|
||||
>
|
||||
<p class="ant-upload-drag-icon">
|
||||
<cloud-upload-outlined />
|
||||
</p>
|
||||
<p class="ant-upload-hint">将文件拖到此处,或点击上传</p>
|
||||
</a-upload-dragger>
|
||||
</a-spin>
|
||||
<div class="ele-text-center">
|
||||
<span>只能上传xls、xlsx文件,</span>
|
||||
<a
|
||||
href="https://cms-api.websoft.top/api/shop/shop-dealer-apply/import/template"
|
||||
download="经销商申请导入模板.xlsx"
|
||||
>
|
||||
下载导入模板
|
||||
</a>
|
||||
</div>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import { CloudUploadOutlined } from '@ant-design/icons-vue';
|
||||
import { importShopDealerApplies } from '@/api/shop/shopDealerApply';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
defineProps<{
|
||||
// 是否打开弹窗
|
||||
visible: boolean;
|
||||
}>();
|
||||
|
||||
// 导入请求状态
|
||||
const loading = ref(false);
|
||||
|
||||
/* 上传 */
|
||||
const doUpload = ({ file }) => {
|
||||
if (
|
||||
![
|
||||
'application/vnd.ms-excel',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
].includes(file.type)
|
||||
) {
|
||||
message.error('只能选择 excel 文件');
|
||||
return false;
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 10) {
|
||||
message.error('大小不能超过 10MB');
|
||||
return false;
|
||||
}
|
||||
loading.value = true;
|
||||
importShopDealerApplies(file)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
return false;
|
||||
};
|
||||
|
||||
/* 更新 visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,298 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="600"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '编辑企业' : '新增企业'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="{ span: 4 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<a-form-item label="企业名称" name="dealerName">
|
||||
<a-input placeholder="请输入企业名称" v-model:value="form.dealerName" />
|
||||
</a-form-item>
|
||||
<a-form-item label="入市状态" name="applyStatus">
|
||||
<a-select
|
||||
v-model:value="form.applyStatus"
|
||||
placeholder="请选择入市状态"
|
||||
@change="handleStatusChange"
|
||||
>
|
||||
<a-select-option :value="10">
|
||||
<a-tag>未入市</a-tag>
|
||||
<span style="margin-left: 8px">未入市</span>
|
||||
</a-select-option>
|
||||
<a-select-option :value="20">
|
||||
<a-tag color="success">已入市</a-tag>
|
||||
<span style="margin-left: 8px">已入市</span>
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
import {
|
||||
addShopDealerApply,
|
||||
updateShopDealerApply
|
||||
} from '@/api/shop/shopDealerApply';
|
||||
import { ShopDealerApply } from '@/api/shop/shopDealerApply/model';
|
||||
import { FormInstance } from 'ant-design-vue/es/form';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: ShopDealerApply | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
// 表格选中数据
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
// 表单数据
|
||||
const form = reactive<ShopDealerApply>({
|
||||
applyId: undefined,
|
||||
type: 3,
|
||||
userId: undefined,
|
||||
dealerName: '',
|
||||
realName: '',
|
||||
mobile: '',
|
||||
refereeId: undefined,
|
||||
applyType: 10,
|
||||
applyTime: undefined,
|
||||
applyStatus: 10,
|
||||
auditTime: undefined,
|
||||
rejectReason: '',
|
||||
tenantId: undefined,
|
||||
createTime: undefined,
|
||||
updateTime: undefined
|
||||
});
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
dealerName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入经销商名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
realName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入企业名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
applyStatus: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择审核状态',
|
||||
trigger: 'change'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const { resetFields } = useForm(form, rules);
|
||||
|
||||
/* 处理审核状态变化 */
|
||||
const handleStatusChange = (value: number) => {
|
||||
// 当状态改为审核通过或驳回时,自动设置审核时间为当前时间
|
||||
if ((value === 20 || value === 30) && !form.auditTime) {
|
||||
form.auditTime = dayjs();
|
||||
}
|
||||
// 当状态改为待审核时,清空审核时间和驳回原因
|
||||
if (value === 10) {
|
||||
form.auditTime = undefined;
|
||||
form.rejectReason = '';
|
||||
}
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 动态验证规则
|
||||
const validateFields: string[] = [
|
||||
'userId',
|
||||
'realName',
|
||||
'mobile',
|
||||
'applyStatus'
|
||||
];
|
||||
|
||||
// 如果是驳回状态,需要验证驳回原因
|
||||
if (form.applyStatus === 30) {
|
||||
validateFields.push('rejectReason');
|
||||
}
|
||||
|
||||
// 如果是审核通过或驳回状态,需要验证审核时间
|
||||
if (form.applyStatus === 20 || form.applyStatus === 30) {
|
||||
validateFields.push('auditTime');
|
||||
}
|
||||
|
||||
formRef.value
|
||||
.validate(validateFields)
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const formData = {
|
||||
...form
|
||||
};
|
||||
|
||||
// 处理时间字段转换 - 转换为ISO字符串格式
|
||||
if (formData.applyTime) {
|
||||
if (dayjs.isDayjs(formData.applyTime)) {
|
||||
formData.applyTime = formData.applyTime.format(
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
);
|
||||
} else if (typeof formData.applyTime === 'number') {
|
||||
formData.applyTime = dayjs(formData.applyTime).format(
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (formData.auditTime) {
|
||||
if (dayjs.isDayjs(formData.auditTime)) {
|
||||
formData.auditTime = formData.auditTime.format(
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
);
|
||||
} else if (typeof formData.auditTime === 'number') {
|
||||
formData.auditTime = dayjs(formData.auditTime).format(
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 当审核状态为通过或驳回时,确保有审核时间
|
||||
if (
|
||||
(formData.applyStatus === 20 || formData.applyStatus === 30) &&
|
||||
!formData.auditTime
|
||||
) {
|
||||
formData.auditTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
||||
}
|
||||
|
||||
// 当状态为待审核时,清空审核时间
|
||||
if (formData.applyStatus === 10) {
|
||||
formData.auditTime = undefined;
|
||||
}
|
||||
|
||||
const saveOrUpdate = isUpdate.value
|
||||
? updateShopDealerApply
|
||||
: addShopDealerApply;
|
||||
saveOrUpdate(formData)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
assignObject(form, props.data);
|
||||
// 处理时间字段 - 确保转换为dayjs对象
|
||||
if (props.data.applyTime) {
|
||||
form.applyTime = dayjs(props.data.applyTime);
|
||||
}
|
||||
if (props.data.auditTime) {
|
||||
form.auditTime = dayjs(props.data.auditTime);
|
||||
}
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
// 重置为默认值
|
||||
Object.assign(form, {
|
||||
applyId: undefined,
|
||||
userId: undefined,
|
||||
realName: '',
|
||||
mobile: '',
|
||||
refereeId: undefined,
|
||||
applyType: 10,
|
||||
applyTime: dayjs(),
|
||||
applyStatus: 10,
|
||||
auditTime: undefined,
|
||||
rejectReason: '',
|
||||
tenantId: undefined,
|
||||
createTime: undefined,
|
||||
updateTime: undefined
|
||||
});
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
:deep(.ant-divider-horizontal.ant-divider-with-text-left) {
|
||||
margin: 24px 0 16px 0;
|
||||
|
||||
.ant-divider-inner-text {
|
||||
padding: 0 16px 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-form-item) {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
:deep(.ant-radio) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
|
||||
.ant-radio-inner {
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-select-selection-item) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
301
src/views/shop/shopDealerApplyRs/index.vue
Normal file
301
src/views/shop/shopDealerApplyRs/index.vue
Normal file
@@ -0,0 +1,301 @@
|
||||
<template>
|
||||
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="applyId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
class="sys-org-table"
|
||||
:scroll="{ x: 1300 }"
|
||||
:where="defaultWhere"
|
||||
:customRow="customRow"
|
||||
cache-key="proSystemShopDealerApplyTable"
|
||||
>
|
||||
<template #toolbar>
|
||||
<a-space>
|
||||
<a-button type="primary" class="ele-btn-icon" @click="openEdit()">
|
||||
<template #icon>
|
||||
<plus-outlined />
|
||||
</template>
|
||||
<span>添加</span>
|
||||
</a-button>
|
||||
<a-button class="ele-btn-icon" @click="openImport()">
|
||||
<template #icon>
|
||||
<cloud-upload-outlined />
|
||||
</template>
|
||||
<span>导入</span>
|
||||
</a-button>
|
||||
<!-- <a-button class="ele-btn-icon" @click="exportData()" :loading="exportLoading">-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <download-outlined/>-->
|
||||
<!-- </template>-->
|
||||
<!-- <span>导出</span>-->
|
||||
<!-- </a-button>-->
|
||||
<a-input-search
|
||||
allow-clear
|
||||
v-model:value="searchText"
|
||||
placeholder="请输入关键词"
|
||||
@search="reload"
|
||||
@pressEnter="reload"
|
||||
/>
|
||||
</a-space>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'applyStatus'">
|
||||
<span class="text-green-500" v-if="record.applyStatus == 20"
|
||||
>已入市</span
|
||||
>
|
||||
<span class="text-gray-300" v-else>未入市</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<div>
|
||||
<a @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
placement="topRight"
|
||||
title="确定要删除此用户吗?"
|
||||
@confirm="remove(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
<!-- 编辑弹窗 -->
|
||||
<ShopDealerApplyEdit
|
||||
v-model:visible="showEdit"
|
||||
:data="current"
|
||||
:organization-list="data"
|
||||
@done="reload"
|
||||
/>
|
||||
<!-- 导入弹窗 -->
|
||||
<ShopDealerApplyImport v-model:visible="showImport" @done="reload" />
|
||||
</a-page-header>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import { PlusOutlined, CloudUploadOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro/es';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { messageLoading } from 'ele-admin-pro/es';
|
||||
import ShopDealerApplyEdit from './components/shopDealerApplyEdit.vue';
|
||||
import ShopDealerApplyImport from './components/shop-dealer-apply-import.vue';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import { utils, writeFile } from 'xlsx';
|
||||
import dayjs from 'dayjs';
|
||||
import { Organization } from '@/api/system/organization/model';
|
||||
import { getPageTitle } from '@/utils/common';
|
||||
import router from '@/router';
|
||||
import {
|
||||
listShopDealerApply,
|
||||
pageShopDealerApply,
|
||||
removeShopDealerApply
|
||||
} from '@/api/shop/shopDealerApply';
|
||||
import {
|
||||
ShopDealerApply,
|
||||
ShopDealerApplyParam
|
||||
} from '@/api/shop/shopDealerApply/model';
|
||||
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
// 树形数据
|
||||
const data = ref<Organization[]>([]);
|
||||
// 树展开的key
|
||||
const expandedRowKeys = ref<number[]>([]);
|
||||
// 树选中的key
|
||||
const selectedRowKeys = ref<number[]>([]);
|
||||
// 表格选中数据
|
||||
const selection = ref<ShopDealerApply[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<ShopDealerApply | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 是否显示用户导入弹窗
|
||||
const showImport = ref(false);
|
||||
// 导出加载状态
|
||||
const exportLoading = ref(false);
|
||||
const searchText = ref('');
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
// {
|
||||
// title: 'ID',
|
||||
// dataIndex: 'userId',
|
||||
// width: 90,
|
||||
// showSorterTooltip: false
|
||||
// },
|
||||
{
|
||||
title: '企业名称',
|
||||
dataIndex: 'dealerName',
|
||||
align: 'dealerName',
|
||||
showSorterTooltip: false
|
||||
},
|
||||
{
|
||||
title: '入市情况',
|
||||
dataIndex: 'applyStatus',
|
||||
key: 'applyStatus',
|
||||
align: 'center',
|
||||
sorter: true
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
sorter: true,
|
||||
align: 'center',
|
||||
showSorterTooltip: false,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd HH:mm:ss')
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
align: 'center'
|
||||
}
|
||||
]);
|
||||
|
||||
// 默认搜索条件
|
||||
const defaultWhere = reactive({
|
||||
username: '',
|
||||
nickname: ''
|
||||
});
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
|
||||
where = {};
|
||||
where.keywords = searchText.value;
|
||||
where.type = 3;
|
||||
return pageShopDealerApply({ page, limit, ...where, ...orders });
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: ShopDealerApplyParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where });
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: ShopDealerApply) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
/* 打开编辑弹窗 */
|
||||
const openImport = () => {
|
||||
showImport.value = true;
|
||||
};
|
||||
|
||||
/* 导出数据 */
|
||||
const exportData = async () => {
|
||||
exportLoading.value = true;
|
||||
|
||||
try {
|
||||
// 定义表头
|
||||
const array: (string | number)[][] = [
|
||||
['ID', '企业名称', '联系方式', '入市状态', '创建时间']
|
||||
];
|
||||
|
||||
// 构建查询参数,使用当前搜索条件
|
||||
const params = {
|
||||
keywords: searchText.value,
|
||||
isAdmin: 0
|
||||
};
|
||||
|
||||
// 获取用户列表数据
|
||||
const list = await listShopDealerApply(params);
|
||||
|
||||
if (!list || list.length === 0) {
|
||||
message.warning('没有数据可以导出');
|
||||
exportLoading.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// 将数据转换为Excel行
|
||||
list.forEach((user: ShopDealerApply) => {
|
||||
array.push([
|
||||
`${user.applyId || ''}`,
|
||||
`${user.realName || ''}`,
|
||||
`${user.mobile || ''}`,
|
||||
`${user.applyStatus === 20 ? '通过' : '未通过'}`,
|
||||
`${user.createTime || ''}`
|
||||
]);
|
||||
});
|
||||
|
||||
// 生成Excel文件
|
||||
const sheetName = `导出企业入市${dayjs(new Date()).format('YYYYMMDD')}`;
|
||||
const workbook = {
|
||||
SheetNames: [sheetName],
|
||||
Sheets: {}
|
||||
};
|
||||
const sheet = utils.aoa_to_sheet(array);
|
||||
workbook.Sheets[sheetName] = sheet;
|
||||
|
||||
// 设置列宽
|
||||
sheet['!cols'] = [];
|
||||
|
||||
message.loading('正在生成Excel文件...', 0);
|
||||
|
||||
setTimeout(() => {
|
||||
writeFile(workbook, `${sheetName}.xlsx`);
|
||||
exportLoading.value = false;
|
||||
message.destroy();
|
||||
message.success(`成功导出 ${list.length} 条记录`);
|
||||
}, 1000);
|
||||
} catch (error: any) {
|
||||
exportLoading.value = false;
|
||||
message.error(error.message || '导出失败');
|
||||
}
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: ShopDealerApply) => {
|
||||
const hide = messageLoading('请求中..', 0);
|
||||
removeShopDealerApply(row.applyId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: ShopDealerApply) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
watch(
|
||||
() => router.currentRoute.value.query,
|
||||
() => {},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'ShopDealerApplyRs'
|
||||
};
|
||||
</script>
|
||||
@@ -1,19 +1,28 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-button type="primary" class="ele-btn-icon" @click="add">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>添加</span>
|
||||
</a-button>
|
||||
<a-input-search
|
||||
allow-clear
|
||||
placeholder="用户ID|订单编号"
|
||||
style="width: 240px"
|
||||
v-model:value="where.keywords"
|
||||
@search="reload"
|
||||
/>
|
||||
<a-button type="dashed" @click="handleExport">导出xls</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { PlusOutlined } from '@ant-design/icons-vue';
|
||||
import type { GradeParam } from '@/api/user/grade/model';
|
||||
import { watch } from 'vue';
|
||||
import { ref, watch } from 'vue';
|
||||
import { utils, writeFile } from 'xlsx';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { pageShopDealerCapital } from '@/api/shop/shopDealerCapital';
|
||||
import {
|
||||
ShopDealerCapital,
|
||||
ShopDealerCapitalParam
|
||||
} from '@/api/shop/shopDealerCapital/model';
|
||||
import { getTenantId } from '@/utils/domain';
|
||||
import useSearch from '@/utils/use-search';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -24,15 +33,81 @@
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: GradeParam): void;
|
||||
(e: 'search', where?: ShopDealerCapitalParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
(e: 'batchMove'): void;
|
||||
}>();
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
const reload = () => {
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const { where } = useSearch<ShopDealerCapitalParam>({
|
||||
keywords: '',
|
||||
userId: undefined,
|
||||
toUserId: undefined,
|
||||
limit: 5000
|
||||
});
|
||||
|
||||
const list = ref<ShopDealerCapital[]>([]);
|
||||
|
||||
// 导出
|
||||
const handleExport = async () => {
|
||||
const array: (string | number)[][] = [
|
||||
[
|
||||
'订单号',
|
||||
'用户',
|
||||
'收益类型',
|
||||
'金额',
|
||||
'描述',
|
||||
'创建时间',
|
||||
'租户ID'
|
||||
]
|
||||
];
|
||||
|
||||
// 按搜索结果导出
|
||||
await pageShopDealerCapital(where)
|
||||
.then((data) => {
|
||||
list.value = data?.list || [];
|
||||
list.value?.forEach((d: ShopDealerCapital) => {
|
||||
array.push([
|
||||
`${d.orderNo}`,
|
||||
`${d.nickName}(${d.userId})`,
|
||||
`${d.flowType == 10 ? '佣金收入' : ''}`,
|
||||
`${d.money}`,
|
||||
`${d.comments}`,
|
||||
`${d.createTime}`,
|
||||
`${d.tenantId}`
|
||||
]);
|
||||
});
|
||||
const sheetName = `bak_shop_dealer_capital_${getTenantId()}`;
|
||||
const workbook = {
|
||||
SheetNames: [sheetName],
|
||||
Sheets: {}
|
||||
};
|
||||
const sheet = utils.aoa_to_sheet(array);
|
||||
workbook.Sheets[sheetName] = sheet;
|
||||
// 设置列宽
|
||||
sheet['!cols'] = [
|
||||
{ wch: 10 },
|
||||
{ wch: 20 },
|
||||
{ wch: 20 },
|
||||
{ wch: 15 },
|
||||
{ wch: 10 },
|
||||
{ wch: 10 },
|
||||
{ wch: 20 }
|
||||
];
|
||||
message.loading('正在导出...');
|
||||
setTimeout(() => {
|
||||
writeFile(workbook, `${sheetName}.xlsx`);
|
||||
}, 1000);
|
||||
})
|
||||
.catch((msg) => {
|
||||
message.error(msg);
|
||||
})
|
||||
.finally(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
<template v-if="column.key === 'image'">
|
||||
<a-image :src="record.image" :width="50" />
|
||||
</template>
|
||||
<template v-if="column.key === 'userId'">
|
||||
<div>{{ record.nickName }}({{ record.userId }})</div>
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
|
||||
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
|
||||
@@ -57,7 +60,6 @@
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
@@ -111,33 +113,39 @@
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id',
|
||||
key: 'id',
|
||||
key: 'index',
|
||||
width: 48,
|
||||
align: 'center',
|
||||
width: 80,
|
||||
fixed: 'left'
|
||||
fixed: 'left',
|
||||
hideInSetting: true,
|
||||
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
{
|
||||
title: '用户ID',
|
||||
title: '订单号',
|
||||
dataIndex: 'orderNo',
|
||||
key: 'orderNo',
|
||||
align: 'center',
|
||||
customRender: ({ text }) => text || '-'
|
||||
},
|
||||
{
|
||||
title: '用户',
|
||||
dataIndex: 'userId',
|
||||
key: 'userId',
|
||||
align: 'center',
|
||||
width: 100,
|
||||
fixed: 'left'
|
||||
},
|
||||
{
|
||||
title: '流动类型',
|
||||
title: '收益类型',
|
||||
dataIndex: 'flowType',
|
||||
key: 'flowType',
|
||||
align: 'center',
|
||||
width: 120,
|
||||
customRender: ({ text }) => {
|
||||
const typeMap = {
|
||||
10: { text: '佣金收入', color: 'success' },
|
||||
20: { text: '提现支出', color: 'warning' },
|
||||
30: { text: '转账支出', color: 'error' },
|
||||
40: { text: '转账收入', color: 'processing' }
|
||||
40: { text: '转账收入', color: 'processing' },
|
||||
50: { text: '新人注册奖', color: 'processing' }
|
||||
};
|
||||
const type = typeMap[text] || { text: '未知', color: 'default' };
|
||||
return {
|
||||
@@ -152,43 +160,35 @@
|
||||
dataIndex: 'money',
|
||||
key: 'money',
|
||||
align: 'center',
|
||||
width: 120,
|
||||
customRender: ({ text, record }) => {
|
||||
const amount = parseFloat(text || '0').toFixed(2);
|
||||
const isIncome = record.flowType === 10 || record.flowType === 40;
|
||||
const isIncome =
|
||||
record.flowType === 10 ||
|
||||
record.flowType === 40 ||
|
||||
record.flowType === 50;
|
||||
return {
|
||||
type: 'span',
|
||||
props: {
|
||||
style: {
|
||||
color: isIncome ? '#52c41a' : '#ff4d4f',
|
||||
fontWeight: 'bold'
|
||||
color: isIncome ? '#424242' : '#ff4d4f'
|
||||
}
|
||||
},
|
||||
children: `${isIncome ? '+' : '-'}¥${amount}`
|
||||
children: `${isIncome ? '' : '-'} ${amount}`
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '关联订单',
|
||||
dataIndex: 'orderNo',
|
||||
key: 'orderNo',
|
||||
align: 'center',
|
||||
customRender: ({ text }) => text || '-'
|
||||
},
|
||||
{
|
||||
title: '对方用户',
|
||||
dataIndex: 'toUserId',
|
||||
key: 'toUserId',
|
||||
align: 'center',
|
||||
width: 100,
|
||||
customRender: ({ text }) => (text ? `ID: ${text}` : '-')
|
||||
},
|
||||
// {
|
||||
// title: '对方用户',
|
||||
// dataIndex: 'toUserId',
|
||||
// key: 'toUserId',
|
||||
// align: 'center',
|
||||
// customRender: ({ text }) => (text ? `ID: ${text}` : '-')
|
||||
// },
|
||||
{
|
||||
title: '描述',
|
||||
dataIndex: 'describe',
|
||||
key: 'describe',
|
||||
dataIndex: 'comments',
|
||||
key: 'comments',
|
||||
align: 'left',
|
||||
width: 200,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => text || '-'
|
||||
},
|
||||
@@ -197,24 +197,16 @@
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
align: 'center',
|
||||
sorter: true,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
|
||||
},
|
||||
{
|
||||
title: '修改时间',
|
||||
dataIndex: 'updateTime',
|
||||
key: 'updateTime',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
sorter: true
|
||||
}
|
||||
// {
|
||||
// title: '操作',
|
||||
// key: 'action',
|
||||
// width: 180,
|
||||
// fixed: 'right',
|
||||
// align: 'center',
|
||||
// hideInSetting: true
|
||||
// }
|
||||
]);
|
||||
|
||||
/* 搜索 */
|
||||
|
||||
@@ -19,16 +19,6 @@
|
||||
</p>
|
||||
<p class="ant-upload-hint">将文件拖到此处,或点击上传</p>
|
||||
</a-upload-dragger>
|
||||
<div class="ant-upload-text text-gray-400">
|
||||
<div
|
||||
>1、必须按<a
|
||||
href="https://oss.wsdns.cn/20251018/408b805ec3cd4084a4dc686e130af578.xlsx"
|
||||
target="_blank"
|
||||
>导入模版</a
|
||||
>的格式上传</div
|
||||
>
|
||||
<div>2、导入成功确认结算完成佣金的发放</div>
|
||||
</div>
|
||||
</a-spin>
|
||||
</ele-modal>
|
||||
</template>
|
||||
@@ -37,7 +27,7 @@
|
||||
import { ref } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import { CloudUploadOutlined } from '@ant-design/icons-vue';
|
||||
import { importSdyDealerOrder } from '@/api/sdy/sdyDealerOrder';
|
||||
import { importShopDealerOrder } from '@/api/shop/shopDealerOrder';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
@@ -68,7 +58,7 @@
|
||||
return false;
|
||||
}
|
||||
loading.value = true;
|
||||
importSdyDealerOrder(file)
|
||||
importShopDealerOrder(file)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
|
||||
@@ -1,182 +1,147 @@
|
||||
<template>
|
||||
<div class="flex items-center gap-20">
|
||||
<!-- 搜索表单 -->
|
||||
<a-form
|
||||
:model="where"
|
||||
layout="inline"
|
||||
class="search-form"
|
||||
@finish="handleSearch"
|
||||
>
|
||||
<a-form-item>
|
||||
<a-space>
|
||||
<a-button
|
||||
danger
|
||||
class="ele-btn-icon"
|
||||
v-if="selection.length > 0"
|
||||
:disabled="selection?.length === 0"
|
||||
@click="removeBatch"
|
||||
>
|
||||
<template #icon>
|
||||
<DeleteOutlined />
|
||||
</template>
|
||||
<span>批量删除</span>
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
|
||||
<!-- <a-form-item label="订单状态">-->
|
||||
<!-- <a-select-->
|
||||
<!-- v-model:value="where.isInvalid"-->
|
||||
<!-- placeholder="全部"-->
|
||||
<!-- allow-clear-->
|
||||
<!-- style="width: 120px"-->
|
||||
<!-- >-->
|
||||
<!-- <a-select-option :value="0">有效</a-select-option>-->
|
||||
<!-- <a-select-option :value="1">失效</a-select-option>-->
|
||||
<!-- </a-select>-->
|
||||
<!-- </a-form-item>-->
|
||||
|
||||
<!-- <a-form-item label="结算状态">-->
|
||||
<!-- <a-select-->
|
||||
<!-- v-model:value="where.isSettled"-->
|
||||
<!-- placeholder="全部"-->
|
||||
<!-- allow-clear-->
|
||||
<!-- style="width: 120px"-->
|
||||
<!-- >-->
|
||||
<!-- <a-select-option :value="0">未结算</a-select-option>-->
|
||||
<!-- <a-select-option :value="1">已结算</a-select-option>-->
|
||||
<!-- </a-select>-->
|
||||
<!-- </a-form-item>-->
|
||||
|
||||
<a-form-item>
|
||||
<a-space>
|
||||
<template>
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-input-search
|
||||
allow-clear
|
||||
placeholder="请输入关键词"
|
||||
placeholder="客户名称|订单编号"
|
||||
style="width: 240px"
|
||||
v-model:value="where.keywords"
|
||||
@search="handleSearch"
|
||||
@search="reload"
|
||||
/>
|
||||
<!-- <a-button type="primary" html-type="submit" class="ele-btn-icon">-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <SearchOutlined/>-->
|
||||
<!-- </template>-->
|
||||
<!-- 搜索-->
|
||||
<!-- </a-button>-->
|
||||
<a-button @click="resetSearch"> 重置 </a-button>
|
||||
<a-button type="dashed" @click="handleExport">导出xls</a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
<a-divider type="vertical" />
|
||||
<a-space>
|
||||
<!-- <a-button @click="exportData" class="ele-btn-icon">-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <ExportOutlined />-->
|
||||
<!-- </template>-->
|
||||
<!-- 导出数据-->
|
||||
<!-- </a-button>-->
|
||||
<a-button @click="openImport" class="ele-btn-icon">
|
||||
<template #icon>
|
||||
<UploadOutlined />
|
||||
</template>
|
||||
导入数据
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
danger
|
||||
@click="batchSettle"
|
||||
:disabled="selection?.length === 0"
|
||||
>
|
||||
<template #icon>
|
||||
<DollarOutlined />
|
||||
</template>
|
||||
批量结算
|
||||
</a-button>
|
||||
</a-space>
|
||||
</div>
|
||||
|
||||
<!-- 导入弹窗 -->
|
||||
<Import v-model:visible="showImport" @done="emit('importDone')" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import {
|
||||
DollarOutlined,
|
||||
UploadOutlined,
|
||||
DeleteOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { ShopDealerOrderParam } from '@/api/shop/shopDealerOrder/model';
|
||||
import Import from './Import.vue';
|
||||
import { utils, writeFile } from 'xlsx';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { getTenantId } from '@/utils/domain';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import type {
|
||||
ShopDealerOrder,
|
||||
ShopDealerOrderParam
|
||||
} from '@/api/shop/shopDealerOrder/model';
|
||||
import { pageShopDealerOrder } from '@/api/shop/shopDealerOrder';
|
||||
|
||||
withDefaults(
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的数据
|
||||
selection?: any[];
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
}>(),
|
||||
{
|
||||
selection: () => []
|
||||
}
|
||||
{}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: ShopDealerOrderParam): void;
|
||||
(e: 'batchSettle'): void;
|
||||
(e: 'export'): void;
|
||||
(e: 'importDone'): void;
|
||||
(e: 'remove'): void;
|
||||
}>();
|
||||
|
||||
// 是否显示导入弹窗
|
||||
const showImport = ref(false);
|
||||
const reload = () => {
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
// 搜索表单
|
||||
const { where, resetFields } = useSearch<ShopDealerOrderParam>({
|
||||
orderNo: '',
|
||||
productName: '',
|
||||
isInvalid: undefined,
|
||||
isSettled: undefined
|
||||
// 表单数据
|
||||
const { where } = useSearch<ShopDealerOrderParam>({
|
||||
keywords: '',
|
||||
userId: undefined,
|
||||
orderNo: undefined,
|
||||
isSettled: 1, // 与列表页一致:只展示/导出已结算订单
|
||||
page: 1,
|
||||
limit: 5000
|
||||
});
|
||||
|
||||
// 搜索
|
||||
const handleSearch = () => {
|
||||
const searchParams = { ...where };
|
||||
// 清除空值
|
||||
Object.keys(searchParams).forEach((key) => {
|
||||
if (searchParams[key] === '' || searchParams[key] === undefined) {
|
||||
delete searchParams[key];
|
||||
}
|
||||
const list = ref<ShopDealerOrder[]>([]);
|
||||
|
||||
const toMoney = (val: unknown) => {
|
||||
const n = Number.parseFloat(String(val ?? '0'));
|
||||
return Number.isFinite(n) ? n.toFixed(2) : '0.00';
|
||||
};
|
||||
|
||||
const toDateTime = (val: unknown) => {
|
||||
if (val === null || val === undefined || val === '') return '';
|
||||
if (typeof val === 'number') return new Date(val).toLocaleString();
|
||||
return String(val);
|
||||
};
|
||||
|
||||
// 导出
|
||||
const handleExport = async () => {
|
||||
const array: (string | number)[][] = [
|
||||
[
|
||||
// 与 `src/views/shop/shopDealerOrder/index.vue` 表头保持一致
|
||||
'订单编号',
|
||||
'买家',
|
||||
'订单金额',
|
||||
'一级佣金(10%)',
|
||||
'二级佣金(5%)',
|
||||
'一级门店分红(2%/3%)',
|
||||
'二级门店分红(1%)',
|
||||
'结算状态',
|
||||
'创建时间'
|
||||
]
|
||||
];
|
||||
|
||||
// 按搜索结果导出
|
||||
await pageShopDealerOrder(where)
|
||||
.then((data) => {
|
||||
list.value = data?.list || [];
|
||||
list.value?.forEach((d: ShopDealerOrder) => {
|
||||
const buyer =
|
||||
(d.title ? String(d.title) : '') +
|
||||
(d.nickname || d.userId
|
||||
? `\n${d.nickname ?? '-'}(${d.userId ?? '-'})`
|
||||
: '');
|
||||
|
||||
const firstDividendUserName = (d as any)?.firstDividendUserName ?? '-';
|
||||
const firstDividend = (d as any)?.firstDividend ?? 0;
|
||||
const secondDividendUserName =
|
||||
(d as any)?.secondDividendUserName ?? '-';
|
||||
const secondDividend = (d as any)?.secondDividend ?? 0;
|
||||
|
||||
array.push([
|
||||
d.orderNo ?? '',
|
||||
buyer,
|
||||
toMoney(d.orderPrice),
|
||||
`${toMoney(d.firstMoney)}\n${d.firstNickname ?? '-'}`,
|
||||
`${toMoney(d.secondMoney)}\n${d.secondNickname ?? '-'}`,
|
||||
`${toMoney(firstDividend)}\n${firstDividendUserName}`,
|
||||
`${toMoney(secondDividend)}\n${secondDividendUserName}`,
|
||||
d.isSettled === 1 ? '已结算' : '未结算',
|
||||
`${d.createTime ?? ''}${
|
||||
d.settleTime ? `\n${toDateTime(d.settleTime)}` : ''
|
||||
}`
|
||||
]);
|
||||
});
|
||||
emit('search', searchParams);
|
||||
const sheetName = `bak_shop_dealer_order_${getTenantId()}`;
|
||||
const workbook = {
|
||||
SheetNames: [sheetName],
|
||||
Sheets: {}
|
||||
};
|
||||
const sheet = utils.aoa_to_sheet(array);
|
||||
workbook.Sheets[sheetName] = sheet;
|
||||
// 设置列宽
|
||||
sheet['!cols'] = [
|
||||
{ wch: 20 },
|
||||
{ wch: 20 },
|
||||
{ wch: 12 },
|
||||
{ wch: 16 },
|
||||
{ wch: 16 },
|
||||
{ wch: 18 },
|
||||
{ wch: 16 },
|
||||
{ wch: 10 },
|
||||
{ wch: 20 }
|
||||
];
|
||||
message.loading('正在导出...', 0);
|
||||
setTimeout(() => {
|
||||
writeFile(workbook, `${sheetName}.xlsx`);
|
||||
message.destroy();
|
||||
}, 1000);
|
||||
})
|
||||
.catch((msg) => {
|
||||
message.destroy();
|
||||
message.error(msg);
|
||||
})
|
||||
.finally(() => {});
|
||||
};
|
||||
|
||||
// 重置搜索
|
||||
const resetSearch = () => {
|
||||
// Object.keys(searchForm).forEach(key => {
|
||||
// searchForm[key] = key === 'orderId' ? undefined : '';
|
||||
// });
|
||||
resetFields();
|
||||
emit('search', {});
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
// 批量结算
|
||||
const batchSettle = () => {
|
||||
emit('batchSettle');
|
||||
};
|
||||
|
||||
// 导出数据
|
||||
const exportData = () => {
|
||||
emit('export');
|
||||
};
|
||||
|
||||
// 打开导入弹窗
|
||||
const openImport = () => {
|
||||
showImport.value = true;
|
||||
};
|
||||
void props;
|
||||
</script>
|
||||
|
||||
@@ -24,66 +24,36 @@
|
||||
</a-divider>
|
||||
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="客户名称" name="title">
|
||||
{{ form.title }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="订单编号" name="orderNo">
|
||||
{{ form.orderNo }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="结算电量" name="orderPrice">
|
||||
{{ parseFloat(form.orderPrice || 0).toFixed(2) }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="换算成度" name="dealerPrice">
|
||||
{{ parseFloat(form.degreePrice || 0).toFixed(2) }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="税率" name="rate">
|
||||
{{ form.rate }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="单价" name="price">
|
||||
{{ form.price }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="结算金额" name="payPrice">
|
||||
{{ parseFloat(form.settledPrice || 0).toFixed(2) }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="实发金额" name="payPrice">
|
||||
<a-form-item label="订单金额" name="payPrice">
|
||||
{{ parseFloat(form.payPrice || 0).toFixed(2) }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<div class="font-bold text-gray-400 bg-gray-50">开发调试</div>
|
||||
<div class="text-gray-400 bg-gray-50">
|
||||
<div>业务员({{ form.userId }}):{{ form.nickname }}</div>
|
||||
<div
|
||||
>一级分销商({{ form.firstUserId }}):{{
|
||||
form.firstNickname
|
||||
}},一级佣金30%:{{ form.firstMoney }}</div
|
||||
>
|
||||
<div
|
||||
>二级分销商({{ form.secondUserId }}):{{
|
||||
form.secondNickname
|
||||
}},二级佣金10%:{{ form.secondMoney }}</div
|
||||
>
|
||||
<div
|
||||
>三级分销商({{ form.thirdUserId }}):{{
|
||||
form.thirdNickname
|
||||
}},三级佣金60%:{{ form.thirdMoney }}</div
|
||||
>
|
||||
</div>
|
||||
<!-- <div class="font-bold text-gray-400 bg-gray-50">开发调试</div>-->
|
||||
<!-- <div class="text-gray-400 bg-gray-50">-->
|
||||
<!-- <div>业务员({{ form.userId }}):{{ form.nickname }}</div>-->
|
||||
<!-- <div-->
|
||||
<!-- >一级分销商({{ form.firstUserId }}):{{-->
|
||||
<!-- form.firstNickname-->
|
||||
<!-- }},一级佣金30%:{{ form.firstMoney }}</div-->
|
||||
<!-- >-->
|
||||
<!-- <div-->
|
||||
<!-- >二级分销商({{ form.secondUserId }}):{{-->
|
||||
<!-- form.secondNickname-->
|
||||
<!-- }},二级佣金10%:{{ form.secondMoney }}</div-->
|
||||
<!-- >-->
|
||||
<!-- <div-->
|
||||
<!-- >三级分销商({{ form.thirdUserId }}):{{-->
|
||||
<!-- form.thirdNickname-->
|
||||
<!-- }},三级佣金60%:{{ form.thirdMoney }}</div-->
|
||||
<!-- >-->
|
||||
<!-- </div>-->
|
||||
<!-- 分销商信息 -->
|
||||
<a-divider orientation="left">
|
||||
<span style="color: #1890ff; font-weight: 600">收益计算</span>
|
||||
@@ -92,7 +62,7 @@
|
||||
<!-- 一级分销商 -->
|
||||
<div class="dealer-section">
|
||||
<h4 class="dealer-title">
|
||||
<a-tag color="orange">一级佣金30%</a-tag>
|
||||
<a-tag color="orange">一级佣金10%</a-tag>
|
||||
</h4>
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
@@ -105,7 +75,7 @@
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="占比" name="rate">
|
||||
{{ '30%' }}
|
||||
{{ '10%' }}
|
||||
</a-form-item>
|
||||
<a-form-item label="获取收益" name="firstMoney">
|
||||
{{ form.firstMoney }}
|
||||
@@ -179,7 +149,7 @@
|
||||
import { assignObject } from 'ele-admin-pro';
|
||||
import { ShopDealerOrder } from '@/api/shop/shopDealerOrder/model';
|
||||
import { FormInstance } from 'ant-design-vue/es/form';
|
||||
import { updateSdyDealerOrder } from '@/api/sdy/sdyDealerOrder';
|
||||
import { updateShopDealerOrder } from '@/api/shop/shopDealerOrder';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
@@ -275,7 +245,7 @@
|
||||
...form,
|
||||
isSettled: 1
|
||||
};
|
||||
updateSdyDealerOrder(formData)
|
||||
updateShopDealerOrder(formData)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
|
||||
@@ -7,28 +7,24 @@
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:customRow="customRow"
|
||||
v-model:selection="selection"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-org-table"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@batchSettle="batchSettle"
|
||||
@export="handleExport"
|
||||
@remove="removeBatch"
|
||||
@importDone="reload"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'title'">
|
||||
<div>{{ record.title }}</div>
|
||||
<div class="text-gray-400">用户ID:{{ record.userId }}</div>
|
||||
<div class="text-gray-400"
|
||||
>{{ record.nickname }}({{ record.userId }})</div
|
||||
>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'orderPrice'">
|
||||
{{ record.orderPrice.toFixed(2) }}
|
||||
{{ parseFloat(record.orderPrice).toFixed(2) }}
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'degreePrice'">
|
||||
@@ -36,7 +32,7 @@
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'price'">
|
||||
{{ record.price }}
|
||||
{{ record.price || 0 }}
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'settledPrice'">
|
||||
@@ -47,6 +43,30 @@
|
||||
{{ record.payPrice.toFixed(2) }}
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'firstNickname'">
|
||||
<div>{{ record.firstMoney }}</div>
|
||||
<div class="text-gray-400">{{ record.firstNickname || '-' }}</div>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'secondNickname'">
|
||||
<div>{{ record.secondMoney }}</div>
|
||||
<div class="text-gray-400">{{ record.secondNickname || '-' }}</div>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'firstDividendUserName'">
|
||||
<div>{{ record.firstDividend }}</div>
|
||||
<div class="text-gray-400"
|
||||
>{{ record.firstDividendUserName || '-' }}</div
|
||||
>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'secondDividendUserName'">
|
||||
<div>{{ record.secondDividend }}</div>
|
||||
<div class="text-gray-400"
|
||||
>{{ record.secondDividendUserName || '-' }}</div
|
||||
>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'dealerInfo'">
|
||||
<div class="dealer-info">
|
||||
<div v-if="record.firstUserId" class="dealer-level">
|
||||
@@ -93,9 +113,22 @@
|
||||
|
||||
<template v-if="column.key === 'action'">
|
||||
<template v-if="record.isSettled === 0 && record.isInvalid === 0">
|
||||
<a @click="openEdit(record)" class="ele-text-success"> 结算 </a>
|
||||
<a @click="settleOrder(record)" class="ele-text-success">
|
||||
结算
|
||||
</a>
|
||||
<a-divider type="vertical" />
|
||||
</template>
|
||||
<!-- <template v-if="record.isInvalid === 0">-->
|
||||
<!-- <a-popconfirm-->
|
||||
<!-- title="确定要标记此订单为失效吗?"-->
|
||||
<!-- @confirm="invalidateOrder(record)"-->
|
||||
<!-- placement="topRight"-->
|
||||
<!-- >-->
|
||||
<!-- <a class="text-purple-500">-->
|
||||
<!-- 验证-->
|
||||
<!-- </a>-->
|
||||
<!-- </a-popconfirm>-->
|
||||
<!-- </template>-->
|
||||
<a-popconfirm
|
||||
v-if="record.isSettled === 0"
|
||||
title="确定要删除吗?"
|
||||
@@ -121,7 +154,10 @@
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import {
|
||||
ExclamationCircleOutlined,
|
||||
DollarOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
@@ -139,7 +175,9 @@
|
||||
ShopDealerOrder,
|
||||
ShopDealerOrderParam
|
||||
} from '@/api/shop/shopDealerOrder/model';
|
||||
import { exportSdyDealerOrder } from '@/api/sdy/sdyDealerOrder';
|
||||
import {
|
||||
updateShopDealerOrder
|
||||
} from '@/api/shop/shopDealerOrder';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
@@ -153,9 +191,6 @@
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
|
||||
// 当前搜索条件
|
||||
const currentWhere = ref<ShopDealerOrderParam>({});
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
@@ -167,11 +202,8 @@
|
||||
if (filters) {
|
||||
where.status = filters.status;
|
||||
}
|
||||
// 保存当前搜索条件用于导出
|
||||
currentWhere.value = { ...where };
|
||||
// 未结算订单
|
||||
where.isSettled = 0;
|
||||
where.myOrder = 1;
|
||||
// 已结算订单
|
||||
where.isSettled = 1;
|
||||
return pageShopDealerOrder({
|
||||
...where,
|
||||
...orders,
|
||||
@@ -182,88 +214,77 @@
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
key: 'index',
|
||||
width: 48,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true,
|
||||
customRender: ({ index }) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
{
|
||||
title: '订单编号',
|
||||
dataIndex: 'orderNo',
|
||||
key: 'orderNo'
|
||||
key: 'orderNo',
|
||||
align: 'center',
|
||||
width: 200
|
||||
},
|
||||
{
|
||||
title: '客户名称',
|
||||
title: '买家',
|
||||
dataIndex: 'title',
|
||||
key: 'title',
|
||||
width: 220
|
||||
key: 'title'
|
||||
},
|
||||
{
|
||||
title: '结算电量',
|
||||
title: '订单金额',
|
||||
dataIndex: 'orderPrice',
|
||||
key: 'orderPrice',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '换算成度',
|
||||
dataIndex: 'degreePrice',
|
||||
key: 'degreePrice',
|
||||
title: '一级佣金',
|
||||
dataIndex: 'firstNickname',
|
||||
key: 'firstNickname',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '结算单价',
|
||||
dataIndex: 'price',
|
||||
key: 'price',
|
||||
title: '二级佣金',
|
||||
dataIndex: 'secondNickname',
|
||||
key: 'secondNickname',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '结算金额',
|
||||
dataIndex: 'settledPrice',
|
||||
key: 'settledPrice',
|
||||
title: '一级门店分红',
|
||||
dataIndex: 'firstDividendUserName',
|
||||
key: 'firstDividendUserName',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '税费',
|
||||
dataIndex: 'rate',
|
||||
key: 'rate',
|
||||
title: '二级门店分红',
|
||||
dataIndex: 'secondDividendUserName',
|
||||
key: 'secondDividendUserName',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '实发金额',
|
||||
dataIndex: 'payPrice',
|
||||
key: 'payPrice',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '签约状态',
|
||||
dataIndex: 'isInvalid',
|
||||
key: 'isInvalid',
|
||||
align: 'center',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '月份',
|
||||
dataIndex: 'month',
|
||||
key: 'month',
|
||||
align: 'center',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '结算状态',
|
||||
dataIndex: 'isSettled',
|
||||
key: 'isSettled',
|
||||
align: 'center',
|
||||
width: 100
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
width: 180
|
||||
}
|
||||
// {
|
||||
// title: '操作',
|
||||
// key: 'action',
|
||||
// width: 180,
|
||||
// fixed: 'right',
|
||||
// align: 'center',
|
||||
// hideInSetting: true
|
||||
// }
|
||||
]);
|
||||
|
||||
/* 搜索 */
|
||||
@@ -272,6 +293,37 @@
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
/* 结算单个订单 */
|
||||
const settleOrder = (row: ShopDealerOrder) => {
|
||||
const totalCommission = (
|
||||
parseFloat(row.firstMoney || '0') +
|
||||
parseFloat(row.secondMoney || '0') +
|
||||
parseFloat(row.thirdMoney || '0')
|
||||
).toFixed(2);
|
||||
|
||||
Modal.confirm({
|
||||
title: '确认结算',
|
||||
content: `确定要结算此订单吗?总佣金金额:¥${totalCommission}`,
|
||||
icon: createVNode(DollarOutlined),
|
||||
okText: '确认结算',
|
||||
okType: 'primary',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
const hide = message.loading('正在结算...', 0);
|
||||
// 这里调用结算API
|
||||
updateShopDealerOrder({
|
||||
...row,
|
||||
isSettled: 1
|
||||
});
|
||||
setTimeout(() => {
|
||||
hide();
|
||||
message.success('结算成功');
|
||||
reload();
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量结算 */
|
||||
const batchSettle = () => {
|
||||
if (!selection.value.length) {
|
||||
@@ -318,16 +370,10 @@
|
||||
});
|
||||
};
|
||||
|
||||
/* 导出数据 */
|
||||
const handleExport = () => {
|
||||
// 调用导出API,传入当前搜索条件
|
||||
exportSdyDealerOrder(currentWhere.value);
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: ShopDealerOrder) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
// showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
|
||||
79
src/views/shop/shopDealerOrder2/components/Import.vue
Normal file
79
src/views/shop/shopDealerOrder2/components/Import.vue
Normal file
@@ -0,0 +1,79 @@
|
||||
<!-- 经销商订单导入弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="520"
|
||||
:footer="null"
|
||||
title="导入分销订单"
|
||||
:visible="visible"
|
||||
@update:visible="updateVisible"
|
||||
>
|
||||
<a-spin :spinning="loading">
|
||||
<a-upload-dragger
|
||||
accept=".xls,.xlsx"
|
||||
:show-upload-list="false"
|
||||
:customRequest="doUpload"
|
||||
style="padding: 24px 0; margin-bottom: 16px"
|
||||
>
|
||||
<p class="ant-upload-drag-icon">
|
||||
<cloud-upload-outlined/>
|
||||
</p>
|
||||
<p class="ant-upload-hint">将文件拖到此处,或点击上传</p>
|
||||
</a-upload-dragger>
|
||||
</a-spin>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref} from 'vue';
|
||||
import {message} from 'ant-design-vue/es';
|
||||
import {CloudUploadOutlined} from '@ant-design/icons-vue';
|
||||
import {importSdyDealerOrder} from "@/api/sdy/sdyDealerOrder";
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
defineProps<{
|
||||
// 是否打开弹窗
|
||||
visible: boolean;
|
||||
}>();
|
||||
|
||||
// 导入请求状态
|
||||
const loading = ref(false);
|
||||
|
||||
/* 上传 */
|
||||
const doUpload = ({file}) => {
|
||||
if (
|
||||
![
|
||||
'application/vnd.ms-excel',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
].includes(file.type)
|
||||
) {
|
||||
message.error('只能选择 excel 文件');
|
||||
return false;
|
||||
}
|
||||
if (file.size / 1024 / 1024 > 10) {
|
||||
message.error('大小不能超过 10MB');
|
||||
return false;
|
||||
}
|
||||
loading.value = true;
|
||||
importSdyDealerOrder(file)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
return false;
|
||||
};
|
||||
|
||||
/* 更新 visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
</script>
|
||||
144
src/views/shop/shopDealerOrder2/components/search.vue
Normal file
144
src/views/shop/shopDealerOrder2/components/search.vue
Normal file
@@ -0,0 +1,144 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-input-search
|
||||
allow-clear
|
||||
placeholder="客户名称|订单编号"
|
||||
style="width: 240px"
|
||||
v-model:value="where.keywords"
|
||||
@search="reload"
|
||||
/>
|
||||
<a-button type="dashed" @click="handleExport">导出xls</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { GradeParam } from '@/api/user/grade/model';
|
||||
import {ref, watch} from 'vue';
|
||||
import {utils, writeFile} from 'xlsx';
|
||||
import {message} from 'ant-design-vue';
|
||||
import {ShopDealerCapital} from "@/api/shop/shopDealerCapital/model";
|
||||
import {getTenantId} from "@/utils/domain";
|
||||
import useSearch from "@/utils/use-search";
|
||||
import {ShopDealerOrder, ShopDealerOrderParam} from "@/api/sdy/sdyDealerOrder/model";
|
||||
import {pageShopDealerOrder} from "@/api/shop/shopDealerOrder";
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
}>(),
|
||||
{}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: GradeParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
(e: 'batchMove'): void;
|
||||
}>();
|
||||
|
||||
const reload = () => {
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const {where} = useSearch<ShopDealerOrderParam>({
|
||||
keywords: '',
|
||||
userId: undefined,
|
||||
orderNo: undefined,
|
||||
limit: 5000
|
||||
});
|
||||
|
||||
const list = ref<ShopDealerCapital[]>([]);
|
||||
|
||||
// 导出
|
||||
const handleExport = async () => {
|
||||
const array: (string | number)[][] = [
|
||||
[
|
||||
'客户名称',
|
||||
'业务员',
|
||||
'订单编号',
|
||||
'结算电量',
|
||||
'换算成度',
|
||||
'结算单价',
|
||||
'结算金额',
|
||||
'税费',
|
||||
'实发金额',
|
||||
'一级佣金30%',
|
||||
'一级佣金收益',
|
||||
'二级佣金10%',
|
||||
'二级佣金收益',
|
||||
'三级佣金60%',
|
||||
'三级佣金收益',
|
||||
'月份',
|
||||
'创建时间',
|
||||
'结算时间',
|
||||
'租户ID'
|
||||
]
|
||||
];
|
||||
|
||||
// 按搜索结果导出
|
||||
await pageShopDealerOrder(where)
|
||||
.then((data) => {
|
||||
list.value = data?.list || [];
|
||||
list.value?.forEach((d: ShopDealerOrder) => {
|
||||
array.push([
|
||||
`${d.title}`,
|
||||
`${d.nickname}(${d.userId})`,
|
||||
`${d.orderNo}`,
|
||||
`${d.orderPrice}`,
|
||||
`${d.degreePrice}`,
|
||||
`${d.price}`,
|
||||
`${d.settledPrice}`,
|
||||
`${d.rate}`,
|
||||
`${d.payPrice}`,
|
||||
`${d.firstNickname}(${d.firstUserId})`,
|
||||
`${d.firstMoney}`,
|
||||
`${d.secondNickname}(${d.secondUserId})`,
|
||||
`${d.secondMoney}`,
|
||||
`${d.thirdNickname}(${d.thirdUserId})`,
|
||||
`${d.thirdMoney}`,
|
||||
`${d.month}`,
|
||||
`${d.createTime}`,
|
||||
`${d.settleTime}`,
|
||||
`${d.tenantId}`
|
||||
]);
|
||||
});
|
||||
const sheetName = `bak_shop_dealer_order_${getTenantId()}`;
|
||||
const workbook = {
|
||||
SheetNames: [sheetName],
|
||||
Sheets: {}
|
||||
};
|
||||
const sheet = utils.aoa_to_sheet(array);
|
||||
workbook.Sheets[sheetName] = sheet;
|
||||
// 设置列宽
|
||||
sheet['!cols'] = [
|
||||
{wch: 10},
|
||||
{wch: 20},
|
||||
{wch: 20},
|
||||
{wch: 15},
|
||||
{wch: 10},
|
||||
{wch: 10},
|
||||
{wch: 20}
|
||||
];
|
||||
message.loading('正在导出...');
|
||||
setTimeout(() => {
|
||||
writeFile(
|
||||
workbook,
|
||||
`${sheetName}.xlsx`
|
||||
);
|
||||
}, 1000);
|
||||
})
|
||||
.catch((msg) => {
|
||||
message.error(msg);
|
||||
})
|
||||
.finally(() => {
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
@@ -0,0 +1,352 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="900"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '分销订单' : '分销订单'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
:okText="`立即结算`"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<!-- 订单基本信息 -->
|
||||
<a-divider orientation="left">
|
||||
<span style="color: #1890ff; font-weight: 600;">基本信息</span>
|
||||
</a-divider>
|
||||
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="客户名称" name="title">
|
||||
{{ form.title }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="订单编号" name="orderNo">
|
||||
{{ form.orderNo }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="结算电量" name="orderPrice">
|
||||
{{ parseFloat(form.orderPrice || 0).toFixed(2) }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="换算成度" name="dealerPrice">
|
||||
{{ parseFloat(form.degreePrice || 0).toFixed(2) }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="税率" name="rate">
|
||||
{{ form.rate }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="单价" name="price">
|
||||
{{ form.price }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="结算金额" name="payPrice">
|
||||
{{ parseFloat(form.settledPrice || 0).toFixed(2) }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="实发金额" name="payPrice">
|
||||
{{ parseFloat(form.payPrice || 0).toFixed(2) }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<div class="font-bold text-gray-400 bg-gray-50">开发调试</div>
|
||||
<div class="text-gray-400 bg-gray-50">
|
||||
<div>业务员({{ form.userId }}):{{ form.nickname }}</div>
|
||||
<div>一级分销商({{ form.firstUserId }}):{{ form.firstNickname }},一级佣金30%:{{ form.firstMoney }}</div>
|
||||
<div>二级分销商({{ form.secondUserId }}):{{ form.secondNickname }},二级佣金10%:{{ form.secondMoney }}</div>
|
||||
<div>三级分销商({{ form.thirdUserId }}):{{ form.thirdNickname }},三级佣金60%:{{ form.thirdMoney }}</div>
|
||||
</div>
|
||||
<!-- 分销商信息 -->
|
||||
<a-divider orientation="left">
|
||||
<span style="color: #1890ff; font-weight: 600;">收益计算</span>
|
||||
</a-divider>
|
||||
|
||||
<!-- 一级分销商 -->
|
||||
<div class="dealer-section">
|
||||
<h4 class="dealer-title">
|
||||
<a-tag color="orange">一级佣金30%</a-tag>
|
||||
</h4>
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="用户ID" name="firstUserId">
|
||||
{{ form.firstUserId }}
|
||||
</a-form-item>
|
||||
<a-form-item label="昵称" name="firstNickname">
|
||||
{{ form.firstNickname }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="占比" name="rate">
|
||||
{{ '30%' }}
|
||||
</a-form-item>
|
||||
<a-form-item label="获取收益" name="firstMoney">
|
||||
{{ form.firstMoney }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
|
||||
<!-- 二级分销商 -->
|
||||
<div class="dealer-section">
|
||||
<h4 class="dealer-title">
|
||||
<a-tag color="orange">二级佣金10%</a-tag>
|
||||
</h4>
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="用户ID" name="secondUserId">
|
||||
{{ form.secondUserId }}
|
||||
</a-form-item>
|
||||
<a-form-item label="昵称" name="nickname">
|
||||
{{ form.secondNickname }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="占比" name="rate">
|
||||
10%
|
||||
</a-form-item>
|
||||
<a-form-item label="获取收益" name="firstMoney">
|
||||
{{ form.secondMoney }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
|
||||
<!-- 三级分销商 -->
|
||||
<div class="dealer-section" v-if="form.thirdUserId > 0">
|
||||
<h4 class="dealer-title">
|
||||
<a-tag color="orange">三级佣金60%</a-tag>
|
||||
</h4>
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="用户ID" name="thirdUserId">
|
||||
{{ form.thirdUserId }}
|
||||
</a-form-item>
|
||||
<a-form-item label="昵称" name="thirdNickname">
|
||||
{{ form.thirdNickname }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="占比" name="rate">
|
||||
{{ '60%' }}
|
||||
</a-form-item>
|
||||
<a-form-item label="获取收益" name="thirdMoney">
|
||||
{{ form.thirdMoney }}
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
|
||||
<a-form-item label="结算时间" name="settleTime" v-if="form.isSettled === 1">
|
||||
{{ form.settleTime }}
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref, reactive, watch} from 'vue';
|
||||
import {Form, message} from 'ant-design-vue';
|
||||
import {assignObject} from 'ele-admin-pro';
|
||||
import {ShopDealerOrder} from '@/api/shop/shopDealerOrder/model';
|
||||
import {FormInstance} from 'ant-design-vue/es/form';
|
||||
import {updateSdyDealerOrder} from "@/api/sdy/sdyDealerOrder";
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: ShopDealerOrder | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
// 表格选中数据
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
// 表单数据
|
||||
const form = reactive<ShopDealerOrder>({
|
||||
id: undefined,
|
||||
userId: undefined,
|
||||
nickname: undefined,
|
||||
orderNo: undefined,
|
||||
title: undefined,
|
||||
orderPrice: undefined,
|
||||
settledPrice: undefined,
|
||||
degreePrice: undefined,
|
||||
price: undefined,
|
||||
month: undefined,
|
||||
payPrice: undefined,
|
||||
firstUserId: undefined,
|
||||
secondUserId: undefined,
|
||||
thirdUserId: undefined,
|
||||
firstMoney: undefined,
|
||||
secondMoney: undefined,
|
||||
thirdMoney: undefined,
|
||||
firstNickname: undefined,
|
||||
secondNickname: undefined,
|
||||
thirdNickname: undefined,
|
||||
rate: undefined,
|
||||
comments: undefined,
|
||||
isInvalid: 0,
|
||||
isSettled: 0,
|
||||
settleTime: undefined,
|
||||
tenantId: undefined,
|
||||
createTime: undefined,
|
||||
updateTime: undefined
|
||||
});
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
userId: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择用户ID',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
const {resetFields} = useForm(form, rules);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
if (form.isSettled == 1) {
|
||||
message.error('请勿重复结算');
|
||||
return;
|
||||
}
|
||||
if (form.userId == 0) {
|
||||
message.error('未签约');
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const formData = {
|
||||
...form,
|
||||
isSettled: 1
|
||||
};
|
||||
updateSdyDealerOrder(formData)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
});
|
||||
};
|
||||
|
||||
console.log(localStorage.getItem(''))
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
assignObject(form, props.data);
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
// 重置为默认值
|
||||
Object.assign(form, {
|
||||
id: undefined,
|
||||
userId: undefined,
|
||||
orderNo: undefined,
|
||||
orderPrice: undefined,
|
||||
firstUserId: undefined,
|
||||
secondUserId: undefined,
|
||||
thirdUserId: undefined,
|
||||
firstMoney: undefined,
|
||||
secondMoney: undefined,
|
||||
thirdMoney: undefined,
|
||||
isInvalid: 0,
|
||||
isSettled: 0,
|
||||
settleTime: undefined
|
||||
});
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
},
|
||||
{immediate: true}
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.dealer-section {
|
||||
margin-bottom: 24px;
|
||||
padding: 16px;
|
||||
background: #fafafa;
|
||||
border-radius: 6px;
|
||||
border-left: 3px solid #1890ff;
|
||||
|
||||
.dealer-title {
|
||||
margin: 0 0 16px 0;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
|
||||
.ant-tag {
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-divider-horizontal.ant-divider-with-text-left) {
|
||||
margin: 24px 0 16px 0;
|
||||
|
||||
.ant-divider-inner-text {
|
||||
padding: 0 16px 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-form-item) {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
:deep(.ant-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
481
src/views/shop/shopDealerOrder2/index.vue
Normal file
481
src/views/shop/shopDealerOrder2/index.vue
Normal file
@@ -0,0 +1,481 @@
|
||||
<template>
|
||||
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
|
||||
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="id"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:customRow="customRow"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-org-table"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@batchSettle="batchSettle"
|
||||
@export="handleExport"
|
||||
@remove="removeBatch"
|
||||
@importDone="reload"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
|
||||
<template v-if="column.key === 'title'">
|
||||
<div>{{ record.title }}</div>
|
||||
<div class="text-gray-400">业务员:{{ record.userId }}</div>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'orderPrice'">
|
||||
{{ parseFloat(record.orderPrice).toFixed(2) }}
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'degreePrice'">
|
||||
{{ record.degreePrice.toFixed(2) }}
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'price'">
|
||||
{{ record.price || 0 }}
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'settledPrice'">
|
||||
{{ record.settledPrice.toFixed(2) }}
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'payPrice'">
|
||||
{{ record.payPrice.toFixed(2) }}
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'dealerInfo'">
|
||||
<div class="dealer-info">
|
||||
<div v-if="record.firstUserId" class="dealer-level">
|
||||
<a-tag color="red">一级</a-tag>
|
||||
用户{{ record.firstUserId }} - ¥{{ parseFloat(record.firstMoney || '0').toFixed(2) }}
|
||||
</div>
|
||||
<div v-if="record.secondUserId" class="dealer-level">
|
||||
<a-tag color="orange">二级</a-tag>
|
||||
用户{{ record.secondUserId }} - ¥{{ parseFloat(record.secondMoney || '0').toFixed(2) }}
|
||||
</div>
|
||||
<div v-if="record.thirdUserId" class="dealer-level">
|
||||
<a-tag color="gold">三级</a-tag>
|
||||
用户{{ record.thirdUserId }} - ¥{{ parseFloat(record.thirdMoney || '0').toFixed(2) }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'isInvalid'">
|
||||
<a-tag v-if="record.isInvalid === 0" color="success">已签约</a-tag>
|
||||
<a-tag v-if="record.isInvalid === 1" color="error">未签约</a-tag>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'isSettled'">
|
||||
<a-tag v-if="record.isSettled === 0" color="orange">未结算</a-tag>
|
||||
<a-tag v-if="record.isSettled === 1" color="success">已结算</a-tag>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'createTime'">
|
||||
<div class="flex flex-col">
|
||||
<a-tooltip title="创建时间">
|
||||
<span class="text-gray-500">{{ record.createTime }}</span>
|
||||
</a-tooltip>
|
||||
<a-tooltip title="结算时间">
|
||||
<span class="text-purple-500">{{ record.settleTime }}</span>
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'action'">
|
||||
<template v-if="record.isSettled === 0 && record.isInvalid === 0">
|
||||
<a @click="settleOrder(record)" class="ele-text-success">
|
||||
结算
|
||||
</a>
|
||||
<a-divider type="vertical"/>
|
||||
</template>
|
||||
<!-- <template v-if="record.isInvalid === 0">-->
|
||||
<!-- <a-popconfirm-->
|
||||
<!-- title="确定要标记此订单为失效吗?"-->
|
||||
<!-- @confirm="invalidateOrder(record)"-->
|
||||
<!-- placement="topRight"-->
|
||||
<!-- >-->
|
||||
<!-- <a class="text-purple-500">-->
|
||||
<!-- 验证-->
|
||||
<!-- </a>-->
|
||||
<!-- </a-popconfirm>-->
|
||||
<!-- </template>-->
|
||||
<a-popconfirm
|
||||
v-if="record.isSettled === 0"
|
||||
title="确定要删除吗?"
|
||||
@confirm="remove(record)"
|
||||
placement="topRight"
|
||||
>
|
||||
<a class="text-red-500">
|
||||
删除
|
||||
</a>
|
||||
</a-popconfirm>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<ShopDealerOrderEdit v-model:visible="showEdit" :data="current" @done="reload"/>
|
||||
</a-page-header>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {createVNode, ref} from 'vue';
|
||||
import {message, Modal} from 'ant-design-vue';
|
||||
import {
|
||||
ExclamationCircleOutlined,
|
||||
DollarOutlined,
|
||||
} from '@ant-design/icons-vue';
|
||||
import type {EleProTable} from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import Search from './components/search.vue';
|
||||
import {getPageTitle} from '@/utils/common';
|
||||
import ShopDealerOrderEdit from './components/shopDealerOrderEdit.vue';
|
||||
import {pageShopDealerOrder, removeShopDealerOrder, removeBatchShopDealerOrder} from '@/api/shop/shopDealerOrder';
|
||||
import type {ShopDealerOrder, ShopDealerOrderParam} from '@/api/shop/shopDealerOrder/model';
|
||||
import {exportSdyDealerOrder, updateSdyDealerOrder} from "@/api/sdy/sdyDealerOrder";
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<ShopDealerOrder[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<ShopDealerOrder | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
|
||||
// 当前搜索条件
|
||||
const currentWhere = ref<ShopDealerOrderParam>({});
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.status = filters.status;
|
||||
}
|
||||
// 保存当前搜索条件用于导出
|
||||
currentWhere.value = {...where};
|
||||
// 已结算订单
|
||||
where.isSettled = 1;
|
||||
return pageShopDealerOrder({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
key: 'index',
|
||||
width: 48,
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
hideInSetting: true,
|
||||
customRender: ({index}) => index + (tableRef.value?.tableIndex ?? 0)
|
||||
},
|
||||
{
|
||||
title: '客户名称',
|
||||
dataIndex: 'title',
|
||||
key: 'title',
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
title: '订单编号',
|
||||
dataIndex: 'orderNo',
|
||||
key: 'orderNo',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '结算电量',
|
||||
dataIndex: 'orderPrice',
|
||||
key: 'orderPrice',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '换算成度',
|
||||
dataIndex: 'degreePrice',
|
||||
key: 'degreePrice',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '结算单价',
|
||||
dataIndex: 'price',
|
||||
key: 'price',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '结算金额',
|
||||
dataIndex: 'settledPrice',
|
||||
key: 'settledPrice',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '税费',
|
||||
dataIndex: 'rate',
|
||||
key: 'rate',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '实发金额',
|
||||
dataIndex: 'payPrice',
|
||||
key: 'payPrice',
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '签约状态',
|
||||
dataIndex: 'isInvalid',
|
||||
key: 'isInvalid',
|
||||
align: 'center',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '月份',
|
||||
dataIndex: 'month',
|
||||
key: 'month',
|
||||
align: 'center',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '结算状态',
|
||||
dataIndex: 'isSettled',
|
||||
key: 'isSettled',
|
||||
align: 'center',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
align: 'center'
|
||||
}
|
||||
// {
|
||||
// title: '操作',
|
||||
// key: 'action',
|
||||
// width: 180,
|
||||
// fixed: 'right',
|
||||
// align: 'center',
|
||||
// hideInSetting: true
|
||||
// }
|
||||
]);
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: ShopDealerOrderParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({where: where});
|
||||
};
|
||||
|
||||
/* 结算单个订单 */
|
||||
const settleOrder = (row: ShopDealerOrder) => {
|
||||
const totalCommission = (parseFloat(row.firstMoney || '0') +
|
||||
parseFloat(row.secondMoney || '0') +
|
||||
parseFloat(row.thirdMoney || '0')).toFixed(2);
|
||||
|
||||
Modal.confirm({
|
||||
title: '确认结算',
|
||||
content: `确定要结算此订单吗?总佣金金额:¥${totalCommission}`,
|
||||
icon: createVNode(DollarOutlined),
|
||||
okText: '确认结算',
|
||||
okType: 'primary',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
const hide = message.loading('正在结算...', 0);
|
||||
// 这里调用结算API
|
||||
updateSdyDealerOrder({
|
||||
...row,
|
||||
isSettled: 1
|
||||
})
|
||||
setTimeout(() => {
|
||||
hide();
|
||||
message.success('结算成功');
|
||||
reload();
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量结算 */
|
||||
const batchSettle = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
|
||||
const validOrders = selection.value.filter(order =>
|
||||
order.isSettled === 0 && order.isInvalid === 0
|
||||
);
|
||||
|
||||
if (!validOrders.length) {
|
||||
message.error('所选订单中没有可结算的订单');
|
||||
return;
|
||||
}
|
||||
|
||||
const totalCommission = validOrders.reduce((sum, order) => {
|
||||
return sum + parseFloat(order.firstMoney || '0') +
|
||||
parseFloat(order.secondMoney || '0') +
|
||||
parseFloat(order.thirdMoney || '0');
|
||||
}, 0).toFixed(2);
|
||||
|
||||
Modal.confirm({
|
||||
title: '批量结算确认',
|
||||
content: `确定要结算选中的 ${validOrders.length} 个订单吗?总佣金金额:¥${totalCommission}`,
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
okText: '确认结算',
|
||||
okType: 'primary',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
const hide = message.loading('正在批量结算...', 0);
|
||||
// 这里调用批量结算API
|
||||
setTimeout(() => {
|
||||
hide();
|
||||
message.success(`成功结算 ${validOrders.length} 个订单`);
|
||||
reload();
|
||||
}, 1500);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 导出数据 */
|
||||
const handleExport = () => {
|
||||
// 调用导出API,传入当前搜索条件
|
||||
exportSdyDealerOrder(currentWhere.value);
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: ShopDealerOrder) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: ShopDealerOrder) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeShopDealerOrder(row.id)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchShopDealerOrder(selection.value.map((d) => d.id))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 查询 */
|
||||
const query = () => {
|
||||
loading.value = true;
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: ShopDealerOrder) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
query();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'ShopDealerOrder'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.order-info {
|
||||
.order-id {
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.order-price {
|
||||
color: #ff4d4f;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.dealer-info {
|
||||
.dealer-level {
|
||||
margin-bottom: 6px;
|
||||
font-size: 12px;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.detail-section) {
|
||||
h4 {
|
||||
color: #1890ff;
|
||||
margin-bottom: 12px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 4px 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-table-tbody > tr > td) {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
:deep(.ant-tag) {
|
||||
margin: 2px 4px 2px 0;
|
||||
}
|
||||
</style>
|
||||
@@ -1,221 +1,42 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<div class="search-container">
|
||||
<!-- 搜索表单 -->
|
||||
<a-form
|
||||
:model="searchForm"
|
||||
layout="inline"
|
||||
class="search-form"
|
||||
@finish="handleSearch"
|
||||
>
|
||||
<a-form-item label="申请人姓名">
|
||||
<a-input
|
||||
v-model:value="searchForm.realName"
|
||||
placeholder="请输入申请人姓名"
|
||||
allow-clear
|
||||
style="width: 160px"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="手机号码">
|
||||
<a-input
|
||||
v-model:value="searchForm.mobile"
|
||||
placeholder="请输入手机号码"
|
||||
allow-clear
|
||||
style="width: 160px"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="申请方式">
|
||||
<a-select
|
||||
v-model:value="searchForm.applyType"
|
||||
placeholder="全部方式"
|
||||
allow-clear
|
||||
style="width: 120px"
|
||||
>
|
||||
<a-select-option :value="10">需要审核</a-select-option>
|
||||
<a-select-option :value="20">免审核</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="审核状态">
|
||||
<a-select
|
||||
v-model:value="searchForm.applyStatus"
|
||||
placeholder="全部状态"
|
||||
allow-clear
|
||||
style="width: 120px"
|
||||
>
|
||||
<a-select-option :value="10">待审核</a-select-option>
|
||||
<a-select-option :value="20">审核通过</a-select-option>
|
||||
<a-select-option :value="30">审核驳回</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="申请时间">
|
||||
<a-range-picker
|
||||
v-model:value="searchForm.dateRange"
|
||||
style="width: 240px"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item>
|
||||
<a-space>
|
||||
<a-button type="primary" html-type="submit" class="ele-btn-icon">
|
||||
<a-space :size="10" style="flex-wrap: wrap">
|
||||
<a-button type="primary" class="ele-btn-icon" @click="add">
|
||||
<template #icon>
|
||||
<SearchOutlined />
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
搜索
|
||||
</a-button>
|
||||
<a-button @click="resetSearch"> 重置 </a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<div class="action-buttons">
|
||||
<a-space>
|
||||
<!-- <a-button type="primary" @click="add" class="ele-btn-icon">-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <PlusOutlined />-->
|
||||
<!-- </template>-->
|
||||
<!-- 新增申请-->
|
||||
<!-- </a-button>-->
|
||||
<a-button
|
||||
type="primary"
|
||||
ghost
|
||||
:disabled="!selection?.length"
|
||||
@click="batchApprove"
|
||||
class="ele-btn-icon"
|
||||
>
|
||||
<template #icon>
|
||||
<CheckOutlined />
|
||||
</template>
|
||||
批量通过
|
||||
</a-button>
|
||||
<a-button
|
||||
:disabled="!selection?.length"
|
||||
@click="exportData"
|
||||
class="ele-btn-icon"
|
||||
>
|
||||
<template #icon>
|
||||
<ExportOutlined />
|
||||
</template>
|
||||
导出数据
|
||||
<span>添加</span>
|
||||
</a-button>
|
||||
</a-space>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive } from 'vue';
|
||||
import {
|
||||
PlusOutlined,
|
||||
SearchOutlined,
|
||||
CheckOutlined,
|
||||
ExportOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { ShopDealerApplyParam } from '@/api/shop/shopDealerApply/model';
|
||||
import dayjs from 'dayjs';
|
||||
import { PlusOutlined } from '@ant-design/icons-vue';
|
||||
import type { GradeParam } from '@/api/user/grade/model';
|
||||
import { watch } from 'vue';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的数据
|
||||
selection?: any[];
|
||||
// 选中的角色
|
||||
selection?: [];
|
||||
}>(),
|
||||
{
|
||||
selection: () => []
|
||||
}
|
||||
{}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: ShopDealerApplyParam): void;
|
||||
(e: 'search', where?: GradeParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'batchApprove'): void;
|
||||
(e: 'export'): void;
|
||||
(e: 'remove'): void;
|
||||
(e: 'batchMove'): void;
|
||||
}>();
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive<any>({
|
||||
realName: '',
|
||||
mobile: '',
|
||||
applyType: undefined,
|
||||
applyStatus: undefined,
|
||||
dateRange: undefined
|
||||
});
|
||||
|
||||
// 搜索
|
||||
const handleSearch = () => {
|
||||
const searchParams: ShopDealerApplyParam = {};
|
||||
|
||||
if (searchForm.realName) {
|
||||
searchParams.realName = searchForm.realName;
|
||||
}
|
||||
if (searchForm.mobile) {
|
||||
searchParams.mobile = searchForm.mobile;
|
||||
}
|
||||
if (searchForm.applyType) {
|
||||
searchParams.applyType = searchForm.applyType;
|
||||
}
|
||||
if (searchForm.applyStatus) {
|
||||
searchParams.applyStatus = searchForm.applyStatus;
|
||||
}
|
||||
if (searchForm.dateRange && searchForm.dateRange.length === 2) {
|
||||
searchParams.startTime = dayjs(searchForm.dateRange[0]).format(
|
||||
'YYYY-MM-DD'
|
||||
);
|
||||
searchParams.endTime = dayjs(searchForm.dateRange[1]).format(
|
||||
'YYYY-MM-DD'
|
||||
);
|
||||
}
|
||||
|
||||
emit('search', searchParams);
|
||||
};
|
||||
|
||||
// 重置搜索
|
||||
const resetSearch = () => {
|
||||
searchForm.realName = '';
|
||||
searchForm.mobile = '';
|
||||
searchForm.applyType = undefined;
|
||||
searchForm.applyStatus = undefined;
|
||||
searchForm.dateRange = undefined;
|
||||
emit('search', {});
|
||||
};
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 批量通过
|
||||
const batchApprove = () => {
|
||||
emit('batchApprove');
|
||||
};
|
||||
|
||||
// 导出数据
|
||||
const exportData = () => {
|
||||
emit('export');
|
||||
};
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.search-container {
|
||||
background: #fff;
|
||||
padding: 16px;
|
||||
border-radius: 6px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
.search-form {
|
||||
margin-bottom: 16px;
|
||||
|
||||
:deep(.ant-form-item) {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
border-top: 1px solid #f0f0f0;
|
||||
padding-top: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -5,12 +5,9 @@
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:confirm-loading="loading"
|
||||
:title="isUpdate ? '编辑分销商用户' : '添加分销商用户'"
|
||||
:body-style="{
|
||||
paddingBottom: '28px',
|
||||
maxHeight: '70vh',
|
||||
overflowY: 'auto'
|
||||
}"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
@@ -18,265 +15,189 @@
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
layout="horizontal"
|
||||
:label-col="styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }"
|
||||
:wrapper-col="
|
||||
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<!-- 基本信息 -->
|
||||
<a-divider orientation="left">基本信息</a-divider>
|
||||
<a-divider orientation="left">
|
||||
<span style="color: #1890ff; font-weight: 600">基础信息</span>
|
||||
</a-divider>
|
||||
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item
|
||||
label="用户ID"
|
||||
name="userId"
|
||||
:label-col="{ span: 8 }"
|
||||
:wrapper-col="{ span: 16 }"
|
||||
>
|
||||
<a-input-number
|
||||
:min="1"
|
||||
placeholder="请输入用户ID"
|
||||
v-model:value="form.userId"
|
||||
style="width: 100%"
|
||||
:disabled="isUpdate"
|
||||
<a-col :span="24" v-if="!isUpdate">
|
||||
<a-form-item label="关联用户" name="userId">
|
||||
<SelectUser
|
||||
:key="selectedUserText"
|
||||
:value="selectedUserText"
|
||||
:placeholder="`选择用户`"
|
||||
@done="onChooseUser"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item
|
||||
label="姓名"
|
||||
name="realName"
|
||||
:label-col="{ span: 8 }"
|
||||
:wrapper-col="{ span: 16 }"
|
||||
>
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入真实姓名"
|
||||
v-model:value="form.realName"
|
||||
/>
|
||||
<a-form-item label="类型" name="type">
|
||||
<a-select v-model:value="form.type" placeholder="请选择类型">
|
||||
<a-select-option :value="0">经销商</a-select-option>
|
||||
<a-select-option :value="1">门店</a-select-option>
|
||||
<!-- <a-select-option :value="2">集团</a-select-option>-->
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item
|
||||
label="手机号"
|
||||
name="mobile"
|
||||
:label-col="{ span: 8 }"
|
||||
:wrapper-col="{ span: 16 }"
|
||||
>
|
||||
<a-form-item label="手机号" name="mobile">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="11"
|
||||
placeholder="请输入手机号"
|
||||
:disabled="true"
|
||||
v-model:value="form.mobile"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item
|
||||
label="支付密码"
|
||||
name="payPassword"
|
||||
:label-col="{ span: 8 }"
|
||||
:wrapper-col="{ span: 16 }"
|
||||
>
|
||||
<a-input-password
|
||||
allow-clear
|
||||
placeholder="请输入支付密码"
|
||||
v-model:value="form.payPassword"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<!-- 佣金信息 -->
|
||||
<a-divider orientation="left">佣金信息</a-divider>
|
||||
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="8">
|
||||
<a-form-item
|
||||
label="可提现佣金"
|
||||
name="money"
|
||||
:label-col="{ span: 12 }"
|
||||
:wrapper-col="{ span: 12 }"
|
||||
>
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
placeholder="0.00"
|
||||
v-model:value="form.money"
|
||||
style="width: 100%"
|
||||
>
|
||||
<template #addonAfter>元</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="8">
|
||||
<a-form-item
|
||||
label="冻结佣金"
|
||||
name="freezeMoney"
|
||||
:label-col="{ span: 12 }"
|
||||
:wrapper-col="{ span: 12 }"
|
||||
>
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
placeholder="0.00"
|
||||
v-model:value="form.freezeMoney"
|
||||
style="width: 100%"
|
||||
>
|
||||
<template #addonAfter>元</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="8">
|
||||
<a-form-item
|
||||
label="累计提现"
|
||||
name="totalMoney"
|
||||
:label-col="{ span: 12 }"
|
||||
:wrapper-col="{ span: 12 }"
|
||||
>
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
placeholder="0.00"
|
||||
v-model:value="form.totalMoney"
|
||||
style="width: 100%"
|
||||
:disabled="true"
|
||||
>
|
||||
<template #addonAfter>元</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<!-- 推荐关系 -->
|
||||
<a-divider orientation="left">推荐关系</a-divider>
|
||||
|
||||
<a-form-item label="推荐人" name="refereeId">
|
||||
<a-input-group compact>
|
||||
<a-input-number
|
||||
:min="1"
|
||||
placeholder="请输入推荐人用户ID"
|
||||
v-model:value="form.refereeId"
|
||||
style="width: calc(100% - 80px)"
|
||||
/>
|
||||
<a-button type="primary" @click="selectReferee">选择</a-button>
|
||||
</a-input-group>
|
||||
</a-form-item>
|
||||
<!-- 团队信息 -->
|
||||
<a-divider orientation="left">团队信息</a-divider>
|
||||
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="8">
|
||||
<a-form-item
|
||||
label="一级成员"
|
||||
name="firstNum"
|
||||
:label-col="{ span: 12 }"
|
||||
:wrapper-col="{ span: 12 }"
|
||||
>
|
||||
<a-input-number
|
||||
:min="0"
|
||||
placeholder="0"
|
||||
v-model:value="form.firstNum"
|
||||
style="width: 100%"
|
||||
:disabled="true"
|
||||
>
|
||||
<template #addonAfter>人</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="8">
|
||||
<a-form-item
|
||||
label="二级成员"
|
||||
name="secondNum"
|
||||
:label-col="{ span: 12 }"
|
||||
:wrapper-col="{ span: 12 }"
|
||||
>
|
||||
<a-input-number
|
||||
:min="0"
|
||||
placeholder="0"
|
||||
v-model:value="form.secondNum"
|
||||
style="width: 100%"
|
||||
:disabled="true"
|
||||
>
|
||||
<template #addonAfter>人</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="8">
|
||||
<a-form-item
|
||||
label="三级成员"
|
||||
name="thirdNum"
|
||||
:label-col="{ span: 12 }"
|
||||
:wrapper-col="{ span: 12 }"
|
||||
>
|
||||
<a-input-number
|
||||
:min="0"
|
||||
placeholder="0"
|
||||
v-model:value="form.thirdNum"
|
||||
style="width: 100%"
|
||||
:disabled="true"
|
||||
>
|
||||
<template #addonAfter>人</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<!-- 其他设置 -->
|
||||
<a-divider orientation="left">其他设置</a-divider>
|
||||
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item
|
||||
label="专属二维码"
|
||||
name="qrcode"
|
||||
:label-col="{ span: 8 }"
|
||||
:wrapper-col="{ span: 16 }"
|
||||
>
|
||||
<a-input-group compact>
|
||||
<a-form-item label="真实姓名" name="realName">
|
||||
<a-input
|
||||
placeholder="系统自动生成"
|
||||
v-model:value="form.qrcode"
|
||||
style="width: calc(100% - 80px)"
|
||||
:disabled="true"
|
||||
allow-clear
|
||||
:maxlength="20"
|
||||
placeholder="请输入真实姓名"
|
||||
v-model:value="form.realName"
|
||||
/>
|
||||
<a-button type="primary" @click="generateQrcode">生成</a-button>
|
||||
</a-input-group>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<!-- <a-col :span="12">-->
|
||||
<!-- <a-form-item-->
|
||||
<!-- label="支付密码"-->
|
||||
<!-- name="payPassword"-->
|
||||
<!-- :help="isUpdate ? '留空表示不修改' : undefined"-->
|
||||
<!-- >-->
|
||||
<!-- <a-input-password-->
|
||||
<!-- allow-clear-->
|
||||
<!-- :maxlength="20"-->
|
||||
<!-- placeholder="请输入支付密码"-->
|
||||
<!-- v-model:value="form.payPassword"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- </a-col>-->
|
||||
<a-col :span="12">
|
||||
<a-form-item
|
||||
label="账户状态"
|
||||
name="isDelete"
|
||||
:label-col="{ span: 8 }"
|
||||
:wrapper-col="{ span: 16 }"
|
||||
>
|
||||
<a-radio-group v-model:value="form.isDelete">
|
||||
<a-radio :value="0">正常</a-radio>
|
||||
<a-radio :value="1">已删除</a-radio>
|
||||
</a-radio-group>
|
||||
<a-form-item label="头像" name="image">
|
||||
<a-image :src="form.avatar" :width="50" :preview="false" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<a-divider orientation="left">
|
||||
<span style="color: #1890ff; font-weight: 600">佣金信息</span>
|
||||
</a-divider>
|
||||
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="可提现" name="money">
|
||||
<a-input-number
|
||||
class="ele-fluid"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
stringMode
|
||||
placeholder="0.00"
|
||||
:disabled="true"
|
||||
v-model:value="form.money"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="已冻结" name="freezeMoney">
|
||||
<a-input-number
|
||||
class="ele-fluid"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
stringMode
|
||||
placeholder="0.00"
|
||||
:disabled="true"
|
||||
v-model:value="form.freezeMoney"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="累积提现" name="totalMoney">
|
||||
<a-input-number
|
||||
class="ele-fluid"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
stringMode
|
||||
placeholder="0.00"
|
||||
:disabled="true"
|
||||
v-model:value="form.totalMoney"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="佣金比例" name="rate">
|
||||
<a-input-number
|
||||
class="ele-fluid"
|
||||
:min="0"
|
||||
:max="1"
|
||||
:precision="4"
|
||||
stringMode
|
||||
:disabled="true"
|
||||
placeholder="例如 0.007"
|
||||
v-model:value="form.rate"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<!-- <a-col :span="12">-->
|
||||
<!-- <a-form-item label="单价" name="price">-->
|
||||
<!-- <a-input-number-->
|
||||
<!-- class="ele-fluid"-->
|
||||
<!-- :min="0"-->
|
||||
<!-- :precision="2"-->
|
||||
<!-- stringMode-->
|
||||
<!-- placeholder="0.00"-->
|
||||
<!-- v-model:value="form.price"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- </a-col>-->
|
||||
</a-row>
|
||||
|
||||
<!-- <a-row :gutter="16">-->
|
||||
<!-- <a-col :span="12">-->
|
||||
<!-- <a-form-item label="排序号" name="sortNumber">-->
|
||||
<!-- <a-input-number-->
|
||||
<!-- :min="0"-->
|
||||
<!-- :max="9999"-->
|
||||
<!-- class="ele-fluid"-->
|
||||
<!-- placeholder="请输入排序号"-->
|
||||
<!-- v-model:value="form.sortNumber"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- </a-col>-->
|
||||
<!-- <a-col :span="12">-->
|
||||
<!-- <a-form-item label="备注" name="comments">-->
|
||||
<!-- <a-textarea-->
|
||||
<!-- :rows="3"-->
|
||||
<!-- :maxlength="200"-->
|
||||
<!-- show-count-->
|
||||
<!-- placeholder="请输入备注"-->
|
||||
<!-- v-model:value="form.comments"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- </a-col>-->
|
||||
<!-- </a-row>-->
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { computed, ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject, uuid } from 'ele-admin-pro';
|
||||
import {
|
||||
addShopDealerUser,
|
||||
updateShopDealerUser
|
||||
} from '@/api/shop/shopDealerUser';
|
||||
import { assignObject, toDateString, uuid } from 'ele-admin-pro';
|
||||
import { addShopDealerUser, updateShopDealerUser } from '@/api/shop/shopDealerUser';
|
||||
import { ShopDealerUser } from '@/api/shop/shopDealerUser/model';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { FormInstance } from 'ant-design-vue/es/form';
|
||||
import { FileRecord } from '@/api/system/file/model';
|
||||
import type { User } from '@/api/system/user/model';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
@@ -309,12 +230,16 @@
|
||||
const form = reactive<ShopDealerUser>({
|
||||
id: undefined,
|
||||
userId: undefined,
|
||||
avatar: undefined,
|
||||
type: 0,
|
||||
realName: undefined,
|
||||
mobile: undefined,
|
||||
payPassword: undefined,
|
||||
payPassword: '',
|
||||
money: undefined,
|
||||
freezeMoney: undefined,
|
||||
totalMoney: undefined,
|
||||
rate: undefined,
|
||||
price: undefined,
|
||||
refereeId: undefined,
|
||||
firstNum: undefined,
|
||||
secondNum: undefined,
|
||||
@@ -324,8 +249,6 @@
|
||||
tenantId: undefined,
|
||||
createTime: undefined,
|
||||
updateTime: undefined,
|
||||
shopDealerUserId: undefined,
|
||||
shopDealerUserName: '',
|
||||
status: 0,
|
||||
comments: '',
|
||||
sortNumber: 100
|
||||
@@ -336,58 +259,90 @@
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
const createTimeText = computed(() => {
|
||||
return form.createTime ? toDateString(form.createTime, 'yyyy-MM-dd HH:mm:ss') : '';
|
||||
});
|
||||
|
||||
const updateTimeText = computed(() => {
|
||||
return form.updateTime ? toDateString(form.updateTime, 'yyyy-MM-dd HH:mm:ss') : '';
|
||||
});
|
||||
|
||||
const selectedUserText = ref<string>('');
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
userId: [
|
||||
{
|
||||
validator: (_rule: unknown, value: number | undefined) => {
|
||||
if (!isUpdate.value && !value) {
|
||||
return Promise.reject(new Error('请选择关联用户'));
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
type: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入用户ID',
|
||||
trigger: 'blur'
|
||||
type: 'number',
|
||||
message: '请选择类型',
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
realName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入真实姓名',
|
||||
type: 'string',
|
||||
message: '请填写真实姓名',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
// mobile: [
|
||||
// {
|
||||
// required: true,
|
||||
// type: 'string',
|
||||
// message: '请填写手机号',
|
||||
// trigger: 'blur'
|
||||
// },
|
||||
// {
|
||||
// pattern: /^1\\d{10}$/,
|
||||
// message: '手机号格式不正确',
|
||||
// trigger: 'blur'
|
||||
// }
|
||||
// ],
|
||||
payPassword: [
|
||||
{
|
||||
validator: (_rule: unknown, value: string) => {
|
||||
if (!isUpdate.value && !value) {
|
||||
return Promise.reject(new Error('请输入支付密码'));
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
{
|
||||
min: 2,
|
||||
max: 20,
|
||||
message: '姓名长度应在2-20个字符之间',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
mobile: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入手机号',
|
||||
trigger: 'blur'
|
||||
},
|
||||
{
|
||||
pattern: /^1[3-9]\d{9}$/,
|
||||
message: '请输入正确的手机号格式',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
money: [
|
||||
{
|
||||
type: 'number',
|
||||
min: 0,
|
||||
message: '可提现佣金不能小于0',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
freezeMoney: [
|
||||
{
|
||||
type: 'number',
|
||||
min: 0,
|
||||
message: '冻结佣金不能小于0',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const onChooseUser = (user?: User) => {
|
||||
if (!user) {
|
||||
selectedUserText.value = '';
|
||||
form.userId = undefined;
|
||||
return;
|
||||
}
|
||||
form.userId = user.userId;
|
||||
// 新增时尽量帮用户填充,避免重复输入
|
||||
if (!form.realName) {
|
||||
form.realName = user.realName ?? user.nickname;
|
||||
}
|
||||
if (!form.mobile) {
|
||||
form.mobile = user.phone ?? user.mobile;
|
||||
}
|
||||
const name = user.realName ?? user.nickname ?? '';
|
||||
const phone = user.phone ?? user.mobile ?? '';
|
||||
selectedUserText.value = phone ? `${name}(${phone})` : name;
|
||||
};
|
||||
|
||||
const chooseImage = (data: FileRecord) => {
|
||||
images.value.push({
|
||||
uid: data.id,
|
||||
@@ -404,25 +359,6 @@
|
||||
|
||||
const { resetFields } = useForm(form, rules);
|
||||
|
||||
/* 选择推荐人 */
|
||||
const selectReferee = () => {
|
||||
message.info('推荐人选择功能待开发');
|
||||
// 这里可以打开用户选择器
|
||||
};
|
||||
|
||||
/* 生成二维码 */
|
||||
const generateQrcode = () => {
|
||||
if (!form.userId) {
|
||||
message.error('请先填写用户ID');
|
||||
return;
|
||||
}
|
||||
|
||||
// 生成二维码逻辑
|
||||
const qrcode = `DEALER_${form.userId}_${Date.now()}`;
|
||||
form.qrcode = qrcode;
|
||||
message.success('二维码生成成功');
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
@@ -432,46 +368,34 @@
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
|
||||
// 数据处理
|
||||
const formData = {
|
||||
...form
|
||||
};
|
||||
|
||||
// 确保数值类型正确
|
||||
if (formData.userId) formData.userId = Number(formData.userId);
|
||||
if (formData.refereeId) formData.refereeId = Number(formData.refereeId);
|
||||
if (formData.money !== undefined)
|
||||
formData.money = Number(formData.money);
|
||||
if (formData.freezeMoney !== undefined)
|
||||
formData.freezeMoney = Number(formData.freezeMoney);
|
||||
if (formData.totalMoney !== undefined)
|
||||
formData.totalMoney = Number(formData.totalMoney);
|
||||
if (formData.firstNum !== undefined)
|
||||
formData.firstNum = Number(formData.firstNum);
|
||||
if (formData.secondNum !== undefined)
|
||||
formData.secondNum = Number(formData.secondNum);
|
||||
if (formData.thirdNum !== undefined)
|
||||
formData.thirdNum = Number(formData.thirdNum);
|
||||
if (formData.isDelete !== undefined)
|
||||
formData.isDelete = Number(formData.isDelete);
|
||||
|
||||
console.log('提交的数据:', formData);
|
||||
|
||||
const saveOrUpdate = isUpdate.value
|
||||
? updateShopDealerUser
|
||||
: addShopDealerUser;
|
||||
// 不在弹窗里编辑的字段不提交,避免误更新(如自增ID、删除标识等)
|
||||
const {
|
||||
isDelete,
|
||||
tenantId,
|
||||
createTime,
|
||||
updateTime,
|
||||
...rest
|
||||
} = form;
|
||||
const formData: ShopDealerUser = { ...rest };
|
||||
// userId 新增需要,编辑不允许修改
|
||||
if (isUpdate.value) {
|
||||
delete formData.userId;
|
||||
}
|
||||
// 编辑时留空表示不修改密码
|
||||
if (isUpdate.value && !formData.payPassword) {
|
||||
delete formData.payPassword;
|
||||
}
|
||||
const saveOrUpdate = isUpdate.value ? updateShopDealerUser : addShopDealerUser;
|
||||
saveOrUpdate(formData)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg || '操作成功');
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
console.error('保存失败:', e);
|
||||
message.error(e.message || '操作失败');
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
@@ -481,52 +405,39 @@
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
formRef.value?.clearValidate();
|
||||
images.value = [];
|
||||
if (props.data) {
|
||||
assignObject(form, props.data);
|
||||
// 不回显密码,避免误操作
|
||||
form.payPassword = '';
|
||||
selectedUserText.value = '';
|
||||
if(props.data.image){
|
||||
images.value.push({
|
||||
uid: uuid(),
|
||||
url: props.data.image,
|
||||
status: 'done'
|
||||
});
|
||||
})
|
||||
}
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
// 新增时确保表单是干净的默认值
|
||||
resetFields();
|
||||
form.payPassword = '';
|
||||
form.type = 0;
|
||||
form.status = 0;
|
||||
form.comments = '';
|
||||
form.sortNumber = 100;
|
||||
selectedUserText.value = '';
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
images.value = [];
|
||||
selectedUserText.value = '';
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
:deep(.ant-form-item-label) {
|
||||
text-align: left !important;
|
||||
}
|
||||
|
||||
:deep(.ant-form-item-label > label) {
|
||||
text-align: left !important;
|
||||
}
|
||||
|
||||
:deep(.ant-divider-horizontal.ant-divider-with-text-left) {
|
||||
margin: 24px 0 16px 0;
|
||||
|
||||
.ant-divider-inner-text {
|
||||
color: #1890ff;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.ant-input-group-addon) {
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
:deep(.ant-input-number-disabled) {
|
||||
background-color: #f5f5f5;
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -3,116 +3,146 @@
|
||||
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="applyId"
|
||||
row-key="id"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:customRow="customRow"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-org-table"
|
||||
v-model:selection="selection"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@add="openEdit"
|
||||
@batchApprove="batchApprove"
|
||||
@export="exportData"
|
||||
@remove="removeBatch"
|
||||
@batchMove="openMove"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'applyStatus'">
|
||||
<a-tag v-if="record.applyStatus === 10" color="orange"
|
||||
>待审核</a-tag
|
||||
>
|
||||
<a-tag v-if="record.applyStatus === 20" color="green">已通过</a-tag>
|
||||
<a-tag v-if="record.applyStatus === 30" color="red">已驳回</a-tag>
|
||||
<template v-if="column.key === 'image'">
|
||||
<a-image :src="record.image" :width="50" />
|
||||
</template>
|
||||
<template v-if="column.key === 'type'">
|
||||
<a-tag v-if="record.type === 0">经销商</a-tag>
|
||||
<a-tag v-if="record.type === 1" color="orange">门店</a-tag>
|
||||
<!-- <a-tag v-if="record.type === 2" color="purple">集团</a-tag>-->
|
||||
</template>
|
||||
<template v-if="column.key === 'qrcode'">
|
||||
<QrcodeOutlined :style="{fontSize: '24px'}" @click="openQrCode(record)" />
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
|
||||
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a @click="openEdit(record)" class="ele-text-primary">
|
||||
<EditOutlined />
|
||||
编辑
|
||||
</a>
|
||||
<template v-if="record.applyStatus !== 20">
|
||||
<a-divider type="vertical" />
|
||||
<a @click="approveApply(record)" class="ele-text-success">
|
||||
<CheckOutlined />
|
||||
通过
|
||||
</a>
|
||||
<a-divider type="vertical" />
|
||||
<a @click="rejectApply(record)" class="ele-text-warning">
|
||||
<CloseOutlined />
|
||||
驳回
|
||||
</a>
|
||||
<a-space>
|
||||
<a @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
v-if="record.applyStatus != 20"
|
||||
title="确定要删除此申请记录吗?"
|
||||
title="确定要删除此记录吗?"
|
||||
@confirm="remove(record)"
|
||||
placement="topRight"
|
||||
>
|
||||
<a class="ele-text-danger">
|
||||
<DeleteOutlined />
|
||||
删除
|
||||
</a>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</template>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<ShopDealerApplyEdit
|
||||
v-model:visible="showEdit"
|
||||
:data="current"
|
||||
@done="reload"
|
||||
/>
|
||||
<ShopDealerUserEdit v-model:visible="showEdit" :data="current" @done="reload" />
|
||||
|
||||
<!-- 二维码预览 -->
|
||||
<a-modal
|
||||
v-model:visible="showQrModal"
|
||||
:title="qrModalTitle"
|
||||
:footer="null"
|
||||
:width="380"
|
||||
centered
|
||||
destroy-on-close
|
||||
>
|
||||
<div style="display: flex; justify-content: center">
|
||||
<a-image v-if="qrModalUrl" :src="qrModalUrl" :width="280" :preview="false" />
|
||||
</div>
|
||||
<div style="display: flex; justify-content: center; margin-top: 12px">
|
||||
<a-space>
|
||||
<a-button @click="copyQrUrl">复制链接</a-button>
|
||||
<a-button type="primary" @click="openQrInNewTab">打开原图</a-button>
|
||||
</a-space>
|
||||
</div>
|
||||
</a-modal>
|
||||
</a-page-header>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { createVNode, ref, computed } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import {
|
||||
ExclamationCircleOutlined,
|
||||
CheckOutlined,
|
||||
CloseOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import { ExclamationCircleOutlined, QrcodeOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import Search from './components/search.vue';
|
||||
import {getPageTitle} from '@/utils/common';
|
||||
import ShopDealerApplyEdit from './components/shopDealerApplyEdit.vue';
|
||||
import {
|
||||
pageShopDealerApply,
|
||||
removeShopDealerApply,
|
||||
removeBatchShopDealerApply,
|
||||
batchApproveShopDealerApply,
|
||||
updateShopDealerApply
|
||||
} from '@/api/shop/shopDealerApply';
|
||||
import type {
|
||||
ShopDealerApply,
|
||||
ShopDealerApplyParam
|
||||
} from '@/api/shop/shopDealerApply/model';
|
||||
import ShopDealerUserEdit from './components/shopDealerUserEdit.vue';
|
||||
import { pageShopDealerUser, removeShopDealerUser, removeBatchShopDealerUser } from '@/api/shop/shopDealerUser';
|
||||
import type { ShopDealerUser, ShopDealerUserParam } from '@/api/shop/shopDealerUser/model';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<ShopDealerApply[]>([]);
|
||||
const selection = ref<ShopDealerUser[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<ShopDealerApply | null>(null);
|
||||
const current = ref<ShopDealerUser | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 是否显示二维码弹窗
|
||||
const showQrModal = ref(false);
|
||||
const qrModalUrl = ref<string>('');
|
||||
const qrModalTitle = ref<string>('二维码');
|
||||
// 是否显示批量移动弹窗
|
||||
const showMove = ref(false);
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
|
||||
const getQrCodeUrl = (userId?: number) => {
|
||||
return `https://mp-api.websoft.top/api/wx-login/getOrderQRCodeUnlimited/uid_${userId ?? ''}`;
|
||||
};
|
||||
|
||||
const openQrCode = (row: ShopDealerUser) => {
|
||||
if (!row.userId) {
|
||||
message.warning('缺少用户ID,无法生成二维码');
|
||||
return;
|
||||
}
|
||||
qrModalUrl.value = getQrCodeUrl(row.userId);
|
||||
qrModalTitle.value = row.realName ? `${row.realName} 的二维码` : `UID_${row.userId} 二维码`;
|
||||
showQrModal.value = true;
|
||||
};
|
||||
|
||||
const copyQrUrl = async () => {
|
||||
if (!qrModalUrl.value) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await navigator.clipboard.writeText(qrModalUrl.value);
|
||||
message.success('已复制');
|
||||
} catch (e) {
|
||||
message.error('复制失败,请手动复制');
|
||||
}
|
||||
};
|
||||
|
||||
const openQrInNewTab = () => {
|
||||
if (!qrModalUrl.value) {
|
||||
return;
|
||||
}
|
||||
window.open(qrModalUrl.value, '_blank');
|
||||
};
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
@@ -124,9 +154,7 @@
|
||||
if (filters) {
|
||||
where.status = filters.status;
|
||||
}
|
||||
where.type = 4;
|
||||
where.applyStatus = 20;
|
||||
return pageShopDealerApply({
|
||||
return pageShopDealerUser({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
@@ -134,201 +162,140 @@
|
||||
});
|
||||
};
|
||||
|
||||
// 表格列配置
|
||||
// 完整的列配置(包含所有字段)
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'applyId',
|
||||
key: 'applyId',
|
||||
align: 'center',
|
||||
width: 80,
|
||||
fixed: 'left'
|
||||
title: '用户ID',
|
||||
dataIndex: 'userId',
|
||||
key: 'userId',
|
||||
width: 90,
|
||||
},
|
||||
{
|
||||
title: '申请人信息',
|
||||
key: 'applicantInfo',
|
||||
align: 'left',
|
||||
fixed: 'left',
|
||||
customRender: ({ record }) => {
|
||||
return `${record.realName || '-'} (${record.mobile || '-'})`;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '申请方式',
|
||||
dataIndex: 'applyType',
|
||||
key: 'applyType',
|
||||
align: 'center',
|
||||
width: 120,
|
||||
customRender: ({ text }) => {
|
||||
const typeMap = {
|
||||
10: { text: '需审核', color: 'orange' },
|
||||
20: { text: '免审核', color: 'green' }
|
||||
};
|
||||
const type = typeMap[text] || { text: '未知', color: 'default' };
|
||||
return {
|
||||
type: 'tag',
|
||||
props: { color: type.color },
|
||||
children: type.text
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '审核状态',
|
||||
dataIndex: 'applyStatus',
|
||||
key: 'applyStatus',
|
||||
title: '类型',
|
||||
dataIndex: 'type',
|
||||
key: 'type',
|
||||
align: 'center',
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
title: '推荐人',
|
||||
dataIndex: 'refereeId',
|
||||
key: 'refereeId',
|
||||
align: 'center',
|
||||
width: 100,
|
||||
customRender: ({ text }) => (text ? `ID: ${text}` : '无')
|
||||
title: '真实姓名',
|
||||
dataIndex: 'realName',
|
||||
key: 'realName'
|
||||
},
|
||||
{
|
||||
title: '手机号',
|
||||
dataIndex: 'mobile',
|
||||
key: 'mobile'
|
||||
},
|
||||
{
|
||||
title: '可提现',
|
||||
dataIndex: 'money',
|
||||
key: 'money',
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
title: '已冻结',
|
||||
dataIndex: 'freezeMoney',
|
||||
key: 'freezeMoney',
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
title: '累积提现',
|
||||
dataIndex: 'totalMoney',
|
||||
key: 'totalMoney',
|
||||
width: 120
|
||||
},
|
||||
// {
|
||||
// title: '申请时间',
|
||||
// dataIndex: 'applyTime',
|
||||
// key: 'applyTime',
|
||||
// align: 'center',
|
||||
// width: 120,
|
||||
// customRender: ({ text }) => text ? toDateString(new Date(text), 'yyyy-MM-dd HH:mm') : '-'
|
||||
// title: '推荐人用户ID',
|
||||
// dataIndex: 'refereeId',
|
||||
// key: 'refereeId',
|
||||
// width: 120
|
||||
// },
|
||||
// {
|
||||
// title: '审核时间',
|
||||
// dataIndex: 'auditTime',
|
||||
// key: 'auditTime',
|
||||
// align: 'center',
|
||||
// customRender: ({ text }) => text ? toDateString(new Date(text), 'yyyy-MM-dd HH:mm') : '-'
|
||||
// title: '成员数量(一级)',
|
||||
// dataIndex: 'firstNum',
|
||||
// key: 'firstNum',
|
||||
// width: 120
|
||||
// },
|
||||
// {
|
||||
// title: '成员数量(二级)',
|
||||
// dataIndex: 'secondNum',
|
||||
// key: 'secondNum',
|
||||
// width: 120
|
||||
// },
|
||||
// {
|
||||
// title: '成员数量(三级)',
|
||||
// dataIndex: 'thirdNum',
|
||||
// key: 'thirdNum',
|
||||
// width: 120
|
||||
// },
|
||||
{
|
||||
title: '驳回原因',
|
||||
dataIndex: 'rejectReason',
|
||||
key: 'rejectReason',
|
||||
align: 'left',
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => text || '-'
|
||||
title: '专属二维码',
|
||||
dataIndex: 'qrcode',
|
||||
key: 'qrcode',
|
||||
align: 'center'
|
||||
},
|
||||
// {
|
||||
// title: '备注',
|
||||
// dataIndex: 'comments',
|
||||
// key: 'comments',
|
||||
// ellipsis: true
|
||||
// },
|
||||
// {
|
||||
// title: '排序号',
|
||||
// dataIndex: 'sortNumber',
|
||||
// key: 'sortNumber',
|
||||
// width: 120
|
||||
// },
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
width: 200,
|
||||
align: 'center',
|
||||
sorter: true,
|
||||
ellipsis: true
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd HH:mm:ss')
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
width: 380,
|
||||
hideInSetting: true
|
||||
}
|
||||
]);
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: ShopDealerApplyParam) => {
|
||||
const reload = (where?: ShopDealerUserParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
/* 审核通过 */
|
||||
const approveApply = (row: ShopDealerApply) => {
|
||||
Modal.confirm({
|
||||
title: '审核通过确认',
|
||||
content: `确定要通过 ${row.realName} 的经销商申请吗?`,
|
||||
icon: createVNode(CheckOutlined),
|
||||
okText: '确认通过',
|
||||
okType: 'primary',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
const hide = message.loading('正在处理审核...', 0);
|
||||
try {
|
||||
await updateShopDealerApply({
|
||||
...row,
|
||||
applyId: row.applyId,
|
||||
applyStatus: 20
|
||||
});
|
||||
hide();
|
||||
message.success('审核通过成功');
|
||||
reload();
|
||||
} catch (error: any) {
|
||||
hide();
|
||||
message.error(error.message || '审核失败,请重试');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 审核驳回 */
|
||||
const rejectApply = (row: ShopDealerApply) => {
|
||||
let rejectReason = '';
|
||||
Modal.confirm({
|
||||
title: '审核驳回',
|
||||
content: createVNode('div', null, [
|
||||
createVNode('p', null, `申请人: ${row.realName} (${row.mobile})`),
|
||||
createVNode('p', { style: 'margin-top: 12px;' }, '请输入驳回原因:'),
|
||||
createVNode('textarea', {
|
||||
placeholder: '请输入驳回原因...',
|
||||
style:
|
||||
'width: 100%; height: 80px; margin-top: 8px; padding: 8px; border: 1px solid #d9d9d9; border-radius: 4px;',
|
||||
onInput: (e: any) => {
|
||||
rejectReason = e.target.value;
|
||||
}
|
||||
})
|
||||
]),
|
||||
icon: createVNode(CloseOutlined),
|
||||
okText: '确认驳回',
|
||||
okType: 'danger',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
if (!rejectReason.trim()) {
|
||||
message.error('请输入驳回原因');
|
||||
return Promise.reject();
|
||||
}
|
||||
const hide = message.loading('正在处理审核...', 0);
|
||||
try {
|
||||
await updateShopDealerApply({
|
||||
...row,
|
||||
applyStatus: 30,
|
||||
rejectReason: rejectReason.trim()
|
||||
});
|
||||
hide();
|
||||
message.success('审核驳回成功');
|
||||
reload();
|
||||
} catch (error: any) {
|
||||
hide();
|
||||
message.error(error.message || '审核失败,请重试');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: ShopDealerApply) => {
|
||||
const openEdit = (row?: ShopDealerUser) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: ShopDealerApply) => {
|
||||
if (!row.applyId) {
|
||||
message.error('删除失败:缺少必要参数');
|
||||
return;
|
||||
}
|
||||
/* 打开批量移动弹窗 */
|
||||
const openMove = () => {
|
||||
showMove.value = true;
|
||||
};
|
||||
|
||||
const hide = message.loading('正在删除申请记录...', 0);
|
||||
removeShopDealerApply(row.applyId)
|
||||
/* 删除单个 */
|
||||
const remove = (row: ShopDealerUser) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeShopDealerUser(row.id)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg || '删除成功');
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message || '删除失败');
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -338,99 +305,34 @@
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
|
||||
const validIds = selection.value
|
||||
.filter((d) => d.applyId)
|
||||
.map((d) => d.applyId);
|
||||
if (!validIds.length) {
|
||||
message.error('选中的数据中没有有效的ID');
|
||||
return;
|
||||
}
|
||||
|
||||
Modal.confirm({
|
||||
title: '批量删除确认',
|
||||
content: `确定要删除选中的 ${validIds.length} 条申请记录吗?此操作不可恢复。`,
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
okText: '确认删除',
|
||||
okType: 'danger',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
const hide = message.loading(
|
||||
`正在删除 ${validIds.length} 条记录...`,
|
||||
0
|
||||
);
|
||||
removeBatchShopDealerApply(validIds)
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchShopDealerUser(selection.value.map((d) => d.id))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg || `成功删除 ${validIds.length} 条记录`);
|
||||
selection.value = [];
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message || '批量删除失败');
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量通过 */
|
||||
const batchApprove = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
|
||||
const pendingApplies = selection.value.filter(
|
||||
(item) => item.applyStatus === 10
|
||||
);
|
||||
if (!pendingApplies.length) {
|
||||
message.error('所选申请中没有待审核的记录');
|
||||
return;
|
||||
}
|
||||
|
||||
Modal.confirm({
|
||||
title: '批量通过确认',
|
||||
content: `确定要通过选中的 ${pendingApplies.length} 个申请吗?`,
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
okText: '确认通过',
|
||||
okType: 'primary',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
const hide = message.loading('正在批量通过...', 0);
|
||||
try {
|
||||
const ids = pendingApplies.map((item) => item.applyId);
|
||||
await batchApproveShopDealerApply(ids);
|
||||
hide();
|
||||
message.success(`成功通过 ${pendingApplies.length} 个申请`);
|
||||
selection.value = [];
|
||||
reload();
|
||||
} catch (error: any) {
|
||||
hide();
|
||||
message.error(error.message || '批量审核失败,请重试');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 导出数据 */
|
||||
const exportData = () => {
|
||||
const hide = message.loading('正在导出申请数据...', 0);
|
||||
// 这里调用导出API
|
||||
setTimeout(() => {
|
||||
hide();
|
||||
message.success('申请数据导出成功');
|
||||
}, 2000);
|
||||
};
|
||||
|
||||
/* 查询 */
|
||||
const query = () => {
|
||||
loading.value = true;
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: ShopDealerApply) => {
|
||||
const customRow = (record: ShopDealerUser) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
@@ -447,71 +349,8 @@
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'ShopDealerApply'
|
||||
name: 'ShopDealerUser'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.sys-org-table {
|
||||
:deep(.ant-table-thead > tr > th) {
|
||||
background-color: #fafafa;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
:deep(.ant-table-tbody > tr:hover > td) {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
}
|
||||
|
||||
.detail-item {
|
||||
p {
|
||||
margin: 4px 0;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
strong {
|
||||
color: #1890ff;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.ele-text-primary {
|
||||
color: #1890ff;
|
||||
|
||||
&:hover {
|
||||
color: #40a9ff;
|
||||
}
|
||||
}
|
||||
|
||||
.ele-text-info {
|
||||
color: #13c2c2;
|
||||
|
||||
&:hover {
|
||||
color: #36cfc9;
|
||||
}
|
||||
}
|
||||
|
||||
.ele-text-success {
|
||||
color: #52c41a;
|
||||
|
||||
&:hover {
|
||||
color: #73d13d;
|
||||
}
|
||||
}
|
||||
|
||||
.ele-text-warning {
|
||||
color: #faad14;
|
||||
|
||||
&:hover {
|
||||
color: #ffc53d;
|
||||
}
|
||||
}
|
||||
|
||||
.ele-text-danger {
|
||||
color: #ff4d4f;
|
||||
|
||||
&:hover {
|
||||
color: #ff7875;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<style lang="less" scoped></style>
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
import { ref } from 'vue';
|
||||
import { message } from 'ant-design-vue/es';
|
||||
import { CloudUploadOutlined } from '@ant-design/icons-vue';
|
||||
import { importSdyDealerOrder } from '@/api/sdy/sdyDealerOrder';
|
||||
import { importShopDealerOrder } from '@/api/shop/shopDealerOrder';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
@@ -68,7 +68,7 @@
|
||||
return false;
|
||||
}
|
||||
loading.value = true;
|
||||
importSdyDealerOrder(file)
|
||||
importShopDealerOrder(file)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
|
||||
@@ -24,17 +24,9 @@
|
||||
>
|
||||
<a-tabs type="card" v-model:active-key="active" @change="onChange">
|
||||
<a-tab-pane tab="基本信息" key="base">
|
||||
<a-form-item label="商品ID" name="goodsId">
|
||||
{{ form.goodsId }}
|
||||
</a-form-item>
|
||||
<a-form-item label="商品名称" name="name">
|
||||
<a-input
|
||||
allow-clear
|
||||
style="width: 558px"
|
||||
placeholder="请输入商品名称"
|
||||
v-model:value="form.name"
|
||||
/>
|
||||
</a-form-item>
|
||||
<!-- <a-form-item label="商品ID" name="goodsId">-->
|
||||
<!-- {{ form.goodsId }}-->
|
||||
<!-- </a-form-item>-->
|
||||
<a-form-item label="所属栏目" name="categoryId">
|
||||
<a-tree-select
|
||||
allow-clear
|
||||
@@ -49,6 +41,14 @@
|
||||
@change="onCategoryId"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="商品名称" name="name">
|
||||
<a-input
|
||||
allow-clear
|
||||
style="width: 558px"
|
||||
placeholder="请输入商品名称"
|
||||
v-model:value="form.name"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="商品卖点" name="comments">
|
||||
<a-textarea
|
||||
:rows="1"
|
||||
@@ -177,13 +177,64 @@
|
||||
</a-button>
|
||||
</a-upload>
|
||||
</a-form-item>
|
||||
<a-form-item label="状态" name="isShow">
|
||||
<a-radio-group v-model:value="form.isShow">
|
||||
<a-radio :value="1">上架</a-radio>
|
||||
<a-radio :value="0">下架</a-radio>
|
||||
<a-form-item label="状态" name="status">
|
||||
<a-radio-group v-model:value="form.status">
|
||||
<a-radio :value="0">上架</a-radio>
|
||||
<a-radio :value="1">下架</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
</a-tab-pane>
|
||||
<a-tab-pane tab="商品详情" key="content">
|
||||
<!-- 富文本编辑器 -->
|
||||
<div v-if="editor == 1">
|
||||
<tinymce-editor
|
||||
ref="editorRef"
|
||||
class="editor-content"
|
||||
v-model:value="content"
|
||||
:disabled="disabled"
|
||||
:init="config"
|
||||
placeholder="支持直接粘贴或拖拽图片,也可点击工具栏图片按钮从文件库选择"
|
||||
/>
|
||||
<div class="file-selector-tip">
|
||||
💡 提示:工具栏"图片"按钮从图片库选择,"上传"按钮快速上传图片;"视频"按钮从视频库选择,"上传视频"按钮快速上传视频;"一键排版"按钮自动优化文章格式;"首行缩进"按钮切换段落缩进
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Markdown编辑器 -->
|
||||
<div v-if="editor == 2">
|
||||
<!-- 📝 Markdown编辑器工具栏扩展 -->
|
||||
<div class="markdown-toolbar-extension">
|
||||
<a-button
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="openMarkdownImageSelector"
|
||||
style="margin-right: 8px;"
|
||||
>
|
||||
📷 从图片库选择
|
||||
</a-button>
|
||||
<a-button
|
||||
type="default"
|
||||
size="small"
|
||||
@click="openMarkdownVideoSelector"
|
||||
style="margin-right: 8px;"
|
||||
>
|
||||
🎬 从视频库选择
|
||||
</a-button>
|
||||
</div>
|
||||
|
||||
<MdEditor
|
||||
v-model="content"
|
||||
:disabled="disabled"
|
||||
height="500px"
|
||||
:placeholder="'请输入Markdown内容...'"
|
||||
:toolbars="markdownToolbars"
|
||||
:onUploadImg="onMarkdownUploadImg"
|
||||
/>
|
||||
<div class="file-selector-tip">
|
||||
💡 提示:支持Markdown语法,可以使用工具栏按钮从文件库选择图片/视频,也可以直接拖拽上传文件
|
||||
</div>
|
||||
</div>
|
||||
</a-tab-pane>
|
||||
<a-tab-pane tab="商品规格" key="spec">
|
||||
<a-form-item label="规格类型" name="specs">
|
||||
<a-radio-group v-model:value="form.specs">
|
||||
@@ -326,57 +377,6 @@
|
||||
</div>
|
||||
</a-form-item>
|
||||
</a-tab-pane>
|
||||
<a-tab-pane tab="商品详情" key="content">
|
||||
<!-- 富文本编辑器 -->
|
||||
<div v-if="editor == 1">
|
||||
<tinymce-editor
|
||||
ref="editorRef"
|
||||
class="editor-content"
|
||||
v-model:value="content"
|
||||
:disabled="disabled"
|
||||
:init="config"
|
||||
placeholder="支持直接粘贴或拖拽图片,也可点击工具栏图片按钮从文件库选择"
|
||||
/>
|
||||
<div class="file-selector-tip">
|
||||
💡 提示:工具栏"图片"按钮从图片库选择,"上传"按钮快速上传图片;"视频"按钮从视频库选择,"上传视频"按钮快速上传视频;"一键排版"按钮自动优化文章格式;"首行缩进"按钮切换段落缩进
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Markdown编辑器 -->
|
||||
<div v-if="editor == 2">
|
||||
<!-- 📝 Markdown编辑器工具栏扩展 -->
|
||||
<div class="markdown-toolbar-extension">
|
||||
<a-button
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="openMarkdownImageSelector"
|
||||
style="margin-right: 8px;"
|
||||
>
|
||||
📷 从图片库选择
|
||||
</a-button>
|
||||
<a-button
|
||||
type="default"
|
||||
size="small"
|
||||
@click="openMarkdownVideoSelector"
|
||||
style="margin-right: 8px;"
|
||||
>
|
||||
🎬 从视频库选择
|
||||
</a-button>
|
||||
</div>
|
||||
|
||||
<MdEditor
|
||||
v-model="content"
|
||||
:disabled="disabled"
|
||||
height="500px"
|
||||
:placeholder="'请输入Markdown内容...'"
|
||||
:toolbars="markdownToolbars"
|
||||
:onUploadImg="onMarkdownUploadImg"
|
||||
/>
|
||||
<div class="file-selector-tip">
|
||||
💡 提示:支持Markdown语法,可以使用工具栏按钮从文件库选择图片/视频,也可以直接拖拽上传文件
|
||||
</div>
|
||||
</div>
|
||||
</a-tab-pane>
|
||||
<a-tab-pane tab="营销设置" key="coupon">
|
||||
<a-form-item label="商品重量" name="goodsWeight">
|
||||
<a-input
|
||||
@@ -423,6 +423,15 @@
|
||||
v-model:value="form.position"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="排序号" name="sortNumber">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:max="9999"
|
||||
style="width: 250px"
|
||||
placeholder="请输入排序号"
|
||||
v-model:value="form.sortNumber"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="是否可以快递配送">
|
||||
<a-switch
|
||||
size="small"
|
||||
@@ -439,26 +448,139 @@
|
||||
:un-checked-value="0"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="是否开启分红角色功能" v-if="!merchantId">
|
||||
<!-- <a-form-item label="是否开启分红功能" v-if="!merchantId">-->
|
||||
<!-- <a-switch-->
|
||||
<!-- size="small"-->
|
||||
<!-- v-model:checked="form.commissionRole"-->
|
||||
<!-- :checked-value="1"-->
|
||||
<!-- :un-checked-value="0"-->
|
||||
<!-- />-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- <a-form-item label="角色分红配置" v-if="form.commissionRole === 1">-->
|
||||
<!-- <a-space>-->
|
||||
<!-- <a-input-->
|
||||
<!-- v-model:value="form.goodsRoleCommission[index].amount"-->
|
||||
<!-- v-for="(item, index) in form.goodsRoleCommission"-->
|
||||
<!-- :key="index"-->
|
||||
<!-- >-->
|
||||
<!-- <template #addonBefore>{{ item.roleName }}</template>-->
|
||||
<!-- <template #addonAfter>元</template>-->
|
||||
<!-- </a-input>-->
|
||||
<!-- </a-space>-->
|
||||
<!-- </a-form-item>-->
|
||||
|
||||
<a-divider orientation="left">分销设置</a-divider>
|
||||
<a-form-item label="是否开启分销" name="isOpenCommission">
|
||||
<a-switch
|
||||
size="small"
|
||||
v-model:checked="form.commissionRole"
|
||||
v-model:checked="form.isOpenCommission"
|
||||
:checked-value="1"
|
||||
:un-checked-value="0"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="角色分红配置" v-if="form.commissionRole === 1">
|
||||
<a-space>
|
||||
<a-input
|
||||
v-model:value="form.goodsRoleCommission[index].amount"
|
||||
v-for="(item, index) in form.goodsRoleCommission"
|
||||
:key="index"
|
||||
>
|
||||
<template #addonBefore>{{ item.roleName }}</template>
|
||||
<template #addonAfter>元</template>
|
||||
</a-input>
|
||||
</a-space>
|
||||
<template v-if="form.isOpenCommission === 1">
|
||||
<a-form-item label="分佣类型" name="commissionType">
|
||||
<a-radio-group v-model:value="form.commissionType">
|
||||
<a-radio :value="10">固定金额</a-radio>
|
||||
<a-radio :value="20">百分比</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
:label="form.commissionType === 20 ? '一级佣金(%)' : '一级佣金(元)'"
|
||||
name="firstMoney"
|
||||
>
|
||||
<a-input-number
|
||||
v-model:value="form.firstMoney"
|
||||
:min="0"
|
||||
:max="form.commissionType === 20 ? 100 : undefined"
|
||||
:precision="2"
|
||||
style="width: 250px"
|
||||
:placeholder="
|
||||
form.commissionType === 20
|
||||
? '请输入一级佣金百分比'
|
||||
: '请输入一级佣金金额'
|
||||
"
|
||||
>
|
||||
<template #addonAfter>{{
|
||||
form.commissionType === 20 ? '%' : '元'
|
||||
}}
|
||||
</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
:label="form.commissionType === 20 ? '二级佣金(%)' : '二级佣金(元)'"
|
||||
name="secondMoney"
|
||||
>
|
||||
<a-input-number
|
||||
v-model:value="form.secondMoney"
|
||||
:min="0"
|
||||
:max="form.commissionType === 20 ? 100 : undefined"
|
||||
:precision="2"
|
||||
style="width: 250px"
|
||||
:placeholder="
|
||||
form.commissionType === 20
|
||||
? '请输入二级佣金百分比'
|
||||
: '请输入二级佣金金额'
|
||||
"
|
||||
>
|
||||
<template #addonAfter>{{
|
||||
form.commissionType === 20 ? '%' : '元'
|
||||
}}
|
||||
</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
<!-- <a-form-item-->
|
||||
<!-- :label="form.commissionType === 20 ? '三级佣金(%)' : '三级佣金(元)'"-->
|
||||
<!-- name="thirdMoney"-->
|
||||
<!-- >-->
|
||||
<!-- <a-input-number-->
|
||||
<!-- v-model:value="form.thirdMoney"-->
|
||||
<!-- :min="0"-->
|
||||
<!-- :max="form.commissionType === 20 ? 100 : undefined"-->
|
||||
<!-- :precision="2"-->
|
||||
<!-- style="width: 250px"-->
|
||||
<!-- :placeholder="-->
|
||||
<!-- form.commissionType === 20-->
|
||||
<!-- ? '请输入三级佣金百分比'-->
|
||||
<!-- : '请输入三级佣金金额'-->
|
||||
<!-- "-->
|
||||
<!-- >-->
|
||||
<!-- <template #addonAfter>{{-->
|
||||
<!-- form.commissionType === 20 ? '%' : '元'-->
|
||||
<!-- }}</template>-->
|
||||
<!-- </a-input-number>-->
|
||||
<!-- </a-form-item>-->
|
||||
<a-form-item label="一级分红" name="firstDividend">
|
||||
<a-input-number
|
||||
v-model:value="form.firstDividend"
|
||||
:min="0"
|
||||
:max="form.commissionType === 20 ? 100 : undefined"
|
||||
:precision="2"
|
||||
style="width: 250px"
|
||||
placeholder="请输入一级分红"
|
||||
>
|
||||
<template #addonAfter>{{
|
||||
form.commissionType === 20 ? '%' : '元'
|
||||
}}
|
||||
</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
<a-form-item label="二级分红" name="secondDividend">
|
||||
<a-input-number
|
||||
v-model:value="form.secondDividend"
|
||||
:min="0"
|
||||
:max="form.commissionType === 20 ? 100 : undefined"
|
||||
:precision="2"
|
||||
style="width: 250px"
|
||||
placeholder="请输入二级分红"
|
||||
>
|
||||
<template #addonAfter>{{
|
||||
form.commissionType === 20 ? '%' : '元'
|
||||
}}
|
||||
</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
</template>
|
||||
<template v-if="form.type === 1 || merchantId">
|
||||
<a-form-item label="可用日期">
|
||||
<a-select v-model:value="canUseDate" mode="multiple">
|
||||
@@ -505,15 +627,6 @@
|
||||
/>
|
||||
</a-form-item>
|
||||
</template>
|
||||
<a-form-item label="排序号" name="sortNumber">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:max="9999"
|
||||
style="width: 250px"
|
||||
placeholder="请输入排序号"
|
||||
v-model:value="form.sortNumber"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
</a-form>
|
||||
@@ -988,6 +1101,14 @@ const form = reactive<ShopGoods>({
|
||||
categoryName: undefined,
|
||||
specs: 0,
|
||||
commissionRole: 0,
|
||||
// 分销佣金(新字段,后端保持 snake_case)
|
||||
isOpenCommission: 0,
|
||||
commissionType: 10,
|
||||
firstMoney: 0,
|
||||
secondMoney: 0,
|
||||
thirdMoney: 0,
|
||||
firstDividend: 0,
|
||||
secondDividend: 0,
|
||||
position: undefined,
|
||||
price: undefined,
|
||||
originPrice: undefined,
|
||||
@@ -1710,6 +1831,33 @@ const onPaste = (e) => {
|
||||
|
||||
const {resetFields} = useForm(form, rules);
|
||||
|
||||
const COMMISSION_PERCENT_FIELDS = [
|
||||
'firstMoney',
|
||||
'secondMoney',
|
||||
'thirdMoney',
|
||||
'firstDividend',
|
||||
'secondDividend'
|
||||
] as const;
|
||||
|
||||
type CommissionPercentField = (typeof COMMISSION_PERCENT_FIELDS)[number];
|
||||
|
||||
const toDbPercent = (val: unknown) => {
|
||||
if (val === null || val === undefined) return val as any;
|
||||
const num = Number(val);
|
||||
if (!Number.isFinite(num)) return val as any;
|
||||
return num / 100;
|
||||
};
|
||||
|
||||
// Back-end stores percent as a fraction (e.g. 0.1 = 10%); UI inputs percent (e.g. 10 = 10%).
|
||||
const toUiPercent = (val: unknown) => {
|
||||
if (val === null || val === undefined) return val as any;
|
||||
const num = Number(val);
|
||||
if (!Number.isFinite(num)) return val as any;
|
||||
// If historical data is already stored as 0~1, convert to 0~100 for display.
|
||||
if (num <= 1) return Number((num * 100).toFixed(2));
|
||||
return num;
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
@@ -1724,6 +1872,26 @@ const save = () => {
|
||||
if (ensureTag.value.length) form.ensureTag = ensureTag.value.join();
|
||||
if (canUseDate.value.length) form.canUseDate = canUseDate.value.join();
|
||||
|
||||
// 分销关闭时,避免把历史值一并保存到后端
|
||||
if (form.isOpenCommission !== 1) {
|
||||
form.commissionType = 10;
|
||||
form.firstMoney = 0;
|
||||
form.secondMoney = 0;
|
||||
form.thirdMoney = 0;
|
||||
form.firstDividend = 0;
|
||||
form.secondDividend = 0;
|
||||
}
|
||||
if (form.isOpenCommission === 1 && form.commissionType === 20) {
|
||||
// UI 输入:0~100;保存到后端:0~1(例如 10% => 0.1)
|
||||
const invalidPercent = COMMISSION_PERCENT_FIELDS.some((k) => {
|
||||
const v = (form as any)[k] ?? 0;
|
||||
return v < 0 || v > 100;
|
||||
});
|
||||
if (invalidPercent) {
|
||||
return message.error('佣金百分比需在 0~100 之间');
|
||||
}
|
||||
}
|
||||
|
||||
// if (form.dealerGift && !form.dealerGiftNum) return message.error('请输入经销商赠品数量');
|
||||
if (form.commissionRole === 1) {
|
||||
for (let i = 0; i < form.goodsRoleCommission.length; i++) {
|
||||
@@ -1750,6 +1918,14 @@ const save = () => {
|
||||
if (isUpdate.value) {
|
||||
formData.type = props.data.type;
|
||||
}
|
||||
if (formData.isOpenCommission === 1 && formData.commissionType === 20) {
|
||||
// Convert percent fields for persistence: 10 => 0.1
|
||||
COMMISSION_PERCENT_FIELDS.forEach((k) => {
|
||||
(formData as any)[k as CommissionPercentField] = toDbPercent(
|
||||
(formData as any)[k]
|
||||
);
|
||||
});
|
||||
}
|
||||
const saveOrUpdate = isUpdate.value ? updateShopGoods : addShopGoods;
|
||||
saveOrUpdate(formData)
|
||||
.then((msg) => {
|
||||
@@ -1875,6 +2051,17 @@ watch(
|
||||
ensureTagItem.value = '';
|
||||
if (props.data) {
|
||||
assignObject(form, props.data);
|
||||
if (form.commissionType === undefined || form.commissionType === null) {
|
||||
form.commissionType = 10;
|
||||
}
|
||||
if (form.isOpenCommission === 1 && form.commissionType === 20) {
|
||||
// Convert historical DB values (0~1) to UI percent (0~100).
|
||||
COMMISSION_PERCENT_FIELDS.forEach((k) => {
|
||||
(form as any)[k as CommissionPercentField] = toUiPercent(
|
||||
(form as any)[k]
|
||||
);
|
||||
});
|
||||
}
|
||||
if (props.data.image) {
|
||||
images.value.push({
|
||||
uid: uuid(),
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
</a-space>
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag v-if="record.status === 0" color="green">出售中</a-tag>
|
||||
<a-tag v-if="record.status === 0" color="green">已上架</a-tag>
|
||||
<a-tag v-if="record.status === 1" color="orange">待上架</a-tag>
|
||||
<a-tag v-if="record.status === 2" color="purple">待审核</a-tag>
|
||||
<a-tag v-if="record.status === 3" color="red">审核不通过</a-tag>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<a-modal
|
||||
:visible="visible"
|
||||
title="订单发送货"
|
||||
width="600px"
|
||||
width="50%"
|
||||
:confirm-loading="loading"
|
||||
@update:visible="updateVisible"
|
||||
@ok="handleSubmit"
|
||||
|
||||
@@ -324,14 +324,12 @@
|
||||
title: '订单编号',
|
||||
dataIndex: 'orderNo',
|
||||
key: 'orderNo',
|
||||
align: 'center',
|
||||
width: 200
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
title: '商品信息',
|
||||
dataIndex: 'orderGoods',
|
||||
key: 'orderGoods',
|
||||
width: 360
|
||||
key: 'orderGoods'
|
||||
},
|
||||
{
|
||||
title: '实付金额',
|
||||
@@ -390,15 +388,13 @@
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
align: 'center',
|
||||
width: 180,
|
||||
sorter: true,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => toDateString(text)
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 280,
|
||||
width: 220,
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
|
||||
Reference in New Issue
Block a user