<template>
  <div class="auto">
    <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">-->
<!--            <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_llj_brand" class="font_normal_body">流量计品牌</label>-->
<!--            <input type="text" class="input_search" style="width:60%" v-model="row.f_llj_brand" placeholder='流量计品牌'-->
<!--                   v-next-el="{id: 'meterbase'}">-->
<!--          </div>-->
          <div class="col-sm-4 form-group" >
            <label for="f_llj_brand" class="font_normal_body"  title="参数:流量计品牌">&ensp;流量计品牌</label>
            <v-select :value.sync="row.f_llj_brand" v-model="row.f_llj_brand"
                      :options='lljbrand' placeholder='流量计品牌' :value-single="true"
                      close-on-select></v-select>
          </div>
          <div class="col-sm-4 form-group" >
            <label for="f_llj_type" class="font_normal_body"  title="参数:流量计类型">&ensp;流量计类型</label>
            <v-select :value.sync="row.f_llj_type" v-model="row.f_llj_type"
                      :options='lljtype' placeholder='流量计类型' :value-single="true"
                      close-on-select></v-select>
          </div>
          <div class="col-sm-4 form-group" >
            <label for="f_meter_flow" class="font_normal_body"  title="参数:气表流量">&ensp;气表流量</label>
            <v-select :value.sync="row.f_meter_flow" v-model="row.f_meter_flow"
                      :options='meterflow' placeholder='气表流量' :value-single="true"
                      close-on-select></v-select>
          </div>
          <div class="col-sm-4 form-group">
            <label for="f_llj_model" class="font_normal_body">流量计型号</label>
            <input type="text" class="input_search" style="width:60%" v-model="row.f_llj_model" placeholder='流量计型号'
                   v-next-el="{id: 'meterbase'}">
          </div>
          <div class="col-sm-4 form-group">
            <label for="f_llj_date" class="font_normal_body">流量计出厂</label>
            <datepicker style="width:60%" placeholder="流量计出厂日期"
                        v-model="row.f_llj_date"
                        :value.sync="row.f_llj_date"
                        :format="'yyyy-MM-dd HH:mm:ss'"
            ></datepicker>
          </div>
          <div class="col-sm-4 form-group" >
            <label for="f_bqf_type" class="font_normal_body">表前阀型号</label>
            <v-select
                      :value.sync="row.f_bqf_type"
                      v-model="row.f_bqf_type"
                      width="60%"
                      search="true"
                      enterPush="true"  :value-single="true"
                      :options="bqftype"
                      placeholder="表前阀型号"
                      close-on-select></v-select>
          </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' 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"
               :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 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">&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">
            <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_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">
            <label for="f_gas_date" class="font_normal_body">&ensp;通气日期</label>
            <datepicker style="width:60%" placeholder="通气日期"
                        v-model="row.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" >
            <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="false">
            <label for="f_remanent_gas" class="font_normal_body">剩余气量</label>
            <input type="number" class="input_search" style="width:60%" 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" 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="[$m.dateyy.required ? 'has-error' : 'has-success']" class="col-sm-4 form-group" >
            <input class="input_search" style="width:60%" type="text" v-model="$refs.dateyy.value" v-show="false"
                   v-validate:dateyy='{required: true }'>
            <label class="font_normal_body" for="f_subscribe_date" style="padding-right:4%;margin-left: 6px;">预约时间</label>
            <datepicker :disabled='isEdit'
                        :value.sync="row.f_subscribe_date"
                        id="f_perform_date"
                        placeholder="预约通气时间"
                        :format="'yyyy-MM-dd HH:mm:ss'"
                        v-ref:dateyy
                        style="width: 60%" v-model="row.f_subscribe_date">
            </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"
                      :value-single="true"
                      :options='meterbookoptions' placeholder='抄表册'
                      close-on-select></v-select>
          </div>
          <div class="col-sm-4 form-group" v-show="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"
                        :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%" 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_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;阀门状态</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">-->
<!--            <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" v-show="row.f_gasproperties=='工业用气'">
            <label for="f_gongye_type" class="font_normal_body">&emsp;用气类型</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_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 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 style="" class="col-sm-8 form-group">
            <label for="f_userfiles_address" class="font_normal_body ">&nbsp;用气点名</label>
            <input class="input_search" style="width:80%" v-model="row.f_userfiles_address"/>
          </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%" style="width:60%" v-model="row.f_limit_sms"-->
<!--                   placeholder='短信限定'></input>-->
<!--          </div>-->
          <div style="" class="col-sm-8 form-group">
            <label for="f_comments" class="font_normal_body ">&nbsp;&nbsp;&nbsp;备&nbsp;&nbsp;&nbsp;注&nbsp;</label>
            <input class="input_search" style="width:80%" v-model="row.f_comments"/>
          </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
  }
    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
    }
  }
  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,
        lljbrand: this.$appdata.getParam('流量计品牌'),
        lljtype: this.$appdata.getParam('流量计类型'),
        meterflow: this.$appdata.getParam('气表流量'),
        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('用户类型'),
        gasproperties: this.meter.f_user_type.length === 1 ? this.$appdata.getParam(this.meter.f_user_type[0]) : [],
        pricetypes: this.$appdata.getParam('气价类型'),
        meterbookoptions: [],  // 抄表册选项
        opteratormetrbook: false, // 抄表册操作
        oldrow: []
      }
    },
    props: ['f_filialeid', 'meter', 'isdecimal', 'valid', 'f_userinfo_id'],
    ready () {
      console.log('看看meter里面的数据', this.meter, this.row)
      this.row = 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))
    },
    methods: {
      toggleDropdown() {
        this.width = this.$els.group.clientWidth *  this.width +'px'
        this.show = !this.show
      },
      bqfTypeChange () {
        console.log('bqfTypeChange')
      },
      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
          // 展示价格明细
          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
        }
      }

    },
    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 () {
        return this.$GetSaleParam.getPriceByOrg(this.f_filialeid)
      },

      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('安装位置')
      // },
      bqftype(){
        return this.$appdata.getParam('表前阀型号')
      },
      usetype () {
        return this.$appdata.getParam('使用类型')
      },
      usestate () {
        return this.$appdata.getParam('使用状态')
      },
      gongyetype () {
        return this.$appdata.getParam('工业用户用气类型')
      }
    }
  }
</script>
