<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>客户</em>
            <el-input v-model='msg.CustomerName'
                placeholder="请输入"></el-input>
            </span>
            
        </li>
         <li>
          <span><em>订单ID</em><el-input v-model='msg.SourceId'
                placeholder="请输入"></el-input></span>
        </li>
        <!-- <li>
            <span><em>来源</em>
                    <el-select filterable   v-model='msg.OrderSource' placeholder="请选择">
                    <el-option label="不限" value='-1'></el-option>
                    <el-option label='1·1' value=''></el-option>
                </el-select>
            </span>
        </li> -->
        <li>
            <span><em>类型</em>
                    <el-select filterable  v-model='msg.Type' placeholder="请选择">
                    <el-option label="不限" value='0'></el-option>
                    <el-option label='收入' value='1'></el-option>
                    <el-option label='抵扣' value='2'></el-option>
                </el-select>
            </span>
        </li>
        <li>
            <span><em>线路</em>
                    <el-select filterable  v-model='msg.LineId' placeholder="请选择">
                    <el-option label="不限" 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>公司</em>
                    <el-select filterable  v-model='msg.RB_Branch_Id' placeholder="请选择">
                    <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>销售</em>
                    <el-select v-model="msg.EmployeeId" filterable placeholder="请选择">
                      <el-option label="不限" value=""></el-option>
                      <el-option v-for="item in employee" :key="item.employeeId" :label="item.name" :value="item.employeeId"></el-option>
                    </el-select>
            </span>
        </li>
        
        <li>
            <span><em>日期</em>
            <el-date-picker
                v-model="dateList"
                type="daterange"
                range-separator="至"
                value-format="yyyy-MM-dd"
                start-placeholder="开始日期"
                end-placeholder="结束日期">
                </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>门店名称</th>
        <th>类型</th>
        <th>金额</th>     
        <th>所属团</th>     
        <th>描述</th>
        <th>时间</th>
        <th>历史余额</th>
        
      </tr>
      <tr v-for="(item,index) in DataList" :key="index+500">
        <td>{{item.CustomerName}}({{item.Contact}})</td>
        
        <td>
            <span>{{item.Type==1?"收入":"抵扣"}}</span>
        </td>
        <td>{{item.Money}}</td>
        <td><span style="cursor:pointer" @click="Gourl(item)">{{item.TCNUM}}</span></td>
        <td>{{item.Description}}</td>
        <td>{{item.UpdateTime}}</td>
        <td>{{item.AccountMoney}}</td>
        
      </tr>
      <tr v-if='DataList.length==0'>
          <td colspan="7" align="center" style="text-align: center">暂无数据</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,
          Type: "0",
          CustomerName:"",
          SourceId:"",
          OrderSource:"",
          StartTime:"",
          EndTime:"",
          LineId:"",
          EmployeeId:"",
          RB_Branch_Id:"",

        },
        currentPage:1,
        DataList:[],
        dateList:[],
        LineList:[],
        getCompanyMsg: {
          RB_Group_Id: "0",
          Status: "0"
        },
        companyList:[],
        employee:[],
      }
    },
    created(){
      if(this.$route.query.CustomerId){
        this.msg.CustomerId=this.$route.query.CustomerId;
      }
    },
    mounted() {
      let userInfo = this.getLocalStorage();

      this.getList();
      this.getLineList();
      this.getCompanyList();
      this.getEmployee();
    },
    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) {
            this.companyList = [{
              Id: '-1',
              BName: '不限'
            }];
            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'} })
      },
      getEmployee(){
				this.apiJavaPost("/api/user/employee/getAllSalesList",{}, res => {
            if (res.data.resultCode === 1) {
              this.employee=res.data.data;
            } else {
              this.Error(res.data.message)
            }
                }, null);
			},
      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.StartTime=this.dateList[0];
          this.msg.EndTime=this.dateList[1];
      }else{
          this.msg.StartTime="";
          this.msg.EndTime="";
      }
        this.loading = true;
        this.apipost('customer_post_GetC_BigRedEnvelopeInfoList', 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>