<template>
  <div class="auto">
    <form class="form-horizontal">
      <div class="row" style="margin-top:6px;">
        <div class="col-sm-6" >
          <label  class="font_normal_body"  title="参数:安装位置">安装位置</label>
          <v-select :value.sync="model.f_position" v-model="model.f_position"
                    :options='positions' placeholder='安装位置'
                    close-on-select></v-select>
        </div>
        <div class="col-sm-6">
          <label class="font_normal_body" title="参数:左右表">&nbsp;&nbsp;&nbsp;左右表</label>
          <v-select :value.sync="model.f_aroundmeter" v-model="model.f_aroundmeter"
                    :options='aroundmeters' placeholder='左右表'
                    close-on-select v-ref:f_aroundmeter></v-select>
        </div>
      </div>
      <div class="row" style="margin-top:6px;">
        <div class="col-sm-6">
          <label class="font_normal_body">&nbsp;&nbsp;&nbsp;安装人</label>
          <input type="text" class="input_search" style="width:60%" v-model="model.f_install_person" placeholder='安装人'></input>
        </div>

        <div class="col-sm-6">
          <label class="font_normal_body">安装日期</label>
          <datepicker style="width:60%" placeholder="安装日期"
                      v-model="model.f_install_date"
                      :value.sync="model.f_install_date"
                      class="datepicker"
                      :format="'yyyy-MM-dd HH:mm:ss'"
                      :show-reset-button="true">
          </datepicker>
        </div>
      </div>
      <div class="row" style="margin-top:6px;">
        <div class="col-sm-6">
          <label class="font_normal_body">&nbsp;&nbsp;&nbsp;通气人</label>
          <input type="text" class="input_search" style="width:60%" v-model="model.f_gas_person" placeholder='通气人'></input>
        </div>
        <div class="col-sm-6">
          <label class="font_normal_body">通气日期</label>
          <datepicker style="width:60%" placeholder="通气日期"
                      v-model="model.f_gas_date"
                      :value.sync="model.f_gas_date"
                      class="datepicker"
                      :format="'yyyy-MM-dd HH:mm:ss'"
                      :show-reset-button="true">
          </datepicker>
        </div>
      </div>
      <div class="row" style="margin-top:6px;">
        <div class="col-sm-6">
          <label class="font_normal_body">&nbsp;&nbsp;&nbsp;改管人</label>
          <input type="text" class="input_search" style="width:60%"  v-model="model.f_changetube_person" placeholder='改管人'></input>
        </div>
        <div class="col-sm-6">
          <label class="font_normal_body">改管日期</label>
          <datepicker style="width:60%" placeholder="改管日期"
                      v-model="model.f_changetube_date"
                      :value.sync="model.f_changetube_date"
                      class="datepicker"
                      :format="'yyyy-MM-dd HH:mm:ss'"
                      :show-reset-button="true">
          </datepicker>
        </div>
      </div>
      <div class="row" style="margin-top:6px;">
        <div class="col-sm-6">
          <label class="font_normal_body" >&nbsp;&nbsp;&nbsp;抄表员</label>
          <v-select :value.sync="model.f_inputtor" placeholder='抄表员'
                    :options='inputtores' v-model="model.f_inputtor"
                    v-ref:f_inputtor
                    close-on-select ></v-select>
        </div>
        <div class="col-sm-6">
          <label class="font_normal_body" title="参数:使用状态">使用状态</label>
          <v-select :value.sync="model.f_usestate" placeholder='使用状态'
                    :options='usestate' v-model="model.f_usestate"
                    v-ref:f_inputtor
                    close-on-select ></v-select>
        </div>
      </div>
      <div class="row" style="margin-top:6px;">
       <div class="col-sm-6">
          <label class="font_normal_body" >抄表月份</label>
          <v-select :value.sync="model.f_hand_month" placeholder='抄表月份'
                    :options='handmonth' v-model="model.f_hand_month"
                    v-ref:f_hand_month
                    close-on-select ></v-select>
       </div>
      </div>
      <div class="row" >
        <div class="col-sm-12">
          <label for="f_comments" class="font_normal_body">&nbsp;&nbsp;&nbsp;备&nbsp;&nbsp;&nbsp;注</label>
          <input class="input_search" style="width:80%" v-model="model.f_comments" :value.sync="model.f_comments" rows="1" placeholder="备注">
        </div>
      </div>



    </form>
  </div>
</template>
<script>
  import Vue from 'vue'

  var data
  export default {
    title: '基本信息',

    data () {
      return {
        model: {
          f_inputtor: '',
          f_position: '',
          f_aroundmeter: '',
          f_install_person: '',
          f_hand_month: '',
          f_install_date: '',
          f_gas_person: '',
          f_gas_date: '',
          f_changetube_person: '',
          f_changetube_date: '',
          f_usestate: '',
          f_comments: ''

        },
        uploadText: '换表',
        // 构建数组来存储对象
        editbank: true,
        recordList: [],
        changestate: [{label: '有效', value: '有效'}, {label: '无效', value: '无效'}],
        handmonth: [{label: '全部', value: ''}, {label: '单月', value: '单月'}, {label: '双月', value: '双月'}]
      }
    },
    props: {
    },

    created () {
    },
    methods: {
      cancel () {
        this.$dispatch('close')
      },
      init () {
        this.model = {
          f_inputtor: '',
          f_position: '',
          f_aroundmeter: '',
          f_install_person: '',
          f_hand_month: '',
          f_install_date: '',
          f_gas_person: '',
          f_gas_date: '',
          f_changetube_person: '',
          f_changetube_date: '',
          f_comments: ''
        }
      }

    },
    computed: {

      aroundmeters () {
        return this.$appdata.getParam('左右表')
      },
      positions () {
        return this.$appdata.getParam('安装位置')
      },
      usestate () {
        return this.$appdata.getParam('使用状态')
      },
      inputtores () {
        // 获取抄表员
        console.log('获取抄表员', this.$login.f)
        let rs = []
        rs.push({'label': '全部', 'value': ''})
        if (this.$login.f.f_gasman.length > 0) {
          for (let i = 0; i < this.$login.f.f_gasman.length; i++) {
            let temp = {
              label: this.$login.f.f_gasman[i].name,
              value: this.$login.f.f_gasman[i].name
            }
            rs.push(temp)
          }
        }
        return [ ...rs]
      },
      installperson () {
        // return this.$login.f.f_installman
        let rs = new Array()
        for (let i = 0; i < this.$login.f.f_installman.length; i++) {
          let temp = {
            label: this.$login.f.f_installman[i].name,
            value: this.$login.f.f_installman[i].name
          }
          rs.push(temp)
        }
        return rs
      }

    },
    watch: {

      model: {
        handler: function (val) { // 此处注意，handler函数不能为箭头函数，this会取上下文，而不是组件里的this,此外，深度监听，必须为handler函数名，否则会无效果
          this.$emit('batchedit', val)
        },
        deep: true

      }

    }
  }
</script>
