Commit c66800e3 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏
parents b83bb669 7eee52fa
......@@ -2,7 +2,7 @@
* @Author: LeeJiancong
* @Date: 2020-07-13 14:08:50
* @LastEditors: LeeJiancong
* @LastEditTime: 2020-07-18 18:56:08
* @LastEditTime: 2020-08-19 15:39:49
*/
import CommodityRoute from './commodityRoute' // 商品能力路由
import MemberRoute from './memberRoute' // 会员能力路由
......@@ -10,8 +10,9 @@ import ShopRoute from './shopRoute' // 店铺能力路由
import ChannelRoute from './channelRoute' // 渠道能力路由
import TranactionRoute from './tranactionRoute' // 交易能力路由
import LogisticsRoute from './logisticsRoutes' // 物流能力路由
import PayandSettleRoute from './payandSettle' //支付与结算
const routes = [CommodityRoute, MemberRoute, ShopRoute, ChannelRoute, TranactionRoute, LogisticsRoute]
const routes = [CommodityRoute, MemberRoute, ShopRoute, ChannelRoute, TranactionRoute,PayandSettleRoute ,LogisticsRoute]
const memberCenterRoute = {
path: '/memberCenter',
......
/*
* @Author: LeeJiancong
* @Date: 2020-07-13 14:36:02
* @LastEditors: LeeJiancong
* @Copyright: 1549414730@qq.com
* @LastEditTime: 2020-08-19 15:34:24
*/
/*
* @Author: Ljc
* @Date: 2020-07-10 16:15:28
* @Last Modified by: ljc
......
/*
* @Author: LeeJiancong
* @Date: 2020-08-19 15:33:27
* @LastEditors: LeeJiancong
* @Copyright: 1549414730@qq.com
* @LastEditTime: 2020-08-20 10:22:11
*/
const payandSettleRoute = {
path:'/memberCenter/payandSettle',
name:'payandSettle',
icon:'smile',
routes:[
{
path:'/memberCenter/payandSettle/paySetting',
name:'paySetting',
key:'paySetting',
routes:[
{
path:'/memberCenter/payandSettle/paySetting/payParamsSetting',
name:'payParamsSetting',
key:'payParamsSetting',
component:'@/pages/payandSettle/paySetting'
}
]
}
]
}
export default payandSettleRoute
\ No newline at end of file
/*
* @Author: LeeJiancong
* @Date: 2020-07-17 18:01:43
* @LastEditors: LeeJiancong
* @Copyright: 1549414730@qq.com
* @LastEditTime: 2020-08-19 17:24:16
*/
/**
* 用于在项目开始前获取所有的配置
* 在项目开始前运行`yarn scripts:build`
......@@ -44,6 +51,14 @@ const serviceConfig = {
// // }
// }
},
//初始化会员支付策略配置
payConfig:{
paymemberConfig:{
url:'/pay/member/pay/config',
method: 'get'
}
}
}
......@@ -68,6 +83,7 @@ async function batchAxiosHttps() {
// }
// serverFn(asyncHttpQueue)
for (const item in serviceConfig) {
if(JSON.stringify(item) !== '{}'){
for (const subItem in serviceConfig[item]) {
try {
const data = await axios(serviceConfig[item][subItem])
......@@ -78,6 +94,7 @@ async function batchAxiosHttps() {
}
}
}
}
return isDemo ? Object.assign(asyncHttpQueue, await demoFetch()) : asyncHttpQueue
}
......
import React from 'react';
import { Table } from 'antd';
import classNames from 'classnames';
import { TableProps, TablePaginationConfig, ColumnType } from 'antd/lib/table';
import { PaginationProps } from 'antd/lib/pagination';
import styles from './index.less';
export interface StandardTableProps extends TableProps<any> {
pagination: TablePaginationConfig;
onPaginationChange?: (page: number, size: number) => void;
};
export default class StandardTable extends React.PureComponent<StandardTableProps> {
state = {
page: 1,
size: 10,
};
handlePaginationChange = (page: number, size: number) => {
const { pagination = {}, onPaginationChange } = this.props;
const { current, pageSize } = pagination;
// 内部自己维护 page、size, 单独控制当前页 或 当前页数
if (!('current' in pagination)) {
this.setState({ page: current });
}
if (!('pageSize' in pagination)) {
this.setState({ size: pageSize });
}
if (onPaginationChange) {
onPaginationChange(page, size);
}
};
render() {
const { page, size } = this.state;
const {
columns,
dataSource,
rowKey = 'id',
pagination = {},
loading,
className,
onPaginationChange,
...restProps
} = this.props;
const newPagination: any = pagination ? {
current: page,
pageSize: size,
showSizeChanger: true,
showQuickJumper: true,
onChange: this.handlePaginationChange,
onShowSizeChange: this.handlePaginationChange,
size: 'small',
showTotal: () => `共 ${pagination.total || 0} 条`,
...pagination,
} : false;
return (
<div className={classNames(className)}>
<Table
rowKey={rowKey}
columns={columns}
dataSource={dataSource}
loading={loading}
pagination={newPagination}
{...restProps}
/>
</div>
)
}
}
\ No newline at end of file
......@@ -21,3 +21,8 @@ export const Environment_Status = {
// 1是阿里云oss服务器, 2是本地文件服务器
export const UPLOAD_TYPE = isDev ? 2 : 1
// 会员规则类型
export const VIP_RULE_TRANSACTION = 1; // 交易
export const VIP_RULE_LOGIN = 2; // 登录
export const VIP_RULE_COMMENT = 3; // 评论
export interface MemberType {
id: number;
typeName: string;
}
export interface BusinessType {
id: number;
typeName: string;
}
export interface UseType {
memberType: MemberType[];
businessType: BusinessType[];
}
export interface UserRegister {
useType: UseType;
}
export interface ShopInfo {
id: number;
name: string;
type: number;
environment: number;
logoUrl: string;
describe: string;
state: number;
url: string;
}
export interface Web {
shopInfo: ShopInfo[];
}
export interface CountryList {
name: string;
key: string;
icon: string;
}
export interface Global {
siteId: number;
siteUrl: string;
logo: string;
countryList: CountryList[];
}
export interface RootObject {
userRegister: UserRegister;
web: Web;
global: Global;
}
\ No newline at end of file
......@@ -240,3 +240,27 @@ h6 {
}
}
}
// 可编辑表格项公用样式
.editable-cell {
position: relative;
}
.editable-cell-value-wrap {
padding: 5px 12px;
min-height: 32px;
cursor: pointer;
}
.editable-row:hover
.editable-cell-value-wrap {
border: 1px solid #d9d9d9;
border-radius: 4px;
padding: 4px 11px;
}
.editable-row .ant-form-explain {
position: absolute;
font-size: 12px;
margin-top: -4px;
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
* @Author: LeeJiancong
* @Date: 2020-07-13 14:08:50
* @LastEditors: LeeJiancong
* @LastEditTime: 2020-07-28 11:31:13
* @LastEditTime: 2020-08-20 10:22:52
*/
export default {
......@@ -115,4 +115,8 @@ export default {
'menu.logisticsAbility.logisticsResult.orderResultSearchList': '物流单查询',
'menu.logisticsAbility.logisticsResult.orderResultDeatil': '物流单详情',
'menu.logisticsAbility.logisticsResult.toOrderComfirmList': '待确认物流单',
'menu.payandSettle': '支付',
'menu.payandSettle.paySetting': '支付方式管理',
'menu.payandSettle.paySetting.payParamsSetting': '会员支付参数配置',
};
\ No newline at end of file
......@@ -2,7 +2,7 @@
* @Author: LeeJiancong
* @Date: 2020-07-14 15:07:34
* @LastEditors: LeeJiancong
* @LastEditTime: 2020-08-19 10:53:33
* @LastEditTime: 2020-08-20 16:45:16
*/
import React, { Component, ReactNode, useRef, useState } from 'react'
import { history } from 'umi'
......@@ -122,7 +122,7 @@ const AddressList: React.FC<ListProps> = (props) => {
const [table, setTable] = useState([])
const [editingKey, setEditingKey] = useState('');
const toEdit = (id: number) => {
history.push(`/memberCenter/logisticsAbility/logistics/addressForm?type=${props.type}&id=${id}`)
history.push(`/memberCenter/logisticsAbility/logistics/addressForm?page_type=${props.type}&id=${id}`)
};
const columns: ColumnType<any>[] = [
{
......@@ -280,7 +280,7 @@ const AddressList: React.FC<ListProps> = (props) => {
formilyChilds={{
children: (
<>
<Button type="primary" icon={<PlusOutlined />} onClick={() => history.push(`/memberCenter/logisticsAbility/logistics/addressForm?type=${props.type}&id=0`)}>新建</Button>
<Button type="primary" icon={<PlusOutlined />} onClick={() => history.push(`/memberCenter/logisticsAbility/logistics/addressForm?page_type=${props.type}&id=0`)}>新建</Button>
</>
)
}}
......
import React, { useState, useRef, ReactNode } from 'react';
import { history } from 'umi';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { Card, Input, Button } from 'antd';
import { ContainerOutlined } from '@ant-design/icons';
import { StandardTable } from 'god';
import React, { useContext, useState, useEffect, useRef } from 'react';
import {
Card,
Input,
Button,
Form,
message,
} from 'antd';
import { ColumnType } from 'antd/lib/table/interface';
import { PublicApi } from '@/services/api';
import { VIP_RULE_TRANSACTION, VIP_RULE_LOGIN, VIP_RULE_COMMENT } from '@/constants';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { ContainerOutlined } from '@ant-design/icons';
import StandardTable from '@/components/StandardTable';
const fetchData = async (params: any) => {
const res = await PublicApi.getMemberManageLevelRulePage(params);
return res.data;
const EditableContext = React.createContext<any>({});
interface EditableRowProps {
index: number;
}
const EditableRow: React.FC<EditableRowProps> = ({ index, ...props }) => {
const [form] = Form.useForm();
return (
<Form form={form} component={false}>
<EditableContext.Provider value={form}>
<tr {...props} />
</EditableContext.Provider>
</Form>
);
};
interface EditableCellProps {
title: React.ReactNode;
editable: boolean;
children: React.ReactNode;
dataIndex: string;
index: number;
record: any;
rules: any;
handleSave: (record: any) => void;
addonAfter: React.ReactNode,
}
const EditableCell: React.FC<EditableCellProps> = ({
title,
editable,
children,
dataIndex,
index,
record,
rules = [],
addonAfter = null,
handleSave,
...restProps
}) => {
const [editing, setEditing] = useState(true);
const inputRef = useRef();
const form = useContext(EditableContext);
const inputId = `${dataIndex}-${index}`; // 拼接 name-index,不然全部展示输入框会警告 id 不唯一的问题
useEffect(() => {
if (editing) {
// inputRef.current.focus();
}
}, [editing]);
const toggleEdit = () => {
setEditing(!editing);
form.setFieldsValue({ [dataIndex]: record[dataIndex] });
};
const save = async e => {
try {
const values = await form.validateFields();
// toggleEdit();
handleSave({
...record,
[dataIndex]: values[inputId],
});
} catch (errInfo) {
console.log('Save failed:', errInfo);
}
};
let childNode = children;
if (editable) {
childNode = editing ? (
<Form.Item
style={{ margin: 0 }}
name={inputId}
rules={rules}
initialValue={record[dataIndex]}
>
<Input
ref={inputRef}
onPressEnter={save}
onBlur={save}
addonAfter={addonAfter}
/>
</Form.Item>
) : (
<div
className="editable-cell-value-wrap"
style={{ paddingRight: 24 }} onClick={toggleEdit}
>
{children}
</div>
);
}
return <td {...restProps}>{childNode}</td>;
};
interface Columns extends ColumnType<any> {
editable?: boolean;
rules?: Array<any>;
}
const MemberUpgradeRule: React.FC<[]> = () => {
const ref = useRef({});
const columns: ColumnType<any>[] = [
const [page, setPage] = useState(1);
const [size, setSize] = useState(10);
const [total, setTotal] = useState(0);
const [dataSource, setDataSource] = useState([]);
const [listLoading, setListLoading] = useState(true);
const [submitLoading, setSubmitLoading] = useState(false);
const getRuleList = async (params) => {
setListLoading(true);
const res = await PublicApi.getMemberManageLevelRulePage(params);
if (res.code === 1000) {
const { data, totalCount } = res.data;
setDataSource(data);
setTotal(totalCount);
}
setListLoading(false);
};
useEffect(() => {
getRuleList({
current: page,
pageSize: size,
});
}, [page, size]);
const columns: Columns[] = [
{
title: 'ID',
dataIndex: 'id',
align: 'center',
key: 'id',
},
{
title: '项目',
dataIndex: 'ruleName',
align: 'center',
key: 'ruleName',
render: (text: any, record: any) => <span>{text}</span>,
},
{
title: '项目说明',
dataIndex: 'remark',
align: 'center',
key: 'remark',
},
{
title: '可获取的分值',
dataIndex: 'point',
align: 'center',
key: 'point',
render: (text: any, record: any) => {
let component: ReactNode = null;
component =
record.id === 1 ? (
<Input
addonAfter="%"
value={record.point}
onChange={e => {
e.preventDefault();
record.point = e.target.value;
}}
/>
) : (
<Input value={record.point} />
);
return component;
},
width: '30%',
editable: true,
},
];
const handleSubmit = () => {};
const handlePaginationChange = (page: number, size: number) => {
setPage(page);
setSize(size);
};
// 重新保存 dataSource
const handleSave = row => {
const newData = [...dataSource];
const index = newData.findIndex(item => item.id === row.id);
const item = newData[index];
newData.splice(index, 1, {
...item,
...row,
point: +row.point,
});
setDataSource(newData);
};
const handleSubmit = async () => {
if (!dataSource.length) {
return;
}
const payload = dataSource.map(item => ({
id: item.id,
point: item.point,
}));
setSubmitLoading(true);
const res = await PublicApi.postMemberManageLevelRuleSetpoint(payload);
if (res.code === 1000) {
message.success('保存成功');
getRuleList({
current: page,
pageSize: size,
});
}
setSubmitLoading(false);
};
const components = {
body: {
row: EditableRow,
cell: EditableCell,
},
};
const rulesMap = {
[VIP_RULE_TRANSACTION]: [
{
pattern: /^([0]|[1-9]+[0-9]*)(\.[0-9]+)?$/,
message: '请输入正确的格式',
},
],
[VIP_RULE_LOGIN]: [
{
pattern: /^[0]$|^[1-9]+[0-9]*$/,
message: '请输入正确的格式',
},
],
[VIP_RULE_COMMENT]: [
{
pattern: /^[0]$|^[1-9]+[0-9]*$/,
message: '请输入正确的格式',
},
],
};
const newColumns: any = columns.map(col => {
if (!col.editable) {
return col;
}
return {
...col,
onCell: (record, index) => ({
handleSave,
record,
index,
dataIndex: col.dataIndex,
title: col.title,
editable: col.editable || false,
rules: [
{
required: true,
message: '请输入相应值',
},
...(rulesMap[record.ruleTypeEnum] || []),
],
addonAfter: record.ruleTypeEnum === VIP_RULE_TRANSACTION ? '%' : null,
}),
};
});
return (
<PageHeaderWrapper
......@@ -68,6 +272,7 @@ const MemberUpgradeRule: React.FC<[]> = () => {
<Button
type="primary"
icon={<ContainerOutlined />}
loading={submitLoading}
onClick={handleSubmit}
>
保存
......@@ -75,11 +280,23 @@ const MemberUpgradeRule: React.FC<[]> = () => {
}
>
<Card>
<div className="editable-row">
<div className="ant-form-explain">
123
</div>
</div>
<StandardTable
tableProps={{ rowKey: 'id' }}
columns={columns}
currentRef={ref}
fetchTableData={(params: any) => fetchData(params)}
dataSource={dataSource}
columns={newColumns}
components={components}
rowClassName={() => 'editable-row'}
loading={listLoading}
pagination={{
pageSize: size,
total,
}}
onPaginationChange={handlePaginationChange}
/>
</Card>
</PageHeaderWrapper>
......
.radio-group-box {
.ant-radio-button-wrapper {
width: 80px;
text-align: center;
}
}
\ No newline at end of file
import React, { Component, useState, useEffect } from 'react';
import { Modal, Button, Form,Radio } from 'antd'
import {
SchemaForm, SchemaMarkupField as Field,
createFormActions,
FormEffectHooks
} from '@formily/antd'
import { Input, FormMegaLayout } from '@formily/antd-components'
import { PublicApi } from '@/services/api'
export interface Params {
id?: any,
mode:number,
type?: number|string,
dialogVisible: boolean;
onCancel: Function;
onOK?: Function;
initialValues?: any;
dontReceive?: boolean; //默认展示
}
const actions = createFormActions()
const { onFieldChange$ } = FormEffectHooks
const comfirmDialog: React.FC<Params> = (props) => {
const handleCancel = () => {
}
const handletOk = (values: any) => {
let value = { ...values }
if(props.type){
value.type = props.type
}
console.log('列表',value)
props.onOK(value)
}
useEffect(() => {
return () => {
}
}, [])
const useFormEffects = () => {
const { setFieldState } = createFormActions()
}
return (
<>
<Modal
title={ props.mode === 0 ?'新增参数配置':'编辑参数配置'}
width={800}
visible={props.dialogVisible}
onOk={() => actions.submit()}
onCancel={() => props.onCancel()}
destroyOnClose
afterClose={() => actions.reset()}
okText={`确定`}
cancelText='取消'
>
<SchemaForm
labelCol={3}
components={{
Input, Radio: Radio.Group, TextArea: Input.TextArea
}}
actions={actions}
effects={() => useFormEffects()}
onSubmit={(values) => handletOk(values)}
initialValues={
props.initialValues
}
>
<Field
name='code'
title='参数代码'
required
x-component-props={{
placeholder: '',
}}
x-component="Input"
/>
<>
<Field
title='参数值'
name="value"
x-component="Input"
required
x-component-props={{
placeholder: '',
// addonBefore: ' '
}}
x-rules={{
message: ''
}}
/>
{/* <FormMegaLayout name='remarkOption' label='不接受原因' full required labelCol={2} labelAlign="top"> */}
<Field
title='参数描述'
name="describe"
x-component="TextArea"
x-component-props={{
placeholder: '最长128个字符'
}}
x-rules={{
max: 128,
// maximum:10,//最大数值
// message: '参数描述最多128个汉字'
}}
/>
</>
</SchemaForm>
</Modal>
</>
)
}
comfirmDialog.defaultProps = {
dontReceive: true,
type:1 //1.支付宝 2.支付宝转账到银行卡参数配置 3.微信
}
export default comfirmDialog
\ No newline at end of file
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