Commit 67a29bb2 authored by GuanHua's avatar GuanHua

merge: 冲突解决

parents 3f2cfa8a a0f0bdd9
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: XieZhiXiong * @Author: XieZhiXiong
* @Date: 2021-08-05 10:28:06 * @Date: 2021-08-05 10:28:06
* @LastEditors: XieZhiXiong * @LastEditors: XieZhiXiong
* @LastEditTime: 2021-11-18 11:14:29 * @LastEditTime: 2021-12-02 10:23:36
* @Description: 地址选择 FormItem * @Description: 地址选择 FormItem
*/ */
import React, { useState, useEffect, useMemo, useRef } from 'react'; import React, { useState, useEffect, useMemo, useRef } from 'react';
...@@ -11,6 +11,7 @@ import { ...@@ -11,6 +11,7 @@ import {
createFormActions, createFormActions,
FormEffectHooks, FormEffectHooks,
FormPath, FormPath,
useValueLinkageEffect,
} from '@formily/antd'; } from '@formily/antd';
import { IRequestSuccess } from '@/index'; import { IRequestSuccess } from '@/index';
import { import {
...@@ -25,8 +26,7 @@ import { ...@@ -25,8 +26,7 @@ import {
postLogisticsShipperAddressAdd, postLogisticsShipperAddressAdd,
postLogisticsShipperAddressUpdate, postLogisticsShipperAddressUpdate,
} from '@/services/LogisticsV2Api'; } from '@/services/LogisticsV2Api';
import { getManageCountryAreaGetTelCode, getManageAreaAll } from '@/services/ManageV2Api'; import { getManageCountryAreaGetTelCode, getManageAreaByPcode } from '@/services/ManageV2Api';
import { useLinkEnumEffect } from '@/components/NiceForm/linkages/linkEnum';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect'; import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import NiceForm from '@/components/NiceForm'; import NiceForm from '@/components/NiceForm';
import { createSchema } from './schema'; import { createSchema } from './schema';
...@@ -41,6 +41,55 @@ const { ...@@ -41,6 +41,55 @@ const {
onFormInit$, onFormInit$,
} = FormEffectHooks; } = FormEffectHooks;
const useFetchAreaEnumLinkageEffect = () => {
useValueLinkageEffect({
type: 'value:areaEnum',
resolve: async ({ origin, target }, { getFieldValue, setFieldState }) => {
const parentValue = getFieldValue(origin);
if (!parentValue) {
setFieldState(target, innerState => {
FormPath.setIn(innerState, 'value', undefined);
FormPath.setIn(innerState, 'props.enum', []);
});
return;
}
// loading start
setFieldState(
target,
innerState => {
FormPath.setIn(innerState, 'props.x-props.hasFeedback', true);
FormPath.setIn(innerState, 'loading', true);
},
);
const res = await getManageAreaByPcode({
pcode: parentValue,
});
if (res.code === 1000) {
setFieldState(target, innerState => {
FormPath.setIn(innerState, 'originData', res.data);
FormPath.setIn(innerState, 'props.enum', res.data.map((item) => ({
label: item.name,
value: item.code,
})));
});
}
// loading end
setFieldState(
target,
innerState => {
FormPath.setIn(innerState, 'loading', false);
},
);
},
reject: ({ target }, { setFieldState }) => {
setFieldState(target, innerState => {
FormPath.setIn(innerState, 'value', undefined);
FormPath.setIn(innerState, 'props.enum', []);
});
}
})
};
interface IProps { interface IProps {
/** /**
* 类型:1 收货地址 2 发货地址,默认 2 * 类型:1 收货地址 2 发货地址,默认 2
...@@ -98,6 +147,10 @@ export type SubmitValuesType = { ...@@ -98,6 +147,10 @@ export type SubmitValuesType = {
*/ */
districtCode: string, districtCode: string,
/** /**
* 街道code
*/
streetCode?: string,
/**
* 详细地址 * 详细地址
*/ */
detailed: string, detailed: string,
...@@ -237,19 +290,46 @@ const AddressSelect: React.FC<IProps> = (props) => { ...@@ -237,19 +290,46 @@ const AddressSelect: React.FC<IProps> = (props) => {
// 有值表示是新增 或 修改操作 // 有值表示是新增 或 修改操作
if (values.name) { if (values.name) {
const originData = formActions.getFieldState('provinceCode', (fieldState) => { const provinceCodeOriginData = formActions.getFieldState('provinceCode', (fieldState) => {
return fieldState.originData; return fieldState.originData;
}); });
if (!originData) { if (!provinceCodeOriginData) {
message.warn('未找到地区信息'); message.warn('未找到省级信息');
return; return;
} }
const currentProvince = originData.find((item) => item.code === values.provinceCode); const currentProvince = provinceCodeOriginData.find((item) => item.code === values.provinceCode);
const currentCity = currentProvince?.areaResponses?.find((item) => item.code === values.cityCode);
const currentDistrict = currentCity?.areaResponses?.find((item) => item.code === values.districtCode); const cityCodeOriginData = formActions.getFieldState('cityCode', (fieldState) => {
return fieldState.originData;
});
if (!cityCodeOriginData) {
message.warn('未找到市级信息');
return;
}
const currentCity = cityCodeOriginData.find((item) => item.code === values.cityCode);
const districtCodeOriginData = formActions.getFieldState('districtCode', (fieldState) => {
return fieldState.originData;
});
if (!districtCodeOriginData) {
message.warn('未找到区级信息');
return;
}
const currentDistrict = districtCodeOriginData.find((item) => item.code === values.districtCode);
const streetCodeOriginData = formActions.getFieldState('streetCode', (fieldState) => {
return fieldState.originData;
});
if (!streetCodeOriginData) {
message.warn('未找到街道信息');
return;
}
const currentStreet = streetCodeOriginData.find((item) => item.code === values.streetCode);
const provinceName = currentProvince?.name; const provinceName = currentProvince?.name;
const cityName = currentCity?.name; const cityName = currentCity?.name;
const districtName = currentDistrict?.name; const districtName = currentDistrict?.name;
const streetName = currentStreet?.name;
const { name, detailed, isDefault, ...rest } = values; const { name, detailed, isDefault, ...rest } = values;
const commonPayload = { const commonPayload = {
...@@ -258,6 +338,7 @@ const AddressSelect: React.FC<IProps> = (props) => { ...@@ -258,6 +338,7 @@ const AddressSelect: React.FC<IProps> = (props) => {
provinceName, provinceName,
cityName, cityName,
districtName, districtName,
streetName,
address: detailed, address: detailed,
isDefault: isDefault ? 1 : 0, isDefault: isDefault ? 1 : 0,
}; };
...@@ -301,6 +382,7 @@ const AddressSelect: React.FC<IProps> = (props) => { ...@@ -301,6 +382,7 @@ const AddressSelect: React.FC<IProps> = (props) => {
flag: true, flag: true,
}; };
}); });
handleVisibleDrawer(false);
} }
setSubmitLoading(false); setSubmitLoading(false);
} catch (error) { } catch (error) {
...@@ -349,6 +431,7 @@ const AddressSelect: React.FC<IProps> = (props) => { ...@@ -349,6 +431,7 @@ const AddressSelect: React.FC<IProps> = (props) => {
flag: true, flag: true,
}; };
}); });
handleVisibleDrawer(false);
} }
setSubmitLoading(false); setSubmitLoading(false);
} catch (error) { } catch (error) {
...@@ -360,7 +443,6 @@ const AddressSelect: React.FC<IProps> = (props) => { ...@@ -360,7 +443,6 @@ const AddressSelect: React.FC<IProps> = (props) => {
setInternalValue(next); setInternalValue(next);
} }
triggerChange(next); triggerChange(next);
handleVisibleDrawer(false);
}; };
const useFields = (): any => ( const useFields = (): any => (
...@@ -395,14 +477,14 @@ const AddressSelect: React.FC<IProps> = (props) => { ...@@ -395,14 +477,14 @@ const AddressSelect: React.FC<IProps> = (props) => {
FormPath.setIn(targetState, 'props.x-props.hasFeedback', true); FormPath.setIn(targetState, 'props.x-props.hasFeedback', true);
FormPath.setIn(targetState, 'loading', true); FormPath.setIn(targetState, 'loading', true);
}); });
const areaRes = await getManageAreaAll(); const areaRes = await getManageAreaByPcode();
formActions.setFieldState('provinceCode', targetState => { formActions.setFieldState('provinceCode', targetState => {
FormPath.setIn(targetState, 'loading', false); FormPath.setIn(targetState, 'loading', false);
}); });
if (areaRes.code !== 1000) { if (areaRes.code !== 1000) {
message.warn('获取地区信息失败'); message.warn('获取省级信息失败');
return; return;
} }
const { data } = areaRes; const { data } = areaRes;
...@@ -436,14 +518,14 @@ const AddressSelect: React.FC<IProps> = (props) => { ...@@ -436,14 +518,14 @@ const AddressSelect: React.FC<IProps> = (props) => {
FormPath.setIn(targetState, 'props.x-props.hasFeedback', true); FormPath.setIn(targetState, 'props.x-props.hasFeedback', true);
FormPath.setIn(targetState, 'loading', true); FormPath.setIn(targetState, 'loading', true);
}); });
const areaRes = await getManageAreaAll(); const areaRes = await getManageAreaByPcode();
formActions.setFieldState('provinceCode', targetState => { formActions.setFieldState('provinceCode', targetState => {
FormPath.setIn(targetState, 'loading', false); FormPath.setIn(targetState, 'loading', false);
}); });
if (areaRes.code !== 1000) { if (areaRes.code !== 1000) {
message.warn('获取地区信息失败'); message.warn('获取省级信息失败');
return; return;
} }
const { data } = areaRes; const { data } = areaRes;
...@@ -457,15 +539,10 @@ const AddressSelect: React.FC<IProps> = (props) => { ...@@ -457,15 +539,10 @@ const AddressSelect: React.FC<IProps> = (props) => {
const res = addressType === 2 ? await getLogisticsShipperAddressGet({ id: `${id}` }) : await getLogisticsReceiverAddressGet({ id: `${id}` }); const res = addressType === 2 ? await getLogisticsShipperAddressGet({ id: `${id}` }) : await getLogisticsReceiverAddressGet({ id: `${id}` });
if (res.code === 1000) { if (res.code === 1000) {
formActions.setFieldValue('name', addressType === 2 ? (res.data as GetLogisticsShipperAddressGetResponse).shipperName : (res.data as GetLogisticsReceiverAddressGetResponse).receiverName); formActions.setFieldValue('name', addressType === 2 ? (res.data as GetLogisticsShipperAddressGetResponse).shipperName : (res.data as GetLogisticsReceiverAddressGetResponse).receiverName);
formActions.setFieldValue('provinceCode', res.data.provinceCode, true); formActions.setFieldValue('provinceCode', res.data.provinceCode);
// ??? formActions.setFieldValue('cityCode', res.data.cityCode);
formActions.setFieldState('provinceCode', (fieldState) => fieldState.modified = false); formActions.setFieldValue('districtCode', res.data.districtCode);
formActions.setFieldValue('cityCode', res.data.cityCode, true); formActions.setFieldValue('streetCode', res.data.streetCode);
// ???
formActions.setFieldState('cityCode', (fieldState) => fieldState.modified = false);
formActions.setFieldValue('districtCode', res.data.districtCode, true);
// ???
formActions.setFieldState('districtCode', (fieldState) => fieldState.modified = false);
formActions.setFieldValue('detailed', res.data.address); formActions.setFieldValue('detailed', res.data.address);
formActions.setFieldValue('postalCode', res.data.postalCode); formActions.setFieldValue('postalCode', res.data.postalCode);
formActions.setFieldValue('areaCode', res.data.areaCode); formActions.setFieldValue('areaCode', res.data.areaCode);
...@@ -596,13 +673,14 @@ const AddressSelect: React.FC<IProps> = (props) => { ...@@ -596,13 +673,14 @@ const AddressSelect: React.FC<IProps> = (props) => {
}); });
}); });
useLinkEnumEffect('areaResponses', result => // useLinkEnumEffect('areaResponses', result =>
result.map(v => ({ // result.map(v => ({
label: v.name, // label: v.name,
value: v.code, // value: v.code,
})), // })),
'code' // 'code'
); // );
useFetchAreaEnumLinkageEffect();
useAsyncSelect('areaCode', fetchTelCode); useAsyncSelect('areaCode', fetchTelCode);
}} }}
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: XieZhiXiong * @Author: XieZhiXiong
* @Date: 2021-08-05 14:02:46 * @Date: 2021-08-05 14:02:46
* @LastEditors: XieZhiXiong * @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-11 18:07:18 * @LastEditTime: 2021-12-02 10:24:50
* @Description: * @Description:
*/ */
import { ISchema } from '@formily/antd'; import { ISchema } from '@formily/antd';
...@@ -104,7 +104,7 @@ export const createSchema = (addressType = 2): ISchema => { ...@@ -104,7 +104,7 @@ export const createSchema = (addressType = 2): ISchema => {
grid: true, grid: true,
full: true, full: true,
autoRow: true, autoRow: true,
columns: 3, columns: 4,
}, },
properties: { properties: {
provinceCode: { provinceCode: {
...@@ -112,11 +112,12 @@ export const createSchema = (addressType = 2): ISchema => { ...@@ -112,11 +112,12 @@ export const createSchema = (addressType = 2): ISchema => {
enum: [], enum: [],
'x-component-props': { 'x-component-props': {
placeholder: '-省份/直辖市-', placeholder: '-省份/直辖市-',
allowClear: true,
}, },
'x-linkages': [ 'x-linkages': [
{ {
type: 'value:linkage', type: 'value:areaEnum',
condition: '{{ !!$self.value }}', // $self.value 不生效不知道咋滴 condition: '{{ !!$value }}', // $self.value 不生效不知道咋滴
origin: 'provinceCode', origin: 'provinceCode',
target: 'cityCode', target: 'cityCode',
}, },
...@@ -128,11 +129,12 @@ export const createSchema = (addressType = 2): ISchema => { ...@@ -128,11 +129,12 @@ export const createSchema = (addressType = 2): ISchema => {
enum: [], enum: [],
'x-component-props': { 'x-component-props': {
placeholder: '-市-', placeholder: '-市-',
allowClear: true,
}, },
'x-linkages': [ 'x-linkages': [
{ {
type: 'value:linkage', type: 'value:areaEnum',
condition: '{{ !!$self.value }}', // $self.value 不生效不知道咋滴 condition: '{{ !!$value }}', // $self.value 不生效不知道咋滴
origin: 'cityCode', origin: 'cityCode',
target: 'districtCode', target: 'districtCode',
}, },
...@@ -144,9 +146,27 @@ export const createSchema = (addressType = 2): ISchema => { ...@@ -144,9 +146,27 @@ export const createSchema = (addressType = 2): ISchema => {
enum: [], enum: [],
'x-component-props': { 'x-component-props': {
placeholder: '-区-', placeholder: '-区-',
allowClear: true,
}, },
'x-linkages': [
{
type: 'value:areaEnum',
condition: '{{ !!$value }}', // $self.value 不生效不知道咋滴
origin: 'districtCode',
target: 'streetCode',
},
],
required: true, required: true,
}, },
streetCode: {
type: 'string',
enum: [],
'x-component-props': {
placeholder: '-街道-',
allowClear: true,
},
required: false,
},
}, },
}, },
}, },
...@@ -244,6 +264,22 @@ export const createSchema = (addressType = 2): ISchema => { ...@@ -244,6 +264,22 @@ export const createSchema = (addressType = 2): ISchema => {
title: '是否默认', title: '是否默认',
'x-component': 'Switch', 'x-component': 'Switch',
}, },
provinceName: {
type: 'string',
display: false,
},
cityName: {
type: 'string',
display: false,
},
districtName: {
type: 'string',
display: false,
},
streetName: {
type: 'string',
display: false,
},
}, },
}, },
}, },
......
...@@ -66,6 +66,9 @@ ...@@ -66,6 +66,9 @@
'common.text.unit.piece': '件', 'common.text.unit.piece': '件',
'common.text.pleaseSelect': '请选择', 'common.text.pleaseSelect': '请选择',
'common.text.notEmpty': '不可为空', 'common.text.notEmpty': '不可为空',
'common.text.image': '图片',
'common.text.title': '标题',
'common.text.all': '全部',
'common.text.canuse': '元使用', 'common.text.canuse': '元使用',
/** form */ /** form */
...@@ -80,5 +83,7 @@ ...@@ -80,5 +83,7 @@
'common.form.activity.endTime.placeholder': '活动结束时间', 'common.form.activity.endTime.placeholder': '活动结束时间',
'common.form.input.placeholder': '请输入', 'common.form.input.placeholder': '请输入',
'common.form.rule.only.number': '只允许填写数字', 'common.form.rule.only.number': '只允许填写数字',
'common.form.upload.placeholder': '请上传',
} }
...@@ -34,4 +34,24 @@ ...@@ -34,4 +34,24 @@
'content.info.time': '发布时间', 'content.info.time': '发布时间',
'content.info.recommendTag': '推荐标签', 'content.info.recommendTag': '推荐标签',
'content.info.sort': '排序', 'content.info.sort': '排序',
'content.info.add': '新建资讯',
'content.info.edit': '编辑资讯',
'content.info.see': '查看资讯',
'content.info.label1': '头条文章',
'content.info.label2': '轮播新闻',
'content.info.label3': '图片新闻',
'content.info.label4': '推荐阅读',
'content.info.label5': '行情推荐',
'content.info.label6': '本栏推荐',
'content.info.recommendSort': '排序',
'content.info.views': '浏览数',
'content.info.tag': '资讯标签',
'content.info.abstract': '摘要',
'content.info.content': '内容',
'content.notice.add': '新建公告',
'content.notice.edit': '编辑公告',
'content.notice.see': '查看公告',
'content.notice.topping': '置顶',
} }
...@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'; ...@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
import { PageHeaderWrapper } from "@ant-design/pro-layout"; import { PageHeaderWrapper } from "@ant-design/pro-layout";
import ReutrnEle from '@/components/ReturnEle'; import ReutrnEle from '@/components/ReturnEle';
import { usePageStatus } from '@/hooks/usePageStatus'; import { usePageStatus } from '@/hooks/usePageStatus';
import { history, Prompt } from 'umi'; import { history, Prompt, useIntl } from 'umi';
import { Card, Button } from 'antd'; import { Card, Button } from 'antd';
import { SchemaForm, createFormActions, FormButtonGroup, Submit } from '@formily/antd' import { SchemaForm, createFormActions, FormButtonGroup, Submit } from '@formily/antd'
import announceInfoSchema from './schema/announceInfoSchema'; import announceInfoSchema from './schema/announceInfoSchema';
...@@ -20,6 +20,7 @@ import { getManageMemberNoticeGet, postManageMemberNoticeAdd, postManageMemberNo ...@@ -20,6 +20,7 @@ import { getManageMemberNoticeGet, postManageMemberNoticeAdd, postManageMemberNo
const actions = createFormActions(); const actions = createFormActions();
const AdvertisementInfo = () => { const AdvertisementInfo = () => {
const intl = useIntl()
useCustomValidator(); useCustomValidator();
const { id, preview } = usePageStatus(); const { id, preview } = usePageStatus();
const initialValues: any = useInitialValues({id:id}, getManageMemberNoticeGet); const initialValues: any = useInitialValues({id:id}, getManageMemberNoticeGet);
...@@ -43,7 +44,6 @@ const AdvertisementInfo = () => { ...@@ -43,7 +44,6 @@ const AdvertisementInfo = () => {
console.log(value) console.log(value)
const {content, top, ...rest} = value; const {content, top, ...rest} = value;
const editorContent = content.toHTML(); const editorContent = content.toHTML();
// const { title, columnType, sort, link, imageUrl} = value;
const serviceActions = isAdd const serviceActions = isAdd
? postManageMemberNoticeAdd ? postManageMemberNoticeAdd
: postManageMemberNoticeUpdate : postManageMemberNoticeUpdate
...@@ -67,8 +67,8 @@ const AdvertisementInfo = () => { ...@@ -67,8 +67,8 @@ const AdvertisementInfo = () => {
return ( return (
<PageHeaderWrapper <PageHeaderWrapper
onBack={() => history.goBack()} onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回" />} backIcon={<ReutrnEle description={intl.formatMessage({ id: 'common.button.back' })} />}
title={isAdd ? '新建公告' : isEdit ? '编辑公告' : '查看公告'} title={isAdd ? intl.formatMessage({ id: 'content.notice.add' }) : isEdit ? intl.formatMessage({ id: 'content.notice.edit' }) : intl.formatMessage({ id: 'content.notice.see' })}
> >
<Card> <Card>
<SchemaForm <SchemaForm
...@@ -82,7 +82,7 @@ const AdvertisementInfo = () => { ...@@ -82,7 +82,7 @@ const AdvertisementInfo = () => {
editable={isAdd || isEdit} editable={isAdd || isEdit}
expressionScope={{ expressionScope={{
label: ( label: (
<div className={styles.custom_label}>栏目</div> <div className={styles.custom_label}>{intl.formatMessage({ id: 'content.info.column' })}</div>
) )
}} }}
> >
...@@ -90,14 +90,14 @@ const AdvertisementInfo = () => { ...@@ -90,14 +90,14 @@ const AdvertisementInfo = () => {
isAdd || isEdit isAdd || isEdit
? ( ? (
<FormButtonGroup offset={3}> <FormButtonGroup offset={3}>
<Submit loading={submitLoading}>提交</Submit> <Submit loading={submitLoading}>{intl.formatMessage({ id: 'common.button.submit' })}</Submit>
<Button onClick={handleCancel}>取消</Button> <Button onClick={handleCancel}>{intl.formatMessage({ id: 'common.button.cancel' })}</Button>
</FormButtonGroup> </FormButtonGroup>
) )
: <></> : <></>
} }
</SchemaForm> </SchemaForm>
<Prompt when={unsaved && (isAdd || isEdit)} message="您还有未保存的内容,是否确定要离开?"></Prompt> <Prompt when={unsaved && (isAdd || isEdit)} message={intl.formatMessage({ id: 'common.tip.save.confirm' })}></Prompt>
</Card> </Card>
</PageHeaderWrapper> </PageHeaderWrapper>
) )
......
This diff is collapsed.
import { ANNOUNCE_COLUMN_TYPE, transfer2Options } from '../../utils/utils'; import { ANNOUNCE_COLUMN_TYPE, transfer2Options } from '../../utils/utils';
import { getIntl } from 'umi';
const columnsList = transfer2Options(ANNOUNCE_COLUMN_TYPE); const columnsList = transfer2Options(ANNOUNCE_COLUMN_TYPE);
const schema = { const schema = {
...@@ -15,15 +17,15 @@ const schema = { ...@@ -15,15 +17,15 @@ const schema = {
properties: { properties: {
title: { title: {
type: 'string', type: 'string',
title: '标题', title: getIntl().formatMessage({ id: 'common.text.title' }),
'x-component': 'Input', 'x-component': 'Input',
'x-component-props': { 'x-component-props': {
placeholder: '最长60个字符,30个汉字' placeholder: `30${getIntl().formatMessage({ id: 'common.unit.individual.chinese' })}, 60${getIntl().formatMessage({ id: 'common.unit.individual.character' })}`,
}, },
"x-rules": [ "x-rules": [
{ {
"required": true, "required": true,
"message": "最长60个字符,30个汉字" "message": `30${getIntl().formatMessage({ id: 'common.unit.individual.chinese' })}, 60${getIntl().formatMessage({ id: 'common.unit.individual.character' })}`,
}, },
{ {
limitByte: true, // 自定义校验规则 limitByte: true, // 自定义校验规则
...@@ -63,7 +65,7 @@ const schema = { ...@@ -63,7 +65,7 @@ const schema = {
}, },
"x-rules": [{ "x-rules": [{
"required": true, "required": true,
"message": "请选择栏目" "message": `${getIntl().formatMessage({ id: 'common.text.pleaseSelect' })}${getIntl().formatMessage({ id: 'content.info.column' })}`,
}], }],
}, },
top: { top: {
...@@ -74,7 +76,7 @@ const schema = { ...@@ -74,7 +76,7 @@ const schema = {
span: 1 span: 1
}, },
'x-component-props': { 'x-component-props': {
children: '置顶', children: getIntl().formatMessage({ id: 'content.notice.topping' }),
} }
} }
} }
...@@ -91,7 +93,7 @@ const schema = { ...@@ -91,7 +93,7 @@ const schema = {
content: { content: {
type: "string", type: "string",
name: 'content', name: 'content',
title: '内容', title: getIntl().formatMessage({ id: 'content.info.content' }),
"x-component": 'CustomEditor', "x-component": 'CustomEditor',
"x-component-parent-props": { "x-component-parent-props": {
style: { style: {
...@@ -100,7 +102,7 @@ const schema = { ...@@ -100,7 +102,7 @@ const schema = {
}, },
"x-rules": { "x-rules": {
"required": true, "required": true,
"message": "请输入内容" "message": `${getIntl().formatMessage({ id: 'common.form.input.placeholder' })}${getIntl().formatMessage({ id: 'content.info.content' })}`,
}, },
"x-component-props": { "x-component-props": {
contentStyle: { contentStyle: {
......
import EyePreview from '@/components/EyePreview'; import { ISchema } from '@formily/antd';
import { DownOutlined } from '@ant-design/icons';
import { TimeList } from '../../statusList'; import { TimeList } from '../../statusList';
import moment from 'moment'; import { getIntl } from 'umi';
import React from 'react';
import { ANNOUNCE_COLUMN_TYPE, transfer2Options } from '../../utils/utils'; import { ANNOUNCE_COLUMN_TYPE, transfer2Options } from '../../utils/utils';
import { FORM_FILTER_PATH } from '@/formSchema/const';
const ALL = [{label: '栏目(全部)', value: 0}] // const ALL = [{ label: getIntl().formatMessage({ id: 'common.text.all' }), value: 0 }]
const COLUMNSOPTIONS = ALL.concat(transfer2Options(ANNOUNCE_COLUMN_TYPE)); // const COLUMNS_OPTIONS = ALL.concat(transfer2Options(ANNOUNCE_COLUMN_TYPE))
const columns = [ export const schema: ISchema = {
{title: 'ID', dataIndex: 'id'}, type: 'object',
{ properties: {
title: '栏目', dataIndex: 'columnType', mageLayout: {
render: (text, record) => { type: 'object',
return ( 'x-component': 'mega-layout',
<div>{ANNOUNCE_COLUMN_TYPE[text]}</div> properties: {
) topLayout: {
}
},
{ title: '标题',
dataIndex: 'title',
render: (text: string, record: any) => (
<EyePreview
url={`/memberCenter/contentAbility/announcements/detail?id=${record.id}&preview=1`}
>
{text}
</EyePreview>
)
},
{
title: '发布时间',
dataIndex: 'createTime',
render: (text) => (
moment(text).format('YYYY-MM-DD HH:mm:ss')
)
},
{title: '状态', dataIndex: 'status', render: "{{renderStatus}}"},
{title: '操作', render: "{{renderOperation}}"}
];
/**
* 公告管理列表也 schemat
*/
const announcementSchema = {
type: 'object',
properties: {
layout: {
type: 'object',
// 'x-component': 'mega-layout',
'x-component': 'CustomFlexRowLayout',
'x-component-props': {
justify: 'space-between',
align: 'center'
},
properties: {
'left-layout': {
type: 'object', type: 'object',
name: 'left-layout', 'x-component': 'mega-layout',
'x-component': 'CustomFlexRowLayout',
'x-component-props': { 'x-component-props': {
justify: 'start', grid: true,
align: 'center'
}, },
properties: { properties: {
createBtn: { ctl: {
type: "object", type: 'object',
name: "createBtn", 'x-component': 'Children',
"x-component": "button", 'x-component-props': {
"x-component-props": { children: '{{controllerBtns}}',
"onClick": "{{goToCreate}}", },
"children": "新建", },
"type": 'primary', title: {
style: { type: 'string',
width: '112px', 'x-component': 'Search',
margin: '0 0 15px 0' 'x-component-props': {
} placeholder: getIntl().formatMessage({id: 'content.info.title'}),
} },
}, },
} },
}, },
'right-layout': { [FORM_FILTER_PATH]: {
type: 'object', type: 'object',
name: 'rigth-layout', 'x-component': 'flex-layout',
"x-component": 'CustomFlexColumnLayout', 'x-component-props': {
properties: { rowStyle: {
controllers: { flexWrap: 'nowrap',
type: 'object', },
name: 'controllers', colStyle: {
'x-component': 'CustomFlexRowLayout', marginLeft: 20,
},
},
properties: {
columnType: {
type: 'string',
enum: transfer2Options(ANNOUNCE_COLUMN_TYPE),
'x-component-props': { 'x-component-props': {
justify: 'end', placeholder: `${getIntl().formatMessage({id: 'common.text.pleaseSelect'})}${getIntl().formatMessage({id: 'content.info.column'})}`,
style: { width: '174px' },
}, },
properties: {
search: {
type: 'string',
name: 'name',
'x-component': 'CustomSearch',
'x-component-props': {
placeholder: "请填写标题名称",
"onSearch": "{{search}}",
}
},
'HIGHT_FILTER_BTN': {
type: 'string',
name: 'HIGHT_FILTER_BTN',
'x-component': 'button',
'x-component-props': {
"children": (
<div>高级搜索 <DownOutlined /></div>
),
"onClick": "{{toggleFilters}}",
style: {
margin: '0 15px'
}
}
},
reset: {
type: 'string',
name: 'reset',
"x-component": "button",
"x-component-props": {
"onClick": "{{reset}}",
"children": "重置",
}
},
}
}, },
'FILTERS': { status: {
type: 'object', type: 'string',
name: 'FILTERS', enum: [
'x-component': 'CustomFlexRowLayout', { label: getIntl().formatMessage({ id: 'common.text.all' }), value: '0' },
{ label: getIntl().formatMessage({ id: 'content.common.waitUp' }), value: '1' },
{ label: getIntl().formatMessage({ id: 'content.common.hadUp' }), value: '2' },
{ label: getIntl().formatMessage({ id: 'content.common.hadDown' }), value: '3' },
],
'x-component-props': { 'x-component-props': {
justify: 'end' placeholder: `${getIntl().formatMessage({id: 'common.text.pleaseSelect'})}${getIntl().formatMessage({id: 'common.table.status'})}`,
style: { width: '174px' },
}, },
properties: { },
columnType: { // time: {
type: 'string', // type: 'string',
'x-component': 'Select', // enum: TimeList,
'x-component-props': { // 'x-component-props': {
style: { // placeholder: getIntl().formatMessage({id: 'content.info.time'}),
width: '160px' // style: { width: '174px' },
}, // },
options: COLUMNSOPTIONS, // },
defaultValue: 0, submit: {
} 'x-component': 'Submit',
}, 'x-mega-props': {
status: { span: 1,
name: 'status', },
type: 'string', 'x-component-props': {
'x-component': 'Select', children: getIntl().formatMessage({id: 'common.button.submit'}),
'x-component-props': { },
options: [ },
{label: '状态(全部)', value: '0'}, },
{label: '待上架', value: '1'}, },
{label: '已上架',value: '2'},
{label: '已下架',value: '3'},
],
defaultValue: '0',
placeholder: '请选择状态',
style: {
width: '160px',
margin: '0 15px'
}
}
},
time: {
name: 'time',
type: 'string',
'x-component': 'Select',
'x-component-props': {
placeholder: '发布时间(全部)',
options: TimeList,
style: {
width: '160px',
}
}
}
}
}
}
}
}
},
"table": {
"key": "table",
"type": "object",
"name": "table",
"x-component": "Table",
"x-component-props": {
"columns": columns,
"rowKey": "id",
pagination: false,
// "pagination": {
// showQuickJumper: true,
// size: "small",
// "onChange": "{{paginationChange}}",
// },
// "rowSelection": "{{rowSelection}}"
}
},
pagination: {
type: 'object',
'x-component': "TablePagination",
'x-style': {
display: 'flex',
flexDirection: 'row',
justifyContent: 'flex-end'
}, },
'x-component-props': { },
showQuickJumper: true, },
pageSize: 10, };
size: 'small'
}
}
}
}
export default announcementSchema
...@@ -190,7 +190,7 @@ const Infomation = () => { ...@@ -190,7 +190,7 @@ const Infomation = () => {
return ( return (
<PageHeaderWrapper> <PageHeaderWrapper>
<Card> <Card>
<StandardTable <StandardTable
columns={columns} columns={columns}
currentRef={ref} currentRef={ref}
tableProps={{ rowKey: 'id' }} tableProps={{ rowKey: 'id' }}
......
...@@ -4,7 +4,7 @@ import { Card, Select, Input, Checkbox, Button} from 'antd'; ...@@ -4,7 +4,7 @@ import { Card, Select, Input, Checkbox, Button} from 'antd';
import { PageHeaderWrapper } from '@ant-design/pro-layout'; import { PageHeaderWrapper } from '@ant-design/pro-layout';
import ReutrnEle from '@/components/ReturnEle'; import ReutrnEle from '@/components/ReturnEle';
import { usePageStatus } from '@/hooks/usePageStatus'; import { usePageStatus } from '@/hooks/usePageStatus';
import { history, Prompt } from 'umi'; import { history, Prompt, useIntl } from 'umi';
// import CustomUpload from '@/components/NiceForm/components/CustomUpload'; // import CustomUpload from '@/components/NiceForm/components/CustomUpload';
import { CustomTags } from '../components/Tags'; import { CustomTags } from '../components/Tags';
import CustomEditor from '../components/CustomEditor'; import CustomEditor from '../components/CustomEditor';
...@@ -36,6 +36,7 @@ type ColumnListType = { ...@@ -36,6 +36,7 @@ type ColumnListType = {
} }
const InfomationInfo = () => { const InfomationInfo = () => {
const intl = useIntl()
useCustomValidator(); useCustomValidator();
const { id, preview } = usePageStatus(); const { id, preview } = usePageStatus();
// const [isTop, setIsTop] = useState(1); // const [isTop, setIsTop] = useState(1);
...@@ -122,7 +123,7 @@ const InfomationInfo = () => { ...@@ -122,7 +123,7 @@ const InfomationInfo = () => {
const targetColumn = column.filter((_item) => _item.value === data.columnId)[0]; const targetColumn = column.filter((_item) => _item.value === data.columnId)[0];
if(targetColumn) { if(targetColumn) {
actions.setFieldState('layout.columnId', state => { actions.setFieldState('layout.columnId', state => {
state.props['description'] = `栏目分类${COLUMN_CATEGORY[targetColumn?.type] || ''}` state.props['description'] = `${intl.formatMessage({ id: 'content.columns.category' })}${COLUMN_CATEGORY[targetColumn?.type] || ''}`
}) })
setType(targetColumn?.type) setType(targetColumn?.type)
} }
...@@ -168,8 +169,8 @@ const InfomationInfo = () => { ...@@ -168,8 +169,8 @@ const InfomationInfo = () => {
<div> <div>
<PageHeaderWrapper <PageHeaderWrapper
onBack={() => history.goBack()} onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回" />} backIcon={<ReutrnEle description={intl.formatMessage({ id: 'common.button.back' })} />}
title={isAdd ? '新建资讯' : isEdit ? '编辑资讯' : '查看资讯'} title={isAdd ? intl.formatMessage({ id: 'content.info.add' }) : isEdit ? intl.formatMessage({ id: 'content.info.edit' }) : intl.formatMessage({ id: 'content.info.see' })}
> >
<Card> <Card>
<SchemaForm <SchemaForm
...@@ -187,7 +188,7 @@ const InfomationInfo = () => { ...@@ -187,7 +188,7 @@ const InfomationInfo = () => {
onFieldValueChange$('layout.columnId').subscribe(({ value }) => { onFieldValueChange$('layout.columnId').subscribe(({ value }) => {
actions.setFieldState('layout.columnId', state => { actions.setFieldState('layout.columnId', state => {
const currentType = state.props["x-component-props"]!.options?.filter((_row) => _row.value === value)[0]; const currentType = state.props["x-component-props"]!.options?.filter((_row) => _row.value === value)[0];
state["props"]["description"] = `栏目分类${currentType && (COLUMN_CATEGORY[currentType.type])}`; state["props"]["description"] = `${intl.formatMessage({ id: 'content.columns.category' })}${currentType && (COLUMN_CATEGORY[currentType.type])}`;
setType(currentType ? currentType.type : 0) setType(currentType ? currentType.type : 0)
}) })
}) })
...@@ -213,7 +214,7 @@ const InfomationInfo = () => { ...@@ -213,7 +214,7 @@ const InfomationInfo = () => {
actions.setFieldState('imageUrl', state => { actions.setFieldState('imageUrl', state => {
state.props["x-rules"] = [1, 2, 3, 4, 6].includes(value) ? { state.props["x-rules"] = [1, 2, 3, 4, 6].includes(value) ? {
"required": true, "required": true,
"message": "请上传图片" "message": `${intl.formatMessage({ id: 'common.form.upload.placeholder' })}${intl.formatMessage({ id: 'common.text.image' })}`
} : {} } : {}
}) })
}) })
...@@ -224,7 +225,7 @@ const InfomationInfo = () => { ...@@ -224,7 +225,7 @@ const InfomationInfo = () => {
}, },
label: ( label: (
<div className={cx((isAdd || isEdit) && [1, 2, 3, 4, 6].includes(recommendLabelValue) && styles.custom_label)}> <div className={cx((isAdd || isEdit) && [1, 2, 3, 4, 6].includes(recommendLabelValue) && styles.custom_label)}>
图片 {intl.formatMessage({ id: 'common.text.image' })}
</div> </div>
) )
}} }}
...@@ -233,15 +234,15 @@ const InfomationInfo = () => { ...@@ -233,15 +234,15 @@ const InfomationInfo = () => {
isAdd || isEdit isAdd || isEdit
? ( ? (
<FormButtonGroup offset={3}> <FormButtonGroup offset={3}>
<Submit loading={submitLoading}>提交</Submit> <Submit loading={submitLoading}>{intl.formatMessage({ id: 'common.button.submit' })}</Submit>
<Button onClick={handleCancel}>取消</Button> <Button onClick={handleCancel}>{intl.formatMessage({ id: 'common.button.cancel' })}</Button>
</FormButtonGroup> </FormButtonGroup>
) )
: <></> : <></>
} }
</SchemaForm> </SchemaForm>
</Card> </Card>
<Prompt when={(isAdd || isEdit) && unsaved} message="您还有未保存的内容,是否确定要离开?" /> <Prompt when={(isAdd || isEdit) && unsaved} message={intl.formatMessage({ id: 'common.tip.save.confirm' })} />
</PageHeaderWrapper> </PageHeaderWrapper>
</div> </div>
) )
......
...@@ -3,7 +3,7 @@ import { TimeList } from '../../statusList'; ...@@ -3,7 +3,7 @@ import { TimeList } from '../../statusList';
import { getIntl } from 'umi'; import { getIntl } from 'umi';
import { FORM_FILTER_PATH } from '@/formSchema/const'; import { FORM_FILTER_PATH } from '@/formSchema/const';
const CustomTimeList = [{label: '全部', value: 0}].concat(TimeList.slice(1)); const CustomTimeList = [{label: getIntl().formatMessage({ id: 'common.text.all' }), value: 0}].concat(TimeList.slice(1));
export const schema: ISchema = { export const schema: ISchema = {
type: 'object', type: 'object',
...@@ -58,10 +58,10 @@ export const schema: ISchema = { ...@@ -58,10 +58,10 @@ export const schema: ISchema = {
status: { status: {
type: 'string', type: 'string',
enum: [ enum: [
{ label: '全部', value: '0' }, { label: getIntl().formatMessage({ id: 'common.text.all' }), value: '0' },
{ label: '待上架', value: '1' }, { label: getIntl().formatMessage({ id: 'content.common.waitUp' }), value: '1' },
{ label: '已上架', value: '2' }, { label: getIntl().formatMessage({ id: 'content.common.hadUp' }), value: '2' },
{ label: '已下架', value: '3' }, { label: getIntl().formatMessage({ id: 'content.common.hadDown' }), value: '3' },
], ],
'x-component-props': { 'x-component-props': {
placeholder: `${getIntl().formatMessage({id: 'common.text.pleaseSelect'})}${getIntl().formatMessage({id: 'common.table.status'})}`, placeholder: `${getIntl().formatMessage({id: 'common.text.pleaseSelect'})}${getIntl().formatMessage({id: 'common.table.status'})}`,
......
import { getIntl } from 'umi';
interface IOption { interface IOption {
value: number|string, value: number|string,
label: number|string label: number|string
...@@ -30,15 +32,15 @@ const schema = { ...@@ -30,15 +32,15 @@ const schema = {
properties: { properties: {
title : { title : {
name: 'title', name: 'title',
title: '标题', title: getIntl().formatMessage({ id: 'common.text.title' }),
'x-component': 'Input', 'x-component': 'Input',
'x-component-props': { 'x-component-props': {
placeholder: '最长30个汉字,60个字符', placeholder: `30${getIntl().formatMessage({ id: 'common.unit.individual.chinese' })}, 60${getIntl().formatMessage({ id: 'common.unit.individual.character' })}`,
}, },
"x-rules": [ "x-rules": [
{ {
"required": true, "required": true,
"message": "请填写标题" "message": `${getIntl().formatMessage({ id: 'common.form.input.placeholder' })}${getIntl().formatMessage({ id: 'common.text.title' })}`,
}, },
{ {
limitByte: true, limitByte: true,
...@@ -48,22 +50,22 @@ const schema = { ...@@ -48,22 +50,22 @@ const schema = {
}, },
columnId: { columnId: {
name: 'columnId', name: 'columnId',
title: '栏目', title: getIntl().formatMessage({ id: 'content.info.column' }),
'x-component': 'Select', 'x-component': 'Select',
"x-component-props": { "x-component-props": {
style: { style: {
marginBottom: '8px' marginBottom: '8px'
}, },
}, },
description: "栏目分类", description: getIntl().formatMessage({ id: 'content.columns.category' }),
"x-rules": { "x-rules": {
"required": true, "required": true,
"message": "请选择咨询说明" "message": `${getIntl().formatMessage({ id: 'common.text.pleaseSelect' })}${getIntl().formatMessage({ id: 'content.columns.category' })}`,
}, },
}, },
recommendLabel: { recommendLabel: {
name: 'recommendLabel', name: 'recommendLabel',
title: '推荐标签', title: getIntl().formatMessage({ id: 'content.info.recommendTag' }),
type: 'string', type: 'string',
'x-component': 'Select', 'x-component': 'Select',
"x-component-props": { "x-component-props": {
...@@ -72,49 +74,19 @@ const schema = { ...@@ -72,49 +74,19 @@ const schema = {
}, },
allowClear: true, allowClear: true,
options: [ options: [
{label: '头条文章', value: 1}, {label: getIntl().formatMessage({ id: 'content.info.label1' }), value: 1},
{label: '轮播新闻', value: 2}, {label: getIntl().formatMessage({ id: 'content.info.label2' }), value: 2},
{label: '图片新闻', value: 3}, {label: getIntl().formatMessage({ id: 'content.info.label3' }), value: 3},
{label: '推荐阅读', value: 4}, {label: getIntl().formatMessage({ id: 'content.info.label4' }), value: 4},
{label: '行情推荐', value: 5}, {label: getIntl().formatMessage({ id: 'content.info.label5' }), value: 5},
{label: '本栏推荐', value: 6} {label: getIntl().formatMessage({ id: 'content.info.label6' }), value: 6}
], ],
}, },
}, },
// sortLayout: {
// type: 'object',
// 'x-component': 'mega-layout',
// "x-component-props": {
// "label": "推荐排序",
// // wrapperCol: 23,
// // layoutProps: {
// // "wrapperCol": 12,
// // },
// style: {
// marginBottom: 0
// },
// // addonAfter: "{{isTop}}"
// },
// properties: {
// sort: {
// name: 'sort',
// type: 'string',
// 'x-component': 'Select',
// 'x-component-props': {
// // style: {
// // width: '100%'
// // },
// options: sortedList,
// allowClear: true,
// }
// },
// }
// },
sort: { sort: {
name: 'sort', name: 'sort',
type: 'string', type: 'string',
title: '推荐排序', title: getIntl().formatMessage({ id: 'content.info.recommendSort' }),
'x-component': 'Select', 'x-component': 'Select',
'x-component-props': { 'x-component-props': {
options: sortedList, options: sortedList,
...@@ -124,7 +96,7 @@ const schema = { ...@@ -124,7 +96,7 @@ const schema = {
}, },
readCount: { readCount: {
name: 'readCount', name: 'readCount',
title: '浏览数', title: getIntl().formatMessage({ id: 'content.info.views' }),
type: 'string', type: 'string',
'x-component': 'Input', 'x-component': 'Input',
'x-component-props': { 'x-component-props': {
...@@ -144,7 +116,7 @@ const schema = { ...@@ -144,7 +116,7 @@ const schema = {
'x-component-props': { 'x-component-props': {
grid: true, grid: true,
full: true, full: true,
label: "行情资讯分类:", label: getIntl().formatMessage({ id: 'content.info.category' }),
"wrapperCol": 24, "wrapperCol": 24,
}, },
properties: { properties: {
...@@ -200,7 +172,7 @@ const schema = { ...@@ -200,7 +172,7 @@ const schema = {
}, },
labelIds: { labelIds: {
name: 'labelIds', name: 'labelIds',
title: '咨询标签', title: getIntl().formatMessage({ id: 'content.info.tag' }),
"x-component": 'CustomTags', "x-component": 'CustomTags',
"x-component-props": { "x-component-props": {
layoutProps: { layoutProps: {
...@@ -223,16 +195,16 @@ const schema = { ...@@ -223,16 +195,16 @@ const schema = {
digest: { digest: {
type: 'string', type: 'string',
name: 'digest', name: 'digest',
title: '摘要', title: getIntl().formatMessage({ id: 'content.info.abstract' }),
"x-component": 'TextArea', "x-component": 'TextArea',
"x-component-props": { "x-component-props": {
placeholder: "最长400个字符,200个汉字", placeholder: `200${getIntl().formatMessage({ id: 'common.unit.individual.chinese' })}, 400${getIntl().formatMessage({ id: 'common.unit.individual.character' })}`,
rows: 5, rows: 5,
}, },
"x-rules": [ "x-rules": [
{ {
"required": true, "required": true,
"message": "最长400个字符,200个汉字" "message": `200${getIntl().formatMessage({ id: 'common.unit.individual.chinese' })}, 400${getIntl().formatMessage({ id: 'common.unit.individual.character' })}`,
}, },
{ {
limitByte: true, limitByte: true,
...@@ -252,7 +224,7 @@ const schema = { ...@@ -252,7 +224,7 @@ const schema = {
content: { content: {
type: "string", type: "string",
name: 'content', name: 'content',
title: '内容', title: getIntl().formatMessage({ id: 'content.info.content' }),
"x-component": 'CustomEditor', "x-component": 'CustomEditor',
"x-component-parent-props": { "x-component-parent-props": {
style: { style: {
...@@ -261,7 +233,7 @@ const schema = { ...@@ -261,7 +233,7 @@ const schema = {
}, },
"x-rules": { "x-rules": {
"required": true, "required": true,
"message": "请输入内容" "message": `${getIntl().formatMessage({ id: 'common.form.input.placeholder' })}${getIntl().formatMessage({ id: 'content.info.content' })}`,
}, },
"x-component-props": { "x-component-props": {
contentStyle: { contentStyle: {
......
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