<template>
  <div class="auto select-overspread">
    <div class="panel panel-info">
      <div class="panel-heading">
        <h3 class="panel-title">修改用户信息</h3>
      </div>
    </div>
    <validator name="v">
      <form class="form-horizontal">
        <div class="col-sm-12 form-group" style="margin-top: 100px;">
          <div class="col-sm-4" :class="[$v.f_gasmun.required ? 'has-error': '']">
            <label class="col-sm-6 control-label">供气量:</label>
            <div class="col-sm-4">
              <input type="text" onkeyup="value=value.replace(/[^\.\d]/g,'')"  onblur="value=value.replace(/[^\.\d]/g,'')" onblur="this.v();" class="form-control" v-model="model.f_gasmun" v-validate:f_gasmun='{required: true }'/>
            </div>
          </div>
          <div class="col-sm-4" :class="[$v.f_gasunits.required ? 'has-error': '']">
            <label class="col-sm-6 control-label">供气单位：</label>
            <div class="col-sm-4">
              <input type="text" class="form-control" v-model="model.f_gasunits" v-validate:f_gasunits='{required: true }'/>
            </div>
          </div>
          <!--<div class="col-sm-4"  :class="[$v.fcredentials.required ? 'has-error select-error': '']">-->
            <!--<label class="col-sm-6 control-label">证件类型:</label>-->
            <!--<div class="col-sm-4">-->
              <!--<input type="text" v-show="false" v-model="$refs.fcredentials.value[0]" v-validate:fcredentials='{required: true }'>-->
              <!--<v-select :value.sync="model.f_credentials" v-model="model.f_credentials" v-ref:fcredentials :options='credentials'-->
                        <!--placeholder='请选择' close-on-select></v-select>-->
            <!--</div>-->
          <!--</div>-->
          <!--//<div class="col-sm-4"  :class="[$v.f_gasdate.required ? 'has-error select-error': '']"></div>-->
          <div class="col-sm-4">
            <label for="startDate" class="col-sm-6 control-label">供气时间:</label>
            <div class="col-sm-4" >
              <datepicker id="startDate" placeholder="开始日期"
                          v-model="model.f_gasdate"
                          :value.sync="model.f_gasdate"
                          :disabled-days-of-Week="[]"
                          :format="'yyyy-MM-dd'"
                          :show-reset-button="reset">
              </datepicker>
            </div>
          </div>


        </div>
        <div class="col-sm-12 form-group">

          <div class="col-sm-4" :class="[$v.f_department.required ? 'has-error': '']">
            <label class="col-sm-6 control-label">操作部门：</label>
            <div class="col-sm-4">
              <input type="text" class="form-control" v-model="model.f_department" v-validate:f_department='{required: true }'/>
            </div>
          </div>
          <!--<div class="col-sm-4" :class="[$v.f_password.required ? 'has-error': '']">-->
            <!--<label class="col-sm-6 control-label">密码:</label>-->
            <!--<div class="col-sm-4">-->
              <!--<input type="text" class="form-control" v-model="model.f_password" v-validate:f_password='{required: true }'/>-->
            <!--</div>-->
          <!--</div>-->
        </div>
        <div class="col-sm-12 form-group">


        </div>
        <div class="col-sm-12 form-group">
          <div class="col-sm-4">
            <label class="col-sm-6 control-label">分公司:</label>
            <div class="col-sm-4">
              <input type="text" class="form-control" v-model="model.f_filiale" disabled/>
            </div>
          </div>
          <div class="col-sm-4">
            <label class="col-sm-6 control-label">操作时间:</label>
            <div class="col-sm-4">
              <input type="text" class="form-control" v-model="model.f_date" disabled/>
            </div>
          </div>
          <div class="col-sm-4">
            <label class="col-sm-6 control-label">操作人:</label>
            <div class="col-sm-4">
              <input type="text" class="form-control" v-model="model.f_operator" disabled/>
            </div>
          </div>
        </div>
      </form>
    </validator>
    <div class="col-sm-12 form-group" style="margin-top: 40px;">
      <center>
        <button type="button" @click="confirm()" class="btn btn-primary" style="width:80px; margin-left:40px;" :disabled='$v.invalid'>
          保存
        </button>
        <button  type="button" @click="reset()" class="btn btn-warning" style="width:80px; margin-left:40px;">
          撤销
        </button>
      </center>
    </div>
  </div>
