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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<template>
    <el-dialog :title="titleMap[mode]" v-model="visible" :width="600" destroy-on-close @closed="$emit('closed')">
        <p class="title-tip" v-if="isShowWrite">
            <el-icon><Warning /></el-icon>
            <span>关联后,企业微信的部门结构和成员同步给本系统。本系统企业组织架构将不再支持手动维护</span>
        </p>
        <el-form :model="addOssForm" :rules="addOssRules" :disabled="mode=='show'" ref="dialogForm" label-width="192px" label-position="center" v-if="isShowWrite">
            <el-row>
                <el-col :span="24">
                    <el-form-item label="企业CorpId" prop="wxCorpId">
                        <el-input v-model="addOssForm.wxCorpId" placeholder="请输入" clearable></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="AgentID" prop="wxAgentId">
                        <el-input v-model="addOssForm.wxAgentId" placeholder="请输入" clearable></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="应用的Secret" prop="wxAppSecret">
                        <el-input v-model="addOssForm.wxAppSecret" placeholder="请输入" clearable></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="通讯录的Secret" prop="wxBookSecret">
                        <el-input v-model="addOssForm.wxBookSecret" placeholder="请输入" clearable></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="回调配置Token" prop="wxCallbackToken">
                        <el-input v-model="addOssForm.wxCallbackToken" placeholder="请输入" clearable></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="回调配置EncodingAesKey" prop="wxAesKey">
                        <el-input v-model="addOssForm.wxAesKey" placeholder="请输入" clearable></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="回调配置域名" prop="wxDomain">
                        <el-input v-model="addOssForm.wxDomain" placeholder="请输入" clearable></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <div v-if="!isShowWrite">
            <p class="sync-res">
                <el-icon v-if="!userResult" class="cr"><CircleClose /></el-icon>
                <el-icon v-if="userResult" class="cg"><CircleCheck /></el-icon>
                <span>员工同步</span><span>{{userResult == false?"失败":"成功"}}</span>
            </p>
            <p class="sync-res">
                <el-icon v-if="!groupResult" class="cr"><CircleClose /></el-icon>
                <el-icon v-if="groupResult" class="cg"><CircleCheck /></el-icon>
                <span>部门同步</span><span>{{groupResult == false?"失败":"成功"}}</span>
            </p>
            <p class="sync-res">
                <el-icon v-if="!postResult" class="cr"><CircleClose /></el-icon>
                <el-icon v-if="postResult" class="cg"><CircleCheck /></el-icon>
                <span>岗位同步</span><span>{{postResult == false?"失败":"成功"}}</span>
            </p>
        </div>
        <template #footer>
            <el-button @click="visible=false" >关闭</el-button>
            <el-button v-if="mode!='show' && isShowWrite" type="primary" :loading="isSaveing" @click="ossSubmit()">保存</el-button>
        </template>
    </el-dialog>
</template>
 
