<template>
  <div class="edit-add-detail">
    <div class="crumbs">
      <Breadcrumb
        :breadcrumbOpt="breadcrumbOpt"
        svg-name="#icon-audit"
        @breadcrumb-click="handleClose"
      />
    </div>
    <div class="common-page-shadow">
      <div class="common-search-container" ref="contentPanel">
        <el-form
          ref="form"
          :model="searchForm"
          label-position="right "
          :inline="true"
          type="flex"
          justify="left"
        >
          <el-form-item label="违约供应商">
            <el-input
              size="small"
              v-model="searchForm.vendorName"
              clearable
              placeholder="请输入违约供应商"
            ></el-input>
          </el-form-item>
        </el-form>
        <div>
          <el-button
            size="small"
            icon="el-icon-search"
            type="danger"
            class="btn btn-plus"
            @click="handleSearch"
          >
            搜索
          </el-button>
          <el-button
            size="small"
            icon="el-icon-refresh-right"
            class="btn btn-plus"
            @click="clearSearchForm"
          >
            重置
          </el-button>
        </div>
      </div>
      <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"
            >
              <el-table-column
                type="index"
                width="55"
                align="center"
                label="序号"
              >
              </el-table-column>
              <el-table-column
                align="center"
                prop="noticeCode"
                min-width="100"
                show-overflow-tooltip
                label="项目编号"
              ></el-table-column>
              <el-table-column
                align="center"
                prop="noticeTitle"
                min-width="100"
                show-overflow-tooltip
                label="项目名称"
              ></el-table-column>
              <el-table-column
                align="center"
                prop="matPlatcode"
                show-overflow-tooltip
                min-width="100"
                label="物料编号"
              ></el-table-column>
              <el-table-column
                align="center"
                prop="matName"
                show-overflow-tooltip
                min-width="100"
                label="物料名称"
              ></el-table-column>
              <el-table-column
                align="center"
                prop="matMaterial"
                min-width="100"
                show-overflow-tooltip
                label="物料牌号"
              ></el-table-column>
              <el-table-column
                align="center"
                prop="matSpec"
                show-overflow-tooltip
                min-width="100"
                label="规格型号"
              ></el-table-column>
              <el-table-column
                align="center"
                prop="matBaseExt"
                show-overflow-tooltip
                min-width="100"
                label="基础扩展"
              ></el-table-column>
              <el-table-column
                align="center"
                prop="matOtherExt"
                show-overflow-tooltip
                min-width="100"
                label="其他扩展"
              ></el-table-column>
              <el-table-column
                align="center"
                prop="num"
                min-width="100"
                show-overflow-tooltip
                label="违约数量"
              ></el-table-column>
              <el-table-column
                align="center"
                prop="matUnit"
                show-overflow-tooltip
                min-width="100"
                label="计量单位"
              ></el-table-column>
              <el-table-column
                align="center"
                prop="transactionPrice"
                show-overflow-tooltip
                min-width="100"
                label="单价(元)"
              ></el-table-column>
              <el-table-column
                align="center"
                prop="transactionAmount"
                min-width="100"
                show-overflow-tooltip
                label="金额(元)"
              ></el-table-column>
              <el-table-column
                align="center"
                prop="taxRate"
                show-overflow-tooltip
                min-width="100"
                label="税率(%)"
              ></el-table-column>
            </el-table>
          </div>
          <div class="common-pagenation">
            <el-pagination
              ref="paginationPanel"
              background
              :current-page="params.pageBean.page"
              :page-sizes="[20, 30, 40, 50]"
              :page-size="params.pageBean.pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="params.pageBean.total"
            >
            </el-pagination>
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import Breadcrumb from '@/components/Breadcrumb/index.vue'
export default {
  name: 'domesticDialog',
  components: {Breadcrumb},
  props: {
    editData: Object,
  },
  data() {
    return {
      breadcrumbOpt: [
        {breadcrumbName: '成交违约'},
        {breadcrumbName: '违约明细'},
      ],
      tableData: [],
      tableLoading: false,
      searchForm: {
        'vrId': '',
        'b.VENDOR_ID_': '',
      }, // 顶部搜索对象
      params: {
        pageBean: {
          page: 1,
          pageSize: 20,
          total: 0,
        },
        querys: [],
      },
      currentUser: {},
    }
  },
  created() {
    this.currentUser = JSON.parse(sessionStorage.getItem('currentUserDetail'))
    this.searchForm['vrId'] = this.$route.query.id
    this.handleSearch()
  },
  mounted() {},
  methods: {
    //分页查询
    loadData() {
      this.tableLoading = true
      this.$http
        .post(
          '${portal}/bizViolateRecordDetail/v1/page',
          this.params
        )
        .then((res) => {
          this.tableLoading = false
          if (res.data.state) {
            this.tableData = res.data.value.rows
            this.params.pageBean = {
              page: res.data.value.page,
              pageSize: res.data.value.pageSize,
              total: res.data.value.total,
            }
          }
        })
    },
    // 关闭//面包屑点击
    handleClose() {
      this.$router.push({
        name: 'defaultWinningBid',
        params: {
          tabsActiveName: 'defaultWinningBidGoods',
          pageBean: this.$route.query.pageBean,
        },
      })
    },
    //重置
    clearSearchForm() {
      this.searchForm = {
        'vrId': this.$route.query.id,
      }
      this.handleSearch()
    },
    // 顶部搜索
    handleSearch() {
      let obj = this.searchForm
      let querys = []
      for (let i in obj) {
        if (obj[i]) {
          querys.push({
            group: 'main',
            operation:
              i == 'vendorName' || i == 'code' || i == 'companyName'
                ? 'LIKE'
                : 'EQUAL',
            parentGroup: '',
            property: i,
            relation: 'AND',
            value: obj[i],
          })
        }
      }
      this.params.querys = querys
      this.loadData()
    },
    handleCurrentChange(page) {
      this.params.pageBean = {...this.params.pageBean, page}
      this.loadData()
    },
    handleSizeChange(pageSize) {
      this.params.pageBean = {...this.params.pageBean, pageSize}
      this.loadData()
    },
    getMethodauth(elAuth) {
      let allMethod = window.sessionStorage.allMethod
      let methodAuth = window.sessionStorage.methodAuth
      let allMethodArray = allMethod && allMethod.split(',')
      let methodAuthArray = methodAuth && methodAuth.split(',')
      // 无权限则隐藏按钮
      if (
        methodAuthArray &&
        methodAuthArray.includes(elAuth) &&
        allMethodArray &&
        allMethodArray.includes(elAuth)
      ) {
        return true
      } else {
        return false
      }
    },
  },
}
</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: calc(100% - 80px);
    .common-table-content {
      height: calc(100% - 60px);
    }
  }
}

.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>
