| <!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> | 
|             <div><el-button type="text" @click="switchPage('default.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/generateOrderPakIn.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> |