<template>
  <div>
    <el-table v-loading="loading" :data="creditList">
      <el-table-column label="借贷部门" align="center" prop="debitDeptName" :show-overflow-tooltip="true" width="150"/>
      <el-table-column label="经办人" align="center" prop="operatorName" />
      <el-table-column label="出借部门" align="center" prop="lendDeptName" :show-overflow-tooltip="true" width="150"/>
      <el-table-column label="登记日期" align="center" prop="registerTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.registerTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="使用说明" align="center" prop="useDescribe" :show-overflow-tooltip="true"/>
      <el-table-column label="使用人" align="center" prop="useName" />
      <el-table-column label="小写合计" align="center" prop="littleTotal" />
      <el-table-column label="计息日" align="center" prop="sumInterestDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.sumInterestDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="预计还款日" align="center" prop="expectedRepaymentDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.expectedRepaymentDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="借贷状态" align="center" prop="debitStatus" :formatter="debitStatusFormatter" :show-overflow-tooltip="true"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
        <template slot-scope="scope">
          <!-- <el-button
             size="mini"
             type="text"
             icon="el-icon-edit"
             @click="handleUpdate(scope.row)"
             v-hasPermi="['system:credit:edit']"
           >修改</el-button>-->
          <OperatorButton
            operatorName="debitDetail"
            :debitInfo="scope.row"
            @getList="getList"
          />
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:credit:remove']"
            v-if="(scope.row.debitStatus == '0' || scope.row.debitStatus == '4') && scope.row.operatorId == $store.state.user.userId"
          >删除</el-button>
          <OperatorButton
            v-for="item in scope.row.operators"
            :key="item"
            :operatorName="item"
            :debitInfo="scope.row"
            @getList="getList"
          />
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import OperatorButton from "./OperatorButton";
export default {
  name: "table-list",
  props: {
    creditList: {
      type: Array,
    },
    queryParams: {
      type: Object,
    },
    total: {
      type: Number,
    },
    loading: {
      type: Boolean,
    },
  },
  components: {
    OperatorButton,
  },
  methods: {
    getList(value) {
      console.log(value);
      this.$emit("getList", value);
    },
    //获取项目名称
    transactionProjectName(row) {
      let project = this.$parent.$parent.transactionProjects.find(
        (item) => item.transactionProjectId == row.relationTransactionProjectId
      );
      if (project) {
        return project.transactionProjectName;
      }
      return "-";
    },
    //获取交易状态
    getTradeStatus(row) {
      return this.selectDictLabel(
        this.$parent.$parent.transactionProjectStatus,
        row.tradeStatus
      );
    },
    handleUpdate(row) {
      this.$parent.$parent.handleUpdate(row);
    },
    handleDelete(row) {
      this.$parent.$parent.handleDelete(row);
    },
    debitStatusFormatter(row){
      return this.selectDictLabel(
        this.$parent.$parent.debitStatusList,
        row.debitStatus
      );
    }
  },
};
</script>

<style scoped></style>
