<template>
  <modal :show.sync="$parent.show" v-ref:modal>
    <div slot="modal-header" class="modal-header">
      <h4 class="modal-title">
        隐患处理
      </h4>
    </div>
    <div slot="modal-body" class="modal-body">
      <div class="row auto">
      <div class="form-group">
        <label class="col-sm-12 control-label">隐患级别：</label>
        <div class="col-sm-12">{{defect.f_defect_level}}</div>
      </div>
      <div class="form-group">
        <label class="col-sm-12 control-label text-left">隐患：</label>
        <div class="col-sm-12">{{defect.f_defect}}</div>
      </div>
      <div class="form-group">
        <label class="col-sm-12 control-label">部位：</label>
        <div class="col-sm-12">{{defect.f_device_type}}</div>
      </div>
      <div class="form-group">
        <label class="col-sm-12 control-label">处理方式：</label>
        <div class="col-sm-12">
          <radio-group :value.sync="defect.f_resolve_type" type="success" buttons="false" disabled="disabled">
          <radio disabled="disabled" v-if="defect.f_resolve_type =='现场处理'" value="现场处理">现场处理</radio>
          <radio disabled="disabled" v-if="defect.f_resolve_type =='用户处理'" value="用户处理">用户处理</radio>
          <radio disabled="disabled" v-if="defect.f_resolve_type =='维修处理'"  value="维修处理">维修处理</radio>
        </radio-group></div>
      </div>
      <div class="form-group">
        <label class="col-sm-12 control-label">整改结果：</label>
        <div class="col-sm-12">
          <v-select id="f_ratification" :value.sync="f_ratification"
                    :options='ratifications' close-on-select clear-button></v-select></div>
      </div>
      <div class="form-group">
        <label class="col-sm-12 control-label">处理人：</label>
        <div class="col-sm-12">
          <input type="text" class="form-control" v-model="defect.f_ratifiedpeople" maxlength="20">
          <!--<chooser :userid.sync='f.id' v-model="defect.f_ratifiedpeople" resource-type="user" :width='200' :select-data.sync='chosenOrg'></chooser>-->
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-12 control-label">处理时间：</label>
        <div class="col-sm-12"><datepicker id="f_end"
                      :value.sync="defect.f_ratifieddate"
                      :disabled-days-of-Week="[]" :format="'yyyy-MM-dd'"></datepicker></div>
        </div>
      <div class="form-group">
        <label class="col-sm-12 control-label">备注：</label>
        <div class="col-sm-12"><textarea  class="form-control"  v-model="defect.f_remark" rows="3"></textarea></div>
      </div>
      </div>
    </div>
    <div slot="modal-footer" class="modal-footer">
      <button type="button" class="btn btn-default" @click="$parent.todo(defect)" v-if="!defect.flag">保存</button>
      <button type="button" class="btn btn-default" @click="$parent.undo">取消</button>
    </div>
  </modal>
</template>

<script>
  import { PagedList } from 'vue-client'
  import Vue from 'vue'
  import * as Util from '../Util'
  import RadioGroup from 'vue-client/src/vue-strap/src/radioGroup'
  import Radio from 'vue-client/src/vue-strap/src/radioBtn'

  export default {
        title:'隐患处理',
        props:['defect','f'],
    data(){
          return {
            model: {},
            chosenOrg:{id:0},
            ratifications:[
                {label: '请选择处理结果', value: null},
                {label: '未处理', value: '未处理'},
                {label: '已处理', value: '已处理'},
              ],
          }
    },
    components: {
      RadioGroup,
      Radio
    },
    watch:{
         'f_ratification'(val){
            if(this.defect.f_ratification)
              this.defect.f_ratification = this.f_ratification[0]
          },
          'defect'(val){
            this.defect.id = this.defect.defectid
            this.f_ratification = this.defect.ratification
            this.defect.f_remark = this.defect.remark
        }
     },
    }
</script>

