<template>
  <div class="auto" id="meterInfoTest">
    <validator name='m' @valid="mValid(true)" @invalid="mValid(false)">
      <form class="form-horizontal select-overspread ">
        <div style="margin-top: 2%;">
          <a style="font-size: 16px;font-weight: 500;">表具信息</a>&nbsp;<a style="color: #999999;text-decoration: none"></a>
        </div>
        <div class="row">
          <div class="col-sm-4 form-group" v-if="isiot" :class="[$m.f_meternumber.required ? 'has-error' : '']">
            <label for="f_meternumber" class="font_normal_body">&ensp;表&emsp;&emsp;号</label>
            <input type="text" class="input_search" style="width:60%" v-model="row.f_meternumber"
                   @blur="meternumberValidate()" placeholder='表号' v-validate:f_meternumber='{required: true }'
                   v-next-el="{id: 'metertitles'}">
          </div>
          <div class="col-sm-4 form-group" v-else>
            <label for="f_meternumber" class="font_normal_body">&ensp;表&emsp;&emsp;号</label>
            <input type="text" class="input_search" style="width:60%" v-model="row.f_meternumber"
                   @blur="meternumberValidate()" placeholder='表号'
                   v-next-el="{id: 'metertitles'}">
          </div>
          <div class="col-sm-4 form-group">
            <label for="f_metertitles" class="font_normal_body">&ensp;表&ensp;封&ensp;号</label>
            <input type="text" class="input_search" style="width:60%" v-model="row.f_metertitles" placeholder='表封号'
                   v-next-el="{id: 'meterbase'}">
          </div>
          <div class="col-sm-4 form-group">
            <label for="f_metertitles" class="font_normal_body">表具状态</label>
            <input type="text" class="input_search" style="width:60%" v-model="row.f_table_state" placeholder='表具状态' disabled>
          </div>
          <div class="col-sm-4 form-group">
            <label for="f_meter_base" class="font_normal_body">&ensp;表&ensp;读&ensp;数</label>
            <input type="number" class="input_search" style="width:60%" v-model="row.f_meter_base" placeholder='表底数'
                   :disabled="!jurisdiction.includes('档案信息查询修改')" :readonly="!row.f_userfiles_id">
          </div>
          <div class="col-sm-4 form-group">
            <label for="f_meter_base" class="font_normal_body">&ensp;初始底数</label>
            <input type="number" class="input_search" style="width:60%" v-model="row.f_initial_base" placeholder='表底数'
                   :disabled="!jurisdiction.includes('档案信息查询修改')">
          </div>

          <div class="col-sm-4 form-group" :class="[$m.brand.required ? 'has-error' : '']">
            <label for="gasbrand" class="font_normal_body">气表品牌</label>
            <input type="text" class="input_search" style="width:60%" v-show="false" v-model="$refs.brand.selectedItems"
                   v-validate:brand='{required: true }'>
<!--            <v-select :value.sync="row.gasbrand" :options='meterbrands' placeholder='气表品牌' close-on-select
                      search @change='brandChange' v-model='row.gasbrand' :disabled="!((row.f_meter_classify.indexOf('卡表') !== -1&&row.f_user_state === '预备') || (row.f_meter_classify.indexOf('卡表') !== -1&&row.f_whether_hairpin === '未发'))" v-ref:brand></v-select>-->
            <v-select :value.sync="row.gasbrand" :options='meterbrands' placeholder='气表品牌' close-on-select
                      search @change='brandChange' v-model='row.gasbrand' :disabled="!(user_State !== '正常'|| isCalorimeter === '卡表')"  v-ref:brand></v-select>
          </div>
          <div class="col-sm-4 form-group" :class="[$m.model.required ? 'has-error' : '']">
            <label for="gasmodel" class="font_normal_body">气表型号</label>
            <input type="text" v-show="false" v-model="$refs.model.selectedItems"
                   v-validate:model='{required: true }'>
