<template>
  <div class="auto" id="meterInfoTest_New">
    <validator name='m' @valid="mValid(true)" @invalid="mValid(false)">
      <form class="form-horizontal select-overspread ">
        <div class="row">
          <div class="col-sm-4 form-group" :class="[$m.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-next-el="{id: 'metertitles'}">
          </div>
          <div class="col-sm-4 form-group" :class="[$m.f_metertitles.required ? 'has-error' : '']"
               v-show="(formconfig && formconfig.f_metertitles && formconfig.f_metertitles.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_metertitles')">
            <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" :class="[$m.f_defendcard.required ? 'has-error' : '']"
               v-show="(formconfig && formconfig.f_defendcard && formconfig.f_defendcard.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_defendcard',false)">
            <label class="font_normal_body">防盗卡号1</label>
            <input type="text" class="input_search" style="width:60%" v-model="row.f_defendcard"
                   v-validate:f_defendcard=getConfigValidate('f_defendcard',false)
                   :value.sync="row.f_defendcard"
                   placeholder='防盗卡号1' >
          </div>
          <div class="col-sm-4 form-group" :class="[$m.f_defendcard_two.required ? 'has-error' : '']"
               v-show="(formconfig && formconfig.f_defendcard_two && formconfig.f_defendcard_two.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_defendcard_two',false)">
            <label class="font_normal_body">防盗卡号2</label>
            <input type="text" class="input_search" style="width:60%" v-model="row.f_defendcard_two"
                   v-validate:f_defendcard_two=getConfigValidate('f_defendcard_two',false)
                   :value.sync="row.f_defendcard_two"
                   placeholder='防盗卡号2' >
          </div>
          <div class="col-sm-4 form-group" v-if="getConfigShowItem('f_meter_base')"
               v-show="(formconfig && formconfig.f_meter_base && formconfig.f_meter_base.required) || !onlyshowmust">
            <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" title="涉及权限:【档案信息查询修改】" v-if="getConfigShowItem('f_initial_base')"
               v-show="(formconfig && formconfig.f_initial_base && formconfig.f_initial_base.required) || !onlyshowmust">
            <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' 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 ' v-ref:model></v-select>
          </div>
          <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" v-if="showindustry">-->
            <!--<label for="f_username" class="font_normal_body" title="参数:工业备注" >&ensp;工业备注</label>-->
            <!--<input type="text" v-show="false" v-model="$refs.f_industry_comments.selectedItems" >-->
            <!--<v-select :value.sync="row.f_industry_comments"-->
                      <!--v-ref:f_industry_comments-->
                      <!--:options='industrycomments' placeholder='工业备注'-->
                      <!--v-model='row.f_industry_comments'-->
                      <!--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" 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'
                      style="width:60%"
                      :options='gongyetype' placeholder='工业备注'
                      close-on-select
                      v-el:cc></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 class="col-sm-4 form-group" title="涉及权限:【档案信息查询修改】" v-if="getConfigShowItem('f_total_gas')"
               v-show="(formconfig && formconfig.f_total_gas && formconfig.f_total_gas.required) || !onlyshowmust">
            <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" title="涉及权限:【档案信息查询修改】" v-if="getConfigShowItem('f_total_fee')"
               v-show="(formconfig && formconfig.f_total_fee && formconfig.f_total_fee.required) || !onlyshowmust">
            <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="row">-->
        <!--<div class="col-sm-12" style="margin-top: -10px">-->
        <!--<label for="f_userfiles_address" class="font_normal_body">安装地址</label>-->
        <!--<input type="text" class="input_search" style="width:60%" v-model="row.f_userfiles_address" placeholder='安装地址'>-->
        <!--</div>-->
        <!--</div>-->

          <div class="col-sm-4 form-group"
               :class="[$m.f_aroundmeter.required ? 'has-error' : '']"
               v-show="(formconfig && formconfig.f_aroundmeter && formconfig.f_aroundmeter.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_aroundmeter')">
            <input type="text" v-show="false" v-model="row.f_aroundmeter"
                   v-validate:f_aroundmeter="getConfigValidate('f_aroundmeter',false)">
            <label for="gasmodel" class="font_normal_body w2" style="width: auto;letter-spacing: 2em;margin-right: -2em;margin-left: -2em;">&ensp;{{getConfigLabelName('f_aroundmeter','表向')}}</label>
            <v-select :value.sync="row.f_aroundmeter" :options='aroundmeters'
                      :placeholder="getConfigPlaceholder('f_aroundmeter','表向')"
                      close-on-select
                      v-model='row.f_aroundmeter'></v-select>
          </div>
          <div class="col-sm-4 form-group" :class="[$m.f_gas_person.required ? 'has-error' : '']"
               v-show="(formconfig && formconfig.f_gas_person && formconfig.f_gas_person.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_gas_person')">
            <label for="f_gas_person" style="width: auto;letter-spacing: 0.5em;margin-right: -0.5em;margin-left: -0.5em"
                   class="font_normal_body">&ensp;{{getConfigLabelName('f_gas_person','通气人')}}</label>
            <input type="text" class="input_search" style="width:60%" v-model="row.f_gas_person"
                   v-validate:f_gas_person="getConfigValidate('f_gas_person',false)"
                   placeholder='通气人'>
          </div>
          <div class="col-sm-4 form-group" :class="[$m.f_gas_date.required ? 'has-error' : '']"
               v-show="(formconfig && formconfig.f_gas_date && formconfig.f_gas_date.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_gas_date')">
            <input type="text" v-model="$refs.f_gas_date.value" v-show="false"
                   v-validate:f_gas_date="getConfigValidate('f_gas_date',false)">
            <label for="f_gas_date" class="font_normal_body">&ensp;{{getConfigLabelName('f_gas_date','通气日期')}}</label>
            <datepicker style="width:60%" placeholder="通气日期"
                        v-model="row.f_gas_date"
                        v-ref:f_gas_date
                        :value.sync="row.f_gas_date"
                        :format="'yyyy-MM-dd HH:mm:ss'"
            ></datepicker>
          </div>

          <div class="col-sm-4 form-group" :class="[$m.f_position.required ? 'has-error' : '']"
               v-show="(formconfig && formconfig.f_position && formconfig.f_position.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_gas_date')">
            <label for="f_position" class="font_normal_body"  title="参数:安装位置">&ensp;{{getConfigLabelName('f_position','安装位置')}}</label>
            <input type="text" v-model="row.f_position" v-show="false"
                   v-validate:f_position="getConfigValidate('f_position',false)">
            <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="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">
            <!--<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" :class="[$m.f_install_person.required ? 'has-error' : '']"
               v-show="(formconfig && formconfig.f_install_person && formconfig.f_install_person.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_install_person')">
            <label for="f_install_person" class="font_normal_body" style="width: auto;letter-spacing: 0.5em;margin-right: -0.5em;margin-left: -0.5em">&ensp;{{getConfigLabelName('f_install_person','安装人')}}</label>
            <input type="text" v-model="row.f_install_person" v-show="false"
                   v-validate:f_install_person="getConfigValidate('f_install_person',false)">
            <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" :class="[$m.f_subscribe_date.required ? 'has-error' : '']"
               v-show="(formconfig && formconfig.f_subscribe_date && formconfig.f_subscribe_date.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_subscribe_date')">
            <label for="f_subscribe_date" class="font_normal_body">&ensp;{{getConfigLabelName('f_subscribe_date','预约时间')}}</label>
            <input type="text" v-model="row.f_subscribe_date" v-show="false"
                   v-validate:f_subscribe_date="getConfigValidate('f_subscribe_date',false)">
            <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 && ((formconfig && formconfig.f_meter_book_num && formconfig.f_meter_book_num.required) || !onlyshowmust)" :class="[$m.f_meter_book_num.required ? 'has-error' : '']"
               v-if="getConfigShowItem('f_meter_book_num')">
            <label for="f_position" class="font_normal_body" style="width: auto;letter-spacing: 0.5em;margin-right: -0.5em;margin-left: -0.5em">&ensp;{{getConfigLabelName('f_meter_book_num','抄表册')}}</label>
            <input type="text" v-model="row.f_meter_book_num" v-show="false"
                   v-validate:f_meter_book_num="getConfigValidate('f_meter_book_num',false)">
            <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" :class="[$m.f_install_date.required ? 'has-error' : '']"
               v-show="(formconfig && formconfig.f_install_date && formconfig.f_install_date.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_install_date')">
            <input type="text" v-model="row.f_install_date" v-show="false"
                   v-validate:f_install_date="getConfigValidate('f_install_date',false)">
            <label for="f_install_date" class="font_normal_body">&ensp;{{getConfigLabelName('f_install_date','安装日期')}}</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" :class="[$m.f_adjustable.required ? 'has-error' : '']"
               v-show="(formconfig && formconfig.f_adjustable && formconfig.f_adjustable.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_adjustable')">
            <label for="f_adjustable" class="font_normal_body" style="width: auto;letter-spacing: 0.5em;margin-right: -0.5em;margin-left: -0.5em">&ensp;{{getConfigLabelName('f_adjustable','调压箱')}}</label>
            <input type="text" v-model="row.f_adjustable" v-show="false"
                   v-validate:f_adjustable="getConfigValidate('f_adjustable',false)">
            <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" :class="[$m.f_hand_date.required ? 'has-error' : '']"
               v-show="(formconfig && formconfig.f_hand_date && formconfig.f_hand_date.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_hand_date')">
            <label for="f_hand_date" class="font_normal_body">&ensp;{{getConfigLabelName('f_hand_date','上次抄表')}}</label>
            <input type="text" v-model="row.f_hand_date" v-show="false"
                   v-validate:f_hand_date="getConfigValidate('f_hand_date',false)">
            <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 class="col-sm-4 form-group" :class="[$m.f_price_ratio.required ? 'has-error' : '']"
               v-show="(formconfig && formconfig.f_price_ratio && formconfig.f_price_ratio.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_price_ratio')">
            <label for="f_ratio" class="font_normal_body" style="width: auto;letter-spacing: 2em;margin-right: -2em;margin-left: -2em">&ensp;{{getConfigLabelName('f_price_ratio','比率')}}</label>
            <input type="number" class="input_search" style="width:60%"  v-model="row.f_price_ratio"
                   :value.sync="row.f_price_ratio"
                   v-validate:f_price_ratio=getConfigValidate('f_price_ratio',false)
                   placeholder='比率'>
          </div>
          <div class="col-sm-4 form-group" :class="[$m.f_scrap_date.required ? 'has-error' : '']"
               v-show="(formconfig && formconfig.f_scrap_date && formconfig.f_scrap_date.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_scrap_date')">
            <label for="f_scrap_date" class="font_normal_body">&ensp;{{getConfigLabelName('f_scrap_date','报废日期')}}</label>
            <input type="text" v-model="row.f_scrap_date" v-show="false"
                   v-validate:f_scrap_date="getConfigValidate('f_scrap_date',false)">
            <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" v-show="row.f_meter_classify == '物联网表' && (formconfig && formconfig.f_valve_state.required || !onlyshowmust)" v-if="getConfigShowItem('f_valve_state')">
            <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.f_garbage_fee.required ? 'has-error' : '']"
               v-show="(formconfig && formconfig.f_garbage_fee && formconfig.f_garbage_fee.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_garbage_fee')">
            <label for="gasmodel" class="font_normal_body" style="width: auto;letter-spacing: 0.5em;margin-right: -0.5em;margin-left: -0.5em">&ensp;{{getConfigLabelName('f_garbage_fee','垃圾费')}}</label>
            <input type="text" v-model="row.f_garbage_fee" v-show="false"
                   v-validate:f_garbage_fee="getConfigValidate('f_garbage_fee',false)">
            <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" :class="[$m.f_inputtor.required ? 'has-error' : '']"
               v-show="(formconfig && formconfig.f_inputtor && formconfig.f_inputtor.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_inputtor')">
            <label class="font_normal_body" style="width: auto;letter-spacing: 0.5em;margin-right: -0.5em;margin-left: -0.5em">&ensp;{{getConfigLabelName('f_inputtor','抄表员')}}</label>
            <input type="text" v-model="row.f_inputtor" v-show="false"
                   v-validate:f_inputtor="getConfigValidate('f_inputtor',false)">
            <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" :class="[$m.f_usetype.required ? 'has-error' : '']"
               v-show="(formconfig && formconfig.f_usetype && formconfig.f_usetype.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_usetype')">
            <label for="f_usetype" class="font_normal_body" title="参数:使用类型">&ensp;{{getConfigLabelName('f_usetype','使用类型')}}</label>
            <input type="text" v-model="row.f_usetype" v-show="false"
                   v-validate:f_usetype="getConfigValidate('f_usetype',false)">
            <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" :class="[$m.f_usetype.required ? 'has-error' : '']"
               v-show="(formconfig && formconfig.f_usestate && formconfig.f_usestate.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_usestate')">
            <label for="f_position" class="font_normal_body" title="参数:使用状态">&ensp;{{getConfigLabelName('f_usestate','使用状态')}}</label>
            <input type="text" v-model="row.f_usestate" v-show="false"
                   v-validate:f_usestate="getConfigValidate('f_usestate',false)">
            <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-8 form-group" :class="[$m.f_userfiles_address.required ? 'has-error' : '']"
               v-show="(formconfig && formconfig.f_userfiles_address && formconfig.f_userfiles_address.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_userfiles_address')">
            <label for="f_userfiles_address"
                   class="font_normal_body">&ensp;{{getConfigLabelName('f_userfiles_address','安装地址')}}</label>
            <input type="text" class="input_search" style="width:80%" v-model="row.f_userfiles_address"
                   v-validate:f_userfiles_address="getConfigValidate('f_userfiles_address',false)"
                   placeholder='安装地址'>
          </div>
          <div  class="col-sm-4 form-group" :class="[$m.f_alarm_code.required ? 'has-error' : '']"
                v-show="(formconfig && formconfig.f_alarm_code && formconfig.f_alarm_code.required) || !onlyshowmust"
                v-if="getConfigShowItem('f_alarm_code')">
            <label for="f_alarm_code"
                   class="font_normal_body">&ensp;{{getConfigLabelName('f_alarm_code','报警器编码')}}</label>
            <input type="text" class="input_search" style="width:60%" v-model="row.f_alarm_code"
                   v-validate:f_alarm_code="getConfigValidate('f_alarm_code',false)"
                   placeholder='报警器编码'>
          </div>
          <div class="col-sm-4 form-group" :class="[$m.f_force_measure.required ? 'has-error' : '']"
               v-show="(formconfig && formconfig.f_force_measure && formconfig.f_force_measure.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_force_measure',false)">
            <label class="font_normal_body">{{getConfigLabelName('f_force_measure','三项强制措施')}}</label>
            <input type="text" v-model="$refs.measure.selectedItems" v-show="false"
                   v-validate:f_force_measure="getConfigValidate('f_force_measure',false)">
            <v-select :value.sync="row.f_force_measure" v-model="row.f_force_measure"
                      :options='forceMeasure' placeholder='三项强制措施' :multiple="true"
                      v-ref:measure>
            </v-select>
          </div>
        </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>
  </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
    }
    if (!self.f_filialeid) {
      self.f_filialeid = self.$login.f.orgid
    }
    let temp = {
      tablename: 't_meter_book',
      condition: `f_book_state='有效' and f_filiale_id='${self.f_filialeid}'`
    }
    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
    }
  }
  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.$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 {
        viewsee: false,
        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('左右表'),
        forceMeasure: this.$appdata.getParam('三项强制措施'),
        garbagefee: this.$appdata.getParam('垃圾费'),
        valvestate: this.$appdata.getParam('阀门状态'),
        usertypes: this.$appdata.getParam('用户类型'),
        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('气价类型'),
        meterbookoptions: [],  // 抄表册选项
        opteratormetrbook: false, // 抄表册操作
        showindustry: false, // 是否显示工业备注
        industrycomments: this.$appdata.getParam('工业备注'),
        oldrow: []
      }
    },
    props: ['f_filialeid', 'meter', 'isdecimal', 'valid', 'f_userinfo_id', 'formconfig', 'onlyshowmust'],
    async ready () {
      console.log('看看meter里面的数据', this.meter, this.row)
      this.row = await Object.assign(this.row, this.meter, {})

      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
      }
      co(meterBookGen(this))
      this.$nextTick(() => {
        console.log('this.row', this.row)
        console.log('this.row.f_force_measure', this.row.f_force_measure)
        if (this.row) {
          if (this.row.f_force_measure !== undefined && Object.prototype.toString.call(this.row.f_force_measure) === '[object Array]') {
            if (this.row.f_force_measure[0]) {
              this.row.f_force_measure = this.row.f_force_measure[0].split(',')
            }
          }
        }
      })
    },
    methods: {
      getConfigValidate (name, defaultVal) {
        this.$resetValidation()
        if (this.formconfig && this.formconfig[name]) {
          let Validate = {}
          if (this.formconfig[name].required) {
            Object.assign(Validate, {required: true})
          }
          if (this.formconfig[name].minlength || this.formconfig[name].minlength === 0) {
            Object.assign(Validate, {minlength: this.formconfig[name].minlength})
          }
          if (this.formconfig[name].maxlength) {
            Object.assign(Validate, {maxlength: this.formconfig[name].maxlength})
          }
          return Validate
        } else if (name === 'f_user_phone') {
          return { minlength: 11, maxlength: 11 }
        } else if (defaultVal) {
          return {required: defaultVal}
        }
        return {}
      },
      getConfigShowItem (name,defaultVal = true) {
        if (this.formconfig && this.formconfig[name] && this.formconfig[name].hasOwnProperty('showItem')) {
          return this.formconfig[name].showItem
        } else {
          return defaultVal
        }
      },
      getConfigLabelName (name, defaultVal) {
        if (this.formconfig && this.formconfig[name] && this.formconfig[name].labelName) {
          return this.formconfig[name].labelName
        } else {
          return defaultVal
        }
      },
      getConfigPlaceholder (name, defaultVal) {
        if (this.formconfig && this.formconfig[name] && this.formconfig[name].placeholder) {
          return this.formconfig[name].placeholder
        } else {
          return defaultVal
        }
      },
      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 : '否'
        // this.tablebaseChange()
        if (this.row.f_user_id) {
          co(brandChangeGen(this))
        }
        this.meternumberValidate()
      },
      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 () {
        // 验证表号
        if (this.row.f_meternumber && this.row.gasbrand.length > 0) {
          if (this.row.gasbrand[0].f_meter_type === '物联网表') {
            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: '表号验证失败！！'
            })
            console.log('标号验证返回：', res)
            if (res.data) {
              this.row.f_meternumber = ''
              this.$showAlert('表号已存在！！', 'warning', 3000)
            }
          }
        }
      }
    },
    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
        }
      },
      'row.f_user_type' (val) {
        if (val && val.length === 1) {
          if (val[0] === '非民用') {
            this.showindustry = true
          } else {
            this.showindustry = false
            this.row.f_industry_comments = ''
          }
        } else {
          this.showindustry = false
          this.row.f_industry_comments = ''
        }
      }

    },
    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('工业备注')
      }
    }
  }
</script>
<style lang="less">
#meterInfoTest_New{
// 去掉number类型输入框的上下箭头
  input[type="number"] {
    &::-webkit-inner-spin-button,
    &::-webkit-outer-spin-button {
      -webkit-appearance: none;
      margin: 0;
    }

    & {
      -moz-appearance: textfield;
    }
  }
  #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>
