forked from shen100/wemall
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2.商品上架,下架功能完成 3.商品分类,开启,关闭功能完成
- Loading branch information
刘珅
committed
May 2, 2017
1 parent
3ec442c
commit f0f597f
Showing
14 changed files
with
332 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
nodejs/static/javascripts/admin/actions/changeCategoryStatus.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { | ||
CHANGE_CATEGORY_STATUS | ||
} from '../constants'; | ||
|
||
function receiveCategoryStatus(data) { | ||
return { | ||
type : CHANGE_CATEGORY_STATUS, | ||
id : data.id, | ||
status : data.status | ||
}; | ||
} | ||
|
||
export default function(reqData) { | ||
return dispatch => { | ||
var url = pageConfig.apiURL + '/admin/category/status/update'; | ||
return fetch(url, { | ||
method: 'POST', | ||
headers: { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ | ||
id : reqData.id, | ||
status : reqData.status | ||
}) | ||
}) | ||
.then(response => response.json()) | ||
.then(json => dispatch(receiveCategoryStatus(json.data))); | ||
}; | ||
}; | ||
|
22 changes: 22 additions & 0 deletions
22
nodejs/static/javascripts/admin/actions/changeProductStatus.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { | ||
CHANGE_PRODUCT_STATUS | ||
} from '../constants'; | ||
|
||
function receiveProductStatus(data) { | ||
return { | ||
type : CHANGE_PRODUCT_STATUS, | ||
id : data.id, | ||
status : data.status | ||
}; | ||
} | ||
|
||
export default function(reqData) { | ||
return dispatch => { | ||
var url = pageConfig.apiURL + '/admin/product/status/update/:id/:status'; | ||
url = url.replace(':id', reqData.id); | ||
url = url.replace(':status', reqData.status); | ||
return fetch(url) | ||
.then(response => response.json()) | ||
.then(json => dispatch(receiveProductStatus(json.data))); | ||
}; | ||
} |
19 changes: 19 additions & 0 deletions
19
nodejs/static/javascripts/admin/actions/requestCategoryList.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { | ||
REQUEST_CATEGORY_LIST | ||
} from '../constants'; | ||
|
||
function receiveCategories(data) { | ||
return { | ||
type: REQUEST_CATEGORY_LIST, | ||
categories: data.categories | ||
}; | ||
} | ||
|
||
export default function() { | ||
return dispatch => { | ||
var url = pageConfig.apiURL + '/admin/categories'; | ||
return fetch(url) | ||
.then(response => response.json()) | ||
.then(json => dispatch(receiveCategories(json.data))) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
nodejs/static/javascripts/admin/containers/CategoryManage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
import React, { Component } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { Link } from 'react-router'; | ||
|
||
import { | ||
Icon, | ||
Row, | ||
Col, | ||
Popconfirm, | ||
Table | ||
} from 'antd'; | ||
|
||
import requestCategoryList from '../actions/requestCategoryList'; | ||
import changeCategoryStatus from '../actions/changeCategoryStatus'; | ||
import Software from './Software'; | ||
import analyze from '../../sdk/analyze'; | ||
import '../../../styles/admin/categoryManage.css'; | ||
|
||
/* | ||
* 管理后台,商品分类管理 | ||
*/ | ||
class CategoryManage extends Component { | ||
constructor(props) { | ||
super(props); | ||
var self = this; | ||
this.state = { | ||
columns: [ | ||
{ | ||
title: '分类名称', | ||
dataIndex: 'name' | ||
}, | ||
{ | ||
title: '排序', | ||
dataIndex: 'order' | ||
}, | ||
{ | ||
title: '创建时间', | ||
dataIndex: 'createdAt' | ||
}, | ||
{ | ||
title: '操作', | ||
render: (text, record) => { | ||
let openEnabled = false; | ||
let closeEnabled = false; | ||
//1: 已开启 | ||
//2: 已关闭 | ||
if (record.status == 1) { | ||
closeEnabled = true; | ||
} else if (record.status == 2) { | ||
openEnabled = true; | ||
} | ||
return ( | ||
<span> | ||
<a> | ||
<Icon type="eye"/> | ||
<span>查看</span> | ||
</a> | ||
<span className="ant-divider category-manage-divider" /> | ||
<a> | ||
<Icon type="edit"/> | ||
<span>编辑</span> | ||
</a> | ||
<span className="ant-divider category-manage-divider" /> | ||
{ | ||
openEnabled ? | ||
<Popconfirm title="确定要开启?" okText="确定" cancelText="取消" | ||
onConfirm={self.onMenuOpen.bind(self, record)}> | ||
<a> | ||
<Icon type="arrow-up"/> | ||
<span>开启</span> | ||
</a> | ||
</Popconfirm> | ||
: | ||
( | ||
closeEnabled ? | ||
<Popconfirm title="确定要关闭?" okText="确定" cancelText="取消" | ||
onConfirm={self.onMenuClose.bind(self, record)}> | ||
<a> | ||
<Icon type="arrow-down"/> | ||
<span>关闭</span> | ||
</a> | ||
</Popconfirm> | ||
: | ||
null | ||
) | ||
} | ||
</span> | ||
); | ||
} | ||
} | ||
] | ||
}; | ||
} | ||
componentDidMount() { | ||
const { dispatch } = this.props; | ||
dispatch(requestCategoryList()); | ||
analyze.pv(); | ||
} | ||
onMenuOpen(record) { | ||
const { dispatch } = this.props; | ||
//1: 已开启 | ||
//2: 已关闭 | ||
dispatch(changeCategoryStatus({ | ||
id : record.id, | ||
status : 1 | ||
})); | ||
} | ||
onMenuClose(record) { | ||
const { dispatch } = this.props; | ||
//1: 已开启 | ||
//2: 已关闭 | ||
dispatch(changeCategoryStatus({ | ||
id : record.id, | ||
status : 2 | ||
})); | ||
} | ||
render() { | ||
let { data } = this.props; | ||
let { columns } = this.state; | ||
let isLoading = data.categories.length > 0 ? false : true; | ||
return ( | ||
<div> | ||
<Row gutter={24}> | ||
<Col span={24}> | ||
<div className="category-list-box"> | ||
<div className="category-list-title">商品分类列表</div> | ||
<Table rowKey="id" columns={columns} | ||
loading={isLoading} pagination={false} | ||
dataSource={data.categories} bordered /> | ||
</div> | ||
</Col> | ||
</Row> | ||
<Software /> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
const mapStateToProps = (state) => { | ||
return { | ||
data: state.category | ||
}; | ||
} | ||
|
||
export default connect(mapStateToProps)(CategoryManage); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { | ||
REQUEST_CATEGORY_LIST, | ||
CHANGE_CATEGORY_STATUS | ||
} from '../constants'; | ||
|
||
let initState = { | ||
categories: [] | ||
}; | ||
|
||
export default (state = initState, action) => { | ||
switch (action.type) { | ||
case REQUEST_CATEGORY_LIST: { | ||
return { | ||
...state, | ||
categories: action.categories | ||
}; | ||
} | ||
case CHANGE_CATEGORY_STATUS: { | ||
let categories = state.categories.slice(0); | ||
for (let i = 0; i < categories.length; i++) { | ||
if (categories[i].id == action.id) { | ||
categories[i].status = action.status; | ||
break; | ||
} | ||
} | ||
return { | ||
...state, | ||
categories: categories | ||
}; | ||
} | ||
default: { | ||
return state | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.