<template>
  <div>
    <div style="margin: 10px 0; display: flex; align-items: center">
      <el-input
        class="input_content"
        placeholder="请输入内容"
        v-model="sourceList.pagination.keyword"
        style="width: 90%"
        clearable
        size="small"
      ></el-input>
      <div style="text-align: center; width: 10%">
        <el-icon style="cursor: pointer" @click="getData"><Search /></el-icon>
      </div>
    </div>
    <el-table
      :data="sourceList.data"
      style="width: 100%; margin-top: 10px"
      v-loading="loading"
      :height="tableHeight"
    >
      <el-table-column
        prop="buyCorporationName"
        label="客户"
        min-width="120"
        fixed="left"
      />
      <el-table-column prop="code" label="主合同号" width="100" />
      <el-table-column prop="amount" label="货运" min-width="150">
        <template #default="{ row }">
          <div style="color: #409eff" v-if="row.acceptCode">
            {{ row.acceptCarriage }} ({{ row.acceptCode }})
          </div>
        </template>
      </el-table-column>
      <!-- <el-table-column label="操作" width="60" fixed="right" align="center">
        <template #default="{ row }">
          <el-button type="primary" text
            ><i class="iconfont icon-iconm_wofqd"></i
          ></el-button>
        </template>
      </el-table-column> -->
    </el-table>
    <el-pagination
      style="margin-top: 10px"
      v-model:current-page="sourceList.pagination.pageNum"
      :page-size="10"
      layout="total, prev, pager, next"
      :total="sourceList.pagination.total"
      prev-text="上一页"
      next-text="下一页"
      @current-change="handleCurrentChange"
    />
  </div>
</template>
  
<script setup>
const tableHeight = ref(0);
const getTableHeight = () => {
  tableHeight.value = window.innerHeight - 209;
};
getTableHeight();
window.addEventListener("resize", () => {
  getTableHeight();
});
const loading = ref(false);
const sourceList = ref({
  data: [],
  pagination: {
    total: 300,
    pageNum: 1,
    pageSize: 10,
  },
});
const { proxy } = getCurrentInstance();
const getData = () => {
  loading.value = true;
  proxy.post("/documents/page", sourceList.value.pagination).then((res) => {
    sourceList.value.data = res.rows;
    sourceList.value.pagination.total = res.total;
    setTimeout(() => {
      loading.value = false;
    }, 200);
  });
};
const handleCurrentChange = (val) => {
  sourceList.value.pagination.pageNum = val;
  getData();
};
getData();
onMounted(() => {});
</script>
  
<style lang="scss" scoped>
* {
  font-size: 12px;
}
.el-button {
  padding: 0px;
}
.btn {
  width: 100%;
  border-radius: 10px;
  padding: 6px 10px;
  height: 24px;
}
.el-pagination {
  padding-left: 30px;
}
:deep(.el-pagination button, .el-pager li) {
  font-size: 12px;
}
:deep(.el-table .el-table__cell) {
  padding: 2px 0px;
}
</style>