123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <!--
- * @Author: your name
- * @Date: 2024-10-28 16:46:38
- * @LastEditTime: 2024-11-14 15:55:59
- * @LastEditors: bogon
- * @Description: In User Settings Edit
- * @FilePath: /performance-test/src/views/performance/components/custonAsCom/dataTable.vue
- -->
- <template>
- <div class="dataTableContent" v-loading="loading">
- <el-tabs
- v-if="tabData.length > 0"
- v-model="activeName"
- @tab-click="handleClick"
- class="tabsBox"
- >
- <template v-for="(tabItem, ind) in tabData">
- <el-tab-pane
- :label="tabItem.filename"
- :name="String(tabItem.filename + tabItem.fileId)"
- :key="tabItem.fileData + ind + 'tabPane'"
- >
- <el-row
- type="flex"
- class="row-bg"
- justify="end"
- :key="tabItem.filename + ind + 'row'"
- >
- <el-button type="primary" @click="handleEditTable(tabItem.fileId)"
- >编辑</el-button
- >
- </el-row>
- <template v-if="tabItem.fileData && tabItem.fileData.length > 0">
- <el-table
- :data="tabItem.fileData"
- border
- height="600"
- style="width: 100%"
- :key="ind + tabItem.fileData"
- >
- <el-table-column
- :width="
- Object.keys(tabItem.fileData[0]).length > 6 ? 200 : null
- "
- v-for="(tableTitle, index) in Object.keys(tabItem.fileData[0])"
- :key="index + 'title'"
- :prop="tableTitle"
- :label="tableTitle"
- >
- </el-table-column>
- </el-table>
- </template>
- <template v-else>
- <el-empty :image-size="200" description="数据正在计算"></el-empty>
- </template>
- </el-tab-pane>
- </template>
- </el-tabs>
- <el-empty v-else :image-size="200"></el-empty>
- </div>
- </template>
- <script>
- import {
- getDataFromIndexedDB,
- checkObjectStoreExists,
- } from "@/utils/indexedDb";
- import { mapMutations, mapState } from "vuex";
- export default {
- data() {
- return {
- activeName: "",
- tabData: [],
- tableData: [],
- loading: true,
- };
- },
- // computed: {
- // ...mapState("dragChart", {
- // triggerGetData: "triggerGetData",
- // }),
- // },
- // watch: {
- // triggerGetData: function (newVal) {
- // if (newVal) {
- // console.log(newVal, "newVal dataTable");
- // this.setTriggerGetData(false);
- // this.getIndexDbData();
- // // 重置 triggerGetData 状态为 false
- // }
- // },
- // },
- mounted() {
- //判断indexedDb中是否存在这个数据表
- checkObjectStoreExists("FileDataDB", "files")
- .then((exists) => {
- if (exists) {
- console.log("对象存储 'files' 存在!");
- this.getIndexDbData();
- } else {
- this.loading = false;
- console.log("对象存储 'files' 不存在!");
- }
- })
- .catch((error) => {
- console.error("检查对象存储时出错:", error);
- });
- },
- methods: {
- ...mapMutations("dragChart", ["setTriggerGetData"]),
- async getIndexDbData() {
- // this.loading = true;
- console.log("触发了这个事件");
- const jsonData = await getDataFromIndexedDB();
- this.tabData = jsonData;
- console.log(jsonData, "jsonData dataTable");
- this.activeName =
- jsonData &&
- jsonData[0] &&
- String(jsonData[0].filename + jsonData[0].fileId);
- this.loading = false;
- },
- handleClick(tab, event) {},
- handleEditTable(id) {
- this.$router.push({
- path: "/home/performance/luckySheet",
- query: { id },
- });
- },
- },
- };
- </script>
- <style scoped lang="scss">
- .dataTableContent {
- .tabsBox {
- margin: 0 15px;
- ::v-deep .el-tabs__item {
- padding: 0 20px !important;
- }
- .row-bg {
- margin-bottom: 10px;
- }
- }
- }
- </style>
|