Commit c55f1f96 authored by 前端-许佳敏's avatar 前端-许佳敏

fix: 接口id不需要带

parent 734d49ee
/*
* @Author: XieZhiXiong
* @Date: 2021-06-10 14:27:37
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-11-17 11:30:29
* @Description: 区域选择
*/
import React, { useState, useEffect } from 'react';
import { Row, Col } from 'antd';
import SelectItem from './SelectItem';
import { getMemberAreaCity, getMemberAreaDistrict, getMemberAreaProvince } from '@/services/MemberV2Api/id8983';
function isObj(value) {
return typeof value === 'object';
};
type AreaCodeType = {
/**
* 区域编码
*/
value: string
/**
* 区域名称
*/
label: string
}
const AreaSelect = (props) => {
const {
mutators,
editable,
} = props;
const value = isObj(props.value) ? props.value : {};
const XComponentProps = props.props['x-component-props'] || {};
const SelectProps = {
...XComponentProps,
disabled: !editable || XComponentProps.disabled,
};
const [provinceList, setProvinceList] = useState<AreaCodeType[]>([]);
const [cityList, setCityList] = useState<AreaCodeType[]>([]);
const [districtList, setDistrictList] = useState<AreaCodeType[]>([]);
const [provinceLoading, setProvinceLoading] = useState(false);
const [cityLoading, setCityLoading] = useState(false);
const [districtLoading, setDistrictLoading] = useState(false);
const [provinceValue, setProvinceValue] = useState('');
const [cityValue, setCityValue] = useState('');
const [districtValue, setDistrictValue] = useState('');
const getProvinceList = async () => {
setProvinceLoading(true);
const res = await getMemberAreaProvince();
if (res.code === 1000) {
setProvinceList(res.data?.map((item) => ({ label: item.name, value: item.code })));
}
setProvinceLoading(false);
};
const getCityList = async (code: string) => {
if (!code) {
return;
}
setCityLoading(true);
const res = await getMemberAreaCity({ code });
if (res.code === 1000) {
setCityList(res.data?.map((item) => ({ label: item.name, value: item.code })));
}
setCityLoading(false);
};
const getDistrictList = async (code: string) => {
if (!code) {
return;
}
setDistrictLoading(true);
const res = await getMemberAreaDistrict({ code });
if (res.code === 1000) {
setDistrictList(res.data?.map((item) => ({ label: item.name, value: item.code })));
}
setDistrictLoading(false);
};
useEffect(() => {
const {
provinceCode,
cityCode,
districtCode,
} = value;
setProvinceValue(provinceCode);
setCityValue(cityCode);
setDistrictValue(districtCode);
}, [value]);
useEffect(() => {
getProvinceList();
}, []);
useEffect(() => {
getCityList(provinceValue);
}, [provinceValue]);
useEffect(() => {
getDistrictList(cityValue);
}, [cityValue]);
const handleProvinceChange = (next: string) => {
setProvinceValue(next);
setCityValue(undefined);
setCityList([]);
setDistrictList([]);
setDistrictValue(undefined);
mutators.change({ ...value, provinceCode: next, cityCode: undefined, districtCode: undefined });
};
const handleCityChange = (next: string) => {
setCityValue(next);
setDistrictList([]);
setDistrictValue(undefined);
mutators.change({ ...value, cityCode: next, districtCode: undefined });
};
const handleDistrictChange = (next: string) => {
setDistrictValue(next);
mutators.change({ ...value, districtCode: next });
};
return (
<div
style={{
width: '100%',
}}
>
<Row gutter={16}>
<Col span={8}>
<SelectItem
placeholder="- 省 -"
allowClear
{...SelectProps}
value={provinceValue}
options={provinceList}
loading={provinceLoading}
onChange={handleProvinceChange}
/>
</Col>
<Col span={8}>
<SelectItem
placeholder="- 市 -"
allowClear
{...SelectProps}
value={cityValue}
options={cityList}
loading={cityLoading}
onChange={handleCityChange}
/>
</Col>
<Col span={8}>
<SelectItem
placeholder="- 县 / 区 -"
allowClear
{...SelectProps}
value={districtValue}
options={districtList}
loading={districtLoading}
onChange={handleDistrictChange}
/>
</Col>
</Row>
</div>
);
};
AreaSelect.isFieldComponent = true;
export default AreaSelect
/*
* @Author: XieZhiXiong
* @Date: 2021-06-10 14:27:37
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-11-17 11:30:29
* @Description: 区域选择
*/
import React, { useState, useEffect } from 'react';
import { Row, Col } from 'antd';
import SelectItem from './SelectItem';
import { getMemberAreaCity, getMemberAreaDistrict, getMemberAreaProvince } from '@/services/MemberV2Api';
function isObj(value) {
return typeof value === 'object';
};
type AreaCodeType = {
/**
* 区域编码
*/
value: string
/**
* 区域名称
*/
label: string
}
const AreaSelect = (props) => {
const {
mutators,
editable,
} = props;
const value = isObj(props.value) ? props.value : {};
const XComponentProps = props.props['x-component-props'] || {};
const SelectProps = {
...XComponentProps,
disabled: !editable || XComponentProps.disabled,
};
const [provinceList, setProvinceList] = useState<AreaCodeType[]>([]);
const [cityList, setCityList] = useState<AreaCodeType[]>([]);
const [districtList, setDistrictList] = useState<AreaCodeType[]>([]);
const [provinceLoading, setProvinceLoading] = useState(false);
const [cityLoading, setCityLoading] = useState(false);
const [districtLoading, setDistrictLoading] = useState(false);
const [provinceValue, setProvinceValue] = useState('');
const [cityValue, setCityValue] = useState('');
const [districtValue, setDistrictValue] = useState('');
const getProvinceList = async () => {
setProvinceLoading(true);
const res = await getMemberAreaProvince();
if (res.code === 1000) {
setProvinceList(res.data?.map((item) => ({ label: item.name, value: item.code })));
}
setProvinceLoading(false);
};
const getCityList = async (code: string) => {
if (!code) {
return;
}
setCityLoading(true);
const res = await getMemberAreaCity({ code });
if (res.code === 1000) {
setCityList(res.data?.map((item) => ({ label: item.name, value: item.code })));
}
setCityLoading(false);
};
const getDistrictList = async (code: string) => {
if (!code) {
return;
}
setDistrictLoading(true);
const res = await getMemberAreaDistrict({ code });
if (res.code === 1000) {
setDistrictList(res.data?.map((item) => ({ label: item.name, value: item.code })));
}
setDistrictLoading(false);
};
useEffect(() => {
const {
provinceCode,
cityCode,
districtCode,
} = value;
setProvinceValue(provinceCode);
setCityValue(cityCode);
setDistrictValue(districtCode);
}, [value]);
useEffect(() => {
getProvinceList();
}, []);
useEffect(() => {
getCityList(provinceValue);
}, [provinceValue]);
useEffect(() => {
getDistrictList(cityValue);
}, [cityValue]);
const handleProvinceChange = (next: string) => {
setProvinceValue(next);
setCityValue(undefined);
setCityList([]);
setDistrictList([]);
setDistrictValue(undefined);
mutators.change({ ...value, provinceCode: next, cityCode: undefined, districtCode: undefined });
};
const handleCityChange = (next: string) => {
setCityValue(next);
setDistrictList([]);
setDistrictValue(undefined);
mutators.change({ ...value, cityCode: next, districtCode: undefined });
};
const handleDistrictChange = (next: string) => {
setDistrictValue(next);
mutators.change({ ...value, districtCode: next });
};
return (
<div
style={{
width: '100%',
}}
>
<Row gutter={16}>
<Col span={8}>
<SelectItem
placeholder="- 省 -"
allowClear
{...SelectProps}
value={provinceValue}
options={provinceList}
loading={provinceLoading}
onChange={handleProvinceChange}
/>
</Col>
<Col span={8}>
<SelectItem
placeholder="- 市 -"
allowClear
{...SelectProps}
value={cityValue}
options={cityList}
loading={cityLoading}
onChange={handleCityChange}
/>
</Col>
<Col span={8}>
<SelectItem
placeholder="- 县 / 区 -"
allowClear
{...SelectProps}
value={districtValue}
options={districtList}
loading={districtLoading}
onChange={handleDistrictChange}
/>
</Col>
</Row>
</div>
);
};
AreaSelect.isFieldComponent = true;
export default AreaSelect
/*
* @Author: XieZhiXiong
* @Date: 2021-05-21 16:10:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-11-17 11:31:38
* @Description: 会员分类信息
*/
import React, { useState } from 'react';
import {
Descriptions,
Button,
message,
} from 'antd';
import CustomizeColumn, { IProps as CustomizeColumnProps } from '@/components/CustomizeColumn';
import ModifyClassifyDrawer, { ValueType, FormValueType, PartnerTypesItem } from '../ModifyClassifyDrawer';
import styles from './index.less';
import { getMemberAbilityMaintenanceDetailRecordClassify, postMemberAbilityMaintenanceDetailRecordClassifyUpdate } from '@/services/MemberV2Api/id9421';
export type DocCategoryProps = Omit<CustomizeColumnProps, 'data' | 'columns'> & {
/**
* 数据源
*/
dataSource: {
/**
* 会员编码
*/
code: string,
/**
* 合作关系名称
*/
partnerTypeName: string,
/**
* 单次合作金额
*/
maxAmount: string,
/**
* 适用区域
*/
classifyAreas: string[],
/**
* 主营品类
*/
categories: {
/**
* 数据id
*/
id: number,
/**
* 品类名称
*/
name: string,
/**
* 付款周期(天)
*/
paymentDay: number,
/**
* 发票类型名称
*/
invoiceTypeName: string,
/**
* 税点,百分比的分子部分
*/
taxPoint: string,
}[],
},
/**
* 审核id
*/
validateId?: string,
/**
* 修改渠道信息之后触发事件
*/
onModifyAfter?: () => void,
}
const MemberDocCategory: React.FC<DocCategoryProps> = (props: DocCategoryProps) => {
const {
dataSource,
validateId,
onModifyAfter,
...rest
} = props;
const [visibleDrawer, setVisibleDrawer] = useState(false);
const [classifyInfo, setClassifyInfo] = useState<FormValueType>();
const [partnerTypes, setPartnerTypes] = useState<PartnerTypesItem[]>([]);
const [infoLoading, setInfoLoading] = useState(false);
const [submitLoading, setSubmitLoading] = useState(false);
const handleVisibleDrawer = (flag?) => {
setVisibleDrawer(!!flag);
};
const handleModifyClassify = () => {
if (!validateId) {
return;
}
setInfoLoading(true);
getMemberAbilityMaintenanceDetailRecordClassify({
validateId,
}).then(res => {
if (res.code === 1000) {
setClassifyInfo({
code: res.data?.code,
partnerType: res.data?.partnerType,
maxAmount: res.data?.maxAmount,
areaCodes: res.data?.areaCodes,
categories: res.data?.categories.map(({ names, paymentDay, taxPoint, ...rest }) => ({
category: names,
paymentDay: `${paymentDay}`,
taxPoint: +taxPoint,
...rest
})),
});
setPartnerTypes(res.data?.partnerTypes.map((item) => ({
value: item.id,
label: item.text,
})));
handleVisibleDrawer(true);
}
}).catch((err) => {
console.warn(err);
}).finally(() => {
setInfoLoading(false);
});
};
const handleSubmit = (value: ValueType) => {
setSubmitLoading(true);
const payload = {
validateId: +validateId,
...value,
};
const msg = message.loading({
content: '正在提交,请稍候...',
duration: 0,
});
postMemberAbilityMaintenanceDetailRecordClassifyUpdate(payload, {
timeout: 0,
}).then(res => {
if (res.code !== 1000) {
return;
}
handleVisibleDrawer(false);
onModifyAfter?.();
}).catch((err) => {
console.warn(err);
}).finally(() => {
msg();
setSubmitLoading(false);
});
};
const data = [
{
title: '会员编号',
value: dataSource?.code || '',
},
{
title: '单次合作金额',
value: dataSource && dataSource.maxAmount ? ${dataSource.maxAmount}` : '',
},
{
title: '适用区域',
value: dataSource && dataSource.classifyAreas ? dataSource.classifyAreas.join(';') : '',
},
{
title: '会员关系',
value: dataSource?.partnerTypeName || '',
columnProps: {
span: 3,
},
},
{
title: '主营品类',
value: (
<ul className={styles['category-list']}>
{dataSource?.categories.map((item) => (
<li className={styles['category-list-item']} key={item.id}>
<Descriptions column={1}>
<Descriptions.Item label="品类">{item.name}</Descriptions.Item>
<Descriptions.Item label="付款周期(天)">{item.paymentDay}</Descriptions.Item>
<Descriptions.Item label="发票类型">{item.invoiceTypeName}</Descriptions.Item>
<Descriptions.Item label="税点">{item.taxPoint}%</Descriptions.Item>
</Descriptions>
</li>
))}
</ul>
),
columnProps: {
span: 3,
},
},
];
return (
<>
<CustomizeColumn
title="分类信息"
data={data}
{...rest}
extra={(
<>
{validateId && (
<Button
type="link"
loading={infoLoading}
onClick={handleModifyClassify}
>
修改
</Button>
)}
</>
)}
/>
<ModifyClassifyDrawer
visible={visibleDrawer}
onClose={() => handleVisibleDrawer(false)}
onSubmit={handleSubmit}
submitLoading={submitLoading}
partnerTypes={partnerTypes}
value={classifyInfo}
/>
</>
);
};
export default MemberDocCategory;
/*
* @Author: XieZhiXiong
* @Date: 2021-05-21 16:10:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-11-17 11:31:38
* @Description: 会员分类信息
*/
import React, { useState } from 'react';
import {
Descriptions,
Button,
message,
} from 'antd';
import CustomizeColumn, { IProps as CustomizeColumnProps } from '@/components/CustomizeColumn';
import ModifyClassifyDrawer, { ValueType, FormValueType, PartnerTypesItem } from '../ModifyClassifyDrawer';
import styles from './index.less';
import { getMemberAbilityMaintenanceDetailRecordClassify, postMemberAbilityMaintenanceDetailRecordClassifyUpdate } from '@/services/MemberV2Api';
export type DocCategoryProps = Omit<CustomizeColumnProps, 'data' | 'columns'> & {
/**
* 数据源
*/
dataSource: {
/**
* 会员编码
*/
code: string,
/**
* 合作关系名称
*/
partnerTypeName: string,
/**
* 单次合作金额
*/
maxAmount: string,
/**
* 适用区域
*/
classifyAreas: string[],
/**
* 主营品类
*/
categories: {
/**
* 数据id
*/
id: number,
/**
* 品类名称
*/
name: string,
/**
* 付款周期(天)
*/
paymentDay: number,
/**
* 发票类型名称
*/
invoiceTypeName: string,
/**
* 税点,百分比的分子部分
*/
taxPoint: string,
}[],
},
/**
* 审核id
*/
validateId?: string,
/**
* 修改渠道信息之后触发事件
*/
onModifyAfter?: () => void,
}
const MemberDocCategory: React.FC<DocCategoryProps> = (props: DocCategoryProps) => {
const {
dataSource,
validateId,
onModifyAfter,
...rest
} = props;
const [visibleDrawer, setVisibleDrawer] = useState(false);
const [classifyInfo, setClassifyInfo] = useState<FormValueType>();
const [partnerTypes, setPartnerTypes] = useState<PartnerTypesItem[]>([]);
const [infoLoading, setInfoLoading] = useState(false);
const [submitLoading, setSubmitLoading] = useState(false);
const handleVisibleDrawer = (flag?) => {
setVisibleDrawer(!!flag);
};
const handleModifyClassify = () => {
if (!validateId) {
return;
}
setInfoLoading(true);
getMemberAbilityMaintenanceDetailRecordClassify({
validateId,
}).then(res => {
if (res.code === 1000) {
setClassifyInfo({
code: res.data?.code,
partnerType: res.data?.partnerType,
maxAmount: res.data?.maxAmount,
areaCodes: res.data?.areaCodes,
categories: res.data?.categories.map(({ names, paymentDay, taxPoint, ...rest }) => ({
category: names,
paymentDay: `${paymentDay}`,
taxPoint: +taxPoint,
...rest
})),
});
setPartnerTypes(res.data?.partnerTypes.map((item) => ({
value: item.id,
label: item.text,
})));
handleVisibleDrawer(true);
}
}).catch((err) => {
console.warn(err);
}).finally(() => {
setInfoLoading(false);
});
};
const handleSubmit = (value: ValueType) => {
setSubmitLoading(true);
const payload = {
validateId: +validateId,
...value,
};
const msg = message.loading({
content: '正在提交,请稍候...',
duration: 0,
});
postMemberAbilityMaintenanceDetailRecordClassifyUpdate(payload, {
timeout: 0,
}).then(res => {
if (res.code !== 1000) {
return;
}
handleVisibleDrawer(false);
onModifyAfter?.();
}).catch((err) => {
console.warn(err);
}).finally(() => {
msg();
setSubmitLoading(false);
});
};
const data = [
{
title: '会员编号',
value: dataSource?.code || '',
},
{
title: '单次合作金额',
value: dataSource && dataSource.maxAmount ? ${dataSource.maxAmount}` : '',
},
{
title: '适用区域',
value: dataSource && dataSource.classifyAreas ? dataSource.classifyAreas.join(';') : '',
},
{
title: '会员关系',
value: dataSource?.partnerTypeName || '',
columnProps: {
span: 3,
},
},
{
title: '主营品类',
value: (
<ul className={styles['category-list']}>
{dataSource?.categories.map((item) => (
<li className={styles['category-list-item']} key={item.id}>
<Descriptions column={1}>
<Descriptions.Item label="品类">{item.name}</Descriptions.Item>
<Descriptions.Item label="付款周期(天)">{item.paymentDay}</Descriptions.Item>
<Descriptions.Item label="发票类型">{item.invoiceTypeName}</Descriptions.Item>
<Descriptions.Item label="税点">{item.taxPoint}%</Descriptions.Item>
</Descriptions>
</li>
))}
</ul>
),
columnProps: {
span: 3,
},
},
];
return (
<>
<CustomizeColumn
title="分类信息"
data={data}
{...rest}
extra={(
<>
{validateId && (
<Button
type="link"
loading={infoLoading}
onClick={handleModifyClassify}
>
修改
</Button>
)}
</>
)}
/>
<ModifyClassifyDrawer
visible={visibleDrawer}
onClose={() => handleVisibleDrawer(false)}
onSubmit={handleSubmit}
submitLoading={submitLoading}
partnerTypes={partnerTypes}
value={classifyInfo}
/>
</>
);
};
export default MemberDocCategory;
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