From 09d7a93e892b7f43ba0d21f6ae1e427d1a95b16f Mon Sep 17 00:00:00 2001 From: ylj20011123 Date: Thu, 19 Jun 2025 19:29:53 +0800 Subject: [PATCH] update --- config/routes.ts | 17 + .../components/ShareBenefit.tsx | 64 +- src/pages/BussinessProject/detail.tsx | 7 +- .../MerchantInformation/index.tsx | 723 ++++++++++++++++++ src/pages/operatingMerchants/service.ts | 51 ++ .../reports/settlementSummaryTable/index.tsx | 17 +- .../travelMember/MemberAddress/index.tsx | 541 +++++++++++++ src/pages/travelMember/service.ts | 36 + src/services/options/index.ts | 3 + src/utils/requestEncryption.ts | 3 +- 10 files changed, 1440 insertions(+), 22 deletions(-) create mode 100644 src/pages/operatingMerchants/MerchantInformation/index.tsx create mode 100644 src/pages/operatingMerchants/service.ts create mode 100644 src/pages/travelMember/MemberAddress/index.tsx diff --git a/config/routes.ts b/config/routes.ts index b7447bf..d00ff2a 100644 --- a/config/routes.ts +++ b/config/routes.ts @@ -687,6 +687,11 @@ export default [ path: 'GrowthValueRecordSearch', name: 'GrowthValueRecordSearch', component: './travelMember/GrowthValueRecordSearch/index' + }, + { + path: 'MemberAddress', + name: 'MemberAddress', + component: './travelMember/MemberAddress/index' } ] }, @@ -727,6 +732,18 @@ export default [ } ] }, + { + path: '/operatingMerchants', + name: 'operatingMerchants', + icon: 'AccountBookOutlined', + routes: [ + { + path: 'MerchantInformation', + name: 'MerchantInformation', + component: './operatingMerchants/MerchantInformation/index' + }, + ] + }, { diff --git a/src/pages/BussinessProject/components/ShareBenefit.tsx b/src/pages/BussinessProject/components/ShareBenefit.tsx index 8d557fe..7ffca95 100644 --- a/src/pages/BussinessProject/components/ShareBenefit.tsx +++ b/src/pages/BussinessProject/components/ShareBenefit.tsx @@ -16,6 +16,7 @@ import RevenueList from './RevenueList'; import moment from 'moment'; import { fmoney } from "@/services/options"; import { getDetail } from "@/pages/contract/service"; +import Item from 'antd/lib/list/Item'; // 更新回款信息 const handleAddUpdate = async (dataType: 1000 | 2000, fields: number) => { @@ -104,7 +105,6 @@ const ShareBenefit: React.FC<{ props: BusinessProjectModel, showEdit?: boolean, return `${record.GUARANTEERATIO || '-'}%` }, }, - { title: '保底租金', dataIndex: 'MINTURNOVER', @@ -171,8 +171,8 @@ const ShareBenefit: React.FC<{ props: BusinessProjectModel, showEdit?: boolean, valueType: 'option', width: 80, hideInTable: showType === 'Nooperate' ? true : !(showEdit === undefined || showEdit), - render: (_, record,) => ( - new Date(record?.STARTDATE).getTime() < new Date().getTime() ? + render: (_, record) => ( + new Date(record?.STARTDATE).getTime() < new Date().getTime() && record.showAgainBtn ? { + const handleGetRelatedData = async (list: any) => { console.log('list', list); let result: any = [] @@ -231,21 +231,31 @@ const ShareBenefit: React.FC<{ props: BusinessProjectModel, showEdit?: boolean, // 可能存在多个关联项目 for (let i = 0; i <= list.length - 1; i++) { - handleGetSplitRes({ + const res = await handleGetSplitRes({ DataType: 2, - CompactId: list[0].REGISTERCOMPACT_ID - }).then(res => { - console.log('res', res); - result.push({ - title: list[0].COMPACT_NAME, - time: `${moment(list[0].COMPACT_STARTDATE).format('YYYY-MM-DD')}-${moment(list[0].COMPACT_ENDDATE).format('YYYY-MM-DD')}`, - data: res.data - }) - // for循环不一定会等接口调完 才赋值 所以放在循环里面 最后一次也会拿到最新的 - setRelateTableData(result) + CompactId: list[i].REGISTERCOMPACT_ID }) - } + result.push({ + title: list[i].COMPACT_NAME, + time: `${moment(list[i].COMPACT_STARTDATE).format('YYYY-MM-DD')}-${moment(list[i].COMPACT_ENDDATE).format('YYYY-MM-DD')}`, + STARTDATE: moment(list[i].COMPACT_STARTDATE).format('YYYY-MM-DD'), + ENDDATE: moment(list[i].COMPACT_ENDDATE).format('YYYY-MM-DD'), + data: res.data + }) + // .then(res => { + // console.log('312321312312', JSON.parse(JSON.stringify(res))); + // result.push({ + // title: list[i].COMPACT_NAME, + // time: `${moment(list[i].COMPACT_STARTDATE).format('YYYY-MM-DD')}-${moment(list[0].COMPACT_ENDDATE).format('YYYY-MM-DD')}`, + // data: res.data + // }) + // console.log('resultresultresultresult', result); + // // for循环不一定会等接口调完 才赋值 所以放在循环里面 最后一次也会拿到最新的 + // }) + } + setRelateTableData(result) + return result } return ( @@ -281,9 +291,29 @@ const ShareBenefit: React.FC<{ props: BusinessProjectModel, showEdit?: boolean, } } const data = await handleGetSplitRes(req) + console.log('fjajasdaslkd', data); + + let res: any = [] if (relatedContractsList && relatedContractsList.length > 0) { - handleGetRelatedData(relatedContractsList) + res = await handleGetRelatedData(relatedContractsList) } + + console.log('resresresresres', res); + if (res && res.length > 0) { + res.forEach((item: any) => { + if (data.data && data.data.length > 0) { + data.data.forEach((subItem: any) => { + if (new Date(item.STARTDATE).getTime() < new Date(subItem.ENDDATE).getTime() && new Date(item.ENDDATE).getTime() >= new Date(subItem.ENDDATE).getTime()) { + // 如果该行数据(上面的) 已经包括了下面的数据的时间 那么这段就不出现重新生成 + } else { + subItem.showAgainBtn = true + } + }) + } + }) + } + + setTableLoading(false) return data }} diff --git a/src/pages/BussinessProject/detail.tsx b/src/pages/BussinessProject/detail.tsx index ba77aaf..61c1382 100644 --- a/src/pages/BussinessProject/detail.tsx +++ b/src/pages/BussinessProject/detail.tsx @@ -368,13 +368,16 @@ const Detail = ({ id, showTabs, tabActive, smallTabActive, isPayment, price, dat PageSize: 999999 } } + console.log('req', req); + const data = await handleGetRelatedList(req) console.log('handleGetRelatedContracts', data); if (data && data.data && data.data.length > 0) { const list: any = [] data.data.forEach((item: any) => { - if (type !== 1000 || (type === 1000 && item.COMPACT_DETAILS !== 1000)) { + // if (type !== 1000 || (type === 1000 && item.COMPACT_DETAILS !== 1000)) { + if (item.COMPACT_DETAILS === 2000) { list.push(item) } }) @@ -682,7 +685,7 @@ const Detail = ({ id, showTabs, tabActive, smallTabActive, isPayment, price, dat // { key: 4, tab: '商家往来款' }, { key: 9, tab: '在售商品信息' }, const list = [{ key: 2, tab: '欠款组成' }, { key: 3, tab: '履约拆分' }, { key: 5, tab: '合作分润' }, { key: 7, tab: '营收分润' }, { key: 8, tab: '单品销售' }, { key: 10, tab: '门店营收' }, { key: 11, tab: '现场稽核' }, - { key: 1, tab: '合同详情' },{ key: 4, tab: '商家往来款' }] // 可显示的所有tab标签 + { key: 1, tab: '合同详情' }, { key: 4, tab: '商家往来款' }] // 可显示的所有tab标签 // 筛选需要显示的tab list const tabs = showTabs || [1, 3, 4, 5, 7, 8, 9, 10, 11] // if (!showTabs && projectDetail?.BUSINESS_TYPE === 1000) { diff --git a/src/pages/operatingMerchants/MerchantInformation/index.tsx b/src/pages/operatingMerchants/MerchantInformation/index.tsx new file mode 100644 index 0000000..e0c94a4 --- /dev/null +++ b/src/pages/operatingMerchants/MerchantInformation/index.tsx @@ -0,0 +1,723 @@ +// 商家信息管理 +import React, { useRef, useState, Suspense } from 'react'; +import moment from 'moment'; // 时间相关引用,没有使用可以删除 +import numeral from "numeral"; // 数字相关引用,没有使用可以删除 +import { connect } from 'umi'; + +import useRequest from '@ahooksjs/use-request'; // 请求数据的引用 +import Draggable from 'react-draggable'; +import SubMenu from "antd/lib/menu/SubMenu"; +import ProTable from '@ant-design/pro-table'; +import ProDescriptions from '@ant-design/pro-descriptions'; +import ProForm, { ProFormDatePicker, ProFormDateTimePicker, ProFormMoney, ProFormSelect, ProFormText, ProFormTextArea, ProFormUploadButton } from '@ant-design/pro-form'; +import { MenuFoldOutlined, PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons'; +import { PageContainer } from '@ant-design/pro-layout'; +import { Button, Col, Drawer, message, Row, Popconfirm, Space, Image, Modal, Form, Switch, Upload, Tooltip, Descriptions, TreeSelect } from 'antd'; + +import type { CurrentUser } from "umi"; +import type { ConnectState } from '@/models/connect'; +import type { ActionType, ProColumns } from '@ant-design/pro-table'; +import type { ProDescriptionsItemProps } from '@ant-design/pro-descriptions'; +import type { FormInstance } from 'antd'; +import { handleGetMEMBERADDRESSList, handleGetSERVERPARTSHOPList } from '../service'; +import LeftSelectTree from '@/pages/reports/settlementAccount/component/leftSelectTree'; +import session from '@/utils/session'; + + + +const MerchantInformation: React.FC<{ currentUser: CurrentUser | undefined }> = (props) => { + const { currentUser } = props + const actionRef = useRef(); + const formRef = useRef(); + const associationActionRef = useRef(); + const [currentRow, setCurrentRow] = useState(); + const [showDetail, setShowDetail] = useState(); + const [modalVisible, handleModalVisible] = useState(); + const [confirmLoading, handleConfirmLoading] = useState(false) // 弹出框的内容表单是否在提交 + const [searchParams, setSearchParams] = useState(); + // 树相关的属性和方法 + const [selectedId, setSelectedId] = useState() + const [collapsible, setCollapsible] = useState(false) + // 新增关联选择的方法 + const [selectedRowKeys, setSelectRowKeys] = useState(); + const [selectedRowDetail, setSelectRowDetail] = useState(); + + let SHOPTRADEObj = session.get('SHOPTRADEObj') + let shopregionObj = session.get('shopregionObj') + let businessStateObj = session.get('businessStateObj') + + // 弹出框拖动效果 + const [bounds, setBounds] = useState<{ left: number, right: number, top: number, bottom: number }>() // 移动的位置 + const [disabled, setDraggleDisabled] = useState() // 是否拖动 + const draggleRef = React.createRef() + // 显示新增门店功能悬浮框 + const [showAddModal, setShowAddModal] = useState(false) + + const onDraggaleStart = (event, uiData) => { + const { clientWidth, clientHeight } = window.document.documentElement; + const targetRect = draggleRef.current?.getBoundingClientRect(); + if (!targetRect) { + return; + } + setBounds({ + left: -targetRect.left + uiData.x, + right: clientWidth - (targetRect.right - uiData.x), + top: -targetRect.top + uiData.y, + bottom: clientHeight - (targetRect.bottom - uiData.y), + }); + }; + // 拖动结束 + + // 定义列表字段内容 + const columns: any = [ + { + dataIndex: 'SELLER_NAME', + title: '商家名称', + align: 'center', + hideInSearch: true, + render: (_, record) => { + return record?.SELLER_NAME ? `${record?.SERVERPART_NAME || ""}${record?.SELLER_NAME}` : "-" + } + }, + { + dataIndex: 'SHOPTRADE', + title: '经营业态', + align: 'center', + width: 150, + valueType: 'select', + valueEnum: SHOPTRADEObj, + fieldProps: { + showSearch: true, + filterOption: (input, option) => + (option?.label ?? '').toLowerCase().includes(input.toLowerCase()), + }, + }, + { + dataIndex: '', + title: '预约点餐', + align: 'center', + width: 150, + hideInSearch: true, + }, + { + dataIndex: 'MONTHLYSALES', + title: '月销售量', + align: 'center', + width: 150, + hideInSearch: true, + }, + { + dataIndex: 'PERCAPITA', + title: '人均消费', + align: 'center', + width: 150, + hideInSearch: true, + }, + { + dataIndex: 'SELLER_SCORE', + title: '评价分数', + align: 'center', + width: 150, + hideInSearch: true, + }, + { + dataIndex: 'COMMENT_COUNT', + title: '评价数量', + align: 'center', + width: 150, + hideInSearch: true, + }, + { + dataIndex: 'SERVERPARTSELLER_DESC', + title: '备注说明', + width: 150, + ellipsis: true, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'option', + title: '操作', + valueType: 'option', + width: 150, + align: 'center', + hideInSearch: true, + render: (_, record) => { + return ( + + { + setCurrentRow({ ...record }); + handleModalVisible(true); + }} + > + 编辑 + + { + await handelDelete(record.SERVERPARTSELLER_ID); + }} + > + 删除 + + + ); + }, + }, + ]; + + // 关联商家的表格 + const merchantColumns: any = [ + { + dataIndex: 'SERVERPART_NAME', + title: '服务区名称', + align: 'center', + width: 150, + ellipsis: true, + hideInSearch: true, + }, + { + dataIndex: 'SHOPNAME', + title: '门店名称', + align: 'center', + width: 150, + ellipsis: true, + hideInSearch: true, + }, + { + dataIndex: 'SHOPREGION', + title: '所属方位', + align: 'center', + width: 120, + hideInSearch: true, + valueType: "select", + valueEnum: shopregionObj + }, + { + dataIndex: 'SCANCODE_ORDER', + title: '扫码点餐', + align: 'center', + width: 120, + hideInSearch: true, + valueType: "select", + valueEnum: { + "0": "禁用", + "1": "启用" + } + }, + { + dataIndex: 'BUSINESS_STATE', + title: '经营状态', + align: 'center', + width: 120, + hideInSearch: true, + valueType: "select", + valueEnum: businessStateObj + }, + { + dataIndex: 'SHOPDIRECTION', + title: '门店方向', + align: 'center', + width: 120, + ellipsis: true, + hideInSearch: true, + }, + { + dataIndex: 'ISVALID', + title: '门店状态', + align: 'center', + width: 120, + valueEnum: { + "0": "无效", + "1": "有效" + }, + initialValue: "1" + }, + { + dataIndex: 'SERVERPARTSHOP_DESC', + title: '介绍说明', + align: 'center', + width: 150, + ellipsis: true, + hideInSearch: true, + }, + { + dataIndex: 'option', + title: '操作', + valueType: 'option', + width: 150, + align: 'center', + hideInSearch: true, + render: (_, record) => { + return ( + + { + setCurrentRow({ ...record }); + handleModalVisible(true); + }} + > + 编辑 + + + ); + }, + }, + ] + + const handelDelete = async (serverpartsellerid: number) => { + + }; + + const handleAddUpdate = async (res: any) => { + + }; + + + return ( +
+
+ +
+ { + return `${record?.SERVERPARTSELLER_ID}` + }} + bordered + formRef={formRef} + headerTitle="服务区商家信息列表" // 列表表头 + actionRef={actionRef} + search={{ span: 6, labelWidth: 'auto' }} + // 请求数据 + request={async (params, sorter) => { + if (!selectedId) { + return + } + const req = { + searchParameter: { + SERVERPART_IDS: selectedId, + SHOPTRADES: params?.SHOPTRADES, + ISVALID: 1 + }, + PageIndex: params.current, + PageSize: params.pageSize, + } + const data = await handleGetMEMBERADDRESSList(req); + console.log('datadatadatadatadata', data); + if (data.List && data.List.length > 0) { + return { data: data.List, success: true, total: data.TotalCount } + } + return { data: [], success: true } + }} + columns={columns} + toolbar={{ + actions: selectedId ? [ + // 新增按钮 + , + ] : "", + }} + pagination={{ defaultPageSize: 10 }} + /> +
+
+ + + {/* 添加服务区商家信息表 */} + { + }} + onCancel={() => { + setShowAddModal(false) + setSelectRowKeys(null) + setSelectRowDetail(null) + }} + okText={"关联"} + onOk={async () => { // 提交框内的数据 + console.log('selectedRowKeysselectedRowKeys', selectedRowKeys); + console.log('selectedRowDetailselectedRowDetail', selectedRowDetail); + + }} + > + { + const req: any = { + searchParameter: { + SERVERPART_IDS: selectedId, + ISVALID: params?.ISVALID + }, + PageIndex: 1, + PageSize: 999999, + SortStr: "SHOPTRADE,SHOPREGION,SHOPSHORTNAME,SHOPCODE" + } + const data = await handleGetSERVERPARTSHOPList(req) + if (data.List && data.List.length > 0) { + let list: any = [] + data.List.forEach((item: any) => { + if (!item.SELLER_ID) { + list.push(item) + } + }) + console.log('datadatadatadatadata2', list); + return { data: list, success: true } + } + return { data: [], success: true } + }} + pagination={false} + rowSelection={{ + type: 'checkbox', + onChange: (rowKeys, rowDetail) => { + setSelectRowKeys(rowKeys) + setSelectRowDetail(rowDetail) + }, + }} + /> + + + {/* 同步商户门店信息的悬浮框 */} + + + + + { + if (disabled) { + setDraggleDisabled(false) + } + }} + onMouseOut={() => { + setDraggleDisabled(true) + }} + + onFocus={() => { }} + onBlur={() => { }} + > + {currentRow ? '更新服务区商家信息' : '新建服务区商家信息'} +
+ } + destroyOnClose={true} + width={900} + visible={modalVisible} + confirmLoading={confirmLoading} + afterClose={() => { + formRef.current?.resetFields(); + setCurrentRow(undefined); + }} + onCancel={() => { + handleConfirmLoading(false) + handleModalVisible(false) + }} + + onOk={async () => { // 提交框内的数据 + formRef?.current?.validateFields().then(() => { + handleConfirmLoading(true) + formRef?.current?.submit() + }) + }} + modalRender={(modal) => { + return onDraggaleStart(event, uiData)} + > +
{modal}
+
+ }} + > + { + let newValue: any = { ...values }; + if (currentRow) { + // 编辑数据 + newValue = { ...values, SERVERPARTSELLER_ID: currentRow.SERVERPARTSELLER_ID }; + } + // 如果有开关,要把开关的代码写进去 + const success = await handleAddUpdate(newValue as SERVERPARTSELLERModel); + + handleConfirmLoading(false) + if (success) { + if (actionRef.current) { + actionRef.current.reload(); + } + handleModalVisible(false); + } + }} + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); +}; +export default connect(({ user }: ConnectState) => ({ + currentUser: user.currentUser +}))(MerchantInformation); diff --git a/src/pages/operatingMerchants/service.ts b/src/pages/operatingMerchants/service.ts new file mode 100644 index 0000000..5b5cb2a --- /dev/null +++ b/src/pages/operatingMerchants/service.ts @@ -0,0 +1,51 @@ +import requestEncryption from '@/utils/requestEncryption'; + +// 拿到服务区商家信息表 +export async function handleGetMEMBERADDRESSList(params: any) { + const data = await requestEncryption(`/BaseInfo/GetSERVERPARTSELLERList`, { + method: 'POST', + data: { ...params, requestEncryption: true } + }) + if (data.Result_Code !== 100) { + return [] + } + return data.Result_Data +} + +// 同步服务区商家信息 +export async function handleSynchroSERVERPARTSELLER(params: any) { + const data = await requestEncryption(`/BaseInfo/SynchroSERVERPARTSELLER`, { + method: 'POST', + data: { ...params, requestEncryption: true } + }) + if (data.Result_Code !== 100) { + return [] + } + return data +} + +// 删除服务区商家 +export async function handleDeleteSERVERPARTSELLER(params: any) { + const data = await requestEncryption(`/BaseInfo/DeleteSERVERPARTSELLER`, { + method: 'POST', + data: { ...params, requestEncryption: true } + }) + if (data.Result_Code !== 100) { + return [] + } + return data +} + +// 获取门店信息列表 +export async function handleGetSERVERPARTSHOPList(params: any) { + const data = await requestEncryption(`/BaseInfo/GetSERVERPARTSHOPList`, { + method: 'POST', + data: { ...params, requestEncryption: true } + }) + if (data.Result_Code !== 100) { + return [] + } + return data.Result_Data +} + + diff --git a/src/pages/reports/settlementSummaryTable/index.tsx b/src/pages/reports/settlementSummaryTable/index.tsx index 7645a27..6ec8f8f 100644 --- a/src/pages/reports/settlementSummaryTable/index.tsx +++ b/src/pages/reports/settlementSummaryTable/index.tsx @@ -19,6 +19,7 @@ import { wrapTreeNode } from "@/utils/format"; import YearExamineDetailTable from "../settlementAccount/component/YearExamineDetailTable"; import './index.less' import * as XLSX from 'xlsx'; +import session from "@/utils/session"; const settlementSummaryTable: React.FC<{ currentUser: CurrentUser }> = (props) => { const { currentUser } = props @@ -30,7 +31,7 @@ const settlementSummaryTable: React.FC<{ currentUser: CurrentUser }> = (props) = const [collapsible, setCollapsible] = useState(false) const [treeView, setTreeView] = useState() const [printIndex, setPrintIndex] = useState(new Date().getTime()) - + let SETTLEMENT_MODESObj = session.get('SETTLEMENT_MODESObj') // 树相关的属性和方法 const [selectedId, setSelectedId] = useState() @@ -85,6 +86,17 @@ const settlementSummaryTable: React.FC<{ currentUser: CurrentUser }> = (props) = "-1": "提前退场", } }, + { + title: "结算模式", + dataIndex: 'SettlementModes', + valueType: 'select', + hideInTable: true, + valueEnum: SETTLEMENT_MODESObj, + fieldProps: { + mode: 'multiple', // 开启多选模式 + }, + initialValue: ["3000", "4000"] + }, { title:
管理中心
, titleStr: '管理中心', @@ -665,7 +677,8 @@ const settlementSummaryTable: React.FC<{ currentUser: CurrentUser }> = (props) = const req: any = { StatisticsYear: params?.StatisticsYear, ServerpartId: selectedId, - SettlementState: params?.SettlementState + SettlementState: params?.SettlementState, + SettlementModes: params?.SettlementModes // ServerpartIds: selectedId, // // ShopRoyaltyId: compareCurrent?.ShopRoyaltyId, // // BusinessProjectId: compareCurrent?.BUSINESSPROJECT_ID, diff --git a/src/pages/travelMember/MemberAddress/index.tsx b/src/pages/travelMember/MemberAddress/index.tsx new file mode 100644 index 0000000..4a772ff --- /dev/null +++ b/src/pages/travelMember/MemberAddress/index.tsx @@ -0,0 +1,541 @@ +// 地址管理 +import React, { useRef, useState, Suspense, useEffect } from 'react'; +import moment from 'moment'; // 时间相关引用,没有使用可以删除 +import numeral from "numeral"; // 数字相关引用,没有使用可以删除 +import { connect } from 'umi'; + +import useRequest from '@ahooksjs/use-request'; // 请求数据的引用 +import Draggable from 'react-draggable'; +import SubMenu from "antd/lib/menu/SubMenu"; +import ProTable from '@ant-design/pro-table'; +import ProDescriptions from '@ant-design/pro-descriptions'; +import ProForm, { ProFormDatePicker, ProFormDateTimePicker, ProFormMoney, ProFormSelect, ProFormText, ProFormTextArea, ProFormUploadButton } from '@ant-design/pro-form'; +import { MenuFoldOutlined, PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons'; +import { PageContainer } from '@ant-design/pro-layout'; +import { Button, Col, Drawer, message, Row, Popconfirm, Space, Image, Modal, Form, Switch, Upload, Tooltip, Descriptions, TreeSelect } from 'antd'; + +import type { CurrentUser } from "umi"; +import type { ConnectState } from '@/models/connect'; +import type { ActionType, ProColumns } from '@ant-design/pro-table'; +import type { ProDescriptionsItemProps } from '@ant-design/pro-descriptions'; +import type { FormInstance } from 'antd'; +import { handleDeleteMEMBERADDRESS, handleGetMEMBERADDRESSList, handleSynchroMEMBERADDRESS } from '../service'; + + + +const MemberAddress: React.FC<{ currentUser: CurrentUser | undefined }> = (props) => { + const { currentUser } = props + const actionRef = useRef(); + const formRef = useRef(); + const [currentRow, setCurrentRow] = useState(); + const [showDetail, setShowDetail] = useState(); + const [modalVisible, handleModalVisible] = useState(); + const [confirmLoading, handleConfirmLoading] = useState(false) // 弹出框的内容表单是否在提交 + const [searchParams, setSearchParams] = useState(); + + // 弹出框拖动效果 + const [bounds, setBounds] = useState<{ left: number, right: number, top: number, bottom: number }>() // 移动的位置 + const [disabled, setDraggleDisabled] = useState() // 是否拖动 + const draggleRef = React.createRef() + + const [province, setProvince] = useState(''); + const [city, setCity] = useState(''); + const [county, setCounty] = useState(''); + const [address, setAddress] = useState(''); + + const onDraggaleStart = (event, uiData) => { + const { clientWidth, clientHeight } = window.document.documentElement; + const targetRect = draggleRef.current?.getBoundingClientRect(); + if (!targetRect) { + return; + } + setBounds({ + left: -targetRect.left + uiData.x, + right: clientWidth - (targetRect.right - uiData.x), + top: -targetRect.top + uiData.y, + bottom: clientHeight - (targetRect.bottom - uiData.y), + }); + }; + // 拖动结束 + + + useEffect(() => { + formRef.current?.setFieldsValue({ ADDRESS: `${province || ''}${city || ''}${county || ''}` }) + + // 监听省、市、区/县的变化,拼接收货地址 + // setAddress(`${province || ''}${city || ''}${county || ''}`); + + }, [province, city, county]); + + // 定义列表字段内容 + const columns: any = [ + { + dataIndex: 'searchText', + title: '', + width: 150, + align: 'center', + hideInTable: true, + fieldProps:{ + placeholder: "输入收货人名称" + } + }, + { + dataIndex: 'USER_NAME', + title: '收货人名称', + width: 150, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'USER_SEX', + title: '收货人性别', + width: 120, + align: 'center', + hideInSearch: true, + valueType: 'select', + valueEnum: { + "1": "男", + "2": "女", + "0": "-", + } + }, + { + dataIndex: 'MOBILEPHONE', + title: '手机号码', + width: 150, + align: 'center', + hideInSearch: true, + }, + // { + // dataIndex: 'RECEIVE_PROVINCE', + // title: '省/直辖市', + // width: 120, + // align: 'center', + // hideInSearch: true, + // }, + // { + // dataIndex: 'RECEIVE_CITY', + // title: '城市/直辖市', + // width: 120, + // align: 'center', + // hideInSearch: true, + // }, + // { + // dataIndex: 'RECEIVE_COUNTY', + // title: '区/县', + // width: 150, + // align: 'center', + // hideInSearch: true, + // }, + { + dataIndex: 'ADDRESS', + title: '收货地址', + width: 300, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'DOORPLATE', + title: '门牌号码', + width: 300, + align: 'center', + hideInSearch: true, + }, + { + dataIndex: 'ISDEFAULT', + title: '默认地址', + width: 120, + align: 'center', + hideInSearch: true, + valueType: 'select', + valueEnum: { + "1": "是", + "0": "否", + } + }, + { + dataIndex: 'TAGTYPE', + title: '地址类型', + width: 120, + align: 'center', + hideInSearch: true, + valueType: 'select', + valueEnum: { + "1000": "家", + "2000": "公司", + "3000": "其他", + } + }, + + // { + // dataIndex: 'CREATE_STAFF_NAME', + // title: '创建人名称', + // align: 'center', + // hideInSearch: true, + // }, + // { + // dataIndex: 'CREATE_DATE', + // title: '创建时间', + // valueType: 'date', + // align: 'center', + // hideInSearch: true, + // }, + // { + // dataIndex: 'UPDATE_STAFF_NAME', + // title: '更新人名称', + // align: 'center', + // hideInSearch: true, + // }, + // { + // dataIndex: 'UPDATE_DATE', + // title: '更新时间', + // valueType: 'date', + // align: 'center', + // hideInSearch: true, + // }, + // { + // dataIndex: 'MEMBERADDRESS_DESC', + // title: '备注说明', + // align: 'center', + // hideInSearch: true, + // }, + { + dataIndex: 'option', + title: '操作', + width: 120, + align: 'center', + valueType: 'option', + hideInSearch: true, + render: (_, record) => { + return ( + + { + console.log('record', record); + + setProvince(record?.RECEIVE_PROVINCE) + setCity(record?.RECEIVE_CITY) + setCounty(record?.RECEIVE_COUNTY) + setCurrentRow({ ...record }); + handleModalVisible(true); + }} + > + 编辑 + + { + await handelDelete(record.MEMBERADDRESS_ID); + }} + > + 删除 + + + ); + }, + }, + ]; + + + const handelDelete = async (id: number) => { + const result = await handleDeleteMEMBERADDRESS({ + MEMBERADDRESSId: id + }); + console.log('resultresultresult', result); + if (result.Result_Code !== 100) { + message.error(`${result.Result_Desc}` || `${result.Result_Code}:删除失败`); + } else { + message.success('删除成功!'); + actionRef.current?.reload() + } + }; + + const handleAddUpdate = async (res: any) => { + let req: any = {} + + if (currentRow?.MEMBERADDRESS_ID) { + req = { + ...currentRow, + ...res + } + } else { + req = { + ...res, + ADDTIME: moment().format('YYYY-MM-DD HH:mm:ss'), + STAFF_ID: currentUser?.ID, + STAFF_NAME: currentUser?.Name, + OWNERUNIT_ID: currentUser?.OwnerUnitId, + OWNERUNIT_NAME: currentUser?.OwnerUnitName, + PROVINCE_CODE: currentUser?.ProvinceCode + } + } + const data = await handleSynchroMEMBERADDRESS(req); + if (data.Result_Code === 100) { + message.success(data.Result_Desc) + formRef?.current?.resetFields() + setCurrentRow(undefined) + handleModalVisible(false) + actionRef.current?.reload() + } else { + message.error(data.Result_Desc) + } + }; + + return ( + + { + return `${record?.MEMBERADDRESS_ID}` + }} + formRef={formRef} + headerTitle="会员收货地址列表" // 列表表头 + actionRef={actionRef} + search={{ span: 6, labelWidth: 'auto' }} + bordered + // 请求数据 + request={async (params, sorter) => { + console.log('params', params); + + const req = { + SearchParameter: { + PROVINCE_CODE: currentUser?.ProvinceCode || "", + OWNERUNIT_ID: 911, + ISVALID: 1 + }, + PageIndex: params.current, + PageSize: params.pageSize, + SortStr: "CREATE_DATE desc", + keyWord: { + Key: "USER_NAME", + Value: params?.searchText + } + } + const data = await handleGetMEMBERADDRESSList(req); + console.log('datadatadatadatadata', data); + if (data.List && data.List.length > 0) { + return { data: data.List, success: true, total: data.TotalCount } + } + return { data: [], success: true } + }} + columns={columns} + toolbar={{ + actions: [] + }} + /> + { + setCurrentRow(undefined); + setShowDetail(false); + }} + closable={false} + > + {currentRow?.MEMBERADDRESS_ID && ( + ({ + data: currentRow || {}, + })} + params={{ + id: currentRow?.MEMBERADDRESS_ID, + }} + columns={columns} + /> + )} + + { + if (disabled) { + setDraggleDisabled(false) + } + }} + onMouseOut={() => { + setDraggleDisabled(true) + }} + + onFocus={() => { }} + onBlur={() => { }} + > + {currentRow ? '更新会员收货地址' : '新建会员收货地址'} + + } + destroyOnClose={true} + width={900} + visible={modalVisible} + confirmLoading={confirmLoading} + afterClose={() => { + formRef.current?.resetFields(); + setCurrentRow(undefined); + }} + onCancel={() => { + handleConfirmLoading(false) + handleModalVisible(false) + setProvince("") + setCity("") + setCounty("") + }} + + onOk={async () => { // 提交框内的数据 + formRef?.current?.validateFields().then(() => { + handleConfirmLoading(true) + formRef?.current?.submit() + }) + }} + modalRender={(modal) => { + return onDraggaleStart(event, uiData)} + > +
{modal}
+
+ }} + > + { + let newValue: any = { ...values }; + if (currentRow) { + // 编辑数据 + newValue = { ...values, MEMBERADDRESS_ID: currentRow.MEMBERADDRESS_ID }; + } + await handleAddUpdate(newValue); + + handleConfirmLoading(false) + }} + > + + + + + + + + + + + + { + console.log('eee', e); + + setProvince(e.target.value) + } + }} + /> + + + { + setCity(e.target.value) + } + }} + /> + + + { + setCounty(e.target.value) + } + }} + /> + + + + + + + + + + + + + + + + + + + + + +
+
+ ); +}; +export default connect(({ user }: ConnectState) => ({ + currentUser: user.currentUser +}))(MemberAddress); diff --git a/src/pages/travelMember/service.ts b/src/pages/travelMember/service.ts index 3dbcfe9..4751d94 100644 --- a/src/pages/travelMember/service.ts +++ b/src/pages/travelMember/service.ts @@ -127,4 +127,40 @@ export async function handleDeleteGROWTHSETTING(params: any) { return [] } return data +} + +// 拿到收货地址列表数据 +export async function handleGetMEMBERADDRESSList(params: any) { + const data = await requestEncryption(`/MemberOrder/GetMEMBERADDRESSList`, { + method: 'POST', + data: { ...params, requestEncryption: true } + }) + if (data.Result_Code !== 100) { + return [] + } + return data.Result_Data +} + +// 同步收获地址 +export async function handleSynchroMEMBERADDRESS(params: any) { + const data = await requestEncryption(`/MemberOrder/SynchroMEMBERADDRESS`, { + method: 'POST', + data: { ...params, requestEncryption: true } + }) + if (data.Result_Code !== 100) { + return [] + } + return data +} + +// 删除收获地址 +export async function handleDeleteMEMBERADDRESS(params: any) { + const data = await requestEncryption(`/MemberOrder/DeleteMEMBERADDRESS`, { + method: 'POST', + data: { ...params, requestEncryption: true } + }) + if (data.Result_Code !== 100) { + return [] + } + return data } \ No newline at end of file diff --git a/src/services/options/index.ts b/src/services/options/index.ts index f6c8dd3..ce16b9d 100644 --- a/src/services/options/index.ts +++ b/src/services/options/index.ts @@ -158,6 +158,9 @@ export async function getServerpartTree(ProvinceCode?: number | string, Serverpa ShowRoyalty=${false}&ShowCompactCount=${ShowCompactCount || false}&StatisticsType=${StatisticsType || ''}`, { method: 'GET', }); + + console.log('djsiadjsakdjsalkjfoidhifsa', data); + if (data.Result_Code !== 100) { return []; } diff --git a/src/utils/requestEncryption.ts b/src/utils/requestEncryption.ts index 7e51086..9f13453 100644 --- a/src/utils/requestEncryption.ts +++ b/src/utils/requestEncryption.ts @@ -126,7 +126,8 @@ requestEncryption.interceptors.request.use((url, opt: any) => { } } - if (options.data.requestEncryption) { + + if (options && options.data && options.data.requestEncryption) { options.data = { name: "", value: encryptAES(JSON.stringify(options.data))