Commit 38acd6bc authored by 前端-黄佳鑫's avatar 前端-黄佳鑫
parents a1bb25e0 255c1d1a
import React from 'react'
import { Popconfirm, Button } from 'antd'
import { PlayCircleOutlined,PauseCircleOutlined } from '@ant-design/icons'
import { useIntl } from 'umi';
export interface StatusSwitchProps {
record: any,
......@@ -11,14 +12,15 @@ export interface StatusSwitchProps {
}
const StatusSwitch:React.FC<StatusSwitchProps> = (props) => {
const intl = useIntl()
const { record, fieldNames = 'status', expectTrueValue = 1 } = props
return (
<Popconfirm
title="确定要执行这个操作?"
title={intl.formatMessage({ id: 'common.tip.option.confirm' })}
onConfirm={props.handleConfirm}
onCancel={props.handleCancel}
okText="是"
cancelText="否"
okText={intl.formatMessage({ id: 'common.button.yes' })}
cancelText={intl.formatMessage({ id: 'common.button.no' })}
>
<Button
type="link"
......@@ -28,7 +30,7 @@ const StatusSwitch:React.FC<StatusSwitchProps> = (props) => {
: { color: 'red' }
}
>
{record[fieldNames] === expectTrueValue ? '有效' : '无效'}
{record[fieldNames] === expectTrueValue ? intl.formatMessage({ id: 'common.status.effective' }) : intl.formatMessage({ id: 'common.status.invalid' })}
{record[fieldNames] === expectTrueValue ? (
<PlayCircleOutlined />
) : (
......@@ -41,4 +43,4 @@ const StatusSwitch:React.FC<StatusSwitchProps> = (props) => {
StatusSwitch.defaultProps = {}
export default StatusSwitch
\ No newline at end of file
export default StatusSwitch
......@@ -12,6 +12,7 @@ import editor from './zh-CN/editor'
import content from './zh-CN/content'
import commodity from './zh-CN/commodity'
import trademark from './zh-CN/trademark'
import repositories from './zh-CN/repositories'
export default {
'global.siteName': '瓴犀',
......@@ -25,6 +26,7 @@ export default {
...classAndProperty,
...commodity,
...trademark,
...repositories,
...member,
...purchase,
...editor,
......
......@@ -68,6 +68,7 @@
'common.form.endTime.placeholder': '结束时间',
'common.form.activity.startTime.placeholder': '活动开始时间',
'common.form.activity.endTime.placeholder': '活动结束时间',
'common.form.input.placeholder': '请输入',
}
......@@ -2,6 +2,12 @@
* 内容能力
*/
export default {
'content.common.up': '上架',
'content.common.down': '下架',
'content.common.waitUp': '待上架',
'content.common.hadUp': '已上架',
'content.common.hadDown': '已下架',
'content.columns.name': '栏目名称',
'content.columns.category': '栏目分类',
'content.columns.sort': '栏目排序',
......@@ -10,5 +16,22 @@
'content.columns.add': '新建栏目',
'content.columns.edit': '编辑栏目',
'content.category.name': '分类名称',
'content.category.type': '类型',
'content.category.recommend': '推荐分类',
'content.category.selectEditProject': '选择要编辑的项目',
'content.category.noCategoryTips': '暂无分类, 开始新增',
'content.category.handleTips': '只能同时对7个一级分类下的第三级分类设置推荐分类,且每个一级分类下最多只允许设置2个推荐分类',
'content.tag.name': '标签名称',
'content.tag.explain': '标签说明',
'content.tag.add': '新建标签',
'content.tag.edit': '编辑标签',
'content.info.title': '标题',
'content.info.column': '栏目',
'content.info.category': '分类',
'content.info.time': '发布时间',
'content.info.recommendTag': '推荐标签',
'content.info.sort': '排序',
}
This diff is collapsed.
import React, { useState, useEffect, useMemo } from 'react'
import { Row, Col, Popconfirm, Button, Card, Tooltip } from 'antd';
import Children from '@/components/NiceForm/components/Children';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import TabTree, { useTreeActions, createTreeActions } from '@/components/TabTree';
import SchemaForm, { createFormActions, LifeCycleTypes, FormEffectHooks, FormButtonGroup } from '@formily/antd';
import { Checkbox } from '@formily/antd-components'
import { classSchema } from './schema'
import React, { useEffect, useMemo } from 'react'
import { Popconfirm, Button, Card, Tooltip } from 'antd';
import TabTree, { createTreeActions } from '@/components/TabTree';
import { createFormActions, FormButtonGroup } from '@formily/antd';
import { Checkbox } from '@formily/antd-components';
import { useIntl } from 'umi';
import { classSchema } from './schema';
import { useTreeTabs } from '@/hooks/useTreeTabs';
import NiceForm from '@/components/NiceForm';
import styles from './index.less';
import { BorderOuterOutlined, QuestionCircleOutlined } from '@ant-design/icons';
import { QuestionCircleOutlined } from '@ant-design/icons';
import { getManageMemberCategoryAll, getManageMemberCategoryGet, postManageMemberCategoryAdd, postManageMemberCategoryDelete, postManageMemberCategoryUpdate } from '@/services/ManageV2Api';
const { ON_FORM_INPUT_CHANGE } = LifeCycleTypes
enum FormState {
FREE, // 空闲状态
EDIT, // 编辑状态
......@@ -69,6 +66,7 @@ const fetchClassTreeData = async (params?) => {
const ClassProperty: React.FC<{}> = () => {
const intl = useIntl()
const {
treeStatus,
setTreeStatus,
......@@ -164,7 +162,7 @@ const ClassProperty: React.FC<{}> = () => {
<div className={styles.page}>
<div className={styles.tree}>
<Card>
<h3 className="mb-30">选择要编辑的项目</h3>
<h3 className="mb-30">{intl.formatMessage({ id: 'content.category.selectEditProject' })}</h3>
{
treeData && treeData.length > 0
? <TabTree
......@@ -176,14 +174,14 @@ const ClassProperty: React.FC<{}> = () => {
customKey="id"
/>
:
<Button block type='primary' onClick={() => handleSelect()}>暂无菜单, 开始新增</Button>
<Button block type='primary' onClick={() => handleSelect()}>{intl.formatMessage({ id: 'content.category.noCategoryTips' })}</Button>
}
</Card>
</div>
<div className={styles.editPanel}>
{
treeStatus !== FormState.FREE && <>
<h3 className="commonPanelTitle mb-30">{treeStatus === FormState.ADD ? '新增' : '编辑'}</h3>
<h3 className="commonPanelTitle mb-30">{intl.formatMessage({ id: treeStatus === FormState.ADD ? 'common.button.add' : 'common.button.edit' })}</h3>
<NiceForm
value={formValue}
components={{
......@@ -194,10 +192,10 @@ const ClassProperty: React.FC<{}> = () => {
onSubmit={onFinish}
actions={formActions}
effects={($, action)=> {}}
schema={classSchema}
schema={classSchema()}
expressionScope={{
showWarn: (
<Tooltip placement="topLeft" title={"只能同时对7个一级分类下的第三级分类设置推荐分类,且每个一级分类下最多只允许设置2个推荐分类"}>
<Tooltip placement="topLeft" title={intl.formatMessage({ id: 'content.category.handleTips' })}>
<span style={{marginTop: '-12px', width: '50px'}}>
<QuestionCircleOutlined />
</span>
......@@ -207,12 +205,17 @@ const ClassProperty: React.FC<{}> = () => {
>
<FormButtonGroup>
<Button htmlType='submit' type="primary" >
保存
{intl.formatMessage({ id: 'common.button.save' })}
</Button>
<Popconfirm title="确定要删除吗?" okText="是" cancelText="否" onConfirm={handleDeleteMenu}>
<Popconfirm
title={intl.formatMessage({ id: 'common.tip.option.confirm' })}
okText={intl.formatMessage({ id: 'common.button.yes' })}
cancelText={intl.formatMessage({ id: 'common.button.no' })}
onConfirm={handleDeleteMenu}
>
{
treeStatus !== FormState.ADD && <Button >
删除
{intl.formatMessage({ id: 'common.button.delete' })}
</Button>
}
</Popconfirm>
......
import { ISchema } from '@formily/antd';
import { useIntl } from 'umi';
export const classSchema: ISchema = {
type: 'object',
properties: {
megaLayout: {
type: 'object',
"x-component": "mega-layout",
"x-component-props": {
grid: true,
columns: 16,
labelAlign: 'top'
},
properties: {
noField1: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
full: true,
"wrapperWidth": 507,
},
"x-mega-props": {
span: 1
},
properties: {
name: {
type: 'string',
title: '分类名称',
required: true,
"x-component-props": {
placeholder: '请输入分类名称'
},
"x-rules": [
{
limitByte: true,
maxByte: 20
}
]
export const classSchema = (): ISchema => {
const intl = useIntl()
return {
type: 'object',
properties: {
megaLayout: {
type: 'object',
"x-component": "mega-layout",
"x-component-props": {
grid: true,
columns: 16,
labelAlign: 'top'
},
properties: {
noField1: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
full: true,
"wrapperWidth": 507,
},
describe: {
type: 'textarea',
title: '类型',
"x-component-props": {
placeholder: '最多100个字符,50个汉字'
},
"x-rules": [
{
limitByte: true,
maxByte: 100
}
]
"x-mega-props": {
span: 1
},
level: {
type: 'string',
visible: false,
'x-linkages': [
{
type: 'value:visible',
target: '*(inlineLayout)',
condition: '{{$value === 3}}'
properties: {
name: {
type: 'string',
title: intl.formatMessage({ id: 'content.category.name' }),
required: true,
"x-component-props": {
placeholder: `${intl.formatMessage({ id: 'common.form.input.placeholder' })}${intl.formatMessage({ id: 'content.category.name' })}`
},
]
},
inlineLayout: {
type: 'object',
"x-component": "mega-layout",
"x-component-props": {
inline: true,
"x-rules": [
{
limitByte: true,
maxByte: 20
}
]
},
properties: {
status: {
title: '',
'x-component': 'CheckboxGroup',
enum: [
{ label: '推荐分类', value: 1 },
],
"x-mega-props": {
"addonAfter": "{{showWarn}}",
// wrapperWidth: 130
describe: {
type: 'textarea',
title: intl.formatMessage({ id: 'content.category.type' }),
"x-component-props": {
placeholder: `100${intl.formatMessage({ id: 'common.unit.individual.character' })},50${intl.formatMessage({ id: 'common.unit.individual.chinese' })}`
},
"x-rules": [
{
limitByte: true,
maxByte: 100
}
]
},
level: {
type: 'string',
visible: false,
'x-linkages': [
{
type: 'value:visible',
target: '*(inlineLayout)',
condition: '{{$value === 3}}'
},
]
},
inlineLayout: {
type: 'object',
"x-component": "mega-layout",
"x-component-props": {
inline: true,
},
properties: {
status: {
title: '',
'x-component': 'CheckboxGroup',
enum: [
{ label: intl.formatMessage({ id: 'content.category.recommend' }), value: 1 },
],
"x-mega-props": {
"addonAfter": "{{showWarn}}",
// wrapperWidth: 130
},
},
}
}
}
// status1: {
// title: '',
// 'x-component': 'Children',
// "x-component-props": {
// "children": "{{renderCheckBox()}}"
// }
// }
}
},
// status1: {
// title: '',
// 'x-component': 'Children',
// "x-component-props": {
// "children": "{{renderCheckBox()}}"
// }
// }
}
},
}
}
}
}
......
import React, { useEffect, useState, useRef } from 'react';
import React, { useRef } from 'react';
import { Card, Button, Popconfirm, Row, Col } from 'antd';
import { createFormActions, ISchema } from '@formily/antd';
import { history, useIntl } from 'umi';
......@@ -6,7 +6,6 @@ import StatusSwitch from '@/components/StatusSwitch';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { PlusOutlined } from '@ant-design/icons'
import { ColumnType } from 'antd/lib/table/interface'
import { getTableDataSource } from '../utils/utils';
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import NiceForm from '@/components/NiceForm';
import EyePreview from '@/components/EyePreview'
......@@ -15,12 +14,6 @@ import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilte
import { getManageMemberColumnPage, postManageMemberColumnDelete, postManageMemberColumnUpdateStatus } from '@/services/ManageV2Api';
const formActions = createFormActions();
const actions = createFormActions();
const getData = async (params) => {
const res = await getManageMemberColumnPage(params)
return res.data
}
const columnList: React.FC<{}> = () => {
......
import React from 'react';
import EyePreview from '@/components/EyePreview';
const columns = [
{title: 'ID', dataIndex: 'id'},
{
title: '栏目名称', dataIndex: 'name',
render: (text: string, record: any) => (
<EyePreview
url={`/memberCenter/contentAbility/columnsManagement/detail?id=${record.id}&preview=1`}
>
{text}
</EyePreview>
)
},
{title: '栏目分类', dataIndex: 'type', render: (text) => text === 1 ? '市场行情' : '资讯'},
{title: '栏目排序', dataIndex: 'sort'},
{
title: '状态', dataIndex: 'status',
filters: [
{
text: '有效',
value: 1,
},
{
text: '无效',
value: 0,
},
],
onFilter: (value, record) => record.status === value,
render: "{{renderStatus}}"
},
{title: '操作', render: "{{renderOperation}}"}
];
const schema = {
type: 'object',
properties: {
layout: {
type: 'object',
// 'x-component': 'mega-layout',
'x-component': 'CustomFlexRowLayout',
'x-component-props': {
justify: 'space-between'
},
properties: {
createBtn: {
type: "object",
name: "createBtn",
"x-component": "button",
"x-component-props": {
"onClick": "{{goToCreate}}",
"children": "新建",
"type": 'primary'
}
},
'right-layout': {
type: 'object',
name: 'rigth-layout',
"x-component": 'CustomFlexRowLayout',
"x-component-props": {
justify: 'center'
},
properties: {
search: {
type: 'string',
name: 'search',
'x-component': 'CustomSearch',
'x-component-props': {
placeholder: "请填写栏目名称",
"onSearch": "{{search}}",
}
},
searchBtn: {
type: 'string',
name: 'searchBtn',
"x-component": "button",
"x-component-props": {
"onClick": "{{reset}}",
"children": "重置",
style: {
marginLeft: '15px'
}
}
},
}
}
}
},
"table": {
"key": "table",
"type": "object",
"name": "table",
"x-component": "SchemaTable",
"x-component-props": {
"columns": columns,
"rowKey": "id",
"pagination": false
}
},
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 schema
This diff is collapsed.
import React, {useState, useEffect} from 'react';
import { Card, Input, Button, Table, Space, Popconfirm } from 'antd';
import { FilterTable, SchemaFlexRowLayout } from '../components/FilterTable';
import { createVirtualBox, createFormActions, FormEffectHooks, createEffectHook } from '@formily/antd';
import { history, Link } from 'umi';
import React, { useRef } from 'react';
import { Card, Button, Popconfirm, Row, Col } from 'antd';
import EyePreview from '@/components/EyePreview';
import NiceForm from '@/components/NiceForm';
import { ColumnType } from 'antd/lib/table/interface'
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { createFormActions } from '@formily/antd';
import { history, useIntl } from 'umi';
import StatusSwitch from '@/components/StatusSwitch';
import tagsManagementSchema from './schema';
import TablePagination from '../components/TablePagination';
import { getTableDataSource } from '../utils/utils';
import CustomSearch from '../components/CustomSearch';
import { StandardTable } from 'god';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { getManageMemberLabelPage, postManageMemberLabelDelete, postManageMemberLabelUpdateStatus } from '@/services/ManageV2Api';
const { onFieldValueChange$ } = FormEffectHooks
const { Search } = Input;
const SchemaButton = createVirtualBox('button', Button);
const SchemaTable = createVirtualBox('SchemaTable', Table);
const actions = createFormActions();
const getData = async (params) => {
const res = await getManageMemberLabelPage(params)
return res.data
}
const Tags = () => {
const tagEffects = () => () => {
onFieldValueChange$('pagination').subscribe((state) => {
handleSearch({...state.value})
})
}
const intl = useIntl()
const ref = useRef<any>({})
useEffect(() => {
const params = {
current: 1,
pageSize: 10
const columns: ColumnType<any>[] = [
{title: 'ID', dataIndex: 'id'},
{
title: intl.formatMessage({ id: 'content.tag.name' }), dataIndex: 'name',
render: (text: string, record: any) => (
<EyePreview
url={`/memberCenter/contentAbility/tagsManagement/detail?id=${record.id}&preview=1`}
>
{text}
</EyePreview>
)
},
{
title: intl.formatMessage({ id: 'content.tag.explain' }),
dataIndex: 'explain'
},
{
title: intl.formatMessage({ id: 'common.table.status' }),
align: 'center',
dataIndex: 'status',
key: 'status',
render: (text: any, record: any) => (
<StatusSwitch
fieldNames="status"
handleConfirm={() => handleModify(record)}
record={record}
/>
)
},
{
title: intl.formatMessage({ id: 'common.table.action' }),
align: 'center',
key: 'operate',
dataIndex: 'operate',
render: (_, record) => !record.status && (
<>
<Button type='link' onClick={() => history.push(`/memberCenter/contentAbility/tagsManagement/detail?id=${record.id}`)}>{intl.formatMessage({ id: 'common.button.modify' })}</Button>
<Popconfirm
title={intl.formatMessage({ id: 'common.tip.option.confirm' })}
onConfirm={() => handleRemove(record.id)}
>
<Button type='link'>{intl.formatMessage({ id: 'common.button.delete' })}</Button>
</Popconfirm>
</>
)
}
getTableDataSource(actions, params, getData);
}, [])
];
const schema = {
type: 'object',
properties: {
megalayout: {
type: 'object',
"x-component": 'mega-layout',
"x-component-props": {
grid: true
},
properties: {
ctl: {
type: 'object',
"x-component": "Children",
"x-component-props": {
children: "{{controllerBtns}}"
}
},
name: {
type: 'string',
"x-component": "Search",
"x-mega-props": {
},
"x-component-props": {
placeholder: intl.formatMessage({ id: 'content.tag.name' }),
advanced: false
}
}
}
}
}
}
// 获取列表
const fetchData = (params: any) => {
return new Promise((resolve) => {
getManageMemberLabelPage(params).then(res => {
resolve(res.data)
})
})
}
// 修改状态
const handleModify = (value) => {
......@@ -44,94 +114,54 @@ const Tags = () => {
id: id,
enableStatus: (status ^ 1),
}
postManageMemberLabelUpdateStatus(postData).
then((data) => {
const paginationValue = actions.getFieldValue('pagination');
handleSearch({...paginationValue})
postManageMemberLabelUpdateStatus(postData).then((res) => {
if (res.code === 1000) {
ref.current.reload()
}
})
}
// 栏目删除
const handleRemove = (id: number) => {
///manage/contentColumn/delete
postManageMemberLabelDelete({id: id})
.then(async (data) => {
const paginationValue = actions.getFieldValue('pagination');
handleSearch({...paginationValue})
postManageMemberLabelDelete({id: id}).then((res) => {
if (res.code === 1000) {
ref.current.reload()
}
})
}
const handleSearch = async (params) => {
const title = actions.getFieldValue('search');
const postData = {
name: title || '',
current: 1,
pageSize: 10,
...params,
}
getTableDataSource(actions, postData, getData);
}
const controllerBtns = <Row>
<Col span={6}>
<Button
onClick={() => history.push('/memberCenter/contentAbility/tagsManagement/add')}
type="primary"
>
{intl.formatMessage({ id: 'common.button.add' })}
</Button>
</Col>
</Row>
// 重设页码
const resetPagination = (params) => {
const paginationValue = actions.getFieldValue('pagination');
actions.setFieldValue('pagination', {
...paginationValue,
...params
})
}
return (
<div>
<Card>
<FilterTable
effects={tagEffects()}
schema={tagsManagementSchema}
components={{CustomSearch, TablePagination}}
actions={actions}
expressionScope={{
goToCreate: () => {
history.push(`/memberCenter/contentAbility/tagsManagement/add`)
},
search: (value) => {
resetPagination({current: 1})
handleSearch({title: value, current: 1 });
},
renderOperation: (val, record) => {
return (
<Space>
{
record.status === 0
? <>
<Link to={`/memberCenter/contentAbility/tagsManagement/detail?id=${record.id}`}>编辑</Link>
<Popconfirm
title="确定要执行这个操作?"
onConfirm={() => handleRemove(record.id)}
okText="是"
cancelText="否"
>
<a>删除</a>
</Popconfirm>
</>
: null
}
</Space>
)
},
renderStatus: (text, record) => {
return (
<StatusSwitch
handleConfirm={() => handleModify(record)}
record={record}
fieldNames="status"
/>
)
},
reset: () => {
actions.setFieldValue('search');
resetPagination({current: 1})
handleSearch({current: 1})
},
}}
<StandardTable
tableProps={{ rowKey: 'id' }}
columns={columns}
currentRef={ref}
fetchTableData={(params: any) => fetchData(params)}
controlRender={
<NiceForm
actions={actions}
expressionScope={{ controllerBtns }}
onSubmit={values => ref.current.reload(values)}
effects={($, actions) => {
useStateFilterSearchLinkageEffect($, actions, 'title', FORM_FILTER_PATH)
}}
schema={schema}
>
</NiceForm>
}
/>
</Card>
</div>
......
import React from 'react';
import EyePreview from '@/components/EyePreview';
const columns = [
{title: 'ID', dataIndex: 'id'},
{
title: '标签名称', dataIndex: 'name',
render: (text: string, record: any) => (
<EyePreview
url={`/memberCenter/contentAbility/tagsManagement/detail?id=${record.id}&preview=1`}
>
{text}
</EyePreview>
)
},
{title: '标签说明', dataIndex: 'explain'},
{title: '状态', dataIndex: 'status', render: "{{renderStatus}}", width: 120},
{title: '操作', render: "{{renderOperation}}", width: 150}
];
const schema = {
type: 'object',
properties: {
layout: {
type: 'object',
// 'x-component': 'mega-layout',
'x-component': 'CustomFlexRowLayout',
'x-component-props': {
justify: 'space-between'
},
properties: {
createBtn: {
type: "object",
name: "createBtn",
"x-component": "button",
"x-component-props": {
"onClick": "{{goToCreate}}",
"children": "新建",
"type": 'primary'
}
},
'right-layout': {
type: 'object',
name: 'rigth-layout',
"x-component": 'CustomFlexRowLayout',
"x-component-props": {
justify: 'center'
},
properties: {
search: {
type: 'string',
name: 'search',
'x-component': 'CustomSearch',
'x-component-props': {
placeholder: "请填写标签名称",
"onSearch": "{{search}}",
}
},
searchBtn: {
type: 'string',
name: 'searchBtn',
"x-component": "button",
"x-component-props": {
"onClick": "{{reset}}",
"children": "重置",
style: {
marginLeft: '15px'
}
}
},
}
}
}
},
"table": {
"key": "table",
"type": "object",
"name": "table",
"x-component": "SchemaTable",
"x-component-props": {
"dataSource": [],
"columns": columns,
"rowKey": "id",
"pagination": false
}
},
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 schema;
......@@ -4,70 +4,71 @@ import { Card, Select, Input, 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 { useInitialValues } from '../hooks/useInitialValues';
import useCustomValidator from '../hooks/useValidator'
import { getManageMemberLabelGet, postManageMemberLabelAdd, postManageMemberLabelUpdate } from '@/services/ManageV2Api';
const { TextArea } = Input;
const schema = {
type: 'object',
properties: {
layout: {
name: 'layout',
type: 'boject',
'x-component': 'mega-layout',
'x-component-props': {
"labelCol": 3,
"wrapperCol": 10,
"labelAlign": "left"
},
properties: {
name: {
name: 'name',
title: '标签名称',
'x-component': 'Input',
"required": true,
"x-rules": [
{
"required": true,
"message": "请填写标签名称"
},
{
limitByte: true, // 自定义校验规则
maxByte: 20,
}
],
},
explain: {
name: 'explain',
title: '标签说明',
'x-component': 'TextArea',
'x-component-props': {
rows: 5
},
"x-rules": [
{
limitByte: true, // 自定义校验规则
maxByte: 80,
}
],
},
}
}
}
}
const TagInfo = () => {
useCustomValidator();
const intl = useIntl()
const { id, preview } = usePageStatus();
const [ submitLoading, setSubmitLoading ] = useState(false);
const initialValues = useInitialValues({id:id}, getManageMemberLabelGet);
const isEdit = id && !preview;
const isAdd = !id && !preview;
const [unsaved, setUnsaved] = useState(true);
const schema = {
type: 'object',
properties: {
layout: {
name: 'layout',
type: 'boject',
'x-component': 'mega-layout',
'x-component-props': {
"labelCol": 3,
"wrapperCol": 10,
"labelAlign": "left"
},
properties: {
name: {
name: 'name',
title: intl.formatMessage({ id: 'content.tag.name' }),
'x-component': 'Input',
"required": true,
"x-rules": [
{
"required": true,
"message": `${intl.formatMessage({ id: 'common.form.input.placeholder' })}${intl.formatMessage({ id: 'content.tag.name' })}`
},
{
limitByte: true, // 自定义校验规则
maxByte: 20,
}
],
},
explain: {
name: 'explain',
title: intl.formatMessage({ id: 'content.tag.explain' }),
'x-component': 'TextArea',
'x-component-props': {
rows: 5
},
"x-rules": [
{
limitByte: true, // 自定义校验规则
maxByte: 80,
}
],
},
}
}
}
}
const handleSubmit = (value) => {
console.log(value)
const { id, name, explain} = value;
......@@ -90,12 +91,13 @@ const TagInfo = () => {
const handleCancel = () => {
history.push('/memberCenter/contentAbility/tagsManagement')
}
return (
<div>
<PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回" />}
title={!id ? '新建标签' : '编辑标签'}
backIcon={<ReutrnEle description={intl.formatMessage({ id: 'common.button.back' })} />}
title={!id ? intl.formatMessage({ id: 'content.tag.add' }) : intl.formatMessage({ id: 'content.tag.edit' })}
>
<Card>
<SchemaForm
......@@ -109,15 +111,15 @@ const TagInfo = () => {
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={unsaved} message="您还有未保存的内容,是否确定要离开?" />
<Prompt when={unsaved} message={intl.formatMessage({ id: 'common.tip.save.confirm' })} />
</PageHeaderWrapper>
</div>
)
......
import React from 'react'
import { history } from 'umi'
import { history, useIntl } from 'umi'
import { Button, Card, message } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import {
......@@ -23,7 +23,8 @@ import { postProductFreightSpaceAdd } from '@/services/ProductV2Api'
const addSchemaAction = createFormActions()
const AddRepository:React.FC<{}> = (props) => {
const AddRepository: React.FC<{}> = (props) => {
const intl = useIntl();
const {
id,
preview,
......@@ -37,11 +38,11 @@ const AddRepository:React.FC<{}> = (props) => {
if (params['applyMember']) {
params['applyMember'] = params['applyMember']
}
if(!params['isAllMemberShare'] && !params['applyMember']?.length) {
message.error('请选择指定会员')
if (!params['isAllMemberShare'] && !params['applyMember']?.length) {
message.error(intl.formatMessage({ id: 'repositories.addRepository.error' }))
} else {
addSchemaAction.getFieldState('warehouseId', prevState => {
if(prevState.value) {
if (prevState.value) {
params['warehouseName'] = prevState.props.enum.filter((item: any) => item.value === prevState.value)[0]['label']
}
})
......@@ -49,7 +50,7 @@ const AddRepository:React.FC<{}> = (props) => {
params['shopIds'] = state.value.map(item => state.props['x-component-props'].dataSource.filter(_ => _.id === item)[0])
})
let res = await postProductFreightSpaceAdd(params)
if(res.code === 1000) {
if (res.code === 1000) {
setTimeout(() => {
history.goBack(-1)
}, 1000)
......@@ -60,22 +61,22 @@ const AddRepository:React.FC<{}> = (props) => {
return (
<PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回"/>}
backIcon={<ReutrnEle description={intl.formatMessage({ id: 'repositories.addRepository.back' })} />}
className='addRepository'
title={pageStatus === PageStatus.PREVIEW ? '查看仓位' : '新增仓位'}
title={pageStatus === PageStatus.PREVIEW ? intl.formatMessage({ id: 'repositories.addRepository.title.1' }) : intl.formatMessage({ id: 'repositories.addRepository.title.2' })}
extra={(
pageStatus !== PageStatus.PREVIEW
pageStatus !== PageStatus.PREVIEW
? (
<Button key="1" onClick={() => addSchemaAction.submit()} type="primary" icon={<SaveOutlined />}>
保存
{intl.formatMessage({ id: 'repositories.addRepository.extra' })}
</Button>
)
)
: null
)}
>
<Card className=''>
{/* <WrapperLayout> */}
<PositionSetting addSchemaAction={addSchemaAction} schema={repositDetailSchema} formSubmit={formSubmit}/>
<PositionSetting addSchemaAction={addSchemaAction} schema={repositDetailSchema} formSubmit={formSubmit} />
{/* </WrapperLayout> */}
</Card>
</PageHeaderWrapper>
......
This diff is collapsed.
import React from 'react'
import { history } from 'umi'
import { history, useIntl } from 'umi'
import { Button, Card, message } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import {
......@@ -15,20 +15,21 @@ import { postProductFreightSpaceAddBatch } from '@/services/ProductV2Api'
const addSchemaAction = createFormActions()
const BatchAddRepository:React.FC<{}> = (props) => {
const BatchAddRepository: React.FC<{}> = (props) => {
const intl = useIntl();
const {
pageStatus
} = usePageStatus()
// 整体表单提交
const formSubmit = async (values) => {
const params = {...values}
const params = { ...values }
console.log(params, 'params')
if (params['applyMember']) {
params['applyMember'] = params['applyMember']
}
if (params['commodityList']) {
params['commodityList'] = params['commodityList'].map(item =>({
params['commodityList'] = params['commodityList'].map(item => ({
productId: item.id,
productName: item.name,
category: item.customerCategoryName,
......@@ -39,11 +40,11 @@ const BatchAddRepository:React.FC<{}> = (props) => {
goodsName: item?.goodsName || null,
}))
}
if(!params['isAllMemberShare'] && !params['applyMember']?.length) {
message.error('请选择指定会员')
if (!params['isAllMemberShare'] && !params['applyMember']?.length) {
message.error(intl.formatMessage({ id: 'repositories.batchAddRepository.error' }))
} else {
addSchemaAction.getFieldState('warehouseId', prevState => {
if(prevState.value) {
if (prevState.value) {
params['warehouseName'] = prevState.props.enum.filter((item: any) => item.value === prevState.value)[0]['label']
}
})
......@@ -51,7 +52,7 @@ const BatchAddRepository:React.FC<{}> = (props) => {
params['shopIds'] = state.value.map(item => state.props['x-component-props'].dataSource.filter(_ => _.id === item)[0])
})
let res = await postProductFreightSpaceAddBatch(params)
if(res.code === 1000) {
if (res.code === 1000) {
setTimeout(() => {
history.goBack(-1)
}, 1000)
......@@ -62,22 +63,22 @@ const BatchAddRepository:React.FC<{}> = (props) => {
return (
<PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回"/>}
backIcon={<ReutrnEle description={intl.formatMessage({ id: 'repositories.batchAddRepository.back' })} />}
className='addRepository'
title={pageStatus === PageStatus.PREVIEW ? '查看仓位' : '批量新增仓位'}
title={pageStatus === PageStatus.PREVIEW ? intl.formatMessage({ id: 'repositories.batchAddRepository.title.1' }) : intl.formatMessage({ id: 'repositories.batchAddRepository.title.2' })}
extra={(
pageStatus !== PageStatus.PREVIEW
pageStatus !== PageStatus.PREVIEW
? (
<Button key="1" onClick={() => addSchemaAction.submit()} type="primary" icon={<SaveOutlined />}>
保存
{intl.formatMessage({ id: 'repositories.batchAddRepository.extra' })}
</Button>
)
)
: null
)}
>
<Card className=''>
{/* <WrapperLayout> */}
<BatchPositionSetting addSchemaAction={addSchemaAction} schema={batchRepositDetailSchema} formSubmit={formSubmit}/>
<BatchPositionSetting addSchemaAction={addSchemaAction} schema={batchRepositDetailSchema} formSubmit={formSubmit} />
{/* </WrapperLayout> */}
</Card>
</PageHeaderWrapper>
......
import React, { useRef } from 'react';
import { history } from 'umi';
import { history, useIntl } from 'umi';
import { Button, Card, message, Space, Tooltip } from 'antd';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { PlusOutlined, QuestionCircleOutlined } from '@ant-design/icons';
......@@ -23,13 +23,13 @@ const formActions = createFormActions();
const modalSchemaAction = createFormActions()
const fetchData = async (params: any) => {
if(params?.category) {
if (params?.category) {
formActions.getFieldState('category', state => {
let categorys = treeReduction(state.props['x-component-props'].dataoption)
params.category = categorys[params.category]['title']
})
}
if(params?.brand) {
if (params?.brand) {
formActions.getFieldState('brand', state => {
let brands = state.props['x-component-props'].dataoption
params.brand = brands.filter(i => i.id === params.brand)[0].name
......@@ -40,19 +40,20 @@ const fetchData = async (params: any) => {
};
const Repositories: React.FC<{}> = () => {
const intl = useIntl();
const ref = useRef<any>({});
const modalRef = useRef<any>({})
const [rowSelection, RowCtl] = useRowSelectionTable({ customKey: 'id' });
const { run, loading } = useHttpRequest(postProductFreightSpaceUpdateBatch, {ctlType: 'none'})
const { run, loading } = useHttpRequest(postProductFreightSpaceUpdateBatch, { ctlType: 'none' })
const columns: ColumnType<any>[] = [
{
title: '仓位ID',
title: intl.formatMessage({ id: 'repositories.columns.id' }),
dataIndex: 'id',
key: 'id',
},
{
title: '仓位名称',
title: intl.formatMessage({ id: 'repositories.columns.name' }),
dataIndex: 'name',
key: 'name',
render: (text: any, record: any) => (
......@@ -64,47 +65,47 @@ const Repositories: React.FC<{}> = () => {
),
},
{
title: '商品名称',
title: intl.formatMessage({ id: 'repositories.columns.productName' }),
dataIndex: 'productName',
key: 'productName',
},
{
title: '品类',
title: intl.formatMessage({ id: 'repositories.columns.category' }),
dataIndex: 'category',
key: 'category',
},
{
title: '品牌',
title: intl.formatMessage({ id: 'repositories.columns.brand' }),
dataIndex: 'brand',
key: 'brand',
},
{
title: '单位',
title: intl.formatMessage({ id: 'repositories.columns.unit' }),
dataIndex: 'unit',
key: 'unit',
},
{
title: '现有库存',
title: intl.formatMessage({ id: 'repositories.columns.inventory' }),
dataIndex: 'inventory',
key: 'inventory',
},
{
title: '已用库存',
title: intl.formatMessage({ id: 'repositories.columns.alreadyiInventory' }),
dataIndex: 'alreadyiInventory',
key: 'alreadyiInventory',
},
{
title: '供应会员',
title: intl.formatMessage({ id: 'repositories.columns.upperMemberName' }),
dataIndex: 'upperMemberName',
key: 'upperMemberName',
},
{
title: '供应库存',
title: intl.formatMessage({ id: 'repositories.columns.upperStockCount' }),
dataIndex: 'upperStockCount',
key: 'upperStockCount',
},
{
title: '仓位状态',
title: intl.formatMessage({ id: 'repositories.columns.status' }),
dataIndex: 'status',
key: 'status',
render: (text: any, record: any) => (
......@@ -116,14 +117,14 @@ const Repositories: React.FC<{}> = () => {
),
},
{
title: '操作',
title: intl.formatMessage({ id: 'repositories.columns.option' }),
dataIndex: 'option',
render: (text: any, record: any) => {
return (
<>
{record.state === 1 ? (
<Button type="link" onClick={() => handleAdjust(record)}>
库存调拨
{intl.formatMessage({ id: 'repositories.columns.option.button' })}
</Button>
) : (
''
......@@ -150,11 +151,11 @@ const Repositories: React.FC<{}> = () => {
required: true,
enum: [
{
label: '直接修改仓位库存(默认)',
label: intl.formatMessage({ id: 'repositories.modalSchema.type.1' }),
value: 1
},
{
label: '按比率调整仓位库存',
label: intl.formatMessage({ id: 'repositories.modalSchema.type.2' }),
value: 2
}
],
......@@ -174,38 +175,38 @@ const Repositories: React.FC<{}> = () => {
},
inventoryAmount: {
type: 'number',
title: '{{help("仓位库存", "输入仓位库存后,点击确定,将用新输入的仓位库存批量调整原仓位库存")}}',
title: `{{help(${intl.formatMessage({ id: 'repositories.modalSchema.inventoryAmount' })})}}`,
"x-component-props": {
placeholder: "请填写仓位库存",
placeholder: intl.formatMessage({ id: 'repositories.modalSchema.inventoryAmount.placeholder' }),
style: { width: '100%' }
},
'x-rules': [
{
required: true,
message: '请填写仓位库存',
message: intl.formatMessage({ id: 'repositories.modalSchema.inventoryAmount.message.1' }),
},
{
pattern: /^\d+(\.\d{1,3})?$/,
message: '仅限三位小数',
message: intl.formatMessage({ id: 'repositories.modalSchema.inventoryAmount.message.1' }),
}
],
},
inventoryRate: {
type: 'string',
title: '{{help("仓位库存调整比率", "输入百分比,即按原仓位库存调增百分或调减百分比,调减请输入负值")}}',
title: `{{help(${intl.formatMessage({ id: 'repositories.modalSchema.inventoryRate' })})}}`,
"x-component-props": {
placeholder: "请填写仓位库存",
placeholder: intl.formatMessage({ id: 'repositories.modalSchema.inventoryRate.placeholder' }),
style: { width: '100%' },
suffix: '%'
},
'x-rules': [
{
required: true,
message: '请填写仓位库存调整比率',
message: intl.formatMessage({ id: 'repositories.modalSchema.inventoryRate.message.1' }),
},
{
pattern: /^[+-]?\d*(\.\d{0,3})?$/,
message: '请填写数值,最多保留3位小数',
message: intl.formatMessage({ id: 'repositories.modalSchema.inventoryRate.message.2' }),
},
],
},
......@@ -247,11 +248,11 @@ const Repositories: React.FC<{}> = () => {
}
const handleSubmit = async (value) => {
if(!RowCtl.selectedRowKeys.length) {
return message.error('请先选择仓位')
if (!RowCtl.selectedRowKeys.length) {
return message.error(intl.formatMessage({ id: 'repositories.error' }))
}
const { code } = await run({...value, inventory: value?.inventoryAmount || value?.inventoryRate, idList: RowCtl.selectedRowKeys})
if(code === 1000) {
const { code } = await run({ ...value, inventory: value?.inventoryAmount || value?.inventoryRate, idList: RowCtl.selectedRowKeys })
if (code === 1000) {
modalRef.current.setVisible(false)
RowCtl.setSelectedRowKeys([])
setTimeout(() => {
......@@ -286,10 +287,10 @@ const Repositories: React.FC<{}> = () => {
onClick={handleToAdd}
icon={<PlusOutlined />}
>
新建
{intl.formatMessage({ id: 'repositories.controllerBtns.button.1' })}
</Button>
<Button onClick={handleBatchAdd}>批量新建</Button>
<Button onClick={() => modalRef.current.setVisible(true)}>批量修改</Button>
<Button onClick={handleBatchAdd}>{intl.formatMessage({ id: 'repositories.controllerBtns.button.2' })}</Button>
<Button onClick={() => modalRef.current.setVisible(true)}>{intl.formatMessage({ id: 'repositories.controllerBtns.button.3' })}</Button>
</Space>
return (
......@@ -328,7 +329,7 @@ const Repositories: React.FC<{}> = () => {
/>
</Card>
<ModalForm
modalTitle='批量修改仓位库存'
modalTitle={intl.formatMessage({ id: 'repositories.modalForm' })}
previewPlaceholder=' '
currentRef={modalRef}
schema={modalSchema}
......
This diff is collapsed.
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