<template>
  <div class="app-bg auto">
    <div class="row app-input">
      <span class="col-xs-4 control-label">抄表人：</span><span class="col-xs-8">{{model.f_inputtor_name}}</span>
    </div>
    <div class="row app-input">
      <span class="col-xs-4 control-label">公司：</span><span class="col-xs-8">{{model.f_fengongsi}}</span>
    </div>
    <div class="row app-input">
      <label class="col-xs-4 control-label">表册号</label>
      <input class="col-xs-8" v-model="model.f_meterbook_id" placeholder="请输入表册号">
    </div>
    <div class="row app-input">
      <label class="col-xs-4 control-label">所属月份</label>
      <input class="col-xs-8" v-model="model.f_hand_date" placeholder="请输入所属月份">
    </div>
    <div class="row app-btn">
      <button class="btn btn-primary col-xs-6" @click="MissionSearch()"><span class="glyphicon glyphicon-zoom-in"></span>查询</button>
      <!-- @click="UploadData()" -->
      <!-- <button class="btn btn-primary col-xs-6" ><span class="glyphicon glyphicon-zoom-in" ></span>汇总</button> -->
    </div>
    <div v-for='row in userinfo' class="app-list">
      <div class="row app-btn" style="color: #00B9F1;" @click="information(row)">
        <span class="col-xs-3">序号：</span><span class="col-xs-3">{{$index}}</span>
        <span class="col-xs-3">表册号：</span><span class="col-xs-3">{{row.f_meterbook_id}}</span>
      </div>
      <div class="row">
        <span class="col-xs-3">所属月份：</span><span class="col-xs-3">{{row.f_hand_date}}</span>
        <span class="col-xs-3">合计：</span><span class="col-xs-3">{{row.yichao + row.weichao}}</span>
      </div>
      <div class="row">
        <span class="col-xs-3">已抄：</span><span class="col-xs-3">{{row.yichao}}</span>
        <span class="col-xs-3">未抄：</span><span class="col-xs-3">{{row.weichao}}</span>
      </div>
    </div>
  </div>
</template>

<script>
import co from 'co'
import * as Util from './Util'
import appData from './appData'
import config from './config'
// 任务查询
let msearch = function * (self) {
  console.log('拿到的数据' + JSON.stringify(appData))
  //config.resultUrl +
  // yield self.$post( 'rs/sql/missionsearch', {data: {f_inputtor:appData.loginUser.logininfo[0].f_bieming,f_meterbook_id:self.model.f_meterbook_id,f_hand_date:self.model.f_hand_date}},
  yield self.$post( 'rs/sql/missionsearch', {data: {f_inputtor:appData.loginUser.logininfo[0].f_bieming,f_meterbook_id:self.model.f_meterbook_id,f_hand_date:self.model.f_hand_date}},
   {resolveMsg: null, rejectMsg: null})
  .then ((res)=> {
    self.userinfo = res.data
  })
  .catch ((res)=> {
    self.$showMessage('获取任务失败，请查看你输入的查询信息')
  })
}

export default {
  title:'test',
  data(){
    return{
      model:{
        f_meterbook_id:'',
        f_hand_date: '',
        f_inputtor_name:'',
        f_fengongsi:''
      },
      userinfo: [],
      handplandata:[]
    }
  },
  methods: {
    // 具体计划查询
    information(row) {
      this.$goto('meter-userinfsearch', {rowdata: row})

    },
    // 用户任务查询
    MissionSearch() {
      let gen = msearch(this)
      return co(gen)
    }
  },
  ready () {
    this.MissionSearch()
    console.log(appData);
    console.log('111111'+ appData.loginUser);
    this.$post('rs/sql/inputtormsg',{data:{condition:appData.loginUser.logininfo[0].f_bieming}},
    {resolveMsg: null, rejectMsg: null})
    .then ((res)=> {
    console.log('123'+JSON.stringify(res.data[0]));
      this.model.f_inputtor_name = res.data[0].name
      this.model.f_fengongsi = res.data[0].fengongsi
    })
    .catch ((res)=> {
      self.$showMessage('获取任务失败，请查看你输入的查询信息')
    })
  }
}
</script>