<script>
    import UpToEnterprise from '@/views/userCenter/user/upToEnterprise.vue'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
    let icons = []
    for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
        icons.push(key)
    }
    export default {
        emits: ['success', 'closed'],
        data() {
            return {
                appType: "",
                userResult: false,
                groupResult: false,
                postResult: false,
                isShowWrite: true,
                addOssForm: {
                    wxCorpId: "",
                    wxAgentId: "",
                    wxAppSecret: "",
                    wxBookSecret: "",
                    wxCallbackToken: "",
                    wxAesKey: "",
                    wxDomain: ""
                },
                //验证规则
                addOssRules: {
                    wxCorpId:[{required: true, message: '请输入企业CorpId'}],
                    wxAgentId:[{required: true, message: '请输入AgentID'}],
                    wxAppSecret: [{required: true, message: '请输入应用的Secret'}],
                    wxBookSecret: [{required: true, message: '请输入通讯录的Secret'}],
                    wxCallbackToken: [{required: true, message: '请输入回调配置Token'}],
                    wxAesKey: [{required: true, message: '请输入回调配置EncodingAesKey'}],
                    wxDomain: [{required: true, message: '请输入回调配置域名'}]
                },
                value1: true,
                mode: "add",
                titleMap: {
                    add: '关联',
                    edit: '修改',
                    show: '查看',
                    end: '立即同步'
                },
                visible: false,
                isSaveing: false,
                //所需数据选项
                groups: [],
                groupsProps: {
                    value: "id",
                    multiple: true,
                    checkStrictly: true
                },
                depts: [],
                deptsProps: {
                    value: "id",
                    checkStrictly: true
                }
            }
        },
        components: {...ElementPlusIconsVue},
        mounted() {
        
        },
        methods: {
            //显示
            open(type,data,status,mode='add'){
                this.appType = type;
                this.mode = mode;
                this.visible = true;
                if(status == 'updata') {  //同步来的
                    this.mode = "end";
                    this.isShowWrite = false;
                    this.userResult = data.userResult;
                    this.groupResult = data.groupResult;
                    this.postResult = data.postResult;
                }
                if(status == 'add') {  //新增或编辑
                    data.forEach(item=> {
                        if(item.appType == type){
                            // 需要返显可放开
                            // if(type == 1) {
                            //     this.addOssForm = {
                            //         wxCorpId: item.wxCorpId,
                            //         wxAgentId: item.wxAgentId,
                            //         wxAppSecret: item.wxAppSecret,
                            //         wxBookSecret: item.wxBookSecret,
                            //         wxCallbackToken: item.wxCallbackToken,
                            //         wxAesKey: item.wxAesKey,
                            //         wxDomain: item.wxDomain
                            //     }
                            // }
                            // if(type == 2) {
                            //     this.addOssForm = {
                            //         wxCorpId: item.dingCorpId,
                            //         wxAgentId: item.dingAgentId,
                            //         wxAppSecret: item.dingAppKey,
                            //         wxBookSecret: item.dingAppSecret,
                            //         wxCallbackToken: item.dingCallbackToken,
                            //         wxAesKey: item.dingAesKey,
                            //         wxDomain: item.dingDomain
                            //     }
                            // }
                        }
                    })
                    this.isShowWrite = true;
                }
                return this
            },
            //表单提交方法
            ossSubmit(){
                var obj = {};
                obj.appType = this.appType;
                if(obj.appType == 1) {
                    obj.domain = this.addOssForm.wxDomain;
                    obj.wxAesKey = this.addOssForm.wxAesKey;
                    obj.wxAgentId = this.addOssForm.wxAgentId;
                    obj.wxAppSecret = this.addOssForm.wxAppSecret;
                    obj.wxBookSecret = this.addOssForm.wxBookSecret;
                    obj.wxCallbackToken = this.addOssForm.wxCallbackToken;
                    obj.wxCorpId = this.addOssForm.wxCorpId;
                    obj.wxDomain = this.addOssForm.wxDomain;
                    obj.domain = obj.wxDomain;
                    obj.wxid = "1788050081081860097";
                    obj.id = "1788050081081860097";
                }
                if(obj.appType == 2) {
                    obj.domain = this.addOssForm.wxDomain;
                    obj.dingAesKey = this.addOssForm.wxAesKey;
                    obj.dingAgentId = this.addOssForm.wxAgentId;
                    obj.dingAppKey = this.addOssForm.wxAppSecret;
                    obj.dingAppSecret = this.addOssForm.wxBookSecret;
                    obj.dingCallbackToken = this.addOssForm.wxCallbackToken;
                    obj.dingCorpId = this.addOssForm.wxCorpId;
                    obj.dingDomain = this.addOssForm.wxDomain;
                    obj.domain = this.addOssForm.wxDomain;
                    obj.dingid = "1787499893602787330";
                    obj.id = "1787499893602787330";
                }
                this.$refs.dialogForm.validate(async (valid) => {
                    if (valid) {
                        this.isSaveing = true;
                        this.$HTTP.post("/api/blade-sync/outer-app-config/submit",obj).then(res=> {
                            this.isSaveing = false;
                            if(res.code == 200) {
                                this.mode = "end";
                                this.isShowWrite = false;
                                this.userResult = res.data.userResult;
                                this.groupResult = res.data.groupResult;
                                this.postResult = res.data.postResult;
                                this.$emit('success', this.addOssForm, this.mode);
                                this.$message.success("操作成功");
                            }else {
                                this.$alert(res.message, "提示", {type: 'error'});
                            }
                        })
                    }else{
                        return false;
                    }
                })
            },
            //表单注入数据
            setData(data){
                //可以和上面一样单个注入,也可以像下面一样直接合并进去
                //Object.assign(this.addOssForm, data);
            }
        }
    }
</script>
 
<style>
.title-tip {
    padding: 0 24px;
    text-align: center;
    color: #ea3c4a;
    font-size: 12px;
    margin-bottom:20px;
}
.sync-res {
    text-align: center;
}
.sync-res .cr {
    color: red;
    margin-right: 8px;
}
.sync-res .cg {
    color: green;
    margin-right: 8px;
}
</style>