<!--            <v-select :value.sync="row.gasmodel" :options='row.gasbrand[0].gasmodel' placeholder='气表型号'-->
<!--                      close-on-select-->
<!--                      v-model='row.gasmodel' :disabled="!(row.gasbrand.length !== 0 && ((row.f_meter_classify.indexOf('卡表') !== -1&&row.f_user_state === '预备') || (row.f_meter_classify.indexOf('卡表') !== -1&&row.f_whether_hairpin === '未发')))" v-ref:model></v-select>-->
            <v-select :value.sync="row.gasmodel" :options='row.gasbrand[0].gasmodel' placeholder='气表型号'
                      close-on-select
                      v-model='row.gasmodel'  :disabled="!(row.gasbrand.length !== 0 && (user_State !== '正常' || isCalorimeter === '卡表' ))"   v-ref:model></v-select>
          </div>
          <div class="col-sm-4 form-group">
            <label for="f_meter_base" class="font_normal_body">&ensp;累购气量</label>
            <input type="number" class="input_search" style="width:60%" v-model="row.f_total_gas" placeholder='累购气量'
                   :disabled="!jurisdiction.includes('档案信息查询修改')">
          </div>
          <div class="col-sm-4 form-group">
            <label for="f_meter_base" class="font_normal_body">表写卡累购气量</label>
            <input type="number" class="input_search" style="width:60%" v-model="row.f_write_totalgas" placeholder='表写卡累购气量'
                   :disabled="!jurisdiction.includes('档案信息查询修改')">
          </div>
          <div class="col-sm-4 form-group">
            <label for="f_meter_base" class="font_normal_body">&ensp;累购金额</label>
            <input type="number" class="input_search" style="width:60%" v-model="row.f_total_fee" placeholder='累购金额'
                   :disabled="!jurisdiction.includes('档案信息查询修改')">
          </div>
          <div class="col-sm-4 form-group">
            <label for="f_meter_base" class="font_normal_body">表写卡累购金额</label>
            <input type="number" class="input_search" style="width:60%" v-model="row.f_write_totalfee" placeholder='表写卡累购金额'
                   :disabled="!jurisdiction.includes('档案信息查询修改')">
          </div>
          <div class="col-sm-4 form-group" v-show="row.f_meter_classify != '机表'">
            <label for="f_times" class="font_normal_body">&ensp;写卡次数</label>
            <input type="number" class="input_search" style="width:60%" v-model="row.f_times" placeholder='写卡次数'
                   :disabled="!jurisdiction.includes('档案信息查询修改')">
          </div>
          <div class="col-sm-4 form-group" v-show="row.f_meter_classify == '物联网表'">
            <label for="f_times" class="font_normal_body">物联网写卡次数</label>
            <input type="number" class="input_search" style="width:60%" v-model="row.f_iot_times" placeholder='物联网次数'
                   :disabled="!jurisdiction.includes('档案信息查询修改')">
          </div>
          <div class="col-sm-4 form-group"  v-show="false">
            <label for="f_remanent_gas" class="font_normal_body">剩余气量</label>
            <input type="number" class="input_search" style="width:60%"  v-model="row.f_remanent_gas"
                   placeholder='剩余气量'
                   :disabled="f_userinfo_id"></input>
            <!--<button type="button" name="button" class="btn btn-link" @click="modefiy('f_remanent_gas')" v-if="f_userinfo_id">修改</button>-->
          </div>
          <div class="col-sm-4 form-group">
            <label for="f_times" class="font_normal_body">&ensp;最大量程</label>
            <input type="number" class="input_search" style="width:60%" v-model="row.f_capacity" placeholder='最大量程'>
          </div>
          <div class="col-sm-4 form-group" v-show="row.f_meter_classify == '物联网表'">
            <label for="gasmodel" class="font_normal_body">&ensp;阀门状态</label>
            <v-select :value.sync="row.f_valve_state" :options='valvestate' placeholder='阀门状态' close-on-select
                      v-model='row.f_valve_state'></v-select>
          </div>
          <div class="col-sm-4 form-group" :class="[$m.way.required ? 'has-error' : '']" v-if="row.gasbrand.length > 0 && row.gasbrand[0].f_meter_type == '物联网表' && row.gasbrand[0].f_hascard == '是'">
            <label for="f_open_way" class="font_normal_body">开户方式</label>
            <v-select :value.sync="row.f_open_way" v-model='row.f_open_way'
                      placeholder='开户方式' :options='openWay' :value-single="true"
                      close-on-select :disabled="false" v-ref:way></v-select>
            <input type="text" v-show="false" v-model="$refs.way.selectedItems" v-validate:way='{required: true }'>
          </div>
          <div class="col-sm-4 form-group" v-show="row.gasbrand.length > 0 && row.gasbrand[0].f_meter_brand.indexOf('集中器') !== -1">
            <label class="font_normal_body" title="集中器">集&ensp;中&ensp;器</label>
            <v-select :value.sync="row.f_concentrator_id" :options='concentrators' value-single placeholder='集中器' close-on-select v-if="row.f_userfiles_id"
                      search v-model='row.f_concentrator_id' :disabled="true"></v-select>
            <v-select :value.sync="row.f_concentrator_id" :options='concentrators' value-single placeholder='集中器' close-on-select v-else
                      search v-model='row.f_concentrator_id' :disabled="false"></v-select>
          </div>
        </div>
        <div>
          <a style="font-size: 16px;font-weight: 500;">气价信息</a>&nbsp;<a style="color: #999999;text-decoration: none"></a>
        </div>
        <div class="row">
          <div class="col-sm-4 form-group" :class="[$m.name.required ? 'has-error' : '']">
            <label for="pricename" class="font_normal_body">气价名称</label>
            <v-select :value.sync="row.pricename" v-model="row.pricename" search
                      placeholder='气价名称' :options="getPricenames" @change="priceChange"
                      close-on-select :disabled="permissionPrice" v-ref:name></v-select>
            <input type="text" v-show="false" v-model="$refs.name.selectedItems" v-validate:name='{required: true }'>
          </div>
          <div class="col-sm-4 form-group">
            <label for="f_username" class="font_normal_body">&ensp;客户类型</label>
            <v-select :value.sync="row.f_user_type"
                      :options='usertypes' placeholder='客户类型'
                      @change="userTypeChange()"
                      :disabled="true"
                      close-on-select></v-select>
          </div>
          <div class="col-sm-4 form-group"
               :class="[$m.gas.required ? 'select-error' : '']">
            <label for="f_username" class="font_normal_body">&ensp;用气性质</label>
            <input type="text" v-show="false" v-model="$refs.gas.selectedItems" v-validate:gas='{required: true }'>
            <v-select :value.sync="row.f_gasproperties" v-model="row.f_gasproperties"
                      :options='gasproperties' placeholder='用气性质'
                      :disabled="true"
                      close-on-select v-ref:gas></v-select>
          </div>
          <div class="col-sm-4 form-group">
            <label for="f_detailprice" class="font_normal_body">&ensp;价&emsp;&emsp;格</label>
            <input type="text" class="input_search" style="width:60%" v-model="row.f_detailprice" placeholder='价格'
                   disabled>
          </div>
          <div class="col-sm-4 form-group" :class="[$m.type.required ? 'select-error' : '']">
            <label for="pricetype" class="font_normal_body">&ensp;气价类型</label>
            <v-select :value.sync="row.pricetype" v-model="row.pricetype"
                      placeholder='气价类型' :options="pricetypes"
                      :value-single="true"
                      :disabled="true"
                      close-on-select v-ref:type>
            </v-select>
            <input type="text" v-show="false" v-model="$refs.type.selectedItems" v-validate:type='{required: true }'>
          </div>
          <div class="col-sm-4 form-group">
            <label class="font_normal_body">&ensp;气价备注</label>
            <input type="text" class="input_search" style="width:60%" v-model="row.f_price_comments" placeholder='气价备注' disabled>
          </div>
        </div>
        <div>
          <a style="font-size: 16px;font-weight: 500;">表具其他信息</a>&nbsp;<a style="color: #999999;text-decoration: none"></a>
        </div>
        <div class="row">
          <div class="col-sm-4 form-group" v-show="row.f_gasproperties=='工业'||row.f_gasproperties=='工业用气'">
            <label for="f_gongye_type" class="font_normal_body" title="参数:工业备注">&ensp;工业备注</label>
            <v-select :value.sync="row.f_gongye_type" v-model='row.f_gongye_type'
                      :options='gongyetype' placeholder='工业备注'
                      close-on-select
                      v-el:cc></v-select>
          </div>
          <div class="col-sm-4 form-group">
            <label for="gasmodel" class="font_normal_body">&ensp;表&ensp;&ensp;&ensp;&ensp;向</label>
            <v-select :value.sync="row.f_aroundmeter" :options='aroundmeters' placeholder='左右表' close-on-select
                      v-model='row.f_aroundmeter'></v-select>
          </div>
          <div class="col-sm-4 form-group" >
            <label for="f_bqf_type" class="font_normal_body">表前阀型号</label>
            <input type="text" class="input_search" style="width:60%" v-model="row.f_bqf_type"
                   placeholder='表前阀型号'>
          </div>
          <div class="col-sm-4 form-group">
            <label class="font_normal_body">表具使用年限</label>
            <input type="number" class="input_search" style="width:60%" v-model="row.f_use_limit"
                   :value.sync="row.f_use_limit"
                   placeholder='表具使用年限' >
          </div>
          <div class="col-sm-4 form-group">
            <label for="f_gas_person" class="font_normal_body">&ensp;通&ensp;气&ensp;人</label>
            <input type="text" class="input_search" style="width:60%" style="width:60%" v-model="row.f_gas_person"
                   placeholder='通气人'></input>
            <!-- <v-select :value.sync="row.f_gas_person" v-model="row.f_gas_person"
                :options='gasperson' placeholder='通气人'
                close-on-select></v-select> -->
          </div>
          <div class="col-sm-4 form-group" :class="[$m.f_gas_date.required ? 'has-error' : '']">
            <input type="text" v-model="$refs.f_gas_date.value" v-show="false"  v-validate:f_gas_date='{required: true }'>
            <label for="f_gas_date" class="font_normal_body">&ensp;通气日期</label>
            <datepicker style="width:60%" placeholder="通气日期"
                        v-model="row.f_gas_date"
                        v-ref:f_gas_date
                        @change="gasDateChange"
                        :value.sync="row.f_gas_date"
                        :format="'yyyy-MM-dd HH:mm:ss'"
            ></datepicker>
          </div>

          <div class="col-sm-4 form-group" >
            <label for="f_position" class="font_normal_body"  title="参数:安装位置">&ensp;安装位置</label>
            <v-select :value.sync="row.f_position" v-model="row.f_position"
                      :options='positions' placeholder='安装位置'
                      close-on-select></v-select>
          </div>
          <div class="col-sm-4 form-group" v-show="true">
            <label for="f_install_person" class="font_normal_body">&ensp;安&ensp;装&ensp;人</label>
            <v-select :value.sync="row.f_install_person" v-model="row.f_install_person"
                      :options='installperson' placeholder='安装人'
                      close-on-select></v-select>
          </div>
          <div class="col-sm-4 form-group">
            <label for="f_subscribe_date" class="font_normal_body">&ensp;预约时间</label>
            <datepicker style="width:60%" placeholder="预约通气时间"
                        v-model="row.f_subscribe_date"
                        :value.sync="row.f_subscribe_date"
                        :format="'yyyy-MM-dd HH:mm:ss'"
            ></datepicker>
          </div>
          <div class="col-sm-4 form-group" v-show="opteratormetrbook" >
            <label for="f_position" class="font_normal_body"  >&ensp;抄&ensp;表&ensp;册</label>
            <v-select :value.sync="row.f_meter_book_num" v-model="row.f_meter_book_num"
                      :options='meterbookoptions' placeholder='抄表册'
                      close-on-select></v-select>
          </div>
          <div class="col-sm-4 form-group" v-show="true" :class="[$m.f_install_date.required ? 'has-error' : '']">
            <input type="text" v-model="$refs.f_install_date.value" v-show="false" v-validate:f_install_date='{required: true }'>
            <label for="f_install_date" class="font_normal_body">&ensp;安装日期</label>
            <datepicker style="width:60%" id="startDate" placeholder="安装日期" width='100%'
                        v-model="row.f_install_date"
                        :value.sync="row.f_install_date"
                        class="datepicker"
                        v-ref:f_install_date
                        :format="'yyyy-MM-dd HH:mm:ss'"
                        :show-reset-button="true">
            </datepicker>
          </div>
          <div class="col-sm-4 form-group">
            <label for="f_adjustable" class="font_normal_body">&ensp;调&ensp;压&ensp;箱</label>
            <v-select :value.sync="row.f_adjustable" :options='adjustables' placeholder='调压箱' close-on-select
                      v-model='row.f_adjustable' :search='true'></v-select>
          </div>
          <div class="col-sm-4 form-group">
            <label for="f_hand_date" class="font_normal_body">&ensp;上次抄表</label>
            <datepicker style="width:60%" id="f_hand_date" placeholder="上次抄表日期"
                        v-model="row.f_hand_date"
                        :value.sync="row.f_hand_date"
                        class="datepicker"
                        :format="'yyyy-MM-dd HH:mm:ss'"
                        :show-reset-button="true">
            </datepicker>
          </div>
          <div v-if="ratioshow" class="col-sm-4 form-group"
               :class="[$m.meternumber.required ? 'has-error' : '']">
            <label for="f_ratio" class="font_normal_body">比&emsp;&emsp;率</label>
            <input type="number" class="input_search" style="width:60%"  v-model="row.f_price_ratio"
                   :value.sync="row.f_price_ratio"
                   v-validate:meternumber='{required: true }' placeholder='比率'>
          </div>
          <div class="col-sm-4 form-group" >
            <label for="f_factory_date" class="font_normal_body">&ensp;出厂日期</label>
            <datepicker style="width:60%" id="f_factory_date" placeholder="出厂日期" width='100%'
                        v-model="row.f_factory_date"
                        :value.sync="row.f_factory_date"
                        class="datepicker"
                        :format="'yyyy-MM-dd'"
                        :show-reset-button="true">
            </datepicker>
          </div>
          <div class="col-sm-4 form-group" >
            <label for="f_scrap_date" class="font_normal_body">&ensp;报废日期</label>
            <datepicker style="width:60%" id="ScrapDate" placeholder="报废日期" width='100%'
                        v-model="row.f_scrap_date"
                        :value.sync="row.f_scrap_date"
                        class="datepicker"
                        :format="'yyyy-MM-dd'"
                        :show-reset-button="true">
            </datepicker>
          </div>
          <div class="col-sm-4 form-group">
            <label for="gasmodel" class="font_normal_body">&ensp;垃&ensp;圾&ensp;费</label>
            <v-select :value.sync="row.f_garbage_fee" :options='garbagefee' placeholder='垃圾费' close-on-select
                      :value-single="true"
                      v-model='row.f_garbage_fee'></v-select>
          </div>
          <div class="col-sm-4 form-group">
            <label class="font_normal_body">&ensp;抄&ensp;表&ensp;员</label>
            <v-select :value.sync="row.f_inputtor" v-model='row.f_inputtor'
                      style="width:60%"
                      :options='inputtores' placeholder='抄表员'
                      close-on-select
                      condition="f_inputtor like '%{}%'" v-el:cc></v-select>
          </div>
          <div class="col-sm-4 form-group" >
            <label for="f_usetype" class="font_normal_body" title="参数:使用类型">&ensp;使用类型</label>
            <v-select :value.sync="row.f_usetype" v-model="row.f_usetype"
                      :options='usetype' placeholder='使用类型'
                      close-on-select></v-select>
          </div>
          <div class="col-sm-4 form-group" >
            <label for="f_position" class="font_normal_body" title="参数:使用状态">&ensp;使用状态</label>
            <v-select :value.sync="row.f_usestate" v-model="row.f_usestate"
                      :options='usestate' placeholder='使用状态'
                      close-on-select></v-select>
          </div>
          <div class="col-sm-4 form-group" >
            <label for="f_limit_sms" class="font_normal_body">&ensp;短信限定</label>
            <input type="text" class="input_search" style="width:60%" v-model="row.f_limit_sms"
                   placeholder='短信限定'></input>
          </div>
          <div style="" class="col-sm-4 form-group">
            <label for="f_alarm_code" class="font_normal_body ">&ensp;报警器号</label>
            <input type="text" class="input_search" style="width:60%" v-model="row.f_alarm_code" placeholder='报警器号'/>
          </div>
          <div style="" class="col-sm-4 form-group">
            <label for="f_hand_month" class="font_normal_body ">&ensp;抄表月份</label>
            <v-select :value.sync="row.f_hand_month" v-model="row.f_hand_month"
                      :options='handmonth' placeholder='抄表月份'
                      close-on-select></v-select>
          </div>
          <div style="" class="col-sm-4 form-group">
            <label for="f_userfiles_address" class="font_normal_body ">&ensp;用气点名</label>
            <input class="input_search" style="width:60%" v-model="row.f_userfiles_address"/>
          </div>
          <div style="" class="col-sm-4 form-group">
            <label class="font_normal_body">&ensp;经&ensp;&ensp;&ensp;&ensp;度</label>
            <input type="text" style="width:60%" v-model="row.f_userfiles_lng" class="input_search" placeholder="经度"/>
          </div>
          <div style="" class="col-sm-4 form-group">
            <label class="font_normal_body">&ensp;纬&ensp;&ensp;&ensp;&ensp;度</label>
            <input type="text" style="width:48%" v-model="row.f_userfiles_lat" class="input_search" placeholder="纬度"/>
            &ensp;<span class="glyphicon glyphicon-map-marker" @click="openModal" ></span>
          </div>
          <div class="col-sm-4 form-group">
            <label class="font_normal_body">备&ensp;&ensp;&ensp;&ensp;注</label>
            <input type="text" style="width:60%" v-model="row.f_comments" class="input_search" placeholder="备注"/>
          </div>
          <div class="col-sm-4 form-group" v-if="config.overduesetShow">
            <label class="font_normal_body">违约金规则</label>
            <v-select :value.sync="row.f_overdue_set" v-model="row.f_overdue_set"
                      :options='overdueset' placeholder='违约金规则'
                      close-on-select></v-select>
          </div>

          <template v-if="config.stuckFlowmeterShow">
            <div class="col-sm-4 form-group">
              <label class="font_normal_body" title="控制器通经">控制器通经</label>
              <input type="text" class="input_search" style="width:60%" v-model="row.f_control_pass"
                     placeholder='控制器通经'></input>
            </div>
            <div class="col-sm-4 form-group">
              <label class="font_normal_body" title="控制器压力等级">控制器压力等级</label>
              <input type="text" class="input_search" style="width:60%" v-model="row.f_control_mpa_level"
                     placeholder='控制器压力等级'></input>
            </div>
            <div class="col-sm-4 form-group">
              <label class="font_normal_body" title="流量计表号">流量计表号</label>
              <input type="text" class="input_search" style="width:60%" v-model="row.f_flowmeter_number"
                     placeholder='流量计表号'></input>
            </div>
            <div class="col-sm-4 form-group">
              <label class="font_normal_body" title="流量计表封号">流量计表封号</label>
              <input type="text" class="input_search" style="width:60%" v-model="row.f_llj_metertitles"
                     placeholder='流量计表封号'></input>
            </div>
            <div class="col-sm-4 form-group">
              <label class="font_normal_body" title="流量计品牌">流量计品牌</label>
              <v-select :value.sync="row.f_flowmeter_brand" :options='flowmeterbrands' value-single placeholder='流量计品牌' close-on-select
                        search v-model='row.f_flowmeter_brand'></v-select>
            </div>
            <div class="col-sm-4 form-group">
              <label class="font_normal_body" title="流量计型号">流量计型号</label>
              <v-select :value.sync="row.f_flowmeter_model" :options='flowmetermodels(row.f_flowmeter_brand)' value-single placeholder='流量计型号' close-on-select
                        v-model='row.f_flowmeter_model' :disabled='row.f_flowmeter_brand.length === 0'></v-select>
            </div>
            <div class="col-sm-4 form-group">
              <label class="font_normal_body" title="流量计通经">流量计通经</label>
              <input type="text" class="input_search" style="width:60%" v-model="row.f_flowmeter_pass"
                     placeholder='流量计通经'></input>
            </div>
            <div class="col-sm-4 form-group">
              <label class="font_normal_body" title="流量计压力等级">流量计压力等级</label>
              <input type="text" class="input_search" style="width:60%" v-model="row.f_flowmeter_mpa_level"
                     placeholder='流量计压力等级'></input>
            </div>
            <div class="col-sm-4 form-group">
              <label class="font_normal_body" title="流量计出厂日期">流量计出厂日期</label>
              <datepicker style="width:60%" placeholder="流量计出厂日期"
                          v-model="row.f_flowmeter_factory_date"
                          :value.sync="row.f_flowmeter_factory_date"
                          :format="'yyyy-MM-dd HH:mm:ss'"
              ></datepicker>
            </div>
            <div class="col-sm-4 form-group">
              <label class="font_normal_body" title="流量计精准度">流量计精准度</label>
              <input type="text" class="input_search" style="width:60%" v-model="row.f_flowmeter_accuracy"
                     placeholder='流量计精准度'></input>
            </div>
            <div class="col-sm-4 form-group">
              <label class="font_normal_body" title="流量计电仪出厂编号">流量计电仪出厂编号</label>
              <input type="text" class="input_search" style="width:60%" v-model="row.f_flowmeter_factory_num"
                     placeholder='流量计电仪出厂编号'></input>
            </div>
            <div class="col-sm-4 form-group">
              <label class="font_normal_body" title="流量计电仪出厂编号">流量计类型</label>
              <input type="text" class="input_search" style="width:60%" v-model="row.f_llj_type"
                     placeholder='流量计类型'></input>
            </div>
            <div class="col-sm-4 form-group">
              <label class="font_normal_body" title="流量计安装日期">流量计安装日期</label>
              <datepicker style="width:60%" placeholder="流量计安装日期"
                          v-model="row.f_flowmeter_install_date"
                          :value.sync="row.f_flowmeter_install_date"
                          :format="'yyyy-MM-dd HH:mm:ss'"
              ></datepicker>
            </div>
          </template>
        </div>
      </form>
    </validator>
    <!--<idverify :show.sync="show" @change-con="changeVal"></idverify>-->
    <modal v-if="showParame" :show.sync="showParame" v-ref:modal backdrop="false">
      <header slot="modal-header" class="modal-header">
        <button type="button" class="close" @click="cancel"><span>&times;</span></button>
        <h3 class="modal-title" style="text-align: center;">添加参数</h3>
      </header>
      <article slot="modal-body" class="modal-body">
        <add-json-parameter v-ref:addparamlist :gasmodel_id="userfileid" :gastype="gastype"
                            :gasid="gasid"></add-json-parameter>
      </article>
      <footer slot="modal-footer" class="modal-footer">
        <button type="button" class="btn btn-primary" @click='confirmUserfiles()'>确认</button>
      </footer>
    </modal>

    <modal :show.sync="mapShow" v-if="mapShow"  large backdrop="false" :width="900">
      <header slot="modal-header" class="modal-header">
      </header>
      <article slot="modal-body" class="modal-body">
        <amap-location :islocationclearmark="false"  dom="addboxmap" v-ref:positionInfo @getmylocation="getmylocation"></amap-location>
      </article>
      <footer slot="modal-footer" class="modal-footer">
        <button v-show="mapShow" type="button" class="button_clear btn-gn" @click='closeModal'>取消</button>
        <button v-show="mapShow" type="button" class="button_clear btn-gn" @click='confirmLocation'>确认</button>
      </footer>
    </modal>
  </div>
