🎉 【字典管理】、【参数管理】同步缓存

This commit is contained in:
dh186609 2023-02-24 13:59:47 +08:00
parent 7131f1ade4
commit ba72065333
2 changed files with 183 additions and 178 deletions

View File

@ -1,46 +1,47 @@
import request from "/@/utils/request"
export function fetchList(query?: Object) {
return request({
url: '/admin/param/page',
method: 'get',
params: query
})
return request({
url: '/admin/param/page',
method: 'get',
params: query
})
}
export function addObj(obj?: Object) {
return request({
url: '/admin/param',
method: 'post',
data: obj
})
return request({
url: '/admin/param',
method: 'post',
data: obj
})
}
export function getObj(id?: string) {
return request({
url: '/admin/param/' + id,
method: 'get'
})
return request({
url: '/admin/param/' + id,
method: 'get'
})
}
export function delObj(ids?: Object) {
return request({
url: '/admin/param',
method: 'delete',
data: ids
})
return request({
url: '/admin/param',
method: 'delete',
data: ids
})
}
export function putObj(obj?: Object) {
return request({
url: '/admin/param',
method: 'put',
data: obj
})
}
export function refreshCache() {
return request({
url: '/admin/param/sync',
method: 'put'
url: '/admin/param',
method: 'put',
data: obj
})
}
export function refreshCache() {
return request({
url: '/admin/param/sync',
method: 'put'
})
}

View File

