zhanbo.xu

feat: 新增API 权限配置

...@@ -5,7 +5,7 @@ VUE_APP_BASE_ENV = "dev" ...@@ -5,7 +5,7 @@ VUE_APP_BASE_ENV = "dev"
5 5
6 VUE_APP_Version = '1.0.0' 6 VUE_APP_Version = '1.0.0'
7 7
8 -VUE_APP_BASE_URL = 'http://101.132.100.41:7008/EcomExp' 8 +VUE_APP_BASE_URL = 'http://101.132.100.41:7001/EcomExp'
9 # FedEx 在线申报工具/开发环境 9 # FedEx 在线申报工具/开发环境
10 # http://101.132.100.41:7001/EcomExp 10 # http://101.132.100.41:7001/EcomExp
11 VUE_APP_BASE_API = /EcomExp 11 VUE_APP_BASE_API = /EcomExp
......
1 +import request from "@/utils/request";
2 +
3 +// 删除用户key
4 +// POST
5 +// /applyKey/deleteKey/{id}
6 +export function deleteKey(id) {
7 + return request({
8 + url: "/bus-customer/applyKey/deleteKey/" + id,
9 + method: "post",
10 + });
11 +}
12 +// 申请key
13 +// /applyKey/generateKey
14 +export function generateKey(params) {
15 + return request({
16 + url: `/bus-customer/applyKey/generateKey`,
17 + method: "post",
18 + data: params.toString(),
19 + headers: {
20 + "Content-Type": "application/x-www-form-urlencoded",
21 + },
22 + });
23 +}
24 +// 获取用户key列表
25 +// POST
26 +// /applyKey/queryKeyList
27 +export function queryKeyList(data) {
28 + return request({
29 + url: "/bus-customer/applyKey/queryKeyList",
30 + method: "post",
31 + data: data,
32 + });
33 +}
34 +// 修改用户key相关信息
35 +// POST
36 +// /applyKey/updateKeyInfo
37 +export function updateKeyInfo(data) {
38 + return request({
39 + url: "/bus-customer/applyKey/updateKeyInfo",
40 + method: "post",
41 + data: data,
42 + });
43 +}
1 +<template>
2 + <el-dialog
3 + class="entryDialog classCUploadDialog"
4 + :title="title"
5 + :visible.sync="outerVisible"
6 + :show-close="false"
7 + width="30%"
8 + :close-on-click-modal="false"
9 + v-loading="loadings.dialogLoading"
10 + @close="close(false)"
11 + >
12 + <div class="modelItem">
13 + <el-form
14 + class="fedexFormStyle"
15 + ref="formData"
16 + :model="formData"
17 + :rules="type == 'roleChange' ? {} : rules"
18 + label-position="top"
19 + :disabled="type == 'roleChange'"
20 + size="small"
21 + >
22 + <el-row :gutter="5">
23 + <!-- 用户ID -->
24 + <el-col :span="24">
25 + <Formitem label="用户ID" prop="userId" type="edit">
26 + <el-input
27 + type="text"
28 + class="inputShadow"
29 + id="inputInner-edit-userId"
30 + resize="none"
31 + v-model="formData.userId"
32 + clearable
33 + placeholder=""
34 + ></el-input>
35 + </Formitem>
36 + </el-col>
37 + <!-- key -->
38 + <!-- <el-col :span="12">
39 + <Formitem label="KEY" prop="key" type="edit">
40 + <el-input
41 + type="text"
42 + class="inputShadow"
43 + id="inputInner-edit-key"
44 + resize="none"
45 + v-model="formData.key"
46 + clearable
47 + placeholder=""
48 + ></el-input>
49 + </Formitem>
50 + </el-col> -->
51 + <!-- 说明 -->
52 + <el-col :span="24">
53 + <Formitem label="说明" prop="description" type="edit">
54 + <el-input
55 + type="text"
56 + class="inputShadow"
57 + id="inputInner-edit-description"
58 + resize="none"
59 + v-model="formData.description"
60 + clearable
61 + placeholder=""
62 + ></el-input>
63 + </Formitem>
64 + </el-col>
65 + </el-row>
66 + </el-form>
67 + </div>
68 + <div class="dialogOption entrySave">
69 + <el-button
70 + class="entrySaveButton"
71 + :disabled="loadings.submitLoading"
72 + @click="submit"
73 + >确 定</el-button
74 + >
75 + <el-button
76 + class="entrySaveButton"
77 + :disabled="loadings.uploadLoading"
78 + @click="close(false)"
79 + >关 闭</el-button
80 + >
81 + </div>
82 + </el-dialog>
83 +</template>
84 +
85 +<script>
86 +import { generateKey, updateKeyInfo } from "@/api/api-key.js";
87 +export default {
88 + props: {
89 + outerVisible: {
90 + type: Boolean,
91 + default: false,
92 + },
93 + title: {
94 + type: String,
95 + default: "新增密码机",
96 + },
97 + type: {
98 + type: String,
99 + default: "",
100 + },
101 + active: {
102 + type: Object,
103 + default: null,
104 + },
105 + },
106 + data() {
107 + return {
108 + formData: {
109 + description: "",
110 + userId: "",
111 + key: "",
112 + id: undefined,
113 + },
114 + rules: {
115 + key: [
116 + {
117 + required: true,
118 + trigger: "blur",
119 + message: "用户ID不能为空!",
120 + },
121 + ],
122 + userId: [
123 + {
124 + required: true,
125 + trigger: "blur",
126 + message: "KEY不能为空!",
127 + },
128 + ],
129 + },
130 + loadings: {
131 + dialogLoading: false,
132 + uploadLoading: false,
133 + submitLoading: false,
134 + },
135 + loadingText: "",
136 + };
137 + },
138 + watch: {
139 + outerVisible(val) {
140 + if (val) {
141 + this.loadings.dialogLoading = false;
142 + if (this.type == "update") {
143 + this.formData = this.active;
144 + }
145 + }
146 + },
147 + },
148 + methods: {
149 + //数据保存
150 + submit() {
151 + this.loadings.dialogLoading = true;
152 + let obj = {};
153 + if (this.type == "add") {
154 + this.$refs.formData.validate((valid) => {
155 + if (valid) {
156 + obj = this.formData;
157 + this.addApi(obj);
158 + } else {
159 + this.loadings.dialogLoading = false;
160 + }
161 + });
162 + } else if (this.type == "update") {
163 + this.$refs.formData.validate((valid) => {
164 + if (valid) {
165 + obj.description = this.formData.description;
166 + obj.userId = this.formData.userId;
167 + obj.key = this.formData.key;
168 + obj.id = this.formData.id;
169 + this.updateapi(obj);
170 + } else {
171 + this.loadings.dialogLoading = false;
172 + }
173 + });
174 + }
175 + },
176 + //新增
177 + addApi(val) {
178 + const { description = "", userId = "", key = "" } = val;
179 + const params = new URLSearchParams();
180 + params.append("description", description);
181 + params.append("userId", userId);
182 +
183 + generateKey(params)
184 + .then((res) => {
185 + if (res.code === "200") {
186 + this.msgSuccess(res.message);
187 + this.close(true);
188 + } else {
189 + this.alertWarningMsg(res.message);
190 + this.loadings.dialogLoading = false;
191 + }
192 + })
193 + .catch((err) => {
194 + console.log(err);
195 + this.loadings.dialogLoading = false;
196 + });
197 + },
198 + //修改
199 + updateapi(val) {
200 + updateKeyInfo(val)
201 + .then((res) => {
202 + if (res.code === "200") {
203 + this.msgSuccess(res.message);
204 + this.close(true);
205 + } else {
206 + this.alertWarningMsg(res.message);
207 + this.loadings.dialogLoading = false;
208 + }
209 + })
210 + .catch((err) => {
211 + console.log(err);
212 + this.loadings.dialogLoading = false;
213 + });
214 + },
215 + close(flag) {
216 + this.formData = {
217 + description: "",
218 + userId: "",
219 + key: "",
220 + };
221 + this.$emit("close", flag);
222 + },
223 + },
224 +};
225 +</script>
226 +
227 +<style lang="scss" scoped>
228 +@import "@/assets/styles/variables.scss";
229 +</style>
1 +<template>
2 + <div class="entrySreach">
3 + <el-form
4 + class="fedexFormStyle fedexformSreach fedexformSreachBottomBorder"
5 + ref="sreachForm"
6 + :model="sreachFormData"
7 + label-position="top"
8 + size="small"
9 + >
10 + <el-row class="row-border">
11 + <!-- 角色名称 -->
12 + <el-col :span="5">
13 + <Formitem label="用户ID" prop="userId">
14 + <el-input
15 + type="text"
16 + class="inputShadow"
17 + id="inputInner--userId"
18 + resize="none"
19 + v-model="sreachFormData.userId"
20 + clearable
21 + placeholder=""
22 + ></el-input>
23 + </Formitem>
24 + </el-col>
25 +
26 + <el-col :span="2">
27 + <el-form-item class="textCenter">
28 + <el-button
29 + class="entrySreachButton"
30 + type="text"
31 + icon="el-icon-search"
32 + :loading="loadings.searchLoading"
33 + @click="search(0)"
34 + ></el-button>
35 + </el-form-item>
36 + </el-col>
37 + <el-col :span="2">
38 + <!-- 清空查询条件-->
39 + <el-form-item class="textLeft textCenter">
40 + <el-button
41 + type="text"
42 + size="small"
43 + icon="el-icon-refresh"
44 + @click="clear"
45 + >
46 + 重置
47 + </el-button>
48 + </el-form-item>
49 + </el-col>
50 + </el-row>
51 + </el-form>
52 + <div class="optionButton">
53 + <el-button
54 + class="entrySaveButton"
55 + icon="el-icon-plus"
56 + size="small"
57 + @click="addcipherMachine"
58 + >
59 + 新 增
60 + </el-button>
61 + </div>
62 + <Table
63 + class="fedexDetialTable fedexSreachTable"
64 + ref="entryTable"
65 + :data="tableData"
66 + :headerData="headerData"
67 + :maxHeight="tableMaxheight"
68 + :border="true"
69 + :pagination="true"
70 + :order="true"
71 + noLabel="序号"
72 + :loading="loadings.searchLoading"
73 + :page="page.pageIndex"
74 + :totalCount="page.total"
75 + @sizeChange="sizeChange"
76 + @currentChange="currentChange"
77 + :selection="false"
78 + :selectFixed="false"
79 + :rowSelectDataType="false"
80 + >
81 + <template v-slot:key="scope">
82 + <template v-if="!scope.row.show">
83 + {{ scope.row.key.replace(/(?<=.{4}).(?=.{4})/g, "*") }}
84 + <span style="margin-left: 8px; cursor: pointer"" @click="scope.row.show = true">
85 + <svg-icon
86 + class="el-icon-user-solid"
87 + icon-class="eye-open"
88 + ></svg-icon
89 + ></span>
90 + </template>
91 + <template v-else
92 + >{{ scope.row.noKey }}
93 + <span
94 + style="margin-left: 8px; cursor: pointer"
95 + @click="scope.row.show = false"
96 + >
97 + <svg-icon class="el-icon-user-solid" icon-class="eye"></svg-icon
98 + ></span>
99 + </template>
100 + </template>
101 + <template slot="optionColumn">
102 + <el-table-column align="left" label="操作" width="100">
103 + <template slot-scope="scope">
104 + <el-button type="text" @click="update(scope.row)"> 修改 </el-button>
105 + <el-button type="text" @click="deleteRow(scope.row)">
106 + 删除
107 + </el-button>
108 + </template>
109 + </el-table-column>
110 + </template>
111 + </Table>
112 + <DialogVue
113 + :outerVisible="outerVisible"
114 + :title="dialogTitle"
115 + :type="editType"
116 + :active="activeData"
117 + @close="dialogClose"
118 + />
119 + </div>
120 +</template>
121 +
122 +<script>
123 +import { queryKeyList, deleteKey } from "@/api/api-key.js";
124 +import DialogVue from "./dialog.vue";
125 +export default {
126 + name: "ApiKey",
127 + components: {
128 + DialogVue,
129 + },
130 + data() {
131 + return {
132 + sreachFormData: {
133 + userId: "",
134 + },
135 + page: {
136 + pageIndex: 1,
137 + pageSize: 20,
138 + total: 0,
139 + },
140 + activeData: null,
141 + tableData: [], // 用户ID KEY 说明 操作(新增、删除、修改) key 控制显示,点击眼睛可查看全部
142 + headerData: [
143 + {
144 + name: "用户ID",
145 + value: "userId",
146 + width: "",
147 + align: "left",
148 + },
149 + {
150 + name: "KEY",
151 + value: "key",
152 + width: "",
153 + align: "left",
154 + slot: true,
155 + },
156 + {
157 + name: "说明",
158 + value: "description",
159 + width: "",
160 + align: "left",
161 + },
162 + ],
163 + loadings: {
164 + searchLoading: false,
165 + },
166 + tableMaxheight: null,
167 + outerVisible: false,
168 + dialogTitle: "",
169 + editType: "",
170 + };
171 + },
172 + created() {
173 + this.search(0);
174 + },
175 + mounted() {
176 + this.tableMaxheight = window.innerHeight - 300;
177 + },
178 + methods: {
179 + //查询
180 +
181 + search(val) {
182 + this.loadings.searchLoading = true;
183 + if (val == 0) {
184 + this.page.pageIndex = 1;
185 + }
186 + let obj = this.sreachFormData;
187 + obj.pageIndex = this.page.pageIndex;
188 + obj.pageSize = this.page.pageSize;
189 +
190 + queryKeyList(obj)
191 + .then((res) => {
192 + if (res.code === "200") {
193 + this.page.total = res.data.totalItems;
194 + this.tableData = res.data.value.map((item, index) => {
195 + item.index = index;
196 + item.noKey = item.key;
197 + item.show = false;
198 + return item;
199 + });
200 + } else {
201 + this.alertWarningMsg(res.message);
202 + }
203 + this.loadings.searchLoading = false;
204 + })
205 + .catch((err) => {
206 + console.log(err);
207 + this.loadings.searchLoading = false;
208 + });
209 + },
210 + addcipherMachine() {
211 + this.dialogTitle = "新增";
212 + this.editType = "add";
213 + this.outerVisible = true;
214 + },
215 + update(val) {
216 + this.dialogTitle = "修改";
217 + this.editType = "update";
218 + this.outerVisible = true;
219 + this.activeData = val;
220 + },
221 + deleteRow(row) {
222 +
223 + this.$confirm("是否确认删除?", "提示", {
224 + confirmButtonText: "确定",
225 + cancelButtonText: "取消",
226 + type: "warning",
227 + })
228 + .then(() => {
229 + deleteKey(row.id).then((res) => {
230 + if (+res.code === 200) {
231 + this.alertSuccessMsg(res.message);
232 + this.search(0);
233 + } else {
234 + this.alertWarningMsg(res.message);
235 + }
236 + });
237 + })
238 + .catch((e) => {
239 + console.log(e);
240 + });
241 + },
242 + dialogClose(flag = false) {
243 + this.outerVisible = false;
244 + this.activeData = null;
245 + if (flag) {
246 + this.search(0);
247 + }
248 + },
249 + //分页
250 + currentChange(val) {
251 + this.page.pageIndex = val.page;
252 + this.search(1);
253 + },
254 + sizeChange(val) {
255 + this.page.pageSize = val;
256 + this.search(1);
257 + },
258 + input() {
259 + this.$forceUpdate();
260 + },
261 + dateChange(val) {
262 + if (val == "" || val == null) {
263 + this.$nextTick(() => {
264 + this.sreachFormData.creationTime = [];
265 + });
266 + }
267 + },
268 + clear() {
269 + this.sreachFormData = {
270 + userId: "",
271 + };
272 + },
273 + },
274 +};
275 +</script>
276 +
277 +<style scoped lang="scss">
278 +@import "@/assets/styles/variables.scss";
279 +.entrySreach {
280 + height: 100%;
281 + background-color: $menuLightBg;
282 +
283 + .entrySreachButton {
284 + display: inline-block;
285 + font-size: 20px;
286 + color: $fedexButton !important;
287 + }
288 +
289 + .optionButton {
290 + padding: 10px;
291 + text-align: left;
292 +
293 + .el-button {
294 + color: $fedexButton;
295 + border-color: $fedexButton !important;
296 +
297 + svg {
298 + display: inline-block;
299 + margin-right: 5px;
300 + fill: $fedexButton;
301 + }
302 + }
303 +
304 + .entrySaveButton:hover,
305 + .entrySaveButton:focus {
306 + color: $menuLightBg !important;
307 + background-color: $fedexButton !important;
308 + }
309 + }
310 +}
311 +
312 +.texttareaTip {
313 + position: absolute;
314 + top: 52%;
315 + right: 20px;
316 + transform: translate(0, -50%);
317 + z-index: 10;
318 +}
319 +</style>