gaoshp
2024-11-03 3e091224ab26252d8624b42b461ba773ee8bee0f
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
<!--
 * @Date: 2024-06-23 09:25:40
 * @LastEditors: Sneed
 * @LastEditTime: 2024-06-23 19:43:23
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/console/basic-data/tpm-data1.vue
-->
<template>
    <div>
        <scTable :ref="'table' + key" @selection-change="handleSelectionChange" row-key="id" border :apiObj="apiObj"
            stripe @dataChange="dataChange">
            <el-table-column type="selection" width="55" />
            <el-table-column :prop="item.prop" :label="item.label" :key="item.prop" v-for="item in cols">
            </el-table-column>
            <el-table-column label="操作" fixed="right" align="left" width="160">
                <template #default="scope">
                    <el-button-group>
                        <el-button text type="primary" size="small"
                            @click="table_edit(scope.row, scope.$index)">编辑</el-button>
                        <el-popconfirm width="220" cancel-button-text="停用" confirm-button-text="删除"
                            title="删除数据会影响已关联的业务 ,若您想在已关联的业务中依然显示这些数据, 您可以选择 停用 操作。停用后此数据将不能再被新业务使用。"
                            @confirm="table_del([scope.row], '0')" @cancel="table_del([scope.row], '1')">
                            <template #reference>
                                <el-button type="danger" text size="small">删除</el-button>
                            </template>
                        </el-popconfirm>
                    </el-button-group>
                </template>
            </el-table-column>
        </scTable>
    </div>
</template>
 
<script>
export default {
    props: {
        key: {
            type: String
        },
        params: {
            type: Object,
            default() {
                return {
                    keyWord: '',
                    status: 1
                }
            }
        },
        cols: {
            type: Array,
            default() {
                return []
            }
        },
        apiObj: {
            type: Object,
            default() {
                return {}
            }
        }
    },
    data() {
        return {
            // apiObj: {
            //     get: async (data) => {
            //         let params = {
            //             ...data,
            //             ...this.params
            //         }
            //         return await this.$HTTP.get(`/api/smis/maintain-item/page`, {}, { params }).then(res => {
            //             res.data.records = res?.data?.records.map(v => {
            //                 return {
            //                     ...v,
            //                     statusName: v.status ? '启用' : '禁用'
            //                 }
            //             })
            //             return res
            //         })
            //     }
            // }
        }
    },
    methods: {
        query() {
            this.$refs?.[`table${this.key}`]?.reload()
        },
        handleSelectionChange(val) {
            this.$emit('selection-change', val)
        },
        dataChange() {
 
        },
        table_edit(row) {
            console.log(row, 'eeeeeee')
            this.$emit('edit', { ...row })
        },
        table_del(selection, type) {
            this.$emit('del', selection, type)
        }
    },
}
</script>
 
<style lang="scss" scoped></style>