Commit 70cfdaca authored by 前端-黄佳鑫's avatar 前端-黄佳鑫

🦄 refactor: 物流能力新增收发货地址重构

parent 152cdc0f
import logisticsAdminister from './logisticsAdminister';
import logisticsBillQuery from './logisticsBillQuery';
import logisticsBillManage from './logisticsBillManage';
......@@ -6,6 +7,8 @@ const logisticsAbilityRoute = {
name: '物流能力',
icon: 'logistics',
routes: [
/** 物流管理 */
...logisticsAdminister,
/** 物流单提交 */
...logisticsBillQuery,
/** 物流单处理 */
......
/**
* @description: 物流能力 物流管理
* @param {type}
* @return {type}
*/
export default [
{
path: '/memberCenter/logisticsAbility/logisticsAdminister',
name: '物流管理',
routes: [
{
/** 物流公司管理 */
path: '/memberCenter/logisticsAbility/logisticsAdminister/logisticsCompanyManage',
name: '物流单查询',
component: '@/pages/transaction/logisticsAbility/logisticsAdminister/logisticsCompanyManage',
},
{
/** 新增物流公司管理 */
path: '/memberCenter/logisticsAbility/logisticsAdminister/logisticsCompanyManage/add',
name: '新增物流公司',
component: '@/pages/transaction/logisticsAbility/logisticsAdminister/logisticsCompanyManage/add',
hideInMenu: true,
},
{
/** 编辑物流公司管理 */
path: '/memberCenter/logisticsAbility/logisticsAdminister/logisticsCompanyManage/edit',
name: '编辑物流公司',
component: '@/pages/transaction/logisticsAbility/logisticsAdminister/logisticsCompanyManage/add',
hideInMenu: true,
},
{
/** 查看物流公司管理 */
path: '/memberCenter/logisticsAbility/logisticsAdminister/logisticsCompanyManage/preview',
name: '查看物流公司',
component: '@/pages/transaction/logisticsAbility/logisticsAdminister/logisticsCompanyManage/add',
hideInMenu: true,
},
{
/** 发货地址 */
path: '/memberCenter/logisticsAbility/logisticsAdminister/shipmentsAddress',
name: '发货地址',
component: '@/pages/transaction/logisticsAbility/logisticsAdminister/shipmentsAddress',
},
{
/** 发货地址 */
path: '/memberCenter/logisticsAbility/logisticsAdminister/shipmentsAddress/add',
name: '添加发货地址',
component: '@/pages/transaction/logisticsAbility/logisticsAdminister/shipmentsAddress/add',
hideInMenu: true,
},
{
/** 发货地址 */
path: '/memberCenter/logisticsAbility/logisticsAdminister/shipmentsAddress/edit',
name: '编辑发货地址',
component: '@/pages/transaction/logisticsAbility/logisticsAdminister/shipmentsAddress/edit',
hideInMenu: true,
},
{
/** 收货地址 */
path: '/memberCenter/logisticsAbility/logisticsAdminister/receivingAddress',
name: '收货地址',
component: '@/pages/transaction/logisticsAbility/logisticsAdminister/receivingAddress',
},
{
/** 收货地址 */
path: '/memberCenter/logisticsAbility/logisticsAdminister/receivingAddress/add',
name: '添加收货地址',
component: '@/pages/transaction/logisticsAbility/logisticsAdminister/receivingAddress/add',
hideInMenu: true,
},
{
/** 收货地址 */
path: '/memberCenter/logisticsAbility/logisticsAdminister/receivingAddress/edit',
name: '编辑收货地址',
component: '@/pages/transaction/logisticsAbility/logisticsAdminister/receivingAddress/edit',
hideInMenu: true,
},
{
/** 运费模板 */
path: '/memberCenter/logisticsAbility/logisticsAdminister/freightTemplate',
name: '运费模板',
component: '@/pages/transaction/logisticsAbility/logisticsAdminister/freightTemplate',
},
]
}
]
......@@ -24,7 +24,7 @@ import Select from './components/Select';
import SearchSelect from './components/SearchSelect';
import TableTagList from './components/TableTagList';
import './index.less'
import { Checkbox, Radio } from '@formily/antd-components';
import { Checkbox, Radio, Switch } from '@formily/antd-components';
import DateSelect from './components/DateSelect';
import DateRangePickerUnix from './components/DateRangePickerUnix';
import NumberRange from './components/NumberRange';
......@@ -129,6 +129,7 @@ export const componentExport = {
CustomSelect,
CheckboxGroup,
CustomRadioGroup,
Switch,
}
const NiceForm: React.FC<NiceFormProps> = props => {
const { children, components, effects, expressionScope, loading = false, ...reset } = props;
......@@ -144,7 +145,7 @@ const NiceForm: React.FC<NiceFormProps> = props => {
if (
paginationInfo
&& match.path === paginationInfo.pathname
&& !('value' in reset)
&& !('value' in reset)
&& !('initialValues' in reset)
) {
reset.actions.setFormState(
......
import { ISchema } from '@formily/antd';
import React, { useEffect, useRef, useState } from 'react';
import { Modal, Row, Col, Drawer,Button } from 'antd';
import { createFormActions } from '@formily/antd';
import { StandardTable } from 'god';
import { ColumnsType } from 'antd/es/table';
import NiceForm from '@/components/NiceForm';
const formActions = createFormActions();
interface Iprops {
modalType?: "Modal" | "Drawer"
/**
* 是否显示
*/
visible: boolean,
/**
* Modal 标题
*/
title: string,
/**
* 搜索schema
*/
schema: ISchema,
/**
* table Ccolumn
*/
columns: ColumnsType,
footer?: React.ReactNode,
tableProps?: {
rowKey: string | ((record) => any)
},
mode: 'checkbox' | 'radio',
customizeRadio?: boolean,
/**
* rowSelection
*/
value?: {[key: string]: any}[],
/**
* onChange
*/
expressionScope?: {[key: string]: any}
/**
* format话参数
*/
format?: ((value) => any) | null,
effects?: ($, actions) => void,
fetchData: (params: any) => any,
onClose: () => void,
onOk: (selectRow: number[] | string[], selectedRows: {[key: string]: any}[]) => void,
}
const TableModal: React.FC<Iprops> = (props: Iprops) => {
const { title, visible, schema, columns, effects, tableProps, mode, expressionScope, fetchData, onClose, onOk, value, format, customizeRadio, modalType, footer } = props;
const ref = useRef<any>({});
const isFirstLoad = useRef<boolean>(true)
const [selectRow, setSelectRow] = useState<number[] | string[]>(() => {
return value.map( (_row) => typeof tableProps.rowKey === 'string' ? _row[tableProps.rowKey as string] : tableProps.rowKey(_row))
})
const [selectRowRecord, setSelectRowRecord] = useState<{[key: string]: any}[]>([]);
useEffect(() => {
if (!visible) {
return;
}
const keys = value.map(
(_row) => {
// console.log(typeof tableProps.rowKey === 'string' && tableProps.rowKey(_row))
return typeof tableProps.rowKey === 'string' ? _row[tableProps.rowKey as string] : tableProps.rowKey(_row)
});
setSelectRow(keys)
setSelectRowRecord(value);
}, [visible, value])
const handleEffects = ($: any, actions: any) => {
effects?.($, actions);
}
const handleOnClose = () => {
onClose?.()
}
const handleOk = () => {
onOk?.(selectRow, selectRowRecord)
}
useEffect(() => {
if (!visible) {
return ;
}
if (!isFirstLoad.current) {
ref.current?.reload?.();
}
isFirstLoad.current = false;
}, [visible])
const onSelectChange = (record, selected: boolean, selectedRows) => {
const recordRows = customizeRadio || mode === 'radio' ? selectedRows.slice(-1) : selectedRows;
const keys = recordRows.map((_item) => typeof tableProps.rowKey === 'string' ? _item[tableProps.rowKey as string] : tableProps.rowKey(_item));
setSelectRowRecord(selectedRows)
setSelectRow(keys)
};
const handleSearch = (params: any) => {
const res = (format && format(params)) || params;
ref.current?.reload(res)
}
const Component = modalType === 'Modal' ? Modal : Drawer;
const renderFooter = () => {
return (
<div style={{ textAlign: 'right'}}>
<Button onClick={handleOnClose} style={{ marginRight: 8 }}>
取消
</Button>
<Button onClick={handleOk} type="primary">
提交
</Button>
</div>
)
}
const otherProps = modalType === 'Drawer' ? { footer: renderFooter() } : { onOk: handleOk}
return (
<Component
title={title}
visible={visible}
onCancel={handleOnClose}
// onOk={handleOk}
width={840}
{...otherProps}
>
<StandardTable
columns={columns}
tableProps={{
...tableProps,
pagination: false
}}
fetchTableData={fetchData}
currentRef={ref}
rowSelection={{
type: customizeRadio && mode === 'radio' ? 'checkbox' : mode,
onSelect: onSelectChange,
selectedRowKeys: selectRow,
hideSelectAll: customizeRadio,
}}
formRender={(child, ps) => (
<div style={{display: "flex", flexDirection: 'row', justifyContent: 'space-between'}}>
<div>{child}</div>
<div>{ps}</div>
</div>
)}
controlRender={
<NiceForm
schema={schema}
actions={formActions}
onSubmit={handleSearch}
expressionScope={expressionScope}
effects={($, actions) => handleEffects($, actions)}
/>
}
>
</StandardTable>
</Component>
)
}
TableModal.defaultProps = {
// rowSelection: null,
mode: 'radio',
tableProps: {
rowKey: 'memberId'
},
value: [],
expressionScope: {},
format: null,
customizeRadio: false,
modalType: "Modal",
footer: null
}
export default TableModal;
......@@ -11,8 +11,8 @@ import { EXTERNALSTATE_COLOR, INTERNALSTATE_COLOR } from '@/pages/transaction/co
import ProgressLayout from '@/pages/transaction/components/detailLayout/components/progressLayout';
import BasicLayout from '@/pages/transaction/components/detailLayout/components/basicLayout';
import ListLayout from '@/pages/transaction/components/detailLayout/components/listLayout';
import GeneralLayout from '@/pages/transaction/components/detailLayout/components/GeneralLayout';
import RecordLyout from '@/pages/transaction/components/detailLayout/components/RecordLyout';
import GeneralLayout from '@/pages/transaction/components/detailLayout/components/generalLayout';
import RecordLyout from '@/pages/transaction/components/detailLayout/components/recordLyout';
import ModalOperate from '@/pages/transaction/components/modalOperate';
const TABLINK = [
......
......@@ -11,8 +11,8 @@ import { EXTERNALSTATE_COLOR, INTERNALSTATE_COLOR } from '@/pages/transaction/co
import ProgressLayout from '@/pages/transaction/components/detailLayout/components/progressLayout';
import BasicLayout from '@/pages/transaction/components/detailLayout/components/basicLayout';
import ListLayout from '@/pages/transaction/components/detailLayout/components/listLayout';
import GeneralLayout from '@/pages/transaction/components/detailLayout/components/GeneralLayout';
import RecordLyout from '@/pages/transaction/components/detailLayout/components/RecordLyout';
import GeneralLayout from '@/pages/transaction/components/detailLayout/components/generalLayout';
import RecordLyout from '@/pages/transaction/components/detailLayout/components/recordLyout';
import EyePreview from '@/components/EyePreview';
const TABLINK = [
......
......@@ -11,8 +11,8 @@ import { EXTERNALSTATE_COLOR, INTERNALSTATE_COLOR } from '@/pages/transaction/co
import ProgressLayout from '@/pages/transaction/components/detailLayout/components/progressLayout';
import BasicLayout from '@/pages/transaction/components/detailLayout/components/basicLayout';
import ListLayout from '@/pages/transaction/components/detailLayout/components/listLayout';
import GeneralLayout from '@/pages/transaction/components/detailLayout/components/GeneralLayout';
import RecordLyout from '@/pages/transaction/components/detailLayout/components/RecordLyout';
import GeneralLayout from '@/pages/transaction/components/detailLayout/components/generalLayout';
import RecordLyout from '@/pages/transaction/components/detailLayout/components/recordLyout';
import ModalOperate from '@/pages/transaction/components/modalOperate';
const TABLINK = [
......
......@@ -11,8 +11,8 @@ import { EXTERNALSTATE_COLOR, INTERNALSTATE_COLOR } from '@/pages/transaction/co
import ProgressLayout from '@/pages/transaction/components/detailLayout/components/progressLayout';
import BasicLayout from '@/pages/transaction/components/detailLayout/components/basicLayout';
import ListLayout from '@/pages/transaction/components/detailLayout/components/listLayout';
import GeneralLayout from '@/pages/transaction/components/detailLayout/components/GeneralLayout';
import RecordLyout from '@/pages/transaction/components/detailLayout/components/RecordLyout';
import GeneralLayout from '@/pages/transaction/components/detailLayout/components/generalLayout';
import RecordLyout from '@/pages/transaction/components/detailLayout/components/recordLyout';
import EyePreview from '@/components/EyePreview';
const TABLINK = [
......
......@@ -11,8 +11,8 @@ import { EXTERNALSTATE_COLOR, INTERNALSTATE_COLOR } from '@/pages/transaction/co
import ProgressLayout from '@/pages/transaction/components/detailLayout/components/progressLayout';
import BasicLayout from '@/pages/transaction/components/detailLayout/components/basicLayout';
import ListLayout from '@/pages/transaction/components/detailLayout/components/listLayout';
import GeneralLayout from '@/pages/transaction/components/detailLayout/components/GeneralLayout';
import RecordLyout from '@/pages/transaction/components/detailLayout/components/RecordLyout';
import GeneralLayout from '@/pages/transaction/components/detailLayout/components/generalLayout';
import RecordLyout from '@/pages/transaction/components/detailLayout/components/recordLyout';
import ModalOperate from '@/pages/transaction/components/modalOperate';
const TABLINK = [
......
.label {
font-size: 12px;
color: #909399;
&::after {
margin-left: 4px;
font-size: 12px;
font-family: SimSun, sans-serif;
color: #ff4d4f;
content: '*';
}
}
\ No newline at end of file
import React, { useState, useEffect, useMemo } from 'react';
import { Card, Spin, Button } from 'antd';
import { history, Prompt } from 'umi';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import NiceForm from '@/components/NiceForm';
import ReutrnEle from '@/components/ReturnEle';
import { createFormActions, FormEffectHooks, ISchema } from '@formily/antd';
import { SaveOutlined } from '@ant-design/icons';
import { PublicApi } from '@/services/api';
import { useLinkEnumEffect } from '@/components/NiceForm/linkages/linkEnum';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import styles from './index.less';
const formActions = createFormActions();
const {
onFormInputChange$,
} = FormEffectHooks;
interface AddressFormProps {
/**
* 数据id
*/
id?: number;
/**
* 是否可编辑的
*/
isEdit?: boolean,
/**
* 联动title
**/
title?: string,
/**
* 接口
*/
fetch?: () => Promise<unknown>,
/**
* schema
*/
schema?: ISchema,
/**
* detail
*/
detail?: () => Promise<unknown>,
};
const AddressForm: React.FC<AddressFormProps> = (props: any) => {
const { id, isEdit, title, fetch, schema, detail } = props;
const [submitLoading, setSubmitLoading] = useState(false);
const [unsaved, setUnsaved] = useState(false);
const [infoLoading, setInfoLoading] = useState(false);
const [initialValue, setInitialValue] = useState(null);
// 获取手机code
const fetchTelCode = async () => {
const { data } = await PublicApi.getManageCountryAreaGetTelCode();
return data;
};
/** 获取地区地址 */
const handleAddressSelesed = async () => {
await PublicApi.getManageAreaAll().then(res => {
const { code, data } = res
if (code !== 1000) {
return
}
formActions.setFieldState('provinceCode', targetState => {
targetState.originData = data;
targetState.props.enum = data.map(v => ({
label: v.name,
value: v.code,
}));
});
})
}
useEffect(() => {
handleAddressSelesed()
}, [])
const AddressLabel = (
<div className={styles.label}>
{title}
</div>
);
const PhoneLabel = (
<div className={styles.label}>
手机号码
</div>
);
const handleSubmit = (value: any) => {
setSubmitLoading(true)
const provinceName = formActions.getFieldState('provinceCode', ({ values }) => {
return { provinceName: values[1].title }
})
const cityName = formActions.getFieldState('cityCode', ({ values }) => {
return { cityName: values[1].title }
})
const districtName = formActions.getFieldState('districtCode', ({ values }) => {
return { districtName: values[1].title }
})
const params = {
...value,
isDefault: value.isDefault ? 1 : 0,
...provinceName,
...cityName,
...districtName
}
id && (params.id = id)
fetch(params).then(res => {
setUnsaved(false)
setSubmitLoading(false)
if (res.code !== 1000) {
return
}
history.goBack();
})
}
const formatedValue = useMemo(() => {
if (!initialValue) {
return {}
}
return initialValue
}, [initialValue])
useEffect(() => {
if (id) {
setInfoLoading(true)
detail({ id }).then(res => {
setInfoLoading(false)
if (res.code !== 1000) {
return
}
setInitialValue(res.data)
})
}
}, [])
return (
<Spin spinning={infoLoading}>
<PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回" />}
extra={[
(isEdit && <Button
key="1"
type="primary"
icon={<SaveOutlined />}
loading={submitLoading}
onClick={() => formActions.submit()}
>
保存
</Button>)
]}
>
<Card>
<NiceForm
initialValues={formatedValue}
onSubmit={handleSubmit}
actions={formActions}
expressionScope={{
AddressLabel,
PhoneLabel,
}}
effects={() => {
useLinkEnumEffect('areaResponses', result =>
result.map(v => ({
label: v.name,
value: v.code,
})),
'code'
);
useAsyncSelect('areaCode', fetchTelCode);
onFormInputChange$().subscribe(() => {
if (!unsaved) {
setUnsaved(true);
}
});
}}
schema={schema}
editable={isEdit}
/>
</Card>
</PageHeaderWrapper>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
</Spin>
)
}
AddressForm.defaultProps = {
id: 0,
isEdit: false,
};
export default AddressForm;
import React, { useRef } from 'react';
import { history } from 'umi';
import { Button, Row, Col, Space, Popconfirm, Switch } from 'antd';
import Table from '@/pages/transaction/components/TableLayout';
import { ColumnType } from 'antd/lib/table/interface';
import { PublicApi } from '@/services/api';
import { LOGISTICSADMINISTERSCHEMA } from '../schema';
import { PlusOutlined } from '@ant-design/icons';
import StatusSwitch from '@/components/StatusSwitch';
const STATUS = {
/** 有效 */
VALID: 1,
/** 无效 */
INVALID: 0
}
const FreightTemplate = () => {
const reload = useRef<any>();
const handleChangeStatus = (id: any, status: any) => {
let _status = status == 0 ? 1 : 0
PublicApi.postLogisticsFreightTemplateEnable({ id: id, status: _status }).then(res => {
if (res.code === 1000) {
reload.current.reload()
}
})
}
const handleDelete = (id: number) => {
PublicApi.postLogisticsFreightTemplateDelete({ id: id }).then(res => {
if (res.code === 1000) {
reload.current.reload()
}
})
}
const columns: ColumnType<any>[] = [
{
title: 'ID',
key: 'id',
dataIndex: 'id',
},
{
title: '模板名称',
key: 'name',
dataIndex: 'name',
},
{
title: '计价方式',
key: 'pricingMode',
dataIndex: 'pricingMode',
render: (_text) => '按重量'
},
{
title: '运送方式',
key: 'transportMode',
dataIndex: 'transportMode',
render: (_text) => '快递'
},
{
title: '运费说明',
key: 'explain',
dataIndex: 'explain',
},
{
title: '状态',
key: 'status',
dataIndex: 'status',
render: (_text: any, data: any) => (
<StatusSwitch fieldNames="status" handleConfirm={() => handleChangeStatus(data.id, data.status)} record={data} />
)
},
{
title: '操作',
key: 'operate',
dataIndex: 'operate',
render: (_text, data) => data.status === STATUS.INVALID && <>
<Button type='link' onClick={() => history.push(`/memberCenter/logisticsAbility/logistics/company/edit?id=${data.id}`)}>编辑</Button>
<Popconfirm title="确定要删除吗?" okText="是" cancelText="否" onConfirm={() => handleDelete(data.id)}>
<Button type='link'>
删除
</Button>
</Popconfirm>
</>
}
]
return (
<Table
columns={columns}
reload={reload}
schema={LOGISTICSADMINISTERSCHEMA}
fetch={PublicApi.getLogisticsFreightTemplatePage}
controllerBtns={
<Row>
<Col span={24}>
<Space direction="horizontal" size={16}>
<Button
type="primary"
icon={<PlusOutlined />}
>
新建
</Button>
</Space>
</Col>
</Row>
}
/>
)
}
export default FreightTemplate;
import React, { useCallback, useEffect, useState, useMemo } from 'react';
import { Card, Spin, Button } from 'antd';
import { history, Prompt } from 'umi';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import NiceForm from '@/components/NiceForm';
import ReutrnEle from '@/components/ReturnEle';
import { createFormActions, FormEffectHooks } from '@formily/antd';
import { LinkOutlined, SaveOutlined } from '@ant-design/icons';
import { formSchema, logisticsSchema } from './schema';
import TableModal from '@/pages/transaction/components/TableModal';
import { PublicApi } from '@/services/api';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { ColumnType } from 'antd/lib/table/interface';
const formActions = createFormActions();
const {
onFieldChange$,
onFormInputChange$,
} = FormEffectHooks;
const COOPERATE = {
/** 平台物流服务商 */
PLATFORM: 1,
/** 商户合作物流公司 */
MERCHANTS: 2
}
const LogisticsCompanyManageAdded = (props: any) => {
const {
query: {
id
},
pathname,
} = history.location;
const [path] = useState(pathname.split('/')[pathname.split('/').length - 1]);
const [excludeList, setExcludeList] = useState([]);
const [submitLoading, setSubmitLoading] = useState(false);
const [unsaved, setUnsaved] = useState(false);
const [infoLoading, setInfoLoading] = useState(false);
const [visible, setVisible] = useState(false);
const [initialValue, setInitialValue] = useState(null);
const columns: ColumnType<any>[] = [
{
title: '会员ID',
key: 'memberId',
dataIndex: 'memberId',
},
{
title: '会员名称',
key: 'name',
dataIndex: 'name',
},
{
title: '会员角色',
key: 'roleName',
dataIndex: 'roleName',
},
{
title: '会员等级',
key: 'levelTag',
dataIndex: 'levelTag',
},
]
const useFormEffects = () => {
onFieldChange$('cooperateType').subscribe(({ value }) => {
if (value === COOPERATE.PLATFORM) {
formActions.setFieldState('code', state => state.visible = false)
formActions.setFieldState('companyMemberId', state => state.visible = true)
formActions.setFieldState('name', state => state.props['x-component-props'].disabled = true)
} else if (value === COOPERATE.MERCHANTS) {
formActions.setFieldState('code', state => state.visible = true)
formActions.setFieldState('companyMemberId', state => state.visible = false)
formActions.setFieldState('name', state => state.props['x-component-props'].disabled = false)
}
})
}
const handleFetchData = useCallback((params: any) => {
return new Promise(resolve => {
PublicApi.getLogisticsSelectListMemberCompanySelected().then(r => {
if (r.code !== 1000) {
return
}
PublicApi.postMemberManageLogisticsPage({ ...params, excludeList: r.data }, { ctlType: 'none' }).then(res => {
if (res.code !== 1000) {
return
}
resolve(res.data)
})
})
})
}, [])
const toggle = (flag: boolean) => {
setVisible(flag)
}
const handleLogisticOnOk = (selectRowKeys: string[] | number[], selectRowRecord: any) => {
const target = selectRowRecord[0];
formActions.setFieldValue('name', target.name)
formActions.setFieldValue('companyMemberId', target.memberId);
setExcludeList(selectRowRecord)
toggle(false)
}
const handleOnSubmit = async (values: any) => {
setSubmitLoading(true)
const params: any = {
name: values.name,
cooperateType: values.cooperateType,
remark: values.remark,
}
if (values.cooperateType === COOPERATE.PLATFORM) {
params.companyMemberId = values.companyMemberId;
params.companyRoleId = excludeList[0].roleId;
} else {
params.code = values.code
}
path === 'edit' && (params.id = id);
const servie = path === 'add' ? PublicApi.postLogisticsCompanyAdd : PublicApi.postLogisticsCompanyUpdate
servie({ ...params }).then(res => {
setUnsaved(false)
setSubmitLoading(false)
if (res.code !== 1000) {
return
}
history.goBack();
})
}
useEffect(() => {
if (path !== 'add') {
setInfoLoading(true)
PublicApi.getLogisticsCompanyGet({ id }).then(res => {
setInfoLoading(false)
if (res.code !== 1000) {
return
}
setInitialValue(res.data)
})
}
}, [])
const formatedValue = useMemo(() => {
if (!initialValue) {
return {}
}
return initialValue
}, [initialValue])
return (
<Spin spinning={infoLoading}>
<PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回" />}
title={!id ? '新增物流公司' : path === 'edit' ? '编辑物流公司' : '查看物流公司'}
extra={[
(path !== 'preview' && <Button
key="1"
type="primary"
icon={<SaveOutlined />}
loading={submitLoading}
onClick={() => formActions.submit()}
>
保存
</Button>)
]}
>
<Card>
<NiceForm
initialValues={formatedValue}
actions={formActions}
onSubmit={handleOnSubmit}
expressionScope={{
connectMember: (
<div onClick={() => toggle(true)}>
<LinkOutlined style={{ marginRight: 4 }} />
选择
</div>
)
}}
effects={() => {
useFormEffects();
onFormInputChange$().subscribe(() => {
if (!unsaved) {
setUnsaved(true);
}
});
}}
schema={formSchema}
editable={path === 'preview' ? false : true}
/>
</Card>
</PageHeaderWrapper>
<TableModal
title="选择平台物流服务商"
mode="radio"
modalType="Drawer"
columns={columns}
schema={logisticsSchema}
fetchData={handleFetchData}
visible={visible}
effects={($, actions) => {
useStateFilterSearchLinkageEffect($, actions, 'name', FORM_FILTER_PATH);
}}
tableProps={{
rowKey: 'memberId',
}}
onClose={() => toggle(false)}
onOk={handleLogisticOnOk}
/>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
</Spin>
)
}
LogisticsCompanyManageAdded.defaultProps = {
id: 0,
isEdit: false,
};
export default LogisticsCompanyManageAdded;
import React, { useRef } from 'react';
import { history } from 'umi';
import { Button, Row, Col, Space, Popconfirm } from 'antd';
import Table from '@/pages/transaction/components/TableLayout';
import { ColumnType } from 'antd/lib/table/interface';
import { PublicApi } from '@/services/api';
import { LOGISTICSADMINISTERSCHEMA } from '../schema';
import { PlusOutlined } from '@ant-design/icons';
import EyePreview from '@/components/EyePreview';
import StatusSwitch from '@/components/StatusSwitch';
const COOPERATE = {
/** 平台物流服务商 */
PLATFORM: 1,
/** 商户合作物流公司 */
MERCHANTS: 2
}
const STATUS = {
/** 有效 */
VALID: 1,
/** 无效 */
INVALID: 0
}
const LogisticsCompanyManage = () => {
const reload = useRef<any>();
const handleChangeStatus = async (id: any, status: any) => {
let _status = status == 1 ? 0 : 1
await PublicApi.postLogisticsCompanyEnable({ id: id, status: _status })
reload.current.reload()
}
const handleDelete = (id: any) => {
PublicApi.postLogisticsCompanyDelete({ id: id }).then(res => {
if (res.code === 1000) {
reload.current.reload()
}
})
}
const columns: ColumnType<any>[] = [
{
title: 'ID',
key: 'id',
dataIndex: 'id',
},
{
title: '物流公司编码/平台会员ID',
key: 'code',
dataIndex: 'code',
render: (text, data) => text ? text : data.companyMemberId
},
{
title: '物流公司名称',
key: 'name',
dataIndex: 'name',
render: (text, data) => <EyePreview url={`/memberCenter/logisticsAbility/logisticsAdminister/logisticsCompanyManage/preview?id=${data.id}`}>{text}</EyePreview>
},
{
title: '合作类型',
key: 'cooperateType',
dataIndex: 'cooperateType',
render: (text) => text === COOPERATE.PLATFORM ? '平台物流服务商' : '商户合作物流公司'
},
{
title: '状态',
key: 'status',
dataIndex: 'status',
render: (_text: any, data: any) => (
<StatusSwitch fieldNames="status" handleConfirm={() => handleChangeStatus(data.id, data.status)} record={data} />
)
},
{
title: '操作',
key: 'operate',
dataIndex: 'operate',
render: (_text, data) => data.status === STATUS.INVALID && <>
<Button type='link' onClick={() => history.push(`/memberCenter/logisticsAbility/logisticsAdminister/logisticsCompanyManage/edit?id=${data.id}`)}>编辑</Button>
<Popconfirm title="确定要删除吗?" okText="是" cancelText="否" onConfirm={() => handleDelete(data.id)}>
<Button type='link'>
删除
</Button>
</Popconfirm>
</>
}
]
return (
<Table
columns={columns}
reload={reload}
schema={LOGISTICSADMINISTERSCHEMA}
fetch={PublicApi.getLogisticsCompanyPage}
controllerBtns={
<Row>
<Col span={24}>
<Space direction="horizontal" size={16}>
<Button
type="primary"
icon={<PlusOutlined />}
onClick={() => history.push(`/memberCenter/logisticsAbility/logisticsAdminister/logisticsCompanyManage/add`)}
>
新建
</Button>
</Space>
</Col>
</Row>
}
/>
)
}
export default LogisticsCompanyManage;
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { PublicApi } from '@/services/api';
import { ISchema } from '@formily/antd';
export const formSchema: ISchema = {
type: 'object',
properties: {
MEGA_LAYOUT1: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
labelCol: 4,
wrapperCol: 8,
labelAlign: 'left',
},
properties: {
cooperateType: {
type: 'string',
title: '合作类型',
enum: [
{ label: '平台物流服务商', value: 1 },
{ label: '商户合作物流公司', value: 2 },
],
'x-component-props': {
placeholder: '请选择合作类型'
},
'x-rules': [
{
required: true,
message: '请选择合作类型'
},
]
},
code: {
type: 'string',
title: '物流公司代码/平台会员ID',
visible: false,
'x-component-props': {
placeholder: '物流公司代码'
},
'x-rules': [
{
required: true,
message: '请输入物流公司代码'
},
{
limitByte: true, // 自定义校验规则
maxByte: 60
}
]
},
companyMemberId: {
type: 'string',
title: "物流公司代码/平台会员ID",
visible: false,
"x-component-props": {
disabled: true,
addonAfter: "{{connectMember}}",
placeholder: '平台会员ID'
},
"x-rules": [
{
required: true,
message: '请选择平台会员ID'
}
],
},
name: {
type: 'string',
title: '物流公司名称',
'x-component-props': {
placeholder: '最长60个字符,30个汉字'
},
'x-rules': [
{
required: true,
message: '请输入物流公司名称'
},
{
limitByte: true, // 自定义校验规则
maxByte: 60
}
]
},
remark: {
type: 'string',
title: '备注',
'x-component': 'TextArea',
'x-component-props': {
placeholder: '最长60个字符,30个汉字'
},
'x-rules': [
{
limitByte: true, // 自定义校验规则
maxByte: 60
}
]
}
}
}
}
}
export const logisticsSchema: ISchema = {
type: "object",
properties: {
megalayout: {
type: "object",
"x-component": "mega-layout",
properties: {
name: {
type: "string",
"x-component": "Search",
"x-mega-props": {},
"x-component-props": {
placeholder: "会员名称",
align: "flex-left",
}
}
}
},
[FORM_FILTER_PATH]: {
type: "object",
"x-component": "flex-layout",
"x-component-props": {
rowStyle: {
justifyContent: "flex-start",
flexWrap: "nowrap"
},
colStyle: {//改变间隔
marginRight: 20
}
},
properties: {
PRO_LAYOUT: {
type: "object",
"x-component": "mega-layout",
"x-mega-props": {
span: 5
},
"x-component-props": {
inline: true
},
properties: {
roleId: {
type: 'string',
"x-component": 'Select',
"x-component-props": {
placeholder: '选择会员角色',
fetchSearch: () => {
return new Promise(resolve => {
PublicApi.getMemberManageRoleAll().then(res => {
res.data.forEach((item:any) => {
item.id = item.roleId;
item.name = item.roleName;
})
resolve(res)
})
})
},
style: {
width: 160
}
}
},
}
},
sumbit: {
"x-component": "Submit",
"x-mega-props": {
span: 1
},
"x-component-props": {
children: "查询"
}
}
}
}
}
}
import React from 'react';
import { receiverAddress } from '../component/schema'
import AddressForm from '../component/addressForm';
import { PublicApi } from '@/services/api';
const ReceivingAddressAdded = () => {
return (
<AddressForm
title='收货地区'
schema={receiverAddress}
fetch={PublicApi.postLogisticsReceiverAddressAdd}
isEdit
/>
)
}
export default ReceivingAddressAdded
import React from 'react';
import { history } from 'umi';
import { receiverAddress } from '../component/schema'
import AddressForm from '../component/addressForm';
import { PublicApi } from '@/services/api';
const ReceivingAddressEdit = () => {
const {
query: {
id
},
} = history.location;
return (
<AddressForm
id={id}
title='收货地区'
schema={receiverAddress}
fetch={PublicApi.postLogisticsReceiverAddressUpdate}
detail={PublicApi.getLogisticsReceiverAddressGet}
isEdit
/>
)
}
export default ReceivingAddressEdit
import React, { useRef } from 'react';
import { history } from 'umi';
import { Button, Row, Col, Space, Popconfirm, Switch } from 'antd';
import Table from '@/pages/transaction/components/TableLayout';
import { ColumnType } from 'antd/lib/table/interface';
import { PublicApi } from '@/services/api';
import { LOGISTICSADMINISTERSCHEMA } from '../schema';
import { PlusOutlined } from '@ant-design/icons';
const ReceivingAddress = () => {
const reload = useRef<any>();
const handleDelete = (id: any) => {
PublicApi.postLogisticsReceiverAddressDelete({ id: id }).then(res => {
if (res.code === 1000) {
reload.current.reload()
}
})
}
const columns: ColumnType<any>[] = [
{
title: '收货人姓名',
key: 'receiverName',
dataIndex: 'receiverName',
},
{
title: '收货地址',
key: 'fullAddress',
dataIndex: 'fullAddress',
},
{
title: '邮编',
key: 'postalCode',
dataIndex: 'postalCode',
},
{
title: '手机号码',
key: 'phone',
dataIndex: 'phone',
},
{
title: '电话号码',
key: 'tel',
dataIndex: 'tel',
},
{
title: '是否默认',
key: 'isDefault',
dataIndex: 'isDefault',
render: (text) => <Switch disabled defaultChecked={text == 0 ? false : true} />
},
{
title: '操作',
key: 'operate',
dataIndex: 'operate',
render: (_text, data) => <>
<Button type='link' onClick={() => history.push(`/memberCenter/logisticsAbility/logisticsAdminister/receivingAddress/edit?id=${data.id}`)}>编辑</Button>
<Popconfirm title="确定要删除吗?" okText="是" cancelText="否" onConfirm={() => handleDelete(data.id)}>
<Button type='link'>
删除
</Button>
</Popconfirm>
</>
}
]
return (
<Table
columns={columns}
reload={reload}
schema={LOGISTICSADMINISTERSCHEMA}
fetch={PublicApi.getLogisticsReceiverAddressPage}
controllerBtns={
<Row>
<Col span={24}>
<Space direction="horizontal" size={16}>
<Button
type="primary"
icon={<PlusOutlined />}
onClick={() => history.push(`/memberCenter/logisticsAbility/logisticsAdminister/receivingAddress/add`)}
>
新建
</Button>
</Space>
</Col>
</Row>
}
/>
)
}
export default ReceivingAddress;
import { ISchema } from '@formily/antd';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { PublicApi } from '@/services/api';
/** 快递单查询 */
export const LOGISTICSADMINISTERSCHEMA: ISchema = {
type: "object",
properties: {
megalayout: {
type: "object",
"x-component": "mega-layout",
"x-component-props": {
grid: true
},
properties: {
ctl: {
type: "object",
"x-component": "controllerBtns",
},
},
},
[FORM_FILTER_PATH]: {
type: "object",
"x-component": "flex-layout",
"x-component-props": {
rowStyle: {
flexWrap: "nowrap"
},
colStyle: {
marginLeft: 20
}
},
}
}
}
import React from 'react';
import { shipperAddress } from '../component/schema'
import AddressForm from '../component/addressForm';
import { PublicApi } from '@/services/api';
const ShipperAddressAdded = () => {
return (
<AddressForm
title='发货地区'
schema={shipperAddress}
fetch={PublicApi.postLogisticsShipperAddressAdd}
isEdit
/>
)
}
export default ShipperAddressAdded
import React from 'react';
import { history } from 'umi';
import { shipperAddress } from '../component/schema'
import AddressForm from '../component/addressForm';
import { PublicApi } from '@/services/api';
const ShipperAddressEdit = () => {
const {
query: {
id
},
} = history.location;
return (
<AddressForm
id={id}
title='发货地区'
schema={shipperAddress}
fetch={PublicApi.postLogisticsShipperAddressUpdate}
detail={PublicApi.getLogisticsShipperAddressGet}
isEdit
/>
)
}
export default ShipperAddressEdit
import React, { useRef } from 'react';
import { history } from 'umi';
import { Button, Row, Col, Space, Popconfirm, Switch } from 'antd';
import Table from '@/pages/transaction/components/TableLayout';
import { ColumnType } from 'antd/lib/table/interface';
import { PublicApi } from '@/services/api';
import { LOGISTICSADMINISTERSCHEMA } from '../schema';
import { PlusOutlined } from '@ant-design/icons';
const ShipmentsAddress = () => {
const reload = useRef<any>();
const handleDelete = (id: any) => {
PublicApi.postLogisticsShipperAddressDelete({ id: id }).then(res => {
if (res.code === 1000) {
reload.current.reload()
}
})
}
const columns: ColumnType<any>[] = [
{
title: '收货人姓名',
key: 'shipperName',
dataIndex: 'shipperName',
},
{
title: '收货地址',
key: 'fullAddress',
dataIndex: 'fullAddress',
},
{
title: '邮编',
key: 'postalCode',
dataIndex: 'postalCode',
},
{
title: '手机号码',
key: 'phone',
dataIndex: 'phone',
},
{
title: '电话号码',
key: 'tel',
dataIndex: 'tel',
},
{
title: '是否默认',
key: 'isDefault',
dataIndex: 'isDefault',
render: (text) => <Switch disabled defaultChecked={text == 0 ? false : true} />
},
{
title: '操作',
key: 'operate',
dataIndex: 'operate',
render: (_text, data) => <>
<Button type='link' onClick={() => history.push(`/memberCenter/logisticsAbility/logisticsAdminister/shipmentsAddress/edit?id=${data.id}`)}>编辑</Button>
<Popconfirm title="确定要删除吗?" okText="是" cancelText="否" onConfirm={() => handleDelete(data.id)}>
<Button type='link'>
删除
</Button>
</Popconfirm>
</>
}
]
return (
<Table
columns={columns}
reload={reload}
schema={LOGISTICSADMINISTERSCHEMA}
fetch={PublicApi.getLogisticsShipperAddressPage}
controllerBtns={
<Row>
<Col span={24}>
<Space direction="horizontal" size={16}>
<Button
type="primary"
icon={<PlusOutlined />}
onClick={() => history.push(`/memberCenter/logisticsAbility/logisticsAdminister/shipmentsAddress/add`)}
>
新建
</Button>
</Space>
</Col>
</Row>
}
/>
)
}
export default ShipmentsAddress;
import React from 'react';
import { history } from 'umi';
import { Modal } from 'antd'
import {
SchemaForm, SchemaMarkupField as Field,
createFormActions,
FormEffectHooks
} from '@formily/antd'
import { Input, Radio } from '@formily/antd-components'
import { PublicApi } from '@/services/api';
interface BillSubmitProps {
/** 数据 */
dataSource: any,
/** 显示隐藏 */
visible: boolean,
/** 关闭 */
onClose: () => void,
}
const actions = createFormActions()
const { onFieldChange$ } = FormEffectHooks
const BillSubmit: React.FC<BillSubmitProps> = (props: any) => {
const { visible, dataSource, onClose } = props;
const useFormEffects = () => {
const { setFieldState } = createFormActions()
onFieldChange$('status').subscribe(({ value }) => {
setFieldState('remark', state => {
if (value === 4) {
state.visible = false
} else {
state.visible = true
}
})
})
}
const handleSubmit = (val: any) => {
const params = {
...val,
id: dataSource.id,
freightPrice: dataSource.freightPrice,
taxInclusive: 1,
taxRate: dataSource.taxRate
}
PublicApi.postLogisticsOrderWaitConfirmConfirm(params).then(res => {
if (res.code !== 1000) {
return
}
history.goBack()
})
}
const onCancel = () => {
onClose();
actions.reset()
}
return (
<Modal
title='单据确认'
visible={visible}
okText='确定'
cancelText='取消'
onCancel={onCancel}
onOk={() => actions.submit()}
afterClose={() => actions.reset()}
>
<SchemaForm
labelCol={6}
layout="vertical"
components={{
Input, Radio: Radio.Group, TextArea: Input.TextArea
}}
actions={actions}
effects={() => useFormEffects()}
onSubmit={(values) => handleSubmit(values)}
initialValues={{
status: 4
}}
>
<Field
enum={
[
{ label: '接受物流单', value: 4 },
{ label: '不接受物流单', value: 3 }
]}
name='status'
required
x-component="Radio"
/>
<Field
title='不接受原因'
name="remark"
x-component="TextArea"
required
x-component-props={{
placeholder: '在此输入你的内容,最多60个汉字'
}}
x-mega-prop={{
labelAlign: 'left'
}}
x-rules={{
max: 60,
message: '原因最多60个汉字'
}}
/>
</SchemaForm>
</Modal>
)
}
export default BillSubmit
import React, { Fragment, useCallback, useEffect, useState } from 'react';
import { Button, } from 'antd';
import { Button, message } from 'antd';
import { history } from 'umi';
import { ColumnType } from 'antd/lib/table/interface';
import PeripheralLayout from '@/pages/transaction/components/detailLayout';
......@@ -13,6 +13,7 @@ import RecordLyout from '@/pages/transaction/components/detailLayout/components/
import FreightLayout from '@/pages/transaction/components/detailLayout/components/generalLayout'
import { CheckCircleOutlined } from '@ant-design/icons';
import FreightEdit from '../freightEdit';
import BillSubmit from '../billSubmit';
const TABLINK = [
{ id: 'progressLayout', title: '流转进度' },
......@@ -38,6 +39,7 @@ const LogisticsBillManageDetail = () => {
const [basicEffect, setBasicEffect] = useState<any>([]);
const [freightEffect, setFreightEffect] = useState<any>([]);
const [freightVisible, setFreightVisible] = useState<boolean>(false);
const [visible, setVisible] = useState<boolean>(false);
const handleBasicEffect = (data: any) => {
setBasicEffect([
......@@ -124,16 +126,16 @@ const LogisticsBillManageDetail = () => {
let { data } = res;
let externalLogs: any = [];
let externalLogStates: any = []
data.verifySteps.forEach((item: any) => {
data.externalList.forEach((item: any) => {
externalLogStates.push({
state: item.step,
stateName: null,
// isExecute: item.isExecute,
isExecute: item.isExecute,
operationalProcess: item.stepName,
roleName: item.roleName,
})
})
data.history.forEach((item: any) => {
data.logisticsOrderLogList.forEach((item: any) => {
externalLogs.push({
id: item.id,
roleName: item.operatorRoleName,
......@@ -161,10 +163,20 @@ const LogisticsBillManageDetail = () => {
params.taxInclusive = 1;
params.taxRate = value.taxRate;
params.freightPrice = value.freightPrice;
setDataSource(params)
handleFreightEffect(params);
setFreightVisible(false);
}
const handleSubmit = () => {
const { taxRate, freightPrice } = dataSource
if (!taxRate && !freightPrice) {
message.warning('请先编辑运费!')
return
}
setVisible(true);
}
return (
<Context.Provider value={dataSource}>
<PeripheralLayout
......@@ -177,6 +189,7 @@ const LogisticsBillManageDetail = () => {
&& (
<Button
type='primary'
onClick={handleSubmit}
>
<CheckCircleOutlined />
单据确认
......@@ -221,6 +234,11 @@ const LogisticsBillManageDetail = () => {
onClose={() => setFreightVisible(false)}
onConfirm={handleConfirm}
/>
<BillSubmit
dataSource={dataSource}
visible={visible}
onClose={() => setVisible(false)}
/>
</Context.Provider>
)
}
......
......@@ -118,16 +118,16 @@ const LogisticsBillSubmitDetail = () => {
let { data } = res;
let externalLogs: any = [];
let externalLogStates: any = []
data.verifySteps.forEach((item: any) => {
data.externalList.forEach((item: any) => {
externalLogStates.push({
state: item.step,
stateName: null,
// isExecute: item.isExecute,
isExecute: item.isExecute,
operationalProcess: item.stepName,
roleName: item.roleName,
})
})
data.history.forEach((item: any) => {
data.logisticsOrderLogList.forEach((item: any) => {
externalLogs.push({
id: item.id,
roleName: item.operatorRoleName,
......
......@@ -102,10 +102,7 @@ export const WAITSBUMITLOGISTICSBILLSCHEMA: ISchema = {
properties: {
ctl: {
type: "object",
"x-component": "Children",
"x-component-props": {
children: "{{controllerBtns}}"
}
"x-component": "controllerBtns",
},
logisticsOrderNo: {
type: "string",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment