update
This commit is contained in:
parent
c6b9269214
commit
7427b81262
@ -1005,10 +1005,7 @@ const MallOrderManage: React.FC<{ currentUser: CurrentUser, isComponent?: boolea
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
导出excel
|
导出excel
|
||||||
</Button>,
|
</Button>
|
||||||
<Button onClick={() => {
|
|
||||||
|
|
||||||
}}>导入订单</Button>
|
|
||||||
|
|
||||||
|
|
||||||
// <Button type={"primary"} onClick={() => {
|
// <Button type={"primary"} onClick={() => {
|
||||||
|
|||||||
@ -1,10 +1,202 @@
|
|||||||
import { connect } from "umi";
|
import React, { useRef, useState } from 'react';
|
||||||
|
import { connect } from 'umi';
|
||||||
import type { ConnectState } from "@/models/connect";
|
import type { ConnectState } from "@/models/connect";
|
||||||
import type { CurrentUser } from "umi";
|
import type { CurrentUser } from "umi";
|
||||||
|
import ProTable, { ActionType, ProColumns } from "@ant-design/pro-table";
|
||||||
|
import { Tag, message, Modal, Space } from "antd";
|
||||||
|
import { handleGetMEMBERSHIPList, handeGetSynchroMEMBERSHIP } from "../service";
|
||||||
|
import session from "@/utils/session";
|
||||||
|
import PageTitleBox from "@/components/PageTitleBox";
|
||||||
|
import type { FormInstance } from "antd";
|
||||||
|
|
||||||
const OwnWaterManager: React.FC<{ currentUser: CurrentUser, isComponent?: boolean, searchReq?: any }> = (props) => {
|
const OwnWaterManager: React.FC<{ currentUser: CurrentUser, isComponent?: boolean, searchReq?: any }> = (props) => {
|
||||||
|
const { currentUser } = props;
|
||||||
|
const actionRef = useRef<ActionType>();
|
||||||
|
const formRef = useRef<FormInstance>();
|
||||||
|
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
|
||||||
|
const [selectedRows, setSelectedRows] = useState<any[]>([]);
|
||||||
|
|
||||||
|
const MEMBERSHIPLEVELYNObj = session.get('MEMBERSHIPLEVELYNObj') || {};
|
||||||
|
|
||||||
|
// 辅助函数:处理标签字符串 (Logic B)
|
||||||
|
const updateTargetTags = (currentTags: string | undefined, targetTag: string, action: 'add' | 'remove') => {
|
||||||
|
let tagList = (currentTags || '').split(',').filter(Boolean);
|
||||||
|
if (action === 'add') {
|
||||||
|
if (!tagList.includes(targetTag)) {
|
||||||
|
tagList.push(targetTag);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tagList = tagList.filter(t => t !== targetTag);
|
||||||
|
}
|
||||||
|
return tagList.join(',');
|
||||||
|
};
|
||||||
|
|
||||||
|
// 批量操作通用逻辑 (Logic B)
|
||||||
|
const handleBatchAction = (action: 'add' | 'remove') => {
|
||||||
|
if (selectedRowKeys.length === 0) {
|
||||||
|
message.warning('请先选择会员');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const title = action === 'add' ? '确认批量开通权限' : '确认批量取消权限';
|
||||||
|
const content = action === 'add'
|
||||||
|
? `确定为选中的 ${selectedRowKeys.length} 名会员开通自有水权限吗?`
|
||||||
|
: `确定为选中的 ${selectedRowKeys.length} 名会员取消自有水权限吗?`;
|
||||||
|
|
||||||
|
Modal.confirm({
|
||||||
|
title,
|
||||||
|
content,
|
||||||
|
onOk: async () => {
|
||||||
|
const hide = message.loading('正在处理中...');
|
||||||
|
try {
|
||||||
|
const promises = selectedRows.map((row) => {
|
||||||
|
const newTags = updateTargetTags(row.MEMBERSHIP_TARGET, '2803', action);
|
||||||
|
return handeGetSynchroMEMBERSHIP({
|
||||||
|
...row,
|
||||||
|
MEMBERSHIP_TARGET: newTags || "#", // 若标签为空,传 # 占位
|
||||||
|
});
|
||||||
|
});
|
||||||
|
const results = await Promise.all(promises);
|
||||||
|
const allSuccess = results.every((res: any) => res.Result_Code === 100);
|
||||||
|
|
||||||
|
if (allSuccess) {
|
||||||
|
message.success('操作成功!');
|
||||||
|
setSelectedRowKeys([]);
|
||||||
|
setSelectedRows([]);
|
||||||
|
actionRef.current?.reload();
|
||||||
|
} else {
|
||||||
|
const failedCount = results.filter((res: any) => res.Result_Code !== 100).length;
|
||||||
|
message.error(`部分操作失败,失败条目数:${failedCount}`);
|
||||||
|
actionRef.current?.reload();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Batch action error:', error);
|
||||||
|
message.error('操作异常');
|
||||||
|
} finally {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleBatchOpen = () => handleBatchAction('add');
|
||||||
|
const handleBatchCancel = () => handleBatchAction('remove');
|
||||||
|
|
||||||
|
const columns: ProColumns<any>[] = [
|
||||||
|
{
|
||||||
|
title: '用户昵称',
|
||||||
|
dataIndex: 'MEMBERSHIP_NAME',
|
||||||
|
width: 150,
|
||||||
|
ellipsis: true,
|
||||||
|
align: 'center',
|
||||||
|
fieldProps: {
|
||||||
|
placeholder: '搜索用户昵称/电话',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '联系电话',
|
||||||
|
dataIndex: 'MEMBERSHIP_MOBILEPHONE',
|
||||||
|
width: 150,
|
||||||
|
align: 'center',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '会员等级',
|
||||||
|
dataIndex: 'MEMBERSHIP_LEVEL',
|
||||||
|
width: 120,
|
||||||
|
align: 'center',
|
||||||
|
valueType: 'select',
|
||||||
|
valueEnum: MEMBERSHIPLEVELYNObj,
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '自有水权限',
|
||||||
|
dataIndex: 'MEMBERSHIP_TARGET',
|
||||||
|
width: 120,
|
||||||
|
align: 'center',
|
||||||
|
valueType: 'select',
|
||||||
|
valueEnum: {
|
||||||
|
'': { text: '全部' },
|
||||||
|
'2803': { text: '已开通' },
|
||||||
|
'-2803': { text: '未开通' },
|
||||||
|
},
|
||||||
|
hideInTable: true,
|
||||||
|
initialValue: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '权限状态',
|
||||||
|
dataIndex: 'MEMBERSHIP_TARGET_STATUS',
|
||||||
|
width: 120,
|
||||||
|
align: 'center',
|
||||||
|
hideInSearch: true,
|
||||||
|
render: (_, record) => {
|
||||||
|
const isAuth = record.MEMBERSHIP_TARGET === '2803' || record.MEMBERSHIP_TARGET?.toString().includes('2803');
|
||||||
return (
|
return (
|
||||||
<div>
|
<Tag color={isAuth ? 'green' : 'red'}>
|
||||||
|
{isAuth ? '已开通' : '未开通'}
|
||||||
|
</Tag>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div style={{ background: '#fff', padding: '16px' }}>
|
||||||
|
<ProTable
|
||||||
|
actionRef={actionRef}
|
||||||
|
formRef={formRef}
|
||||||
|
columns={columns}
|
||||||
|
rowKey="MEMBERSHIP_ID"
|
||||||
|
headerTitle={<PageTitleBox props={props} />}
|
||||||
|
bordered
|
||||||
|
scroll={{ y: 'calc(100vh - 500px)' }}
|
||||||
|
search={{
|
||||||
|
labelWidth: 'auto',
|
||||||
|
defaultCollapsed: false,
|
||||||
|
span: 6,
|
||||||
|
}}
|
||||||
|
request={async (params, sorter) => {
|
||||||
|
const sortstr = Object.keys(sorter).map(n => {
|
||||||
|
const value = sorter[n]
|
||||||
|
return value ? `${n} ${value.replace('end', '')}` : ''
|
||||||
|
}).filter(Boolean).toString();
|
||||||
|
|
||||||
|
const req = {
|
||||||
|
SearchParameter: {
|
||||||
|
OWNERUNIT_ID: currentUser?.OwnerUnitId || 911,
|
||||||
|
MEMBERSHIP_TARGET: params?.MEMBERSHIP_TARGET || "",
|
||||||
|
MEMBERSHIP_STATES: 1000,
|
||||||
|
},
|
||||||
|
keyWord: {
|
||||||
|
Key: "MEMBERSHIP_NAME,MEMBERSHIP_MOBILEPHONE",
|
||||||
|
value: params?.MEMBERSHIP_NAME || ""
|
||||||
|
},
|
||||||
|
PageIndex: params.current || 1,
|
||||||
|
PageSize: params?.pageSize || 20,
|
||||||
|
sortstr: sortstr,
|
||||||
|
};
|
||||||
|
|
||||||
|
const data = await handleGetMEMBERSHIPList(req);
|
||||||
|
return {
|
||||||
|
data: data?.List || [],
|
||||||
|
success: true,
|
||||||
|
total: data?.TotalCount || 0,
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
rowSelection={{
|
||||||
|
selectedRowKeys,
|
||||||
|
onChange: (keys, rows) => {
|
||||||
|
setSelectedRowKeys(keys);
|
||||||
|
setSelectedRows(rows);
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
tableAlertOptionRender={() => (
|
||||||
|
<Space size={16}>
|
||||||
|
<a onClick={handleBatchOpen}>批量开通权限</a>
|
||||||
|
<a onClick={handleBatchCancel} style={{ color: '#ff4d4f' }}>批量取消权限</a>
|
||||||
|
</Space>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -834,7 +834,13 @@ const TradingLedger: React.FC<{ currentUser: CurrentUser }> = (props) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
导出财务结算Excel
|
导出财务结算Excel
|
||||||
</Button>
|
</Button>,
|
||||||
|
<Button onClick={() => {
|
||||||
|
|
||||||
|
}}>导入订单</Button>,
|
||||||
|
<Button onClick={() => {
|
||||||
|
window.open('https://samanage.yciccloud.com:6060/cloud/%E2%80%9C%E5%BD%A9%E4%BA%91%E9%A9%BF%E2%80%9D%E5%95%86%E5%9F%8E%E8%AE%A2%E5%8D%95%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx', '_blank')
|
||||||
|
}}>下载模板</Button>
|
||||||
]
|
]
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user