抽出vue component 控制开关按钮组件

This commit is contained in:
shiyidong 2021-05-12 01:09:31 +08:00
parent 57bcaba7f0
commit 102cafa9a6
2 changed files with 8 additions and 23 deletions

View File

@ -37,7 +37,7 @@ import RightToolbar from "@/components/RightToolbar"
// import hljs from 'highlight.js' // import hljs from 'highlight.js'
// import 'highlight.js/styles/github-gist.css' // import 'highlight.js/styles/github-gist.css'
import {DICT_TYPE, getDictDataLabel, getDictDatas} from "@/utils/dict"; import {DICT_TYPE, getDictDataLabel, getDictDatas} from "@/utils/dict";
import { InfConfigKeyEnum } from '@/utils/constants';
// 全局方法挂载 // 全局方法挂载
Vue.prototype.getDicts = getDicts Vue.prototype.getDicts = getDicts
Vue.prototype.getConfigKey = getConfigKey Vue.prototype.getConfigKey = getConfigKey
@ -49,6 +49,7 @@ Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.getDictDatas = getDictDatas Vue.prototype.getDictDatas = getDictDatas
Vue.prototype.getDictDataLabel = getDictDataLabel Vue.prototype.getDictDataLabel = getDictDataLabel
Vue.prototype.DICT_TYPE = DICT_TYPE Vue.prototype.DICT_TYPE = DICT_TYPE
Vue.prototype.InfConfigKeyEnum = InfConfigKeyEnum
Vue.prototype.download = download Vue.prototype.download = download
Vue.prototype.downloadExcel = downloadExcel Vue.prototype.downloadExcel = downloadExcel
Vue.prototype.downloadWord = downloadWord Vue.prototype.downloadWord = downloadWord

View File

@ -37,8 +37,10 @@
<!-- 操作工具栏 --> <!-- 操作工具栏 -->
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button :type="enable?'info':'primary'" plain :icon="enable?'el-icon-close':'el-icon-check'" size="mini" @click="enableHandler" <log-switch :ckey="InfConfigKeyEnum.API_LOG_KEY"
v-hasPermi="['infra:api-access-log:export']">{{enable?'关闭日志':'开启日志'}}</el-button> :permissions="['infra:api-access-log:export','infra:api-access-log:asd']"/>
<!-- <el-button :type="enable?'info':'primary'" plain :icon="enable?'el-icon-close':'el-icon-check'" size="mini" @click="enableHandler"
v-hasPermi="['infra:api-access-log:export']">{{enable?'关闭日志':'开启日志'}}</el-button> -->
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
@ -118,11 +120,11 @@
<script> <script>
import { getApiAccessLogPage, exportApiAccessLogExcel } from "@/api/infra/apiAccessLog"; import { getApiAccessLogPage, exportApiAccessLogExcel } from "@/api/infra/apiAccessLog";
import { getConfigKey,updateValueByKey } from "@/api/infra/config"; import LogSwitch from "@/components/LogSwitch";
import { InfConfigKeyEnum } from "@/utils/constants";
export default { export default {
name: "ApiAccessLog", name: "ApiAccessLog",
components: { components: {
LogSwitch
}, },
data() { data() {
return { return {
@ -130,8 +132,6 @@ export default {
loading: true, loading: true,
// //
showSearch: true, showSearch: true,
//
enable: false,
// //
total: 0, total: 0,
// API 访 // API 访
@ -157,25 +157,9 @@ export default {
}; };
}, },
created() { created() {
this.getEnableConfig();
this.getList(); this.getList();
}, },
methods: { methods: {
//
enableHandler(){
let data = new FormData();
data.append("key",InfConfigKeyEnum.API_LOG_KEY);
data.append("value",this.enable?false:true);
updateValueByKey(data).then(response => {
this.msgSuccess(this.enable?"关闭成功":"开启成功");
this.getEnableConfig();
})
},
getEnableConfig(){
getConfigKey(InfConfigKeyEnum.API_LOG_KEY).then(response => {
this.enable = (response.data == "true");
})
},
/** 查询列表 */ /** 查询列表 */
getList() { getList() {
this.loading = true; this.loading = true;