add branch_num in machineinfo page
authorHongyuan Ma <CS_MaleicAcid@163.com>
Wed, 11 Jul 2018 04:44:53 +0000 (12:44 +0800)
committerHongyuan Ma <CS_MaleicAcid@163.com>
Wed, 11 Jul 2018 04:44:53 +0000 (12:44 +0800)
front-end/src/component/farmer-detail-card/index.jsx
front-end/src/component/history-records-pane1/index.jsx
front-end/src/page/machineInfo/index.jsx
front-end/src/util/machine-record-table/index.jsx

index 10549ce3a63710d280a64ba311c02734c846aa15..bee5456feba68bbe8d20734cd91808fb92e2dadf 100644 (file)
@@ -9,6 +9,7 @@ class FarmerDetailCard extends React.Component {
     }
     render(){
         let machine = this.props.machine || {}
+        let branch_num = this.props.branch_num || 0
         let system = machine.os_name + ' ' + machine.os_version;
         let camp = machine.comp_name + ' ' + machine.comp_version;
         let owner = machine.owner || {};
@@ -37,7 +38,7 @@ class FarmerDetailCard extends React.Component {
                         <div className='ui buttons'>
                             {/*todo link to machine page*/}
                             <Button basic mini color='grey'>
-                                4 branches involved
+                                {branch_num} branches involved
                             </Button>
                         </div>
                     </Card.Content>
index a93eedbfd1d4546daa9e1b8c87dbc30c6db1971d..bd92ac27fa4d16c04af48375efdffb13bfc43190 100644 (file)
@@ -19,8 +19,8 @@ class HistoryRecordPane1 extends React.Component {
             currentTotal: 0,
             currentPage:1,
             machine_sn: props.machine_sn || '',
-            branches: props.branches || [],
-            selected_branch: 1,
+            branches: props.branches,
+            selected_branch: props.branches[0].value,
         }
         // console.dir(this.state.branches)
         this.loadMachineRecordListByBranch = this.loadMachineRecordListByBranch.bind(this);
@@ -28,7 +28,8 @@ class HistoryRecordPane1 extends React.Component {
     }
 
     componentDidMount() {
-        // this.loadHistoryRecordList();
+        // console.log(this.state.branches[0].value)
+        this.loadMachineRecordListByBranch()
     }
     componentWillReceiveProps(nextProps) {
         this.setState({
@@ -55,7 +56,9 @@ class HistoryRecordPane1 extends React.Component {
         listParam.page = page;
         listParam.test_machine__machine_sn = this.state.machine_sn;
         listParam.branch__id = this.state.selected_branch;
-
+        if(listParam.branch__id <= 0) {
+            return;
+        }
         _record.getMachineRecordListByBranch(listParam).then(res => {
             _this.setState({
                 currentList: res.results,
index 4f59c382e32483de122e88d371d77940208decde..3634145f52e1217d5153152e19de9a72daa5a497 100644 (file)
@@ -13,7 +13,9 @@ class MachineInfo extends React.Component {
         super(props);
         this.state = {
             machineNo: this.props.match.params.machine_sn,
-            branches:[],
+            branches: [
+                {'branch':0,'value':0}
+            ],
             machineInfo: {},
             isLoading: false,
             currentPage: 1,
@@ -98,7 +100,7 @@ class MachineInfo extends React.Component {
                 </div>
                 <div className="col-md-3">
                     {/*<Segment vertical>Farmer Info</Segment>*/}
-                    <FarmerDetailCard machine={this.state.machineInfo}></FarmerDetailCard>
+                    <FarmerDetailCard machine={this.state.machineInfo} branch_num={this.state.branches.length}></FarmerDetailCard>
                 </div>
 
                 <div className="col-md-9">
index 89b5160d07f656b0470b59452e7b926678088dad..27c34c728df5a8515543997be57450d6381da5a7 100644 (file)
@@ -84,7 +84,7 @@ class MachineRecordTable extends React.Component {
 
 
                     <Table.Cell textAlign='center'>
-                        <Link color='linkedin' to={'detailInfo/' + record.uuid}>
+                        <Link color='linkedin' to={'/detailInfo/' + record.uuid}>
                             <Icon name='linkify'/> Link
                         </Link>
                     </Table.Cell>