Commit bc005bb2 authored by superman's avatar superman

列表的接口全部改成list

parent 688aa87b
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -26,7 +26,8 @@ import {
smallFormItemLayout,
footerFormSubmitLayout,
handleUpload,
leftRightFormItemLayout
leftRightFormItemLayout,
FILE_UPLOAD
} from '../../utils';
......@@ -204,7 +205,7 @@ export default class BaseInfoForm extends Component {
<Form.Item label="产品主图" {...leftRightFormItemLayout}>
{
isEdit ?
<Upload action="/api/fileUpload/upload" listType="picture-card"
<Upload {...FILE_UPLOAD} listType="picture-card"
multiple={true}
headers={{
authorization: user && user.token,
......
......@@ -27,7 +27,8 @@ import {
formItemLayout,
smallFormItemLayout,
footerFormSubmitLayout,
handleUpload
handleUpload,
FILE_UPLOAD
} from '../../utils';
import Copy from '../../components/CopyToClipboard/CopyToClipboard';
......@@ -88,7 +89,7 @@ export default class DocumentsForm extends Component {
<Form.Item>
{
isEdit ?
<Upload.Dragger action="/api/fileUpload/upload"
<Upload.Dragger {...FILE_UPLOAD}
multiple={true}
headers={{
authorization: user && user.token,
......
......@@ -33,7 +33,7 @@ export default class List extends Component {
};
handleRowClick({id}) {
this.props.history.push('/announcement/' + id );
this.props.history.push('/announcement/' + id);
}
handleFilterVisible() {
......@@ -46,9 +46,11 @@ export default class List extends Component {
const pagination = {
total: total,
pageSize: parseInt(query.s, 10) || 10,
pageSize: parseInt(query.s, 10) || 30,
current: parseInt(query.p, 10) || 1,
showSizeChanger: true,
showTotal: total => `共 ${total} 条`,
pageSizeOptions:['10', '30', '50', '100'],
onShowSizeChange: (current, pageSize)=> {
console.log('Current: ', current, '; PageSize: ', pageSize);
query.p = current;
......@@ -152,14 +154,15 @@ export default class List extends Component {
<Icon type="plus"/>添加
</Button>
</Link>
<Button style={{margin:'0 1em'}} type="ghost" onClick={e=>{e.preventDefault(); this.props.history.goBack();}}>
<Button style={{margin:'0 1em'}} type="ghost"
onClick={e=>{e.preventDefault(); this.props.history.goBack();}}>
<Icon type="rollback"/>返回
</Button>
</div>
);
return (
<Layout header={header} >
<Layout header={header}>
<Table className="list-table" columns={columns}
dataSource={Array.isArray(items)?items:[]}
loading={loading}
......
......@@ -17,7 +17,8 @@ import {
Modal,
DatePicker,
Table,
Spin
Spin,
Tree
} from 'antd';
import Layout from '../../components/Layout/Layout';
......@@ -30,9 +31,13 @@ import {
userStatusToString,
formatDateTime,
NULL,
ACTIONPERMISSION
resourceActions,
enableStatusToString,
ENABLE_STATUS_LIST
} from '../../utils';
import './EditItem.less';
@connect(state=>({
loading: state.authority.loading || state.resource.loading,
......@@ -46,7 +51,9 @@ export default class EditItem extends Component {
constructor() {
super(...arguments);
this.state = {
isEdit: false
isEdit: false,
permissions: {},
permissionsMask: 0
}
}
......@@ -69,7 +76,8 @@ export default class EditItem extends Component {
fetchResourceList() {
this.props.dispatch({
type: 'FETCH_RESOURCE_LIST'
type: 'FETCH_RESOURCE_LIST',
query: {s: 100}
});
};
......@@ -78,13 +86,14 @@ export default class EditItem extends Component {
let data = {};
data = this.props.form.getFieldsValue();
data.id = this.props.params.id;
// if (isNaN(data.status)) {
// STATUS_LIST.forEach(item=> {
// if (item.text === data.status) {
// data.status = item.value
// }
// })
// }
data.permissions = JSON.stringify(this.state.permissions);
if (isNaN(data.status)) {
ENABLE_STATUS_LIST.forEach(item=> {
if (item.text === data.status) {
data.status = item.value
}
})
}
console.log(data);
this.props.dispatch({
type: 'UPDATE_AUTHORITY_ITEM',
......@@ -132,10 +141,51 @@ export default class EditItem extends Component {
/>
);
const resourcesMap = {};
resources.forEach(item=> {
resourcesMap[item.controllerName] = {category: item.category};
//对权限资源分组
const resourcesCategoryMap = {};
//权限资源对应Controller Map;
const resourcesControllerNameMap = {};
//角色权限
const permissions = {};
const checkedKeys = [];
resources.forEach(res=> {
if (res.actionMask && res.status == 9 ) {
const category = res.category || '其他';
const map = resourcesCategoryMap[category] || [];
//角色拥有权限
const permisMask = permissions[res.controllerName];
const permisAction = permisMask && resourceActions(permisMask) || [];
const permisActionMap = {};
if(permisAction.length){
permisAction.forEach(pac=>{
permisActionMap[pac.mask] = pac;
});
}
res.action = resourceActions(res.actionMask);
res.action.forEach(ac=>{
if(permisActionMap[ac.mask]){
ac.checked = true;
checkedKeys.push(['a', res.controllerName, ac.mask].join('-'));
}
});
map.push(res);
resourcesCategoryMap[category] = map;
resourcesControllerNameMap[res.controllerName] = res;
}
});
return (
......@@ -145,15 +195,14 @@ export default class EditItem extends Component {
item &&
<Form className="main-form" horizontal>
<Form.Item label="角色名" {...smallFormItemLayout}>
<Row>
<Col span="12">
<Form.Item label="角色ID" {...smallFormItemLayout}>
{
isEdit ?
<Input {...getFieldProps('name', {initialValue: item.name})} />
:
item.name || NULL
}
</Form.Item>
<Form.Item label="描述" {...smallFormItemLayout}>
<Form.Item label="名称" {...smallFormItemLayout}>
{
isEdit ?
<Input {...getFieldProps('description', {initialValue: item.description})} />
......@@ -163,15 +212,15 @@ export default class EditItem extends Component {
</Form.Item>
<Form.Item label="状态" {...smallFormItemLayout}>
{
// isEdit ?
// <Select
// placeholder="请选择状态" {...getFieldProps('status', {initialValue: statusToString(item.status)})} >
// <Select.Option value="1">系统</Select.Option>
// <Select.Option value="5">禁用</Select.Option>
// <Select.Option value="9">启用</Select.Option>
// </Select>
// :
// (typeof item.status !== 'undefined' ? statusToString(item.status) : NULL)
isEdit ?
<Select
placeholder="请选择状态" {...getFieldProps('status', {initialValue: enableStatusToString(item.status)})} >
<Select.Option value="1">系统</Select.Option>
<Select.Option value="5">禁用</Select.Option>
<Select.Option value="9">启用</Select.Option>
</Select>
:
(typeof item.status !== 'undefined' ? enableStatusToString(item.status) : NULL)
}
</Form.Item>
......@@ -179,14 +228,6 @@ export default class EditItem extends Component {
{item.dateCreated && formatDateTime(item.dateCreated)}
</Form.Item>
<Form.Item label="">
{
Object.keys(resourcesMap).map((resource, index)=>
<div key={'resource-'+index}>{JSON.stringify(resource)}</div>
)
}
</Form.Item>
<Form.Item {...footerFormSubmitLayout} style={{marginTop:30}}>
{
isEdit ?
......@@ -218,6 +259,51 @@ export default class EditItem extends Component {
{isEdit ? '取消' : '返回'}
</Button>
</Form.Item>
</Col>
<Col span="12">
<Tree checkable={isEdit} defaultExpandAll={true} defaultCheckedKeys={checkedKeys} onCheck={(checkedKeys)=>{
// console.log(checkedKeys);
const cs = {};
let totalMask = 0;
checkedKeys.forEach(key=>{
const [ac, cn, mask] = key.split('-');
if(ac === 'a' && typeof mask !== 'undefined'){
let _mask = parseInt(mask, 10);
cs[cn] = (cs[cn] || 0) + _mask;
totalMask += _mask;
}
});
console.log(cs);
this.setState({
permissions: cs,
permissionsMask: totalMask
})
}}>
{
Object.keys(resourcesCategoryMap).map((key, index)=>
<Tree.TreeNode className="resource-category" key={'c-'+index}
title={key}>
{
resourcesCategoryMap[key].map(res=>
<Tree.TreeNode className="resource-item"
key={ res.action.length===1 ? ('a-'+res.controllerName+'-'+res.action[0].mask) :('r-' + res.id)}
title={res.description + (res.action.length===1 ? ' - '+res.action[0].title :'')}>
{
res.action.length > 1 && res.action.map(action=>
<Tree.TreeNode className="resource-action"
key={'a-' + res.controllerName + '-' + action.mask}
title={action.title}/>
)
}
</Tree.TreeNode>
)
}
</Tree.TreeNode>
)
}
</Tree>
</Col>
</Row>
</Form>
}
</Spin>
......
:global {
.resource-category {
}
.resource-item {
& > .ant-tree-child-tree {
&:before,
&:after {
content: '';
display: block;
clear: both;
}
}
}
.resource-action {
float: left;
}
.ant-tree-checkbox-indeterminate .ant-tree-checkbox-inner {
background-color: #1DA57A;
border-color: #1DA57A
}
}
......@@ -13,7 +13,8 @@ import {
handleUpload,
filterFormItemLayout,
PRODUCT_STATUS,
filterFormItemStyle
filterFormItemStyle,
enableStatusToString
} from '../../utils';
import {Link} from 'react-router';
......@@ -21,7 +22,6 @@ import Layout from '../../components/Layout/Layout';
import MainHeader from '../../components/MainHeader/MainHeader';
@connect(state=>({
items: state.authority.items,
loading: state.authority.loading,
......@@ -93,12 +93,12 @@ export default class List extends Component {
const columns = [
{
title: '名称',
title: '角色ID',
dataIndex: 'name',
key: 'name',
width: 150,
}, {
title: '描述',
title: '名称',
dataIndex: 'description',
key: 'description',
width: 100
......@@ -119,6 +119,9 @@ export default class List extends Component {
key: 'status',
width: 80,
className: 'tac',
render: (status)=>(
<span>{enableStatusToString(status)}</span>
)
}, {
title: '操作',
key: 'operation',
......@@ -135,9 +138,11 @@ export default class List extends Component {
const pagination = {
total: total,
pageSize: parseInt(query.s, 10) || 10,
pageSize: parseInt(query.s, 10) || 30,
current: parseInt(query.p, 10) || 1,
showSizeChanger: true,
showTotal: total => `共 ${total} 条`,
pageSizeOptions: ['10', '30', '50', '100'],
onShowSizeChange: (current, pageSize)=> {
console.log('Current: ', current, '; PageSize: ', pageSize);
query.p = current;
......
......@@ -27,7 +27,8 @@ import Layout from '../../components/Layout/Layout';
import MainHeader from '../../components/MainHeader/MainHeader';
import {
handleUpload
handleUpload,
FILE_UPLOAD
} from '../../utils';
@connect(state=>({
......@@ -52,7 +53,7 @@ export default class BaseUpload extends Component {
<Layout header={header}>
<Row style={{padding:'20px 20px 20px'}}>
<Col span="24">
<Upload.Dragger action="/api/fileUpload/upload"
<Upload.Dragger {...FILE_UPLOAD}
multiple={true}
headers={{
authorization: user && user.token,
......
......@@ -144,7 +144,7 @@ export default class AddItem extends Component {
<Form.Item label="消息正文" help={
<div dangerouslySetInnerHTML={{__html: channelType === 1 ? '微信跳转链接模板: &lt;a href="此处替换跳转链接"&gt;此处替换显示内容&lt;/a&gt;' : '最多50个字符' }} />
} {...formItemLayout}>
<Input placeholder="消息正文" type="textarea" maxLength="50"
<Input placeholder="消息正文" type="textarea" maxLength={ channelType === 1 ? 10000:50}
autosize={{minRows:3, maxRows:10}} {...getFieldProps('customMessage.contents')} />
</Form.Item>
......
......@@ -43,9 +43,11 @@ export default class List extends Component {
const pagination = {
total: total,
pageSize: parseInt(query.s, 10) || 10,
pageSize: parseInt(query.s, 10) || 30,
current: parseInt(query.p, 10) || 1,
showSizeChanger: true,
showTotal: total => `共 ${total} 条`,
pageSizeOptions:['10', '30', '50', '100'],
onShowSizeChange: (current, pageSize)=> {
console.log('Current: ', current, '; PageSize: ', pageSize);
query.p = current;
......
......@@ -40,6 +40,7 @@ const columns = [
title: '标题',
dataIndex: 'shortTitle',
key: 'shortTitle',
width: 200,
render: (shortTitle, record)=>(<span title={shortTitle}>{(shortTitle + '').substring(0, 15)}</span>)
}, {
title: '募集比率',
......@@ -170,9 +171,11 @@ export default class List extends Component {
const pagination = {
total: total,
pageSize: parseInt(query.s, 10) || 10,
pageSize: parseInt(query.s, 10) || 30,
current: parseInt(query.p, 10) || 1,
showSizeChanger: true,
showTotal: total => `共 ${total} 条`,
pageSizeOptions:['10', '30', '50', '100'],
onShowSizeChange: (current, pageSize)=> {
console.log('Current: ', current, '; PageSize: ', pageSize);
query.p = current;
......
......@@ -101,9 +101,11 @@ export default class List extends Component {
const pagination = {
total: total,
pageSize: parseInt(query.s, 10) || 10,
pageSize: parseInt(query.s, 10) || 30,
current: parseInt(query.p, 10) || 1,
showSizeChanger: true,
showTotal: total => `共 ${total} 条`,
pageSizeOptions:['10', '30', '50', '100'],
onShowSizeChange: (current, pageSize)=> {
console.log('Current: ', current, '; PageSize: ', pageSize);
query.p = current;
......
......@@ -29,15 +29,12 @@ import {
footerFormSubmitLayout,
userStatusToString,
formatDateTime,
NULL
NULL,
resourceActions,
enableStatusToString,
ENABLE_STATUS_LIST
} from '../../utils';
import {
STATUS_LIST,
statusToString
} from './utils';
@connect(state=>({
loading: state.resource.loading,
item: state.resource.item,
......@@ -74,7 +71,7 @@ export default class EditItem extends Component {
data = this.props.form.getFieldsValue();
data.id = this.props.params.id;
if (isNaN(data.status)) {
STATUS_LIST.forEach(item=> {
ENABLE_STATUS_LIST.forEach(item=> {
if (item.text === data.status) {
data.status = item.value
}
......@@ -134,15 +131,20 @@ export default class EditItem extends Component {
item &&
<Form className="main-form" horizontal>
<Form.Item label="分组" {...smallFormItemLayout}>
<Form.Item label="类别" {...smallFormItemLayout}>
{
isEdit ?
<Input {...getFieldProps('category', {initialValue: item.category})} />
<Select
style={{width:200}} {...getFieldProps('category', {initialValue: item.category})}>
<Select.Option value="业务管理">业务管理</Select.Option>
<Select.Option value="基础功能">基础功能</Select.Option>
<Select.Option value="系统管理">系统管理</Select.Option>
</Select>
:
item.category || NULL
}
</Form.Item>
<Form.Item label="描述" {...smallFormItemLayout}>
<Form.Item label="名称" {...smallFormItemLayout}>
{
isEdit ?
<Input {...getFieldProps('description', {initialValue: item.description})} />
......@@ -154,29 +156,26 @@ export default class EditItem extends Component {
{
isEdit ?
<Select
placeholder="请选择状态" {...getFieldProps('status', {initialValue: statusToString(item.status)})} >
placeholder="请选择状态" {...getFieldProps('status', {initialValue: enableStatusToString(item.status)})} >
<Select.Option value="1">系统</Select.Option>
<Select.Option value="5">禁用</Select.Option>
<Select.Option value="9">启用</Select.Option>
</Select>
:
(typeof item.status !== 'undefined' ? statusToString(item.status) : NULL)
(typeof item.status !== 'undefined' ? enableStatusToString(item.status) : NULL)
}
</Form.Item>
<Form.Item label="method" {...smallFormItemLayout}>
{ item.httpMethod }
</Form.Item>
<Form.Item label="url" {...smallFormItemLayout}>
{ item.url }
</Form.Item>
<Form.Item label="controllerName" {...smallFormItemLayout}>
{ item.controllerName }
</Form.Item>
<Form.Item label="actionName" {...smallFormItemLayout}>
{ item.actionName }
<Form.Item label="Actions" {...smallFormItemLayout}>
{
resourceActions(item.actionMask).map(({title, mask})=>
<span key={mask} style={{marginRight:'1em'}}>{title}</span>
)
}
</Form.Item>
<Form.Item label="注册时间" {...smallFormItemLayout}>
<Form.Item label="创建时间" {...smallFormItemLayout}>
{item.dateCreated && formatDateTime(item.dateCreated)}
</Form.Item>
<Form.Item {...footerFormSubmitLayout} style={{marginTop:30}}>
......
......@@ -13,17 +13,15 @@ import {
handleUpload,
filterFormItemLayout,
PRODUCT_STATUS,
filterFormItemStyle
filterFormItemStyle,
ENABLE_STATUS_LIST,
enableStatusToString
} from '../../utils';
import {Link} from 'react-router';
import Layout from '../../components/Layout/Layout';
import MainHeader from '../../components/MainHeader/MainHeader';
import {
STATUS_LIST,
statusToString
} from './utils';
@connect(state=>({
......@@ -102,37 +100,26 @@ export default class List extends Component {
key: 'id',
width: 60
}, {
title: 'category',
title: '类别',
dataIndex: 'category',
key: 'category',
width: 80,
}, {
title: 'description',
title: '名称',
dataIndex: 'description',
key: 'description',
width: 100
}, {
title: 'Method',
dataIndex: 'httpMethod',
key: 'httpMethod',
width: 60,
className: 'tac'
}, {
title: 'url',
dataIndex: 'url',
key: 'url',
width: 200
}, {
title: 'actionName',
title: '资源',
dataIndex: 'controllerName',
key: 'controllerName',
width: 180,
}, {
title: '权限值',
dataIndex: 'actionName',
key: 'actionName',
width: 80,
className: 'tac'
}, {
title: 'controllerName',
dataIndex: 'controllerName',
key: 'controllerName',
width: 180,
}, {
title: '创建时间',
dataIndex: 'dateCreated',
......@@ -145,13 +132,13 @@ export default class List extends Component {
</span>
)
}, {
title: 'status',
title: '状态',
dataIndex: 'status',
key: 'status',
width: 80,
className: 'tac',
render: (status)=> (
<span>{statusToString(status)}</span>
<span>{enableStatusToString(status)}</span>
)
}, {
title: '操作',
......@@ -169,9 +156,11 @@ export default class List extends Component {
const pagination = {
total: total,
pageSize: parseInt(query.s, 10) || 10,
pageSize: parseInt(query.s, 10) || 30,
current: parseInt(query.p, 10) || 1,
showSizeChanger: true,
showTotal: total => `共 ${total} 条`,
pageSizeOptions:['10', '30', '50', '100'],
onShowSizeChange: (current, pageSize)=> {
console.log('Current: ', current, '; PageSize: ', pageSize);
query.p = current;
......
export const STATUS = {
1: '系统',
5: '禁用',
9: '启用'
};
export function statusToString(status) {
return STATUS[status] || '未定义('+ status+')';
}
export const STATUS_LIST = Object.keys(STATUS).map(key=> {
return {value: key, text: STATUS[key]}
});
......@@ -148,9 +148,11 @@ export default class List extends Component {
const pagination = {
total: total,
pageSize: parseInt(query.s, 10) || 10,
pageSize: parseInt(query.s, 10) || 30,
current: parseInt(query.p, 10) || 1,
showSizeChanger: true,
showTotal: total => `共 ${total} 条`,
pageSizeOptions:['10', '30', '50', '100'],
onShowSizeChange: (current, pageSize)=> {
console.log('Current: ', current, '; PageSize: ', pageSize);
query.p = current;
......
......@@ -128,9 +128,11 @@ export default class List extends Component {
const pagination = {
total: total,
pageSize: parseInt(query.s, 10) || 10,
pageSize: parseInt(query.s, 10) || 30,
current: parseInt(query.p, 10) || 1,
showSizeChanger: true,
showTotal: total => `共 ${total} 条`,
pageSizeOptions:['10', '30', '50', '100'],
onShowSizeChange: (current, pageSize)=> {
console.log('Current: ', current, '; PageSize: ', pageSize);
query.p = current;
......
......@@ -97,9 +97,11 @@ export default class List extends Component {
const pagination = {
total: total,
pageSize: parseInt(query.s, 10) || 10,
pageSize: parseInt(query.s, 10) || 30,
current: parseInt(query.p, 10) || 1,
showSizeChanger: true,
showTotal: total => `共 ${total} 条`,
pageSizeOptions:['10', '30', '50', '100'],
onShowSizeChange: (current, pageSize)=> {
console.log('Current: ', current, '; PageSize: ', pageSize);
query.p = current;
......
import {takeLatest} from 'redux-saga';
import {take, call, put, fork, cancel, select} from 'redux-saga/effects';
/*import {takeLatest} from 'redux-saga';
import {take, call, put, fork, cancel, select, race} from 'redux-saga/effects';
import {message} from 'antd';
export default class RESTful {
constructor() {
constructor(id) {
this.id = id;
}
index() {
......@@ -27,26 +27,48 @@ export default class RESTful {
}
}
watchIndex() {
const self = this;
return function*() {
while (true) {
const {query} = yield take('FETCH_' + self.id + '_LIST');
yield fork(self.index(), query);
}
};
}
show() {
const {api, id} = this;
const self = this;
const {api} = this;
return function*(id) {
try {
const result = yield call(api.show, id);
yield put({
type: 'FETCH_' + id + '_ITEM_SUCCESS',
type: 'FETCH_' + self.id + '_ITEM_SUCCESS',
result
});
} catch (err) {
console.log(err);
message.error(err);
yield put({
type: 'FETCH_' + id + '_ITEM_FAILED',
type: 'FETCH_' + self.id + '_ITEM_FAILED',
err
});
}
}
}
watchShow() {
const self = this;
return function*() {
while (true) {
const {id} = yield take('FETCH_' + self.id + '_ITEM');
yield fork(self.show(), id);
}
}
}
create() {
const {api, id} = this;
return function*(data) {
......@@ -66,4 +88,191 @@ export default class RESTful {
}
}
}
watchCreate() {
const self = this;
return function*() {
while (true) {
const {data} = yield take('CREATE_' + self.id + '_ITEM');
yield fork(self.create(), data);
}
}
}
update() {
const {api, id} = this;
return function*(data) {
try {
yield call(api.update, data);
message.success('修改成功!');
yield put({
type: 'UPDATE_' + id + '_ITEM_SUCCESS',
item: data
});
} catch (err) {
console.log(err);
message.error(err);
yield put({
type: 'UPDATE_' + id + '_ITEM_FAILED',
err
});
}
}
}
watchUpdate() {
const self = this;
return function*() {
while (true) {
yield take('UPDATE_' + self.id);
yield put({
type: 'UPDATE_' + self.id + '_START'
});
const {data} = yield race({
data: take('UPDATE_' + self.id + '_ITEM'),
canceled: take('CANCEL_UPDATE_' + self.id)
});
if (data && data.item) {
yield fork(self.update(), data.item);
}
yield put({
type: 'UPDATE_' + self.id + '_END'
});
}
}
}
delete() {
const self = this;
const {api} = this;
return function*(id) {
try {
const result = yield call(api.show, id);
yield put({
type: 'DELETE_' + self.id + '_ITEM_SUCCESS',
result
});
} catch (err) {
console.log(err);
message.error(err);
yield put({
type: 'DELETE_' + self.id + '_ITEM_FAILED',
err
});
}
}
}
watchDelete() {
const self = this;
return function*() {
while (true) {
const {id} = yield take('DELETE_' + self.id + '_ITEM');
yield fork(self.delete(), id);
}
}
}
patch() {
const {api, id} = this;
return function*(data) {
try {
yield call(api.update, data);
message.success('操作成功!');
yield put({
type: 'PATCH_' + id + '_ITEM_SUCCESS',
item: data
});
} catch (err) {
console.log(err);
message.error(err);
yield put({
type: 'PATCH_' + id + '_ITEM_FAILED',
err
});
}
}
}
watchPatch() {
const self = this;
return function*() {
while (true) {
const {id} = yield take('PATCH_' + self.id + '_ITEM');
yield fork(self.patch(), id);
}
}
}
watch() {
const self = this;
const mask = this.mask;
const tasks = [
self.watchIndex,
self.watchCreate,
//savenull,
self.watchShow,
//editnull,
self.watchUpdate,
self.watchDelete,
self.watchPatch
];
return function*() {
tasks.forEach((task, index)=> {
const mi = 1 << index;
if (task && ((mask & mi ) === mi)) {
yield fork(task());
}
});
}
}
actions() {
const loadingFn = function (state) {
return {...state, loading: true};
};
const failedFn = function (state, action) {
return {...state, loading: false, err: action.err}
};
const editStartFn = function (state) {
return {...state, isEdit: true}
};
const editEndFn = function (state) {
return {...state, isEdit: false};
};
const itemsFn = function (state, action) {
return {...state, loading: false, items: action.items, total: action.total}
};
const itemFn = function (state, action) {
return {...state, loading: false, item: {...state.item, ...action.item}}
};
const id = this.id;
return {
['INDEX_' + id ]: loadingFn,
['INDEX_' + id + '_SUCCESS']: itemsFn,
['INDEX_' + id + '_FAILED']: failedFn,
['SHOW_' + id]: loadingFn,
['SHOW_' + id + '_SUCCESS']: itemFn,
['SHOW_' + id + '_FAILED']: failedFn,
['CREATE_' + id]: loadingFn,
['CREATE_' + id + '_SUCCESS']: itemFn,
['CREATE_' + id + '_FAILED']: failedFn,
['UPDATE_' + id]: loadingFn,
['UPDATE_' + id + '_SUCCESS']: itemFn,
['UPDATE_' + id + '_FAILED']: failedFn,
['ENTER_EDIT' + id]: editStartFn,
['EXIT_EDIT_' + id]: editEndFn,
['DELETE_' + id]: loadingFn,
['DELETE_' + id + '_SUCCESS']: itemFn,
['DELETE_' + id + '_FAILED']: failedFn,
['PATCH_' + id]: loadingFn,
['PATCH_' + id + '_SUCCESS']: itemFn,
['PATCH_' + id + '_FAILED']: failedFn,
}
}
}
*/
......@@ -5,11 +5,11 @@ import {message} from 'antd';
function* getList(query) {
try {
const {total, announcements} = yield call(fetchList, query);
const {total, list} = yield call(fetchList, query);
yield put({
type: 'FETCH_ANNOUNCEMENT_LIST_SUCCESS',
total,
items: announcements
items: list
});
} catch (err) {
console.log(err);
......
......@@ -5,11 +5,11 @@ import {message} from 'antd';
function* getList(query) {
try {
const {total, authorities} = yield call(fetchList, query);
const {total, list} = yield call(fetchList, query);
yield put({
type: 'FETCH_AUTHORITY_LIST_SUCCESS',
total,
items: authorities
items: list
});
} catch (err) {
console.log(err);
......
......@@ -5,11 +5,11 @@ import {message} from 'antd';
function* getList(query) {
try {
const {total, customMessageViewDOs} = yield call(fetchList, query);
const {total, list} = yield call(fetchList, query);
yield put({
type: 'FETCH_MESSAGE_LIST_SUCCESS',
total,
items: customMessageViewDOs
items: list
});
} catch (err) {
console.log(err);
......
......@@ -5,11 +5,11 @@ import {message} from 'antd';
function* getList(query) {
try {
const {total, items} = yield call(fetchList, query);
const {total, list} = yield call(fetchList, query);
yield put({
type: 'FETCH_PRODUCT_LIST_SUCCESS',
total,
items
items:list
});
} catch (err) {
console.log(err);
......
......@@ -7,11 +7,11 @@ import {message} from 'antd';
function* getList(query) {
try {
const {total, audits} = yield call(fetchList, query);
const {total, list} = yield call(fetchList, query);
yield put({
type: 'FETCH_REMITTANCE_LIST_SUCCESS',
total,
items: audits
items: list
});
} catch (err) {
console.log(err);
......
......@@ -5,11 +5,11 @@ import {message} from 'antd';
function* getList(query) {
try {
const {total, resources} = yield call(fetchList, query);
const {total, list} = yield call(fetchList, query);
yield put({
type: 'FETCH_RESOURCE_LIST_SUCCESS',
total,
items: resources
items: list
});
} catch (err) {
console.log(err);
......
......@@ -5,11 +5,11 @@ import {message} from 'antd';
function* getList(query) {
try {
const {total, trades} = yield call(fetchList, query);
const {total, list} = yield call(fetchList, query);
yield put({
type: 'FETCH_TRADE_LIST_SUCCESS',
total,
items: trades
items: list
});
} catch (err) {
console.log(err);
......
......@@ -45,10 +45,10 @@ function* watchAddItem() {
function* getList(query) {
try {
const {users, total} = yield call(fetchList, query);
const {list, total} = yield call(fetchList, query);
yield put({
type: 'FETCH_USER_LIST_SUCCESS',
items: users,
items: list,
total
});
} catch (err) {
......
......@@ -5,11 +5,11 @@ import {message} from 'antd';
function* getList(query) {
try {
const {total, audits} = yield call(fetchList, query);
const {total, list} = yield call(fetchList, query);
yield put({
type: 'FETCH_WITHDRAW_LIST_SUCCESS',
total,
items: audits
items: list
});
} catch (err) {
console.log(err);
......
......@@ -2,7 +2,7 @@ import xFetch from '../xFetch';
import {serialize} from '../../utils';
export async function fetchList(query) {
return xFetch('/api/admin/authorities' + '?' +serialize(query));
return xFetch('/api/admin/authorities' + '?' + serialize({s:30, ...query}));
}
export async function fetchItem(id) {
......
......@@ -2,7 +2,7 @@ import xFetch from '../xFetch';
import {serialize} from '../../utils';
export async function fetchList(query) {
return xFetch('/api/admin/resources' + '?' +serialize(query));
return xFetch('/api/admin/resources' + '?' + serialize({s:30, ...query}));
}
export async function fetchItem(id) {
......
......@@ -4,7 +4,7 @@ import {serialize} from '../utils';
export async function fetchList(query) {
const data = {...query};
delete data.title;
return xFetch('/api/announcements' + '?' + serialize(data));
return xFetch('/api/announcements' + '?' + serialize({s:30, ...data}));
}
export async function fetchItem(id) {
......
......@@ -2,8 +2,7 @@ import xFetch from './xFetch';
import {serialize} from '../utils';
export async function fetchList(query) {
const data = {...query};
return xFetch('/api/customMessages' + '?' + serialize(data));
return xFetch('/api/customMessages' + '?' +serialize({s:30, ...query}));
}
export async function fetchItem(id) {
......
......@@ -2,7 +2,7 @@ import xFetch from './xFetch';
import {serialize} from '../utils';
export async function fetchList(query) {
return xFetch('/api/products' + '?' + serialize(query));
return xFetch('/api/products' + '?' + serialize({s:30, ...query}));
}
export async function fetchCates() {
......
......@@ -2,7 +2,7 @@ import xFetch from './xFetch';
import {serialize} from '../utils';
export async function fetchList(query) {
return xFetch('/api/remittance/audits' + '?' + serialize(query));
return xFetch('/api/remittance/audits' + '?' + serialize({s:30, ...query}));
}
export async function fetchItem(id) {
return xFetch('/api/remittance/audits/' + id);
......
......@@ -2,7 +2,7 @@ import xFetch from './xFetch';
import {serialize} from '../utils';
export async function fetchList(query) {
return xFetch('/api/trades' + '?' + serialize(query));
return xFetch('/api/trades' + '?' + serialize({s:30, ...query}));
}
export async function fetchItem(id) {
return xFetch('/api/trades/' + id);
......
......@@ -16,7 +16,7 @@ export async function create(data) {
}
export async function fetchList(query) {
return xFetch('/api/admin/users' + '?' + serialize(query));
return xFetch('/api/admin/users' + '?' + serialize({s:30, ...query}));
}
export async function fetchItem(id) {
......
......@@ -2,7 +2,7 @@ import xFetch from './xFetch';
import {serialize} from '../utils';
export async function fetchList(query) {
return xFetch('/api/withdraw/audits' + '?' + serialize(query));
return xFetch('/api/withdraw/audits' + '?' + serialize({s:30, ...query}));
}
export async function fetchItem(id) {
......
......@@ -4,6 +4,8 @@
export const NULL = '_____?_____';
export const FILE_UPLOAD = {action: '/api/fileUpload'};
export function serialize(obj, prefix) {
if (obj) {
var str = [];
......@@ -259,13 +261,32 @@ export function cr2br(text) {
}
export const ACTIONPERMISSION = {
index: 1 << 0,
create: 1 << 1,
save: 1 << 2,
show: 1 << 3,
edit: 1 << 4,
update: 1 << 5,
'delete': 1 << 6,
patch: 1 << 7
export function resourceActions(mask) {
return resourceActions.enum.reduce((arr, action, index)=> {
const value = 1 << index;
if ((mask & value) === value) {
arr.push({title: action, mask: value});
}
return arr;
}, []);
}
resourceActions.enum = ['列表index', '创建create', 'save', '详情show', 'edit', '编辑update', '删除delete', '审核patch'];
export const ENABLE_STATUS = {
1: '系统',
5: '禁用',
9: '启用'
};
export function enableStatusToString(status) {
return ENABLE_STATUS[status] || '未定义('+ status+')';
}
export const ENABLE_STATUS_LIST = Object.keys(ENABLE_STATUS).map(key=> {
return {value: key, text: ENABLE_STATUS[key]}
});
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