</template>

<script>
  import co from 'co'
  import {HttpResetClass} from 'vue-client'
  import Vue from 'vue'

  let meterBookGen = function * (self) {
    if (self.$login.r.find(value => value == '抄表册建档')) {
      self.opteratormetrbook = true
    }
    let temp = {
      tablename: 't_meter_book',
      condition: `f_book_state='有效' and f_filiale_id='${self.$login.f.orgid}'`
    }
    let http = new HttpResetClass()
    let meterbooks = yield http.load('POST', 'rs/sql/saleSingleTable', {data: temp},
      {resolveMsg: null, rejectMsg: '获取抄表册信息失败！！'})
    if (meterbooks.data.length > 0) {
      let options = []
      for (let i = 0; i < meterbooks.data.length; i++) {
        let tmp = {label: meterbooks.data[i].f_book_name, value: `${meterbooks.data[i].id}`}
        options.push(tmp)
      }
      self.meterbookoptions = options
    }
    try {
      let result = yield http.load('GET', `rs/vue/MeterinfoTest.json`, {}, {resolveMsg: null, rejectMsg: null})
      Object.assign(self.config, result.data)
      if (!self.row.f_open_way) self.row.f_open_way = self.config.open_way
    } catch (error) {
      // 忽略704,文件找不到异常
      if (error.status !== 704) {
        throw error
      }
    }
  }
  let brandChangeGen = function* (self, val) {
    let beforeRecord = null

    if (self.meter.f_meter_classify === '机表') {
      beforeRecord = yield self.$resetpost('rs/sql/saleSingleTable', {
        data: {
          tablename: 't_handplan',
          condition: `f_user_id = '${self.row.f_user_id}' and f_meter_state in ('已抄表','未抄表')`
        }
      }, {resolveMsg: null, rejectMsg: '在档案中更改气表品牌时，获取之前机表抄表信息出错！！'})
    } else {
      beforeRecord = yield self.$resetpost('rs/sql/saleSingleTable', {
        data: {
          tablename: 't_sellinggas',
          condition: `f_user_id = '${self.row.f_user_id}' and f_state = '有效'`
        }
      }, {resolveMsg: null, rejectMsg: '在档案中更改气表品牌时，获取之前卡表收费信息出错！！'})
    }
    if (beforeRecord.data.length > 0 && self.row.gasbrand[0].f_meter_brand != self.oldrow.gasbrand[0].f_meter_brand) {
      self.$showAlert('该气表已投入使用，如需更改请执行换表操作', 'warning', 3000)
      // self.row.gasbrand = self.meter.gasbrand
      self.$dispatch('success')
      /* self.row.valid = bool
      self.$dispatch('self-valid') */
    } else {
      self.row.f_whether_hairpin = self.row.gasbrand[0].f_meter_type === '机表' ? '无卡' : '未发'
    }
    console.log('111', self.row)
  }
  export default {
    title: '表具信息',
    data () {
      return {
        config: {
          // 卡控流量计相关字段显示
          stuckFlowmeterShow: false,
          overduesetShow: true,
          open_way: '指令开户'
        },
        mapShow: false,
        viewsee: false,
        isCalorimeter: '',
        row: this.meter,
        show: false,
        field: '',
        ratioshow: false,
        userfileid: '',
        gasid: '',
        gastype: 'userfiles',
        showParame: false,
        selectUserFiles: '', // 选中的 userfiles
        jurisdiction: this.$login.r,
        positions: this.$appdata.getParam('安装位置'),
        usetype: this.$appdata.getParam('使用类型'),
        usestate: this.$appdata.getParam('使用状态'),
        aroundmeters: this.$appdata.getParam('左右表'),
        garbagefee: this.$appdata.getParam('垃圾费'),
        valvestate: this.$appdata.getParam('阀门状态'),
        usertypes: this.$appdata.getParam('用户类型'),
        handmonth: [{label: '单月', value: '单月'}, {label: '双月', value: '双月'}],
        gasproperties: this.meter.f_user_type && this.meter.f_user_type.length === 1 ? this.$appdata.getParam(this.meter.f_user_type[0]) : [],
        pricetypes: this.$appdata.getParam('气价类型'),
        industrycomments: this.$appdata.getParam('工业备注'),
        openWay: [{label: '指令开户', value: '指令开户'}, {label: '发卡开户', value: '发卡开户'}],
        concentrators: [],
        meterbookoptions: [],  // 抄表册选项
        opteratormetrbook: false, // 抄表册操作
        oldrow: [],
        overdueset:[],
        isiot: true,
        templng: '',  //  临时经度
        templat: '', //  临时纬度
        user_State: ''
      }
    },
    props: ['f_filialeid', 'meter', 'isdecimal', 'valid', 'f_userinfo_id', 'overdueset', 'curuser'],
    async ready () {
      this.user_State = this.curuser.f_user_state
      if (this.curuser.f_meter_classify.indexOf('卡表') !== -1 && this.curuser.f_whether_hairpin === '未发') {
        this.isCalorimeter = '卡表'
      }
      this.row = Object.assign(this.row, this.meter, {f_use_limit : this.$appdata.getSingleValue('报废年限')})
      if (this.row.f_meter_classify) {
        if (this.row.f_meter_classify === '物联网表') {
          this.isiot = true
        } else {
          this.isiot = false
        }
      }
      this.oldrow = this.row
      this.isdecimal = this.row.gasbrand.length > 0 ? this.row.gasbrand.f_isdecimal : '否'
      this.row.valid = false
      if (this.row.pricetype === '混合气价') {
        this.ratioshow = true
      }
      await this.getConcentrators()
      co(meterBookGen(this))
    },
    methods: {
      gasDateChange () {
        if (!this.row.f_scrap_date && this.row.f_gas_date) {
          if (this.row.f_use_limit) {
            let date = new Date(this.row.f_gas_date)
            let year = date.getFullYear() + (this.row.f_use_limit / 1)
            this.$set('row.f_scrap_date', year + this.row.f_gas_date.slice(4))

          }
        }
      },
      // 获取集中器下拉框
      async getConcentrators () {
        let condition = {
          items: 'id,f_mpc_alias',
          tablename: 't_concentrator',
          condition: `f_mpc_state !='删除'`,
          orderitem: 'id'
        }
        let data = await this.$resetpost('rs/sql/saleSingleTable', {data: condition}, {resolveMsg: null, rejectMsg: '获取集中器失败!'})
        this.concentrators = []
        for (let row of data.data) {
          this.concentrators.push({label: row.f_mpc_alias, value: row.id})
        }
      },
      async confirmUserfiles () {
        if (this.$refs.addparamlist.confirm()) {
          var paramlist = this.$refs.addparamlist.addGasParameter
          await this.$resetpost('rs/logic/updateGasParam', {
            data: {
              id: this.selectUserFiles.f_user_id,
              paramlist: paramlist,
              gastype: 'userfiles'
            }
          }, {resolveMsg: '更新成功', rejectMsg: '更新失败'})
          this.showParame = false
        }
      },

      priceChange (val) {
        if (val.length > 0) {
          this.row.f_user_type = [val[0].f_user_type]
          this.row.f_gasproperties = [val[0].f_gasproperties]
          this.row.pricetype = val[0].f_price_type
          // 展示气价备注
          this.$set('row.f_price_comments', val[0].f_comments ? val[0].f_comments : '无')
          // 展示价格明细
          if (val[0].detailprice) {
            // this.row.f_detailprice = this.$CommonService.getShowPriceDetail(val[0].detailprice)
            this.$set('row.f_detailprice', this.$CommonService.getShowPriceDetail(val[0].detailprice))
          }
        }
      },
      cancel () {
        this.gasid = ''
        this.userfileid = ''
        this.showParame = false
      },
      tablebaseChange () {
        if (this.isdecimal === '是') {
          this.$set('row.f_meter_base', (this.row.f_meter_base - 0).toFixed(4))
        } else {
          this.$set('row.f_meter_base', (this.row.f_meter_base - 0).toFixed(0))
        }
      },
      brandChange (val) {
        this.isdecimal = val.length > 0 ? val[0].f_isdecimal : '否'
        console.log('sadasfasf', val)
        if (val.length > 0 && val[0].f_meter_type === '物联网表') {
          this.isiot = true
        } else {
          this.isiot = false
        }
        // this.tablebaseChange()
        if (this.row.f_user_id) {
          co(brandChangeGen(this))
        }
        this.meternumberValidate()
        console.log('---------------------------------')
        console.log(this.curuser)
        console.log(this.meter)
        console.log(this.user_State)
        console.log('---------------------------------')
      },
      userTypeChange () {
        this.gasproperties = []
        if (this.row.f_user_type.length === 1) {
          this.gasproperties = this.$appdata.getParam(this.row.f_user_type[0])
        }
      },
      // getPricenames(pricetype) {
      //     console.log('气价。，。。', pricetype, this.row.f_user_type, this.row.f_gasproperties)
      //     let rs = []
      //     if (this.row.f_user_type.length === 1 && this.row.f_gasproperties.length === 1 && pricetype.length === 1) {
      //         let params = {
      //             f_user_type: this.row.f_user_type[0],
      //             f_gasproperties: this.row.f_gasproperties[0],
      //             f_price_type: pricetype[0],
      //             filter: this.f_filialeid
      //         }
      //         rs = this.$GetSaleParam.getPrice(params)
      //     }
      //     if (rs.length === 0) {
      //         this.row.f_price_name = ''
      //     }
      //     return rs
      // },
      mValid (bool) {
        this.row.valid = bool
        this.$dispatch('self-valid')
      },
      // 带权限修改单值返回修改后得值和修改原因
      modefiy (field) {
        this.show = true
        this.field = field
      },
      async meternumberValidate () {
        let http1 = new HttpResetClass()
        let res1 = await http1.load('POST', '/rs/sql/getBrandAndType', {data: {condition: ` mi.f_meternumber = '${this.row.f_meternumber}'`}}, {resolveMsg: null, rejectMsg: '获取默认气表品牌型号失败！！'})
        if (res1.data.length > 0) {
          // 替换表号自带的气表品牌和型号
          let meterbrands = this.meterbrands
          for (let row of meterbrands) {
            if (row.label == res1.data[0].f_meter_brand) {
              // 已经选择了气表品牌则不再替换
              if (this.row.gasbrand.length <= 0) this.row.gasbrand = [row.value]
              // 替换气表型号
              if (res1.data[0].f_meter_style) {
                for (let model of row.value.gasmodel) {
                  if (model.label == res1.data[0].f_meter_style) {
                    // 已经选择了气表型号则不再替换
                    if (this.row.gasmodel.length <= 0) this.row.gasmodel = [model.value]
                    continue
                  }
                }
              }
              continue
            }
          }
        }
        // 验证表号
        if (this.row.f_meternumber && this.row.gasbrand.length > 0) {
          // 表号位数验证
          let meternumberLen = this.row.gasbrand[0].f_meternumber_len
          if (meternumberLen) {
            if (this.row.f_meternumber.length != meternumberLen) {
              this.row.f_meternumber = ''
              this.$showAlert(`表号位数不正确, 当前气表品牌表号位数是: ${meternumberLen}`, 'warning', 3000)
              return
            }
          }
          // 表计信息验证
          if (this.row.gasbrand[0].f_meterverification == '是') {
            if (res1.data.length <= 0) {
              this.$showAlert(`当前表号: ${this.row.f_meternumber}在表计信息中无记录, 请核实!!!`, 'warning', 3000)
              this.row.f_meternumber = ''
              return
            }
          }
          let param = {
            f_meternumber: this.row.f_meternumber,
            f_gasbrand_id: this.row.gasbrand[0].id
          }
          if (this.row.f_userfiles_id) {
            param.f_userfiles_id = this.row.f_userfiles_id
          }
          let res = await this.$resetpost('rs/logic/meternumberValidate', param, {
            resolveMsg: null,
            rejectMsg: '表号验证失败！！'
          })
          if (this.row.gasbrand[0].f_meter_type === '物联网表') {
            if (res.data) {
              this.row.f_meternumber = ''
              this.$showAlert('表号已存在！！', 'warning', 3000)
            }
          } else {
            if (res.data) {
              this.$showAlert('请注意，相同的表号已存在', 'warning', 3000)
            }
          }
        }
      },
      openModal () {
        this.mapShow = true
      },
      closeModal () {
        this.mapShow = false;
      },
      getmylocation (res) {
        this.templng = res.position.lng
        this.templat = res.position.lat
      },
      confirmLocation () {
        this.row.f_userfiles_lat = this.templat
        this.row.f_userfiles_lng = this.templng
        this.mapShow = false;
      },
      flowmetermodels (label) {
        let gasbrand = this.$GetSaleParam.getGasbrand()
        let flowmetermodels = []
        for (let row of gasbrand) {
          if (row.label == label) {
            for (let gasmodel of row.value.gasmodel) {
              flowmetermodels.push({label: gasmodel.label, value: gasmodel.label})
            }
            break
          }
        }
        return flowmetermodels
      }
    },
    watch: {
      'meter' () {
        this.row = Object.assign(this.row, this.meter, {})
        this.isdecimal = this.row.gasbrand.f_isdecimal
        this.row.valid = false
        this.showtype = this.row.gasbrand.f_meter_type
      },
      'row.pricetype' (val) {
        if (val == '混合气价') {
          this.ratioshow = true
        } else {
          this.ratioshow = false
        }
      }
    },
    computed: {

      // 控制用户类型修改
      permissionUserType () {
        let res = false
        if (this.row.f_user_id) {
          res = !(this.jurisdiction.includes('民用气价修改') && this.jurisdiction.includes('非民用气价修改'))
        }
        return res
      },

      // 控制用气性质，气价类型，气价名称修改
      permissionPrice () {
        let res = false
        if (this.row.f_user_id) {
          console.log('获取权限、', this.row, this.jurisdiction)
          // 变更操作
          if (this.row.pricename.length > 0) {
            if (this.row.f_user_type[0] === '民用') {
              // 判断是否有民用气价权限
              res = !this.jurisdiction.includes('民用气价修改')
            } else if (this.row.f_user_type[0] === '非民用') {
              // 判断是否有非民用气价权限
              res = !this.jurisdiction.includes('非民用气价修改')
            }
          }
        }
        console.log('有无气价权限', res)
        return res
      },

      getPricenames () {
        let f_filialeid = this.f_filialeid
        let result = []
        this.$GetSaleParam.prices.forEach((item) => {
          if (item.f_state === '有效' && f_filialeid == item.f_filialeid) {
            let value = {
              label: item.f_price_name,
              value: item
            }
            result.push(value)
          }
        })
        return Array.from(new Set(result))
      },

      adjustables () {
        let arr = []
        let filter = this.f_filialeid
        this.$GetSaleParam.getAdjustable(filter).forEach((item) => {
          let temp = {}
          temp.label = `[${item.value.f_adjustable_id}]-${item.label}`
          temp.value = item.value
          arr.push(temp)
        })
        return [{label: '全部', value: ''}, ...arr]
      },
      inputtores () {
        // return this.$login.f.f_gasman
        let rs = new Array()
        for (let i = 0; i < this.$login.f.f_gasman.length; i++) {
          let temp = {
            label: this.$login.f.f_gasman[i].name,
            value: this.$login.f.f_gasman[i].name
          }
          rs.push(temp)
        }
        return rs
      },
      installperson () {
        // return this.$login.f.f_installman
        let rs = new Array()
        for (let i = 0; i < this.$login.f.f_installman.length; i++) {
          let temp = {
            label: this.$login.f.f_installman[i].name,
            value: this.$login.f.f_installman[i].name
          }
          rs.push(temp)
        }
        return rs
      },
      meterbrands () {
        return this.$GetSaleParam.getGasbrand()
      },
      aroundmeters () {
        return this.$appdata.getParam('左右表')
      },
      positions () {
        return this.$appdata.getParam('安装位置')
      },
      usetype () {
        return this.$appdata.getParam('使用类型')
      },
      usestate () {
        return this.$appdata.getParam('使用状态')
      },
      gongyetype () {
        return this.$appdata.getParam('工业备注')
      },
      flowmeterbrands () {
        let gasbrand = this.$GetSaleParam.getGasbrand()
        let flowmeterbrands = []
        for (let row of gasbrand) {
          flowmeterbrands.push({label: row.label, value: row.label})
        }
        return flowmeterbrands
      }
    }
  }
</script>
<style lang="less">
  #meterInfoTest{
    #addboxmap {
      height: 300px;
    }
    .glyphicon-map-marker:hover {
      color: red;
    }
    .glyphicon-map-marker {
      color: blue;
      cursor: pointer;
    }
    .col-sm-4 {
      .font_normal_body {
        width: 73px;
        overflow: auto;
        white-space: nowrap;
        // 指滚动条两边的按钮
        &::-webkit-scrollbar-button {
          display: none;
        }
        // 滚动条的宽度
        &::-webkit-scrollbar {
          width: 5px !important;
          height: 5px !important;
        }
        // 滚动条的设置
        &::-webkit-scrollbar-thumb {
          background-color: #ddd;
          background-clip: padding-box;
        }
        &::-webkit-scrollbar-thumb:hover {
          background-color: #bbb;
        }
        &::-webkit-scrollbar-track {
          /*滚动条里面轨道*/
          box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
          background: #ededed;
        }
      }
    }
  }
</style>
