<template>
  <form novalidate class="form-horizontal" style="width: 95%;margin: auto;position: relative;top: 40px">
    <div class="form-group col-sm-12 col-xs-12 col-md-12 info">
      <div class="text-center">
        <label class="font">检查说明：</label>
        <div class="col-md-12 col-sm-12 col-xs-12">
          <ol class="showInput">
            <li>已对客户燃气设施进行了安全检查</li>
            <li>已对客户进行了安全知识宣传，并发放宣传资料</li>
            <li>已对客户的资料进行了登记</li>
            <li>已对违章及隐患之客户下发隐患整改告知书</li>
          </ol>
        </div>
      </div>
    </div>
    <!--
        <div class="form-group col-sm-12 col-xs-12 col-md-12 info">
          <div class="text-center">
            <label class="font">安检告知书单号：</label>
          </div>
          <div class="col-md-12 col-sm-12 col-xs-12">
         <input type="number" v-model="paper.f_notification_number"/>
          </div>
        </div>-->
    <div class="col-md-12 col-sm-12 col-xs-12">
      <span class="col-md-3 col-sm-5 col-xs-4">工商用户安检登记表单号:</span>
      <div class="col-md-9 col-sm-7 col-xs-8">
        <input  style="width: 100%" type="number" v-model="paper.f_notification_number" class=" form-control text-center time-input"  :disabled="role == 'androidview'"/>
      </div>
    </div>
    <div class="col-md-12 col-sm-12 col-xs-12">
      <span class="col-md-3 col-sm-5 col-xs-4">安全隐患整改告知书单号:</span>
      <div class="col-md-9 col-sm-7 col-xs-8">
        <input  style="width: 100%" type="number" v-model="paper.f_defect_number" class=" form-control text-center time-input"  :disabled="role == 'androidview'"/>
      </div>
    </div>
    <div class="col-md-12 col-sm-12 col-xs-12">
      <label class="text-left font col-md-12 col-sm-12 col-xs-12">备注</label>
      <div class="col-md-12 col-sm-12 col-xs-12">
        <textarea  style="width: 100%" v-model="paper.f_remark" class=" form-control time-input" :disabled="role == 'androidview'"></textarea>
      </div>
    </div>
    <div class="col-md-12 col-sm-12 col-xs-12" v-if="paper.f_no_checkplan ==  '重点用户跟进单'">
      <label class="text-left font col-md-12 col-sm-12 col-xs-12">户内情况</label>
      <div class="col-md-12 col-sm-12 col-xs-12">
        <textarea  style="width: 100%" v-model="paper.f_indoor_circumstance" class=" form-control time-input" :disabled="role == 'androidview'"></textarea>
      </div>
    </div>

    <div style="width: 95%;margin: auto" >
      <div class="flex panel panel-default well" style="width: 100%;display: inline-block">
        <div class="panel-body bg-info">
          <div class="text-center">
            <label class="control-label" style="font-weight: bold">隐患结果统计</label>
          </div>
          <ul class="list-unstyled panel-ul">
            <li >
              <div partial class="panel panel-default well" style="padding: 0px">
                <div class="panel-body inbg">
                  <p style="margin-bottom: 5px">
                   <span class="li-font">
                       安检结果:{{deviceresult}}
                      </span>
                  </p>
                  <div class="row col-xs-12 col-sm-12 col-md-6 form-group" v-for="deviceCollect in deviceCollects">
                    <div class="row col-xs-12 col-sm-12 col-md-6" >
                      <p class="li-font">
                        {{deviceCollect.name}}:{{deviceCollect.deviceInfos}}&nbsp;&nbsp;&nbsp;
                      </p>
                    </div>
                    <!--<div class="row col-xs-12 col-sm-6 col-md-6" v-if="deviceCollect.value == '有隐患'">-->
                    <!--<lable>-->
                    <!--隐患:-->
                    <!--</lable>-->
                    <!--<span class="li-font" v-for="val in deviceCollect.devices">-->
                    <!--{{val}}&nbsp;&nbsp;&nbsp;-->
                    <!--</span>-->
                    <!--</div>-->
                  </div>
                </div>
              </div>
              <partial name="default"></partial>
            </li>
          </ul>

        </div>
      </div>


    </div>
    <div class="form-group col-sm-12">
      <label class="text-left font">隐患照片</label>

      <div class="auto col-sm-12">
        <div class="panel" style="padding: 10px 10px 5px 10px;">
          <div class="panel-body panel-self col-sm-12" style="background-color: #F8F8F8;width: 100%;height: 260px;position: relative">
            <div class="row col-xs-12 col-sm-12 col-md-6" style="height: 240px;overflow: scroll;top: 1px" >
              <div class="col-xs-4 col-sm-3 col-md-2" style="margin-bottom: 35px" v-for="img in picture">
                <img-self :src="img.f_path" :alt="img.name" :width="140" :height="170"></img-self>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="form-group col-xs-12 col-sm-12" style="margin-top: 10px" v-if="showNew && role =='androidview'">
      <div class="auto" style="width: 100%;float: left;" >
        <label class="text-left font">总体安检照片</label>
        <div class="auto">
          <div class="panel">
            <div class="panel-body panel-self" style="background-color: #F8F8F8;width: 100%;height: 260px;position: relative">
              <div class="row" style="height: 240px;overflow: scroll;top: 1px">
                <div class="row">
                  <div class="col-xs-4 col-sm-3 col-md-2" style="margin-bottom: 10px;margin-right: 30px" v-for="(index,img) in paper.f_all_imgs">
                    <img-self :src="img.f_overall_path" alt="总体安检照片" :width="150" :height="200"></img-self>
                    <!--<img src="../../assets/remove.png" @click="delfile('f_overall_path', img.f_overall_path,index)" class="imgs" style="width: 30px;" alt="">-->
                  </div>
                </div>
              </div>
              <div class="row text-right div-photo">
                <!--<button type="button" name="button" class="btn btn-primary btn-photo" @click="takePic('f_overall_path', '总体安检照片1')">拍照</button>-->
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>


    <div class="form-group col-sm-12" v-if="showOld &&  role =='androidview'">
      <label class="text-left font">总体安检照片</label>
      <div class="auto">
        <div class="panel" style="padding: 10px 10px 5px 10px;">
          <div class="panel-body panel-self col-xs-12 col-sm-12" style="background-color: #F8F8F8;width: 100%;height: 260px;position: relative">
            <div class="row col-xs-12 col-sm-12 col-md-6" style="height: 240px;overflow: scroll;top: 1px" >
              <div class="col-xs-4 col-sm-3 col-md-2" style="margin-bottom: 10px;margin-right: 30px" v-for="(index,img) in paper.f_all_imgs">
                <img-self :src='`${this.$androidUtil.getProxyUrl()}/rs/getImg/readBlob?id=`+img.f_blob_id' alt="总体安检照片"  :width="150" :height="200"></img-self>
                <!--<img src="../../assets/remove.png" @click="delfile('f_overall_path', img.f_overall_path,index)" class="imgs" style="width: 30px;" alt="">-->
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="form-group col-sm-12" v-if="showNewest">
      <label class="text-left font">总体安检照片</label>
      <div class="auto">
        <div class="panel">
          <div class="panel-body panel-self col-xs-12 col-sm-12" style="background-color: #F8F8F8;width: 100%;height: 260px;position: relative">
            <div class="row col-xs-12 col-sm-12 col-md-12" style="height: 240px;overflow: scroll;top: 1px" >
              <div class="col-xs-4 col-sm-3 col-md-2 " v-for="(index,img) in paper.f_all_imgs">
                <div class="panel-self" style="margin-bottom: 35px" v-if="img.title != '其他'" >
                  <div id='img' style="margin: 4% 0 0 11%;">
                    <img-self :src="img.f_overall_path" :alt="总体安检照片" :width="140" :height="170"></img-self>
                  </div>
                  <!--<img src="../assets/cs0.png" @click="delfile('f_overall_path', img.f_overall_path,index)" style="width: 140px;height:170px" alt="">-->
                  <div class="row col-xs-12 col-sm-12 col-md-6 text-right div-photo1">
                    <span>{{img.title}}</span>
                    <button v-if="img.f_overall_path.includes('nopic.png') && role !='androidview'" type="button" name="button" class="btn btn-photo" @click="takePic(img.type, img.title,index)">拍照</button>
                    <button v-if="!img.f_overall_path.includes('nopic.png') && role !='androidview'" type="button" name="button" class="btn btn-photo" @click="delfile('f_overall_path', img.f_overall_path,index)">删除</button>
                    <!--<button type="button" name="button" class="btn btn-primary btn-photo" @click="takePic('f_overall_path', '总体安检照片1')">拍照</button>-->
                    <!--&nbsp;&nbsp;&nbsp;&nbsp;<img src="../../../assets/remove.png" :class="style__" @click="delfile('f_overall_path', img.f_overall_path)" style="width: 25%;"></img>-->
                  </div>
                </div>
              </div>

            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="form-group col-sm-12" v-if="showNewest">
      <label class="text-left font">总体安检其他照片</label>
      <div class="auto">
        <div class="panel" style="padding: 10px 10px 5px 10px;">
          <div class="panel-body panel-self col-xs-12 col-sm-12" style="background-color: #F8F8F8;width: 100%;height: 260px;position: relative">
            <div class="row col-xs-12 col-sm-12 col-md-6" style="height: 240px;overflow: scroll;top: 1px" >
              <div style="height: auto" v-for="(index,img) in paper.f_all_imgs">
                <div class="col-xs-4 col-sm-3 col-md-2" v-if="img.title == '其他'" style="margin-bottom: 35px" >
                  <img-self :src="img.f_overall_path" alt="总体安检照片" :width="140" :height="170"></img-self>
                  <img src="../../assets/删除.png" @click="delfile('f_overall_path', img.f_overall_path,index,'其他')" style="width: 15px;" alt="" v-if="role !='androidview'">
                </div>
              </div>
            </div>

            <div class="row col-xs-12 col-sm-12 col-md-6 text-right div-photo" v-if="role !='androidview'">
              <button type="button" name="button" class="btn btn-photo" @click="takePic('f_overall_path', '其他','总体其他安检照片')">拍照</button>
              <!--<button type="button" name="button" class="btn btn-primary btn-photo" @click="takePic('f_overall_path', '总体安检照片1')">拍照</button>-->
              <!--&nbsp;&nbsp;&nbsp;&nbsp;<img src="../../../assets/remove.png" :class="style__" @click="delfile('f_overall_path', img.f_overall_path)" style="width: 25%;"></img>-->
            </div>
          </div>
        </div>
      </div>
    </div>


    <!--<div class="form-group col-sm-12">-->
    <!--<label class="text-left font">总体安检照片2</label>-->
    <!--<div class="auto">-->
    <!--<div class="panel">-->
    <!--<div class="panel-body panel-self" style="background-color: #F8F8F8;width: 100%;height: 260px;position: relative">-->
    <!--<div class="row col-xs-12 col-sm-6 col-md-6" style="height: 240px;overflow: scroll;top: 1px">-->
    <!--<div class="col-sm-4">-->
    <!--<img-self  :src="paper.f_overall2_path" alt="总体安检照片2" width="150" height="200"></img-self>-->
    <!--</div>-->
    <!--</div>-->
    <!--<div class="row col-xs-12 col-sm-6 col-md-6 text-right div-photo">-->
    <!--<button type="button" name="button" class="btn btn-primary btn-photo" @click="takePic('f_overall2_path', '总体安检照片2')">拍照</button>-->
    <!--&nbsp;&nbsp;&nbsp;&nbsp;<img src="../../../assets/remove.png" :class="style__"  @click="delfile('f_overall2_path', paper.f_overall2_path)" style="width: 25%;"></img>-->
    <!--</div>-->
    <!--</div>-->
    <!--</div>-->
    <!--</div>-->
    <!--</div>-->
    <!--    <div class="form-group col-sm-12">
          <label class="text-left font">用户签名</label>
          <div class="auto">
            <div class="panel">
              <div class="panel-body panel-self" style="background-color: #F8F8F8;width: 100%;height: 260px;position: relative">
                <div class="row col-xs-12 col-sm-6 col-md-6" style="height: 240px;overflow: scroll;top: 1px">
                  <div class="col-sm-4">
                    <img :class="style__" :src="paper.f_sign_path" :width="200" :height="150" />
                  </div>
                </div>
                <div class="row col-xs-12 col-sm-6 col-md-6 text-right div-photo">
                  <button type="button" name="button" class="btn btn-primary btn-photo" @click="sign">签名</button>
                </div>
              </div>
            </div>
          </div>
        </div>-->

    <div class="form-group col-md-12 col-sm-12 col-xs-12">
      <div  class="form-group col-md-12 col-sm-12 col-xs-12">
        <input type="checkbox" v-model="paper.f_defect_notified" class="showInput" />安检通知书/隐患整改通知书
      </div>
      <div class="form-group col-md-12 col-sm-12 col-xs-12" v-if="paper.f_defect_notified">
        <div  class="form-group col-md-12 col-sm-12 col-xs-12">
          <button type="button" @click="print()" :disabled="role == 'androidview'">打印隐患整改单</button>
        </div>
        <div  class="form-group col-md-12 col-sm-12 col-xs-12">
          <label class="text-left font">安检通知书/隐患整改通知书照片(要求能清晰反应安检通知单和用户签字内容)：</label>
          <div class="auto col-md-6 col-sm-6 col-xs-6" >
            <div class="panel" style="padding: 10px 10px 5px 10px;">
              <div class="panel-body panel-self" style="background-color: #F8F8F8;width: 100%;height: 260px;position: relative">
                <div class="row col-xs-12 col-sm-6 col-md-6" style="height: 240px;overflow: scroll;top: 1px">
                  <div class="col-sm-4">
                    <img-self  :src="paper.f_notified_path" alt="安检通知书/隐患整改通知书照片" width="150" height="200"></img-self>
                  </div>
                </div>
                <div class="row col-xs-12 col-sm-6 col-md-6 text-right div-photo">
                  <button type="button" name="button" class="btn btn-primary btn-photo" @click="takePic('f_notified_path', '安检通知书/隐患整改通知书照片')">拍照</button>
                  &nbsp;&nbsp;&nbsp;&nbsp;<img src="../../assets/remove.png" :class="style__" @click="delfile('f_notified_path', this.paper.f_notified_path)" style="width: 25%;"></img>
                </div>
              </div>
            </div>
          </div>
          <div class="auto col-md-6 col-sm-6 col-xs-6" >
            <div class="panel" style="padding: 10px 10px 5px 10px;">
              <div class="panel-body panel-self" style="background-color: #F8F8F8;width: 100%;height: 260px;position: relative">
                <div class="row col-xs-12 col-sm-6 col-md-6" style="height: 240px;overflow: scroll;top: 1px">
                  <div class="col-sm-4">
                    <img-self  :src="paper.f_notified1_path" alt="安检通知书/隐患整改通知书照片" width="150" height="200"></img-self>
                  </div>
                </div>
                <div class="row col-xs-12 col-sm-6 col-md-6 text-right div-photo">
                  <button type="button" name="button" class="btn btn-primary btn-photo" @click="takePic('f_notified_path', '安检通知书/隐患整改通知书照片')">拍照</button>
                  &nbsp;&nbsp;&nbsp;&nbsp;<img src="../../assets/remove.png" :class="style__" @click="delfile('f_notified1_path', this.paper.f_notified1_path)" style="width: 25%;"></img>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!--      <div class="col-sm-12 select-overspread">
              <span class="col-md-3 col-sm-4 col-xs-4" style="line-height: 20px;">安检人员:</span>
              <div class="col-md-9 col-sm-8 col-xs-8">
                <input  style="width: 100%" type="text" v-model="paper.f_order_checker_name" class=" form-control text-center time-input" :disabled="role == 'androidview'"/>
                &lt;!&ndash;<v-select :value.sync="paper.f_order_checker_name" v-model='paper.f_order_checker_name'&ndash;&gt;
                          &lt;!&ndash;:value-single="true" style="margin-top: 8px"&ndash;&gt;
                          &lt;!&ndash;:options='checkersid' placeholder='安检人员'&ndash;&gt;
                          &lt;!&ndash;close-on-select></v-select>&ndash;&gt;
              </div>
            </div>-->

      <div class="form-group" v-if="hasdefect"><!-- TODO 显示条件应为存在需要转维修的隐患 -->
        <span class="col-md-3 col-sm-4 col-xs-4">不转维修的理由:</span>
        <div class="col-md-9 col-sm-8 col-xs-8">
          <input  style="width: 100%" type="text" v-model="paper.f_reson" class=" form-control text-center time-input" :disabled="role == 'androidview'"/>
        </div>
      </div>
      <!--      <div class="form-group col-md-12 col-sm-12 col-xs-12">
              <div class="row col-xs-12 col-sm-12 col-md-12">
                <label class="text-left">请对我们的服务做出评价：</label>
              </div>
              <div class="col-xs-4 col-sm-4 col-sm-4"  v-for="item in radios">
                <input v-model="paper.f_client_evaluation" :value="item.label"  :checked='item.isChecked'  @click="check(item.value)" type="radio" :disabled="role == 'androidview'">{{item.label}}
              </div>

              &lt;!&ndash;<div class="col-sm-4">&ndash;&gt;
              &lt;!&ndash;<radio-group :value.sync="paper.f_client_evaluation" type="success" buttons="false">&ndash;&gt;
              &lt;!&ndash;<radio value="满意">满意</radio>&ndash;&gt;
              &lt;!&ndash;<radio value="基本满意">基本满意</radio>&ndash;&gt;
              &lt;!&ndash;<radio value="不满意">不满意</radio>&ndash;&gt;
              &lt;!&ndash;</radio-group>&ndash;&gt;
              &lt;!&ndash;</div> &ndash;&gt;
            </div>-->
      <div class="form-group col-md-12 col-sm-12 col-xs-12" >
        <div class="row col-xs-12 col-sm-12 col-md-12">
          <label class="text-left" >是否偷盗气用户：</label>
        </div>
        <div class="col-xs-4 col-sm-4 col-sm-4"  v-for="item in openRadioss">
          <input v-model="paper.f_promise_user" :value="item.label"  :checked='item.isChecked'  @click="checkOpens(item.value)" type="radio" :disabled="role == 'androidview'">
          <label >{{item.label}}</label>
        </div>
      </div>

      <div class="form-group col-md-12 col-sm-12 col-xs-12" v-if="paper.f_no_checkplan == '预约开户单'">
        <div class="row col-xs-12 col-sm-12 col-md-12">
          <label class="text-left" style="color: red">是否同意开户：</label>
        </div>
        <div class="col-xs-4 col-sm-4 col-sm-4"  v-for="item in openRadios">
          <input v-model="paper.f_allow_open" :value="item.label"  :checked='item.isChecked'  @click="checkOpen(item.value)" type="radio" :disabled="role == 'androidview'">
          <label style="color: red">{{item.label}}</label>
        </div>
      </div>
      <!--      <div class="form-group col-md-12 col-sm-12 col-xs-12">
              <label class="text-left font col-md-12 col-sm-12 col-xs-12">反馈录音:</label>
              <div class="col-md-12 col-sm-12 col-xs-12">
                <button type="button" name="button" class="btn btn-primary btn-voice" @click="record">
                  <img src="../../assets/录音.png" style="width: 14%;">
                  <span v-if="!paper.f_recording1_path">开始录音</span>
                  <span v-if="paper.f_recording1_path">已录音</span>
                </button>
                &nbsp;&nbsp;&nbsp;&nbsp;<img src="../../assets/remove.png" style="width: 15px;" :class="style__" @click="delAudioFile('f_recording1_path', paper.f_recording1_path)"></img>
              </div>
            </div>-->
      <div class="text-center form-group col-md-12 col-sm-12 col-xs-12">
        <button type="button" v-show="$parent.$parent.actionEnabled && item.f_upload_state != '已传' || (item.f_upload_state == '已传' && (paper.f_entry_status != '入户' || item.f_last_check_state != '入户') && role !='androidview') " class="btn save-btn" @click="thissave()">保存</button>
        <button id="upload" type="button" v-show="$parent.$parent.actionEnabled && item.f_upload_state != '已传' || (item.f_upload_state == '已传' && (paper.f_entry_status != '入户' || item.f_last_check_state != '入户') && role !='androidview') " class="btn upload-btn" @click="thisuploadCheckPaper" >上传</button>
        <button v-if="(safeCheckToRepair == true || safeCheckToRepair == 'true') && $parent.$parent.actionEnabled && item.f_upload_state != '已传' || (item.f_upload_state == '已传' && (paper.f_entry_status != '入户' || item.f_last_check_state != '入户') && role !='androidview')" class="btn repair-btn btn-warning" type="button" @click="showToRepair">上传并转维修</button>
      </div>
    </div>
  </form>
  <modal :show.sync="showCheckToRepair" v-ref:modal :backdrop="isback">
    <div slot="modal-header" class="modal-header">
      <h4 class="modal-title">
        安检转维修
      </h4>
    </div>
    <div slot="modal-body" class="modal-body">
      <div v-if="showrepair" class="width: 95%;margin: auto">
        <!--<div class="row col-xs-12 col-sm-6 col-md-6">-->
        <!--<label class="col-xs-4 col-md-4 control-label text-left">派单方式</label>-->
        <!--<div class="col-xs-8 col-md-8">-->
        <!--<label v-for="handling1 in handling" >-->
        <!--<input type="radio"-->
        <!--v-model="meading"-->
        <!--value="{{handling1.label}}">-->
        <!--{{handling1.label}}-->
        <!--</label>-->
        <!--</div>-->
        <!--</div>-->
        <!--<div class="row col-xs-12 col-sm-6 col-md-6" v-if="meading == '转站点'">-->
        <!--<label class="col-xs-4 col-md-4 control-label font text-left" for="f_reciever">站点</label>-->
        <!--&lt;!&ndash;<input type="text" v-show="false" v-model="serviceacitivity.f_reciever"&ndash;&gt;-->
        <!--&lt;!&ndash;v-validate:f_reciever='{ required: true }'>&ndash;&gt;-->
        <!--<div class="col-xs-8 col-md-8">-->
        <!--<right-tree @ready="onReady" islist :Url="Url" :userid="userid" :source="source"  v-on:re-res="reres" :textContent="选择站点管理员" :selectData="" v-ref:f_reciever>-->
        <!--</right-tree>-->
        <!--</div>-->
        <!--</div>-->

        <!--<div class="row col-xs-12 col-sm-6 col-md-6" style="margin-top: 6px" v-if="meading == '转维修员'">-->
        <!--<label class="col-xs-4 col-md-4 control-label font text-left">维修人</label>-->
        <!--<div class="col-xs-8">-->
        <!--<v-select :value="$parent.$parent.model.serviceacitivity[0].f_reciever" :value-single="true"-->
        <!--:options='f_repair_person' placeholder='请选择维修员'-->
        <!--close-on-select v-on:change="repiarmancg"></v-select>-->
        <!--</div>-->

        <!--</div>-->
        <!--<div class="row col-xs-12 col-sm-6 col-md-6" style="margin-top: 6px">-->
        <!--<label for="f_repair" class="col-xs-4 col-md-4 control-label font text-left">报修类型</label>-->
        <!--<div class="col-xs-8 col-md-8">-->
        <!--<v-select :value.sync="$parent.$parent.model.f_repairtype" :value-single="true"-->
        <!--:options='repairstypes' placeholder='报修类型'-->
        <!--close-on-select>-->
        <!--</v-select>-->
        <!--</div>-->
        <!--</div>-->

        <div class="row col-xs-12 col-sm-12 col-md-6" style="margin-top: 6px">
          <label class="control-label font text-left col-sm-4 col-md-4 col-xs-4">备注</label>
          <div class="col-xs-8 col-md-8">
            <input type="text" v-model="paper.f_remarks"/>
          </div>

        </div>

      </div>
      <div v-if="!showrepair">
        暂无隐患设备信息
      </div>
    </div>
    <div slot="modal-footer" class="modal-footer">
      <button type="button" class="btn btn-default" v-if="showrepair" @click="uploadPaper()">确定</button>
      <button type="button" class="btn btn-default" @click="undo()">取消</button>
    </div>
  </modal>
