小程序用户改用门店登录
This commit is contained in:
@@ -1,16 +1,30 @@
|
||||
import React from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Tag, Typography } from 'antd';
|
||||
import XinTable from '@/components/XinTable';
|
||||
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings.ts';
|
||||
import type INotice from '@/domain/iNotice.ts';
|
||||
import { NOTICE_READ_MAP, NOTICE_TYPE_MAP } from '@/domain/iNotice.ts';
|
||||
import type IStore from '@/domain/iStore.ts';
|
||||
import { getStoreOptions } from '@/api/customer/store.ts';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
|
||||
/**
|
||||
* 通知管理(user_id=0 为全员广播)
|
||||
* 通知管理(store_id=0 为全员广播)
|
||||
*/
|
||||
const NoticePage: React.FC = () => {
|
||||
const [stores, setStores] = useState<IStore[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
getStoreOptions().then((res) => setStores(res.data.data ?? []));
|
||||
}, []);
|
||||
|
||||
const storeNameMap = new Map(stores.map((s) => [s.id, s.name]));
|
||||
const storeOptions = [
|
||||
{ label: '全员广播', value: 0 },
|
||||
...stores.map((s) => ({ label: s.name ?? '', value: s.id ?? 0 })),
|
||||
];
|
||||
|
||||
const columns: XinTableColumn<INotice>[] = [
|
||||
{
|
||||
title: 'ID',
|
||||
@@ -48,21 +62,22 @@ const NoticePage: React.FC = () => {
|
||||
},
|
||||
{
|
||||
title: '接收对象',
|
||||
dataIndex: 'user_id',
|
||||
valueType: 'digit',
|
||||
hideInTable: false,
|
||||
dataIndex: 'store_id',
|
||||
valueType: 'select',
|
||||
hideInSearch: true,
|
||||
initialValue: 0,
|
||||
fieldProps: {
|
||||
min: 0,
|
||||
precision: 0,
|
||||
placeholder: '留空或 0 = 全员广播',
|
||||
options: storeOptions,
|
||||
showSearch: true,
|
||||
optionFilterProp: 'label',
|
||||
placeholder: '默认全员广播',
|
||||
},
|
||||
align: 'center',
|
||||
render: (_, record) =>
|
||||
record.user_id === 0 ? (
|
||||
record.store_id === 0 ? (
|
||||
<Tag color="gold">全员广播</Tag>
|
||||
) : (
|
||||
<Tag>{`用户 #${record.user_id}`}</Tag>
|
||||
<Tag>{storeNameMap.get(record.store_id) ?? `门店 #${record.store_id}`}</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
@@ -119,7 +134,7 @@ const NoticePage: React.FC = () => {
|
||||
<div className="mb-5">
|
||||
<Title level={3}>通知管理</Title>
|
||||
<Text type="secondary">
|
||||
向小程序用户发送消息;接收对象留空或填 0 为全员广播,价格调整通知由批量调价自动生成。
|
||||
向门店端小程序发送消息;接收对象默认全员广播,价格调整通知由批量调价自动生成。
|
||||
</Text>
|
||||
</div>
|
||||
<XinTable<INotice> {...tableProps} />
|
||||
|
||||
Reference in New Issue
Block a user