#
Junjie
2024-01-08 8d530a2bc48f5f28937e0b4507b7deccf9e34e92
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>API开放平台</title>
    <link rel="stylesheet" href="../static/css/element.css">
    <link rel="stylesheet" href="../static/css/common.css">
    <script type="text/javascript" src="../static/js/jquery/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="../static/js/vue.min.js"></script>
    <script type="text/javascript" src="../static/js/showdown.min.js"></script>
    <script type="text/javascript" src="../static/js/common.js"></script>
    <script type="text/javascript" src="../static/js/element.js"></script>
</head>
<body>
    <div id="app">
        <div id="content"></div>
        <div class="slider">
            <div><el-button type="text" @click="switchPage('index.html')">规范说明</el-button></div>
            <el-divider></el-divider>
            <div><el-button type="text" @click="switchPage('reportCompleted.html')">订单完成上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportCancel.html')">订单取消上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportStock.html')">库存上报</el-button></div>
            <div><el-button type="text" @click="switchPage('reportApiManage.html')">上报API管理</el-button></div>
            <el-divider></el-divider>
            <div><el-button type="text" @click="switchPage('getOrderType.html')">获取订单类型</el-button></div>
            <div><el-button type="text" @click="switchPage('getOrderStatus.html')">获取订单状态列表</el-button></div>
            <div><el-button type="text" @click="switchPage('getOrderList.html')">获取订单列表</el-button></div>
            <div><el-button type="text" @click="switchPage('generateOrderPakIn.html')">生成入库订单</el-button></div>
            <div><el-button type="text" @click="switchPage('generateOrderPakOut.html')">生成出库订单</el-button></div>
            <div><el-button type="text" @click="switchPage('createMat.html')">添加物料信息</el-button></div>
            <el-divider></el-divider>
            <div><el-button type="text" @click="keyList()">密钥管理</el-button></div>
        </div>
 
        <el-dialog title="密钥管理" :visible.sync="keyTableVisible">
            <el-table :data="keyTableData" v-loading="loading">
                <el-table-column property="hostId$" label="仓库"></el-table-column>
                <el-table-column property="signKey" label="签名密钥" width="150"></el-table-column>
                <el-table-column property="appKey" label="接口请求密钥" width="250"></el-table-column>
                <el-table-column property="createTime$" label="时间" width="200"></el-table-column>
                <el-table-column label="操作" width="400">
                    <template slot-scope="scope">
                        <el-button size="mini" @click="generateSignKey(scope.row.hostId)">签名密钥</el-button>
                        <el-button size="mini" @click="generateAppKey(scope.row.hostId)">接口密钥</el-button>
                        <el-switch
                                v-model="scope.row.signStatus"
                                @change="switchChange(scope.row.hostId,scope.row.signStatus)"
                                active-text="开启签名"
                                inactive-text="关闭签名">
                        </el-switch>
                    </template>
                </el-table-column>
            </el-table>
        </el-dialog>
    </div>
 
    <script>
        showdown.setOption('tables', true);
        var converter = new showdown.Converter()
 
        var app = new Vue({
            el: '#app',
            data: {
                keyTableVisible: false,
                keyTableData: [],
                loading: true
            },
            created() {
                this.init()
            },
            methods: {
                init() {
                    this.introduceClick()
                },
                introduceClick() {
                    $.ajax({
                        url: "md/reportCompleted.md",
                        headers: {'token': localStorage.getItem('token')},
                        method: 'GET',
                        success: function (res) {
                            // $("#content").html(marked.parse(res))
                            // console.log(converter.makeHtml(res))
                            $("#content").html(converter.makeHtml(res))
                        }
                    });
                },
                keyList() {
                    let that = this
                    this.keyTableVisible = true
                    $.ajax({
                        url: baseUrl + "/hostKey/list/auth",
                        headers: {'token': localStorage.getItem('token')},
                        data: {},
                        dataType:'json',
                        contentType:'application/json;charset=UTF-8',
                        method: 'POST',
                        success: function (res) {
                            let tmp = []
                            res.data.forEach((item, index) => {
                                item.signStatus = item.signStatus == 1 ? true : false;
                                tmp.push(item)
                            });
                            that.keyTableData = tmp
                            that.loading = false
                        }
                    });
                },
                generateSignKey(hostId) {
                    let that = this
                    this.$confirm('此操作将覆盖原签名密钥, 是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        $.ajax({
                            url: baseUrl + "/hostKey/generateSignKey/auth",
                            headers: {'token': localStorage.getItem('token')},
                            data: {
                                hostId: hostId
                            },
                            dataType: 'json',
                            contentType: 'application/json;charset=UTF-8',
                            method: 'GET',
                            success: function (res) {
                                if (res.code === 200) {
                                    that.$message({
                                        type: 'success',
                                        message: '生成成功'
                                    });
 
                                    that.keyTableData.forEach((item, index) => {
                                        if (item.hostId == hostId) {
                                            item.signKey = res.data.signKey
                                        }
                                    });
                                } else {
                                    that.$message({
                                        type: 'error',
                                        message: res.msg
                                    });
                                }
                            }
                        });
                    }).catch(() => {
                        //取消
                    });
                },
                generateAppKey(hostId) {
                    let that = this
                    this.$confirm('此操作将覆盖原接口密钥, 是否继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        $.ajax({
                            url: baseUrl + "/hostKey/generateAppKey/auth",
                            headers: {'token': localStorage.getItem('token')},
                            data: {
                                hostId: hostId
                            },
                            dataType: 'json',
                            contentType: 'application/json;charset=UTF-8',
                            method: 'GET',
                            success: function (res) {
                                if (res.code === 200) {
                                    that.$message({
                                        type: 'success',
                                        message: '生成成功'
                                    });
 
                                    that.keyTableData.forEach((item, index) => {
                                        if (item.hostId == hostId) {
                                            item.appKey = res.data.appKey
                                        }
                                    });
                                } else {
                                    that.$message({
                                        type: 'error',
                                        message: res.msg
                                    });
                                }
                            }
                        });
                    }).catch(() => {
                        //取消
                    });
                },
                switchChange(hostId, signStatus) {
                    let that = this
                    //签名校验开关
                    $.ajax({
                        url: baseUrl + "/hostKey/switchSign/auth",
                        headers: {'token': localStorage.getItem('token')},
                        data: {
                            hostId: hostId,
                            signStatus: signStatus ? 1 : 0,
                        },
                        dataType: 'json',
                        contentType: 'application/json;charset=UTF-8',
                        method: 'GET',
                        success: function (res) {
                            if (res.code === 200) {
                                that.$message({
                                    type: 'success',
                                    message: '切换成功'
                                });
                            } else {
                                that.$message({
                                    type: 'error',
                                    message: res.msg
                                });
                            }
                        }
                    });
                },
                switchPage(url) {
                    location.href = url
                }
            }
        })
    </script>
</body>
</html>