Commit 67a29bb2 authored by GuanHua's avatar GuanHua

merge: 冲突解决

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