feat(cms): 新增网站密钥和字段加密功能- 在 CMS 网站模型中新增 websiteSecret 字段用于存储小程序密钥
- 为 CMS 网站字段添加 encrypted 字段以支持内容加密- 实现字段值的加密和解密功能,提升数据安全性- 更新网站编辑组件以支持密钥的输入和存储- 调整字段编辑组件,增加加密开关和类型选项 -优化字段列表展示逻辑,支持加密字段的特殊处理- 修改字段值类型为 any以适应多种数据格式 - 完善字段编辑表单验证规则和保存逻辑 - 更新相关组件的类型定义和事件处理- 调整界面布局和交互细节,提升用户体验
This commit is contained in:
172
src/views/sdy/shopDealerOrder/components/search.vue
Normal file
172
src/views/sdy/shopDealerOrder/components/search.vue
Normal file
@@ -0,0 +1,172 @@
|
||||
<!-- 搜索表单 -->
|
||||
<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.orderId"
|
||||
placeholder="请输入订单编号"
|
||||
allow-clear
|
||||
style="width: 160px"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="商品名称">
|
||||
<a-input
|
||||
v-model:value="searchForm.productName"
|
||||
placeholder="请输入商品名称"
|
||||
allow-clear
|
||||
style="width: 160px"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="订单状态">
|
||||
<a-select
|
||||
v-model:value="searchForm.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="searchForm.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-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"
|
||||
:disabled="!selection?.length"
|
||||
@click="batchSettle"
|
||||
class="ele-btn-icon"
|
||||
>
|
||||
<template #icon>
|
||||
<DollarOutlined />
|
||||
</template>
|
||||
批量结算
|
||||
</a-button>
|
||||
</a-space>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive } from 'vue';
|
||||
import {
|
||||
SearchOutlined,
|
||||
DollarOutlined,
|
||||
ExportOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { ShopDealerOrderParam } from '@/api/shop/shopDealerOrder/model';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
// 选中的数据
|
||||
selection?: any[];
|
||||
}>(),
|
||||
{
|
||||
selection: () => []
|
||||
}
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: ShopDealerOrderParam): void;
|
||||
(e: 'batchSettle'): void;
|
||||
(e: 'export'): void;
|
||||
}>();
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = reactive<ShopDealerOrderParam>({
|
||||
orderId: undefined,
|
||||
orderNo: '',
|
||||
productName: '',
|
||||
isInvalid: undefined,
|
||||
isSettled: undefined
|
||||
});
|
||||
|
||||
// 搜索
|
||||
const handleSearch = () => {
|
||||
const searchParams = { ...searchForm };
|
||||
// 清除空值
|
||||
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 : '';
|
||||
});
|
||||
emit('search', {});
|
||||
};
|
||||
|
||||
// 批量结算
|
||||
const batchSettle = () => {
|
||||
emit('batchSettle');
|
||||
};
|
||||
|
||||
// 导出数据
|
||||
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>
|
||||
458
src/views/sdy/shopDealerOrder/components/shopDealerOrderEdit.vue
Normal file
458
src/views/sdy/shopDealerOrder/components/shopDealerOrderEdit.vue
Normal file
@@ -0,0 +1,458 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<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-form-item label="订单总金额" name="orderPrice">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
placeholder="请输入订单总金额(不含运费)"
|
||||
v-model:value="form.orderPrice"
|
||||
style="width: 300px"
|
||||
>
|
||||
<template #addonAfter>元</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
|
||||
<!-- 分销商信息 -->
|
||||
<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="red">一级分销商</a-tag>
|
||||
</h4>
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="用户ID" name="firstUserId">
|
||||
<a-input-number
|
||||
:min="1"
|
||||
placeholder="请输入一级分销商用户ID"
|
||||
v-model:value="form.firstUserId"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="分销佣金" name="firstMoney">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
placeholder="请输入一级分销佣金"
|
||||
v-model:value="form.firstMoney"
|
||||
style="width: 100%"
|
||||
>
|
||||
<template #addonAfter>元</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
|
||||
<!-- 二级分销商 -->
|
||||
<div class="dealer-section">
|
||||
<h4 class="dealer-title">
|
||||
<a-tag color="orange">二级分销商</a-tag>
|
||||
</h4>
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="用户ID" name="secondUserId">
|
||||
<a-input-number
|
||||
:min="1"
|
||||
placeholder="请输入二级分销商用户ID"
|
||||
v-model:value="form.secondUserId"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="分销佣金" name="secondMoney">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
placeholder="请输入二级分销佣金"
|
||||
v-model:value="form.secondMoney"
|
||||
style="width: 100%"
|
||||
>
|
||||
<template #addonAfter>元</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
|
||||
<!-- 三级分销商 -->
|
||||
<div class="dealer-section">
|
||||
<h4 class="dealer-title">
|
||||
<a-tag color="gold">三级分销商</a-tag>
|
||||
</h4>
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="12">
|
||||
<a-form-item label="用户ID" name="thirdUserId">
|
||||
<a-input-number
|
||||
:min="1"
|
||||
placeholder="请输入三级分销商用户ID"
|
||||
v-model:value="form.thirdUserId"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="分销佣金" name="thirdMoney">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
placeholder="请输入三级分销佣金"
|
||||
v-model:value="form.thirdMoney"
|
||||
style="width: 100%"
|
||||
>
|
||||
<template #addonAfter>元</template>
|
||||
</a-input-number>
|
||||
</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="isInvalid">
|
||||
<a-radio-group v-model:value="form.isInvalid">
|
||||
<a-radio :value="0">有效</a-radio>
|
||||
<a-radio :value="1">失效</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="结算状态" name="isSettled">
|
||||
<a-radio-group v-model:value="form.isSettled">
|
||||
<a-radio :value="0">未结算</a-radio>
|
||||
<a-radio :value="1">已结算</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<a-form-item label="结算时间" name="settleTime" v-if="form.isSettled === 1">
|
||||
<a-date-picker
|
||||
v-model:value="form.settleTime"
|
||||
show-time
|
||||
placeholder="请选择结算时间"
|
||||
style="width: 300px"
|
||||
/>
|
||||
</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, uuid } from 'ele-admin-pro';
|
||||
import { addShopDealerOrder, updateShopDealerOrder } from '@/api/shop/shopDealerOrder';
|
||||
import { ShopDealerOrder } from '@/api/shop/shopDealerOrder/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?: 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 images = ref<ItemType[]>([]);
|
||||
|
||||
// 表单数据
|
||||
const form = reactive<ShopDealerOrder>({
|
||||
id: undefined,
|
||||
userId: undefined,
|
||||
orderId: undefined,
|
||||
orderPrice: undefined,
|
||||
firstUserId: undefined,
|
||||
secondUserId: undefined,
|
||||
thirdUserId: undefined,
|
||||
firstMoney: undefined,
|
||||
secondMoney: undefined,
|
||||
thirdMoney: 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'
|
||||
}
|
||||
],
|
||||
orderId: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入订单ID',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
orderPrice: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入订单总金额',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
firstUserId: [
|
||||
{
|
||||
validator: (rule: any, value: any) => {
|
||||
if (form.firstMoney && !value) {
|
||||
return Promise.reject('设置了一级佣金必须填写一级分销商用户ID');
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
firstMoney: [
|
||||
{
|
||||
validator: (rule: any, value: any) => {
|
||||
if (form.firstUserId && !value) {
|
||||
return Promise.reject('设置了一级分销商必须填写一级佣金');
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
secondUserId: [
|
||||
{
|
||||
validator: (rule: any, value: any) => {
|
||||
if (form.secondMoney && !value) {
|
||||
return Promise.reject('设置了二级佣金必须填写二级分销商用户ID');
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
secondMoney: [
|
||||
{
|
||||
validator: (rule: any, value: any) => {
|
||||
if (form.secondUserId && !value) {
|
||||
return Promise.reject('设置了二级分销商必须填写二级佣金');
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
thirdUserId: [
|
||||
{
|
||||
validator: (rule: any, value: any) => {
|
||||
if (form.thirdMoney && !value) {
|
||||
return Promise.reject('设置了三级佣金必须填写三级分销商用户ID');
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
thirdMoney: [
|
||||
{
|
||||
validator: (rule: any, value: any) => {
|
||||
if (form.thirdUserId && !value) {
|
||||
return Promise.reject('设置了三级分销商必须填写三级佣金');
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
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 ? updateShopDealerOrder : addShopDealerOrder;
|
||||
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);
|
||||
// 处理时间字段
|
||||
if (props.data.settleTime) {
|
||||
form.settleTime = dayjs(props.data.settleTime);
|
||||
}
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
// 重置为默认值
|
||||
Object.assign(form, {
|
||||
id: undefined,
|
||||
userId: undefined,
|
||||
orderId: 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>
|
||||
506
src/views/sdy/shopDealerOrder/index.vue
Normal file
506
src/views/sdy/shopDealerOrder/index.vue
Normal file
@@ -0,0 +1,506 @@
|
||||
<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="shopDealerOrderId"
|
||||
: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="exportData"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'orderInfo'">
|
||||
<div class="order-info">
|
||||
<div class="order-id">订单号: {{ record.orderId || '-' }}</div>
|
||||
<div class="order-price">金额: ¥{{ parseFloat(record.orderPrice || '0').toFixed(2) }}</div>
|
||||
</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="processing">未结算</a-tag>
|
||||
<a-tag v-if="record.isSettled === 1" color="success">已结算</a-tag>
|
||||
</template>
|
||||
|
||||
<template v-if="column.key === 'action'">
|
||||
<a @click="viewDetail(record)" class="ele-text-info">
|
||||
<EyeOutlined/>
|
||||
详情
|
||||
</a>
|
||||
<template v-if="record.isSettled === 0 && record.isInvalid === 0">
|
||||
<a-divider type="vertical"/>
|
||||
<a @click="settleOrder(record)" class="ele-text-success">
|
||||
<DollarOutlined/>
|
||||
结算
|
||||
</a>
|
||||
</template>
|
||||
<template v-if="record.isInvalid === 0">
|
||||
<a-divider type="vertical"/>
|
||||
<a-popconfirm
|
||||
title="确定要标记此订单为失效吗?"
|
||||
@confirm="invalidateOrder(record)"
|
||||
placement="topRight"
|
||||
>
|
||||
<a class="ele-text-warning">
|
||||
<CloseOutlined/>
|
||||
失效
|
||||
</a>
|
||||
</a-popconfirm>
|
||||
</template>
|
||||
</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,
|
||||
EyeOutlined,
|
||||
DollarOutlined,
|
||||
CloseOutlined
|
||||
} 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 ShopDealerOrderEdit from './components/shopDealerOrderEdit.vue';
|
||||
import {pageShopDealerOrder, removeShopDealerOrder, removeBatchShopDealerOrder} from '@/api/shop/shopDealerOrder';
|
||||
import type {ShopDealerOrder, ShopDealerOrderParam} from '@/api/shop/shopDealerOrder/model';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<ShopDealerOrder[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<ShopDealerOrder | 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 pageShopDealerOrder({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: '商品信息',
|
||||
key: 'productInfo',
|
||||
align: 'left',
|
||||
width: 200,
|
||||
customRender: ({record}) => {
|
||||
return `商品ID: ${record.productId || '-'}`;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '单价/数量',
|
||||
key: 'priceInfo',
|
||||
align: 'center',
|
||||
width: 120,
|
||||
customRender: ({record}) => {
|
||||
return `¥${parseFloat(record.unitPrice || '0').toFixed(2)} × ${record.quantity || 1}`;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '订单信息',
|
||||
key: 'orderInfo',
|
||||
align: 'left',
|
||||
width: 180
|
||||
},
|
||||
{
|
||||
title: '买家',
|
||||
dataIndex: 'userId',
|
||||
key: 'userId',
|
||||
align: 'center',
|
||||
width: 100,
|
||||
customRender: ({text}) => `用户${text || '-'}`
|
||||
},
|
||||
{
|
||||
title: '分销商信息',
|
||||
key: 'dealerInfo',
|
||||
align: 'left',
|
||||
width: 300
|
||||
},
|
||||
{
|
||||
title: '订单状态',
|
||||
dataIndex: 'isInvalid',
|
||||
key: 'isInvalid',
|
||||
align: 'center',
|
||||
width: 100,
|
||||
filters: [
|
||||
{text: '有效', value: 0},
|
||||
{text: '失效', value: 1}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '结算状态',
|
||||
dataIndex: 'isSettled',
|
||||
key: 'isSettled',
|
||||
align: 'center',
|
||||
width: 100,
|
||||
filters: [
|
||||
{text: '未结算', value: 0},
|
||||
{text: '已结算', value: 1}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '结算时间',
|
||||
dataIndex: 'settleTime',
|
||||
key: 'settleTime',
|
||||
align: 'center',
|
||||
width: 120,
|
||||
customRender: ({text}) => text ? toDateString(new Date(text), 'yyyy-MM-dd HH:mm') : '-'
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
align: 'center',
|
||||
width: 180,
|
||||
sorter: true,
|
||||
customRender: ({text}) => toDateString(text, 'yyyy-MM-dd HH:mm')
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 240,
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
}
|
||||
]);
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: ShopDealerOrderParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({where: where});
|
||||
};
|
||||
|
||||
/* 查看订单详情 */
|
||||
const viewDetail = (row: ShopDealerOrder) => {
|
||||
Modal.info({
|
||||
title: '分销订单详情',
|
||||
width: 800,
|
||||
content: createVNode('div', {style: 'max-height: 500px; overflow-y: auto;'}, [
|
||||
createVNode('div', {class: 'detail-section'}, [
|
||||
createVNode('h4', null, '订单基本信息'),
|
||||
createVNode('p', null, `订单ID: ${row.orderId || '-'}`),
|
||||
createVNode('p', null, `买家用户ID: ${row.userId || '-'}`),
|
||||
createVNode('p', null, `订单金额: ¥${parseFloat(row.orderPrice || '0').toFixed(2)}`),
|
||||
createVNode('p', null, `创建时间: ${row.createTime ? toDateString(row.createTime, 'yyyy-MM-dd HH:mm:ss') : '-'}`),
|
||||
]),
|
||||
createVNode('div', {class: 'detail-section', style: 'margin-top: 16px;'}, [
|
||||
createVNode('h4', null, '分销商信息'),
|
||||
...(row.firstUserId ? [
|
||||
createVNode('div', {style: 'margin: 8px 0; padding: 8px; background: #fff2f0; border-left: 3px solid #ff4d4f;'}, [
|
||||
createVNode('strong', null, '一级分销商'),
|
||||
createVNode('p', null, `用户ID: ${row.firstUserId}`),
|
||||
createVNode('p', null, `佣金: ¥${parseFloat(row.firstMoney || '0').toFixed(2)}`)
|
||||
])
|
||||
] : []),
|
||||
...(row.secondUserId ? [
|
||||
createVNode('div', {style: 'margin: 8px 0; padding: 8px; background: #fff7e6; border-left: 3px solid #fa8c16;'}, [
|
||||
createVNode('strong', null, '二级分销商'),
|
||||
createVNode('p', null, `用户ID: ${row.secondUserId}`),
|
||||
createVNode('p', null, `佣金: ¥${parseFloat(row.secondMoney || '0').toFixed(2)}`)
|
||||
])
|
||||
] : []),
|
||||
...(row.thirdUserId ? [
|
||||
createVNode('div', {style: 'margin: 8px 0; padding: 8px; background: #fffbe6; border-left: 3px solid #fadb14;'}, [
|
||||
createVNode('strong', null, '三级分销商'),
|
||||
createVNode('p', null, `用户ID: ${row.thirdUserId}`),
|
||||
createVNode('p', null, `佣金: ¥${parseFloat(row.thirdMoney || '0').toFixed(2)}`)
|
||||
])
|
||||
] : [])
|
||||
]),
|
||||
createVNode('div', {class: 'detail-section', style: 'margin-top: 16px;'}, [
|
||||
createVNode('h4', null, '状态信息'),
|
||||
createVNode('p', null, [
|
||||
'订单状态: ',
|
||||
createVNode('span', {
|
||||
style: `color: ${row.isInvalid === 0 ? '#52c41a' : '#ff4d4f'}; font-weight: bold;`
|
||||
}, row.isInvalid === 0 ? '有效' : '失效')
|
||||
]),
|
||||
createVNode('p', null, [
|
||||
'结算状态: ',
|
||||
createVNode('span', {
|
||||
style: `color: ${row.isSettled === 1 ? '#52c41a' : '#1890ff'}; font-weight: bold;`
|
||||
}, row.isSettled === 1 ? '已结算' : '未结算')
|
||||
]),
|
||||
createVNode('p', null, `结算时间: ${row.settleTime ? toDateString(new Date(row.settleTime), 'yyyy-MM-dd HH:mm:ss') : '-'}`),
|
||||
])
|
||||
]),
|
||||
okText: '关闭'
|
||||
});
|
||||
};
|
||||
|
||||
/* 结算单个订单 */
|
||||
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
|
||||
setTimeout(() => {
|
||||
hide();
|
||||
message.success('结算成功');
|
||||
reload();
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 标记订单失效 */
|
||||
const invalidateOrder = (row: ShopDealerOrder) => {
|
||||
const hide = message.loading('正在处理...', 0);
|
||||
// 这里调用失效API
|
||||
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 exportData = () => {
|
||||
const hide = message.loading('正在导出数据...', 0);
|
||||
// 这里调用导出API
|
||||
setTimeout(() => {
|
||||
hide();
|
||||
message.success('数据导出成功');
|
||||
}, 2000);
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
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>
|
||||
Reference in New Issue
Block a user