<template>
  <div class="app-container">
  <div v-if="jiBie==2">
    <el-form>
      <el-form-item label="当前站点余额">{{balance||0}}</el-form-item>
    </el-form>
  </div>
    <el-form :model="queryParams" ref="queryForm" :inline="true"  label-width="68px">
      <el-form-item label="类型" prop="type">
        <el-select
          v-model="queryParams.type"
          placeholder="请选择消费充值类型"
          clearable
          size="small"
        >
          <el-option label="充值" value="+" />
          <el-option label="消费" value="-" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table  :data="balanceAdjustList">
      <el-table-column label="类型" align="center" prop="type">
        <template slot-scope="scope">
          <span class="badge" :class="scope.row.type == '+' ? 'badge-primary':'badge-danger'">{{ scope.row.type == '+' ? '增加' : '减少' }}</span>
        </template>
      </el-table-column>
      <af-table-column label="变动金额" align="center" prop="amt" />
      <af-table-column label="站点名称" align="center" prop="stationName" v-if="jiBie==1" />
      <af-table-column label="调价时间" align="center" prop="createTime"  />
      <el-table-column label="涉及订单" align="center" prop="type">
        <template slot-scope="scope">
          <span>{{ scope.row.orderNo == null ? '无' : scope.row.orderNo }}</span>
        </template>
      </el-table-column>
      <af-table-column label="操作人" align="center" prop="createName"  />
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listAdjust, listBanlaceAdjust,selectDeptBalance  } from "@/api/lng";


export default {
  name: "Lng_BalaceRecord",
  data() {
    return {
      // 总条数
      total: 0,
      // 结算价格，司机价格优惠调整表格数据
      balanceAdjustList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        levelId: this.levelId,
        pageNum: 1,
        pageSize: 10,
        settlementPrice: null,
        settlementType: null,
        driverPrice: null,
        stationId: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
      balance:0
    };
  },
  created() {
    
    this.init();
  },
  methods: {
    init() {
      this.getList();
      this.selectDeptBalance()
    },
    selectDeptBalance(){
      selectDeptBalance().then((res)=>{
        if(res.code == 200){
          this.balance = res.data.balance;
        }else{
          throw new Error('')
        }
      }).catch((err)=>{
        this.msgError("加载余额失败~")
      })
    },
    /** 查询结算价格，司机价格优惠调整列表 */
    getList() {
      this.queryParams.levelId = this.levelId;
      listBanlaceAdjust(this.queryParams).then(response => {
        this.balanceAdjustList = response.rows;
        this.total = response.total;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.levelId = this.levelId;
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    }
  }
};
</script>
