diff --git a/admin-web/src/pages/Product/ProductAttrList.js b/admin-web/src/pages/Product/ProductAttrList.js index 50ca26ee2..fad82cb73 100644 --- a/admin-web/src/pages/Product/ProductAttrList.js +++ b/admin-web/src/pages/Product/ProductAttrList.js @@ -1,5 +1,18 @@ import React, { PureComponent, Fragment, Component } from 'react'; -import { Form, Card, Table, Button, Divider, Modal, Input, message, Switch, Select } from 'antd'; +import { + Row, + Col, + Form, + Card, + Table, + Button, + Divider, + Modal, + Input, + message, + Switch, + Select, +} from 'antd'; import moment from 'moment'; import { connect } from 'dva'; import PageHeaderWrapper from '@/components/PageHeaderWrapper'; @@ -148,6 +161,9 @@ export default class ProductAttrList extends PureComponent { valueModalVisible: false, modalType: 'add', //add or update initValues: {}, + current: 1, + pageSize: 10, + name: null, }; componentDidMount() { @@ -156,10 +172,13 @@ export default class ProductAttrList extends PureComponent { initFetch = () => { const { dispatch } = this.props; + const { current, pageSize, name } = this.state; dispatch({ type: 'productAttrList/page', payload: { - ...PaginationHelper.defaultPayload, + pageNo: current, + pageSize, + name, }, }); // const { dispatch } = this.props; @@ -306,6 +325,19 @@ export default class ProductAttrList extends PureComponent { }); }; + handleTableChange = pagination => { + const { pageSize, current, index } = pagination; + this.setState( + { + current, + pageSize, + }, + function() { + this.initFetch(); + } + ); + }; + switchValueChange = (checked, record) => { const { dispatch } = this.props; dispatch({ @@ -340,8 +372,82 @@ export default class ProductAttrList extends PureComponent { }); }; + handleFormReset = () => { + const { form, dispatch } = this.props; + form.resetFields(); + this.setState( + { + name: null, + }, + function() { + this.initFetch(); + } + ); + }; + + handleCondition = e => { + e.preventDefault(); + + const { dispatch, form } = this.props; + + form.validateFields((err, fieldsValue) => { + if (err) return; + const values = { + ...fieldsValue, + }; + + if (values.name) { + this.setState( + { + searched: true, + name: values.name, + }, + function() { + this.initFetch(); + } + ); + } else { + this.initFetch(); + } + + // dispatch({ + // type: 'fenfa/getCategoryList', + // payload: { + // key: values.name + // }, + // }); + }); + }; + + renderSimpleForm() { + const { form } = this.props; + const { getFieldDecorator } = form; + return ( +
+ + + + {getFieldDecorator('name')()} + + + + + + + + + + +
+ ); + } + render() { - const { attrData, productAttrList, loading, pagination, tree } = this.props; + const { attrData, productAttrList, loading, tree } = this.props; const columns = [ { title: '规格名称', @@ -395,18 +501,31 @@ export default class ProductAttrList extends PureComponent { tree: tree, }; + const pagination = { + total: attrData.count, + index: this.state.current, + pageSize: this.state.pageSize, + }; + return (
- + + + + + +
{this.renderSimpleForm()}
+ +
this.handleTableChange(pagination)} /> {modalVisible ? : null} diff --git a/docs/sql/mall_admin.sql b/docs/sql/mall_admin.sql index 5da350bd8..c9a8230fd 100644 --- a/docs/sql/mall_admin.sql +++ b/docs/sql/mall_admin.sql @@ -315,6 +315,7 @@ INSERT INTO `resource` VALUES (51, 1, -1, '短信ss', 0, '', 'user', '', '2019-0 INSERT INTO `resource` VALUES (52, 1, 1, '短信签名', 51, '/sms/sign-list', 'user', '', '2019-05-26 12:01:56', '2019-05-26 12:01:56', b'0'); INSERT INTO `resource` VALUES (53, 1, 2, '短信模板', 51, '/sms/template-list', 'user', '', '2019-05-26 12:02:19', '2019-05-26 12:02:18', b'0'); INSERT INTO `resource` VALUES (54, 1, 3, '部门管理', 13, '/admin/dept-list', 'user', '', '2019-06-27 23:41:19', '2019-06-27 23:41:51', b'0'); +INSERT INTO `resource` VALUES (55, 1, 4, '规格管理', 20, '/product/product-attr-list', null, null, '2019-08-14 23:59:38', '2019-08-14 23:59:38', b'0'); COMMIT; -- ----------------------------