<template>
  <div>
    <el-table v-loading="loading" :data="projectList">
      <el-table-column
        label="交易项目"
        align="center"
        prop="relationTransactionProjectId"
        :formatter="transactionProjectName"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="交易状态"
        align="center"
        prop="tradeStatus"
        :formatter="getTradeStatus"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="卖方"
        align="center"
        prop="applyDeptName"
        :show-overflow-tooltip="true"
      />
      <el-table-column label="申请人" align="center" prop="applyName" />
      <el-table-column label="申请时间" align="center" prop="createTime" width="150px"/>
      <el-table-column label="申报总价" align="center" prop="tradeTotal" />
      <el-table-column
        label="买方"
        align="center"
        prop="tradeDeptName"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="买方经办人"
        align="center"
        prop="tradeTransactorName"
        :show-overflow-tooltip="true"
      />
      <el-table-column label="交易评分" align="center" prop="tradeScore" />
      <el-table-column label="交易成交价" align="center" prop="dealPrice" />
      <el-table-column label="尾款" align="center" prop="pendingPayment" width="80"/>
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
<!--          <el-button-->
<!--            v-if="scope.row.tradeStatus == '0' || scope.row.tradeStatus == '4'"-->
<!--            size="mini"-->
<!--            type="text"-->
<!--            icon="el-icon-edit"-->
<!--            @click="handleUpdate(scope.row)"-->
<!--            v-hasPermi="['system:project:edit']"-->
<!--            >修改</el-button-->
<!--          >-->
          <OperatorButton
            operatorName="tradeDetail"
            :tradeInfo="scope.row"
            @getList="getList"
          />
          <el-button
            v-if="(scope.row.tradeStatus == '0' || scope.row.tradeStatus == '4') && scope.row.applyId == $store.state.user.userId"
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:project:remove']"
            >删除</el-button
          >
          <OperatorButton
            v-for="item in scope.row.operators"
            :key="item"
            :operatorName="item"
            :tradeInfo="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: {
    projectList: {
      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);
    },
  },
};
</script>

<style scoped></style>
