|
|
@@ -0,0 +1,117 @@
|
|
|
+<template>
|
|
|
+ <div class="system_config">
|
|
|
+ <MenuPage cur-key="baiduDict" />
|
|
|
+ <div class="btn-box">
|
|
|
+ <el-button type="primary" :loading="refresh_loading" @click="getInfo">刷新</el-button>
|
|
|
+ <el-button type="primary" :loading="loading" @click="onSubmit">应用</el-button>
|
|
|
+ </div>
|
|
|
+ <el-form ref="configForm" :model="configForm" label-width="110px" :rules="rules" class="config-form">
|
|
|
+ <el-form-item label="键值(APIKEY)" prop="api_key">
|
|
|
+ <el-input
|
|
|
+ v-model="configForm.api_key"
|
|
|
+ autocomplete="off"
|
|
|
+ placeholder="请输入应用接口键值(APIKEY)"
|
|
|
+ maxlength="100"
|
|
|
+ @blur="handleTrim('configForm', 'api_key')"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="密钥" prop="secret_key">
|
|
|
+ <el-input
|
|
|
+ v-model="configForm.secret_key"
|
|
|
+ autocomplete="off"
|
|
|
+ placeholder="请输入密钥"
|
|
|
+ maxlength="200"
|
|
|
+ @blur="handleTrim('configForm', 'secret_key')"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { getSysConfigBaiduDict, setSysConfigBaiduDict } from '@/api/user';
|
|
|
+import MenuPage from '../common/menu.vue';
|
|
|
+export default {
|
|
|
+ name: 'BaiduDictConfig',
|
|
|
+ components: { MenuPage },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ configForm: {
|
|
|
+ api_key: '',
|
|
|
+ secret_key: '',
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ api_key: [{ required: true, message: '请输入应用接口键值(APIKEY)', trigger: 'blur' }],
|
|
|
+ secret_key: [{ required: true, message: '请输入密钥', trigger: 'blur' }],
|
|
|
+ },
|
|
|
+ loading: false,
|
|
|
+ refresh_loading: false,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getInfo();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 去掉前后空格
|
|
|
+ handleTrim(form, fild) {
|
|
|
+ this[form][fild] = this[form][fild].trim();
|
|
|
+ },
|
|
|
+ getInfo() {
|
|
|
+ this.refresh_loading = true;
|
|
|
+ getSysConfigBaiduDict()
|
|
|
+ .then((res) => {
|
|
|
+ this.refresh_loading = false;
|
|
|
+ if (res.status === 1) {
|
|
|
+ this.configForm.api_key = res.api_key;
|
|
|
+ this.configForm.secret_key = res.secret_key;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.refresh_loading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 应用
|
|
|
+ onSubmit() {
|
|
|
+ this.loading = true;
|
|
|
+ setSysConfigBaiduDict(this.configForm)
|
|
|
+ .then((res) => {
|
|
|
+ this.loading = false;
|
|
|
+ if (res.status === 1) {
|
|
|
+ this.$message.success('操作成功!');
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+@use '@/styles/mixin.scss' as *;
|
|
|
+
|
|
|
+.system_config {
|
|
|
+ @include page-base;
|
|
|
+
|
|
|
+ .btn-box {
|
|
|
+ width: 100%;
|
|
|
+ max-width: 1148px;
|
|
|
+ padding: 5px 0;
|
|
|
+ margin: 0 auto;
|
|
|
+ border-bottom: $border;
|
|
|
+ }
|
|
|
+
|
|
|
+ .config-form {
|
|
|
+ width: 100%;
|
|
|
+ max-width: 1148px;
|
|
|
+ height: calc(100vh - 200px);
|
|
|
+ margin: 10px auto;
|
|
|
+ overflow: auto;
|
|
|
+
|
|
|
+ :deep .el-input--small {
|
|
|
+ width: 304px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|