import { Button, Popconfirm, Tabs } from 'antd' import React, { useMemo } from 'react' import { dayjsFormat } from '@/utils/utils' import classNames from 'classnames' import { isDevMode } from '@/utils/env' import { VList } from 'virtuallist-antd' import consts from '@/consts' import type { ProColumns } from '@ant-design/pro-table' import ProTable from '@ant-design/pro-table' import { updateCustomerService, delCustomerService, updateClientService, delClientService } from '@/services/customer' import { useModal } from '@/components/ModalStore' import { useDispatch, useRequest } from '@umijs/max' const { TabPane } = Tabs export enum Servicelog { /** 上门服务 */ VISIT = '1', /** 电话拜访 */ CALL = '2', /** 其他事项 */ OTHER = '3', /** 在线服务 */ ONLINE = '4' } export enum ServiceLogType { CLIENT, COMPANY } export const servicelogEnum = { [Servicelog.VISIT]: { title: '上门服务', bg: 'bg-hex-886ab5', text: 'text-hex-886ab5', border: 'border-hex-886ab5' }, [Servicelog.CALL]: { title: '电话拜访', bg: 'bg-hex-246daf', text: 'text-hex-246daf', border: 'border-hex-246daf' }, [Servicelog.OTHER]: { title: '其他事项', bg: 'bg-hex-1ca081', text: 'text-hex-1ca081', border: 'border-hex-1ca081' }, [Servicelog.ONLINE]: { title: '在线服务', bg: 'bg-hex-b8795e', text: 'text-hex-b8795e ', border: 'border-hex-b8795e' } } type ClientLowerListProps = { logList: { log: any[] } serviceList: API.ServiceLogItem[] updatePayload: { main: string; target: string } } type ServiceLogItemProps = { item: API.ServiceLogItem logType: ServiceLogType updatePayload: { main: string; target: string } } export const ServiceLogItem: React.FC = ({ item, logType, updatePayload }) => { const dispatchModal = useModal() const dispatch = useDispatch() const { run: truUpdate } = useRequest( logType === ServiceLogType.COMPANY ? updateCustomerService : updateClientService, { manual: true, onSuccess: () => { dispatch({ type: 'refresh/commitAction', payload: updatePayload }) } } ) const { run: truDel } = useRequest( logType === ServiceLogType.COMPANY ? delCustomerService : delClientService, { manual: true, onSuccess: () => { dispatch({ type: 'refresh/commitAction', payload: updatePayload }) } } ) const handleOnEdit = async (defaultValues: API.ServiceLogItem) => { dispatchModal('M_RECORD_ADD', { defaultValues, onConfirm: truUpdate }) } return (
{item.staffName}
{dayjsFormat(item.createTime, 'HH:mm:ss')}
{servicelogEnum[item.status]?.title}
{dayjsFormat(item.date, 'YYYY-MM-DD')}
{item.mark}
{item.isOperation ? (
truDel({ id: item.id })}>
) : null}
) } const ClientLowerList: React.FC = ({ logList: { log: logs = [] }, serviceList, updatePayload }) => { const tableHeight = (document.body.clientHeight - 124 - 78) / 2 const columns: ProColumns[] = [ { title: '日期', dataIndex: 'createTime', key: 'createTime', width: 160 }, { title: '操作人', dataIndex: 'operatorName', key: 'operatorName', ellipsis: true, width: 115 }, { title: '操作', dataIndex: 'operationType', key: 'operationType', ellipsis: true, width: 120 }, { title: '操作内容', dataIndex: 'content', key: 'content', ellipsis: true } ] const vList = useMemo(() => { return VList({ height: tableHeight, vid: 'client_log_list' }) }, []) return (
{serviceList.map(item => (
))}
search={false} toolBarRender={false} rowKey="id" size="small" columns={columns} dataSource={logs} pagination={false} scroll={{ y: tableHeight }} components={vList} />
) } export default ClientLowerList