<template>
  <work-busy :is-busy="loading"></work-busy>
  <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_meternumber"
                       style="width: 60%" placeholder="表号" condition="f_meternumber = '{}'">
              </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="f_address like '%{}%'">
              </div>
              <div class="col-sm-2 form-group" style="margin: 0">
                <role-selector-safe
                  role-name="新安检员"
                  role-lable="安&nbsp;检&nbsp;员&nbsp;"
                  :value.sync="model.f_checker_id"
                  v-model="model.f_checker_id"
                  :value-multiple="true"
                  :value-close="false"
                  condition="f_checker_name in {}">
                </role-selector-safe>
              </div>
              <div class="form-group col-sm-2">
                <label class="font_normal_body">安检起始</label>
                <datepicker
                  :value.sync="model.f_check_start"
                  placeholder='安检起始时间' style="width: 60%"
                  :disabled-days-of-week="[]"
                  :format="'yyyy-MM-dd'"
                  :show-rest-button="reset"
                  condition="f_offsite_time >= '{} 00:00:00'"
                  v-model="model.f_check_start">
                </datepicker>
              </div>
              <div class="form-group col-sm-2">
                <label class="font_normal_body">安检结束</label>
                <datepicker
                  :value.sync="model.f_check_end"
                  placeholder='安检结束时间' style="width: 60%"
                  :disabled-days-of-week="[]"
                  :format="'yyyy-MM-dd'"
                  :show-rest-button="reset"
                  condition="f_offsite_time <= '{} 23:59:59'"
                  v-model="model.f_check_end">
                </datepicker>
              </div>
              <div class="form-group col-sm-2" style="width: auto;margin-top:8px;float: right">
                <button style="margin-left: 4px" class="button_search button_spacing" @click="search()">查询</button>
                <button style="margin-left: 4px" class="button_search button_spacing" @click="$parent.$parent.export()">导出</button>
                <div
                     :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="form-group col-sm-2"  v-show="$parent.$parent.criteriaShow">
                <label class="font_normal_body">用户姓名</label>
                <input type="text" class="input_search" v-model="model.f_user_name"
                       style="width: 60%" placeholder="用户姓名" condition="f_user_name like '%{}%'">
              </div>
              <div class="form-group col-sm-2"  v-show="$parent.$parent.criteriaShow">
                <label class="font_normal_body">用户编号</label>
                <input type="text" class="input_search" v-model="model.f_userinfo_id"
                       style="width: 60%" placeholder="用户编号" condition="f_userinfo_id = '{}'">
              </div>
              <div class="form-group col-sm-2"  v-show="$parent.$parent.criteriaShow">
                <label class="font_normal_body">用户电话</label>
                <input type="text" class="input_search" v-model="model.f_phone_newest"
                       style="width: 60%" placeholder="用户电话" condition="f_phone_newest = '{}'">
              </div>
              <div class="form-group col-sm-2"  v-show="$parent.$parent.criteriaShow">
                <label class="font_normal_body">隐患项目</label>
                <input type="text" class="input_search" v-model="model.f_item_name"
                       style="width: 60%" placeholder="隐患项目" condition="f_item_name like '%{}%'">
              </div>
              <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%"
                          v-model='model.f_is_repaired'
                          :value.sync="model.f_is_repaired"
                          :options="[{label: '已整改', value: '已整改'}, {label: '未整改', value: '未整改'}]"
                          condition="f_is_repaired = '{}'"
                          :value-single="true"
                          close-on-select clear-button>
                </v-select>
              </div>
              <div class="form-group col-sm-2"   v-show="$parent.$parent.criteriaShow">
                <dep-selector
                  :value.sync="model.parentid"
                  v-model="model.parentid"
                  condition="parentid in {}">
                </dep-selector>
              </div>
            </div>
            <div class="row" v-show="$parent.$parent.criteriaShow">
              <div class="col-sm-2 form-group">
                <label class="font_normal_body">维修员</label>
                <input type="text" class="input_search" v-model="model.f_repairman"
                       style="width: 60%" placeholder="维修员" condition="f_repairman = '{}'">
              </div>
            </div>
          </div>
        </criteria>
        <data-grid class="list_area table_sy" 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>
                <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>
            </tr>
          </template>
          <template partial='body'>
            <td style="text-align: center">{{row.f_user_name}}</td>
            <td style="text-align: center">{{row.f_userinfo_id}}</td>
            <td style="text-align: center">{{row.f_meternumber}}</td>
            <td style="text-align: center">{{row.f_address}}</td>
            <td style="text-align: center">{{row.f_phone_newest}}</td>
            <td style="text-align: center">{{row.f_offsite_time}}</td>
            <td style="text-align: center">{{row.f_item_name}}</td>
            <td style="text-align: center">{{row.f_is_repaired}}</td>
            <td style="text-align: center">{{row.f_visit_info}}</td>
            <td style="text-align: center">{{row.f_measure}}</td>
            <td style="text-align: center">{{row.f_handle_date}}</td>
            <td style="text-align: center">{{row.f_checker_name}}</td>
            <td style="text-align: center">{{row.f_repairman}}</td>
            <td style="text-align: center">
              <button class="button_spacing button_search-1" @click='$parent.$parent.$parent.showDealModal(row)'>详情</button>
            </td>
          </template>
        </data-grid>
      </criteria-paged>
      <modal :show.sync="showSolveModal" v-ref:solveModal width="750px">
        <div slot="modal-header" class="modal-header">
          <h4 class="modal-title">
            处理详情
          </h4>
        </div>
        <div slot="modal-body" class="modal-body">
          <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>

          <div class="col-sm-6" style="margin-top: 10px">
            <label class="font_normal_body">安&nbsp;检&nbsp;员</label>
            <input class="input_search" style="width: 60%" type="text" :disabled="true" v-model="solveModal.f_checker_name" placeholder="安检员">
          </div>
          <div class="col-sm-6" style="margin-top: 10px">
            <label class="font_normal_body">安检时间</label>
            <input class="input_search" style="width: 60%" type="text" :disabled="true" v-model="solveModal.f_offsite_time" placeholder="安检时间">
          </div>
          <div class="col-sm-12" style="margin-bottom: 10px; display: flex; gap: 10px">
            <label class="font_normal_body">隐患图片</label>
            <img-self-plus v-if="solveModal.f_path" :width="200" :height="200" :src="solveModal.f_path"></img-self-plus>
            <img-self-plus v-if="solveModal.f_p1_path" :width="200" :height="200" :src="solveModal.f_p1_path"></img-self-plus>
            <img-self-plus v-if="solveModal.f_p2_path" :width="200" :height="200" :src="solveModal.f_p2_path"></img-self-plus>
          </div>
          <div v-if="solveModal.f_repairman">
            <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>
            <div class="col-sm-6" style="margin-top: 10px">
              <label class="font_normal_body">处&nbsp;理&nbsp;人</label>
              <input class="input_search" style="width: 60%" disabled="true" type="text" v-model="solveModal.f_repairman" placeholder="处理人">
            </div>
            <div class="col-sm-6" style="margin-top: 10px">
              <label class="font_normal_body">处理时间</label>
              <input class="input_search" style="width: 60%" :disabled="true" type="text" v-model="solveModal.f_repair_date" placeholder="处理时间">
            </div>
            <div  class="col-sm-12" style="margin-bottom: 10px">
              <p> <label class="font_normal_body">处理后图片</label></p>
              <P></P>
              <div class="col-sm-12">
                <div class="col-sm-4" v-if="solveModal.f_repair_path">
                  <img-self-plus :width="200" :height="200" :src="solveModal.f_repair_path" style="margin-left: 10px"></img-self-plus>
                </div>
                <div class="col-sm-4" v-if="solveModal.f_repair1_path">
                  <img-self-plus :width="200" :height="200" :src="solveModal.f_repair1_path"  style="margin-left: 10px"></img-self-plus>
                </div>
                <div class="col-sm-4" v-if="solveModal.f_repair2_path">
                  <img-self-plus :width="200" :height="200" :src="solveModal.f_repair2_path"  style="margin-left: 10px"></img-self-plus>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div slot="modal-footer" class="modal-footer" style="text-align: center">
          <button class="button_search" @click="cancel">关闭</button>
        </div>
      </modal>
    </div>
  </div>
