<template>
  <div id="unit" class="row" :class="{'binary':showItem}">
    <div :class="{'basic-main':!showItem,'binary-left':showItem}" style="height:98%">
      <other-maintenance-lists @select-changed="idsearch" :showMessage.sync="showAddMssage" v-if="stepControl"
                              :recordlist="recordlist" :record="record"    v-ref:stocklist></other-maintenance-lists>
    </div>
    <div class="binary-right" v-if="showItem">

      <other-maintenance-operations  :model="model" :oldmodel="oldmodel" v-show="showItem" :record="record"
                                     :recordlist="recordlist"     :f_distribution_state="f_distribution_state" :row="row" :rowsdata="rowsdata1"
                                     :warehousename="warehousename"></other-maintenance-operations>
    </div>
  </div>
</template>

<script>
  export default {
    title: '其他记录维护',
    name: 'Otherrecordmaintenance',
    data () {
      return {
        showupload: false,
        record: [],
        recordlist: [],
        // oldrecordlist:[],
        model: {},
        oldmodel: {},
        showAddMssage: false,
        // 分配状态z
        f_distribution_state: '',
        // 单选数据
        row: {},
        // 多选数据
        rowsdata: [],
        rowsdata1: {},
        stepControl: true,
        warehousename: '',
        showItem: false
      }
    },
    created () {
    },
   /* ready () {
      this.arrAddFun()
    }, */
    methods: {
      selected (row) {
        this.row = row.val
      },
      changeDisplay () {
        this.stepControl = !this.stepControl
        this.$dispatch('change-state', '')
      },
      join (rowsdata) {

      },
      idsearch (row) {
        this.showAddMssage = true
        this.showItem = true
        this.model = JSON.parse(JSON.stringify(row.val))
        this.oldmodel = JSON.parse(JSON.stringify(row.val))
        // this.querydefc()
        this.querydefc()
      },
      async getGroupData () {
        let condition1 = " othercharge_id = '" + this.model.id + "'"
        if (this.model.did != null) {
          let condition2 = " or  charge_detail_id = '" + this.model.id + "' "
          let condition = condition1 + condition2
          console.log('获取其他操作记录')
          let res = await this.$resetpost('rs/sql/queryrecord', {
            data: {
              condition: condition
            }
          },
            {
              resolveMsg: null, rejectMsg: '获取记录出错'
            })
          this.record = res.data
        } else {
          let condition = condition1
          let res = await this.$resetpost('rs/sql/queryrecord', {
            data: {
              condition: condition
            }
          },
            {
              resolveMsg: null, rejectMsg: '获取记录出错'
            })
          this.record = res.data
        }

            // console.log("获取明细操作记录")
            // let res2 =  await this.$resetpost('rs/sql/querydetailoperating', {
            //     data: {
            //       condition2: condition2}},
            //   {resolveMsg: null, rejectMsg: '获取记录出错'
            //   })
          //   for(var i=0;i<res2.data.length;i++){
          //     // console.log("数组长度"+res2.data.length())
          //     let req =res2.data[i]
          //     this.record.push(req)
          //     console.log(res2.data[i])
          //   }
          //   console.log('这是操作记录' + res.data+res2.data)
          // }
      },
      async querydefc () {
        let condition = " o.f_userinfo_id= '" + this.model.f_userinfo_id + "'  and o.id='" + this.model.id + "'"
        console.log('获取明细记录')
        let res = await this.$resetpost('rs/sql/querydetail', {
          data: {
            condition: condition
          }
        }, {resolveMsg: '获取记录', rejectMsg: '获取记录出错'})
        console.log('这是明细' + res.data)
        this.recordlist = res.data
        this.getGroupData()
      }
    },
    events: {
      'change-state' (state) {
        this.f_distribution_state = state
        this.rowsdata1 = {}
      },
      'getwarehouse' (a) {
        this.warehousename = a
      },
      'change-receive' (state) {
        this.f_distribution_state = state
      },
      'change-state1' (state) {
        console.log('选择分配状态', state)
        this.rowsdata1 = {}
      },
      'select' (rowsdata) {
        this.mergeRowData(rowsdata)
      },
      'join' (rowsdata) {
        this.rowsdata1 = Object.assign({}, rowsdata)
        console.log('111:', this.rowsdata1)
      },
        // 重新查询
      'refresh' () {
        this.model = ''
        this.$refs.stocklist.search()
      },
      'close' () {
        this.showItem = false
        this.$refs.stocklist.search()
        console.log('this.$refs', this.$refs)
        console.log('showitem', this.showItem)
      }
         // 调拨组件选择调出仓库,根据选择仓库进行查询
        //  'idsearch' (f_warehouse_id) {
        //
        // }
    }
    // watch:{
    //     model:{
    //       handler(val){
    //         console.log('值改变了'),
    //           this.getGroupData()
    //       }
    //     }
    //   }

  }
</script>

<style lang="less">

</style>
