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

fix: 修改门店管理新增

parent 90240028
......@@ -16,18 +16,14 @@ interface AreaSelectProps {
* 选择触发改变
*/
onChange?: (value: AreaSelectValueType[]) => void,
/**
* 到街道默认为 3
* TODO: 因为澳门只有到市
*/
MAX: number
}
const MAX = 3; // 到街道
const AreaSelect: React.FC<AreaSelectProps> = (props) => {
const {
value,
onChange,
MAX = 3
} = props;
const [innerValues, setInnerValues] = useState<AreaSelectValueType[]>([]);
......@@ -43,6 +39,15 @@ const AreaSelect: React.FC<AreaSelectProps> = (props) => {
}
};
const handleResetChang = (newInnerValues: AreaSelectValueType[], index: number) => {
let i = index + 1;
while (i < newInnerValues.length) {
newInnerValues[i] = undefined;
i++;
}
newInnerValues = newInnerValues.filter(Boolean);
}
const handleSelectChange = (value: AreaSelectValueType, index: number) => {
let newInnerValues = [...innerValues];
......@@ -50,13 +55,11 @@ const AreaSelect: React.FC<AreaSelectProps> = (props) => {
// 如果是清空操作,则把当前层级之后的 选项 及 值 也清空
if (!value) {
let i = index + 1;
while (i < newInnerValues.length) {
newInnerValues[i] = undefined;
i++;
}
newInnerValues = newInnerValues.filter(Boolean);
handleResetChang(newInnerValues, index)
triggerChange([]);
} else {
handleResetChang(newInnerValues, index)
setInnerValues(newInnerValues);
}
// 全部选择了才触发 onChange
......
......@@ -14,7 +14,7 @@ export default {
'portalSystem.shi': '是',
'portalSystem.fou': '否',
'portalSystem.chaxun': '查询',
'portalSystem.menhuguanlixiangqing': '门管理详情',
'portalSystem.menhuguanlixiangqing': '门管理详情',
'portalSystem.jibenxinxi': '基本信息',
'portalSystem.mendianLOGO': '门店LOGO',
'portalSystem.lianxixinxi': '联系信息',
......@@ -29,9 +29,9 @@ export default {
'portalSystem.bianjimendian': '编辑门店',
'portalSystem.xinzengmendian': '新增门店',
'portalSystem.baocun': '保存',
'portalSystem.menhudaima': '门代码',
'portalSystem.menhudaima': '门代码',
'portalSystem.qingshuru': '请输入',
'portalSystem.qingshurumenhudaima': '请输入门代码',
'portalSystem.qingshurumenhudaima': '请输入门代码',
'portalSystem.qingshumendianmingcheng': '请输门店名称',
'portalSystem.qingxuanzeshengshiqu': '请选择省/市/区',
'portalSystem.qingtianxiexiangxidizhi': '请填写详细地址,路名、门牌号等',
......
......@@ -190,7 +190,7 @@ const PortalSystemAdded = (props) => {
</Form>
}
/>
<Prompt when={unsaved} message="{intl.formatMessage({id: 'dealAbility.ninhaiyouweibaocundenei'})}" />
<Prompt when={unsaved} message={intl.formatMessage({id: 'dealAbility.ninhaiyouweibaocundenei'})} />
</Context.Provider>
)
}
......
import React, { Fragment, useContext, useEffect, useMemo, useState } from 'react';
import CardLayout from '@/pages/transaction/components/card'
import { Button, Col, Radio, Row, Drawer, Empty } from 'antd';
import { Button, Col, Radio, Row, Drawer, Empty, Modal } from 'antd';
import style from './index.less';
import { DeleteOutlined, EditOutlined } from '@ant-design/icons';
import { DeleteOutlined, EditOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
import { DELIVERY_SCHEMA } from './schema/delivery';
import { DISPATCH_SCHEMA } from './schema/dispatch';
import NiceForm from '@/components/NiceForm';
......@@ -110,6 +110,7 @@ const AddressLayout: React.FC<addressProps> = (props: addressProps) => {
}
const area = (areaSelect) => {
const [province, city, district, street] = areaSelect;
let newObj: addressInfo = {};
......@@ -139,10 +140,26 @@ const AddressLayout: React.FC<addressProps> = (props: addressProps) => {
onChange(params, type)
}
const handleColse = () => {
if (unsaved) {
Modal.confirm({
title: '提示',
icon: <ExclamationCircleOutlined />,
content: '您还有未保存的内容,是否确定要离开?',
onOk() {
setVisible(false);
setUnsaved(false)
},
});
} else {
setVisible(false)
}
}
const renderFooter = () => {
return (
<div style={{ textAlign: 'right' }}>
<Button style={{ marginRight: 8 }}>
<Button style={{ marginRight: 8 }} onClick={() => handleColse()}>
取消
</Button>
<Button type="primary" onClick={() => addressSchemaAction.submit()}>
......@@ -252,7 +269,7 @@ const AddressLayout: React.FC<addressProps> = (props: addressProps) => {
width={600}
destroyOnClose
closable
onClose={() => setVisible(false)}
onClose={() => handleColse()}
footer={renderFooter()}
>
<NiceForm
......
......@@ -32,10 +32,10 @@ const BasicLayout: React.FC<BasicProps> = (props: BasicProps) => {
<Row gutter={[48, 24]}>
<Col span={12}>
<Form.Item
label={intl.formatMessage({ id: 'portalSystem.menhudaima', defaultMessage: '门代码' })}
label={intl.formatMessage({ id: 'portalSystem.menhudaima', defaultMessage: '门代码' })}
name='code'
rules={[
{ required: true, message: intl.formatMessage({ id: 'portalSystem.qingshurumenhudaima', defaultMessage: '请输入门代码' }) },
{ required: true, message: intl.formatMessage({ id: 'portalSystem.qingshurumenhudaima', defaultMessage: '请输入门代码' }) },
{ validator: (rule, value, callback) => validatorByte(rule, value, callback, 12) }
]}>
<Input placeholder={intl.formatMessage({ id: 'portalSystem.qingshuru', defaultMessage: '请输入' })} />
......
......@@ -25,7 +25,7 @@ export const DELIVERY_SCHEMA: ISchema = {
},
{
limitByte: true,
maxByte: 20
maxByte: 40
}
]
},
......
......@@ -26,7 +26,7 @@ export const DISPATCH_SCHEMA: ISchema = {
},
{
limitByte: true,
maxByte: 20
maxByte: 40
}
]
},
......
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