- 添加 签名、短信模板

This commit is contained in:
sin-ning@aliyun.com 2019-05-27 00:23:52 +08:00
parent c3206ec5f4
commit 5c68383abb
10 changed files with 514 additions and 630 deletions

View File

@ -0,0 +1,56 @@
import { pageTemplate, addTemplate, updateTemplate, deletedTemplate } from '../../services/sms';
export default {
namespace: 'smsTemplateList',
state: {
list: [],
},
effects: {
*page({ payload }, { call, put }) {
const response = yield call(pageTemplate, payload);
if (response.code === 0) {
yield put({
type: 'pageSuccess',
payload: response.data,
});
}
},
*add({ payload }, { call }) {
const { params, callback } = payload;
const response = yield call(addTemplate, params);
if (response.code === 0) {
if (callback) {
callback(response);
}
}
},
*update({ payload }, { call }) {
const { params, callback } = payload;
const response = yield call(updateTemplate, params);
if (response.code === 0) {
if (callback) {
callback(response);
}
}
},
*deleted({ payload }, { call }) {
const { params, callback } = payload;
const response = yield call(deletedTemplate, params);
if (callback) {
callback(response);
}
},
},
reducers: {
pageSuccess(state, { payload }) {
const { data } = payload;
return {
...state,
list: data,
};
},
},
};

View File