@ -1,165 +1,169 @@
<template>
<div class="layout-padding">
<el-card class="layout-padding-auto">
<el-row v-show="showSearch" class="mb8">
<el-form ref="queryRef" :inline="true" :model="state.queryForm">
<el-form-item :label="t('param.systemFlag')" class="ml2" prop="systemFlag">
<el-select v-model="state.queryForm.systemFlag" :placeholder="t('param.inputsystemFlagTip')">
<el-option v-for="(item, index) in dict_type" :key="index" :label="item.label"
:value="item.value"></el-option>
</el-select>
</el-form-item>
<el-form-item class="ml2">
<el-button formDialogRef icon="search" type="primary" @click="getDataList">
{{ $t('common.queryBtn') }}
</el-button>
<el-button formDialogRef icon="Refresh" @click="resetQuery">{{ $t('common.resetBtn') }}</el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<div class="mb8" style="width: 100%">
<el-button class="ml10" formDialogRef icon="folder-add" type="primary" @click="formDialogRef.openDialog()">
{{ $t('common.addBtn') }}
</el-button>
<el-button class="ml10" formDialogRef icon="Download" type="primary" @click="exportExcel">
{{ $t('common.exportBtn') }}
</el-button>
<el-button :disabled="multiple" class="ml10" formDialogRef icon="Delete" type="primary"
@click="handleDelete(selectObjs)">
{{ $t('common.delBtn') }}
</el-button>
<el-button class="ml10" formDialogRef icon="refresh-left" type="primary" @click="handleRefreshCache()">
{{ $t('common.refreshCacheBtn') }}
</el-button>
<right-toolbar v-model:showSearch="showSearch" class="ml10" style="float: right;margin-right: 20px"
@queryTable="getDataList"></right-toolbar>
</div>
</el-row>
<el-table v-loading="state.loading" :data="state.dataList" style="width: 100%"
@selection-change="handleSelectionChange">
<el-table-column align="center" type="selection" :selectable='handleSelectable' width="50">
</el-table-column>
<el-table-column :label="t('param.index')" type="index" width="80" />
<el-table-column :label="t('param.publicName')" prop="publicName" show-overflow-tooltip />
<el-table-column :label="t('param.publicKey')" prop="publicKey" show-overflow-tooltip />
<el-table-column :label="t('param.publicValue')" prop="publicValue" show-overflow-tooltip />
<el-table-column :label="t('param.status')" prop="status" show-overflow-tooltip>
<template #default="scope">
<dict-tag :options="status_type" :value="scope.row.status"></dict-tag>
</template>
</el-table-column>
<el-table-column :label="t('param.createTime')" prop="createTime" show-overflow-tooltip />
<el-table-column :label="t('param.systemFlag')" prop="systemFlag" show-overflow-tooltip>
<template #default="scope">
<dict-tag :options="dict_type" :value="scope.row.systemFlag"></dict-tag>
</template>
</el-table-column>
<el-table-column :label="$t('common.action')" width="150">
<template #default="scope">
<el-button text type="primary" @click="formDialogRef.openDialog(scope.row.publicId)">{{
$t('common.editBtn')
}}
</el-button>
<div class="layout-padding">
<el-card class="layout-padding-auto">
<el-row class="mb8" v-show="showSearch">
<el-form :inline="true" :model="state.queryForm" ref="queryRef">
<el-form-item :label="t('param.systemFlag')" class="ml2" prop="systemFlag">
<el-select :placeholder="t('param.inputsystemFlagTip')" v-model="state.queryForm.systemFlag">
<el-option :key="index" :label="item.label" :value="item.value"
v-for="(item, index) in dict_type"></el-option>
</el-select>
</el-form-item>
<el-form-item class="ml2">
<el-button @click="getDataList" formDialogRef icon="search" type="primary">
{{ $t('common.queryBtn') }}
</el-button>
<el-button @click="resetQuery" formDialogRef icon="Refresh">{{ $t('common.resetBtn') }}
</el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<div class="mb8" style="width: 100%">
<el-button @click="formDialogRef.openDialog()" class="ml10" formDialogRef icon="folder-add"
type="primary">
{{ $t('common.addBtn') }}
</el-button>
<el-button @click="exportExcel" class="ml10" formDialogRef icon="Download" type="primary">
{{ $t('common.exportBtn') }}
</el-button>
<el-button :disabled="multiple" @click="handleDelete(selectObjs)" class="ml10" formDialogRef icon="Delete"
type="primary">
{{ $t('common.delBtn') }}
</el-button>
<el-button @click="handleRefreshCache()" class="ml10" formDialogRef icon="refresh-left"
type="primary">
{{ $t('common.refreshCacheBtn') }}
</el-button>
<right-toolbar @queryTable="getDataList" class="ml10" style="float: right;margin-right: 20px"
v-model:showSearch="showSearch"></right-toolbar>
</div>
</el-row>
<el-table :data="state.dataList" @selection-change="handleSelectionChange" style="width: 100%"
v-loading="state.loading">
<el-table-column :selectable='handleSelectable' align="center" type="selection" width="50">
</el-table-column>
<el-table-column :label="t('param.index')" type="index" width="80"/>
<el-table-column :label="t('param.publicName')" prop="publicName" show-overflow-tooltip/>
<el-table-column :label="t('param.publicKey')" prop="publicKey" show-overflow-tooltip/>
<el-table-column :label="t('param.publicValue')" prop="publicValue" show-overflow-tooltip/>
<el-table-column :label="t('param.status')" prop="status" show-overflow-tooltip>
<template #default="scope">
<dict-tag :options="status_type" :value="scope.row.status"></dict-tag>
</template>
</el-table-column>
<el-table-column :label="t('param.createTime')" prop="createTime" show-overflow-tooltip/>
<el-table-column :label="t('param.systemFlag')" prop="systemFlag" show-overflow-tooltip>
<template #default="scope">
<dict-tag :options="dict_type" :value="scope.row.systemFlag"></dict-tag>
</template>
</el-table-column>
<el-table-column :label="$t('common.action')" width="150">
<template #default="scope">
<el-button @click="formDialogRef.openDialog(scope.row.publicId)" text type="primary">{{
$t('common.editBtn')
}}
</el-button>
<el-tooltip :content="$t('sysdict.deleteDisabledTip')" :disabled="scope.row.systemFlag === 1"
placement="top">
<el-tooltip :content="$t('sysdict.deleteDisabledTip')" :disabled="scope.row.systemFlag === 1"
placement="top">
<span style="margin-left: 12px">
<el-button text type="primary" :disabled="scope.row.systemFlag !== 1"
@click="handleDelete([scope.row.publicId])">
<el-button :disabled="scope.row.systemFlag !== 1" @click="handleDelete([scope.row.publicId])" text
type="primary">
{{ $t('common.delBtn') }}
</el-button>
</span>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<pagination v-bind="state.pagination" @size-change="sizeChangeHandle" @current-change="currentChangeHandle" />
</el-card>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<pagination @current-change="currentChangeHandle" @size-change="sizeChangeHandle"
v-bind="state.pagination"/>
</el-card>
<!-- 编辑新增 -->
<form-dialog ref="formDialogRef" @refresh="getDataList()" />
</div>
<!-- 编辑新增 -->
<form-dialog @refresh="getDataList()" ref="formDialogRef"/>
</div>
</template>
<script lang="ts" name="systemSysPublicParam" setup>
import { BasicTableProps, useTable } from "/@/hooks/table";
import { delObj, fetchList,refreshCache } from "/@/api/admin/param";
import { useMessage, useMessageBox } from "/@/hooks/message";
import { useDict } from '/@/hooks/dict';
import { useI18n } from "vue-i18n";
import {BasicTableProps, useTable} from "/@/hooks/table";
import {delObj, fetchList, refreshCache} from "/@/api/admin/param";
import {useMessage, useMessageBox} from "/@/hooks/message";
import {useDict} from '/@/hooks/dict';
import {useI18n} from "vue-i18n";
//
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
const { t } = useI18n()
//
//
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
const {t} = useI18n()
//
const { dict_type, status_type } = useDict('dict_type', 'status_type')
//
const formDialogRef = ref()
//
const queryRef = ref()
const showSearch = ref(true)
//
const selectObjs = ref([]) as any
const multiple = ref(true)
const {dict_type, status_type} = useDict('dict_type', 'status_type')
//
const formDialogRef = ref()
//
const queryRef = ref()
const showSearch = ref(true)
//
const selectObjs = ref([]) as any
const multiple = ref(true)
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {
systemFlag: ''
},
pageList: fetchList
})
// table hook
const {
getDataList,
currentChangeHandle,
sizeChangeHandle,
downBlobFile
} = useTable(state)
//
const resetQuery = () => {
queryRef.value.resetFields()
getDataList()
}
//
const handleSelectable = (row: any) => {
//
return row.systemFlag !== '1'
}
// excel
const exportExcel = () => {
downBlobFile('/admin/param/export', state.queryForm, 'param.xlsx')
}
//
const handleSelectionChange = (objs: any) => {
objs.forEach((val: any) => {
selectObjs.value.push(val.publicId)
});
multiple.value = !objs.length
}
const handleRefreshCache = () =>{
refreshCache().then(()=>{
useMessage().success('同步成功')
})
}
//
const handleDelete = (ids: string[]) => {
useMessageBox().confirm(t('common.delConfirmText'))
.then(() => {
delObj(ids).then(() => {
getDataList();
useMessage().success(t('common.delSuccessText'));
}).catch((err: any) => {
useMessage().error(err.msg)
})
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {
systemFlag: ''
},
pageList: fetchList
})
};
// table hook
const {
getDataList,
currentChangeHandle,
sizeChangeHandle,
downBlobFile
} = useTable(state)
//
const resetQuery = () => {
queryRef.value.resetFields()
getDataList()
}
//
const handleSelectable = (row: any) => {
//
return row.systemFlag !== '1'
}
// excel
const exportExcel = () => {
downBlobFile('/admin/param/export', state.queryForm, 'param.xlsx')
}
//
const handleSelectionChange = (objs: any) => {
objs.forEach((val: any) => {
selectObjs.value.push(val.publicId)
});
multiple.value = !objs.length
}
const handleRefreshCache = () => {
refreshCache().then(() => {
useMessage().success('同步成功')
})
}
//
const handleDelete = (ids: string[]) => {
useMessageBox().confirm(t('common.delConfirmText'))
.then(() => {
delObj(ids).then(() => {
getDataList();
useMessage().success(t('common.delSuccessText'));
}).catch((err: any) => {
useMessage().error(err.msg)
})
})
};
</script>