<template>
  <div id="unit" class="flex-row">
    <validator name='m'>
    <div class="basic-main" style="margin-left: 1%;" >

          <criteria-paged :model="model" v-ref:paged  @sort="sort" >
            <criteria partial='criteria' v-ref:criteria @condition-changed="$parent.selfSearch">
              <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
                <div class="row">
                  <div class="form-group col-sm-3">
                    <label class="font_normal_body">组织机构</label>
                    <res-select
                      @res-select="$parent.$parent.getorg"
                      :initresid='$parent.$parent.curorgid'
                      class="select select_list"
                      restype='organization'
                      style="width: 60%"
                    >
                    </res-select>
                  </div>
                  <div class="form-group col-sm-2">
                    <label class="font_normal_body">客户编号</label>
                    <input type="text" class="input_search" style="width:60%" v-model="model.f_userinfo_code"
                           @keyup.enter="search()"  condition="f_userinfo_code = '{}'" placeholder='客户编号'>
                  </div>
                  <div class="form-group col-sm-2">
                    <label class="font_normal_body">客户名称</label>
                    <input type="text" class="input_search" style="width:60%" v-model="model.f_user_name"
                           @keyup.enter="search()"  condition="f_user_name like '%{}%'" placeholder='客户姓名'>
                  </div>

                  <div style="float:right">
                    <button class="button_search" @click="search(), $parent.$parent.clean()">查询</button>
                    <button class="button_clear" @click="$parent.$parent.clear()">清空</button>
                    <div style="float: right"  class="button_spacing" :class="{'button_shrink_top':$parent.$parent.criteriaShow,'button_shrink_bottom':!$parent.$parent.criteriaShow}"    @click="$parent.$parent.hidden()"></div>
                  </div>
                </div>
                <div class="row" v-if="$parent.$parent.criteriaShow">
                  <div class="form-group col-sm-2" >
                    <label class="font_normal_body">旧客户号</label>
                    <input type="text" class="input_search" style="width:60%" v-model="model.f_olduserinfo_code" placeholder='客户编号'
                           condition="f_olduserinfo_code = '{}'">
                  </div>
                  <div class="form-group col-sm-2">
                    <label class="font_normal_body">表&emsp;&emsp;号</label>
                    <input type="text" class="input_search" style="width:60%" v-model="model.f_meternumber" placeholder='表号'
                           condition="f_meternumber = '{}'">
                  </div>
                  <div class="form-group col-sm-2">
                    <label class="font_normal_body">卡&emsp;&emsp;号</label>
                    <input type="text" class="input_search" style="width:60%" v-model="model.f_card_id" placeholder='卡号'
                           condition="f_card_id = '{}'">
                  </div>
                  <div class="form-group col-sm-2">
                    <label class="font_normal_body">用气性质</label>
                    <v-select :value.sync="model.f_gasproperties" v-model="model.f_gasproperties"
                              multiple="true"
                              :options='$parent.$parent.gasproperties2' placeholder='用气性质'
                              condition="f_gasproperties in {}"></v-select>
                  </div>
                  <div class="form-group col-sm-2">
                    <label class="font_normal_body">客户电话</label>
                    <input type="text" class="input_search" style="width:60%" v-model="model.f_user_phone" placeholder='客户电话'
                           condition="f_user_phone = '{}'">
                  </div>
                  <div class="form-group col-sm-2">
                    <label class="font_normal_body">客户地址</label>
                    <input type="text" class="input_search" style="width:60%" v-model="model.f_address"
                           condition="f_address like '%{}%'" placeholder='客户地址'>
                  </div>
                </div>
              </div>
            </criteria>
            <data-grid :model="model" class="list_area table_sy" v-ref:grid partial='list'>
              <template partial='head'>
                <tr>
                  <th>
                    <nobr>序号</nobr>
                  </th>
                  <th>
                    <nobr>客户编号</nobr>
                  </th>
                  <th>
                    <nobr>客户信息</nobr>
                  </th>
                  <th>
                    <nobr>表号</nobr>
                  </th>
                  <th>
                    <nobr>卡号</nobr>
                  </th>
                  <th>
                    <nobr>客户地址</nobr>
                  </th>
                  <th>
                    <nobr>气价名称</nobr>
                  </th>
                  <th>
                    <nobr>表具信息</nobr>
                  </th>
                  <th>
                    <nobr>状态</nobr>
                  </th>
                  <th>
                    <nobr>操作</nobr>
                  </th>
                  <th>
                    <nobr>历史操作</nobr>
                  </th>
                </tr>
              </template>
              <template partial='body'>
                <td style="text-align: center;">{{$index + 1}}</td>
                <td style="text-align: center;white-space: nowrap;">{{row.f_userinfo_code}}</td>
                <td style="text-align: center;white-space: nowrap;">{{row.f_user_name}}</td>
                <td style="text-align: center;white-space: nowrap;">{{row.f_meternumber}}</td>
                <td style="text-align: center;white-space: nowrap;">{{row.f_card_id}}</td>
                <td style="text-align: center;white-space: nowrap;">{{row.f_address}}</td>
                <td style="text-align: center;white-space: nowrap;">{{row.f_price_name}}</td>
                <td style="text-align: center;white-space: nowrap;">{{row.f_meter_brand}}</td>
                <td style="text-align: center;white-space: nowrap;">{{row.f_user_state}}</td>
                <td style="text-align: center;white-space: nowrap;">
                  <button  type="button" name="button" class="button_search button_spacing width-60" v-if="row.f_user_state === '正常'"
                          @click.stop="$parent.$parent.$parent.priceshow(row)">调价
                  </button>
                </td>
                <td style="text-align: center;white-space: nowrap;">
                  <button type="button" name="button" class="button_search button_spacing width-60" v-if="row.f_user_state === '正常'"
                          @click.stop="$parent.$parent.$parent.lookOver(row)">查看
                  </button>
                </td>
              </template>
            </data-grid>
          </criteria-paged>
        </div>

    <modal :show.sync="show" width="50%" backdrop="false" style="overflow: scroll;">

      <header slot="modal-header" class="modal-header">
        <h4 class="modal-title" style="text-align: center;">气价调整</h4>
      </header>
      <article slot="modal-body" class="modal-body">
        <div class="panel panel-primary datapanel">
          <form class="form-horizontal">
            <div class="form-group">
              <div class="row">
                <div class="col-sm-4 flex-row ">
                  <label class="control-label">客户编号</label>
                  <p class="form-control-static">{{row.f_userinfo_code}}</p>
                </div>
                  <div class="col-sm-4 flex-row ">
                <label class="control-label">客户名称</label>
                <p class="form-control-static">{{row.f_user_name}}</p>
                  </div>
                  <div class="col-sm-4 flex-row ">
                <label class="control-label">客户电话</label>
                <p class="form-control-static">{{row.f_user_phone}}</p>
                 </div>
              </div>
              <div class="row">
                <div class="col-sm-12 flex-row ">
                  <label class="control-label">客户地址</label>
                  <p class="form-control-static">{{row.f_address}}</p>
                </div>
              </div>
            </div>
          </form>

        </div>

        <div class="panel panel-primary datapanel">
          <form class="form-horizontal select-overspread">
            <div class="form-group">
              <div class="row bg-info text-center text-center" style="height:35px">
                <div style="float: left">
                  <label class="font_normal_body">旧气价信息</label>
                </div>
              </div>
              <div class="row" style="margin-top: 2%">
                <div class="col-sm-3 flex-row ">
                  <label class="control-label">客户类型</label>
                  <p class="form-control-static">{{row.f_user_type}}</p>
                </div>
                <div class="col-sm-3 flex-row ">
                  <label class="control-label">用气性质</label>
                  <p class="form-control-static">{{row.f_gasproperties}}</p>
                </div>
                <div class="col-sm-3 flex-row ">
                  <label class="control-label">气价类型</label>
                  <p class="form-control-static">{{row.f_price_type}}</p>
                </div>
                <div class="col-sm-3 flex-row ">
                  <label class="control-label">气价名称</label>
                  <p class="form-control-static">{{row.f_price_name}}</p>
                </div>
            </div>

              <div class="row bg-info text-center text-center" style="height:35px">
                <div style="float: left">
                  <label class="font_normal_body">新气价信息</label>
                </div>
              </div>

              <div class="row" style="margin-top: 2%">
                <label class="radio-inline col-sm-3">
                  <input type="radio" value="系统气价" v-model="model.type" class="magic-radio" checked id="type_two">
                  <label for="type_two">系统气价</label>
                  <!-- <strong>IC卡丢失或损坏</strong> -->
                </label>
                <label class="radio-inline col-sm-4">
                  <input type="radio" value="自定义气价" v-model="model.type" class="magic-radio" id="type_three">
                  <label for="type_three">自定义气价</label>
                  <!-- <strong>IC卡信息错乱</strong> -->
                </label>
              </div>
              <div class="row" style="margin-top: 2%" v-if="model.type ==='自定义气价'">

                <div :class="[$m.f_price_type.required ? 'has-error' : '']" class="col-sm-4 form-group">
                  <input class="input_search" style="width:60%" type="text" v-model="newinfo.f_price_type" v-show="false"
                         v-validate:f_price_type='{required: true }'>
                  <label title="参数:气价类型" class="font_normal_body" for="f_price_type">气价类型</label>
                  <v-select :disabled='isEdit'
                            :options='pricetype'
                            :value-single="true"
                            :value.sync="newinfo.f_price_type"
                            close-on-select
                            id="f_price_type"
                            placeholder='请选择'
                            v-model="newinfo.f_price_type">
                  </v-select>
                </div>
                  <div  class="col-sm-4" :class="[$m.f_price_name.required ? 'has-error' : 'has-success']">
                      <label for="f_price_name" class="font_normal_body">气价名称</label>
                      <input style="width:60%" class="input_search" type="text" v-model="newinfo.f_price_name"
                             v-validate:f_price_name='{required: true }'  placeholder="气价名称">
                  </div>
                <div :class="[$m.f_stairmonths.required || $v.f_stairmonths.dctest ? 'has-error' : 'has-success']" class="col-sm-4 form-group"v-if="newinfo.f_price_type ==='阶梯气价'">
                  <label class="font_normal_body" for="f_stairmonths">阶段月数</label>
                  <input class="input_search" style="width:60%" type="number"
                         v-model="newinfo.f_stairmonths" v-validate:f_stairmonths='{required: true, dctest: [ 12, "<=" ] }'>
                </div>
                <div  :class="[$m.f_stair_start_date.required ? 'has-error' : 'has-success']" class="col-sm-4 form-group" v-if="newinfo.f_price_type ==='阶梯气价'">
                <input class="input_search" style="width:60%" type="text" v-model="newinfo.f_stair_start_date" v-show="false"
                       v-validate:f_stair_start_date='{required: true }'>
                <label class="font_normal_body"  for="f_stair_start_date">开始日期</label>
                <datepicker :format="'yyyy-MM-dd'"
                            :value.sync="newinfo.f_stair_start_date"
                            class="datepicker"
                            id="f_stair_start_date"
                            placeholder="阶梯开始日期"
                            style="width: 60%"
                            v-model="newinfo.f_stair_start_date">
                </datepicker>
              </div>

                <div  class="col-sm-4" :class="[$m.f_price.required ? 'has-error' : 'has-success']" v-if="newinfo.f_price_type ==='固定气价'">
                  <label for="f_price" class="font_normal_body">&nbsp;&nbsp;&nbsp;单价&nbsp;&nbsp;&nbsp;</label>
                  <input style="width:60%" class="input_search" type="number" v-model="detailprice[0].f_price"
                         v-validate:f_price='{required: true }'  placeholder="单价">
                </div>
                <div class='auto' style="margin-top: 10px;">
                <stair-price :isheat.sync="model.f_isheat" :stairmodel.sync='detailprice'
                             v-if="newinfo.f_price_type ==='阶梯气价'"></stair-price>
                </div>
              </div>
              <div class="row" style="margin-top: 2%" v-if="model.type ==='系统气价'">
                <div class="col-sm-4 flex-row" >
                  <label class="control-label">用户类型</label>
                  <v-select :value.sync="newinfo.f_user_type"
                            :options='usertypes' placeholder='用户类型'
                            @change="userTypeChange()"
                            close-on-select></v-select>
                </div>
                <div class="col-sm-4 flex-row"
                     :class="[$m.gas.required ? 'has-error' : '']">
                  <label class="control-label">用气性质</label>
                  <input type="text" v-show="false" v-model="$refs.gas.selectedItems" v-validate:gas='{required: true }'>
                  <v-select :value.sync="newinfo.f_gasproperties" v-model="newinfo.f_gasproperties"
                            :options='gasproperties' placeholder='用气性质'
                            close-on-select v-ref:gas></v-select>
                </div>
                <div class="col-sm-4 flex-row" :class="[$m.type.required ? 'has-error' : '']">
                  <label class="control-label">气价类型</label>
                  <v-select :value.sync="newinfo.pricetype" v-model="newinfo.pricetype"
                            placeholder='气价类型' :options="pricetypes"
                            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>
              <div class="row" style="margin-top: 2%" v-if="model.type ==='系统气价'">

                <div class="col-sm-4 flex-row" :class="[$m.name.required ? 'has-error' : '']">
                  <label class="control-label">气价名称</label>
                  <v-select :value.sync="newinfo.pricename" v-model="newinfo.pricename"
                            placeholder='气价名称' :options="getPricenames()" @change="priceChange"
                            close-on-select :disabled='newinfo.pricetype.length === 0 ' v-ref:name></v-select>
                  <input type="text" v-show="false" v-model="$refs.name.selectedItems" v-validate:name='{required: true }'>
                  <span class="col-sm-3" v-if="newinfo.pricetype.length === 1 && gasproperties.length === 0"
                        style="color:red;text-align:right">请确定用气性质已选择！！</span>
                </div>

                <div class="col-sm-4 flex-row">
                  <label class="control-label">气价备注</label>
                  <input type="text" class="input_search" style="width:60%" v-model="newinfo.f_price_comments" placeholder='气价备注' disabled>
                </div>

                <div  class="col-sm-4 flex-row"  >
                  <label class="control-label" >生效日期</label>
                  <input class="input_search" style="width:60%" type="text" v-model="preformdate"
                         :disabled="true">
                </div>

              </div>
            </div>
          </form>
        </div>

        <upload :blodid="row.f_userinfo_id" v-if="config.showupload" isremark="true" fusetype="单户调价"></upload>
      </article>
      <footer slot="modal-footer" class="modal-footer">
        <button class="button_search" :disabled='!$m.valid ' @click="modifyUser">确定</button>
        <button type="button" class="button_clear" @click='close'>取消</button>
      </footer>

    </modal>


      <modal :backdrop="false" :show.sync="showPopUps" v-if="showPopUps" width="1000px">
        <header class="modal-header" slot="modal-header">
          <button @click="showPopUps=!showPopUps" class="close" type="button"><span>&times;</span></button>
          <h4 class="modal-title">历史记录</h4>
        </header>
        <article class="modal-body"  slot="modal-body"  style="height:100%;width:100%"  title="历史记录">
          <user-price-change-history :row="row"  :show.sync="showPopUps" v-on:toggle="close"></user-price-change-history>
        </article>
        <footer class="modal-footer" slot="modal-footer">

        </footer>
      </modal>
    </validator>

  </div>

