<style scoped>
  .departmentTreeStyleCont {
    padding-top: 20px;
    display: flex;
    height: 100%;
  }

  .departmentTreeStyleCont .departmentTreeStyle {
    background: #fff;
    padding: 20px;
    flex: 0 1 400px;
    min-height: 800px;
  }

  .departmentTreeStyleCont .departmentTreeStyle > p {
    font-size: 14px;
    margin-bottom: 15px;
    color: #333;
    font-weight: bold;
    height: 14px;
    line-height: 14px;
    border-left: 3px solid #E95252;
    text-indent: 20px;
  }

  .departmentTreeStyleCont .departmentTreeStyle .spanIcon {
    padding-left: 20px;
    display: none
  }

  .departmentTreeStyleCont .departmentTreeStyle .el-tree-node__content {
    height: 32px;
    line-height: 32px;
    font-size: 12px
  }

  .TreeSpan img {
    width: 24px;
    height: 24px;
    border-radius: 12px;
    vertical-align: sub;
    margin-right: 3px;
  }

  .departmentTreeStyleCont .departmentTreeStyle .el-tree-node__content:hover .spanIcon {
    display: inline-block
  }

  .departmentTreeStyleCont .departmentTreeStyle .el-tree-node__content:hover .spanIcon i {
    font-size: 14px !important;
    color: #999;
    margin-right: 2px;
  }

  .departmentTreeStyleCont .departmentTreeStyle .el-tree-node__content:hover .spanIcon i:hover {
    color: #E95252;
  }

  .departmentTreeStyleCont .departmentTreeLayer > p {
    font-size: 14px;
    margin-bottom: 15px;
    color: #333;
    font-weight: bold;
    height: 14px;
    line-height: 14px;
    border-left: 3px solid #E95252;
    text-indent: 20px;
  }

  .departmentTreeStyleCont .departmentTreeLayer {
    background: #fff;
    min-height: 300px;
    padding: 20px;
    margin-left: 20px;
    flex: auto
  }

  .departmentTreeStyleCont .el-date-editor.el-input,
  .departmentTreeStyleCont .el-date-editor.el-input__inner {
    width: auto !important;
  }
</style>
<template>
  <div class="flexOne">
    <div class="query-box">
      <ul>
          <li>
          <span><em>{{$t('pub.Customer')}}</em>
            <el-input v-model='msg.CustomerName'
                :placeholder="$t('pub.pleaseImport')"></el-input>
            </span>

        </li>
         <li>
          <span><em>{{$t('objFill.orderid')}}</em><el-input v-model='msg.OrderId'
                :placeholder="$t('pub.pleaseImport')"></el-input></span>
        </li>
        <li>
            <span><em>{{$t('advmanager.v_type')}}</em>
                    <el-select filterable  v-model='msg.Type' :placeholder="$t('pub.pleaseSel')">
                    <el-option :label="$t('pub.unlimitedSel')" value='0'></el-option>
                    <el-option :label="$t('restaurant.res_income')" value='1'></el-option>
                    <el-option :label="$t('objFill.v101.Buying.dikou')" value='2'></el-option>
                </el-select>
            </span>
        </li>
        <li>
            <span><em>{{$t('advmanager.v_line')}}</em>
                    <el-select filterable  v-model='msg.LineId' :placeholder="$t('pub.pleaseSel')">
                    <el-option :label="$t('pub.unlimitedSel')" value=""></el-option>
                    <el-option v-for="(item,index) in LineList" :key="index+300" :label="item.LineName" :value="item.LineID"></el-option>
                </el-select>
            </span>
        </li>
        <li>
            <span><em>{{$t('sm.company')}}</em>
                    <el-select filterable  v-model='msg.RB_Branch_Id' :placeholder="$t('pub.pleaseSel')">
                    <el-option
                      v-for="item in companyList"
                      :label="item.BName"
                      :value="item.Id"
                      :key="item.Id"
                    ></el-option>
                </el-select>
            </span>
        </li>
        <li>
            <span><em>发放{{$t('pub.date')}}</em>
            <el-date-picker
                v-model="dateList"
                type="daterange"
                :range-separator="$t('OrderList.zhi')"
                value-format="yyyy-MM-dd"
                :start-placeholder="$t('OrderList.star')"
                :end-placeholder="$t('OrderList.end')">
                </el-date-picker>
            </span>
        </li>

        <li>
          <input type="button" class="hollowFixedBtn" :value="$t('pub.searchBtn')" @click="resetPageIndex(),getList()"/>
        </li>
      </ul>
    </div>
    <table class="singeRowTable" border="0" cellspacing="0" cellpadding="0" v-loading='loading'>
      <tr>
        <th>{{$t('salesModule.storeName')}}</th>
        <th>{{$t('advmanager.v_type')}}</th>
        <th>积分数量</th>
        <th>{{$t('objFill.v101.Rest.suoshutuan')}}</th>
        <th>{{$t('system.label_info')}}</th>
        <th>{{$t('salesModule.Time')}}</th>
      </tr>
      <tr v-for="(item,index) in DataList" :key="index+500">
        <td>{{item.CustomerName}}</td>
        <td>
            <span>{{item.Type==1?$t('restaurant.res_income'):$t('objFill.v101.Buying.dikou')}}</span>
        </td>
        <td>{{item.IntegralNum}}</td>
        <td><span style="cursor:pointer" @click="Gourl(item)">{{item.TCNUM}}</span></td>
        <td>{{item.Description}}</td>
        <td>{{item.CreateTime}}</td>
      </tr>
      <tr v-if='DataList.length==0'>
          <td colspan="7" align="center" style="text-align: center">{{$t('system.content_noData')}}</td>
      </tr>
    </table>
    <el-pagination background @current-change="handleCurrentChange" :current-page.sync="currentPage"
                   layout="total,prev, pager, next, jumper" :page-size=msg.pageSize :total=total>
    </el-pagination>

  </div>
