gaoshp
2024-11-19 f29900986f01cf5d39b5755cec674825cef27961
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!--
 * @Author: lzhe lzhe@example.com
 * @Date: 2024-03-26 10:28:33
 * @LastEditors: lzhe lzhe@example.com
 * @LastEditTime: 2024-05-11 11:31:56
 * @FilePath: /smart-web/src/views/master/person/main/index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
    <div class="aposcope-main">
        <div class="debugging">
            <el-button type="primary" plain style="width: 80px;" @click="debugerBtn">调试</el-button>
        </div>
        <div class="conList" v-for="item in tableData">
            <div class="conTop">
                <span class="titile">{{item.name}}</span>
            </div>
            <div class="conBottom" v-if="item.configEntity != null">
                <div class="first">
                    <div>{{item.id == "internalMessage"?"站内信配置":"配置名称"}}</div>
                </div> 
                <div class="second">
                    <div>{{item.pname}}</div>
                </div>
                <div class="thrid" v-if="item.id != 'internalMessage'">
                    <span @click="table_edit(item, index ,2)"><el-icon><EditPen /></el-icon>编辑</span>
                    <span @click="table_del(item,index)"><el-icon><Delete /></el-icon>删除</span>
                </div>
            </div>
            <div class="conBottom" v-if="item.configEntity == null">
                <el-button type="primary" plain style="margin-left: 20px;" @click="table_edit(item, index ,1)">新增配置</el-button>
            </div>
        </div>
    </div>
    <save-dialog v-if="dialog.save" ref="saveDialog" @success="addconfigSuccess" @closed="dialog.save=false"></save-dialog>
    <save-debug v-if="dialog.debugging" ref="saveDebugging" @success="adddebugSuccess" @closed="dialog.debugging=false"></save-debug>
</template>
<script>
    import * as ElementPlusIconsVue from '@element-plus/icons-vue'
    let icons = []
    for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
        icons.push(key)
    }
    import saveDialog from './editconfiguration'
    import saveDebug from './sendDebug'
    export default {
        name: "configuration",
        data(){
            return {
                dialog: {
                    save: false,
                    debugging: false
                },
                tableData: []
            }
        },
        created(){
            
        },
        mounted(){
            this.getConfiguration();
        },
        components: {
            ...ElementPlusIconsVue,saveDialog,saveDebug
        },
        methods: {
            table_del(item,index) {
                this.$confirm(`确定将选择数据删除?`, '', {
                    type: 'warning'
                }).then(() => {
                    this.$HTTP.delete(`/api/blade-notify/notifier/config/${item.configEntity.id}`).then(res=> {
                        if(res.code == 200) {
                            this.getConfiguration();
                        }else {
                            this.$message.error(res.msg);
                        }
                    })
                }).catch(() => {
 
                })
            },
            table_edit(row,index,type){
                if(row.name == "钉钉") {
                    var url = `/api/blade-notify/notifier/config/dingTalk/dingTalkMessage/metadata`;
                }else if(row.name == "企业微信") {
                    var url = `/api/blade-notify/notifier/config/weiXinQY/qyTextMessage/metadata`;
                }else if(row.name == "短信") {
                    var url = `/api/blade-notify/notifier/config/sms/aliyunSms/metadata`;
                }else if(row.name == "邮件") {
                    var url = `/api/blade-notify/notifier/config/email/embedded/metadata`;
                }
                this.dialog.save = true
                this.$HTTP.get(url).then(res=> {
                    if(res.code == 200) {
                        this.dialog.save = true;
                        this.$nextTick(() => {
                            var obj = Object.assign(res.data,row);
                            if(type == 1) {
                                this.$refs.saveDialog.open('add',obj);
                            }else if(type == 2) {  //编辑
                                this.$refs.saveDialog.open('edit',{}).setData(obj);
                            }
                        })
                    }
                })
            },
            debugerBtn() {
                this.dialog.debugging = true;
                this.$nextTick(() => {
                    this.$refs.saveDebugging.open(this.tableData);
                })
            },
            getConfiguration() {
                this.$HTTP.get(`/api/blade-notify/notifier/config/service-list`).then(res=> {
                    if(res.code == 200) {
                        res.data.forEach(item=> {
                            if(item.configEntity != null) {
                                item.pname = item.configEntity.name;
                            }else {
                                item.pname = "";
                            }
                        })
                        this.tableData = res.data;
                    }
                })
            },
            addconfigSuccess() {
                this.getConfiguration();
            },
            adddebugSuccess() {
 
            }
        }
    }
</script>
<style scoped>
.aposcope-main {
    min-height: 100%;
    margin: 8px;
    background-color: #fff;
    padding-top: 20px;
    padding-bottom: 20px;
}
.conList {
    margin: 0 16px 24px 16px;
    border-radius: 2px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .16);
    padding: 23px 0 15px 16px;
    box-sizing: border-box;
    height: 126px;
    width: 47%;
    position: relative;
    float: left;
}
.conTop {
    font-size: 18px;
}
.conBottom {
    display: flex;
    margin-top: 20px;
    position: absolute;
    width: 100%;
    bottom: 20px;
    left:0;
}
.conList .conBottom .first {
    width: 20%;
    padding-left: 30px;
}
.conList .conBottom div {
    font-weight: 400;
    font-size: 16px;
    text-align: left;
    color: #333;
}
.conList .conBottom .second {
    width: 60%;
    justify-content: flex-start;
}
.conList .conBottom .thrid {
    width: 20%;
    cursor: pointer;
}
.conList .conBottom .thrid span:nth-child(1) {
    margin-right: 16px;
}
.debugging {
    text-align: right;
    margin-bottom: 20px;
    margin-right: 30px;
}
</style>