</template>

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

  let loadParamGem = async function (self) {
    if (!self.f_filialeid) {
      self.f_filialeid = self.$login.f.orgid
    }
    await self.$LoadParams.loadParam(self.f_filialeid)
  }

  export default {
    title: '单户调价',
    data () {
      return {
        model: new PagedList('rs/sql/sale_getUserPrice', 30, {orderitem: '"f_userinfo_id DESC"'}),
        row: null, // 选择一条客户信息，对其进行修改
        rows: [], // 客户档案选择一条时，将只显示一条信息，rows用来存放整页的数据
        orderDefault: 'f_createfile_date desc',
        orderFields: {
          f_userinfo_id: 'no'
        },
        config: {
          showupload: true
        },
        detailprice: [],
        newinfo: {
          f_user_type: '',
          f_gasproperties: '',
          pricetype: '',
          pricename: '',
          f_perform_date: this.$login.toStandardDateString() + ' 00:00:00' // 操作时间
        },
        preformdate: this.$login.toStandardDateString() + ' 00:00:00',
        showPerformDate: false,
        show: false,
        showPopUps: false,
        curorgid: [this.$login.f.orgid],
        f_filialeid: this.$login.f.orgid,
        f_orgid: '',
        criteriaShow: false,
        valid: false,
        pricetype: [{label: '固定气价', value: '固定气价'}, {label: '阶梯气价', value: '阶梯气价'}],
        gasproperties: [],
        gasproperties2: this.$appdata.getParam('用气性质') ? [{label: '全部', value: ''}, ...this.$appdata.getParam('用气性质')] : [],
        usertypes: this.$appdata.getParam('用户类型') ? [{label: '全部', value: ''}, ...this.$appdata.getParam('用户类型')] : [],
        pricetypes: this.$appdata.getParam('气价类型') ? [{label: '全部', value: ''}, ...this.$appdata.getParam('气价类型')] : []
        // userstates: [{label: '全部', value: ''}, ...this.$appdata.getParam('客户状态')]
      }
    },
    methods: {
      userTypeChange () {
        this.gasproperties = []
        if (this.newinfo.f_user_type.length === 1) {
          this.gasproperties = this.$appdata.getParam(this.newinfo.f_user_type[0])
        }
      },

      hidden () {
        this.criteriaShow = !this.criteriaShow
      },
      search () {
        this.$refs.paged.$refs.criteria.search()
      },
      priceshow (row) {
        this.show = true
        this.showPerformDate = (row.f_calculation == '表端结算')
        this.row = row
      },
      lookOver (row) {
        this.showPopUps = true
        this.row = row
      },
      getPricenames () {
        console.log('气价。，。。', this.newinfo.pricetype, this.newinfo.f_user_type, this.newinfo.f_gasproperties)
        let rs = []
        if (this.newinfo.f_user_type.length === 1 && this.newinfo.f_gasproperties.length === 1 && this.newinfo.pricetype.length === 1) {
          let params = {
            f_user_type: this.newinfo.f_user_type[0],
            f_gasproperties: this.newinfo.f_gasproperties[0],
            f_price_type: this.newinfo.pricetype[0]
          }
          rs = this.$GetSaleParam.getPriceAll(params)
        }
        if (rs.length === 0) {
          this.newinfo.f_price_name = ''
        }
        return rs
      },
      priceChange (val) {
        if (val && val.length > 0) {
          // 展示气价备注
          this.$set('newinfo.f_price_comments', val[0].f_comments ? val[0].f_comments : '无')
        }
      },
      close () {
        this.showPerformDate = false
        this.show = false
        this.row = null
        this.newinfo = {
          f_user_type: '',
          f_gasproperties: '',
          pricetype: '',
          pricename: ''
        }
      },
      async modifyUser () {
        if (this.model.type === '系统气价') {
          let param = {
            f_userinfo_id: this.row.f_userinfo_id,
            f_userfiles_id: this.row.f_userfiles_id,
            f_user_id: this.row.f_user_id,
            f_user_name: this.row.f_user_name,
            f_user_type: this.newinfo.f_user_type[0],
            f_gasproperties: this.newinfo.f_gasproperties[0],
            f_price_type: this.newinfo.pricetype[0],
            f_price_id: this.newinfo.pricename[0].f_price_id,
            f_filialeid: this.f_filialeid,
            f_operator: this.$login.f.name,
            f_operatorid: this.$login.f.id,
            f_orgid: this.$login.f.orgid,
            f_orgname: this.$login.f.orgs,
            f_depid: this.$login.f.depids,
            f_depname: this.$login.f.deps,
            f_perform_date: this.row.f_perform_date,
            f_change_reason: ''
          }

          await this.$resetpost('rs/logic/user_pricechange', {data: param}, {resolveMsg: '更新成功', rejectMsg: '更新失败'})

          this.criteriaShow = false
          this.close()
          this.search()
        } else if (this.model.type === '自定义气价') {
          let data = {
            f_userinfo_id: this.row.f_userinfo_id,
            f_userfiles_id: this.row.f_userfiles_id,
            f_user_id: this.row.f_user_id,
            f_user_name: this.row.f_user_name,
            f_price_type: this.newinfo.f_price_type,
            f_price_name: this.newinfo.f_price_name,
            f_user_type: this.row.f_user_type,
            f_gasproperties: this.row.f_gasproperties,
            f_perform_date: '2021-01-01 00:00:00',
            f_perform_date_change: this.row.f_perform_date,
            f_end_date: '2099-12-31 23:59:59',
            f_islow_income: 0,
            f_limit_cycle: 0,
            f_limit_gas: 0,
            f_stairmonths: null,
            f_population_base: null,
            f_stair_start_date: null,
            f_isheat: 0,
            f_deduction_way: 'cycle',
            f_heat_start_date: null,
            f_heat_cycle: null,
            f_priority: 100,
            f_comments: '',
            f_state: '有效',
            f_filialeid: this.f_filialeid,
            f_operator: this.$login.f.name,
            f_operatorid: this.$login.f.id,
            f_orgid: this.$login.f.orgid,
            f_orgname: this.$login.f.orgs,
            f_depid: this.$login.f.depids,
            f_depname: this.$login.f.deps,
            userid: this.$login.f.id,
            audit: false,
            type: '添加',
            detailprice: this.detailprice,
            f_custom: '自定义气价'
          }
          if (this.newinfo.f_price_type === '阶梯气价') {
            data.f_stairmonths = this.newinfo.f_stairmonths
            data.f_population_base = 0
            data.f_stair_start_date = this.newinfo.f_stair_start_date
          }
          if (data.f_price_type === '固定气价') {
            if (data.detailprice[0].id) {
              delete data.detailprice[0].id
            }
            data.detailprice[0].f_price_name = 1
          } else if (data.f_price_type === '阶梯气价') {
            data.detailprice.forEach((item, index) => {
              data.detailprice[index].f_price_name = index + 1
              if (data.detailprice[index].id) {
                if (delete data.detailprice[index].id) {
                  delete data.detailprice[index].id
                }
              } else if (data.detailprice[index].f_ratio) {
                data.detailprice[index].f_ratio = null
              } else if (!data.detailprice[index].f_add_gas) {
                data.detailprice[index].f_add_gas = 0
              } else if (!data.detailprice[index].f_add_gas_heat) {
                data.detailprice[index].f_add_gas_heat = 0
              }
            })
          }

          this.$resetpost('rs/logic/customprice', {data: data}, {resolveMsg: '更新成功', rejectMsg: '更新失败'})

          this.criteriaShow = false
          this.close()
          this.search()
        }
      },
      clean () {
        this.row = null
        this.areainfo = null
        this.$refs.paged.$refs.grid.select(null)
        this.$refs.paged.$refs.grid.model.rows = this.rows
      },

      selfSearch (args) {
        if (!this.f_orgid) {
          this.getorg([this.$login.f.orgid])
        }
        if (this.f_orgid) {
          args.condition = `${args.condition} and f_filialeid in ${this.f_orgid}`
        } else {
          args.condition = `${args.condition} and f_filialeid = '${this.$login.f.orgid}'`
        }
        this.criteriaShow = false
        this.$refs.paged.$refs.grid.$el.scrollTop = 0
        this.model.search(args.condition, args.model)
        this.clean()
      },
      getorg (val) {
        this.f_orgid = this.$login.convertToIn(val)
        this.$parent.f_orgid = this.f_orgid
      },
      sort (field, rule) {
        // 将所有排序方式设为不排序，实现相互排斥
        for (let key in this.orderFields) {
          if (key === field) {
            this.orderFields[key] = rule
          } else {
            this.orderFields[key] = 'no'
          }
        }
        // 如果新规则不排序，还原为默认排序
        if (rule === 'no') {
          this.model.paramSource.orderitem = `'${this.orderDefault}'`
        } else {
          this.model.paramSource.orderitem = `'${field} ${rule}'`
        }

        this.search()
      },

      clear () {
        Object.keys(this.$refs.paged.$refs.criteria.model).forEach((key) => {
          this.$refs.paged.$refs.criteria.model[key] = []
        })
      }
    },
    ready () {
      loadParamGem(this)
    },
    watch: {
      // 每次查询将查询到的数据存储起来，供选择操作后的替换
      'model.state' (val) {
        if (val === '正确') {
          this.rows = this.model.rows
        }
      },
      'newinfo.f_price_type' (val) {
        if (val === '固定气价') {
          this.detailprice = []
        } else if (val === '阶梯气价') {
          this.detailprice = [{f_gas: '', f_price: '', f_add_gas: 0, f_add_gas_heat: 0}]
        }
      },
      'show' (val) {
        if (!val) {
          this.newinfo = {
            f_user_type: '',
            f_gasproperties: '',
            pricetype: '',
            pricename: ''
          }
          this.row = null
        } else {
          this.newinfo = {
            f_user_type: [this.row.f_user_type],
            f_gasproperties: [this.row.f_gasproperties],
            pricetype: [this.row.f_price_type],
            pricename: ''
          }
        }
      },
      'f_filialeid' (val) {
        loadParamGem(this)
      },
      async 'newinfo.pricename' () {
        if (this.newinfo.pricename == null || !(this.newinfo.pricename instanceof Array) || this.newinfo.pricename.length == 0) return
        let qij = await this.$resetpost('rs/sql/saleSingleTable', {
          data: {
            tablename: 't_stairprice',
            condition: ` f_price_id = ${this.newinfo.pricename[0].f_price_id} and getDate()>= f_perform_date and  getDate()<f_end_date `
          }
        }, {resolveMsg: null, rejectMsg: null})
        if (qij.data && qij.data.length > 0) {
          this.preformdate = qij.data[0].f_perform_date
        }
      }
    }
  }
</script>
<style scoped>

  .datapanel {
     color: #333;
     background-color: white;
     box-shadow: darkgrey 0.5px 0.5px 0.5px 0.5px ;
     padding: 10px 30px 10px 30px;
     height: auto;
     border-radius:15px;
   }

</style>