</template>

<script>
  import {PagedList} from 'vue-client'
  import Vue from 'vue'
  import co from 'co'
  import AppData from '../../stores/AppData'
  import * as Util from '../Util'
  import getNowDate from "../../utils/getNowDate";
  import HttpResetClass from "vue-client/src/plugins/HttpResetClass";
  import BenzAMRRecorder from 'benz-amr-recorder'
  import axios from 'axios'

  let select = function* (self) {
    let http = new HttpResetClass()
    let getGasman = yield http.load('POST', '/rs/search', {
      source: 'tool.getChildrenOfResName($新安检员$)',
      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/defectList', 20,{orderitem: `'f_offsite_time desc'`})
      return {
        loading: false,
        model: model,
        fun: this.$login.f,
        checkersid: [],
        safetype: this.getSafeParam('安检类型'),
        criteriaShow: false,
        showModal: false,
        f_approval_states: this.getSafeParam('安检单审核状态'),
        f_entry_status:this.getSafeParam('安检状态'),
        f_checkplans: this.getSafeParam('有无计划'),
        showcheckmsg: false,
        checkInfo: {},
        orderDefault: "'f_offsite_time'",
        orderFields: {
          f_offsite_time: 'no'
        },
        sliceArea: [],
        cbc:[],
        DefectConfig:'' ,
        DefectConfigs:[{label:'全部',value:''},{label: '金额异常差值', value: '金额异常差值'},{label: '气量异常差值', value: '气量异常差值'}],
        device_types:[{label:'全部',value:''}],
        f_check_type:[{label:'全部',value:''},{label:'民用',value:'民用'},{label:'非民用',value:'非民用'}],
        showModal2: false,
        selectData:{
          dispatchType:'',
          f_repairman:'',
          f_remarks:'',
          f_repairtype:''
        },
        repairers: [],
        repairTypeOptions:this.$appdata.getParam('报修类型'),
        dispatchTypeOptions: [{label: '派发给站点', value: '派发给站点'},{label: '派发给维修员', value: '派发给维修员'}],
        dangerGroups: [],
        showModal3: false,
        progressbarWidth:'0',
        canToRepair: this.$appdata.getSingleValue('隐患明细转维修'),
        checkes: [],
        solveModal: {
          f_checker_name: '',
          f_offsite_time: '',
          f_path: '',
          f_p1_path: '',
          f_p2_path: '',
          f_p3_path: '',
          f_repairman: '',
          f_repair_date: '',
          f_repair_path: '',
          f_repair1_path: '',
          f_repair2_path: '',
        },
        showSolveModal: false,
        check: null,
        exportCondition: '1 = 1'
      }
    },
    computed :{
      searchData() {
        return {condition: this.model.condition}
      }
    },
    methods: {
      async export() {
        this.loading = true
        const data = {
          meterNumber: this.$refs.paged.$refs.criteria.model.f_meternumber,
          address: this.$refs.paged.$refs.criteria.model.f_address,
          checker: this.$refs.paged.$refs.criteria.model.f_checker_id,
          checkStart: this.$refs.paged.$refs.criteria.model.f_check_start,
          checkEnd: this.$refs.paged.$refs.criteria.model.f_check_end,
          userName: this.$refs.paged.$refs.criteria.model.f_user_name,
          userinfoId: this.$refs.paged.$refs.criteria.model.f_userinfo_id,
          phoneNewest: this.$refs.paged.$refs.criteria.model.f_phone_newest,
          itemName: this.$refs.paged.$refs.criteria.model.f_item_name,
          repaired: this.$refs.paged.$refs.criteria.model.f_is_repaired,
          repairMan: this.$refs.paged.$refs.criteria.model.f_repairman,
          orderItem: 'f_offsite_time'
        }
        console.log('data=', JSON.stringify(data))
        let response = await axios({
          url: '/api/af-safecheck/export/defect', // 你的下载接口地址
          method: 'POST',
          responseType: 'blob', // 表示接收二进制文件
          data,
          headers: {
            'Content-Type': 'application/json'
          }
        })
        const url = window.URL.createObjectURL(new Blob([response.data]));
        const link = document.createElement('a');
        link.href = url;
        link.setAttribute('download', '隐患单.xlsx'); // 或者其他你期望的文件名
        document.body.appendChild(link);
        link.click();
        this.loading = false
        // window.open(`/api/af-safecheck/export/defect?condition=${this.exportCondition}&orderitem=f_offsite_time`)
      },
      showDealModal(row){
        console.log('row=', JSON.stringify(row))
        this.check = row
        this.solveModal.f_path = row.f_path ? '/rs/image/file/' + row.f_path : ''
        this.solveModal.f_p1_path = row.f_p1_path ? '/rs/image/file/' + row.f_p1_path : ''
        this.solveModal.f_p2_path = row.f_p2_path ? '/rs/image/file/' + row.f_p2_path : ''
        this.solveModal.f_repair_path = row.f_repair_path ? '/rs/image/file/' + row.f_repair_path : ''
        this.solveModal.f_repair1_path = row.f_repair1_path ? '/rs/image/file/' + row.f_repair1_path : ''
        this.solveModal.f_repair2_path = row.f_repair2_path ? '/rs/image/file/' + row.f_repair2_path : ''
        this.solveModal.f_repairman = row.f_repairman
        this.solveModal.f_repair_date = row.f_repair_date
        this.solveModal.f_checker_name = this.check.f_checker_name
        this.solveModal.f_offsite_time = this.check.f_offsite_time
        this.showSolveModal = !this.showSolveModal
      },
      isChecked(row) {
        return this.checkes.findIndex(item => item.f_defect_id == row.f_defect_id) != -1
      },
      setCheckes(row) {
        let index=this.checkes.findIndex(item => item.f_defect_id == row.f_defect_id)
        if(index<0){
          this.checkes.push(row)
        }else{
          this.checkes.splice(index,1)
        }
        console.log('this.checkes=', JSON.stringify(this.checkes))
      },
      toRepair(){
        console.log('this.checkes=', JSON.stringify(this.checkes))
        if(this.checkes.length==0){
          return this.$showMessage('请先选择需要转维修的隐患！')
        }

        const dangerGroups = []
        for (const danger of this.checkes) {
          let i = dangerGroups.findIndex(dangerGroup => dangerGroup.f_userinfo_id === danger.f_userinfo_id)
          if (i == -1){
            dangerGroups.push({
              f_userinfo_id: danger.f_userinfo_id,
              dangers: []
            })
            i = dangerGroups.length - 1
          }
          dangerGroups[i].dangers.push(danger)
        }
        this.dangerGroups = dangerGroups
        console.log('this.dangerGroups=', JSON.stringify(this.dangerGroups))
        this.showModal2=true
      },
      getEmp() {
        let val = {source: 'this.getParentByType($organization$).getSpecialResByType($user$).where(row.getAttributes().get($rolestr$)!=null ).where(row.getAttributes().get($rolestr$).indexOf($维修员$) != -1))', userid: `${this.$login.f.id}`}
        let http = new HttpResetClass()
        http.load('POST', '/rs/search', {data: val}, {resolveMsg: null, rejectMsg: null}).then((res) => {
          let str=''
          res.data.forEach((item,idx,arr) => {
            //tag
            if(idx+1==arr.length){
              str += item.id
            }else{
              str += item.id+','
            }

          })
          let http1 = new HttpResetClass()
          http1.load('POST', 'rs/sql/tel_singleTable_OrderBy', {
            data: {
              items: 'id,f_user_telephone',
              tablename: 't_user',
              condition: `id  in  (${str})`,
              orderitem: 'id'
            }
          }, {resolveMsg: null, rejectMsg: null}).then((ress) => {

            res.data.forEach((user)=>{
              try {
                ress.data.forEach((tel,tidx,arr)=>{
                  //tag
                  if(user.id==tel.id){
                    this.repairers.push({label: `${user.name}：${tel.f_user_telephone}`, value: user.name})
                    ress.data.splice(tidx,1)
                    //tag
                    throw new Error("跳出循环");
                  }
                })
              }catch (e) {
                //tag
              }
            })
          })

        })
      },
      getSiteRes(obj) {
        console.log('siteRes ---> ')
        console.log(obj)
        if(obj.resids[0]){
          this.selectData.f_meetunit = obj.res.join('.')
          this.selectData.f_reciever = obj.resids.join('.')
          this.selectData.f_outlets = obj.res[obj.res.length - 1]
        }else {
          this.selectData.f_meetunit = ''
          this.selectData.f_reciever = ''
          this.selectData.f_outlets = ''
        }
      },
      cancel1(){
        this.showModal2=false
        this.selectData={
          dispatchType:'',
          f_repairman:'',
          f_remarks:'',
          f_repairtype:''
        }
      },
      async rectification(){
        if(this.selectData.dispatchType){
          if(this.selectData.dispatchType=='派发给站点'){
            if(!this.selectData.f_reciever){
              this.$showMessage('请选择部门！')
              return
            }
          }else{
            if(!this.selectData.f_repairman){
              this.$showMessage('请选择维修员！')
              return
            }
          }
        }else {
          this.$showMessage('请选择派发类型！')
          return
        }

        if(!this.selectData.f_repairtype){
          this.$showMessage('请选择报修类型！')
          return
        }
        this.showModal3=true
        let act={}
        let toRepair=''
        let successCount=0
        if(this.selectData.dispatchType=='派发给站点'){
          act={f_meetunit:this.selectData.f_meetunit,f_reciever:this.selectData.f_reciever,f_service_acitivity_type:'派单'}
          toRepair=null
        }else{
          console.log('派发给维修员---------'+this.selectData.f_repairman)
          act={f_meetunit:'',f_reciever:this.selectData.f_repairman,f_service_acitivity_type:'派单'}
          toRepair='一级派单'
        }
        let rep={
          loginUser: {
            name: this.$login.f.name,
            ename: this.$login.f.ename
          },
          f_meetunit: this.$login.f.deps,
          f_attendant: this.$login.f.name,
          f_outlets: this.$login.f.deps,
          f_remarks: this.selectData.f_remarks,
          f_repairtype: this.selectData.f_repairtype,
          toRepair: toRepair,
          activity:act
        }
        for(let i=0; i<this.dangerGroups.length; i++){
          let defectIdStr = ''
          const defectIds = []
          for (let j = 0; j < this.dangerGroups[i].dangers.length; j++) {
            defectIds.push(`'${this.dangerGroups[i].dangers[j].f_defect_id}'`)
          }
          defectIdStr = `(${defectIds.join(',')})`
          const data = {
            id:this.dangerGroups[i].dangers[0].f_paper_id,
            repData:rep,
            source:'pc',
            defectIdStr: defectIdStr
          }
          console.log('data=', JSON.stringify(data))
          try {
            let result =await new HttpResetClass().load('post','/rs/logic/phoneUploadRectification', data, {resolveMsg: null, rejectMsg: null})
            if (result.data.code==200) {
              successCount += result.data.successcon
              this.progressbarWidth=Math.ceil((i+1)*100/(this.dangerGroups.length))
            }
          }catch (e) {
            this.showModal3=false
            this.$showMessage('网络异常，请稍后再试！')
            return
          }
        }
        this.showModal3=false
        this.cancel1()
        this.$showMessage('本次转维修成功'+successCount+'单')
      },
      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
              })
            })
          })
        }
      },
      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()
      },
      cancel() {
        this.showSolveModal = false
      },
      print(row) {
        this.showcheckmsg = true
        this.checkInfo = row
      },

      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) {
        this.model.search(args.condition, args.model, args.condValue)
      }
    },

    ready() {
      this.$refs.paged.$refs.criteria.model.f_check_start = Util.toStartDateString()
      this.getEmp()
      this.readConfig()
      ////tag
      this.function = this.f
      ////tag

      let gen = select(this)
      //this.pianqu()
      this.Mreadibook(`('${this.$login.f.orgid}')`)
      co(gen)
    }
  }
</script>
