<template>
  <div class="edit-add-detail">
    <div class="crumbs">
      <Breadcrumb
        :breadcrumbOpt="breadcrumbOpt"
        svg-name="#icon-solution"
        @breadcrumb-click="handleClose"
      />
    </div>
    <div class="common-page-shadow">
      <el-row class="common-table-container flex searchPanel">
        <el-col :span="24" class="common-table-wrapper">
          <!-- LJ：表格高度自适应需配合样式  btn-pagenation 有按钮有分页  btngroup只有按钮  pagenation只有分页 -->
          <div class="common-table-content btn-pagenation">
            <el-table
              :border="true"
              stripe
              fit
              size="mini"
              v-loading="tableLoading"
              ref="multipleSelection"
              :data="tableData"
              @selection-change="selectionChange"
            >
              <el-table-column type="selection" min-width="20%" align="center">
              </el-table-column>
              <el-table-column
                prop="date"
                min-width="10%"
                label="项目编号"
                align="center"
                resizable
              >
              </el-table-column>
              <el-table-column
                prop="name"
                show-overflow-tooltip
                min-width="10%"
                align="center"
                label="项目名称"
                resizable
              >
              </el-table-column>
              <el-table-column
                show-overflow-tooltip
                min-width="10%"
                align="center"
                label="费用类型"
                resizable
              >
                <template v-slot="{row}">
                  {{ row.expensesType == 0 ? '保证金' : '标书费' }}
                </template>
              </el-table-column>
              <el-table-column
                prop="number"
                show-overflow-tooltip
                min-width="10%"
                align="center"
                label="数量"
                resizable
              >
              </el-table-column>
              <el-table-column
                prop="amount"
                show-overflow-tooltip
                min-width="10%"
                align="center"
                label="金额"
                resizable
              >
              </el-table-column>
              <el-table-column
                prop="companyName"
                show-overflow-tooltip
                min-width="10%"
                align="center"
                label="总金额"
                resizable
              >
              </el-table-column>
            </el-table>
          </div>
          <div class="common-pagenation">
            <div class="common-total">
              <div class="text">
                总计: <span>￥{{ totalValue }}</span>
              </div>
              <div class="btn">
                <el-button type="primary" size="small" @click="open(row)"
                  >确定支付</el-button
                >
              </div>
            </div>
          </div>
        </el-col>
      </el-row>
    </div>
    <bankCard ref="child"></bankCard>
  </div>
</template>

<script>
import bankCard from './bankCard.vue'
import routerManagement from '@/api/BasicDataManagement/routerManagement.js'
import Breadcrumb from '@/components/Breadcrumb/index.vue'
export default {
  name: 'domesticDialog',
  components: {Breadcrumb, bankCard},
  props: {
    editData: Object
  },
  data() {
    return {
      totalValue: 0,
      breadcrumbOpt: [{breadcrumbName: '项目采购'}, {breadcrumbName: '结算'}],
      tableData: [],
      tableLoading: false,
      queryParam: {
        pageBean: {
          page: 1,
          pageSize: 20,
          total: 0
        }
      },
      querys: [
        {
          group: 'main',
          operation: 'EQUAL',
          parentGroup: '',
          property: 'BID_STATUS_',
          relation: 'AND',
          value: '3'
        },
        {
          group: 'main',
          operation: 'EQUAL',
          parentGroup: '',
          property: 'JOIN_STATUS_',
          relation: 'AND',
          value: '1'
        }
      ]
    }
  },
  created() {
    this.addModifyBtn()
    this.loadData()
  },
  mounted() {},
  methods: {
    open() {
      this.$refs.child.open() //访问银行卡组件弹窗
    },
    //勾选数据
    selectionChange(val) {
      this.totalValue = 0
      val.forEach(item => {
        this.totalValue += item.number * item.amount
      })
    },
    //获取记录表
    addModifyBtn() {
      console.log(this.$route.query.recordData)
    },
    // 关闭//面包屑点击
    handleClose() {
      this.$router.push({
        name: 'participateRegistration',
        params: {
          tabsActiveName: 'projectParticipate',
          pageBean: this.$route.query.pageBean
        }
      })
    },
    //获取数据
    loadData() {
      this.tableLoading = true
      this.queryParam.querys = []
      if (this.querys[0].value) {
        this.queryParam.querys.push(this.querys[0])
      }
      if (this.querys[1].value) {
        this.queryParam.querys.push(this.querys[1])
      }
      routerManagement.queryEventsList(this.queryParam).then(res => {
        if (res.data.state) {
          this.tableLoading = false
          this.tableData = res.data.value.rows
          this.queryParam.pageBean = {
            page: res.data.value.page,
            pageSize: res.data.value.pageSize,
            total: res.data.value.total
          }
        }
        console.log('返回的表格数据', this.tableData)
      })
    },
  }
}
</script>

<style lang="scss" scoped>
.common-page-shadow {
  width: 100%;
  height: calc(100% - 40px);
  box-sizing: border-box;
  margin-top: 10px;
  .common-search-container {
    height: 80px;
    div {
      display: flex;
      align-items: center;
    }
  }
  .common-table-container {
    height: 100%;
  }
  .common-table-content.btn-pagenation {
    height: calc(100% - 70px);
  }
}

.rows {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ebebeb;
  margin-bottom: 16px;
  padding: 10px 0;
  .rows-left {
    margin-right: 10px;
    .rows-hr {
      width: 3px;
      height: 18px;
      background-color: #0e6eff;
      border-radius: 2px;
    }
  }
  .rows-title {
    .text-overflow {
      width: 100%;
      font-size: 16px;
    }
  }
}
</style>
