import { connect } from "umi"; import type { ConnectState } from "@/models/connect"; import ProTable, { ActionType } from "@ant-design/pro-table"; import { Col, FormInstance, message, Modal, Popconfirm, Row, Space } from "antd"; import { useRef, useState } from "react"; import { handleDeleteMEMBERADDRESS, handleGetMEMBERADDRESSList, handleSynchroMEMBERADDRESS } from "../../service"; import React from "react"; import Draggable from "react-draggable"; import ProForm, { ProFormSelect, ProFormText, ProFormTextArea } from "@ant-design/pro-form"; import moment from 'moment' import ModalFooter from "../../scenicSpotConfig/component/modalFooter"; import { handleSetlogSave } from "@/utils/format"; type DetailProps = { currentBigRow: any currentUser: any } const AddressDetail = ({ currentBigRow, currentUser }: DetailProps) => { const modalActionRef = useRef(); const formRef = useRef(); const [province, setProvince] = useState(''); const [city, setCity] = useState(''); const [county, setCounty] = useState(''); const [currentRow, setCurrentRow] = useState(); const [modalVisible, handleModalVisible] = useState(); const [confirmLoading, handleConfirmLoading] = useState(false) // 弹出框的内容表单是否在提交 const [bounds, setBounds] = useState<{ left: number, right: number, top: number, bottom: number }>() // 移动的位置 const [disabled, setDraggleDisabled] = useState() // 是否拖动 const draggleRef = React.createRef() // 抽屉里面的table的columns const drawerColumns: any = [ { dataIndex: 'searchText', title: '', width: 150, align: 'center', hideInTable: true, fieldProps: { placeholder: "输入收货人名称" } }, { dataIndex: 'USER_NAME', title: '收货人名称', width: 150, align: 'center', ellipsis: true, hideInSearch: true, render: (_, record) => { return record?.USER_NAME ? { console.log('record', record); handleSetlogSave(`查看【${record?.ADDRESS || ""}】地址信息`) setProvince(record?.RECEIVE_PROVINCE) setCity(record?.RECEIVE_CITY) setCounty(record?.RECEIVE_COUNTY) setCurrentRow({ ...record }); handleModalVisible(true); }} > {record?.USER_NAME || "-"} : "-" } }, { dataIndex: 'USER_SEX', title: '收货人性别', width: 120, align: 'center', hideInSearch: true, valueType: 'select', valueEnum: { "1": "男", "2": "女", "0": "-", } }, { dataIndex: 'MOBILEPHONE', title: '手机号码', width: 150, align: 'center', ellipsis: true, hideInSearch: true, }, { dataIndex: 'RECEIVE_PROVINCE', title: '省/直辖市', width: 120, align: 'center', ellipsis: true, hideInSearch: true, }, { dataIndex: 'RECEIVE_CITY', title: '城市/直辖市', width: 150, 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, ellipsis: true, valueType: 'select', valueEnum: { "1": "是", "0": "否", } }, { dataIndex: 'TAGTYPE', title: '地址类型', width: 120, align: 'center', hideInSearch: true, ellipsis: 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, // fixed: 'right', // render: (_, record) => { // return ( // // { // console.log('record', record); // setProvince(record?.RECEIVE_PROVINCE) // setCity(record?.RECEIVE_CITY) // setCounty(record?.RECEIVE_COUNTY) // setCurrentRow({ ...record }); // handleModalVisible(true); // }} // > // 编辑 // // { // console.log('res', record); // 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}:删除失败`); handleSetlogSave(`删除【${currentRow?.ADDRESS || ""}】失败`) } else { message.success('删除成功!'); modalActionRef.current?.reload() handleSetlogSave(`删除【${currentRow?.ADDRESS || ""}】成功`) handleConfirmLoading(false) handleModalVisible(false) setProvince("") setCity("") setCounty("") } }; 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 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) { handleSetlogSave(`更新【${currentRow?.ADDRESS || ""}】成功`) message.success(data.Result_Desc) formRef?.current?.resetFields() setCurrentRow(undefined) handleModalVisible(false) modalActionRef.current?.reload() } else { handleSetlogSave(`更新【${currentRow?.ADDRESS || ""}】失败`) message.error(data.Result_Desc) } }; return (
{ const req = { SearchParameter: { MEMBERSHIP_ID: currentBigRow?.MEMBERSHIP_ID, 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 } }} /> { if (disabled) { setDraggleDisabled(false) } }} onMouseOut={() => { setDraggleDisabled(true) }} onFocus={() => { }} onBlur={() => { }} > {currentRow ? '更新会员收货地址' : '新建会员收货地址'}
} destroyOnClose={true} width={900} bodyStyle={{ height: '700px', // 你可以根据需要调整高度 overflowY: 'auto', }} visible={modalVisible} confirmLoading={confirmLoading} afterClose={() => { formRef.current?.resetFields(); setCurrentRow(undefined); }} onCancel={() => { handleConfirmLoading(false) handleModalVisible(false) setProvince("") setCity("") setCounty("") }} footer={ { await handelDelete(currentRow?.MEMBERADDRESS_ID) }} handleCancel={() => { handleConfirmLoading(false) handleModalVisible(false) setProvince("") setCity("") setCounty("") }} handleOK={() => { formRef?.current?.validateFields().then(() => { handleConfirmLoading(true) formRef?.current?.submit() }) }} />} onOk={async () => { // 提交框内的数据 formRef?.current?.validateFields().then(() => { handleConfirmLoading(true) formRef?.current?.submit() }) }} modalRender={(modal) => { return onDraggaleStart(event, uiData)} handle=".modal-drag-title" >
{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, }))(AddressDetail);