@ -7,7 +7,7 @@ import DictionaryText from '../../components/Dictionary/DictionaryText';
import dictionary from '../../utils/dictionary';
import styles from '../List/TableList.less';
import SignListSearch from './SignListSearch';
import SignListUpdate from './SignListUpdate';
import SignListModal from './SignListModal';
@connect(({ smsSignList, loading }) => ({
smsSignList,
@ -26,7 +26,7 @@ class SignList extends PureComponent {
// init page 参数
this.current = 1;
this.total = 0;
this.size = 20;
this.size = 10;
this.searchParams = {};
// 查询 page
@ -80,7 +80,6 @@ class SignList extends PureComponent {
okText: '确认',
cancelText: '取消',
onOk: () => {
console.log('OK');
dispatch({
type: 'smsSignList/deleted',
payload: {
@ -249,7 +248,7 @@ class SignList extends PureComponent {
/>
</Card>
<SignListUpdate
<SignListModal
initData={sign}
title={title}
visible={visible}

View File

@ -1,313 +1,2 @@
@import '~antd/lib/style/themes/default.less';
@import '~@/utils/utils.less';
.standardList {
:global {
.ant-card-head {
border-bottom: none;
}
.ant-card-head-title {
padding: 24px 0;
line-height: 32px;
}
.ant-card-extra {
padding: 24px 0;
}
.ant-list-pagination {
margin-top: 24px;
text-align: right;
}
.ant-avatar-lg {
width: 48px;
height: 48px;
line-height: 48px;
}
}
.headerInfo {
position: relative;
text-align: center;
& > span {
display: inline-block;
margin-bottom: 4px;
color: @text-color-secondary;
font-size: @font-size-base;
line-height: 22px;
}
& > p {
margin: 0;
color: @heading-color;
font-size: 24px;
line-height: 32px;
}
& > em {
position: absolute;
top: 0;
right: 0;
width: 1px;
height: 56px;
background-color: @border-color-split;
}
}
.listContent {
display: flex;
flex: 1;
flex-direction: row;
font-size: 0;
.listContentItem {
flex: 1;
margin-left: 40px;
color: @text-color-secondary;
font-size: @font-size-base;
vertical-align: middle;
> span {
line-height: 20px;
}
> p {
margin-top: 4px;
margin-bottom: 0;
line-height: 22px;
}
}
}
.extraContentSearch {
width: 272px;
margin-left: 16px;
}
}
@media screen and (max-width: @screen-xs) {
.standardList {
:global {
.ant-list-item-content {
display: block;
flex: none;
width: 100%;
}
.ant-list-item-action {
margin-left: 0;
}
}
.listContent {
margin-left: 0;
& > div {
margin-left: 0;
}
}
.listCard {
:global {
.ant-card-head-title {
overflow: visible;
}
}
}
}
}
@media screen and (max-width: @screen-sm) {
.standardList {
.extraContentSearch {
width: 100%;
margin-left: 0;
}
.headerInfo {
margin-bottom: 16px;
& > em {
display: none;
}
}
}
}
@media screen and (max-width: @screen-md) {
.standardList {
.listContent {
& > div {
display: block;
}
& > div:last-child {
top: 0;
width: 100%;
}
}
}
.listCard {
:global {
.ant-radio-group {
display: block;
margin-bottom: 8px;
}
}
}
}
@media screen and (max-width: @screen-lg) and (min-width: @screen-md) {
.standardList {
.listContent {
& > div {
display: block;
}
& > div:last-child {
top: 0;
width: 100%;
}
}
}
}
@media screen and (max-width: @screen-xl) {
.standardList {
.listContent {
& > div {
margin-left: 24px;
}
& > div:last-child {
top: 0;
}
}
}
}
@media screen and (max-width: 1400px) {
.standardList {
.listContent {
text-align: right;
& > div:last-child {
top: 0;
}
}
}
}
.standardListForm {
:global {
.ant-form-item {
margin-bottom: 12px;
&:last-child {
margin-bottom: 32px;
padding-top: 4px;
}
}
}
}
.formResult {
width: 100%;
[class^='title'] {
margin-bottom: 8px;
}
}
.tableListForm {
:global {
.ant-form-item {
display: flex;
margin-right: 0;
margin-bottom: 24px;
> .ant-form-item-label {
width: auto;
padding-right: 8px;
line-height: 32px;
}
.ant-form-item-control {
line-height: 32px;
}
}
.ant-form-item-control-wrapper {
flex: 1;
}
}
.submitButtons {
display: block;
margin-bottom: 24px;
white-space: nowrap;
}
}
@media screen and (max-width: @screen-lg) {
.tableListForm :global(.ant-form-item) {
margin-right: 24px;
}
}
@media screen and (max-width: @screen-md) {
.tableListForm :global(.ant-form-item) {
margin-right: 8px;
}
}
// 订单content
.orderGroup {
@padding-slid: 10px;
@solid-color: rgba(167, 157, 160, 0.92);
@header-background: rgba(210, 219, 238, 0.99);
display: flex;
flex: 1;
flex-direction: column;
justify-content: flex-start;
.header {
display: flex;
flex: 1;
justify-content: space-between;
padding-right: @padding-slid;
padding-left: @padding-slid;
font-weight: bold;
font-size: 15px;
line-height: 35px;
background-color: @header-background;
}
.goodsContainer {
:first-child {
border-top: none;
border-bottom: none;
}
:last-child {
border-bottom: none;
}
}
.orderGoods {
display: flex;
flex: 2;
flex-direction: row;
width: 500px;
border: 1px solid @solid-color;
}
.order {
display: flex;
flex: 1;
flex-direction: row;
padding-right: @padding-slid;
padding-left: @padding-slid;
line-height: 100px;
border: 1px solid @solid-color;
.contentItem {
display: flex;
flex: 1;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
> div {
line-height: 30px;
}
.columnName {
font-weight: bold;
font-size: 12px;
}
}
.image {
width: 80px;
height: 80px;
}
}
}

View File

@ -8,7 +8,7 @@ import dictionary from '../../utils/dictionary';
*
* @type {React.ComponentClass<RcBaseFormProps & Omit<FormComponentProps, keyof FormComponentProps>>}
*/
const SignListUpdate = Form.create()(props => {
const SignListModal = Form.create()(props => {
const { onOk, onCancel, visible, title, form, initData = {} } = props;
const { getFieldDecorator, validateFields } = props.form;
@ -57,7 +57,7 @@ const SignListUpdate = Form.create()(props => {
message: '请选择平台',
},
],
initialValue: `${initData.platform}`,
initialValue: initData.platform,
})(<DictionarySelect dicKey={dictionary.SMS_PLATFORM} />)}
</Form.Item>
</Form>
@ -65,4 +65,4 @@ const SignListUpdate = Form.create()(props => {
);
});
export default SignListUpdate;
export default SignListModal;

View File

@ -1,10 +1,272 @@
import React, { PureComponent } from 'react';
import { Card, Divider, Table, Modal, Button } from 'antd';
import { connect } from 'dva';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import DictionaryText from '../../components/Dictionary/DictionaryText';
import dictionary from '../../utils/dictionary';
import styles from '../List/TableList.less';
import TemplateListSearch from './TemplateListSearch';
import TemplateListModal from './TemplateListModal';
@connect(({ smsTemplateList, loading }) => ({
smsTemplateList,
loading: loading.models.smsTemplateList,
}))
class TemplateList extends PureComponent {
state = {
visible: false,
title: '添加模板', // 添加签名 修改签名
type: 'add', // add update
id: '',
sign: {},
};
componentDidMount() {
// init page 参数
this.current = 1;
this.total = 0;
this.size = 10;
this.searchParams = {};
// 查询 page
this.queryPage();
}
queryPage = () => {
const { dispatch } = this.props;
const { current, total, size, searchParams } = this;
dispatch({
type: 'smsTemplateList/page',
payload: {
current,
total,
size,
...searchParams,
},
});
};
handleSearch = searchParams => {
this.searchParams = searchParams;
this.queryPage();
};
handleAddShow = () => {
this.setState({
visible: true,
type: 'add',
title: '添加模板',
});
};
handleUpdateShow = sign => {
const { id } = sign;
this.setState({
visible: true,
type: 'update',
title: '更新模板',
id,
sign,
});
};
handleDeleted = ({ id, sign }) => {
const { dispatch } = this.props;
Modal.confirm({
title: `提示消息`,
content: `确认删除 ${sign} 签名吗`,
okText: '确认',
cancelText: '取消',
onOk: () => {
dispatch({
type: 'smsTemplateList/deleted',
payload: {
params: {
id,
},
callback: () => {
this.queryPage();
},
},
});
},
onCancel() {
console.log('Cancel');
},
});
};
handleCancel = () => {
this.setState({
visible: false,
});
};
handleOk = fields => {
const { dispatch } = this.props;
const { type, id } = this.state;
if (type === 'add') {
dispatch({
type: 'smsTemplateList/add',
payload: {
params: {
...fields,
},
callback: () => {
this.handleCancel();
this.queryPage();
},
},
});
} else if (type === 'update') {
dispatch({
type: 'smsTemplateList/update',
payload: {
params: {
id,
...fields,
},
callback: () => {
this.handleCancel();
this.queryPage();
},
},
});
}
};
handleTableChange = pagination => {
const { pageSize, current } = pagination;
this.size = pageSize;
this.current = current;
this.queryPage();
};
render() {
return <PageHeaderWrapper>template-list</PageHeaderWrapper>;
// props
const { loading, smsTemplateList } = this.props;
const { list, total, index, size } = smsTemplateList;
const { visible, title, type, sign } = this.state;
const columns = [
{
title: 'ID',
dataIndex: 'id',
key: 'id',
},
{
title: '签名',
dataIndex: 'sign',
key: 'sign',
// eslint-disable-next-line no-shadow
render({ sign }) {
return <div>{sign}</div>;
},
},
{
title: '签名',
dataIndex: 'template',
key: 'template',
},
{
title: '短信平台',
dataIndex: 'platform',
key: 'platform',
render(platform) {
return (
<div>
<DictionaryText dicKey={dictionary.SMS_PLATFORM} dicValue={platform} />
</div>
);
},
},
{
title: '审核状态',
dataIndex: 'applyStatus',
key: 'applyStatus',
render(applyStatus) {
return (
<div>
<DictionaryText dicKey={dictionary.SMS_APPLY_STATUS} dicValue={applyStatus} />
</div>
);
},
},
{
title: '更新时间',
dataIndex: 'updateTime',
key: 'updateTime',
width: 200,
render(updateTime) {
return <div>{updateTime}</div>;
},
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
width: 200,
render(createTime) {
return <div>{createTime}</div>;
},
},
{
title: '操作',
render: row => {
return (
<div>
<a onClick={this.handleUpdateShow.bind(this, row)}>修改</a>
<Divider type="vertical" />
<a onClick={this.handleDeleted.bind(this, row)}>删除</a>
</div>
);
},
},
];
const pagination = {
total,
index,
pageSize: size,
};
return (
<PageHeaderWrapper>
<Card>
<div className={styles.tableListForm}>
<TemplateListSearch handleSearch={this.handleSearch} />
</div>
<br />
<div>
<Button icon="plus" onClick={this.handleAddShow}>
添加签名
</Button>
</div>
<br />
<Table
loading={loading}
rowKey="id"
dataSource={list}
columns={columns}
pagination={pagination}
onChange={this.handleTableChange}
/>
</Card>
<TemplateListModal
initData={sign}
title={title}
visible={visible}
type={type}
onOk={this.handleOk}
onCancel={this.handleCancel}
/>
</PageHeaderWrapper>
);
}
}

View File

@ -1,313 +1,2 @@
@import '~antd/lib/style/themes/default.less';
@import '~@/utils/utils.less';
.standardList {
:global {
.ant-card-head {
border-bottom: none;
}
.ant-card-head-title {
padding: 24px 0;
line-height: 32px;
}
.ant-card-extra {
padding: 24px 0;
}
.ant-list-pagination {
margin-top: 24px;
text-align: right;
}
.ant-avatar-lg {
width: 48px;
height: 48px;
line-height: 48px;
}
}
.headerInfo {
position: relative;
text-align: center;
& > span {
display: inline-block;
margin-bottom: 4px;
color: @text-color-secondary;
font-size: @font-size-base;
line-height: 22px;
}
& > p {
margin: 0;
color: @heading-color;
font-size: 24px;
line-height: 32px;
}
& > em {
position: absolute;
top: 0;
right: 0;
width: 1px;
height: 56px;
background-color: @border-color-split;
}
}
.listContent {
display: flex;
flex: 1;
flex-direction: row;
font-size: 0;
.listContentItem {
flex: 1;
margin-left: 40px;
color: @text-color-secondary;
font-size: @font-size-base;
vertical-align: middle;
> span {
line-height: 20px;
}
> p {
margin-top: 4px;
margin-bottom: 0;
line-height: 22px;
}
}
}
.extraContentSearch {
width: 272px;
margin-left: 16px;
}
}
@media screen and (max-width: @screen-xs) {
.standardList {
:global {
.ant-list-item-content {
display: block;
flex: none;
width: 100%;
}
.ant-list-item-action {
margin-left: 0;
}
}
.listContent {
margin-left: 0;
& > div {
margin-left: 0;
}
}
.listCard {
:global {
.ant-card-head-title {
overflow: visible;
}
}
}
}
}
@media screen and (max-width: @screen-sm) {
.standardList {
.extraContentSearch {
width: 100%;
margin-left: 0;
}
.headerInfo {
margin-bottom: 16px;
& > em {
display: none;
}
}
}
}
@media screen and (max-width: @screen-md) {
.standardList {
.listContent {
& > div {
display: block;
}
& > div:last-child {
top: 0;
width: 100%;
}
}
}
.listCard {
:global {
.ant-radio-group {
display: block;
margin-bottom: 8px;
}
}
}
}
@media screen and (max-width: @screen-lg) and (min-width: @screen-md) {
.standardList {
.listContent {
& > div {
display: block;
}
& > div:last-child {
top: 0;
width: 100%;
}
}
}
}
@media screen and (max-width: @screen-xl) {
.standardList {
.listContent {
& > div {
margin-left: 24px;
}
& > div:last-child {
top: 0;
}
}
}
}
@media screen and (max-width: 1400px) {
.standardList {
.listContent {
text-align: right;
& > div:last-child {
top: 0;
}
}
}
}
.standardListForm {
:global {
.ant-form-item {
margin-bottom: 12px;
&:last-child {
margin-bottom: 32px;
padding-top: 4px;
}
}
}
}
.formResult {
width: 100%;
[class^='title'] {
margin-bottom: 8px;
}
}
.tableListForm {
:global {
.ant-form-item {
display: flex;
margin-right: 0;
margin-bottom: 24px;
> .ant-form-item-label {
width: auto;
padding-right: 8px;
line-height: 32px;
}
.ant-form-item-control {
line-height: 32px;
}
}
.ant-form-item-control-wrapper {
flex: 1;
}
}
.submitButtons {
display: block;
margin-bottom: 24px;
white-space: nowrap;
}
}
@media screen and (max-width: @screen-lg) {
.tableListForm :global(.ant-form-item) {
margin-right: 24px;
}
}
@media screen and (max-width: @screen-md) {
.tableListForm :global(.ant-form-item) {
margin-right: 8px;
}
}
// 订单content
.orderGroup {
@padding-slid: 10px;
@solid-color: rgba(167, 157, 160, 0.92);
@header-background: rgba(210, 219, 238, 0.99);
display: flex;
flex: 1;
flex-direction: column;
justify-content: flex-start;
.header {
display: flex;
flex: 1;
justify-content: space-between;
padding-right: @padding-slid;
padding-left: @padding-slid;
font-weight: bold;
font-size: 15px;
line-height: 35px;
background-color: @header-background;
}
.goodsContainer {
:first-child {
border-top: none;
border-bottom: none;
}
:last-child {
border-bottom: none;
}
}
.orderGoods {
display: flex;
flex: 2;
flex-direction: row;
width: 500px;
border: 1px solid @solid-color;
}
.order {
display: flex;
flex: 1;
flex-direction: row;
padding-right: @padding-slid;
padding-left: @padding-slid;
line-height: 100px;
border: 1px solid @solid-color;
.contentItem {
display: flex;
flex: 1;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
> div {
line-height: 30px;
}
.columnName {
font-weight: bold;
font-size: 12px;
}
}
.image {
width: 80px;
height: 80px;
}
}
}

View File

@ -0,0 +1,101 @@
import React from 'react';
import { Form, Input, Modal } from 'antd';
import DictionarySelect from '../../components/Dictionary/DictionarySelect';
import dictionary from '../../utils/dictionary';
/**
* table 查询
*
* @type {React.ComponentClass<RcBaseFormProps & Omit<FormComponentProps, keyof FormComponentProps>>}
*/
const SignListModal = Form.create()(props => {
const { onOk, onCancel, visible, title, form, initData = {} } = props;
const { getFieldDecorator, validateFields } = props.form;
function handleOk(e) {
e.preventDefault();
validateFields((err, fields) => {
const searchParams = fields;
if (onOk) {
onOk(searchParams);
form.resetFields();
}
});
}
function handleCancel() {
if (onCancel) {
onCancel();
}
}
const formItemLayout = {
labelCol: { span: 4 },
wrapperCol: { span: 18 },
};
return (
<Modal title={title} visible={visible} onOk={handleOk} onCancel={handleCancel}>
<Form>
<Form.Item {...formItemLayout} label="签名">
{getFieldDecorator('smsSignId', {
rules: [
{
required: true,
message: '请输入签名',
},
],
initialValue: initData.sign ? initData.sign.id : null,
})(<Input placeholder="请输入签名" />)}
</Form.Item>
<Form.Item {...formItemLayout} label="类型">
{getFieldDecorator('smsType', {
rules: [
{
required: true,
message: '请选择短信类型',
},
],
initialValue: initData.smsType,
})(<DictionarySelect placeholder="请选择短信类型" dicKey={dictionary.SMS_TYPE} />)}
</Form.Item>
<Form.Item {...formItemLayout} label="平台">
{getFieldDecorator('platform', {
rules: [
{
required: true,
message: '请选择平台',
},
],
initialValue: initData.platform,
})(<DictionarySelect placeholder="请选择平台" dicKey={dictionary.SMS_PLATFORM} />)}
</Form.Item>
<Form.Item {...formItemLayout} label="模板Code">
{getFieldDecorator('templateCode', {
rules: [
{
required: true,
message: '短信平台的Code',
},
],
initialValue: initData.templateCode,
})(<Input placeholder="第三方平台Code" />)}
</Form.Item>
<Form.Item {...formItemLayout} label="模板">
{getFieldDecorator('template', {
rules: [
{
required: true,
message: '请输入短信模板',
},
],
initialValue: initData.template,
})(<Input.TextArea placeholder="请输入模板" rows={4} />)}
</Form.Item>
</Form>
</Modal>
);
});
export default SignListModal;

View File

@ -0,0 +1,61 @@
import React from 'react';
import { Button, Col, Form, Input, Row } from 'antd';
const FormItem = Form.Item;
/**
* table 查询
*
* @type {React.ComponentClass<RcBaseFormProps & Omit<FormComponentProps, keyof FormComponentProps>>}
*/
const SignListSearch = Form.create()(props => {
const { handleSearch } = props;
const { getFieldDecorator, validateFields, form } = props.form;
function onSubmit(e) {
e.preventDefault();
validateFields((err, fields) => {
const searchParams = fields;
if (handleSearch) {
handleSearch(searchParams);
}
});
}
function handleFormReset() {
form.resetFields();
}
return (
<Form onSubmit={onSubmit} layout="inline">
<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
<Col md={8} sm={24}>
<FormItem label="编号">
{getFieldDecorator('id')(<Input placeholder="请输入ID" />)}
</FormItem>
</Col>
<Col md={8} sm={24}>
<FormItem label="签名">
{getFieldDecorator('smsSignId')(<Input placeholder="请输入签名" />)}
</FormItem>
</Col>
</Row>
<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
<Col md={8} sm={24}>
<span>
<Button type="primary" htmlType="submit">
查询
</Button>
<Button style={{ marginLeft: 8 }} onClick={handleFormReset}>
重置
</Button>
</span>
</Col>
</Row>
</Form>
);
});
export default SignListSearch;

View File

@ -26,3 +26,29 @@ export async function deletedSign(params) {
method: 'DELETE',
});
}
// template
export async function pageTemplate(params) {
return request(`/admin-api/admins/sms/template/page?${stringify(params)}`, {
method: 'GET',
});
}
export async function addTemplate(params) {
return request(`/admin-api/admins/sms/template/add?${stringify(params)}`, {
method: 'POST',
});
}
export async function updateTemplate(params) {
return request(`/admin-api/admins/sms/template/update?${stringify(params)}`, {
method: 'PUT',
});
}
export async function deletedTemplate(params) {
return request(`/admin-api/admins/sms/template/deleted?${stringify(params)}`, {
method: 'DELETE',
});
}

View File

@ -12,6 +12,7 @@ const DictionaryConstants = {
ORDER_RETURN_SERVICE_TYPE: 'order_return_service_type',
// sms
SMS_TYPE: 'sms_type',
SMS_PLATFORM: 'sms_platform',
SMS_APPLY_STATUS: 'sms_apply_status',
};