</template>

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

// let getRepairParam = function * (self){
//   let data = {
//     $parent.$parent.model: self.$parent.$parent.model, loginUser: {
//       name: self.role == 'view'?self.$login.f.name:Vue.user.name,
//       ename: self.role == 'view'?self.$login.f.ename:Vue.user.ename
//     }, user: self.user, callObj: self.callObj
//   }
//   if(self.$parent.$parent.meading == '转维修员'){
//     data.toRepair = '一级派单'
//   }
//   data.$parent.$parent.model.f_attendant = data.loginUser.name
//   console.log('===================')
//   console.log(data)
//   let res
//   let errString = self.$parent.$parent.errorVerify()
//   if(errString){
//     console.log(errString)
//     if (Vue.android)
//       self.undo()
//     this.$showMessage(errString)
//     return
//   } else {
//     if(self.role == 'inspect'){
//       if(self.$parent.$parent.meading == '转维修员' && (self.$parent.$parent.model.serviceacitivity[0].f_reciever == '' || self.$parent.$parent.model.serviceacitivity[0].f_reciever == undefined)){
//         this.$showMessage("请选择维修员!")
//         return
//       }
//       if(self.$parent.$parent.meading == '转站点' && (self.$parent.$parent.model.serviceacitivity[0].f_reciever == '' || self.$parent.$parent.model.serviceacitivity[0].f_reciever == undefined)){
//         HostApp.alert()
//         this.$showMessage("请选择站点!")
//         return
//       }
//       if(self.$parent.$parent.model.f_repairtype == ''){
//         this.$showMessage("请选择报修类型!")
//         return
//       }
//       console.log("转维修数据1：==》"+JSON.stringify(data))
//       let checkResult = '正常'
//       let options = [{"data": "已处理"},{"data": "未处理"}]
//       let value = ''
//       let codata = JSON.parse(JSON.stringify(self.paper))
//       for(let device in codata){
//         console.log('转维修codata[device]'+JSON.stringify(codata[device]))
//         let f_device_type
//         if(device.startsWith("device")){
//           for(let item in codata[device]) {
//             if(codata[device].length > 1 ){
//               let j = Number.parseInt(item)+1
//               f_device_type = `${codata[device][item].f_device_type}${j}`
//             }else{
//               f_device_type = codata[device][item].f_device_type
//             }
//             // console.log('codata[device][item]=>',codata[device][item])
//             let details = []
//             for(let i in codata[device][item].f_items){
//               let items = codata[device][item].f_items[i]
//               console.log('items',items)
//               if(items.f_is_defect == true || items.f_is_defect == 'true'){
//                 checkResult = '有隐患'
//                 console.log('类型----',f_device_type)
//                 let res = yield self.$resetpost(`${self.Url}/rs/sql/getDeviceItem`,{data:{f_device_id:codata[device][item].f_device_id,f_item_name:items.f_item_name}})
//                 console.log('获取安检设备信息结果=》'+JSON.stringify(res))
//                 self.$set('detail.f_defect_id', res.data[0].id)
//                 self.$set('detail.f_project',`${items.f_item_name}：${items.f_item_value}`)
//                 self.$set('detail.type',items.type)
//                 self.$set('detail.options',options)
//                 details.push(JSON.parse(JSON.stringify(self.detail)))
//               }
//               if(items.type == 'selector'){
//                 items.selected = ''
//               }
//               self.detail = {}
//             }
//             console.log('details',details)
//             self.$set('defectDevice.f_type',f_device_type)
//             self.$set('defectDevice.details',details)
//             if(self.defectDevice.details.length >0 ){
//               self.repairitems.push(JSON.parse(JSON.stringify(self.defectDevice)))
//             }
//             self.defectDevice = {}
//             console.log('repairitems===>'+self.repairitems)
//           }
//         }
//       }
//       self.$set('$parent.$parent.model.f_repairitems.data',self.repairitems)
//
//
//       console.log("转维修数据2：==》"+JSON.stringify(data))
//       res = self.$androidUtil.bzLogic('safecheckToRepair',data)
//       console.log('res==========')
//       console.log(res.code)
//       console.log(res.data)
//       if(res.code == 200){
//         self.$parent.$parent.isSafeCheckToRepair = true
//         self.undo()
//         self.$set('paper.f_SafeToRepair_id',res.data.f_service_id)
//         console.log('更新维修单id')
//         self.$resetpost(`${self.Url}/rs/logic/updatePaperRepair`,{data:{f_paper_id:self.paper.f_paper_id,f_SafeToRepair_id:res.data.f_service_id}}).then((ret)=>{
//           console.log('ret==>'+ret)
//           if(ret.data.code ==200){
//             console.log('维修单id修改成功')
//             self.$parent.$parent.$back()
//           }else{
//             self.$showMessage('安检转维修失败！')
//           }
//         }).catch(v=>{
//           console.log('v=>'+JSON.stringify(v))
//           self.$showMessage('安检转维修失败！')
//         })
//       }else{
//         self.$showMessage('安检转维修失败！')
//       }
//     }
//   }
// }



