
<template>
  <div>
    <basicLayout 
      ref="basicLayout" 
      :oldFormPath="{
        add:'HDrpManagement/writeoffbill/components'
      }"
      tableName="writeoffbillTable" 
      idName="sa_writeoffbillid" 
      :apiId="{query:20221124090104,del:20221124090304}"
      :options="options"
      :detailPath="{
        path:'/writeoffbillDetail'
      }"
      @listData="listData">
      <template #custom>
        <div class="mt-10">
          <span class="search__label">状态: </span>
          <el-select
            class="inline-16"
            size="small"
            v-model="status"
            placeholder="请选择核销单状态"
            @change="typeChange"
            clearable
          >
            <el-option label="新建" value="新建"></el-option>
            <el-option label="审核" value="审核"></el-option>
          </el-select>
        </div>
        <div class="mt-10">
          <label class="search__label" >单据日期:</label>
          <el-date-picker
              style="margin-right: 24px !important;"
              size="small"
              @change="selectChange"
              value-format="yyyy-MM-dd"
              v-model="dateSelect"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              clearable>
          </el-date-picker>
        </div>
      </template>
      <template v-slot:tbList="scope">
        <div v-if="scope.data.column.columnname == 'status'">
          <span style="color:#000000" v-if="scope.data.column.data[[scope.data.column.columnname]] == '新建'">{{scope.data.column.data[[scope.data.column.columnname]]}}</span>
          <span style="color:#52C41A" v-else-if="scope.data.column.data[[scope.data.column.columnname]] == '审核'">{{scope.data.column.data[[scope.data.column.columnname]]}}</span>
        </div>
        <div v-else-if="scope.data.column.columnname == 'writeoffamount'">
          <span>{{ tool.formatAmount(scope.data.column.data.writeoffamount,2) }}</span>
        </div>
        <div v-else-if="scope.data.column.columnname == 'unwriteoffamount'">
          <span>{{ tool.formatAmount(scope.data.column.data.unwriteoffamount,2) }}</span>
        </div>
        <div v-else>
          {{scope.data.column.data[[scope.data.column.columnname]]}}
        </div>
        <div v-if="!scope.data.column.data[[scope.data.column.columnname]] && scope.data.column.data[[scope.data.column.columnname]] !== 0">--</div>
      </template>
      <template v-slot:tbOpreation="scope">
      </template>
    </basicLayout>
  </div>
</template>

<script>
import { log } from '@antv/g2plot/lib/utils'
export default {
  data () {
    return {
      options:[],
      status:'',
      dateSelect:[]
    }
  },
  methods:{
    listData (data) {
      console.log(data);
      
    },
    typeChange () {
      this.$refs.basicLayout.param.content.where.status = this.status
      this.$refs.basicLayout.listData(this.$refs.basicLayout.param.content.pageNumber=1)
    },
    selectChange(){
      if (this.dateSelect !== '' && this.dateSelect !== null){
        this.$refs.basicLayout.param.content.pageNumber = 1
        this.$refs.basicLayout.param.content.where.begindate = this.dateSelect[0]
        this.$refs.basicLayout.param.content.where.enddate = this.dateSelect[1]
      }else {
        this.$refs.basicLayout.param.content.where.begindate = ''
        this.$refs.basicLayout.param.content.where.enddate = ''
      }
      this.$refs.basicLayout.listData()
    }
  }
}

</script>
<style>
</style>