From: Hongyuan Ma Date: Wed, 11 Jul 2018 04:18:34 +0000 (+0800) Subject: add MachineRecordListFilter; X-Git-Url: http://git.postgresql.org/gitweb/delmail?a=commitdiff_plain;h=7c58bc67a7f0003916a52cfdc6f0908c18041c3a;p=pgperffarm.git add MachineRecordListFilter; --- diff --git a/front-end/src/component/history-records-pane1/index.css b/front-end/src/component/history-records-pane1/index.css index e69de29..b8cdbf8 100644 --- a/front-end/src/component/history-records-pane1/index.css +++ b/front-end/src/component/history-records-pane1/index.css @@ -0,0 +1,4 @@ +.active_branch{ + color: #fff9f8 !important; + background-color: #40a9ff !important; +} \ No newline at end of file diff --git a/front-end/src/component/history-records-pane1/index.jsx b/front-end/src/component/history-records-pane1/index.jsx index 4bd4e74..a93eedb 100644 --- a/front-end/src/component/history-records-pane1/index.jsx +++ b/front-end/src/component/history-records-pane1/index.jsx @@ -3,8 +3,11 @@ import Pagination from 'util/pagination/index.jsx'; import {Tab, Divider, Icon, Label} from 'semantic-ui-react' import MachineRecordTable from 'util/machine-record-table/index.jsx' +import Record from 'service/record-service.jsx' import PGUtil from 'util/util.jsx' + const _util = new PGUtil(); +const _record = new Record(); import './index.css'; class HistoryRecordPane1 extends React.Component { @@ -12,43 +15,73 @@ class HistoryRecordPane1 extends React.Component { super(props); this.state = { - list: [], + currentList: [], + currentTotal: 0, + currentPage:1, + machine_sn: props.machine_sn || '', branches: props.branches || [], - selected_branch: '', - restoreNum: 0, - selected: [{ - 'cate': 'Category 1', - 'index': 0, - 'key': 'date', - 'data': [ - {'name': 'All', 'value': ''}, - {'name': '7 days', 'value': '7'}, - {'name': '30 days', 'value': '30'} - ], - }], + selected_branch: 1, } - console.log('br') - console.dir(this.state.branches) + // console.dir(this.state.branches) + this.loadMachineRecordListByBranch = this.loadMachineRecordListByBranch.bind(this); + // this.loadMachineRecordListByBranch } componentDidMount() { // this.loadHistoryRecordList(); } componentWillReceiveProps(nextProps) { - this.setState({branches: nextProps.branches}); + this.setState({ + branches: nextProps.branches, + machine_sn: nextProps.machine_sn, + }); } - reloadRecordTable(branch_id){ + handleBranchTagClick(branch_id){ console.log('new reload branch is: ' + branch_id) + + this.setState({ + selected_branch: branch_id, + },() => { + this.loadMachineRecordListByBranch() + }); + } + // load record list + loadMachineRecordListByBranch(page=1) { + let _this = this; + let listParam = {}; + + listParam.page = page; + listParam.test_machine__machine_sn = this.state.machine_sn; + listParam.branch__id = this.state.selected_branch; + + _record.getMachineRecordListByBranch(listParam).then(res => { + _this.setState({ + currentList: res.results, + currentTotal: res.count, + isLoading: false + }); + }, errMsg => { + _this.setState({ + curentList: [] + }); + _util.errorTips(errMsg); + + console.log(errMsg) + }); + + console.log(this.state.list) + } render(){ let _list = this.state.branches || []; console.log('list is') console.dir(_list) let branch_tags = _list.map((branchItem, index) => { + let className = branchItem.value == this.state.selected_branch ? 'active_branch' : ''; return ( -