<template>
  <div id="unit" class="flex-row" v-if="listpage" >
    <div :class="{'basic-main':((!isdetail) && (!usershow)),'binary-left':isdetail||usershow}" >
      <dispatch-list v-ref:list :row="row" :config="config" :f_filialeid.sync="f_filialeid" @select-changed="selected" @showlist="showlist" ></dispatch-list>

    </div>
    <div class="binary-right" style="overflow-y: scroll" v-if="isdetail&&!usershow">
      <dispatch-down v-show="!changeView" :data="row" :config="config"  :f_filialeid.sync="f_filialeid" @close="refresh" v-ref:gas ></dispatch-down>
<!--      <price-record v-show="changeView" v-ref:update :row="row"  @select-changed="selected2"></price-record>-->
    </div>
<!--    <div class="binary-right" v-if="usershow">-->
<!--      <gasprice-user :priceid="priceid" :pricename="pricename"></gasprice-user>-->
<!--    </div>-->

  </div>


</template>
<script>
    /**
     *阶梯气价管理组件
     */

    let readGen = async function (self) {
        // 获取气价里面的配置
      let getConfig = await self.$getConfig(self, 'GasPrice')
      if (getConfig) {
        Object.assign(self.config, self.config, getConfig.data)
      }
      console.log('获取气价配置', self.config)
    }

    export default {
      title: '派单管理',
      data () {
        return {
          f_userinfo_id: '',
          f_filialeid: this.$login.f.orgid,
          config: {
            isLimit: false, // 限购
            audit: false,  // 启用审核
            heatingSeason: false, // 采暖季
            deductionWay: 'cycle'  // 'cycle: 周期扣费； day: 日运算扣费； singleHS: 采暖季独立扣费； dayHS: 采暖季日扣费；' 此值不配置默认周期扣费
          },
          listpage: true,
          row: null,
          styles: 'col-sm-2  form-group',
          parentData: '',
          isdetail: false,
          priceid: '',
          pricename: '',
          gasPriceShow: false,
          usershow: false,

                // 控制气价信息界面和变更操作记录界面的展示
          changeView: false,
          listrow: '',
          listshow: false,
          queryshow: false
        }
      },
      ready () {
        readGen(this)
      },
      methods: {
        showlist (row) {
          this.listrow = row
          this.listshow = true
          this.queryshow = true
        },
        mycaiClean () {
          this.listshow = false
          this.queryshow = false
          this.table = ''
        },
        cancel (obj) {
          this.listpage = true
        },
        dealMsg (val) {
          this.listpage = false
          this.f_userinfo_id = val.f_userinfo_id
        },
        selected (obj) {
          this.row = obj.val
          this.parentData = this.row.id
          this.isdetail = true
          this.usershow = false
          this.listpage = true
        },
        selected2 (obj) {
          this.row = Object.assign({}, this.row, obj.val)
          this.gasPriceShow = true
          this.listpage = true
          this.usershow = false
        },
        refresh () {
          this.row = null
          this.gasPriceShow = false
          this.isdetail = false
          this.usershow = false
          this.listpage = true
          this.$refs.list.search()
        },
        changeInputSize (val) {
          this.$refs.list.styles = 'col-sm-' + val + '  form-group'
        }
      },
      events: {
        'success' (name, row, res) {
          this.changeInputSize(2)
          this.row = row
          this.gasPriceShow = false
          this.isdetail = false
          this.usershow = false
          this.listpage = true
          this.$refs.list.search()
        },
        'error' (name, row, res) {
          this.changeInputSize(2)
          this.row = row
          this.gasPriceShow = false
          this.isdetail = false
          this.usershow = false
          this.listpage = true
          this.$refs.list.search()
        },
        'close' (res) {
          this.changeInputSize(2)
          this.row = null
          this.gasPriceShow = false
          this.isdetail = false
          this.usershow = false
          this.listpage = true
        },
        'search' () {
          this.changeInputSize(2)
          this.row = null
          this.gasPriceShow = false
          this.isdetail = false
          this.usershow = false
          this.listpage = true
                // this.$refs.list.search()
        },

        'add' () {
              // 点击新增按钮改变样式
          this.changeInputSize(4)
          this.isdetail = true
          this.usershow = false
          this.listpage = true
          if (this.gasPriceShow) {
            this.$refs.gas.initModel()
          }
          this.gasPriceShow = true
          this.$refs.list.$refs.paged.$refs.grid.selectStore.selected = null
          this.row = null
        }
      }
    }
</script>
