<template>
  <div class="flex-row">
    <div class="basic-main">
      <criteria-paged :model="model" v-ref:paged @sort="sort">
        <criteria partial='criteria' class="search_area" @condition-changed='$parent.selfSearch' v-ref:criteria>
          <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
            <div class="row">
              <div class="form-group col-sm-2">
                <label class="font_normal_body">客户编号</label>
                <input type="text" class="input_search" v-model="model.f_userinfo_code"
                       style="width: 60%" placeholder="客户编号" condition="tcp.f_userinfo_code='{}'">
              </div>
              <div class="form-group col-sm-2">
                <label class="font_normal_body">客户名称</label>
                <input type="text" class="input_search" v-model="model.f_user_name"
                       style="width: 60%" placeholder="客户名称" condition="tcp.f_user_name like '%{}%'">
              </div>
              <div class="form-group col-sm-2">
                <label class="font_normal_body">客户电话</label>
                <input type="text" class="input_search" v-model="model.f_user_phone"
                       style="width: 60%" placeholder="客户电话" condition="tcp.f_user_phone like '%{}%'">
              </div>
              <div class="form-group col-sm-2">
                <label class="font_normal_body">小&emsp;&emsp;区</label>
                <input type="text" class="input_search" v-model="model.f_residential_area"
                       style="width: 60%" placeholder="小区" condition="tcp.f_residential_area like '%{}%'">
              </div>
              <div class="form-group col-sm-2">
                <label class="font_normal_body">详细地址</label>
                <input type="text" class="input_search" v-model="model.f_address"
                       style="width: 60%" placeholder="详细地址" condition="tcp.f_address like '%{}%'">
              </div>
              <div class="form-group col-sm-2" style="width: auto;margin-top:8px;float: right">

                <export-excel-safe :data="$parent.$parent.searchData"
                                   :field="$parent.$parent.excelHeaders"
                                   progress="safeGetExportProgress"
                                   sqlurl="rs/logic/SafeExportExcel" sql-name="defectDetails"
                                   template-name='安检隐患明细'></export-excel-safe>
                <!--                <button class="button_spacing button_search" @click="$parent.$parent.showaudio()" v-if="!$parent.$parent.audioshow">录音</button>-->
                <button class="button_spacing button_search" @click="$parent.$parent.showaudio()"
                        v-if="$parent.$parent.audioshow">隐藏
                </button>

                <button class="button_spacing button_search" @click="search()">查询</button>
                <div style="float: right" class="button_spacing"
                     :class="{'button_shrink_top':$parent.$parent.criteriaShow,'button_shrink_bottom':!$parent.$parent.criteriaShow}"
                     @click="$parent.$parent.hidden()"></div>
              </div>

            </div>
            <div class="row">
              <div class="col-sm-4 form-group" v-show="$parent.$parent.criteriaShow" style="margin: 0">
                <role-selector-safe
                  role-name="维修员"
                  role-lable="维&nbsp;修&nbsp;员&nbsp;"
                  @re-res="$parent.$parent.getRes"
                  :value.sync="model.f_checker_id"
                  v-model="model.f_checker_id"
                  condition="tdi.f_repairman = '{}'">
                </role-selector-safe>
              </div>
              <div class="form-group col-sm-2" v-show="$parent.$parent.criteriaShow">
                <label class="font_normal_body">检&ensp;查&ensp;项</label>
                <v-select :value.sync="model.f_device_type" v-model='model.f_device_type'
                          :value-single="true" style="width: 60%"
                          class="select_list select"
                          :options='$parent.$parent.device_types' placeholder='检查项'
                          close-on-select
                          @change="$parent.$parent.changeDefect"
                          condition="f_device_type like '%{}%'"></v-select>
                <!--<input type="text" class="input_search" v-model="model.f_device_type"-->
                <!--style="width: 60%" placeholder="检&ensp;查&ensp;项" condition="f_device_type like '%{}%'">-->
              </div>
              <div class="form-group col-sm-2" v-show="$parent.$parent.criteriaShow">
                <label class="font_normal_body">隐患名称</label>
                <v-select :value.sync="model.f_item_name" v-model='model.f_item_name'
                          :value-single="true" style="width: 60%"
                          class="select_list select"
                          :options='$parent.$parent.DefectConfigs' placeholder='隐患名称'
                          close-on-select
                          condition="f_item_name like '%{}%'"></v-select>
              </div>
              <div class="form-group col-sm-2" v-show="$parent.$parent.criteriaShow">
                <label class="font_normal_body">安检起始</label>
                <datepicker
                  class="select_list select"
                  :value.sync="model.f_check_start"
                  placeholder='安检起始时间' style="width: 60%"
                  :disabled-days-of-week="[]"
                  :format="'yyyy-MM-dd'"
                  :show-rest-button="reset"
                  v-model="model.f_check_start"
                  condition="f_offsite_time > ='{} 00:00:00'">
                </datepicker>
              </div>
              <div class="form-group col-sm-2" v-show="$parent.$parent.criteriaShow">
                <label class="font_normal_body">安检结束</label>
                <datepicker
                  class="select_list select"
                  :value.sync="model.f_check_end"
                  placeholder='安检结束时间' style="width: 60%"
                  :disabled-days-of-week="[]"
                  :format="'yyyy-MM-dd'"
                  :show-rest-button="reset"
                  v-model="model.f_check_end"
                  condition="f_offsite_time < ='{} 23:59:59'">
                </datepicker>
              </div>
              <div class="form-group col-sm-2" v-show="$parent.$parent.criteriaShow">
                <label class="font_normal_body">维修起始</label>
                <datepicker
                  class="select_list select"
                  :value.sync="model.f_repair_start"
                  placeholder='维修起始' style="width: 60%"
                  :disabled-days-of-week="[]"
                  :format="'yyyy-MM-dd'"
                  :show-rest-button="reset"
                  v-model="model.f_repair_start"
                  condition="tdi.f_repair_date >='{} 00:00:00'">
                </datepicker>
              </div>
              <div class="form-group col-sm-2" v-show="$parent.$parent.criteriaShow">
                <label class="font_normal_body">维修截止</label>
                <datepicker
                  class="select_list select"
                  :value.sync="model.f_repair_end"
                  placeholder='维修截止' style="width: 60%"
                  :disabled-days-of-week="[]"
                  :format="'yyyy-MM-dd'"
                  :show-rest-button="reset"
                  v-model="model.f_repair_end"
                  condition="tdi.f_repair_date <='{} 23:59:59'">
                </datepicker>
              </div>

            </div>
            <div class="row">
              <div class="form-group col-sm-2" v-show="$parent.$parent.criteriaShow">
                <label class="font_normal_body">维修结果</label>
                <v-select class="select_list select"
                          placeholder='维修结果' style="width: 60%"
                          :value.sync="model.f_is_repaired" v-model="model.f_is_repaired"
                          :options='$parent.$parent.repaireds'
                          filer-key="name"
                          close-on-select clear-button
                          condition="{}"
                          :value-single="true">
                </v-select>
                <!--<input type="text" class="input_search" v-model="model.f_device_type"-->
                <!--style="width: 60%" placeholder="检&ensp;查&ensp;项" condition="f_device_type like '%{}%'">-->
              </div>
              <div class="form-group col-sm-2" v-show="$parent.$parent.criteriaShow">
                <label class="font_normal_body">气表状态</label>
                <v-select :value.sync="model.f_table_state" v-model='model.f_table_state'
                          :value-single="true" style="width: 60%"
                          class="select_list select"
                          :options='$parent.$parent.table_state' placeholder='气表状态'
                          close-on-select
                          condition="uf.f_table_state = '{}'"></v-select>
              </div>
              <div class="form-group col-sm-2" v-show="$parent.$parent.criteriaShow">
                <label class="font_normal_body">处理公司</label>
                <v-select
                  placeholder='处理公司'
                  :value-single="true"
                  class="select select_list" style="width: 60%"
                  v-model='model.f_dealername'
                  :value.sync="model.f_dealername"
                  :options='$parent.$parent.dealername'
                  condition="f_dealer_name  = '{}'"
                  close-on-select clear-button></v-select>
              </div>
              <div class="form-group col-sm-2" v-show="$parent.$parent.criteriaShow">
                <label class="font_normal_body">用户类型</label>
                <v-select
                  placeholder='用户类型'
                  :value-single="true"
                  class="select select_list" style="width: 60%"
                  v-model='model.f_user_type'
                  :value.sync="model.f_user_type"
                  :options='$parent.$parent.user_types'
                  condition="f_user_type  = '{}'"
                  close-on-select clear-button></v-select>
              </div>
              <div class="form-group col-sm-2" v-show="$parent.$parent.criteriaShow">
                <label class="font_normal_body">用气性质</label>
                <v-select
                  placeholder='用气性质'
                  :value-single="true"
                  class="select select_list" style="width: 60%"
                  v-model='model.f_gasproperties'
                  :value.sync="model.f_gasproperties"
                  :options='$parent.$parent.gasproperties'
                  condition="f_gasproperties  = '{}'"
                  close-on-select clear-button></v-select>
              </div>
            </div>
            <modal :show.sync="$parent.$parent.showModal" v-ref:modal>
              <div slot="modal-header" class="modal-header">
                <h4 class="modal-title">
                  选择计划
                </h4>
              </div>
              <div slot="modal-body" class="modal-body">
                <plan-chooser :f.sync="$parent.$parent.fun" v-ref:chooser></plan-chooser>
              </div>
              <div slot="modal-footer" class="modal-footer" style="text-align: center">
                <button class="button_search" @click="$parent.$parent.ok">确认</button>
                <button class="button_search" @click="$parent.$parent.cancel">取消</button>
              </div>
            </modal>
          </div>
        </criteria>
        <data-grid style="overflow: hidden" :model="model" partial='list' v-ref:grid>
          <template partial='head'>
            <tr>
              <th>
                <nobr>检查项</nobr>
              </th>
              <th>
                <nobr>隐患原因</nobr>
              </th>
              <th>
                <nobr>隐患级别</nobr>
              </th>
              <th>
                <nobr>客户编号</nobr>
              </th>
              <th>
                <nobr>客户名称</nobr>
              </th>
              <th>
                <nobr>用户状态</nobr>
              </th>
              <th>
                <nobr>客户电话</nobr>
              </th>
              <th>
                <nobr>表号</nobr>
              </th>
              <th>
                <nobr>表品牌</nobr>
              </th>
              <th>
                <nobr>表位置</nobr>
              </th>
              <th>
                <nobr>气表状态</nobr>
              </th>
              <th>
                <nobr>客户小区</nobr>
              </th>
              <th>
                <data-order field="f_address" name="客户地址"></data-order>
              </th>

              <th>
                <data-order field="f_offsite_time" name="安检时间"></data-order>
              </th>
              <th>
                <nobr>安检员</nobr>
              </th>
              <th>
                <nobr>隐患状态</nobr>
              </th>
              <th>
                <nobr>处理人</nobr>
              </th>
              <th>
                <nobr>处理时间</nobr>
              </th>

              <th>
                <nobr>隐患开始处理时间</nobr>
              </th>
              <th>
                <nobr>隐患结束处理时间</nobr>
              </th>
              <th>
                <nobr>隐患处理备注</nobr>
              </th>
              <th>
                <nobr>隐患处理公司</nobr>
              </th>
              <th>
                <nobr>用户类型</nobr>
              </th>
              <th>
                <nobr>用气性质</nobr>
              </th>
              <th>
                <nobr>操作</nobr>
              </th>
            </tr>
          </template>
          <template partial='body'>
            <td style="text-align: center">{{ row.f_device_type }}</td>
            <td style="text-align: center">{{ row.f_item_name }}/{{ row.f_item_value }}</td>
            <td style="text-align: center">{{ row.f_defect_level }}</td>
            <td style="text-align: center">{{ row.f_userinfo_code }}</td>
            <td style="text-align: center">{{ row.f_user_name }}</td>
            <td style="text-align: center">{{ row.f_user_state }}</td>
            <td style="text-align: center">{{ row.f_user_phone }}</td>
            <td style="text-align: center">{{ row.f_meternumber }}</td>
            <td style="text-align: center">{{ row.f_meter_brand }}</td>
            <td style="text-align: center">{{ row.f_position }}</td>
            <td style="text-align: center">{{ row.f_table_state }}</td>
            <td style="text-align: center">{{ row.f_residential_area }}</td>
            <td style="text-align: center">{{ row.f_address }}</td>
            <td style="text-align: center">{{ row.f_offsite_time }}</td>
            <td style="text-align: center">{{ row.f_checker_name }}</td>
            <td style="text-align: center">{{ row.f_is_repaired }}</td>
            <td style="text-align: center">{{ row.f_repairman }}</td>
            <td style="text-align: center">{{ row.f_repair_date }}</td>
            <td style="text-align: center">{{ row.f_dealer_starttime }}</td>
            <td style="text-align: center">{{ row.f_dealer_endtime }}</td>
            <td style="text-align: center">{{ row.f_deal_remark }}</td>
            <td style="text-align: center">{{ row.f_dealer_name }}</td>
            <td style="text-align: center">{{ row.f_user_type }}</td>
            <td style="text-align: center">{{ row.f_gasproperties }}</td>
            <td style="text-align: center">
              <button class="button_spacing button_search-1" @click="$parent.$parent.$parent.situation(row)">
                处理照片
              </button>
              <button type="button" class="button_new-1 button_spacing" data-toggle="dropdown"
                      @click="$parent.$parent.$parent.print(row)">
                打印
              </button>
            </td>
          </template>
        </data-grid>
      </criteria-paged>
      <check-msgdeal v-if="showcheckmsg" :show="showcheckmsg" :data="checkInfodeal" :realpath="realpath"
                     :realsignpath="yhpathdeals"></check-msgdeal>
    </div>
  </div>
  <modal :show.sync="trouble">
    <div slot="modal-header" class="modal-header">
      <h4 class="modal-title">
        隐患处理照片及签名
      </h4>
    </div>
    <div slot="modal-body" class="modal-body" v-if="yhpath">
      <div style="width: 100%;height: 36px;background-color: #f1f8ff;float: left">
        <div style="width: 8px;height: 100%;background-color: #6aa6e2;margin-right: 20px;float: left"></div>
        <div style="width: auto;height:100%;float: left;"><p class="title-font" style="margin-top: 5px">处理后图片</p></div>
      </div>
      <!--      <label class="font_normal_body">处理后图片</label>-->
      <img-self :width="300" :height="320" :src="yhpath"></img-self>
      <div style="width: 100%;height: 36px;background-color: #f1f8ff;float: left">
        <div style="width: 8px;height: 100%;background-color: #6aa6e2;margin-right: 20px;float: left"></div>
        <div style="width: auto;height:100%;float: left;"><p class="title-font" style="margin-top: 5px">用户签名</p></div>
      </div>
      <!--      <label class="font_normal_body">用户签名</label>-->
      <img-self :width="300" :height="320" :src="yhpathsign"></img-self>
      <!--      <img :src="`/rs/image/file/${yhpath.f_dealpath}`" alt="无照片！！！" width="300" height="320">-->

    </div>
    <div slot="modal-footer" class="modal-footer">
      <button class="button_spacing button_search-1" @click="trouble = false;yhpath=null">确认</button>
    </div>
  </modal>