</template>

<script>
  export default {
    data() {
      return {
        loading: true,
        //分页
        total: 0,
        pageSize: '',
        msg: {
          pageIndex: 1,
          pageSize: 15,
          CustomerName:"",
          OrderId:"",          
          QStartDate:"",
          QEndDate:"",
          LineId:"",
          RB_Branch_Id:"",
          TCID:0
        },
        currentPage:1,
        DataList:[],
        dateList:[],
        LineList:[],
        getCompanyMsg: {
          RB_Group_Id: "0",
          Status: "0"
        },
        companyList:[]        
      }
    },
    created(){
      if(this.$route.query.CustomerId){
        this.msg.CustomerId=this.$route.query.CustomerId;
      }
      if(this.$route.query.TCID && this.$route.query.TCID>0){
        this.msg.TCID=this.$route.query.TCID;
      }
    },
    mounted() {
      let userInfo = this.getLocalStorage();

      this.getList();
      this.getLineList();
      this.getCompanyList();      
    },
    methods: {
      getCompanyList() {
        let userInfo = this.getLocalStorage();
        let RB_Group_id = userInfo.RB_Group_id;
        let msg = {
          Status: 0,
          is_show: 0,
          RB_Group_Id: RB_Group_id
        }
        this.apipost('admin_get_BranchGetList', msg, res => {
          if (res.data.resultCode == 1) {
            let text = this.$t('pub.unlimitedSel')
            this.companyList = [{
              Id: '-1',
              BName: text 
            }];;
            res.data.data.forEach(x => {
              var obj = {
                Id: '',
                BName: ''
              }
              obj.Id = x.Id.toString();
              obj.BName = x.BName;
              this.companyList.push(obj);
            })
          }
        }, err => {})
      },
      Gourl(item){
     	   this.$router.push({ name:"groupTourOrderByTuan",query:{"id":item.TCID,"tcmun":item.TCNUM,blank: 'y'} })
      },
      getLineList() {
        this.apipost("line_post_GetAllList_V2", {LineDirection: 0}, res => {
          if (res.data.resultCode == 1) {
            this.LineList = res.data.data;
          }
        });
      },

      getList() { //获取数据
      if(this.dateList){
          this.msg.QStartDate=this.dateList[0];
          this.msg.QEndDate=this.dateList[1];
      }else{
          this.msg.QStartDate="";
          this.msg.QEndDate="";
      }
        this.loading = true;
        this.apipost('customer_post_GetCustomerIntegralPageList', this.msg, res => {
          this.loading = false
          if (res.data.resultCode == 1) {
            this.DataList = res.data.data.pageData;
            this.total = res.data.data.count;
          } else {
          }
        }, err => {
        })
      },
      handleCurrentChange(val) {
        this.msg.pageIndex = val;
        this.getList();
      },
      resetPageIndex() {
        this.msg.pageIndex = 1;
        this.currentPage = 1
      },
    }
  }
</script>
