优化字典、配置
This commit is contained in:
parent
1eede00c20
commit
c56d32bd54
@ -5,136 +5,152 @@
|
|||||||
<el-card shadow="hover" class="border-0">
|
<el-card shadow="hover" class="border-0">
|
||||||
<template #header>
|
<template #header>
|
||||||
<el-space>
|
<el-space>
|
||||||
<el-input type="text" v-model="params.name" clearable placeholder="请输入配置名称">
|
<el-input type="text" v-model="params.name" clearable placeholder="请输入配置名称">
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<el-icon class="el-input__icon">
|
<el-icon class="el-input__icon">
|
||||||
<SearchOutlined />
|
<SearchOutlined />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</template>
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
<el-button type="primary" @click="reloadTable" icon="Search"> 查询 </el-button>
|
<el-button type="primary" @click="reloadTable" icon="Search"> 查询 </el-button>
|
||||||
</el-space>
|
</el-space>
|
||||||
<div style="margin-top:15px;">
|
<div style="margin-top: 15px">
|
||||||
<el-button type="primary" @click="addConfig" icon="Plus">新建</el-button>
|
<el-button type="primary" @click="addConfig" icon="Plus">新建</el-button>
|
||||||
<el-button type="danger" :disabled="!selectionData.length" @click="handleDelete()" icon="Delete">删除</el-button>
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
:disabled="!selectionData.length"
|
||||||
|
@click="handleDelete()"
|
||||||
|
icon="Delete"
|
||||||
|
>删除</el-button
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<BasicTable :columns="columns" :showTableSetting="false" :request="loadDataTable" :row-key="(row) => row.id"
|
<BasicTable
|
||||||
ref="tableRef" :actionColumn="actionColumn" @selection-change="onSelectionChange" highlight-current-row
|
:columns="columns"
|
||||||
@row-click="onCheckedRow" :pagination="{ small: true, layout: 'total,prev, pager, next,jumper' }"/>
|
:showTableSetting="false"
|
||||||
|
:request="loadDataTable"
|
||||||
|
:row-key="(row) => row.id"
|
||||||
|
ref="tableRef"
|
||||||
|
:actionColumn="actionColumn"
|
||||||
|
@selection-change="onSelectionChange"
|
||||||
|
highlight-current-row
|
||||||
|
@row-click="onCheckedRow"
|
||||||
|
:pagination="{ small: true, layout: 'total,prev, pager, next,jumper' }"
|
||||||
|
/>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :xs="24" :sm="24" :md="16" :lg="16" :xl="16" class="mb-4">
|
<el-col :xs="24" :sm="24" :md="16" :lg="16" :xl="16" class="mb-4">
|
||||||
<el-card shadow="hover" class="mb-4 border-0 proCard">
|
<el-card shadow="hover" class="mb-4 border-0 proCard">
|
||||||
<configItem :configId="configId" v-if="configItemShow"></configItem>
|
<configItem :configId="configId" v-if="configItemShow" />
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<editDialog v-if="editVisible" :configId="configId" v-model:visible="editVisible" @success="reloadTable">
|
<editDialog
|
||||||
</editDialog>
|
v-if="editVisible"
|
||||||
|
:configId="configId"
|
||||||
|
v-model:visible="editVisible"
|
||||||
|
@success="reloadTable"
|
||||||
|
/>
|
||||||
</PageWrapper>
|
</PageWrapper>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, reactive, h, nextTick, defineAsyncComponent } from 'vue';
|
import { ref, reactive, h, nextTick, defineAsyncComponent } from 'vue';
|
||||||
import { SearchOutlined } from '@vicons/antd';
|
import { SearchOutlined } from '@vicons/antd';
|
||||||
import { TableAction } from '@/components/Table';
|
import { TableAction } from '@/components/Table';
|
||||||
import { getConfigList, configDelete, configBatchDelete } from '@/api/data/config';
|
import { getConfigList, configDelete, configBatchDelete } from '@/api/data/config';
|
||||||
import { columns } from './columns';
|
import { columns } from './columns';
|
||||||
import configItem from './configItem.vue';
|
import configItem from './configItem.vue';
|
||||||
import { message, confirm } from "@/utils/auth";
|
import { message, confirm } from '@/utils/auth';
|
||||||
const editDialog = defineAsyncComponent(() =>
|
const editDialog = defineAsyncComponent(() => import('./edit.vue'));
|
||||||
import('./edit.vue')
|
const configId = ref(0);
|
||||||
)
|
const configItemShow = ref(false);
|
||||||
const configId = ref(0)
|
const tableRef = ref();
|
||||||
const configItemShow = ref(false)
|
const editVisible = ref(false);
|
||||||
const tableRef = ref();
|
const selectionData = ref([]);
|
||||||
const editVisible = ref(false)
|
const params = ref({
|
||||||
const selectionData = ref([])
|
name: '',
|
||||||
const params = ref({
|
});
|
||||||
name: '',
|
|
||||||
});
|
|
||||||
|
|
||||||
const actionColumn = reactive({
|
const actionColumn = reactive({
|
||||||
width: 200,
|
width: 200,
|
||||||
label: '操作',
|
label: '操作',
|
||||||
prop: 'action',
|
prop: 'action',
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
render(record) {
|
render(record) {
|
||||||
return h(TableAction as any, {
|
return h(TableAction as any, {
|
||||||
style: 'text',
|
style: 'text',
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
label: '编辑',
|
label: '编辑',
|
||||||
icon:'Edit',
|
icon: 'Edit',
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
onClick: handleEdit.bind(null, record),
|
onClick: handleEdit.bind(null, record),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '删除',
|
label: '删除',
|
||||||
icon:'Delete',
|
icon: 'Delete',
|
||||||
type: 'danger',
|
type: 'danger',
|
||||||
onClick: handleDelete.bind(null, record),
|
onClick: handleDelete.bind(null, record),
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//新建字典
|
||||||
//新建字典
|
const addConfig = async () => {
|
||||||
const addConfig = async () => {
|
configId.value = 0;
|
||||||
configId.value=0
|
await nextTick();
|
||||||
await nextTick();
|
editVisible.value = true;
|
||||||
editVisible.value=true
|
};
|
||||||
};
|
//编辑字典
|
||||||
//编辑字典
|
const handleEdit = async (record: Recordable) => {
|
||||||
const handleEdit = async (record: Recordable) => {
|
configId.value = record.row.id;
|
||||||
configId.value=record.row.id
|
await nextTick();
|
||||||
await nextTick();
|
editVisible.value = true;
|
||||||
editVisible.value=true
|
};
|
||||||
};
|
//选择字典项
|
||||||
//选择字典项
|
function onCheckedRow(row) {
|
||||||
function onCheckedRow(row) {
|
configId.value = row.id;
|
||||||
configId.value = row.id
|
}
|
||||||
}
|
|
||||||
|
//刷新字典项值列表
|
||||||
//刷新字典项值列表
|
function reloadTable() {
|
||||||
function reloadTable() {
|
tableRef.value.reload({ pageNo: 1 });
|
||||||
tableRef.value.reload({ pageNo: 1 });
|
}
|
||||||
}
|
|
||||||
|
//加载字典项值列表;
|
||||||
//加载字典项值列表;
|
const loadDataTable = async (res) => {
|
||||||
const loadDataTable = async (res) => {
|
const result = await getConfigList({ ...params.value, ...res });
|
||||||
const result = await getConfigList({ ...params.value, ...res });
|
configId.value = result?.records[0]?.id;
|
||||||
configId.value = result?.records[0]?.id
|
configItemShow.value = true;
|
||||||
configItemShow.value = true
|
nextTick(() => {
|
||||||
nextTick(() => {
|
const tables = tableRef.value.getTableRef();
|
||||||
const tables = tableRef.value.getTableRef();
|
tables.setCurrentRow(result?.records[0]);
|
||||||
tables.setCurrentRow(result?.records[0])
|
});
|
||||||
})
|
return result;
|
||||||
return result;
|
};
|
||||||
};
|
|
||||||
|
//删除字典项
|
||||||
//删除字典项
|
async function handleDelete(record: Recordable) {
|
||||||
async function handleDelete(record: Recordable) {
|
let ids = [];
|
||||||
let ids = []
|
if (!record) {
|
||||||
if (!record) {
|
ids = selectionData.value.map(({ id }) => id);
|
||||||
ids = selectionData.value.map(({ id }) => id);
|
}
|
||||||
|
await confirm('确定要删除?');
|
||||||
|
record ? await configDelete(record.row.id) : await configBatchDelete(ids);
|
||||||
|
message('删除成功');
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
function onSelectionChange(value) {
|
||||||
|
selectionData.value = value;
|
||||||
}
|
}
|
||||||
await confirm('确定要删除?');
|
|
||||||
record ? await configDelete(record.row.id) : await configBatchDelete(ids);
|
|
||||||
message("删除成功");
|
|
||||||
reloadTable()
|
|
||||||
}
|
|
||||||
function onSelectionChange(value) {
|
|
||||||
selectionData.value = value
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.card-header {
|
.card-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -5,145 +5,170 @@
|
|||||||
<el-card shadow="hover" class="border-0">
|
<el-card shadow="hover" class="border-0">
|
||||||
<template #header>
|
<template #header>
|
||||||
<el-space>
|
<el-space>
|
||||||
<el-input type="text" v-model="params.name" clearable placeholder="请输入字典名称">
|
<el-input type="text" v-model="params.name" clearable placeholder="请输入字典名称">
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<el-icon class="el-input__icon">
|
<el-icon class="el-input__icon">
|
||||||
<SearchOutlined />
|
<SearchOutlined />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</template>
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
<el-button type="primary" icon="Search" @click="reloadTable"> 查询 </el-button>
|
<el-button type="primary" icon="Search" @click="reloadTable"> 查询 </el-button>
|
||||||
</el-space>
|
</el-space>
|
||||||
<div style="margin-top:15px;">
|
<div style="margin-top: 15px">
|
||||||
<el-button type="primary" @click="dictRefresh" icon="RefreshRight" v-perm="['sys:dict:cache']">刷新缓存</el-button>
|
<el-button
|
||||||
<el-button type="primary" @click="addDict" icon="Plus" v-perm="['sys:dict:add']">新建</el-button>
|
type="primary"
|
||||||
<el-button type="danger" v-perm="['sys:dict:delete']" icon="Delete" :disabled="!selectionData.length" @click="handleDelete()">删除</el-button>
|
@click="dictRefresh"
|
||||||
|
icon="RefreshRight"
|
||||||
|
v-perm="['sys:dict:cache']"
|
||||||
|
>刷新缓存</el-button
|
||||||
|
>
|
||||||
|
<el-button type="primary" @click="addDict" icon="Plus" v-perm="['sys:dict:add']"
|
||||||
|
>新建</el-button
|
||||||
|
>
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
v-perm="['sys:dict:delete']"
|
||||||
|
icon="Delete"
|
||||||
|
:disabled="!selectionData.length"
|
||||||
|
@click="handleDelete()"
|
||||||
|
>删除</el-button
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<BasicTable :columns="columns" :showTableSetting="false" :request="loadDataTable" :row-key="(row) => row.id"
|
<BasicTable
|
||||||
ref="tableRef" :actionColumn="actionColumn" @selection-change="onSelectionChange" highlight-current-row
|
:columns="columns"
|
||||||
@row-click="onCheckedRow" :pagination="{ small: true, layout: 'total,prev, pager, next,jumper' }" />
|
:showTableSetting="false"
|
||||||
|
:request="loadDataTable"
|
||||||
|
:row-key="(row) => row.id"
|
||||||
|
ref="tableRef"
|
||||||
|
:actionColumn="actionColumn"
|
||||||
|
@selection-change="onSelectionChange"
|
||||||
|
highlight-current-row
|
||||||
|
@row-click="onCheckedRow"
|
||||||
|
:pagination="{ small: true, layout: 'total,prev, pager, next,jumper' }"
|
||||||
|
/>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :xs="24" :sm="24" :md="16" :lg="16" :xl="16" class="mb-4">
|
<el-col :xs="24" :sm="24" :md="16" :lg="16" :xl="16" class="mb-4">
|
||||||
<el-card shadow="hover" class="mb-4 border-0 proCard">
|
<el-card shadow="hover" class="mb-4 border-0 proCard">
|
||||||
<dictItem :dictId="dictId" v-if="dictItemShow"></dictItem>
|
<dictItem :dictId="dictId" v-if="dictItemShow" />
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<editDialog v-if="editVisible" :dictId="dictId" v-model:visible="editVisible" @success="reloadTable">
|
<editDialog
|
||||||
</editDialog>
|
v-if="editVisible"
|
||||||
|
:dictId="dictId"
|
||||||
|
v-model:visible="editVisible"
|
||||||
|
@success="reloadTable"
|
||||||
|
/>
|
||||||
</PageWrapper>
|
</PageWrapper>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, reactive, h, nextTick, defineAsyncComponent } from 'vue';
|
import { ref, reactive, h, nextTick, defineAsyncComponent } from 'vue';
|
||||||
import { SearchOutlined } from '@vicons/antd';
|
import { SearchOutlined } from '@vicons/antd';
|
||||||
import { TableAction } from '@/components/Table';
|
import { TableAction } from '@/components/Table';
|
||||||
import { getDictList, refreshCache, dictDelete, dictBatchDelete } from '@/api/data/dictionary';
|
import { getDictList, refreshCache, dictDelete, dictBatchDelete } from '@/api/data/dictionary';
|
||||||
import { columns } from './columns';
|
import { columns } from './columns';
|
||||||
import dictItem from './dictItem.vue';
|
import dictItem from './dictItem.vue';
|
||||||
import { message, confirm } from "@/utils/auth";
|
import { message, confirm } from '@/utils/auth';
|
||||||
const editDialog = defineAsyncComponent(() =>
|
const editDialog = defineAsyncComponent(() => import('./edit.vue'));
|
||||||
import('./edit.vue')
|
const dictId = ref(0);
|
||||||
)
|
const dictItemShow = ref(false);
|
||||||
const dictId = ref(0)
|
const tableRef = ref();
|
||||||
const dictItemShow = ref(false)
|
const selectedKey = ref('');
|
||||||
const tableRef = ref();
|
const rowKeysName = ref('');
|
||||||
const selectedKey = ref('');
|
const currentRow = ref();
|
||||||
const rowKeysName = ref('');
|
const editVisible = ref(false);
|
||||||
const currentRow = ref();
|
const selectionData = ref([]);
|
||||||
const editVisible = ref(false)
|
const params = ref({
|
||||||
const selectionData = ref([])
|
name: '',
|
||||||
const params = ref({
|
});
|
||||||
name: '',
|
|
||||||
});
|
|
||||||
|
|
||||||
const actionColumn = reactive({
|
const actionColumn = reactive({
|
||||||
width: 200,
|
width: 200,
|
||||||
label: '操作',
|
label: '操作',
|
||||||
prop: 'action',
|
prop: 'action',
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
render(record) {
|
render(record) {
|
||||||
return h(TableAction as any, {
|
return h(TableAction as any, {
|
||||||
style: 'text',
|
style: 'text',
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
label: '编辑',
|
label: '编辑',
|
||||||
icon:'Edit',
|
icon: 'Edit',
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
onClick: handleEdit.bind(null, record),
|
onClick: handleEdit.bind(null, record),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '删除',
|
label: '删除',
|
||||||
icon:'Delete',
|
icon: 'Delete',
|
||||||
type: 'danger',
|
type: 'danger',
|
||||||
onClick: handleDelete.bind(null, record),
|
onClick: handleDelete.bind(null, record),
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//新建字典
|
||||||
//新建字典
|
const addDict = async () => {
|
||||||
const addDict = async () => {
|
dictId.value = 0;
|
||||||
dictId.value=0
|
await nextTick();
|
||||||
await nextTick();
|
editVisible.value = true;
|
||||||
editVisible.value=true
|
};
|
||||||
};
|
//编辑字典
|
||||||
//编辑字典
|
const handleEdit = async (record: Recordable) => {
|
||||||
const handleEdit = async (record: Recordable) => {
|
dictId.value = record.row.id;
|
||||||
dictId.value=record.row.id
|
await nextTick();
|
||||||
await nextTick();
|
editVisible.value = true;
|
||||||
editVisible.value=true
|
};
|
||||||
};
|
//选择字典项
|
||||||
//选择字典项
|
function onCheckedRow(row) {
|
||||||
function onCheckedRow(row) {
|
dictId.value = row.id;
|
||||||
dictId.value = row.id
|
}
|
||||||
}
|
|
||||||
|
//刷新字典项值列表
|
||||||
//刷新字典项值列表
|
function reloadTable() {
|
||||||
function reloadTable() {
|
tableRef.value.reload({ pageNo: 1 });
|
||||||
tableRef.value.reload({ pageNo: 1 });
|
}
|
||||||
}
|
|
||||||
|
//加载字典项值列表;
|
||||||
//加载字典项值列表;
|
const loadDataTable = async (res) => {
|
||||||
const loadDataTable = async (res) => {
|
const result = await getDictList({ ...params.value, ...res });
|
||||||
const result = await getDictList({ ...params.value, ...res });
|
dictId.value = result?.records[0]?.id;
|
||||||
dictId.value = result?.records[0]?.id
|
dictItemShow.value = true;
|
||||||
dictItemShow.value = true
|
nextTick(() => {
|
||||||
nextTick(() => {
|
const tables = tableRef.value.getTableRef();
|
||||||
const tables = tableRef.value.getTableRef();
|
tables.setCurrentRow(result?.records[0]);
|
||||||
tables.setCurrentRow(result?.records[0])
|
});
|
||||||
})
|
return result;
|
||||||
return result;
|
};
|
||||||
};
|
|
||||||
|
//刷新缓存
|
||||||
//刷新缓存
|
async function dictRefresh() {
|
||||||
async function dictRefresh() {
|
await refreshCache();
|
||||||
await refreshCache();
|
message('刷新成功');
|
||||||
message("刷新成功");
|
}
|
||||||
}
|
//删除字典项
|
||||||
//删除字典项
|
async function handleDelete(record: Recordable) {
|
||||||
async function handleDelete(record: Recordable) {
|
let ids = [];
|
||||||
let ids = []
|
if (!record) {
|
||||||
if (!record) {
|
ids = selectionData.value.map(({ id }) => id);
|
||||||
ids = selectionData.value.map(({ id }) => id);
|
}
|
||||||
|
await confirm('确定要删除?');
|
||||||
|
record ? await dictDelete(record.row.id) : await dictBatchDelete(ids);
|
||||||
|
message('删除成功');
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
function onSelectionChange(value) {
|
||||||
|
selectionData.value = value;
|
||||||
}
|
}
|
||||||
await confirm('确定要删除?');
|
|
||||||
record ? await dictDelete(record.row.id) : await dictBatchDelete(ids);
|
|
||||||
message("删除成功");
|
|
||||||
reloadTable()
|
|
||||||
}
|
|
||||||
function onSelectionChange(value) {
|
|
||||||
selectionData.value = value
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.card-header {
|
.card-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user