<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-demo__rdaccountlog}">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item>
          <el-input v-model="dataForm.advertiserId" placeholder="广告主账号" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-date-picker
                  v-model="date"
                  type="datetimerange"
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  :default-time="['00:00:00', '23:59:59']"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  @change="getTimes">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">{{ $t('query') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button v-if="$hasPermission('sys:rdaccountlog:refresh')" type="primary" @click="refreshHandle()">刷新</el-button>
        </el-form-item>
<!--        <el-form-item>-->
<!--          <el-button type="info" @click="exportHandle()">{{ $t('export') }}</el-button>-->
<!--        </el-form-item>-->
<!--        <el-form-item>-->
<!--          <el-button v-if="$hasPermission('demo:rdaccountlog:save')" type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>-->
<!--        </el-form-item>-->
<!--        <el-form-item>-->
<!--          <el-button v-if="$hasPermission('demo:rdaccountlog:delete')" type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>-->
<!--        </el-form-item>-->
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
        <el-table-column prop="id" label="id" header-align="center" align="center"></el-table-column>
<!--        <el-table-column prop="advertPlatform" label="所属广告平台" header-align="center" align="center"></el-table-column>-->
        <el-table-column prop="advertiserId" label="广告主账号" header-align="center" align="center"></el-table-column>
        <el-table-column prop="transactionType" label="流水类型" header-align="center" align="center">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.transactionType === 'RECHARGE'" size="small">充值</el-tag>
            <el-tag v-if="scope.row.transactionType === 'TRANSFER'" size="small">转账</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="accountCreateTime" label="流水产生时间" header-align="center" align="center"></el-table-column>
        <el-table-column prop="amount" label="交易总金额(元)" header-align="center" align="center"></el-table-column>
<!--        <el-table-column prop="frozen" label="冻结总金额(元)" header-align="center" align="center"></el-table-column>-->
        <el-table-column prop="cash" label="现金总金额(元)" header-align="center" align="center"></el-table-column>
        <el-table-column prop="grantss" label="赠款总金额(元)" header-align="center" align="center"></el-table-column>
        <el-table-column prop="returnGoods" label="返货总金额(元)" header-align="center" align="center"></el-table-column>
        <el-table-column prop="transactionSeq" label="交易流水号" header-align="center" align="center"></el-table-column>
        <el-table-column prop="remitter" label="付款方" header-align="center" align="center"></el-table-column>
        <el-table-column prop="payee" label="收款方" header-align="center" align="center"></el-table-column>
        <el-table-column prop="dealbase" label="返点" header-align="center" align="center"></el-table-column>
<!--        <el-table-column prop="status" label="状态（开1、关0）" header-align="center" align="center"></el-table-column>-->
<!--        <el-table-column prop="createdBy" label="创建人" header-align="center" align="center"></el-table-column>-->
<!--        <el-table-column prop="updatedBy" label="修改人" header-align="center" align="center"></el-table-column>-->
<!--        <el-table-column prop="createTime" label="创建时间" header-align="center" align="center"></el-table-column>-->
<!--        <el-table-column prop="updateTime" label="修改时间" header-align="center" align="center"></el-table-column>-->
<!--        <el-table-column prop="deleteTime" label="删除时间" header-align="center" align="center"></el-table-column>-->
<!--        <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">-->
<!--          <template slot-scope="scope">-->
<!--            <el-button v-if="$hasPermission('demo:rdaccountlog:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>-->
<!--            <el-button v-if="$hasPermission('demo:rdaccountlog:delete')" type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>-->
<!--          </template>-->
<!--        </el-table-column>-->
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './rdaccountlog-add-or-update'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/sys/rdaccountlog/page',
        getDataListIsPage: true,
        exportURL: '/sys/rdaccountlog/export',
        deleteURL: '/sys/rdaccountlog',
        deleteIsBatch: true
      },
      date:'',
      dataForm: {
        id: '',
        advertiserId:'',
        accountCreateTimeStart:'',
        accountCreateTimeStart:''
      }
    }
  },
  components: {
    AddOrUpdate
  },
  methods: {
    //利⽤change事件监听表单内容变化，并将选中的值赋值给所需要的两个字段
    //⽀付时间戳设置
    getTimes() {
      if (this.date != null) {
        this.dataForm.accountCreateTimeStart = this.date[0]
        this.dataForm.accountCreateTimeEnd = this.date[1]
      }else{
        this.dataForm.accountCreateTimeStart =''
        this.dataForm.accountCreateTimeEnd = ''
      }
    },
    refreshHandle(){
      const loading = this.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)',
        target: document.querySelector('.div1')
      });
      this.$http.get(`/sys/rdaccountlog/refresh`).then(({data: res}) => {
        if (res.code !== 0) {
          loading.close();
          return this.$message.error(res.msg)
        }
        this.$message({
          message: this.$t('prompt.success'),
          type: '刷新成功',
          duration: 500,
          onClose: () => {
            loading.close();
            this.query()
          }
        })
      }).catch(() => {
      })
    }
  }
}
</script>