// let getRepairs = async function(self,url) {
//   // 获取配置信息
//   try {
//     let val = {source: 'this.getParentByType($department$).getChildByName($维修员$).getUsers()', userid: `${Vue.$login.jwt}`}
//     let repairs =[]
//     let res = await Vue.resetpost(`${url}/rs/search`,{data: val},{resolveMsg: null, rejectMsg: null})
//     res.data.forEach((item) => {
//       repairs.push({label: item.name, value: item})
//     })
//     self.f_repair_person = repairs
//     if(self.$parent.$parent.role == 'inspect'){
//       let res = self.$androidUtil.bzLogic('getUserInfo',{id:self.paper.f_userinfoid})
//       if(res.code == 200){
//         self.$parent.$parent.user = res.data[0]
//         self.$parent.$parent.model.f_area = self.$parent.$parent.user.f_area
//       }
//     }else{
//       console.log('pc')
//       self.$resetpost(`${self.Url}/rs/sql/getUserInfo`,{data:{id:self.paper.f_userinfoid}},{resolveMsg: null, rejectMsg: null}).then((res)=>{
//         console.log('res',res)
//         if(res.data.length != 0){
//           self.$parent.$parent.user = res.data[0]
//           self.$parent.$parent.model.f_area = self.$parent.$parent.user.f_area
//         }
//       })
//       // path({alias:'getUserInfo',data:{id:this.paper.f_userinfoid}})
//     }
//   } catch (error) {
//     console.log('error'+JSON.stringify(error))
//   }
// }

