forked from yoone/WEB
1
0
Fork 0

客户评星

This commit is contained in:
cll 2025-07-23 17:29:28 +08:00
parent f32d2d2879
commit cc3ec13156
3 changed files with 51 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import {
customercontrollerDeltag, customercontrollerDeltag,
customercontrollerGetcustomerlist, customercontrollerGetcustomerlist,
customercontrollerGettags, customercontrollerGettags,
customercontrollerSetrate,
} from '@/servers/api/customer'; } from '@/servers/api/customer';
import { import {
ActionType, ActionType,
@ -13,12 +14,13 @@ import {
ProFormSelect, ProFormSelect,
ProTable, ProTable,
} from '@ant-design/pro-components'; } from '@ant-design/pro-components';
import { App, Button, Space, Tag } from 'antd'; import { App, Button, Rate, Space, Tag } from 'antd';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { useRef, useState } from 'react'; import { useRef, useState } from 'react';
const ListPage: React.FC = () => { const ListPage: React.FC = () => {
const actionRef = useRef<ActionType>(); const actionRef = useRef<ActionType>();
const { message } = App.useApp();
const columns: ProColumns[] = [ const columns: ProColumns[] = [
{ {
title: '用户名', title: '用户名',
@ -89,6 +91,37 @@ const ListPage: React.FC = () => {
hideInSearch: true, hideInSearch: true,
sorter: true, sorter: true,
}, },
{
title: '等级',
hideInSearch: true,
render: (_, record) => {
if(!record.yoone_orders || !record.yoone_total) return '-'
if(Number(record.yoone_orders) === 1 && Number(record.yoone_total) > 0 ) return 'B'
return '-'
}
},
{
title: '评星',
dataIndex: 'rate',
width: 200,
render: (_, record) => {
return <Rate onChange={async(val)=>{
try{
const { success, message: msg } = await customercontrollerSetrate({
id: record.customerId,
rate: val
});
if (success) {
message.success(msg);
actionRef.current?.reload();
}
}catch(e){
message.error(e.message);
}
}} value={record.rate} />
},
},
{ {
title: 'phone', title: 'phone',
dataIndex: 'phone', dataIndex: 'phone',

View File

@ -17,6 +17,21 @@ export async function customercontrollerGetcustomerlist(
}); });
} }
/** 此处后端没有提供注释 PUT /customer/rate */
export async function customercontrollerSetrate(
body: Record<string, any>,
options?: { [key: string]: any },
) {
return request<API.BooleanRes>('/customer/rate', {
method: 'PUT',
headers: {
'Content-Type': 'text/plain',
},
data: body,
...(options || {}),
});
}
/** 此处后端没有提供注释 POST /customer/tag/add */ /** 此处后端没有提供注释 POST /customer/tag/add */
export async function customercontrollerAddtag( export async function customercontrollerAddtag(
body: API.CustomerTagDTO, body: API.CustomerTagDTO,

View File

@ -110,6 +110,7 @@ declare namespace API {
sorterValue?: string; sorterValue?: string;
state?: string; state?: string;
first_purchase_date?: string; first_purchase_date?: string;
customerId?: number;
}; };
type CustomerTagDTO = { type CustomerTagDTO = {
@ -798,6 +799,7 @@ declare namespace API {
sorterValue?: string; sorterValue?: string;
state?: string; state?: string;
first_purchase_date?: string; first_purchase_date?: string;
customerId?: number;
}; };
type QueryFlavorsDTO = { type QueryFlavorsDTO = {