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

    </div>
    <div class="binary-right" style="overflow-y: scroll" v-if="isdetail&&!usershow">
      <printing-dispatch-down v-ref:printdown v-show="!changeView" :data="row" :config="config"  :f_filialeid.sync="f_filialeid" @close="refresh" ></printing-dispatch-down>
    </div>


  </div>


</template>
<script>
    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
        },
        selected (obj) {
                // 组件未加载无法初始化其值
          if (this.$refs.printdown != null) {
            this.$refs.printdown.data = {}
          }
          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
        },
        'revoke' (savedata) {
              // 更新打印状态
          this.gasPriceShow = false
          this.isdetail = false
          this.usershow = false
          this.listpage = true
          this.$refs.list.confirmprintState(savedata)
        },
        '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>