</template>
<script>
  import * as Util from '../../stores/Util'
  //import AppData from '../../../../stores/AppData'
  export default {
    title: '添加人员信息',
    data () {
      return {
        model: {
           //f_filiale: Util. f.f_fengongsi,
          //id: 185,
          f_filiale: null,
           f_date: Util.toStandardDateString(),
          // f_operator: Util.f.name,
          f_operator: null,
           f_gasdate: Util.toStandardDateString(),
          f_gasmun : null,
          f_gasunits : null,
          f_department : null
        }
      }
    },
    props: ['upperson'],
    ready () {
      this.$nextTick(() => {
        this.$dispatch('hiddenpaged')
        // this.upperson.f_credentials = this.upperson.f_credentials ?  this.upperson.f_credentials : this.model.f_credentials
        // this.upperson.f_inputtor_type = this.upperson.f_inputtor_type ?  this.upperson.f_inputtor_type : this.model.f_inputtor_type
        // this.upperson.f_parentname = this.upperson.f_parentname ?  this.upperson.f_parentname : this.model.f_parentname
        // this.model = Object.assign({}, this.model, this.upperson)
        // this.model.f_credentials = [this.model.f_credentials]
        // this.model.f_inputtor_type = [this.model.f_inputtor_type]
        // this.model.f_parentname = [this.model.f_parentname]
        console.log("组件之间的传值 f_gasmun,f_gasunits,f_department")
        this.model = Object.assign({}, this.model, this.upperson) //添加id，识别是否为更新操作
        console.log(this.upperson.f_gasmun);
        console.log(this.model.f_gasmun);
        console.log(this.upperson.f_gasunits);
        console.log(this.upperson.f_department)
        //thi.model.id = this.upperson.id
        this.model.f_gasmun = this.upperson.f_gasmun //? this.upperson.f_gasmun :this.model.f_gasmun;
        this.model.f_gasunits = this.upperson.f_gasunits //? this.upperson.f_gasunits :this.model.f_gasunits;
        this.model.f_department = this.upperson.f_department //? this.upperson.f_department :this.model.f_department;
      })
    },
    methods: {
      confirm() {
        console.log(this.model),
        this.model.f_gasdate //= this.model.startDate;//供气时间赋值
        //姓名相同所以不需要赋值
        this.model.f_department=this.model.f_department;//操作部门
        this.model.f_filiale //= this.model.f_fengongsi;//分公司赋值
        this.model.f_date //= this.model.f_operator_date;//操作日期赋值
        this.$resetpost('rs/entity/t_supplygas', this.model).then(() => {
          this.reset()
        })
      },
      reset () {
        this.$dispatch('close')
      }
    },
    watch: {
      'upperson' () {
        this.$nextTick(() => {
          this.$dispatch('hiddenpaged')
          // this.upperson.f_credentials = this.upperson.f_credentials ?  this.upperson.f_credentials : this.model.f_credentials
          // this.upperson.f_inputtor_type = this.upperson.f_inputtor_type ?  this.upperson.f_inputtor_type : this.model.f_inputtor_type
          // this.upperson.f_parentname = this.upperson.f_parentname ?  this.upperson.f_parentname : this.model.f_parentname
          // this.model = Object.assign({}, this.model, this.upperson)
           this.model.f_gasmun = [this.model.f_gasmun]
           this.model.f_gasunits = [this.model.f_gasunits]
           this.model.f_date = [this.model.f_date]
        })
      }
    },
    computed: {
      // credentials (){
      //   return AppData.getParam("证件类型")
      // },
      // inputtortype () {
      //   return AppData.getParam("角色类型")
      // },
      // parentname () {
      //   return AppData.getParam("营业网点")
      // }
    }
  }
</script>