</template>

<script>
  import {PagedList} from 'vue-client'
  import Vue from 'vue'
  import co from 'co'
  import HttpResetClass from "vue-client/src/plugins/HttpResetClass";

  //获取json配置文件
  let asyncReady = async function (self) {
    // 获取配置信息
    try {
      let res = await Vue.resetget(`/phone/rs/vue`, {data: {}}, {resolveMsg: null, rejectMsg: null})
      Vue.config = res.data
      self.getDefectInfoConfig(res.data)
    } catch (error) {
      // 忽略704,文件找不到异常R
      if (error.status !== 704) {
        throw error
      }
    }
  }

  let select = function* (self) {
    let http = new HttpResetClass()
    let getGasman = yield http.load('POST', '/rs/search', {
      source: 'this.getParentByType($department$).getAllChildrens().where(row.getAttributes().get($rolestr$).indexOf($安检员$) != -1))',
      userid: self.$login.f.id
    }, {resolveMsg: null, rejectMsg: null})
    ////tag
    self.checkersid.push({label: '全部', value: ''})
    getGasman.data.forEach((checker) => {
      self.checkersid.push({label: checker.name, value: checker.id})
    })
  }

  export default {
    title: '隐患明细查看',
    data() {
      let model = new PagedList('rs/sql/defectDetails', 20)
      model.f_plan_id = ''
      model.f_approved = ''
      model.f_entry = ''
      model.f_no_checkplan = ''
      model.f_filialeid = `('${this.$login.f.orgid}')`
      //model.f_check_type='民用'
      // let searchData={
      //     f_plan_id: this.model.f_checker_id==undefined?"":this.model.f_checker_id,
      //     f_approved: this.model.f_approved,
      //     f_entry_status: this.model.f_entry,
      //     f_no_checkplan:this.model.f_no_checkplan[0],
      //     f_filialeid: this.model.f_filialeid,
      //     //orderitem: this.model.f_offsite_time,
      //     //condition:this.model.condition
      // }
      // model.f_subcompany = this.$login.f.f_fengongsi
      return {
        audioshow: false,
        trouble: false,
        dealername: [{label: '全部', value: ''}, {label: '洁能', value: '洁能'}, {label: '宏语', value: '宏语'}],
        searchData: {
          condition: "1=1",
        },
        table_state: [{label: '全部', value: ''}, ...this.$appdata.getParam('气表状态')],
        gasproperties: [{label: '全部', value: ''}, ...this.$appdata.getParam('用气性质')],
        user_types: [{label: '全部', value: ''}, ...this.$appdata.getParam('用户类型')],
        model: model,
        //searchData:searchData,
        excelHeaders: {
          'f_device_type': '检查项',
          'f_item_name': '隐患名称',
          'f_defect_level': '隐患级别',
          'f_userinfo_code': '客户编号',
          'f_user_name': '客户姓名',
          'f_user_phone': '客户电话',
          'f_meternumber': '表号',
          'f_meter_brand': '表品牌',
          'f_position': '表位置',
          'f_table_state': '气表状态',
          'f_residential_area': '客户小区',
          'f_address': '客户地址',
          'f_offsite_time': '安检时间',
          'f_deal_remark': '隐患处理备注',
          'f_dealer_starttime': '开始处理时间',
          'f_dealer_endtime': '结束处理时间',
          'f_dealer_name': '隐患处理公司',
          'f_checker_name': '安检员',
          'f_repairman': '维修人',
          'f_user_state': '用户状态',
          'f_is_repaired': '隐患状态',
          'f_user_type': '用户类型',
          'f_gasproperties': '用气性质',
          'f_repair_date': '处理时间'

        },
        fun: this.$login.f,
        checkersid: [],
        repairers: [],
        safetype: this.getSafeParam('安检类型'),
        criteriaShow: false,
        repaireds: [{label: '全部', value: ''},
          {label: '已处理', value: `f_is_repaired='已处理'`},
          {label: '已整改', value: `f_is_repaired='已整改'`},
          {label: '用户已处理', value: `f_is_repaired='用户已处理'`},
          {label: '转维修', value: `f_is_repaired='转维修'`},
          {label: '未处理', value: "f_is_repaired  is null"}
        ],
        showModal: false,
        f_approval_states: this.getSafeParam('安检单审核状态'),
        f_entry_status: this.getSafeParam('安检状态'),
        f_checkplans: this.getSafeParam('有无计划'),
        showcheckmsg: false,
        checkInfodeal: {},
        orderDefault: "'f_offsite_time'",
        orderFields: {
          f_offsite_time: 'no'
        },
        sliceArea: [],
        yhpath: null,
        yhpathsign: null,
        realpath: null,
        yhpathdeals: null,
        cbc: [],
        DefectConfig: '',
        DefectConfigs: [{label: '全部', value: ''}, {label: '气量异常差值', value: '气量异常差值'}],
        device_types: [{label: '全部', value: ''}],
      }
    },
    methods: {
      getEmp() {
        let val = {
          source: 'this.getParentByType($organization$).getChildByName($维修员$).getUsers()',
          userid: `${this.$login.f.id}`
        }
        // let val = {source: 'this.getParentByType($department$).getAllChildrens().where(row.getAttributes().get($rolestr$) == $维修员$))', userid: `${this.$login.f.id}`}
        // let val = {source: 'this.getParentByType($department$).getChildByName($置换员$).getUsers()', userid: `${this.$login.f.id}`}
        let http = new HttpResetClass()
        http.load('POST', '/rs/search', {data: val}, {resolveMsg: null, rejectMsg: null}).then((res) => {
          res.data.forEach((item) => {
            this.repairers.push({label: item.name, value: item.name})
          })
        })
      },
      //隐患处理照片查看
      situation(row) {
        //tag
        if (row.f_dealpath === '' || row.f_dealpath === null || row.f_item_name === '气量异常差值' || row.f_dealsign_path === '' || row.f_dealsign_path === null) {
          this.$showMessage('无签名照片或者隐患处理照片,或处理过数据！！！')
        } else {
          this.yhpath = '/rs/image/file/' + row.f_dealpath.substring(row.f_dealpath.lastIndexOf('/')+1)
          this.yhpathsign = '/rs/image/file/' + row.f_dealsign_path.substring(row.f_dealpath.lastIndexOf('/')+1)
          this.trouble = true
        }
      },

      changeDefect(val) {
        try {
          if (val) {
            for (var Key1 in this.DefectConfig) {
              if (Key1 == val) {
                this.DefectConfigs = [{label: '全部', value: ''}]
                for (var Key2 in this.DefectConfig[Key1].items) {
                  this.DefectConfigs.push({label: Key2, value: Key2})
                }
                return
              }
            }
          } else if (val == '') {
            this.DefectConfigs = [{label: '全部', value: ''}]
            for (var Key1 in this.DefectConfig) {
              for (var Key2 in this.DefectConfig[Key1].items) {
                this.DefectConfigs.push({label: Key2, value: Key2})
              }
            }
          }
        } catch (e) {
          //tag
        }
      },
      getDefectInfoConfig(val) {
        try {
          if (val.safecheck.DevicesSetConfig != undefined) {
            this.DefectConfig = val.safecheck.DevicesConfig
            // 获取到配置项，进行遍历，获取每个隐患项
            for (var Key1 in this.DefectConfig) {
              this.device_types.push({label: Key1, value: Key1})
              for (var Key2 in this.DefectConfig[Key1].items) {
                this.DefectConfigs.push({label: Key2, value: Key2})
              }
            }
            // 非民用或其他配置项加入，在进行遍历
          }
        } catch (e) {
          //tag
        }
      },
      showaudio() {
        //tag
        this.audioshow = !this.audioshow
        //tag
      },
      getmeterbook(val) {
        this.cbc = []
        this.cbc.push({
          label: '全部',
          value: ''
        })
        if (val == '') {

          this.cbcs.forEach(res => {
            this.cbc.push({
              label: res.f_book_name,
              value: res.id
            })
          })
        } else {
          this.cbcs.forEach(res => {
            if (res.f_book_slice_area == val) {
              this.cbc.push({
                label: res.f_book_name,
                value: res.id
              })
            }
          })
        }
      },
      getSafeParam(val) {
        if (this.$appdata.getParam(val)) {
          return [{label: '全部', value: ''}, ...this.$appdata.getParam(val)]
        } else {
          return [{label: '全部', value: ''}]
        }

      },
      Mreadibook(val) {
        ////tag
        ////tag
        this.sliceArea = []
        if (val) {
          new HttpResetClass().load('POST', `/rs/sql/safe_singleTable_OrderBy`, {
            data: {
              items: 'name',
              tablename: 't_zone',
              condition: `parentid  in ${val}`,
              orderitem: 'id'
            }
          }, {resolveMsg: null, rejectMsg: null}).then((res) => {
            this.sliceArea.push({
              label: '全部',
              value: ''
            })
            res.data.forEach(ress => {
              this.sliceArea.push({
                label: ress.name,
                value: ress.name
              })
            })

          })
        }
      },
      getAllMeterBook(val) {
        ////tag
        ////tag
        this.cbcs = []
        if (val) {
          new HttpResetClass().load('POST', `/rs/sql/safe_singleTable_OrderBy`, {
            data: {
              items: 'f_book_name,f_book_slice_area,id',
              tablename: 't_meter_book',
              condition: `f_filiale_id  in ${val}`,
              orderitem: 'id'
            }
          }, {resolveMsg: null, rejectMsg: null}).then((res) => {
            res.data.forEach(ress => {
              this.cbcs.push({
                id: ress.id,
                f_book_name: ress.f_book_name,
                f_book_slice_area: ress.f_book_slice_area
              })
            })
            this.cbc = []
            this.cbc.push({
              label: '全部',
              value: ''
            })
            this.cbcs.forEach(res => {
              this.cbc.push({
                label: res.f_book_name,
                value: res.id
              })
            })
          })
        }
      },
      getRes(obj) {
        this.model.f_filialeid = this.$login.convertToIn(obj.resids);
        this.searchData.f_filialeid = this.$login.convertToIn(obj.resids);
        this.Mreadibook(this.model.f_filialeid)
        this.getAllMeterBook(this.model.f_filialeid)
        //this.$refs.paged.$refs.criteria.search()
      },

      change(row) {
        // Vue.$login = {jwt: row.f_checker_id}
        asyncReady(this).then(() => {
          ////tag)
          row.f_upload_state = '已传'
          this.$goto('new-check-paper', {f_plan_id: row.f_check_plan_id, item: row, role: 'view'}, 'self')
        }).catch(
          (respanse) => {
            alert('获取配置文件失败')
          })
      },
      readConfig() {
        let gen = asyncReady(this)
        return co(gen)
      },
      showChooser() {
        this.showModal = true
      },
      hidden() {
        this.criteriaShow = !this.criteriaShow
      },
      refresh() {
        this.$refs.paged.$refs.criteria.search()
      },
      ok() {
        this.showModal = false
        if (this.$refs.paged.$refs.criteria.$refs.modal.$children[0].selectedRow.id) {
          this.model.f_plan_id = this.$refs.paged.$refs.criteria.$refs.modal.$children[0].selectedRow.id
          this.model.f_check_plan = this.$refs.paged.$refs.criteria.$refs.modal.$children[0].selectedRow
        }
      },
      cancel() {
        this.showModal = false
        this.model.f_check_plan = {f_plan_name: '', id: ''}
        this.model.f_plan_id = ''
      },
      print(row) {
        this.realpath = ''
        this.yhpathdeals = ''
        this.showcheckmsg = true
        this.checkInfodeal = row
        this.realpath = '/rs/image/file/' + row.f_dealpath.substring(row.f_dealpath.lastIndexOf('/')+1)
        this.yhpathdeals = '/rs/image/file/' + row.f_dealsign_path.substring(row.f_dealpath.lastIndexOf('/')+1)
      },

      sort(field, rule) {
        // 将所有排序方式设为不排序，实现相互排斥
        for (let key in this.orderFields) {
          if (key === field) {
            this.orderFields[key] = rule
          } else {
            this.orderFields[key] = 'no'
          }
        }
        // 如果新规则不排序，还原为默认排序
        if (rule === 'no') {
          this.model.paramSource.orderitem = `'${this.orderDefault}'`
        } else {
          this.model.paramSource.orderitem = `'${field} ${rule}'`
        }
        this.search()
      },
      search() {
        this.$refs.paged.$refs.criteria.search()
      },
      selfSearch(args) {
        ////tag
        this.model.search(args.condition, args.model, args.condValue)
      }
    },

    ready() {
      this.readConfig()
      this.getEmp()
      ////tag
      this.function = this.f
      ////tag

      let gen = select(this)
      //this.pianqu()
      this.Mreadibook(`('${this.$login.f.orgid}')`)
      co(gen)
    },
    watch: {
      'model.f_no_checkplan'(val) {
        if (this.model.f_no_checkplan) {
          this.searchData.f_no_checkplan = val
        }
        if (this.model.f_no_checkplan == '有计划安检') {

          this.showChooser()
        }
      },
      'model.condition'(val) {
        if (val) {
          this.searchData.condition = val
        }

      },
      'model.f_entry'(val) {
        if (val) {
          this.searchData.f_entry_status = val

        }
      },
      'model.f_plan_id'(val) {
        if (val) {
          this.searchData.f_plan_id = val
        }
      },
      'model.f_slice_area'(val) {
        if (val) {

        }
      },
      'model.f_approved'(val) {
        if (val) {
          this.searchData.f_approved = val
        }
      },
    }

  }
</script>
