<template>
  <div class="system-user-container layout-padding">
    <el-card shadow="hover" class="layout-padding-auto">
      <div class="system-user-search mb15">
        <el-date-picker v-model="state.date" type="date" format="YYYY/MM/DD" value-format="YYYY-MM-DD"
          placeholder="请选择日期" />
        <el-button @click="getTableData" size="default" type="primary" class="ml10">
          <el-icon>
            <ele-Search />
          </el-icon>
          查询
        </el-button>
      </div>
      <el-table :data="state.tableData.data" v-loading="state.tableData.loading" style="width: 100%" border stripe
        :cell-style="{ textAlign: 'center' }" :header-cell-style="{ 'text-align': 'center' }">
        <el-table-column prop="date" label="日期">
        </el-table-column>
        <el-table-column prop="count" label="区县上传数量"></el-table-column>
        <el-table-column prop="saleCount" label="销售成交数"> </el-table-column>
        <el-table-column prop="saleResCount" label="销售住宅成交数"> </el-table-column>
        <el-table-column prop="saleArea" label="销售面积（㎡）">
          <template #default="scope">
            {{ proxy?.$method.numFormat(scope.row.saleArea) }}
          </template>
        </el-table-column>
        <el-table-column prop="saleResArea" label="销售住宅面积（㎡）">
          <template #default="scope">
            {{ proxy?.$method.numFormat(scope.row.saleResArea) }}
          </template>
        </el-table-column>
        <el-table-column prop="saleAmount" label="销售总价">
          <template #default="scope">
            {{ proxy?.$method.numFormat(scope.row.saleAmount) }}
          </template>
        </el-table-column>
        <el-table-column prop="saleResAmount" label="销售住宅总价">
          <template #default="scope">
            {{ proxy?.$method.numFormat(scope.row.saleResAmount) }}
          </template>
        </el-table-column>
        <el-table-column label="操作" show-overflow-tooltip width="100" fixed="right">
          <template #default="scope">
            <el-button size="small" @click="look(scope.row)" text type="primary">查看详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination @size-change="onHandleSizeChange" @current-change="onHandleCurrentChange" class="mt15"
        :pager-count="5" :page-sizes="[10, 20, 30]" v-model:current-page="state.tableData.param.pageNum" background
        v-model:page-size="state.tableData.param.pageSize" layout="total, sizes, prev, pager, next, jumper"
        :total="state.tableData.total">
      </el-pagination>
    </el-card>
  </div>
</template>

<script setup lang="ts" name="reportrundata">
import { defineAsyncComponent, reactive, onMounted, ref } from "vue";
import { ElMessageBox, ElMessage, ElNotification } from "element-plus";
import { getday } from "/@/api/report/day";
import { useCurrentInstance } from '/@/method/get'
const { proxy } = useCurrentInstance()
import { useRouter } from "vue-router";
let router = useRouter();

// 定义变量内容
const dialogConRef = ref();
// 定义变量内容
const state = reactive<any>({
  date: undefined,
  tableData: {
    data: [],
    total: 0,
    loading: false,
    param: {
      pageNum: 1,
      pageSize: 10,
    },
  },
});
const look = (row: any) => {
  router.push({
    path: '/report/dayDeatil',
    query: {
      id: row.id,
      tagsViewName: row.date + "详情"
    }
  });
}

// 初始化表格数据
const getTableData = async () => {
  state.tableData.loading = true;
  // 项目
  const data = await getday().getList({
    page: state.tableData.param.pageNum,
    limit: state.tableData.param.pageSize,
    date: state.date,
  });
  state.tableData.data = data.data;
  state.tableData.total = data.count;
  state.tableData.loading = false;
};
// 分页改变
const onHandleSizeChange = (val: number) => {
  state.tableData.param.pageSize = val;
  getTableData();
};

// 分页改变
const onHandleCurrentChange = (val: number) => {
  state.tableData.param.pageNum = val;
  getTableData();
};
// 页面加载时
onMounted(() => {
  getTableData();
});
</script>

<style scoped lang="scss">
.wgt {
  font-weight: bold;
}

.system-user-container {
  :deep(.el-card__body) {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: auto;

    .el-table {
      flex: 1;
    }
  }
}
</style>