let select = function * (self) {
  let getGasman = yield self.$resetpost(`${self.Url}/rs/search`, {
    source: 'this.getParentByType($organization$).getChildByName($安检员$).getUsers()',
    userid: Vue.user.id
  }, {resolveMsg: null, rejectMsg: null})
  console.log('获取安检员', getGasman)
  getGasman.data.forEach((checker)=>{
    self.checkersid.push({label:checker.name,value:checker.name})
  })
  self.checkersid.push({label:'全部',value:''})
}

export default {
  title: '用户反馈',
  data() {
    return {
      images:[],
      meading:this.$parent.$parent.meading,
      paper:this.$parent.$parent.data,
      item:this.$parent.$parent.item,
      printContent:[],
      hasdefect:false,
      checkersid:[],
      openRadios:[
        {
          label: '同意',
          value: 0,
          isChecked: false,
        },
        {
          label: '不同意',
          value:1,
          isChecked: false,
        },
      ],
      openRadioss:[
        {
          label: '是',
          value: 0,
          isChecked: false,
        },
        {
          label: '否',
          value:1,
          isChecked: false,
        },
      ],
      radios:[
        {
          label: '满意',
          value: 0,
          isChecked: false,
        },
        {
          label: '基本满意',
          value:1,
          isChecked: false,
        },
        {
          label: '不满意',
          value:2,
          isChecked: false,
        },
      ],
      repairitems:[],
      // repairstypes:this.$appdata.getParam('报修类型'),
      // f_repair_person: this.readRepair(),
      showrepair: false,
      safeCheckToRepair:'',
      showCheckToRepair:false,
      userid: '',
      source:
        'dep=this.getParentByType($organization$).getSpecialResByType($department$),' +
        'tool.getFullTree(dep.where(row.getChildByName($派单员$) != null))',
      isback:false,
      defectDevice:{},
      detail:{},
      callObj:null,
      user:{},
      role:this.$parent.$parent.role,
      handling:[{label:'转站点',value:'转站点'},{label:'转维修员',value:'转维修员'}],
      Url:this.$androidUtil.getProxyUrl(),
      deviceresult:this.$parent.$parent.deviceresult,
      deviceCollects:this.$parent.$parent.deviceCollects,
      hasDevice:this.$parent.$parent.hasDevice,
      picture:this.$parent.$parent.picture,
      config:this.$parent.$parent.config,
      showOld:false,
      showNew:false,
      showNewest:false
    }
  },

  props: ['idx'],
  components: {
    RadioGroup,
    Radio
  },
  methods: {
    thissave(){
      // if (this.deviceresult=='有隐患'){//TODO 存在转维修隐患时条件成立
      //   this.$showMessage('当前存在隐患，是否确认不转维修', ['confirm', 'cancel']).then((res) => {
      //     if (res === 'confirm') {
      //       if (!this.paper.f_reson){
      //         this.$showMessage('请输入不转维修的原因！')
      //         return
      //       } else {
      //         this.$parent.$parent.save()
      //       }
      //     }
      //   })
      // }else {
      this.$parent.$parent.save()
      // }

    },
    thisuploadCheckPaper(){
      if (this.hasdefect){
        this.$showMessage('当前存在转维修隐患，是否确认不转维修', ['confirm', 'cancel']).then((res) => {
          if (res === 'confirm') {
            if (!this.paper.f_reson){
              this.$showMessage('请输入不转维修的原因！')
              return
            } else {
              this.$parent.$parent.uploadCheckPaper()
            }
          }
        })
      }else {
        this.$parent.$parent.uploadCheckPaper()
      }
    },
    check(index) {
      console.log('index',index)
      // 先取消所有选中项
      for (let item of this.radios){
        item.isChecked = false;
      }
      //再设置当前点击项选中
      this.paper.f_client_evaluation = this.radios[index].label;
      // 设置值，以供传递
      this.radios[index].isChecked = true;
      console.log('paper.f_client_evaluation==',this.paper.f_client_evaluation);
    },
    checkOpen(index){
      console.log('index',index)
      // 先取消所有选中项
      for (let item of this.openRadios){
        item.isChecked = false;
      }
      //再设置当前点击项选中
      this.paper.f_allow_open = this.openRadios[index].label;
      // 设置值，以供传递
      this.openRadios[index].isChecked = true;
      console.log('paper.f_allow_open==',this.paper.f_allow_open);
    },
    checkOpens(index){
      console.log('index',index)
      // 先取消所有选中项
      for (let item of this.openRadioss){
        item.isChecked = false;
      }
      //再设置当前点击项选中
      this.paper.f_promise_user = this.openRadioss[index].label;
      // 设置值，以供传递
      this.openRadioss[index].isChecked = true;
      console.log('paper.f_promise_user==',this.paper.f_promise_user);
    },
    getSignValue(fileName) {
      this.f_signname = fileName
    },
    cameraCallBack(title,prop, fileName) {
      console.log('title=====>'+title)
      if(prop.indexOf('_overall_path') != -1){
        let f_overall_path = fileName + '?' + Math.random()
        if(title != '其他'){
          for (let img in HostApp.__this__.paper.f_all_imgs) {
            if(HostApp.__this__.paper.f_all_imgs[img].title == title){
              HostApp.__this__.paper.f_all_imgs[img].f_overall_path= f_overall_path
              HostApp.__this__.paper.f_all_imgs[img].f_create_time= Util.toStandardDateString()
            }
          }
        }else{
          HostApp.__this__.paper.f_all_imgs.push({
            f_overall_path:f_overall_path,
            title:'其他',
            f_create_time : Util.toStandardDateString(),
            type:'f_other_overall_path'
          })
        }
      }else{
        HostApp.__this__.paper[prop] = fileName + '?' + Math.random()
      }
      HostApp.__callback__ = null
      HostApp.__this__ = null
    },
    takePic(prop, title,index) {
      HostApp.__callback__ = this.cameraCallBack
      HostApp.__this__ = this
      console.log("prop:" + prop)
      console.log("this.prop:" + this.paper[prop])
      let fileName
      if(prop.indexOf('_overall_path') != -1){
        if (!this.paper.f_all_imgs[index] || this.paper.f_all_imgs[index].f_overall_path.includes("nopic.png")) {
          fileName = Util.guid() + '-' + prop + '.jpg'
        } else {
          fileName = Util.getFileName(this.paper.f_all_imgs[index].f_overall_path)
        }
      }else{
        if (!this.paper[prop] || this.paper[prop].includes("nopic.png")) {
          fileName = Util.guid() + '-' + prop + '.jpg'
        } else {
          fileName = Util.getFileName(this.paper[prop])
        }
      }

      HostApp._open_a_page({
        type: 'boomerang',
        page: 'com.aofeng.hybrid.android.peripheral.CameraActivity',
        param: {
          file: fileName,
          requestCode: 111,
          callback: 'javascript:HostApp.__callback__("' + title + '","' + prop + '", "%s");',
          watermark: title + '\t时间：' + Util.toStandardTimeString() + '\t' + Vue.user.name
        }
      })
    },
    amrCallBack(fileName) {
      HostApp.__this__.$set('paper.f_recording1_path', fileName)
      HostApp.__callback__ = null
      HostApp.__this__ = null
    },
    record() {
      if (this.$parent.$parent.role != 'inspect') {
        if (this.paper.f_recording1_path != '') {
          window.location = this.paper.f_recording1_path
        }
      } else {
        HostApp.__callback__ = this.amrCallBack
        HostApp.__this__ = this
        let fileName
        if (!this.paper.f_recording1_path) {
          fileName = Util.guid() + '.amr'
        } else {
          fileName = Util.getFileName(this.paper.f_recording1_path)
        }
        HostApp._open_a_page({
          type: 'boomerang',
          page: 'com.aofeng.hybrid.android.peripheral.AudioClipActivity',
          param: {file: fileName, requestCode: 111, callback: 'javascript:HostApp.__callback__("%s");'}
        })
      }
    },
    // 签名回调
    signCallback(prop, fileName) {
      // HostApp.alert('绑定属性:' + prop + ' 文件全路径如file:///storage/sdcard0/safecheck/abc.jpg：' + fullFileName)
      HostApp.__this__.$set('paper.f_sign_path', fileName)
      HostApp.__callback__ = null
      HostApp.__this__ = null
    },
    // 用户签名
    sign() {
      this.delAudioFile('f_sign_path', this.paper.f_sign_path)
      let prop = 'f_sign_path'
      let idx = 'aofeng'
      let fileName
      if (!this.paper.f_sign_path) {
        fileName = Util.guid() + '-valve-' + idx + '-' + prop + '.jpg'
      } else {
        fileName = Util.getFileName(this.paper.f_sign_path)
      }
      HostApp.__callback__ = this.signCallback
      HostApp.__this__ = this
      HostApp.getSignature({
        file: fileName,
        requestCode: 111,
        callback: 'javascript:HostApp.__callback__("' + prop + '", "%s");'
      })
    },
    delfile(prop, fileName,index,type) {
      if (fileName == Vue.nopic)
        return
      else {
        if(prop == 'f_overall_path'){
          if(type == '其他'){
            this.paper.f_all_imgs.splice(index,1)
          }else{
            this.paper.f_all_imgs[index].f_overall_path = Vue.nopic
          }
          HostApp.delfile(fileName)
        }else{
          HostApp.delfile(fileName)
          this.paper[prop] = Vue.nopic
        }
      }
    },
    delAudioFile(prop, fileName) {
      if (!fileName)
        return
      else {
        HostApp.delfile(fileName)
        this.paper[prop] = null
      }
    },
    //获取打印用户信息
    getUser() {
      if (this.paper.f_user_name == undefined)
        this.paper.f_user_name = ''
      this.printContent.push({type: 3, text: '用户名称：' + this.paper.f_user_name, fontsize: 2, isbold: false, align: 'left'})
      if (this.paper.f_userinfo_code == undefined)
        this.paper.f_userinfo_code = ''
      this.printContent.push({type: 3, text: '用户编号:' + this.paper.f_userinfo_code, fontsize: 2, isbold: false, align: 'left'})
      if (this.paper.f_address == undefined)
        this.paper.f_address = ''
      this.printContent.push({type: 3, text: '地址:' + this.paper.f_address, fontsize: 2, isbold: false, align: 'left'})
      if (this.paper.f_user_phone == undefined)
        this.paper.f_user_phone = ''
      this.printContent.push({type: 3, text: '电话:' + this.paper.f_user_phone, fontsize: 2, isbold: false, align: 'left'})
    },
    verify(){
      let hasError = this.$parent.$parent.verifyUser()
      if(hasError)
        return hasError
      hasError = this.$parent.$parent.verifyDevices()
      if(hasError)
        return hasError
    },
    print() {
      let errString = this.verify()
      if (errString) {
        console.log(errString)
        if (Vue.android)
          this.$showMessage(errString)
        return
      }
      // 文本
      let templatename = '安检结果单'
      if(Vue.config.safecheck != undefined) {
        if (Vue.config.safecheck.ApproveConfig != undefined) {
          if (Vue.config.safecheck.ApproveConfig.templatename != undefined) {
            templatename = Vue.config.safecheck.ApproveConfig.templatename
          }
        }
      }
      let textHead = {type: 3, text: templatename, fontsize: 3, isbold: true, align: 'center'}
      let feedPageHead = {type: 4, value: 2, unit: 'line'}
      let feedPageEnd = {type: 4, value: 4, unit: 'line'}
      this.printContent.push(textHead)
      this.printContent.push(feedPageHead)
      this.getUser()
      this.getDefect()
      this.getCheck()
      this.printContent.push(feedPageEnd)
      let arrstr = JSON.stringify(this.printContent)
      console.log(arrstr)
      this.$androidUtil.print(arrstr)
      this.$set('printContent', [])
    },
    //打印安检信息
    getCheck() {
      let telephone = '96777'
      if(Vue.config.safecheck != undefined) {
        if (Vue.config.safecheck.ApproveConfig != undefined) {
          if (Vue.config.safecheck.ApproveConfig.checkphone != undefined) {
            telephone = Vue.config.safecheck.ApproveConfig.checkphone
          }
        }
      }
      this.printContent.push({type: 3, text: '*******************************', fontsize: 3, isbold: false, align: 'center'})
      this.printContent.push({type: 3, text: '咨询电话；'+telephone, fontsize: 2, isbold: false, align: 'left'})
      this.printContent.push({type: 3, text: '安检人：'+Vue.user.name, fontsize: 2, isbold: false, align: 'left'})
      this.printContent.push({type: 3, text: '安检时间：' + this.getNowFormatDate(), fontsize: 2, isbold: false, align: 'left'})
      this.printContent.push({type: 3, text: '用户签字：', fontsize: 2, isbold: false, align: 'left'})
      this.printContent.push({type: 4, value: 4, unit: 'line'})
    },

    getDefect() {
      let showmore = false
      if(Vue.config.safecheck != undefined) {
        if (Vue.config.safecheck.ApproveConfig != undefined) {
          if (Vue.config.safecheck.ApproveConfig.showmore != undefined) {
            showmore = Vue.config.safecheck.ApproveConfig.showmore
          }
        }
      }

      let backData = this.$parent.$parent.getAllDefect()
      // 对隐患信息进行遍历
      let res = JSON.parse(backData.f_defect_content)
      this.printContent.push({
        type: 3,
        text: '安检结果：' + res.result,
        fontsize: 2,
        isbold: false,
        align: 'left'
      })
      this.printContent.push({type: 3, text: '*******************************', fontsize: 3, isbold: false, align: 'center'})


      if(showmore) {
        //全部打印
        for (let dev in this.$parent.$parent.config) {
          for (let device in backData) {
            if (device.startsWith("device")) {
              for (let item in backData[device]) {
                //遍历结果
                if (backData[device].length != 0 && backData[device][item].f_device_type == dev) {
                  let error = true
                  for (let i in backData[device][item].f_items) {
                    if (backData[device][item].f_items[i].f_is_defect == true || backData[device][item].f_items[i].f_is_defect == 'true') {
                      error = false
                    }
                  }
                  if (error) {
                    this.printContent.push({
                      type: 3,
                      text: dev + (backData[device].indexOf(backData[device][item]) + 1) + '：正常',
                      fontsize: 2,
                      isbold: false,
                      align: 'left'
                    })
                  } else {
                    this.printContent.push({
                      type: 3,
                      text: dev + (backData[device].indexOf(backData[device][item]) + 1) + ':有隐患',
                      fontsize: 2,
                      isbold: true,
                      align: 'left'
                    })
                  }

                  for (let i in backData[device][item].f_items) {
                    if (backData[device][item].f_items[i].f_item_value != '' && backData[device][item].f_items[i].f_item_value != null) {
                      this.printContent.push({
                        type: 3,
                        text:  backData[device][item].f_items[i].f_item_name + backData[device][item].f_items[i].f_item_value,
                        fontsize: 2,
                        isbold: false,
                        align: 'left'
                      })
                    }
                  }
                  this.printContent.push({type: 4, value: 2, unit: 'line'})
                }
              }
            }
          }
        }

        for (let dev in this.$parent.$parent.config) {
          for (let device in backData) {
            if (device.startsWith("device")) {
              for (let item in backData[device]) {
                //遍历结果
                if (backData[device].length != 0 && backData[device][item].f_device_type == dev) {
                  let error = true
                  for (let i in backData[device][item].f_items) {
                    if (backData[device][item].f_items[i].f_is_defect == true || backData[device][item].f_items[i].f_is_defect == 'true') {
                      error = false
                    }
                  }
                  if (!error) {
                    this.printContent.push({
                      type: 3,
                      text:  '隐患:',
                      fontsize: 2,
                      isbold: true,
                      align: 'left'
                    })
                  }
                }
              }
            }
          }
          for (let device in backData) {
            if (device.startsWith("device")) {
              for (let item in backData[device]) {
                if (backData[device].length != 0 && backData[device][item].f_device_type == dev) {
                  for (let i in backData[device][item].f_items) {
                    if (backData[device][item].f_items[i].f_is_defect == true || backData[device][item].f_items[i].f_is_defect == 'true') {
                      this.printContent.push({
                        type: 3,
                        text: backData[device][item].f_items[i].f_item_name + ' ' + backData[device][item].f_items[i].f_item_value,
                        fontsize: 2,
                        isbold: true,
                        align: 'left'
                      })
                    }
                  }
                }
              }
            }
          }

        }
      }else {
        for (let dev in this.$parent.$parent.config) {
          for (let device in backData) {
            if (device.startsWith("device")) {
              for (let item in backData[device]) {
                //遍历结果
                if (backData[device].length != 0 && backData[device][item].f_device_type == dev) {
                  let error = true
                  for (let i in backData[device][item].f_items) {
                    if (backData[device][item].f_items[i].f_is_defect == true || backData[device][item].f_items[i].f_is_defect == 'true') {
                      error = false
                    }
                  }
                  if (error) {
                    this.printContent.push({
                      type: 3,
                      text: dev + (backData[device].indexOf(backData[device][item]) + 1) + '：正常',
                      fontsize: 2,
                      isbold: false,
                      align: 'left'
                    })
                  } else {
                    this.printContent.push({
                      type: 3,
                      text: dev + (backData[device].indexOf(backData[device][item]) + 1) + ':有隐患',
                      fontsize: 2,
                      isbold: false,
                      align: 'left'
                    })
                  }

                  for (let i in backData[device][item].f_items) {
                    if (backData[device][item].f_items[i].f_is_defect == true || backData[device][item].f_items[i].f_is_defect == 'true') {
                      this.printContent.push({
                        type: 3,
                        text: '隐患:' + backData[device][item].f_items[i].f_item_name + backData[device][item].f_items[i].f_item_value,
                        fontsize: 2,
                        isbold: false,
                        align: 'left'
                      })
                    }
                  }
                  this.printContent.push({type: 4, value: 2, unit: 'line'})
                }
              }
            }
          }
        }
      }
    },
    //获取当前时间
    getNowFormatDate(){
      var date = new Date();
      var seperator1 = "-";
      var seperator2 = ":";
      var month = date.getMonth() + 1;
      var strDate = date.getDate();
      if (month >= 1 && month <= 9) {
        month = "0" + month;
      }
      if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
      }
      var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
        + " " + date.getHours() + seperator2 + date.getMinutes()
        + seperator2 + date.getSeconds();
      return currentdate;
    },
    readRepair () {
      let url = this.$androidUtil.getProxyUrl()
      let gen = getRepairs(this,url)
      return co(gen)
    },
    showToRepair(){
      let res = this.hasDefect()
      console.log('==========检测结果========')
      console.log(res)
      if(res == '正常'){
        this.showrepair = false
      }else{
        this.showrepair = true
        this.assignObj()
      }
      this.showCheckToRepair = !this.showCheckToRepair
    },
    // 选中部门
    reres(val){
      if(val.res == undefined){
        return
      }
      this.$parent.$parent.model.serviceacitivity[0].f_meetunit = val.res
      this.$parent.$parent.model.f_meetunit = val.res
      this.$parent.$parent.model.f_orgstr = val.resids
      var arr = val.res.split('.')
      this.$parent.$parent.model.f_outlets = arr[arr.length - 1]
      this.$parent.$parent.model.serviceacitivity[0].f_reciever = val.resids
    },
    assignObj(){
      //安检维修组需要的数据
      this.$parent.$parent.model.f_contact_phone = this.paper.f_user_phone
      this.$parent.$parent.model.f_user_name = this.paper.f_user_name
      this.$parent.$parent.model.f_address = this.paper.f_address
      this.$parent.$parent.model.f_user_type = this.paper.f_user_type
      this.$parent.$parent.model.f_street = this.paper.f_street
      this.$parent.$parent.model.f_residential_area = this.paper.f_residential_area
      this.$parent.$parent.model.f_building = this.paper.f_building
      this.$parent.$parent.model.f_unit = this.paper.f_unit
      this.$parent.$parent.model.f_floor = this.paper.f_floor
      this.$parent.$parent.model.f_room = this.paper.f_room
      this.$parent.$parent.model.f_floor = this.paper.f_floor
      this.$parent.$parent.model.f_userinfo_id = this.paper.f_card_id
      this.$parent.$parent.model.f_card_id = this.paper.f_card_id
      this.$parent.$parent.model.f_userinfo_code = this.paper.f_userinfo_code
    },
    hasDefect(){
      let checkResult = '正常'
      let codata = JSON.parse(JSON.stringify(this.paper))
      for(let device in this.paper){
        if(device.startsWith("device")){
          for(let item in this.paper[device]) {
            for(let i in this.paper[device][item].f_items){
              let items = this.paper[device][item].f_items[i]
              console.log('转维修判断items'+JSON.stringify(items))
              console.log('this.config[self.data[device][item].f_device_type]' + JSON.stringify(this.config[this.paper[device][item].f_device_type]))
              console.log('this.config[self.data[device][item].f_device_type].items' + JSON.stringify(this.config[this.paper[device][item].f_device_type].items))
              if(this.config[this.paper[device][item].f_device_type].items[items.f_item_name].type == 'selector'){
                let options = this.config[this.paper[device][item].f_device_type].items[items.f_item_name].options
                console.log('options'+JSON.stringify(options))
                for (let value in items.f_item_value){
                  for (let i in options){
                    let option = options[i]
                    // 当隐患等级带有 安检组维修或安装组维修的 this.hasdefect = true 必须进行上传并转维修处理，否则填写不转维修原因
                    if(option.data == items.f_item_value[value] && (option.level && (option.level.indexOf('工商大表组') > -1))){
                      checkResult = '有需要转维修的隐患'
                      this.hasdefect = true
                    }
                  }
                }
              }
            }
          }
        }
      }
      return checkResult
    },
    uploadPaper() {
      if(this.showrepair){
        this.$parent.$parent.isToRepair = true
        this.$parent.$parent.uploadCheckPaper()
        // this.$parent.$parent.savePaper(false).then((res) => {
        //   console.log(`res=${res}`)
        //   if(res != true){
        //     console.log('失败')
        //     return
        //   }else{
        // this.$parent.$parent.todo()
        //   }
        // })
      }else{
        this.$parent.$parent.undo()
      }

    },
    //确认安检转维修

    undo(){
      this.$parent.$parent.isToRepair = false
      this.showCheckToRepair = !this.showCheckToRepair
      this.meading = '转站点'
    },
  },
  ready() {
    let gen = select(this)
    co(gen)
    if(!this.$parent.$parent.showBack){
      this.$parent.$parent.showBack= true
    }
    this.hasDefect()
    // this.$parent.$parent.devicesCollect()
    this.$dispatch('devicesCollect')
    console.log('this.$parent.$parent.meading=>'+this.$parent.$parent.meading)
    console.log('Feeback this.meading=>'+this.meading)
    for (let item of this.radios){
      if(this.paper.f_client_evaluation == item.label){
        item.isChecked = true;
      }
    }
    for (let item of this.openRadios){
      if(this.paper.f_allow_open == item.label){
        item.isChecked = true;
      }
    }
    for (let item of this.openRadioss){
      if(this.paper.f_promise_user == item.label){
        item.isChecked = true;
      }
    }
    if (!this.paper.f_notified_path)
      this.$set('paper.f_notified_path', Vue.nopic)
    if (!this.paper.f_notified1_path)
      this.$set('paper.f_notified1_path', Vue.nopic)
    if (!this.paper.f_sign_path)
      this.$set('paper.f_sign_path', Vue.nopic)
    console.log('!this.paper.f_all_imgs==>'+!this.paper.f_all_imgs)
    if (!this.paper.f_all_imgs){
      this.showNewest = true
      // title： 是显示的拍照标题名称，f_overall_path:是实际照片存储路径,f_create_time:拍照时间，type:是拍照存储的类型必须是 _path 结尾
      let imgs = [
        {title:'厨房全景',f_overall_path:Vue.nopic,f_create_time:'',type:'f_kitchen_overall_path'},
        {title:'表具正面',f_overall_path:Vue.nopic,f_create_time:'',type:'f_table_overall_path'},
        {title:'管道全景',f_overall_path:Vue.nopic,f_create_time:'',type:'f_pipeline_overall_path'},
        {title:'报警器',f_overall_path:Vue.nopic,f_create_time:'',type:'f_bjq_warner_overall_path'},
        {title:'灶具熄火保护',f_overall_path:Vue.nopic,f_create_time:'',type:'f_zjxh_overall_path'},
        {title:'供气合同',f_overall_path:Vue.nopic,f_create_time:'',type:'f_contract_overall_path'},
        {title:'安全协议',f_overall_path:Vue.nopic,f_create_time:'',type:'f_security_protocol_overall_path'},
        {title:'停气管控',f_overall_path:Vue.nopic,f_create_time:'',type:'f_control_overall_path'}
      ]
      // imgs.push({f_overall_path:Vue.nopic})
      this.$set('paper.f_all_imgs', imgs)
      console.log('进入setpaper.f_all_imgs')
    }else{
      console.log('进入setpaper.f_all_imgs'+this.role)
      if(this.role =='androidview'){
        if(this.paper.f_all_imgs[0].f_blob_id != null){
          this.showOld = true
          this.showNewest = false
          this.showNew = false
        }else if (this.paper.f_all_imgs[0].f_blob_id == null && this.paper.f_all_imgs[0].title == null && this.paper.f_all_imgs[0].type == null){
          this.showOld = false
          this.showNewest = false
          this.showNew = true
        }else{
          this.showOld = false
          this.showNewest = true
          this.showNew = false
        }
      }else{
        this.showNewest = true
      }
      console.log('this.showOld'+this.showOld)
      console.log('this.showNewest'+this.showNewest)
      console.log('this.showNew'+this.showNew)
      console.log('this.role'+this.role)
      console.log('this.role && this.showOld'+(this.role == 'androidview' && this.showOld))

    }
    if (!this.paper.f_overall2_path)
      this.$set('paper.f_overall2_path', Vue.nopic)

    this.userid = this.role == 'view'? this.$login.f.id:Vue.user.id
    if(Vue.config.safecheck != undefined){
      if(Vue.config.safecheck.ApproveConfig != undefined){
        if(Vue.config.safecheck.ApproveConfig.safeCheckToRepair != undefined) {
          this.safeCheckToRepair = Vue.config.safecheck.ApproveConfig.safeCheckToRepair
        }
      }
    }
    console.log(`this.safeCheckToRepair==========${this.safeCheckToRepair}`)
    console.log(JSON.stringify(Vue.config))
  },
  watch:{
    '$parent.$parent.isUpload'(val){
      console.log('isUpload发生变化===>'+val)
    }
  }
}
</script>
<style>
.panel-self{
  border-radius: 5px;
  border:1px solid #c5e1f7;
  background-color: #F2F6FA;
}
.text-left{
  text-align:left;
}
.font{
  font: 15px PingFang-SC-Medium;
  color: #333333;
}
.showInput{
  text-align: left;
  font: 14px PingFang-SC-Medium;
  color: #666666;
}
.info{
  margin-top: 15px;
  border-radius: 5px;
  background-color: #f3faff;
}
.btn-photo{
  border: 0;
  border-radius: 7px;
  background-color: #7dc1f4;
  font: 15px PingFang-SC-Bold;
  height: 20%;
}
.div-photo{
  width: auto;
  height: auto;
  /* margin-top: 10px; */
  position: absolute;
  bottom: 10px;
  right: 10px;
}
.div-photo1{
  width: auto;
  height: auto;
  /* margin-top: 10px; */
  position: absolute;
  bottom: 5%;
  right: 10%;
}
.btn-voice{
  border-radius: 7px;
  border: 1px solid #dedede;
  background-color: #f5fbff;
  font: 15px PingFang-SC-Bold;
  color: #499edf;
}
.save-btn{
  width: 25%;
  background-color:#499edf;
  border-radius: 6px;
  color: #FFFFFF;
  font: 15px PingFang-SC-Bold;
}
.upload-btn{
  width: 25%;
  background-color:#ffffff;
  border: 1px solid #499edf;
  border-radius: 6px;
  color: #499edf;
  font: 15px PingFang-SC-Bold;
}
.repair-btn{
  width: 25%;
  border: 1px solid #499edf;
  border-radius: 6px;
  font: 15px PingFang-SC-Bold;
}
</style>
