wujingjing
2025-03-04 ce5d4a0d224aaab33b4d8ddd7b4af170882d406e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<template>
    <el-dialog
        class="limit-height"
        :destroy-on-close="true"
        v-model="dialogIsShow"
        width="70%"
        :close-on-click-modal="false"
        @closed="closeDialog"
    >
        <template #header>
            <div style="color: #fff">
                <SvgIcon name="ele-Document" :size="16" style="margin-right: 3px; display: inline; vertical-align: middle" />
                <span>查看业务表</span>
            </div>
        </template>
        <div class="w100 h100">
            <div class="h-full flex-column">
                <ColFilter class="flex-0 ml-auto mb-2" :column-list="tableCheckData" />
                <el-table v-loading="tableLoading" ref="draggableTableRef" class="flex-auto" border :data="tableData" highlight-current-row>
                    <el-table-column
                        v-for="item in visibleTableColumns"
                        :prop="item.name"
                        sortable
                        :key="item.name"
                        :label="item.title"
                        show-overflow-tooltip
                    >
                    </el-table-column>
                </el-table>
            </div>
        </div>
    </el-dialog>
</template>
 
<script setup lang="ts" name="BusinessTablePreview">
import type { PropType } from 'vue';
import { computed, ref, watch } from 'vue';
// import TableSearch from './search/index.vue';
import type { Attach } from '../hook/useAttach';
import ColFilter from '/@/components/table/colFilter/ColFilter.vue';
const dialogIsShow = defineModel({
    type: Boolean,
});
const props = defineProps({
    data: {
        type: Object as PropType<Attach>,
        default: () => {},
    },
});
const closeDialog = () => {
    dialogIsShow.value = false;
    tableData.value = [];
    tableColumns.value = [];
};
 
//#region ====================== 指标管理表格数据,table init ======================
const tableLoading = ref(false);
const tableData = ref([]);
 
const tableColumns = ref([]);
 
const tableCheckData = computed(() => {
    return tableColumns.value.map((item) => {
        return {
            prop: item.name,
            label: item.title,
            get isShow() {
                return item.isShow;
            },
            set isShow(value) {
                item.isShow = value;
            },
        };
    });
});
 
const visibleTableColumns = computed(() => {
    return tableColumns.value.filter((item) => item.isShow);
});
 
//#endregion
 
const getIndexMapItem = (columns) => {
    return new Map<number, any>(
        columns.map((item, index) => {
            return [index, item];
        })
    );
};
 
//#region ====================== 查询 ======================
 
const parseRecordData = (values, columns) => {
    const indexMapItem = getIndexMapItem(columns);
    return (values || []).map((item, index) => {
        const row = {} as any;
        item?.forEach((item, index) => {
            row[indexMapItem.get(index).name] = item;
        });
        return row;
    });
};
 
//#endregion
watch(
    () => dialogIsShow.value,
    (val) => {
        if (!val) return;
        tableColumns.value = (props.data?.model?.columns || []).map((item) => {
            return {
                name: item,
                title: item,
                isShow: true,
            };
        });
        tableData.value = parseRecordData(props.data?.model?.values || [], tableColumns.value);
    }
);
</script>
<style scoped lang="scss">
.set-permission {
    padding-block: 16px;
    padding-block-end: 0;
}
.set-form {
    display: block;
    box-sizing: border-box;
    height: 100%;
    padding-block: 16px;
    .set-form-item {
        font-weight: 500;
        color: #667085;
        font-size: 14px;
    }
}
 
:deep(.el-dialog__body) {
    height: calc(90vh - 111px) !important;
}
</style>
<style lang="scss">
.limit-height {
    .el-dialog__body {
        height: calc(90vh - 111px) !important;
    }
}
 
.yw-layout-main {
    .el-card__body {
        padding: 10px;
    }
}
</style>