This commit is contained in:
2025-10-06 17:24:17 +08:00
parent e9101b5c07
commit 31ca550ead
102 changed files with 21435 additions and 0 deletions

View File

@@ -0,0 +1,671 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
ref="crud"
v-model="form"
:permission="permissionList"
:before-open="beforeOpen"
@row-del="rowDel"
@row-update="rowUpdate"
@row-save="rowSave"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
@tree-load="treeLoad"
>
<template #menu="{ row }">
<el-button
type="primary"
text
icon="el-icon-setting"
v-if="permission.api_scope_setting"
plain
style="border: 0; background-color: transparent !important"
@click.stop="handleDataScope(row)"
>权限配置
</el-button>
</template>
<template #name="{ row }">
<i :class="row.source" style="margin-right: 5px" />
<span>{{ row.name }}</span>
</template>
<template #source="{ row }">
<div style="text-align: center">
<i :class="row.source" />
</div>
</template>
</avue-crud>
<el-drawer
:title="`[${scopeMenuName}] 接口权限配置`"
v-model="drawerVisible"
:direction="direction"
append-to-body
:before-close="handleDrawerClose"
size="1000px"
>
<basic-container>
<avue-crud
:option="optionScope"
:data="dataScope"
:page="pageScope"
v-model="formScope"
:table-loading="scopeLoading"
ref="crudScope"
@row-del="rowDelScope"
@row-update="rowUpdateScope"
@row-save="rowSaveScope"
:before-open="beforeOpenScope"
@search-change="searchChangeScope"
@search-reset="searchResetScope"
@selection-change="selectionChangeScope"
@current-change="currentChangeScope"
@size-change="sizeChangeScope"
@on-load="onLoadScope"
>
<template #menu-left>
<el-button type="danger" icon="el-icon-delete" plain @click="handleDeleteScope"
>删 除
</el-button>
</template>
<template #scopeType="{ row }">
<el-tag>{{ row.scopeTypeName }}</el-tag>
</template>
</avue-crud>
</basic-container>
</el-drawer>
</basic-container>
</template>
<script>
import { add, remove, update, getLazyMenuList, getMenu } from '@/api/system/menu';
import {
addApiScope,
removeApiScope,
updateApiScope,
getListApiScope,
getMenuApiScope,
} from '@/api/system/scope';
import { mapGetters } from 'vuex';
import iconList from '@/config/iconList';
export default {
data() {
return {
form: {},
selectionList: [],
query: {},
loading: true,
parentId: 0,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
drawerVisible: false,
direction: 'rtl',
scopeLoading: false,
scopeMenuId: 0,
scopeMenuName: '菜单',
menu: true,
option: {
lazy: true,
tip: false,
simplePage: true,
searchShow: true,
searchMenuSpan: 6,
dialogWidth: '60%',
tree: true,
border: true,
index: true,
selection: true,
viewBtn: false,
editBtn: false,
addBtn: false,
delBtn: false,
menuWidth: 150,
dialogClickModal: false,
column: [
{
label: '菜单名称',
prop: 'name',
width: 300,
search: true,
rules: [
{
required: true,
message: '请输入菜单名称',
trigger: 'blur',
},
],
},
{
label: '路由地址',
prop: 'path',
rules: [
{
required: true,
message: '请输入路由地址',
trigger: 'blur',
},
],
},
{
label: '上级菜单',
prop: 'parentId',
type: 'tree',
dicUrl: '/blade-system/menu/tree',
hide: true,
props: {
label: 'title',
},
rules: [
{
required: false,
message: '请选择上级菜单',
trigger: 'click',
},
],
},
{
label: '菜单图标',
prop: 'source',
type: 'icon',
slot: true,
width: 85,
iconList: iconList,
rules: [
{
required: true,
message: '请输入菜单图标',
trigger: 'click',
},
],
},
{
label: '菜单编号',
prop: 'code',
search: true,
rules: [
{
required: true,
message: '请输入菜单编号',
trigger: 'blur',
},
],
},
{
label: '菜单类型',
prop: 'category',
type: 'radio',
dicData: [
{
label: '菜单',
value: 1,
},
{
label: '按钮',
value: 2,
},
],
hide: true,
rules: [
{
required: true,
message: '请选择菜单类型',
trigger: 'blur',
},
],
},
{
label: '菜单别名',
prop: 'alias',
rules: [
{
required: true,
message: '请输入菜单别名',
trigger: 'blur',
},
],
},
{
label: '按钮功能',
prop: 'action',
type: 'radio',
dicData: [
{
label: '工具栏',
value: 0,
},
{
label: '操作栏',
value: 1,
},
{
label: '工具操作栏',
value: 2,
},
],
hide: true,
rules: [
{
required: true,
message: '请选择按钮功能',
trigger: 'blur',
},
],
},
{
label: '菜单排序',
prop: 'sort',
type: 'number',
width: 85,
rules: [
{
required: true,
message: '请输入菜单排序',
trigger: 'blur',
},
],
},
{
label: '新窗口',
prop: 'isOpen',
type: 'radio',
dicData: [
{
label: '否',
value: 0,
},
{
label: '是',
value: 1,
},
],
hide: true,
},
{
label: '菜单备注',
prop: 'remark',
type: 'textarea',
span: 24,
minRows: 6,
hide: true,
},
],
},
data: [],
formScope: {},
selectionListScope: [],
pageScope: {
pageSize: 10,
currentPage: 1,
total: 0,
},
optionScope: {
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
selection: true,
menuWidth: 200,
dialogWidth: 900,
dialogClickModal: false,
column: [
{
label: '权限名称',
prop: 'scopeName',
search: true,
rules: [
{
required: true,
message: '请输入权限名称',
trigger: 'blur',
},
],
},
{
label: '权限编号',
prop: 'resourceCode',
search: true,
width: 180,
rules: [
{
required: true,
message: '请输入权限编号',
trigger: 'blur',
},
],
},
{
label: '权限路径',
prop: 'scopePath',
width: 180,
rules: [
{
required: true,
message: '请输入权限编号',
trigger: 'blur',
},
],
},
{
label: '接口类型',
type: 'select',
dicUrl: '/blade-system/dict/dictionary?code=api_scope_type',
props: {
label: 'dictValue',
value: 'dictKey',
},
dataType: 'number',
slot: true,
width: 100,
prop: 'scopeType',
rules: [
{
required: true,
message: '请输入通知类型',
trigger: 'blur',
},
],
},
{
label: '备注',
prop: 'remark',
span: 24,
hide: true,
},
],
},
dataScope: [],
};
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.menu_add, false),
viewBtn: this.validData(this.permission.menu_view, false),
delBtn: this.validData(this.permission.menu_delete, false),
editBtn: this.validData(this.permission.menu_edit, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
scopeIds() {
let ids = [];
this.selectionListScope.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
// 菜单管理模块
rowSave(row, done, loading) {
add(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
searchReset() {
this.query = {};
this.parentId = 0;
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.parentId = '';
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getMenu(this.form.id).then(res => {
this.form = res.data.data;
});
}
done();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getLazyMenuList(this.parentId, Object.assign(params, this.query)).then(res => {
this.data = res.data.data;
this.loading = false;
this.selectionClear();
});
},
treeLoad(tree, treeNode, resolve) {
const parentId = tree.id;
getLazyMenuList(parentId).then(res => {
resolve(res.data.data);
});
},
// 数据权限模块
handleDataScope(row) {
this.drawerVisible = true;
this.scopeMenuId = row.id;
this.scopeMenuName = row.name;
this.onLoadScope(this.pageScope);
},
handleDrawerClose(hide) {
hide();
},
rowSaveScope(row, done, loading) {
row = {
...row,
menuId: this.scopeMenuId,
};
addApiScope(row).then(
() => {
this.onLoadScope(this.pageScope);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdateScope(row, index, done, loading) {
row = {
...row,
menuId: this.scopeMenuId,
};
updateApiScope(row).then(
() => {
this.onLoadScope(this.pageScope);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDelScope(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return removeApiScope(row.id);
})
.then(() => {
this.onLoadScope(this.pageScope);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleDeleteScope() {
if (this.selectionListScope.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return removeApiScope(this.scopeIds);
})
.then(() => {
this.onLoadScope(this.pageScope);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crudScope.toggleSelection();
});
},
beforeOpenScope(done, type) {
if (['edit', 'view'].includes(type)) {
getMenuApiScope(this.formScope.id).then(res => {
this.formScope = res.data.data;
});
}
done();
},
searchResetScope() {
this.onLoadScope(this.pageScope);
},
searchChangeScope(params, done) {
this.onLoadScope(this.pageScope, params);
done();
},
selectionChangeScope(list) {
this.selectionListScope = list;
},
currentChangeScope(currentPage) {
this.pageScope.currentPage = currentPage;
},
sizeChangeScope(pageSize) {
this.pageScope.pageSize = pageSize;
},
onLoadScope(page, params = {}) {
this.scopeLoading = true;
const values = {
...params,
menuId: this.scopeMenuId,
};
getListApiScope(page.currentPage, page.pageSize, Object.assign(values, this.query)).then(
res => {
const data = res.data.data;
this.pageScope.total = data.total;
this.dataScope = data.records;
this.selectionListScope = [];
this.scopeLoading = false;
}
);
},
},
};
</script>

View File

@@ -0,0 +1,764 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
ref="crud"
v-model="form"
:permission="permissionList"
:before-open="beforeOpen"
:before-close="beforeClose"
@row-del="rowDel"
@row-update="rowUpdate"
@row-save="rowSave"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
@tree-load="treeLoad"
>
<template #menu="{ row }">
<el-button
type="primary"
text
icon="el-icon-setting"
v-if="permission.data_scope_setting"
plain
style="border: 0; background-color: transparent !important"
@click.stop="handleDataScope(row)"
>权限配置
</el-button>
</template>
<template #name="{ row }">
<i :class="row.source" style="margin-right: 5px" />
<span>{{ row.name }}</span>
</template>
<template #source="{ row }">
<div style="text-align: center">
<i :class="row.source" />
</div>
</template>
</avue-crud>
<el-drawer
:title="`[${scopeMenuName}] 数据权限配置`"
v-model="drawerVisible"
:direction="direction"
append-to-body
:before-close="handleDrawerClose"
size="1000px"
>
<basic-container>
<avue-crud
:option="optionScope"
:data="dataScope"
:page="pageScope"
v-model="formScope"
:table-loading="scopeLoading"
ref="crudScope"
@row-del="rowDelScope"
@row-update="rowUpdateScope"
@row-save="rowSaveScope"
:before-open="beforeOpenScope"
@search-change="searchChangeScope"
@search-reset="searchResetScope"
@selection-change="selectionChangeScope"
@current-change="currentChangeScope"
@size-change="sizeChangeScope"
@on-load="onLoadScope"
>
<template #menu-left>
<el-button type="danger" icon="el-icon-delete" plain @click="handleDeleteScope"
>删 除
</el-button>
</template>
<template #scopeType="{ row }">
<el-tag>{{ row.scopeTypeName }}</el-tag>
</template>
</avue-crud>
</basic-container>
</el-drawer>
</basic-container>
</template>
<script>
import { add, remove, update, getLazyMenuList, getMenu } from '@/api/system/menu';
import {
addDataScope,
removeDataScope,
updateDataScope,
getListDataScope,
getMenuDataScope,
} from '@/api/system/scope';
import { mapGetters } from 'vuex';
import iconList from '@/config/iconList';
import func from '@/utils/func';
export default {
data() {
return {
form: {},
selectionList: [],
query: {},
loading: true,
parentId: 0,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
drawerVisible: false,
direction: 'rtl',
scopeMenuId: 0,
scopeMenuCode: '',
scopeMenuName: '菜单',
scopeLoading: false,
menu: true,
watchMode: true,
option: {
lazy: true,
tip: false,
simplePage: true,
searchShow: true,
searchMenuSpan: 6,
dialogWidth: '60%',
tree: true,
border: true,
index: true,
selection: true,
viewBtn: false,
editBtn: false,
addBtn: false,
delBtn: false,
menuWidth: 150,
dialogClickModal: false,
column: [
{
label: '菜单名称',
prop: 'name',
width: 300,
search: true,
rules: [
{
required: true,
message: '请输入菜单名称',
trigger: 'blur',
},
],
},
{
label: '路由地址',
prop: 'path',
rules: [
{
required: true,
message: '请输入路由地址',
trigger: 'blur',
},
],
},
{
label: '上级菜单',
prop: 'parentId',
type: 'tree',
dicUrl: '/blade-system/menu/tree',
hide: true,
props: {
label: 'title',
},
rules: [
{
required: false,
message: '请选择上级菜单',
trigger: 'click',
},
],
},
{
label: '菜单图标',
prop: 'source',
type: 'icon',
slot: true,
width: 85,
iconList: iconList,
rules: [
{
required: true,
message: '请输入菜单图标',
trigger: 'click',
},
],
},
{
label: '菜单编号',
prop: 'code',
search: true,
rules: [
{
required: true,
message: '请输入菜单编号',
trigger: 'blur',
},
],
},
{
label: '菜单类型',
prop: 'category',
type: 'radio',
dicData: [
{
label: '菜单',
value: 1,
},
{
label: '按钮',
value: 2,
},
],
hide: true,
rules: [
{
required: true,
message: '请选择菜单类型',
trigger: 'blur',
},
],
},
{
label: '菜单别名',
prop: 'alias',
rules: [
{
required: true,
message: '请输入菜单别名',
trigger: 'blur',
},
],
},
{
label: '按钮功能',
prop: 'action',
type: 'radio',
dicData: [
{
label: '工具栏',
value: 0,
},
{
label: '操作栏',
value: 1,
},
{
label: '工具操作栏',
value: 2,
},
],
hide: true,
rules: [
{
required: true,
message: '请选择按钮功能',
trigger: 'blur',
},
],
},
{
label: '菜单排序',
prop: 'sort',
type: 'number',
width: 85,
rules: [
{
required: true,
message: '请输入菜单排序',
trigger: 'blur',
},
],
},
{
label: '新窗口',
prop: 'isOpen',
type: 'radio',
dicData: [
{
label: '否',
value: 0,
},
{
label: '是',
value: 1,
},
],
hide: true,
},
{
label: '菜单备注',
prop: 'remark',
type: 'textarea',
span: 24,
minRows: 6,
hide: true,
},
],
},
data: [],
formScope: {},
selectionListScope: [],
pageScope: {
pageSize: 10,
currentPage: 1,
total: 0,
},
optionScope: {
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
selection: true,
menuWidth: 200,
dialogWidth: 900,
dialogClickModal: false,
column: [
{
label: '权限名称',
prop: 'scopeName',
search: true,
value: '',
rules: [
{
required: true,
message: '请输入数据权限名称',
trigger: 'blur',
},
],
},
{
label: '权限编号',
prop: 'resourceCode',
search: true,
width: 100,
rules: [
{
required: true,
message: '请输入数据权限编号',
trigger: 'blur',
},
],
},
{
label: '权限字段',
prop: 'scopeColumn',
width: 130,
rules: [
{
required: true,
message: '请输入数据权限编号',
trigger: 'blur',
},
],
},
{
label: '规则类型',
type: 'select',
dicUrl: '/blade-system/dict/dictionary?code=data_scope_type',
props: {
label: 'dictValue',
value: 'dictKey',
},
dataType: 'number',
slot: true,
width: 140,
prop: 'scopeType',
rules: [
{
required: true,
message: '请输入通知类型',
trigger: 'blur',
},
],
},
{
label: '可见字段',
prop: 'scopeField',
span: 24,
hide: true,
value: '*',
rules: [
{
required: true,
message: '请输入数据权限可见的字段',
trigger: 'blur',
},
],
},
{
label: '权限类名',
prop: 'scopeClass',
span: 24,
hide: true,
rules: [
{
required: true,
message: '请输入MybatisMapper对应方法的完整类名路径',
trigger: 'blur',
},
],
},
{
label: '规则值',
prop: 'scopeValue',
span: 24,
minRows: 5,
type: 'textarea',
display: true,
hide: true,
},
{
label: '备注',
prop: 'remark',
span: 24,
hide: true,
},
],
},
dataScope: [],
};
},
watch: {
'formScope.scopeType'() {
this.initScope();
},
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.menu_add, false),
viewBtn: this.validData(this.permission.menu_view, false),
delBtn: this.validData(this.permission.menu_delete, false),
editBtn: this.validData(this.permission.menu_edit, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
scopeIds() {
let ids = [];
this.selectionListScope.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
initScope() {
const scopeType = func.toInt(this.formScope.scopeType);
const watchMode = this.watchMode;
let column = '-',
name = '暂无';
if (scopeType === 1) {
column = '-';
name = '全部可见';
} else if (scopeType === 2) {
column = 'create_user';
name = '本人可见';
} else if (scopeType === 3) {
column = 'create_dept';
name = '所在机构可见';
} else if (scopeType === 4) {
column = 'create_dept';
name = '所在机构可见及子级可见';
} else if (scopeType === 5) {
column = '';
name = '自定义';
}
this.$refs.crudScope.option.column.filter(item => {
if (watchMode) {
if (item.prop === 'scopeName') {
this.formScope.scopeName = `${this.scopeMenuName} [${name}]`;
}
if (item.prop === 'resourceCode') {
this.formScope.resourceCode = this.scopeMenuCode;
}
if (item.prop === 'scopeColumn') {
this.formScope.scopeColumn = column;
}
}
if (item.prop === 'scopeValue') {
item.display = scopeType === 5;
}
});
},
// 菜单管理模块
rowSave(row, done, loading) {
add(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
searchReset() {
this.query = {};
this.parentId = 0;
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.parentId = '';
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getMenu(this.form.id).then(res => {
this.form = res.data.data;
});
}
done();
},
beforeClose(done) {
this.formScope = {};
done();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getLazyMenuList(this.parentId, Object.assign(params, this.query)).then(res => {
this.data = res.data.data;
this.loading = false;
this.selectionClear();
});
},
treeLoad(tree, treeNode, resolve) {
const parentId = tree.id;
getLazyMenuList(parentId).then(res => {
resolve(res.data.data);
});
},
// 数据权限模块
handleDataScope(row) {
this.drawerVisible = true;
this.scopeMenuId = row.id;
this.scopeMenuCode = row.code;
this.scopeMenuName = row.name;
this.onLoadScope(this.pageScope);
},
handleDrawerClose(hide) {
hide();
},
rowSaveScope(row, done, loading) {
row = {
...row,
menuId: this.scopeMenuId,
};
addDataScope(row).then(
() => {
this.onLoadScope(this.pageScope);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdateScope(row, index, done, loading) {
row = {
...row,
menuId: this.scopeMenuId,
};
updateDataScope(row).then(
() => {
this.onLoadScope(this.pageScope);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDelScope(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return removeDataScope(row.id);
})
.then(() => {
this.onLoadScope(this.pageScope);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleDeleteScope() {
if (this.selectionListScope.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return removeDataScope(this.scopeIds);
})
.then(() => {
this.onLoadScope(this.pageScope);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crudScope.toggleSelection();
});
},
beforeOpenScope(done, type) {
if (['add'].includes(type)) {
this.watchMode = true;
this.initScope();
}
if (['edit', 'view'].includes(type)) {
this.watchMode = false;
getMenuDataScope(this.formScope.id).then(res => {
this.formScope = res.data.data;
});
}
done();
},
searchResetScope() {
this.onLoadScope(this.pageScope);
},
searchChangeScope(params, done) {
this.onLoadScope(this.pageScope, params);
done();
},
selectionChangeScope(list) {
this.selectionListScope = list;
},
currentChangeScope(currentPage) {
this.pageScope.currentPage = currentPage;
},
sizeChangeScope(pageSize) {
this.pageScope.pageSize = pageSize;
},
onLoadScope(page, params = {}) {
this.scopeLoading = true;
const values = {
...params,
menuId: this.scopeMenuId,
};
getListDataScope(page.currentPage, page.pageSize, Object.assign(values, this.query)).then(
res => {
const data = res.data.data;
this.pageScope.total = data.total;
this.dataScope = data.records;
this.selectionListScope = [];
this.scopeLoading = false;
}
);
},
},
};
</script>

View File

@@ -0,0 +1,468 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
ref="crud"
v-model="form"
:permission="permissionList"
:before-open="beforeOpen"
@row-del="rowDel"
@row-update="rowUpdate"
@row-save="rowSave"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
v-if="permission.role_delete"
plain
@click="handleDelete"
>Delete
</el-button>
<el-button
icon="el-icon-setting"
@click="handleRole"
v-if="userInfo.authority.includes('admin')"
plain
>Authority
</el-button>
</template>
<template #menu="{ row }">
<el-button
type="primary"
text
icon="el-icon-setting"
v-if="userInfo.authority.includes('admin')"
plain
style="border: 0; background-color: transparent !important"
@click.stop="handleRowRole(row)"
>Authority
</el-button>
</template>
</avue-crud>
<el-dialog title="RoleSetting" append-to-body v-model="box" width="345px">
<el-tabs type="border-card">
<el-tab-pane label="Menu">
<el-tree
:data="menuGrantList"
show-checkbox
node-key="id"
ref="treeMenu"
:default-checked-keys="menuTreeObj"
:props="props"
>
</el-tree>
</el-tab-pane>
<el-tab-pane label="Data">
<el-tree
:data="dataScopeGrantList"
show-checkbox
node-key="id"
ref="treeDataScope"
:default-checked-keys="dataScopeTreeObj"
:props="props"
>
</el-tree>
</el-tab-pane>
<el-tab-pane label="API">
<el-tree
:data="apiScopeGrantList"
show-checkbox
node-key="id"
ref="treeApiScope"
:default-checked-keys="apiScopeTreeObj"
:props="props"
>
</el-tree>
</el-tab-pane>
</el-tabs>
<template #footer>
<span class="dialog-footer">
<el-button @click="box = false">Cancel</el-button>
<el-button type="primary" @click="submit">Submit</el-button>
</span>
</template>
</el-dialog>
</basic-container>
</template>
<script>
import {
add,
getList,
getRole,
getRoleAlias,
getRoleTreeById,
grant,
grantTree,
remove,
update,
} from '@/api/system/role';
import { mapGetters } from 'vuex';
import website from '@/config/website';
import { validatenull } from '@/utils/validate';
export default {
data() {
return {
form: {},
box: false,
props: {
label: 'title',
value: 'key',
},
menuGrantList: [],
dataScopeGrantList: [],
apiScopeGrantList: [],
apiGrantList: [],
menuTreeObj: [],
dataScopeTreeObj: [],
apiScopeTreeObj: [],
selectionList: [],
query: {},
loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
option: {
tip: false,
simplePage: true,
searchShow: true,
searchMenuSpan: 6,
tree: true,
border: true,
index: true,
selection: true,
viewBtn: true,
labelWidth: 120,
searchLabelWidth: 120,
menuWidth: 350,
dialogWidth: 600,
dialogClickModal: false,
column: [
{
label: 'ParentRole',
prop: 'parentId',
dicData: [],
type: 'tree',
hide: true,
span: 24,
props: {
label: 'title',
},
rules: [
{
required: false,
message: '请选择上级角色',
trigger: 'click',
},
],
},
{
label: 'RoleName',
prop: 'roleName',
search: true,
span: 24,
rules: [
{
required: true,
message: 'Please input role name',
trigger: 'blur',
},
],
},
{
label: 'Tenant',
prop: 'tenantId',
type: 'tree',
dicUrl: '/blade-system/tenant/select',
addDisplay: false,
editDisplay: false,
viewDisplay: website.tenantMode,
span: 24,
props: {
label: 'tenantName',
value: 'tenantId',
},
hide: !website.tenantMode,
search: website.tenantMode,
rules: [
{
required: true,
message: 'Please input tenant',
trigger: 'click',
},
],
},
{
label: 'RoleAlias',
labelTip:
'An attribute used for permission validation and annotation, which can be entered manually or selected quickly from existing aliases.',
prop: 'roleAlias',
search: true,
span: 24,
rules: [
{
required: true,
message: 'Please input role alias',
trigger: 'blur',
},
],
},
{
label: 'CurrentAlias',
labelTip: 'Existing role aliases in the system — click to quickly insert.',
prop: 'currentAlias',
type: 'radio',
dicData: [],
props: {
label: 'roleName',
value: 'roleAlias',
},
hide: true,
span: 24,
},
{
label: 'Sort',
prop: 'sort',
type: 'number',
span: 24,
rules: [
{
required: true,
message: 'Please input role sort',
trigger: 'blur',
},
],
},
],
},
data: [],
};
},
computed: {
...mapGetters(['userInfo', 'permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.role_add, false),
viewBtn: this.validData(this.permission.role_view, false),
delBtn: this.validData(this.permission.role_delete, false),
editBtn: this.validData(this.permission.role_edit, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
idsArray() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids;
},
},
watch: {
'form.currentAlias'() {
const alias = this.form.currentAlias;
if (!validatenull(alias)) {
this.form.roleAlias = alias;
}
},
},
methods: {
initData(roleId) {
getRoleTreeById(roleId).then(res => {
const column = this.findObject(this.option.column, 'parentId');
column.dicData = res.data.data;
});
},
submit() {
const menuList = this.$refs.treeMenu.getCheckedKeys();
const dataScopeList = this.$refs.treeDataScope.getCheckedKeys();
const apiScopeList = this.$refs.treeApiScope.getCheckedKeys();
grant(this.idsArray, menuList, dataScopeList, apiScopeList).then(() => {
this.box = false;
this.$message({
type: 'success',
message: '操作成功!',
});
this.selectionList = [];
this.onLoad(this.page);
});
},
rowSave(row, done, loading) {
add(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
beforeOpen(done, type) {
if (['add', 'edit'].includes(type)) {
this.initData(this.form.id);
}
if (['edit', 'view'].includes(type)) {
if (this.form.parentId === '0') {
this.form.parentId = '';
}
}
getRoleAlias().then(res => {
const column = this.findObject(this.option.column, 'currentAlias');
column.dicData = res.data.data;
});
done();
},
handleRole() {
if (this.selectionList.length !== 1) {
this.$message.warning('只能选择一条数据');
return;
}
this.menuTreeObj = [];
this.dataScopeTreeObj = [];
this.apiScopeTreeObj = [];
grantTree().then(res => {
this.menuGrantList = res.data.data.menu;
this.dataScopeGrantList = res.data.data.dataScope;
this.apiScopeGrantList = res.data.data.apiScope;
getRole(this.ids).then(res => {
this.menuTreeObj = res.data.data.menu;
this.dataScopeTreeObj = res.data.data.dataScope;
this.apiScopeTreeObj = res.data.data.apiScope;
this.box = true;
});
});
},
handleRowRole(row) {
this.menuTreeObj = [];
this.dataScopeTreeObj = [];
this.apiScopeTreeObj = [];
grantTree().then(res => {
this.menuGrantList = res.data.data.menu;
this.dataScopeGrantList = res.data.data.dataScope;
this.apiScopeGrantList = res.data.data.apiScope;
getRole(row.id).then(res => {
this.menuTreeObj = res.data.data.menu;
this.dataScopeTreeObj = res.data.data.dataScope;
this.apiScopeTreeObj = res.data.data.apiScope;
this.selectionList.push(row);
this.box = true;
});
});
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
this.data = res.data.data;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>

472
src/views/base/region.vue Normal file
View File

@@ -0,0 +1,472 @@
<template>
<el-row>
<el-col :span="9">
<div class="box">
<el-scrollbar>
<basic-container>
<avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" />
</basic-container>
</el-scrollbar>
</div>
</el-col>
<el-col :span="15">
<basic-container>
<el-button-group>
<el-button
v-if="permission.region_add"
type="primary"
icon="el-icon-plus"
@click="addChildren"
>新增下级
</el-button>
<el-button
v-if="permission.region_delete"
type="primary"
icon="el-icon-delete"
@click="handleDelete"
>删除
</el-button>
<el-button
v-if="permission.region_import"
type="primary"
icon="el-icon-upload"
@click="handleImport"
>导入
</el-button>
<el-button
v-if="permission.region_export"
type="primary"
icon="el-icon-download"
@click="handleExport"
>导出
</el-button>
<el-button
v-if="permission.region_debug"
type="primary"
icon="el-icon-video-play"
@click="handleDebug"
>调试
</el-button>
</el-button-group>
</basic-container>
<basic-container>
<avue-form ref="form" :option="regionOption" v-model="regionForm" @submit="handleSubmit">
<template #code="{}">
<el-input placeholder="请输入 区划子编号" v-model="regionForm.subCode">
<template #prepend>{{ regionForm.parentCode }}</template>
</el-input>
</template>
</avue-form>
<el-dialog title="行政区划数据导入" append-to-body v-model="excelBox" width="555px">
<avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
<template #excelTemplate>
<el-button type="primary" @click="handleTemplate">
点击下载<i class="el-icon-download el-icon--right"></i>
</el-button>
</template>
</avue-form>
</el-dialog>
<el-dialog title="行政区划数据调试" append-to-body v-model="debugBox" width="350px">
<avue-form :option="debugOption" v-model="debugForm" />
</el-dialog>
</basic-container>
</el-col>
</el-row>
</template>
<script>
import { getLazyTree, getDetail, submit, remove } from '@/api/base/region';
import { exportBlob } from '@/api/common';
import { mapGetters } from 'vuex';
import { validatenull } from '@/utils/validate';
import { downloadXls } from '@/utils/util';
import { getToken } from '@/utils/auth';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
export default {
data() {
return {
topCode: '00',
treeCode: '',
treeParentCode: '',
treeData: [],
treeOption: {
nodeKey: 'id',
lazy: true,
treeLoad: function (node, resolve) {
const parentCode = node.level === 0 ? '00' : node.data.id;
getLazyTree(parentCode).then(res => {
resolve(
res.data.data.map(item => {
return {
...item,
leaf: !item.hasChildren,
};
})
);
});
},
addBtn: false,
menu: false,
size: 'small',
props: {
labelText: '标题',
label: 'title',
value: 'value',
children: 'children',
},
},
regionForm: {},
regionOption: {
labelWidth: 100,
column: [
{
label: '父区划编号',
prop: 'parentCode',
span: 24,
disabled: true,
rules: [
{
required: true,
message: '请输入父区划编号',
trigger: 'blur',
},
],
},
{
label: '父区划名称',
prop: 'parentName',
span: 24,
disabled: true,
},
{
label: '区划编号',
prop: 'code',
formslot: true,
span: 24,
rules: [
{
required: true,
message: '请输入区划编号',
trigger: 'blur',
},
],
},
{
label: '区划子编号',
prop: 'subCode',
display: false,
},
{
label: '区划名称',
prop: 'name',
span: 24,
rules: [
{
required: true,
message: '请输入区划名称',
trigger: 'blur',
},
],
},
{
label: '区划等级',
prop: 'regionLevel',
type: 'radio',
dicUrl: '/blade-system/dict/dictionary?code=region',
props: {
label: 'dictValue',
value: 'dictKey',
},
dataType: 'number',
span: 24,
rules: [
{
required: true,
message: '请选择区划等级',
trigger: 'blur',
},
],
},
{
label: '区划排序',
prop: 'sort',
type: 'number',
span: 24,
rules: [
{
required: true,
message: '请输入区划排序',
trigger: 'blur',
},
],
},
{
label: '区划备注',
prop: 'remark',
type: 'textarea',
minRows: 6,
span: 24,
},
],
},
excelBox: false,
excelForm: {},
excelOption: {
submitBtn: false,
emptyBtn: false,
column: [
{
label: '模板上传',
prop: 'excelFile',
type: 'upload',
drag: true,
loadText: '模板上传中,请稍等',
span: 24,
propsHttp: {
res: 'data',
},
tip: '请上传 .xls,.xlsx 标准格式文件',
action: '/blade-system/region/import-region',
},
{
label: '数据覆盖',
prop: 'isCovered',
type: 'switch',
align: 'center',
width: 80,
dicData: [
{
label: '否',
value: 0,
},
{
label: '是',
value: 1,
},
],
value: 0,
slot: true,
rules: [
{
required: true,
message: '请选择是否覆盖',
trigger: 'blur',
},
],
},
{
label: '模板下载',
prop: 'excelTemplate',
formslot: true,
span: 24,
},
],
},
debugBox: false,
debugForm: {},
debugOption: {
labelWidth: 50,
submitBtn: false,
emptyBtn: false,
column: [
{
label: '省份',
prop: 'province',
type: 'select',
props: {
label: 'name',
value: 'code',
},
cascader: ['city'],
dicUrl: '/blade-system/region/select',
span: 24,
},
{
label: '地市',
prop: 'city',
type: 'select',
props: {
label: 'name',
value: 'code',
},
cascader: ['district'],
dicFlag: false,
dicUrl: '/blade-system/region/select?code={{province}}',
span: 24,
},
{
label: '区县',
prop: 'district',
type: 'select',
props: {
label: 'name',
value: 'code',
},
dicFlag: false,
dicUrl: '/blade-system/region/select?code={{city}}',
span: 24,
},
],
},
};
},
watch: {
'regionForm.subCode'() {
this.regionForm.code = this.regionForm.parentCode + this.regionForm.subCode;
},
'excelForm.isCovered'() {
if (this.excelForm.isCovered !== '') {
const column = this.findObject(this.excelOption.column, 'excelFile');
column.action = `/blade-system/region/import-region?isCovered=${this.excelForm.isCovered}`;
}
},
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.region_add, false),
viewBtn: this.validData(this.permission.region_view, false),
delBtn: this.validData(this.permission.region_delete, false),
editBtn: this.validData(this.permission.region_edit, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
initTree() {
this.treeData = [];
getLazyTree(this.topCode).then(res => {
this.treeData = res.data.data.map(item => {
return {
...item,
leaf: !item.hasChildren,
};
});
});
},
nodeClick(data) {
const column = this.findObject(this.regionOption.column, 'parentCode');
column.disabled = true;
this.treeCode = data.id;
this.treeParentCode = data.parentId;
getDetail(this.treeCode).then(res => {
this.regionForm = res.data.data;
this.regionForm.subCode = this.regionForm.code.replace(this.regionForm.parentCode, '');
});
},
addChildren() {
if (validatenull(this.regionForm.code) || validatenull(this.regionForm.name)) {
this.$message.warning('请先选择一项区划');
return;
}
this.regionForm.parentCode = this.regionForm.code;
this.regionForm.parentName = this.regionForm.name;
this.regionForm.code = '';
this.regionForm.subCode = '';
this.regionForm.name = '';
this.regionForm.regionLevel =
this.regionForm.regionLevel === 5 ? 5 : this.regionForm.regionLevel + 1;
},
handleSubmit(form, done) {
const parentCode = form.parentCode === this.topCode ? '' : form.parentCode;
form.code = parentCode + form.subCode;
submit(form).then(
() => {
this.$message({
type: 'success',
message: '操作成功!',
});
this.initTree();
this.regionForm.subCode = '';
this.$refs.form.resetForm();
done();
},
error => {
done();
window.console.log(error);
}
);
},
handleDelete() {
if (validatenull(this.regionForm.code)) {
this.$message.warning('请先选择一项区划');
return;
}
this.$confirm(`确定将 [${this.regionForm.name}] 数据删除?`, {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.treeCode);
})
.then(() => {
this.$message({
type: 'success',
message: '操作成功!',
});
this.initTree();
this.regionForm.subCode = '';
this.$refs.form.resetForm();
});
},
uploadAfter(res, done, loading, column) {
window.console.log(column);
this.excelBox = false;
this.initTree();
done();
},
handleDebug() {
this.debugBox = true;
},
handleImport() {
this.excelBox = true;
},
handleExport() {
this.$confirm('是否导出行政区划数据?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
NProgress.start();
exportBlob(
`/blade-system/region/export-region?${this.website.tokenHeader}=${getToken()}`
).then(res => {
downloadXls(res.data, `行政区划数据${this.$dayjs().format('YYYY-MM-DD HH:mm:ss')}.xlsx`);
NProgress.done();
});
});
},
handleTemplate() {
exportBlob(
`/blade-system/region/export-template?${this.website.tokenHeader}=${getToken()}`
).then(res => {
downloadXls(res.data, '行政区划模板.xlsx');
});
},
},
};
</script>
<style>
.box {
height: 800px;
}
.el-scrollbar {
height: 100%;
}
.box .el-scrollbar__wrap {
overflow: scroll;
}
</style>

290
src/views/data/record.vue Normal file
View File

@@ -0,0 +1,290 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
ref="crud"
v-model="form"
:permission="permissionList"
:before-open="beforeOpen"
v-model:page="page"
@search-change="searchChange"
@search-reset="searchReset"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #userAgent-form="{}">
<code-editor v-model="form.userAgent" :readonly="true" theme="nord" height="50px" />
</template>
<template #oldData-form="{}">
<code-editor
v-model="form.oldData"
:json="true"
:readonly="true"
theme="nord"
height="200px"
/>
</template>
<template #newData-form="{}">
<code-editor
v-model="form.newData"
:json="true"
:readonly="true"
theme="nord"
height="200px"
/>
</template>
<template #recordResult-form="{}">
<code-editor
v-model="form.recordResult"
:json="true"
:readonly="true"
theme="nord"
height="350px"
/>
</template>
<template #recordMessage-form="{}">
<code-editor v-model="form.recordMessage" :readonly="true" theme="nord" height="350px" />
</template>
<template #env="{ row }">
<el-tag>{{ row.env }}</el-tag>
</template>
<template #tableName="{ row }">
<el-tag>{{ row.tableName }}</el-tag>
</template>
<template #method="{ row }">
<el-tag>{{ row.method }}</el-tag>
</template>
<template #recordLevel="{ row }">
<el-tag>{{ row.recordLevel }}</el-tag>
</template>
<template #remoteIp="{ row }">
<el-tag>{{ row.remoteIp }}</el-tag>
</template>
</avue-crud>
</basic-container>
</template>
<script>
import { getRecordList, getRecordDetail } from '@/api/data/record';
import { mapGetters } from 'vuex';
export default {
data() {
return {
form: {},
selectionList: [],
query: {},
loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
option: {
height: 'auto',
calcHeight: 32,
tip: false,
searchShow: true,
searchMenuSpan: 6,
searchIndex: 3,
searchIcon: true,
border: true,
index: true,
viewBtn: true,
editBtn: false,
addBtn: false,
delBtn: false,
menuWidth: 120,
labelWidth: 120,
dialogType: 'drawer',
column: [
{
label: '服务ID',
prop: 'serviceId',
width: '120',
search: true,
},
{
label: '服务器名',
prop: 'serverHost',
width: '140',
search: true,
},
{
label: '服务器IP',
prop: 'serverIp',
width: '180',
search: true,
},
{
label: '环境',
prop: 'env',
width: '80',
search: true,
slot: true,
},
{
label: '审计级别',
prop: 'recordLevel',
width: '100',
search: true,
slot: true,
},
{
label: '数据表名',
prop: 'tableName',
width: '150',
search: true,
slot: true,
},
{
label: '操作方式',
prop: 'method',
width: '100',
slot: true,
},
{
label: '请求URI',
prop: 'requestUri',
search: true,
overHidden: true,
},
{
label: '操作类型',
prop: 'operation',
width: '100',
hide: true,
},
{
label: '操作IP',
prop: 'remoteIp',
width: '140',
slot: true,
},
{
label: '记录人',
prop: 'recordUserName',
width: '120',
hide: true,
},
{
label: '记录耗时',
prop: 'recordCost',
width: '100',
suffix: 'ms',
hide: true,
},
{
label: '记录时间',
prop: 'recordTime',
width: '180',
type: 'datetime',
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
span: 24,
},
{
label: '用户代理',
prop: 'userAgent',
span: 24,
hide: true,
},
{
label: '操作前数据',
prop: 'oldData',
type: 'textarea',
span: 24,
minRows: 3,
hide: true,
},
{
label: '操作后数据',
prop: 'newData',
type: 'textarea',
span: 24,
minRows: 3,
hide: true,
},
{
label: '审计结果',
prop: 'recordResult',
type: 'textarea',
span: 24,
minRows: 3,
hide: true,
},
{
label: '审计消息',
prop: 'recordMessage',
type: 'textarea',
span: 24,
minRows: 2,
hide: true,
},
],
},
data: [],
};
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
viewBtn: this.validData(this.permission.record_view, false),
};
},
},
methods: {
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getRecordDetail(this.form.id).then(res => {
this.form = res.data.data;
});
}
done();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getRecordList(page.currentPage, page.pageSize, Object.assign(params, this.query))
.then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
})
.catch(() => {
this.loading = false;
});
},
},
};
</script>
<style scoped>
/* 可以根据需要添加自定义样式 */
</style>

View File

@@ -0,0 +1,309 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
v-model:page="page"
v-model:search="search"
ref="crud"
@row-del="rowDel"
v-model="form"
:permission="permissionList"
@row-update="rowUpdate"
@row-save="rowSave"
:before-open="beforeOpen"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
plain
v-if="permission.notice_delete"
@click="handleDelete"
>删 除
</el-button>
</template>
<template #category="{ row }">
<el-tag>{{ row.categoryName }}</el-tag>
</template>
</avue-crud>
</basic-container>
</template>
<script setup>
import { ElMessage, ElMessageBox } from 'element-plus';
import { ref, reactive, computed, onMounted } from 'vue';
import { useStore } from 'vuex';
import { getList, remove, update, add, getNotice } from '@/api/desk/notice';
// 定义响应式数据
const form = ref({});
const search = ref({});
const loading = ref(true);
const page = ref({
pageSize: 10,
currentPage: 1,
total: 0,
});
const selectionList = ref([]);
const data = ref([]);
const option = reactive({
height: 'auto',
calcHeight: 32,
dialogWidth: 950,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
selection: true,
excelBtn: true,
dialogClickModal: false,
grid: false,
column: [
{
label: '通知标题',
prop: 'title',
span: 24,
row: true,
search: true,
rules: [
{
required: true,
message: '请输入通知标题',
trigger: 'blur',
},
],
},
{
label: '通知类型',
type: 'select',
dicUrl: '/blade-system/dict/dictionary?code=notice',
props: {
label: 'dictValue',
value: 'dictKey',
},
dataType: 'number',
slot: true,
prop: 'category',
search: true,
rules: [
{
required: true,
message: '请输入通知类型',
trigger: 'blur',
},
],
},
{
label: '通知时间',
prop: 'releaseTimeRange',
type: 'datetime',
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
searchRange: true,
hide: true,
addDisplay: false,
editDisplay: false,
viewDisplay: false,
search: true,
rules: [
{
required: true,
message: '请输入通知时间',
trigger: 'blur',
},
],
},
{
label: '通知日期',
prop: 'releaseTime',
type: 'date',
gridRow: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
rules: [
{
required: true,
message: '请输入通知日期',
trigger: 'click',
},
],
},
{
label: '通知内容',
prop: 'content',
component: 'avue-ueditor',
action: '/blade-resource/oss/endpoint/put-file',
propsHttp: {
res: 'data',
url: 'link',
},
hide: true,
minRows: 4,
span: 24,
},
],
});
// 使用 vuex store
const store = useStore();
const permission = computed(() => store.getters.permission);
// 计算权限
const permissionList = computed(() => {
const validData = (value, defaultVal = false) => (value ? true : defaultVal);
return {
addBtn: validData(permission.value.notice_add, false),
viewBtn: validData(permission.value.notice_view, false),
delBtn: validData(permission.value.notice_delete, false),
editBtn: validData(permission.value.notice_edit, false),
};
});
// 计算选中的id
const ids = computed(() => {
return selectionList.value.map(ele => ele.id).join(',');
});
// 新增
const rowSave = (row, done, loading) => {
add(row).then(
() => {
onLoad();
ElMessage.success('操作成功!');
done();
},
error => {
console.error(error);
loading();
}
);
};
// 修改
const rowUpdate = (row, index, done, loading) => {
update(row).then(
() => {
onLoad();
ElMessage.success('操作成功!');
done();
},
error => {
console.error(error);
loading();
}
);
};
// 删除
const rowDel = row => {
ElMessageBox.confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => remove(row.id))
.then(() => {
onLoad();
ElMessage.success('操作成功!');
});
};
// 重置查询
const searchReset = () => {
search.value = {};
page.value.currentPage = 1;
onLoad();
};
// 查询
const searchChange = (params, done) => {
page.value.currentPage = 1;
onLoad();
done();
};
// 勾选事件
const selectionChange = list => {
selectionList.value = list;
};
// 重置勾选
const selectionClear = () => {
selectionList.value = [];
// 假设你有一个 ref 为 'crud' 的组件,可以调用 toggleSelection 方法
// if (crudRef.value) crudRef.value.toggleSelection();
};
// 批量删除
const handleDelete = () => {
if (selectionList.value.length === 0) {
ElMessage.success('请选择至少一条数据');
return;
}
ElMessageBox.confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => remove(ids.value))
.then(() => {
onLoad();
ElMessage.success('操作成功!');
});
};
// 打开前事件
const beforeOpen = (done, type) => {
if (['edit', 'view'].includes(type)) {
getNotice(form.value.id).then(res => {
form.value = res.data.data;
});
}
done();
};
// 刷新事件
const refreshChange = () => {
onLoad();
};
// 加载数据
const onLoad = () => {
const { releaseTimeRange } = search.value;
let values = { ...search.value };
if (releaseTimeRange) {
values = {
...values,
releaseTime_datege: releaseTimeRange[0],
releaseTime_datelt: releaseTimeRange[1],
};
values.releaseTimeRange = null;
}
loading.value = true;
getList(page.value.currentPage, page.value.pageSize, values).then(res => {
const { total, records } = res.data.data;
page.value.total = total;
data.value = records;
loading.value = false;
selectionClear();
});
};
// 生命周期钩子
onMounted(() => {
// 可以在这里执行组件挂载后的逻辑
});
</script>
<style scoped>
/* 你的样式代码 */
</style>

309
src/views/desk/notice.vue Normal file
View File

@@ -0,0 +1,309 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
v-model:page="page"
ref="crud"
@row-del="rowDel"
v-model="form"
:permission="permissionList"
@row-update="rowUpdate"
@row-save="rowSave"
:before-open="beforeOpen"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
plain
v-if="permission.notice_delete"
@click="handleDelete"
>删 除
</el-button>
</template>
<template #category="{ row }">
<el-tag>{{ row.categoryName }}</el-tag>
</template>
</avue-crud>
</basic-container>
</template>
<script>
import { getList, remove, update, add, getNotice } from '@/api/desk/notice';
import { mapGetters } from 'vuex';
export default {
data() {
return {
form: {},
query: {},
loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
selectionList: [],
option: {
height: 'auto',
calcHeight: 32,
dialogWidth: 950,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
selection: true,
excelBtn: true,
dialogClickModal: false,
grid: false,
column: [
{
label: '通知标题',
prop: 'title',
span: 24,
row: true,
search: true,
rules: [
{
required: true,
message: '请输入通知标题',
trigger: 'blur',
},
],
},
{
label: '通知类型',
type: 'select',
dicUrl: '/blade-system/dict/dictionary?code=notice',
props: {
label: 'dictValue',
value: 'dictKey',
},
dataType: 'number',
slot: true,
prop: 'category',
search: true,
rules: [
{
required: true,
message: '请输入通知类型',
trigger: 'blur',
},
],
},
{
label: '通知时间',
prop: 'releaseTimeRange',
type: 'datetime',
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
searchRange: true,
hide: true,
addDisplay: false,
editDisplay: false,
viewDisplay: false,
search: true,
rules: [
{
required: true,
message: '请输入通知时间',
trigger: 'blur',
},
],
},
{
label: '通知日期',
prop: 'releaseTime',
type: 'date',
gridRow: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
rules: [
{
required: true,
message: '请输入通知日期',
trigger: 'click',
},
],
},
{
label: '通知内容',
prop: 'content',
component: 'avue-ueditor',
action: '/blade-resource/oss/endpoint/put-file',
propsHttp: {
res: 'data',
url: 'link',
},
hide: true,
minRows: 4,
span: 24,
},
],
},
data: [],
};
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.notice_add, false),
viewBtn: this.validData(this.permission.notice_view, false),
delBtn: this.validData(this.permission.notice_delete, false),
editBtn: this.validData(this.permission.notice_edit, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
rowSave(row, done, loading) {
add(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getNotice(this.form.id).then(res => {
this.form = res.data.data;
});
}
done();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
const { releaseTimeRange } = this.query;
let values = {
...params,
...this.query,
};
if (releaseTimeRange) {
values = {
...values,
releaseTime_datege: releaseTimeRange[0],
releaseTime_datelt: releaseTimeRange[1],
};
values.releaseTimeRange = null;
}
this.loading = true;
getList(page.currentPage, page.pageSize, values).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>
<style></style>

View File

@@ -0,0 +1,225 @@
<template>
<basic-container>
<avue-crud :option="option"
v-model:search="search"
v-model:page="page"
v-model="form"
:table-loading="loading"
:data="data"
:permission="permissionList"
:before-open="beforeOpen"
ref="crud"
@row-update="rowUpdate"
@row-save="rowSave"
@row-del="rowDel"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad">
<template #menu-left>
<el-button type="danger"
icon="el-icon-delete"
plain
v-if="permission.category_delete"
@click="handleDelete">删 除
</el-button>
<el-button type="warning"
plain
icon="el-icon-download"
@click="handleExport">导 出
</el-button>
</template>
</avue-crud>
</basic-container>
</template>
<script>
import {getList, getDetail, add, update, remove} from "@/api/kiosk/category";
import option from "@/option/kiosk/category";
import {mapGetters} from "vuex";
import {exportBlob} from "@/api/common";
import {getToken} from '@/utils/auth';
import {downloadXls} from "@/utils/util";
import {dateNow} from "@/utils/date";
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
export default {
data() {
return {
form: {},
query: {},
search: {},
loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0
},
selectionList: [],
option: option,
data: []
};
},
computed: {
...mapGetters(["permission"]),
permissionList() {
return {
addBtn: this.validData(this.permission.category_add, false),
viewBtn: this.validData(this.permission.category_view, false),
delBtn: this.validData(this.permission.category_delete, false),
editBtn: this.validData(this.permission.category_edit, false)
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(",");
}
},
methods: {
rowSave(row, done, loading) {
add(row).then(() => {
this.onLoad(this.page);
this.$message({
type: "success",
message: "操作成功!"
});
done();
}, error => {
loading();
window.console.log(error);
});
},
rowUpdate(row, index, done, loading) {
update(row).then(() => {
this.onLoad(this.page);
this.$message({
type: "success",
message: "操作成功!"
});
done();
}, error => {
loading();
console.log(error);
});
},
rowDel(row) {
this.$confirm("确定将选择数据删除?", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: "success",
message: "操作成功!"
});
});
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning("请选择至少一条数据");
return;
}
this.$confirm("确定将选择数据删除?", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: "success",
message: "操作成功!"
});
this.$refs.crud.toggleSelection();
});
},
handleExport() {
let downloadUrl = `/kiosk-category/category/export-category?${this.website.tokenHeader}=${getToken()}`;
const {
} = this.query;
let values = {
};
this.$confirm("是否导出数据?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
NProgress.start();
exportBlob(downloadUrl, values).then(res => {
downloadXls(res.data, `自助终端产品目录表${dateNow()}.xlsx`);
NProgress.done();
})
});
},
beforeOpen(done, type) {
if (["edit", "view"].includes(type)) {
getDetail(this.form.id).then(res => {
this.form = res.data.data;
});
}
done();
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
currentChange(currentPage){
this.page.currentPage = currentPage;
},
sizeChange(pageSize){
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
const {
} = this.query;
let values = {
};
getList(page.currentPage, page.pageSize, values).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
this.selectionClear();
});
}
}
};
</script>
<style>
</style>

View File

@@ -0,0 +1,162 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
ref="crud"
v-model="form"
:permission="permissionList"
:before-open="beforeOpen"
v-model:page="page"
@search-change="searchChange"
@search-reset="searchReset"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
</avue-crud>
</basic-container>
</template>
<script>
import { getApiList, getApiLogs } from '@/api/logs';
import { mapGetters } from 'vuex';
export default {
data() {
return {
form: {},
selectionList: [],
query: {},
loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
option: {
height: 'auto',
calcHeight: 32,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
editBtn: false,
addBtn: false,
delBtn: false,
menuWidth: 120,
dialogType: 'drawer',
column: [
{
label: '服务id',
prop: 'serviceId',
width: '120',
search: true,
},
{
label: '服务host',
prop: 'serverHost',
search: true,
},
{
label: '服务ip',
prop: 'serverIp',
width: '160',
},
{
label: '软件环境',
prop: 'env',
width: '85',
},
{
label: '日志名',
prop: 'title',
},
{
label: '请求方法',
prop: 'method',
width: '85',
},
{
label: '请求接口',
prop: 'requestUri',
},
{
label: '日志时间',
prop: 'createTime',
width: '180',
},
{
label: '用户代理',
prop: 'userAgent',
span: 24,
hide: true,
},
{
label: '请求数据',
prop: 'params',
type: 'textarea',
span: 24,
minRows: 2,
hide: true,
},
],
},
data: [],
};
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
viewBtn: this.validData(this.permission.log_api_view, false),
};
},
},
methods: {
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getApiLogs(this.form.id).then(res => {
this.form = res.data.data;
});
}
done();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getApiList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
});
},
},
};
</script>
<style></style>

View File

@@ -0,0 +1,166 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
ref="crud"
:before-open="beforeOpen"
v-model="form"
:permission="permissionList"
v-model:page="page"
@search-change="searchChange"
@search-reset="searchReset"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
</avue-crud>
</basic-container>
</template>
<script>
import { getErrorList, getErrorLogs } from '@/api/logs';
import { mapGetters } from 'vuex';
export default {
data() {
return {
form: {},
selectionList: [],
query: {},
loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
option: {
height: 'auto',
calcHeight: 32,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
editBtn: false,
addBtn: false,
delBtn: false,
menuWidth: 120,
dialogType: 'drawer',
column: [
{
label: '服务id',
prop: 'serviceId',
search: true,
width: '120',
},
{
label: '服务host',
prop: 'serverHost',
search: true,
width: '150',
},
{
label: '服务ip',
prop: 'serverIp',
width: '160',
},
{
label: '软件环境',
prop: 'env',
width: '85',
},
{
label: '请求方法',
prop: 'method',
width: '85',
},
{
label: '请求接口',
prop: 'requestUri',
},
{
label: '日志时间',
prop: 'createTime',
width: '180',
},
{
label: '用户代理',
prop: 'userAgent',
span: 24,
hide: true,
},
{
label: '请求数据',
prop: 'params',
type: 'textarea',
span: 24,
minRows: 2,
hide: true,
},
{
label: '日志数据',
prop: 'stackTrace',
type: 'textarea',
span: 24,
minRows: 16,
hide: true,
},
],
},
data: [],
};
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
viewBtn: this.validData(this.permission.log_error_view, false),
};
},
},
methods: {
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getErrorLogs(this.form.id).then(res => {
this.form = res.data.data;
});
}
done();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getErrorList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
});
},
},
};
</script>
<style></style>

View File

@@ -0,0 +1,166 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
ref="crud"
v-model="form"
:permission="permissionList"
v-model:page="page"
:before-open="beforeOpen"
@search-change="searchChange"
@search-reset="searchReset"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
</avue-crud>
</basic-container>
</template>
<script>
import { getUsualList, getUsualLogs } from '@/api/logs';
import { mapGetters } from 'vuex';
export default {
data() {
return {
form: {},
selectionList: [],
query: {},
loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
option: {
height: 'auto',
calcHeight: 32,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
editBtn: false,
addBtn: false,
delBtn: false,
menuWidth: 120,
dialogType: 'drawer',
column: [
{
label: '服务id',
prop: 'serviceId',
search: true,
},
{
label: '服务host',
prop: 'serverHost',
search: true,
},
{
label: '服务ip',
prop: 'serverIp',
},
{
label: '软件环境',
prop: 'env',
width: '100',
},
{
label: '日志级别',
prop: 'logLevel',
},
{
label: '日志id',
prop: 'logId',
},
{
label: '请求接口',
prop: 'requestUri',
},
{
label: '日志时间',
prop: 'createTime',
width: '180',
},
{
label: '用户代理',
prop: 'userAgent',
span: 24,
hide: true,
},
{
label: '日志数据',
prop: 'logData',
type: 'textarea',
span: 24,
minRows: 2,
hide: true,
},
{
label: '请求数据',
prop: 'params',
type: 'textarea',
span: 24,
minRows: 2,
hide: true,
},
],
},
data: [],
};
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
viewBtn: this.validData(this.permission.log_usual_view, false),
};
},
},
methods: {
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getUsualLogs(this.form.id).then(res => {
this.form = res.data.data;
});
}
done();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getUsualList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
});
},
},
};
</script>
<style></style>

View File

@@ -0,0 +1,210 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
ref="crud"
v-model="form"
v-model:page="page"
:permission="permissionList"
@row-del="rowDel"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button type="danger" icon="el-icon-delete" plain @click="handleDelete"
>删 除
</el-button>
</template>
<template #menu="scope">
<el-button
type="primary"
text
icon="el-icon-edit"
@click.stop="handleDesign(scope.row.name)"
v-if="userInfo.authority.includes('admin')"
>设计
</el-button>
<el-button
type="primary"
text
icon="el-icon-view"
@click.stop="handlePreview(scope.row.name)"
v-if="userInfo.authority.includes('admin')"
>预览
</el-button>
</template>
<template #name="{ row }">
<el-tag style="cursor: pointer" @click="handlePreview(row.name)">{{ row.name }}</el-tag>
</template>
</avue-crud>
</basic-container>
</template>
<script>
import { getList, remove } from '@/api/report/report';
import { getToken } from '@/utils/auth';
import { mapGetters } from 'vuex';
export default {
data() {
return {
form: {},
selectionList: [],
query: {},
loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
option: {
height: 'auto',
calcHeight: 32,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
selection: true,
viewBtn: true,
dialogClickModal: false,
column: [
{
label: '文件名',
prop: 'name',
search: true,
slot: true,
},
{
label: '创建时间',
prop: 'createTime',
},
{
label: '更新时间',
prop: 'updateTime',
},
],
},
data: [],
};
},
computed: {
...mapGetters(['userInfo', 'permission']),
permissionList() {
return {
addBtn: false,
viewBtn: false,
delBtn: true,
editBtn: false,
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
handlePreview(name) {
window.open(
`${this.website.design.reportUrl}/preview?_u=blade-${name}&${
this.website.tokenHeader
}=bearer ${getToken()}`
);
},
handleDesign(name) {
window.open(
`${this.website.design.reportUrl}/designer?_u=blade-${name}&${
this.website.tokenHeader
}=bearer ${getToken()}`
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>
<style></style>

View File

@@ -0,0 +1,306 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
v-model:page="page"
:permission="permissionList"
:before-open="beforeOpen"
v-model="form"
ref="crud"
@row-del="rowDel"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button
type="primary"
plain
v-if="permission.attach_upload"
icon="el-icon-upload"
@click="handleUpload"
>上 传
</el-button>
<el-button
type="danger"
icon="el-icon-delete"
plain
v-if="permission.attach_delete"
@click="handleDelete"
>删 除
</el-button>
</template>
<template #menu="scope">
<el-button
type="primary"
text
icon="el-icon-download"
v-if="permission.attach_download"
@click="handleDownload(scope.row)"
>下载
</el-button>
</template>
<template #attachSize="{ row }">
<el-tag>{{ `${func.bytesToKB(row.attachSize)} KB` }}</el-tag>
</template>
</avue-crud>
<el-dialog title="附件管理" append-to-body v-model="attachBox" width="555px">
<avue-form ref="form" :option="attachOption" v-model="attachForm" :upload-after="uploadAfter">
</avue-form>
</el-dialog>
</basic-container>
</template>
<script>
import { getList, getDetail, remove } from '@/api/resource/attach';
import { mapGetters } from 'vuex';
import func from '@/utils/func';
export default {
data() {
return {
form: {},
query: {},
loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
attachBox: false,
selectionList: [],
option: {
height: 'auto',
calcHeight: 32,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
grid: true,
selection: true,
dialogClickModal: false,
column: [
{
label: '附件地址',
prop: 'link',
rules: [
{
required: true,
message: '请输入附件地址',
trigger: 'blur',
},
],
},
{
label: '附件域名',
prop: 'domainUrl',
search: true,
rules: [
{
required: true,
message: '请输入附件域名',
trigger: 'blur',
},
],
},
{
label: '附件名称',
prop: 'name',
search: true,
rules: [
{
required: true,
message: '请输入附件名称',
trigger: 'blur',
},
],
},
{
label: '附件原名',
prop: 'originalName',
search: true,
rules: [
{
required: true,
message: '请输入附件原名',
trigger: 'blur',
},
],
},
{
label: '附件拓展名',
prop: 'extension',
rules: [
{
required: true,
message: '请输入附件拓展名',
trigger: 'blur',
},
],
},
{
label: '附件大小',
prop: 'attachSize',
slot: true,
rules: [
{
required: true,
message: '请输入附件大小',
trigger: 'blur',
},
],
},
],
},
data: [],
attachForm: {},
attachOption: {
submitBtn: false,
emptyBtn: false,
column: [
{
label: '附件上传',
prop: 'attachFile',
type: 'upload',
drag: true,
loadText: '模板上传中,请稍等',
span: 24,
propsHttp: {
res: 'data',
},
action: '/blade-resource/oss/endpoint/put-file-attach',
},
],
},
};
},
computed: {
func() {
return func;
},
...mapGetters(['permission']),
permissionList() {
return {
addBtn: false,
editBtn: false,
viewBtn: false,
delBtn: this.validData(this.permission.attach_delete, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
handleUpload() {
this.attachBox = true;
},
uploadAfter(res, done, loading, column) {
window.console.log(column);
this.attachBox = false;
this.refreshChange();
done();
},
handleDownload(row) {
window.open(`${row.link}`);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => {
this.form = res.data.data;
});
}
done();
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>
<style></style>

469
src/views/resource/oss.vue Normal file
View File

@@ -0,0 +1,469 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
v-model:page="page"
:permission="permissionList"
v-model="form"
ref="crud"
@row-update="rowUpdate"
@row-save="rowSave"
@row-del="rowDel"
:before-open="beforeOpen"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
plain
v-if="permission.oss_delete"
@click="handleDelete"
>删 除
</el-button>
</template>
<template #menu="scope">
<el-button
type="primary"
text
icon="el-icon-video-play"
v-if="userInfo.authority.includes('admin')"
@click="handleDebug(scope.row)"
>调试
</el-button>
<el-button
type="primary"
text
icon="el-icon-circle-check"
v-if="permission.oss_enable"
@click.stop="handleEnable(scope.row)"
>启用
</el-button>
</template>
<template #status="{ row }">
<el-tag>{{ row.statusName }}</el-tag>
</template>
<template #category="{ row }">
<el-tag>{{ row.categoryName }}</el-tag>
</template>
</avue-crud>
<el-dialog title="对象存储上传调试" append-to-body v-model="box" width="550px">
<avue-form ref="form" :option="debugOption" v-model="debugForm" @submit="handleSubmit" />
</el-dialog>
</basic-container>
</template>
<script>
import { getList, getDetail, add, update, remove, enable } from '@/api/resource/oss';
import { mapGetters } from 'vuex';
import func from '@/utils/func';
import { sensitive } from '@/utils/sensitive';
export default {
data() {
return {
form: {},
query: {},
sensitiveManager: null,
loading: true,
box: false,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
selectionList: [],
option: {
height: 'auto',
calcHeight: 32,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
selection: true,
grid: true,
menuWidth: 350,
labelWidth: 100,
dialogWidth: 880,
dialogClickModal: false,
column: [
{
label: '分类',
type: 'radio',
value: 1,
span: 24,
width: 120,
searchLabelWidth: 50,
row: true,
dicUrl: '/blade-system/dict/dictionary?code=oss',
props: {
label: 'dictValue',
value: 'dictKey',
},
dataType: 'number',
slot: true,
prop: 'category',
search: true,
rules: [
{
required: true,
message: '请选择分类',
trigger: 'blur',
},
],
},
{
label: '资源编号',
prop: 'ossCode',
span: 24,
width: 120,
search: true,
rules: [
{
required: true,
message: '请输入资源编号',
trigger: 'blur',
},
],
},
{
label: '资源地址',
labelTip: '对象存储通用资源地址,可以是内网也可以是外网',
prop: 'endpoint',
span: 24,
rules: [
{
required: true,
message: '请输入资源地址',
trigger: 'blur',
},
],
},
{
label: '外网地址',
labelTip: '资源地址设置为内网上传,则外部访问需要配置外网映射地址',
prop: 'transformEndpoint',
span: 24,
},
{
label: '空间名',
prop: 'bucketName',
span: 24,
width: 120,
rules: [
{
required: true,
message: '请输入空间名',
trigger: 'blur',
},
],
},
{
label: 'accessKey',
prop: 'accessKey',
span: 24,
search: true,
width: 200,
overHidden: true,
rules: [
{
required: true,
message: '请输入accessKey',
trigger: 'blur',
},
],
},
{
label: 'secretKey',
prop: 'secretKey',
span: 24,
width: 200,
hide: true,
overHidden: true,
rules: [
{
required: true,
message: '请输入secretKey',
trigger: 'blur',
},
],
},
{
label: 'appId',
prop: 'appId',
span: 24,
hide: true,
display: false,
},
{
label: 'region',
prop: 'region',
span: 24,
hide: true,
display: false,
},
{
label: '是否启用',
prop: 'status',
span: 24,
width: 85,
align: 'center',
slot: true,
addDisplay: false,
editDisplay: false,
viewDisplay: false,
},
{
label: '备注',
prop: 'remark',
span: 24,
hide: true,
},
],
},
data: [],
debugForm: {
code: '',
},
debugOption: {
submitText: '提交',
column: [
{
label: '资源编号',
prop: 'code',
disabled: true,
span: 24,
},
{
label: '上传背景',
prop: 'backgroundUrl',
type: 'upload',
listType: 'picture-img',
dataType: 'string',
action: '/blade-resource/oss/endpoint/put-file',
propsHttp: {
res: 'data',
url: 'link',
},
span: 24,
},
],
},
};
},
watch: {
'form.category'() {
const category = func.toInt(this.form.category);
this.$refs.crud.option.column.filter(item => {
if (item.prop === 'endpoint') {
item.labelTip = category === 7 ? '本地服务器上传路径使用Nginx代理后的服务地址' : '';
}
if (item.prop === 'accessKey') {
item.labelTip =
category === 7
? '本地服务器文件上传基础路径,注意必须提前创建好并分配目录读写权限'
: '';
}
if (item.prop === 'secretKey') {
item.display = category !== 7;
}
if (item.prop === 'appId') {
item.display = category === 4;
}
if (item.prop === 'region') {
item.display = category === 4 || category === 5;
}
});
},
'debugForm.code'() {
const column = this.findObject(this.debugOption.column, 'backgroundUrl');
column.action = `/blade-resource/oss/endpoint/put-file?code=${this.debugForm.code}`;
},
},
computed: {
...mapGetters(['userInfo', 'permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.oss_add),
viewBtn: this.validData(this.permission.oss_view),
delBtn: this.validData(this.permission.oss_delete),
editBtn: this.validData(this.permission.oss_edit),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
created() {
// 创建脱敏工具实例
this.sensitiveManager = sensitive.create({
fields: ['accessKey', 'secretKey'], // 配置需要脱敏的字段
});
},
methods: {
rowSave(row, done, loading) {
add(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
// 获取需要提交的数据
const submitData = this.sensitiveManager.getSubmitData(row);
update(submitData).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
handleEnable(row) {
this.$confirm('是否确定启用这条配置?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return enable(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
handleDebug(row) {
this.box = true;
this.debugForm.code = row.ossCode;
this.debugForm.backgroundUrl = '';
},
handleSubmit(form, done) {
this.$message({
type: 'success',
message: `获取到图片地址:[${form.backgroundUrl}]`,
});
done();
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => {
this.form = res.data.data;
// 保存初始脱敏数据
this.sensitiveManager.saveInitialData(this.form);
});
}
done();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>

501
src/views/resource/sms.vue Normal file
View File

@@ -0,0 +1,501 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
v-model:page="page"
:permission="permissionList"
:before-open="beforeOpen"
v-model="form"
ref="crud"
@row-update="rowUpdate"
@row-save="rowSave"
@row-del="rowDel"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
plain
v-if="permission.sms_delete"
@click="handleDelete"
>删 除
</el-button>
</template>
<template #menu="scope">
<el-button
type="primary"
text
icon="el-icon-video-play"
v-if="userInfo.authority.includes('admin')"
@click="handleDebug(scope.row)"
>调试
</el-button>
<el-button
type="primary"
text
icon="el-icon-circle-check"
v-if="permission.sms_enable"
@click.stop="handleEnable(scope.row)"
>启用
</el-button>
</template>
<template #status="{ row }">
<el-tag>{{ row.statusName }}</el-tag>
</template>
<template #category="{ row }">
<el-tag>{{ row.categoryName }}</el-tag>
</template>
</avue-crud>
<el-dialog title="手机短信发送调试" append-to-body v-model="box" width="550px">
<avue-form :option="debugOption" v-model="debugForm" @submit="handleSend" />
</el-dialog>
</basic-container>
</template>
<script>
import { getList, getDetail, add, update, remove, enable, send } from '@/api/resource/sms';
import { mapGetters } from 'vuex';
import func from '@/utils/func';
import { sensitive } from '@/utils/sensitive';
export default {
data() {
return {
form: {},
query: {},
sensitiveManager: null,
loading: true,
box: false,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
selectionList: [],
option: {
height: 'auto',
calcHeight: 32,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
selection: true,
grid: true,
menuWidth: 350,
labelWidth: 100,
dialogWidth: 880,
dialogClickModal: false,
column: [
{
label: '分类',
type: 'radio',
value: 1,
span: 24,
width: 100,
searchLabelWidth: 50,
row: true,
dicUrl: '/blade-system/dict/dictionary?code=sms',
props: {
label: 'dictValue',
value: 'dictKey',
},
dataType: 'number',
slot: true,
prop: 'category',
search: true,
rules: [
{
required: true,
message: '请选择分类',
trigger: 'blur',
},
],
},
{
label: '资源编号',
prop: 'smsCode',
span: 24,
width: 200,
search: true,
rules: [
{
required: true,
message: '请输入资源编号',
trigger: 'blur',
},
],
},
{
label: '模版ID',
prop: 'templateId',
span: 24,
width: 200,
search: true,
rules: [
{
required: true,
message: '请输入模版ID',
trigger: 'blur',
},
],
},
{
label: 'SDKAppID',
prop: 'appId',
span: 24,
width: 200,
hide: true,
display: false,
rules: [
{
required: true,
message: '请输入appId',
trigger: 'blur',
},
],
},
{
label: 'accessKey',
prop: 'accessKey',
span: 24,
overHidden: true,
hide: true,
rules: [
{
required: true,
message: '请输入accessKey',
trigger: 'blur',
},
],
},
{
label: 'secretKey',
prop: 'secretKey',
span: 24,
overHidden: true,
display: true,
hide: true,
rules: [
{
required: true,
message: '请输入secretKey',
trigger: 'blur',
},
],
},
{
label: 'regionId',
prop: 'regionId',
span: 24,
hide: true,
display: false,
rules: [
{
required: true,
message: '请输入regionId',
trigger: 'blur',
},
],
},
{
label: '短信签名',
prop: 'signName',
span: 24,
width: 200,
rules: [
{
required: true,
message: '请输入短信签名',
trigger: 'blur',
},
],
},
{
label: '是否启用',
prop: 'status',
span: 24,
width: 85,
align: 'center',
slot: true,
addDisplay: false,
editDisplay: false,
viewDisplay: false,
},
{
label: '备注',
prop: 'remark',
span: 24,
hide: true,
},
],
},
data: [],
debugForm: {
code: '',
},
debugOption: {
submitText: '发送',
column: [
{
label: '资源编号',
prop: 'code',
disabled: true,
span: 24,
},
{
label: '发送手机',
prop: 'phones',
span: 24,
},
{
label: '发送参数',
prop: 'params',
span: 24,
placeholder: "例: {'code':2333,'title':'通知标题'}",
},
],
},
};
},
watch: {
'form.category'() {
const category = func.toInt(this.form.category);
this.$refs.crud.option.column.filter(item => {
if (item.prop === 'templateId') {
if (category === 1) {
item.label = '模版内容';
} else {
item.label = '模版ID';
}
}
if (item.prop === 'accessKey') {
if (category === 1) {
item.label = 'apiKey';
} else if (category === 4) {
item.label = 'secretId';
} else {
item.label = 'accessKey';
}
}
if (item.prop === 'secretKey') {
item.display = category !== 1;
if (category === 4) {
item.label = 'secretKey';
} else {
item.label = 'secretKey';
}
}
if (item.prop === 'regionId') {
if (category === 3) {
item.display = true;
this.form.regionId = 'cn-hangzhou';
} else if (category === 4) {
item.display = true;
this.form.regionId = 'ap-guangzhou';
} else {
item.display = false;
}
}
if (item.prop === 'appId') {
item.display = category === 4;
}
});
},
},
computed: {
...mapGetters(['userInfo', 'permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.sms_add, false),
viewBtn: this.validData(this.permission.sms_view, false),
delBtn: this.validData(this.permission.sms_delete, false),
editBtn: this.validData(this.permission.sms_edit, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
created() {
// 创建脱敏工具实例
this.sensitiveManager = sensitive.create({
fields: ['accessKey', 'secretKey'], // 配置需要脱敏的字段
});
},
methods: {
rowSave(row, done, loading) {
add(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
// 获取需要提交的数据
const submitData = this.sensitiveManager.getSubmitData(row);
update(submitData).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleEnable(row) {
this.$confirm('是否确定启用这条配置?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return enable(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
handleDebug(row) {
this.box = true;
this.debugForm.code = row.smsCode;
},
handleSend(form, done) {
send(form.code, form.phones, form.params).then(
res => {
this.$message({
type: 'success',
message: '发送成功!',
});
done();
window.console.log(res);
this.box = false;
},
error => {
window.console.log(error);
done();
}
);
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => {
this.form = res.data.data;
// 保存初始脱敏数据
this.sensitiveManager.saveInitialData(this.form);
});
}
done();
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>

385
src/views/system/client.vue Normal file
View File

@@ -0,0 +1,385 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
v-model:page="page"
@row-del="rowDel"
v-model="form"
ref="crud"
:permission="permissionList"
@row-update="rowUpdate"
@row-save="rowSave"
:before-open="beforeOpen"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
plain
v-if="permission.client_delete"
@click="handleDelete"
>Del
</el-button>
</template>
</avue-crud>
</basic-container>
</template>
<script>
import { getList, getDetail, add, update, remove } from '@/api/system/client';
import { mapGetters } from 'vuex';
export default {
data() {
return {
form: {},
query: {},
loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
selectionList: [],
option: {
height: 'auto',
calcHeight: 32,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
grid: true,
selection: true,
dialogClickModal: false,
column: [
{
label: 'ClientId',
prop: 'clientId',
search: true,
rules: [
{
required: true,
message: 'Please input client id',
trigger: 'blur',
},
],
},
{
label: 'Secret',
prop: 'clientSecret',
search: true,
rules: [
{
required: true,
message: 'Please input client secret',
trigger: 'blur',
},
],
},
{
label: 'GrantType',
prop: 'authorizedGrantTypes',
type: 'checkbox',
value: 'refresh_token,password,authorization_code,captcha,social,sms_code,register',
dicData: [
{
label: 'refresh_token',
value: 'refresh_token',
},
{
label: 'password',
value: 'password',
},
{
label: 'authorization_code',
value: 'authorization_code',
},
{
label: 'captcha',
value: 'captcha',
},
{
label: 'social',
value: 'social',
},
{
label: 'sms_code',
value: 'sms_code',
},
{
label: 'register',
value: 'register',
},
],
rules: [
{
required: true,
message: 'Please input grant type',
trigger: 'blur',
},
],
},
{
label: 'Scope',
prop: 'scope',
value: 'all',
rules: [
{
required: true,
message: 'Please input scope',
trigger: 'blur',
},
],
},
{
label: 'TokenLimit',
prop: 'accessTokenValidity',
type: 'number',
value: 3600,
rules: [
{
required: true,
message: 'Please input token limit second(s)',
trigger: 'blur',
},
],
},
{
label: 'RefreshLimit',
prop: 'refreshTokenValidity',
type: 'number',
value: 604800,
hide: true,
rules: [
{
required: true,
message: 'Please input token refresh limit second(s)',
trigger: 'blur',
},
],
},
{
label: 'CallbackURL',
prop: 'webServerRedirectUri',
hide: true,
rules: [
{
required: true,
message: 'Please input callback URL',
trigger: 'blur',
},
],
},
{
label: 'AutoApprove',
prop: 'autoapprove',
hide: true,
type: 'radio',
dicData: [
{
label: 'yes',
value: 'true',
},
{
label: 'no',
value: 'false',
},
],
value: 'true',
rules: [
{
required: true,
message: 'Please input auto approve',
trigger: 'blur',
},
],
},
{
label: 'Resource',
prop: 'resourceIds',
hide: true,
rules: [
{
message: 'Please input resources',
trigger: 'blur',
},
],
},
{
label: 'Authority',
prop: 'authorities',
hide: true,
rules: [
{
message: 'Please input authorities',
trigger: 'blur',
},
],
},
{
label: 'AdditionalInfo',
hide: true,
prop: 'additionalInformation',
span: 24,
rules: [
{
message: '',
trigger: 'blur',
},
],
},
],
},
data: [],
};
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.client_add),
viewBtn: this.validData(this.permission.client_view),
delBtn: this.validData(this.permission.client_delete),
editBtn: this.validData(this.permission.client_edit),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
rowSave(row, done, loading) {
add(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => {
this.form = res.data.data;
});
}
done();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>
<style></style>

405
src/views/system/dept.vue Normal file
View File

@@ -0,0 +1,405 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
ref="crud"
v-model="form"
:permission="permissionList"
:before-open="beforeOpen"
:before-close="beforeClose"
@row-del="rowDel"
@row-update="rowUpdate"
@row-save="rowSave"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
@tree-load="treeLoad"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
v-if="permission.dept_delete"
plain
@click="handleDelete"
>DEL
</el-button>
</template>
<template #menu="scope">
<el-button
type="primary"
text
icon="el-icon-circle-plus"
@click.stop="handleAdd(scope.row, scope.index)"
v-if="userInfo.authority.includes('admin')"
>ADD SUB
</el-button>
</template>
<template #deptCategory="{ row }">
<el-tag>{{ row.deptCategoryName }}</el-tag>
</template>
</avue-crud>
</basic-container>
</template>
<script>
import { getLazyList, remove, update, add, getDept, getDeptTree } from '@/api/system/dept';
import { getLeaderList } from '@/api/system/user';
import { mapGetters } from 'vuex';
import website from '@/config/website';
import func from '@/utils/func';
export default {
data() {
return {
form: {},
selectionList: [],
query: {},
loading: true,
parentId: 0,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
option: {
lazy: true,
tip: false,
simplePage: true,
searchShow: true,
searchMenuSpan: 6,
tree: true,
border: true,
index: true,
selection: true,
viewBtn: true,
menuWidth: 320,
dialogWidth: 800,
dialogClickModal: false,
column: [
{
label: 'Store',
prop: 'deptName',
search: true,
rules: [
{
required: true,
message: 'please input store name',
trigger: 'blur',
},
],
},
{
label: 'Tenant',
prop: 'tenantId',
type: 'tree',
dicUrl: '/blade-system/tenant/select',
addDisplay: false,
editDisplay: false,
viewDisplay: website.tenantMode,
span: 24,
props: {
label: 'tenantName',
value: 'tenantId',
},
hide: !website.tenantMode,
search: website.tenantMode,
rules: [
{
required: true,
message: 'please input tenant',
trigger: 'click',
},
],
},
{
label: 'FullName',
prop: 'fullName',
search: true,
rules: [
{
required: true,
message: 'please input store full name',
trigger: 'blur',
},
],
},
{
label: 'Parent',
prop: 'parentId',
dicData: [],
type: 'tree',
hide: true,
addDisabled: false,
props: {
label: 'title',
},
rules: [
{
required: false,
message: 'please select parent store',
trigger: 'click',
},
],
},
{
label: 'Leader',
prop: 'leaderId',
type: 'tree',
multiple: true,
filterable: true,
dicData: [],
props: {
label: 'realName',
value: 'id',
},
clearable: true,
hide: true,
},
{
label: 'Type',
type: 'select',
dicUrl: '/blade-system/dict/dictionary?code=org_category',
props: {
label: 'dictValue',
value: 'dictKey',
},
dataType: 'number',
width: 120,
prop: 'deptCategory',
slot: true,
rules: [
{
required: true,
message: 'please input store type',
trigger: 'blur',
},
],
},
{
label: 'Sort',
prop: 'sort',
type: 'number',
align: 'right',
width: 80,
hide: true,
rules: [
{
required: true,
message: 'please input sort number',
trigger: 'blur',
},
],
},
{
label: 'Remark',
prop: 'remark',
type: 'textarea',
span: 24,
minRows: 2,
hide: true,
},
],
},
data: [],
};
},
computed: {
...mapGetters(['userInfo', 'permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.dept_add, false),
viewBtn: this.validData(this.permission.dept_view, false),
delBtn: this.validData(this.permission.dept_delete, false),
editBtn: this.validData(this.permission.dept_edit, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
initData(tenantId) {
getDeptTree(tenantId).then(res => {
const column = this.findObject(this.option.column, 'parentId');
column.dicData = res.data.data;
});
getLeaderList(tenantId).then(res => {
const column = this.findObject(this.option.column, 'leaderId');
column.dicData = res.data.data;
});
},
handleAdd(row) {
this.parentId = row.id;
const column = this.findObject(this.option.column, 'parentId');
column.value = row.id;
column.addDisabled = true;
this.$refs.crud.rowAdd();
},
rowSave(row, done, loading) {
row.leaderId = func.join(row.leaderId);
add(row).then(
res => {
// 获取新增数据的相关字段
const data = res.data.data;
row.id = data.id;
row.deptCategoryName = data.deptCategoryName;
row.tenantId = data.tenantId;
this.$message({
type: 'success',
message: 'Success!',
});
// 数据回调进行刷新
done(row);
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
row.leaderId = func.join(row.leaderId);
update(row).then(
() => {
this.$message({
type: 'success',
message: 'Success!',
});
// 数据回调进行刷新
done(row);
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row, index, done) {
this.$confirm('Confirmation for Del?', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.$message({
type: 'success',
message: 'Success!',
});
// 数据回调进行刷新
done(row);
});
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('Please select one or more');
return;
}
this.$confirm('Confirmation for Del?', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
// 刷新表格数据并重载
this.data = [];
this.parentId = 0;
this.$refs.crud.refreshTable();
this.$refs.crud.toggleSelection();
// 表格数据重载
this.onLoad(this.page);
this.$message({
type: 'success',
message: 'Success!',
});
});
},
searchReset() {
this.query = {};
this.parentId = 0;
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.parentId = '';
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
beforeOpen(done, type) {
if (['add', 'edit'].includes(type)) {
this.initData(this.form.tenantId);
}
if (['edit', 'view'].includes(type)) {
getDept(this.form.id).then(res => {
this.form = Object.assign(res.data.data, {
hasChildren: this.form.hasChildren,
});
if (this.form.parentId === '0') {
this.form.parentId = '';
}
if (this.form.hasOwnProperty('leaderId')) {
this.form.leaderId = func.split(this.form.leaderId);
}
});
}
done();
},
beforeClose(done) {
this.parentId = '';
const column = this.findObject(this.option.column, 'parentId');
column.value = '';
column.addDisabled = false;
done();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getLazyList(this.parentId, Object.assign(params, this.query)).then(res => {
this.data = res.data.data;
this.loading = false;
this.selectionClear();
});
},
treeLoad(tree, treeNode, resolve) {
const parentId = tree.id;
getLazyList(parentId).then(res => {
resolve(res.data.data);
});
},
},
};
</script>
<style></style>

450
src/views/system/dict.vue Normal file
View File

@@ -0,0 +1,450 @@
<template>
<basic-container>
<avue-crud
:option="optionParent"
:table-loading="loading"
:data="dataParent"
:page="pageParent"
ref="crud"
v-model="formParent"
:permission="permissionList"
:before-open="beforeOpen"
@row-del="rowDel"
@row-update="rowUpdate"
@row-save="rowSave"
@row-click="handleRowClick"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoadParent"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
v-if="permission.dict_delete"
plain
@click="handleDelete"
>删 除
</el-button>
</template>
<template #menu="scope">
<el-button
type="primary"
text
icon="el-icon-setting"
@click.stop="handleRowClick(scope.row)"
v-if="userInfo.authority.includes('admin')"
>字典配置
</el-button>
</template>
<template #code="{ row }">
<el-tag @click="handleRowClick(row)" style="cursor: pointer">{{ row.code }}</el-tag>
</template>
<template #isSealed="{ row }">
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
</template>
</avue-crud>
<el-dialog :title="`[${dictValue}]字典配置`" append-to-body v-model="box" width="1000px">
<avue-crud
:option="optionChild"
:table-loading="loadingChild"
:data="dataChild"
ref="crudChild"
v-model="formChild"
:permission="permissionList"
:before-open="beforeOpenChild"
:before-close="beforeCloseChild"
@row-del="rowDelChild"
@row-update="rowUpdateChild"
@row-save="rowSaveChild"
@search-change="searchChangeChild"
@search-reset="searchResetChild"
@selection-change="selectionChangeChild"
@current-change="currentChangeChild"
@size-change="sizeChangeChild"
@refresh-change="refreshChangeChild"
@on-load="onLoadChild"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
v-if="permission.dict_delete"
plain
@click="handleDelete"
>删 除
</el-button>
</template>
<template #menu="scope">
<el-button
type="primary"
text
icon="el-icon-circle-plus"
@click.stop="handleAdd(scope.row, scope.index)"
v-if="userInfo.authority.includes('admin')"
>新增子项
</el-button>
</template>
<template #isSealed="{ row }">
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
</template>
</avue-crud>
</el-dialog>
</basic-container>
</template>
<script>
import {
getParentList,
getChildList,
remove,
update,
add,
getDict,
getDictTree,
} from '@/api/system/dict';
import { optionParent, optionChild } from '@/option/system/dict';
import { mapGetters } from 'vuex';
export default {
data() {
return {
dictValue: '暂无',
parentId: -1,
formParent: {},
formChild: {},
selectionList: [],
query: {},
box: false,
loading: true,
loadingChild: true,
pageParent: {
pageSize: 10,
pageSizes: [10, 30, 50, 100, 200],
currentPage: 1,
total: 0,
},
pageChild: {
pageSize: 10,
pageSizes: [10, 30, 50, 100, 200],
currentPage: 1,
total: 0,
},
dataParent: [],
dataChild: [],
optionParent: optionParent,
optionChild: optionChild,
};
},
computed: {
...mapGetters(['userInfo', 'permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.dict_add, false),
delBtn: this.validData(this.permission.dict_delete, false),
editBtn: this.validData(this.permission.dict_edit, false),
viewBtn: false,
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
mounted() {
this.initData();
},
methods: {
initData() {
getDictTree().then(res => {
const column = this.findObject(this.optionChild.column, 'parentId');
column.dicData = res.data.data;
});
},
handleAdd(row) {
this.formChild.dictValue = '';
this.formChild.dictKey = '';
this.formChild.sort = 0;
this.formChild.isSealed = 0;
this.formChild.remark = '';
this.formChild.parentId = row.id;
this.$refs.crudChild.rowAdd();
},
rowSave(row, done, loading) {
const form = {
...row,
dictKey: -1,
};
add(form).then(
() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
this.onLoadChild(this.pageChild);
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleRowClick(row) {
this.query = {};
this.parentId = row.id;
this.dictValue = row.dictValue;
const code = this.findObject(this.optionChild.column, 'code');
code.value = row.code;
const parentId = this.findObject(this.optionChild.column, 'parentId');
parentId.value = row.id;
this.formChild.code = row.code;
this.formChild.parentId = row.id;
this.box = true;
this.onLoadChild(this.pageChild);
},
searchReset() {
this.query = {};
this.onLoadParent(this.pageParent);
},
searchChange(params, done) {
this.query = params;
this.pageParent.currentPage = 1;
this.onLoadParent(this.pageParent, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getDict(this.formParent.id).then(res => {
this.formParent = res.data.data;
});
}
done();
},
currentChange(currentPage) {
this.pageParent.currentPage = currentPage;
},
sizeChange(pageSize) {
this.pageParent.pageSize = pageSize;
},
refreshChange() {
this.onLoadParent(this.pageParent, this.query);
},
rowSaveChild(row, done, loading) {
add(row).then(
() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdateChild(row, index, done, loading) {
update(row).then(
() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDelChild(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
searchResetChild() {
this.query = {};
this.onLoadChild(this.pageChild);
},
searchChangeChild(params, done) {
this.query = params;
this.pageChild.currentPage = 1;
this.onLoadChild(this.pageChild, params);
done();
},
selectionChangeChild(list) {
this.selectionList = list;
},
selectionClearChild() {
this.selectionList = [];
this.$refs.crudChild.toggleSelection();
},
handleDeleteChild() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crudChild.toggleSelection();
});
},
beforeOpenChild(done, type) {
if (['add', 'edit'].includes(type)) {
this.initData();
}
if (['edit', 'view'].includes(type)) {
getDict(this.formChild.id).then(res => {
this.formChild = res.data.data;
});
}
done();
},
beforeCloseChild(done) {
this.$refs.crudChild.modelValue.parentId = this.parentId;
this.$refs.crudChild.option.column.filter(item => {
if (item.prop === 'parentId') {
item.value = this.parentId;
}
});
done();
},
currentChangeChild(currentPage) {
this.pageChild.currentPage = currentPage;
},
sizeChangeChild(pageSize) {
this.pageChild.pageSize = pageSize;
},
refreshChangeChild() {
this.onLoadChild(this.pageChild, this.query);
},
onLoadParent(page, params = {}) {
this.loading = true;
getParentList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(
res => {
const data = res.data.data;
this.pageParent.total = data.total;
this.dataParent = data.records;
this.loading = false;
this.selectionClear();
}
);
},
onLoadChild(page, params = {}) {
this.loadingChild = true;
getChildList(
page.currentPage,
page.pageSize,
this.parentId,
Object.assign(params, this.query)
).then(res => {
this.dataChild = res.data.data;
this.loadingChild = false;
this.selectionClear();
});
},
},
};
</script>

View File

@@ -0,0 +1,450 @@
<template>
<basic-container>
<avue-crud
:option="optionParent"
:table-loading="loading"
:data="dataParent"
:page="pageParent"
ref="crud"
v-model="formParent"
:permission="permissionList"
:before-open="beforeOpen"
@row-del="rowDel"
@row-update="rowUpdate"
@row-save="rowSave"
@row-click="handleRowClick"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoadParent"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
v-if="permission.dictbiz_delete"
plain
@click="handleDelete"
>删 除
</el-button>
</template>
<template #menu="scope">
<el-button
type="primary"
text
icon="el-icon-setting"
@click.stop="handleRowClick(scope.row)"
v-if="userInfo.authority.includes('admin')"
>字典配置
</el-button>
</template>
<template #code="{ row }">
<el-tag @click="handleRowClick(row)" style="cursor: pointer">{{ row.code }}</el-tag>
</template>
<template #isSealed="{ row }">
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
</template>
</avue-crud>
<el-dialog :title="`[${dictValue}]字典配置`" append-to-body v-model="box" width="1000px">
<avue-crud
:option="optionChild"
:table-loading="loadingChild"
:data="dataChild"
ref="crudChild"
v-model="formChild"
:permission="permissionList"
:before-open="beforeOpenChild"
:before-close="beforeCloseChild"
@row-del="rowDelChild"
@row-update="rowUpdateChild"
@row-save="rowSaveChild"
@search-change="searchChangeChild"
@search-reset="searchResetChild"
@selection-change="selectionChangeChild"
@current-change="currentChangeChild"
@size-change="sizeChangeChild"
@refresh-change="refreshChangeChild"
@on-load="onLoadChild"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
v-if="permission.dict_delete"
plain
@click="handleDelete"
>删 除
</el-button>
</template>
<template #menu="scope">
<el-button
type="primary"
text
icon="el-icon-circle-plus"
@click.stop="handleAdd(scope.row, scope.index)"
v-if="userInfo.authority.includes('admin')"
>新增子项
</el-button>
</template>
<template #isSealed="{ row }">
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
</template>
</avue-crud>
</el-dialog>
</basic-container>
</template>
<script>
import {
getParentList,
getChildList,
remove,
update,
add,
getDict,
getDictTree,
} from '@/api/system/dictbiz';
import { optionParent, optionChild } from '@/option/system/dictbiz';
import { mapGetters } from 'vuex';
export default {
data() {
return {
dictValue: '暂无',
parentId: -1,
formParent: {},
formChild: {},
selectionList: [],
query: {},
box: false,
loading: true,
loadingChild: true,
pageParent: {
pageSize: 10,
pageSizes: [10, 30, 50, 100, 200],
currentPage: 1,
total: 0,
},
pageChild: {
pageSize: 10,
pageSizes: [10, 30, 50, 100, 200],
currentPage: 1,
total: 0,
},
dataParent: [],
dataChild: [],
optionParent: optionParent,
optionChild: optionChild,
};
},
computed: {
...mapGetters(['userInfo', 'permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.dictbiz_add, false),
delBtn: this.validData(this.permission.dictbiz_delete, false),
editBtn: this.validData(this.permission.dictbiz_edit, false),
viewBtn: false,
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
mounted() {
this.initData();
},
methods: {
initData() {
getDictTree().then(res => {
const column = this.findObject(this.optionChild.column, 'parentId');
column.dicData = res.data.data;
});
},
handleAdd(row) {
this.formChild.dictValue = '';
this.formChild.dictKey = '';
this.formChild.sort = 0;
this.formChild.isSealed = 0;
this.formChild.remark = '';
this.formChild.parentId = row.id;
this.$refs.crudChild.rowAdd();
},
rowSave(row, done, loading) {
const form = {
...row,
dictKey: -1,
};
add(form).then(
() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
this.onLoadChild(this.pageChild);
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleRowClick(row) {
this.query = {};
this.parentId = row.id;
this.dictValue = row.dictValue;
const code = this.findObject(this.optionChild.column, 'code');
code.value = row.code;
const parentId = this.findObject(this.optionChild.column, 'parentId');
parentId.value = row.id;
this.formChild.code = row.code;
this.formChild.parentId = row.id;
this.box = true;
this.onLoadChild(this.pageChild);
},
searchReset() {
this.query = {};
this.onLoadParent(this.pageParent);
},
searchChange(params, done) {
this.query = params;
this.pageParent.currentPage = 1;
this.onLoadParent(this.pageParent, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getDict(this.formParent.id).then(res => {
this.formParent = res.data.data;
});
}
done();
},
currentChange(currentPage) {
this.pageParent.currentPage = currentPage;
},
sizeChange(pageSize) {
this.pageParent.pageSize = pageSize;
},
refreshChange() {
this.onLoadParent(this.pageParent, this.query);
},
rowSaveChild(row, done, loading) {
add(row).then(
() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdateChild(row, index, done, loading) {
update(row).then(
() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDelChild(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
searchResetChild() {
this.query = {};
this.onLoadChild(this.pageChild);
},
searchChangeChild(params, done) {
this.query = params;
this.pageChild.currentPage = 1;
this.onLoadChild(this.pageChild, params);
done();
},
selectionChangeChild(list) {
this.selectionList = list;
},
selectionClearChild() {
this.selectionList = [];
this.$refs.crudChild.toggleSelection();
},
handleDeleteChild() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crudChild.toggleSelection();
});
},
beforeOpenChild(done, type) {
if (['add', 'edit'].includes(type)) {
this.initData();
}
if (['edit', 'view'].includes(type)) {
getDict(this.formChild.id).then(res => {
this.formChild = res.data.data;
});
}
done();
},
beforeCloseChild(done) {
this.$refs.crudChild.modelValue.parentId = this.parentId;
this.$refs.crudChild.option.column.filter(item => {
if (item.prop === 'parentId') {
item.value = this.parentId;
}
});
done();
},
currentChangeChild(currentPage) {
this.pageChild.currentPage = currentPage;
},
sizeChangeChild(pageSize) {
this.pageChild.pageSize = pageSize;
},
refreshChangeChild() {
this.onLoadChild(this.pageChild, this.query);
},
onLoadParent(page, params = {}) {
this.loading = true;
getParentList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(
res => {
const data = res.data.data;
this.pageParent.total = data.total;
this.dataParent = data.records;
this.loading = false;
this.selectionClear();
}
);
},
onLoadChild(page, params = {}) {
this.loadingChild = true;
getChildList(
page.currentPage,
page.pageSize,
this.parentId,
Object.assign(params, this.query)
).then(res => {
this.dataChild = res.data.data;
this.loadingChild = false;
this.selectionClear();
});
},
},
};
</script>

438
src/views/system/menu.vue Normal file
View File

@@ -0,0 +1,438 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
ref="crud"
v-model="form"
:permission="permissionList"
:before-open="beforeOpen"
:before-close="beforeClose"
@row-del="rowDel"
@row-update="rowUpdate"
@row-save="rowSave"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
@tree-load="treeLoad"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
v-if="permission.menu_delete"
plain
@click="handleDelete"
>删 除
</el-button>
</template>
<template #menu="scope">
<el-button
type="primary"
text
icon="el-icon-circle-plus"
@click.stop="handleAdd(scope.row, scope.index)"
v-if="userInfo.authority.includes('admin') && scope.row.category === 1"
>新增子项
</el-button>
</template>
<template #name="{ row }">
<i :class="row.source" style="margin-right: 5px" />
<span>{{ row.name }}</span>
</template>
<template #source="{ row }">
<div style="text-align: center">
<i :class="row.source" />
</div>
</template>
</avue-crud>
</basic-container>
</template>
<script>
import { getLazyList, remove, update, add, getMenu } from '@/api/system/menu';
import { mapGetters } from 'vuex';
import iconList from '@/config/iconList';
import func from '@/utils/func';
import { getMenuTree } from '@/api/system/menu';
export default {
data() {
return {
form: {},
query: {},
loading: true,
selectionList: [],
parentId: 0,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
option: {
lazy: true,
tip: false,
simplePage: true,
searchShow: true,
searchMenuSpan: 6,
dialogWidth: '60%',
tree: true,
border: true,
index: true,
selection: true,
viewBtn: true,
menuWidth: 320,
dialogClickModal: false,
column: [
{
label: '菜单名称',
prop: 'name',
width: 300,
search: true,
rules: [
{
required: true,
message: '请输入菜单名称',
trigger: 'blur',
},
],
},
{
label: '路由地址',
prop: 'path',
rules: [
{
required: true,
message: '请输入路由地址',
trigger: 'blur',
},
],
},
{
label: '上级菜单',
prop: 'parentId',
type: 'tree',
dicData: [],
hide: true,
addDisabled: false,
props: {
label: 'title',
},
rules: [
{
required: false,
message: '请选择上级菜单',
trigger: 'click',
},
],
},
{
label: '菜单图标',
prop: 'source',
type: 'icon',
slot: true,
iconList: iconList,
rules: [
{
required: true,
message: '请输入菜单图标',
trigger: 'click',
},
],
},
{
label: '菜单编号',
prop: 'code',
search: true,
rules: [
{
required: true,
message: '请输入菜单编号',
trigger: 'blur',
},
],
},
{
label: '菜单类型',
prop: 'category',
type: 'radio',
dicData: [
{
label: '菜单',
value: 1,
},
{
label: '按钮',
value: 2,
},
],
hide: true,
rules: [
{
required: true,
message: '请选择菜单类型',
trigger: 'blur',
},
],
},
{
label: '菜单别名',
prop: 'alias',
search: true,
rules: [
{
required: true,
message: '请输入菜单别名',
trigger: 'blur',
},
],
},
{
label: '是否缓存',
prop: 'isOpen',
type: 'radio',
hide: true,
dicData: [
{
label: '否',
value: 1,
},
{
label: '是',
value: 2,
},
],
value: 1,
rules: [
{
required: true,
message: '请选择是否缓存',
trigger: 'blur',
},
],
},
{
label: '菜单排序',
prop: 'sort',
type: 'number',
rules: [
{
required: true,
message: '请输入菜单排序',
trigger: 'blur',
},
],
},
{
label: '菜单备注',
prop: 'remark',
type: 'textarea',
span: 24,
minRows: 2,
hide: true,
},
],
},
data: [],
};
},
watch: {
'form.category'() {
const category = func.toInt(this.form.category);
this.$refs.crud.option.column.filter(item => {
if (item.prop === 'path') {
item.rules[0].required = category === 1;
}
if (item.prop === 'isOpen') {
item.disabled = category === 2;
}
});
},
},
computed: {
...mapGetters(['userInfo', 'permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.menu_add, false),
viewBtn: this.validData(this.permission.menu_view, false),
delBtn: this.validData(this.permission.menu_delete, false),
editBtn: this.validData(this.permission.menu_edit, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
initData() {
getMenuTree().then(res => {
const column = this.findObject(this.option.column, 'parentId');
column.dicData = res.data.data;
});
},
handleAdd(row) {
this.parentId = row.id;
const column = this.findObject(this.option.column, 'parentId');
column.value = row.id;
column.addDisabled = true;
this.$refs.crud.rowAdd();
},
rowSave(row, done, loading) {
add(row).then(
res => {
// 获取新增数据的相关字段
const data = res.data.data;
row.id = data.id;
this.$message({
type: 'success',
message: '操作成功!',
});
// 数据回调进行刷新
done(row);
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.$message({
type: 'success',
message: '操作成功!',
});
// 数据回调进行刷新
done(row);
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row, index, done) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.$message({
type: 'success',
message: '操作成功!',
});
// 数据回调进行刷新
done(row);
});
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
// 刷新表格数据并重载
this.data = [];
this.parentId = 0;
this.$refs.crud.refreshTable();
this.$refs.crud.toggleSelection();
// 表格数据重载
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
searchReset() {
this.query = {};
this.parentId = 0;
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.parentId = '';
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
beforeOpen(done, type) {
if (['add', 'edit'].includes(type)) {
this.initData();
}
if (['edit', 'view'].includes(type)) {
getMenu(this.form.id).then(res => {
this.form = Object.assign(res.data.data, {
hasChildren: this.form.hasChildren,
});
if (this.form.parentId === '0') {
this.form.parentId = '';
}
});
}
done();
},
beforeClose(done) {
this.parentId = '';
const column = this.findObject(this.option.column, 'parentId');
column.value = '';
column.addDisabled = false;
done();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getLazyList(this.parentId, Object.assign(params, this.query)).then(res => {
this.data = res.data.data;
this.loading = false;
this.selectionClear();
});
},
treeLoad(tree, treeNode, resolve) {
const parentId = tree.id;
getLazyList(parentId).then(res => {
resolve(res.data.data);
});
},
},
};
</script>
<style></style>

371
src/views/system/param.vue Normal file
View File

@@ -0,0 +1,371 @@
<template>
<basic-container>
<div class="avue-crud">
<el-row :hidden="!search" style="padding: 6px 18px">
<!-- 查询模块 -->
<el-form :inline="true" :model="query">
<el-form-item label="参数名:">
<el-input v-model="query.paramName" placeholder="请输入参数名"></el-input>
</el-form-item>
<el-form-item label="参数键:">
<el-input v-model="query.paramKey" placeholder="请输入参数键"></el-input>
</el-form-item>
<!-- 查询按钮 -->
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="searchChange">搜 索</el-button>
<el-button icon="el-icon-delete" @click="searchReset()">清 空</el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<div class="avue-crud__header">
<!-- 头部左侧按钮模块 -->
<div class="avue-crud__left">
<el-button
v-if="this.permissionList.addBtn"
type="primary"
icon="el-icon-plus"
@click="handleAdd"
>新 增
</el-button>
<el-button
v-if="this.permissionList.delBtn"
type="danger"
icon="el-icon-delete"
@click="handleDelete"
plain
>删 除
</el-button>
</div>
<!-- 头部右侧按钮模块 -->
<div class="avue-crud__right">
<el-button icon="el-icon-refresh" @click="searchChange" circle></el-button>
<el-button icon="el-icon-search" @click="searchHide" circle></el-button>
</div>
</div>
</el-row>
<el-row>
<!-- 列表模块 -->
<el-table
ref="table"
v-loading="loading"
@selection-change="selectionChange"
:data="data"
:height="height"
style="width: 100%"
:border="option.border"
>
<el-table-column
type="selection"
v-if="option.selection"
width="55"
align="center"
></el-table-column>
<el-table-column type="expand" v-if="option.expand" align="center"></el-table-column>
<el-table-column v-if="option.index" label="#" type="index" width="50" align="center">
</el-table-column>
<template v-for="(item, index) in option.column">
<!-- table字段 -->
<el-table-column
v-if="item.hide !== true"
:prop="item.prop"
:label="item.label"
:width="item.width"
:key="index"
>
</el-table-column>
</template>
<!-- 操作栏模块 -->
<el-table-column prop="menu" label="操作" :width="220" align="center">
<template #="{ row }">
<el-button
v-if="this.permissionList.viewBtn"
type="primary"
text
icon="el-icon-view"
@click="handleView(row)"
>查看
</el-button>
<el-button
v-if="this.permissionList.editBtn"
type="primary"
text
icon="el-icon-edit"
@click="handleEdit(row)"
>编辑
</el-button>
<el-button
v-if="this.permissionList.delBtn"
type="primary"
text
icon="el-icon-delete"
@click="rowDel(row)"
>删除
</el-button>
</template>
</el-table-column>
</el-table>
</el-row>
<el-row>
<div class="avue-crud__pagination" style="width: 100%">
<!-- 分页模块 -->
<el-pagination
align="right"
background
@size-change="sizeChange"
@current-change="currentChange"
:current-page="page.currentPage"
:page-sizes="[10, 20, 30, 40, 50, 100]"
:page-size="page.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="page.total"
>
</el-pagination>
</div>
</el-row>
<!-- 表单模块 -->
<el-dialog
:title="title"
v-model="box"
width="50%"
:before-close="beforeClose"
append-to-body
>
<el-form :disabled="view" ref="form" :model="form" label-width="80px">
<!-- 表单字段 -->
<el-form-item label="参数名:" prop="paramName">
<el-input v-model="form.paramName" placeholder="请输入参数名" />
</el-form-item>
<el-form-item label="参数键:" prop="paramKey">
<el-input v-model="form.paramKey" placeholder="请输入参数键" />
</el-form-item>
<el-form-item label="参数值:" prop="paramValue">
<el-input v-model="form.paramValue" placeholder="请输入参数值" />
</el-form-item>
<el-form-item label="备注:" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
</el-form>
<!-- 表单按钮 -->
<template #footer>
<span v-if="!view" class="dialog-footer">
<el-button type="primary" icon="el-icon-circle-check" @click="handleSubmit"
>提 交</el-button
>
<el-button icon="el-icon-circle-close" @click="box = false">取 消</el-button>
</span>
</template>
</el-dialog>
</div>
</basic-container>
</template>
<script>
import { getList, getDetail, add, update, remove } from '@/api/system/param';
import { mapGetters } from 'vuex';
export default {
data() {
return {
height: 0,
// 弹框标题
title: '',
// 是否展示弹框
box: false,
// 是否显示查询
search: true,
// 加载中
loading: true,
// 是否为查看模式
view: false,
// 查询信息
query: {},
// 分页信息
page: {
currentPage: 1,
pageSize: 10,
total: 40,
},
// 表单数据
form: {},
// 选择行
selectionList: [],
// 表单配置
option: {
expand: false,
index: true,
border: true,
selection: true,
column: [
{
label: '参数名',
prop: 'paramName',
},
{
label: '参数键',
prop: 'paramKey',
},
{
label: '参数值',
prop: 'paramValue',
},
{
label: '备注',
prop: 'remark',
},
],
},
// 表单列表
data: [],
};
},
mounted() {
this.init();
this.onLoad(this.page);
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.param_add, false),
viewBtn: this.validData(this.permission.param_view, false),
delBtn: this.validData(this.permission.param_delete, false),
editBtn: this.validData(this.permission.param_edit, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
init() {
this.height = this.setPx(document.body.clientHeight - 340);
},
searchHide() {
this.search = !this.search;
},
searchChange() {
this.onLoad(this.page);
},
searchReset() {
this.query = {};
this.page.currentPage = 1;
this.onLoad(this.page);
},
handleSubmit() {
if (!this.form.id) {
add(this.form).then(() => {
this.box = false;
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
} else {
update(this.form).then(() => {
this.box = false;
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
}
},
handleAdd() {
this.title = '新增';
this.form = {};
this.box = true;
},
handleEdit(row) {
this.title = '编辑';
this.box = true;
getDetail(row.id).then(res => {
this.form = res.data.data;
});
},
handleView(row) {
this.title = '查看';
this.view = true;
this.box = true;
getDetail(row.id).then(res => {
this.form = res.data.data;
});
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.selectionClear();
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
beforeClose(done) {
done();
this.form = {};
this.view = false;
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.table.clearSelection();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
this.onLoad(this.page);
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
this.onLoad(this.page);
},
onLoad(page, params = {}) {
this.loading = true;
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>

298
src/views/system/post.vue Normal file
View File

@@ -0,0 +1,298 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
v-model:page="page"
:permission="permissionList"
:before-open="beforeOpen"
v-model="form"
ref="crud"
@row-update="rowUpdate"
@row-save="rowSave"
@row-del="rowDel"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
plain
v-if="permission.post_delete"
@click="handleDelete"
>删 除
</el-button>
</template>
<template #category="{ row }">
<el-tag>{{ row.categoryName }}</el-tag>
</template>
</avue-crud>
</basic-container>
</template>
<script>
import { getList, getDetail, add, update, remove } from '@/api/system/post';
import { mapGetters } from 'vuex';
import website from '@/config/website';
export default {
data() {
return {
form: {},
query: {},
loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
selectionList: [],
option: {
height: 'auto',
calcHeight: 32,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
selection: true,
dialogClickModal: false,
column: [
{
label: '所属租户',
prop: 'tenantId',
type: 'tree',
dicUrl: '/blade-system/tenant/select',
addDisplay: false,
editDisplay: false,
viewDisplay: website.tenantMode,
span: 24,
props: {
label: 'tenantName',
value: 'tenantId',
},
hide: !website.tenantMode,
rules: [
{
required: true,
message: '请输入所属租户',
trigger: 'click',
},
],
},
{
label: '岗位类型',
prop: 'category',
type: 'select',
dicUrl: '/blade-system/dict/dictionary?code=post_category',
props: {
label: 'dictValue',
value: 'dictKey',
},
dataType: 'number',
slot: true,
search: true,
rules: [
{
required: true,
message: '请选择岗位类型',
trigger: 'blur',
},
],
},
{
label: '岗位编号',
prop: 'postCode',
search: true,
rules: [
{
required: true,
message: '请输入岗位编号',
trigger: 'blur',
},
],
},
{
label: '岗位名称',
prop: 'postName',
search: true,
rules: [
{
required: true,
message: '请输入岗位名称',
trigger: 'blur',
},
],
},
{
label: '岗位排序',
prop: 'sort',
type: 'number',
rules: [
{
required: true,
message: '请输入岗位排序',
trigger: 'blur',
},
],
},
{
label: '岗位描述',
prop: 'remark',
type: 'textarea',
span: 24,
minRows: 6,
hide: true,
},
],
},
data: [],
};
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.post_add, false),
viewBtn: this.validData(this.permission.post_view, false),
delBtn: this.validData(this.permission.post_delete, false),
editBtn: this.validData(this.permission.post_edit, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
rowSave(row, done, loading) {
add(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => {
this.form = res.data.data;
});
}
done();
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>
<style></style>

770
src/views/system/tenant.vue Normal file
View File

@@ -0,0 +1,770 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
ref="crud"
v-model="form"
v-model:page="page"
:permission="permissionList"
:before-open="beforeOpen"
@row-del="rowDel"
@row-update="rowUpdate"
@row-save="rowSave"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button
v-if="permission.tenant_add && !recycleMode"
type="primary"
icon="el-icon-plus"
@click="$refs.crud.rowAdd()"
>新 增
</el-button>
<el-button
type="danger"
icon="el-icon-delete"
v-if="permission.tenant_delete && !recycleMode"
plain
@click="handleDelete"
>删 除
</el-button>
<el-button
type="primary"
plain
icon="el-icon-refresh"
v-if="userInfo.authority.includes('administrator') && !recycleMode"
@click="handleRecycle"
>回收站
</el-button>
<el-button
type="success"
plain
icon="el-icon-check"
v-if="userInfo.authority.includes('administrator') && recycleMode"
@click="handleRecyclePass"
>恢 复
</el-button>
<el-button
type="danger"
plain
icon="el-icon-close"
v-if="userInfo.authority.includes('administrator') && recycleMode"
@click="handleRecycleRemove"
>删 除
</el-button>
<el-button
type="primary"
plain
icon="el-icon-refresh-left"
v-if="userInfo.authority.includes('administrator') && recycleMode"
@click="handleRecycleBack"
>返 回
</el-button>
<el-tooltip
class="item"
effect="dark"
content="给租户配置账号额度、过期时间等授权信息"
placement="top"
>
<el-button
plain
type="info"
v-if="userInfo.authority.includes('administrator') && !recycleMode"
icon="el-icon-setting"
@click="handleSetting"
>批量授权配置
</el-button>
</el-tooltip>
</template>
<template #menu-right>
<el-tooltip
class="item"
effect="dark"
content="将自定义的数据源定制为租户绑定的独立数据源"
placement="top"
>
<el-button
plain
v-if="userInfo.authority.includes('administrator') && !recycleMode"
icon="el-icon-message-box"
@click="handleDatasourceSetting"
>数据源管理
</el-button>
</el-tooltip>
<el-tooltip
class="item"
effect="dark"
content="将自定义的菜单集合定制为租户绑定的菜单产品包"
placement="top"
>
<el-button
plain
v-if="userInfo.authority.includes('administrator') && !recycleMode"
icon="el-icon-set-up"
@click="handlePackageSetting"
>产品包管理
</el-button>
</el-tooltip>
</template>
<template #menu="scope">
<el-button
v-if="userInfo.authority.includes('administrator') && !recycleMode"
type="primary"
text
icon="el-icon-coin"
@click.stop="handleRowDatasource(scope.row)"
>数据源
</el-button>
<el-button
v-if="userInfo.authority.includes('administrator') && !recycleMode"
type="primary"
text
icon="el-icon-notebook"
@click.stop="handleRowPackage(scope.row)"
>产品包
</el-button>
</template>
<template #accountNumber="{ row }">
<el-tag>{{ row.accountNumber > 0 ? row.accountNumber : '不限制' }}</el-tag>
</template>
<template #expireTime="{ row }">
<el-tag>{{ row.expireTime ? row.expireTime : '不限制' }}</el-tag>
</template>
</avue-crud>
<el-dialog title="租户授权配置" append-to-body v-model="box" width="450px">
<avue-form :option="settingOption" v-model="settingForm" @submit="handleSubmit" />
</el-dialog>
<el-dialog title="租户数据源配置" append-to-body v-model="datasourceBox" width="450px">
<avue-form
ref="formDatasource"
:option="datasourceOption"
v-model="datasourceForm"
@submit="handleDatasourceSubmit"
/>
</el-dialog>
<el-drawer
title="租户数据源管理"
append-to-body
v-model="datasourceSettingBox"
direction="rtl"
size="50%"
>
<tenant-datasource></tenant-datasource>
</el-drawer>
<el-dialog title="租户产品包配置" append-to-body v-model="packageBox" width="450px">
<avue-form
ref="formPackage"
:option="packageOption"
v-model="packageForm"
@submit="handlePackageSubmit"
/>
</el-dialog>
<el-drawer
title="租户产品包管理"
append-to-body
v-model="packageSettingBox"
direction="rtl"
size="50%"
>
<tenant-package></tenant-package>
</el-drawer>
</basic-container>
</template>
<script>
import {
getList,
getDetail,
update,
add,
setting,
datasource,
packageInfo,
packageSetting,
recycle,
pass,
remove,
} from '@/api/system/tenant';
import { getDetail as packageDetail } from '@/api/system/tenantpackage';
import { mapGetters } from 'vuex';
import { getMenuTree } from '@/api/system/menu';
import { validatenull } from '@/utils/validate';
export default {
data() {
return {
form: {},
selectionList: [],
query: {},
loading: true,
box: false,
datasourceBox: false,
datasourceSettingBox: false,
packageBox: false,
packageSettingBox: false,
recycleMode: false,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
option: {
height: 'auto',
calcHeight: 32,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
selection: true,
addBtn: false,
viewBtn: true,
menuWidth: 380,
dialogWidth: 900,
dialogClickModal: false,
column: [
{
label: '租户ID',
prop: 'tenantId',
width: 100,
search: true,
addDisplay: false,
editDisplay: false,
span: 24,
rules: [
{
required: true,
message: '请输入租户ID',
trigger: 'blur',
},
],
},
{
label: '租户名称',
prop: 'tenantName',
search: true,
width: 180,
span: 24,
rules: [
{
required: true,
message: '请输入参数名称',
trigger: 'blur',
},
],
},
{
label: '联系人',
prop: 'linkman',
width: 100,
search: true,
rules: [
{
required: true,
message: '请输入联系人',
trigger: 'blur',
},
],
},
{
label: '联系电话',
prop: 'contactNumber',
width: 150,
},
{
label: '联系地址',
prop: 'address',
span: 24,
minRows: 2,
type: 'textarea',
hide: true,
},
{
label: '账号额度',
prop: 'accountNumber',
width: 90,
slot: true,
addDisplay: false,
editDisplay: false,
},
{
label: '过期时间',
prop: 'expireTime',
width: 180,
slot: true,
addDisplay: false,
editDisplay: false,
},
{
label: '绑定域名',
prop: 'domainUrl',
span: 24,
},
{
label: '系统背景',
prop: 'backgroundUrl',
type: 'upload',
listType: 'picture-img',
dataType: 'string',
action: '/blade-resource/oss/endpoint/put-file',
propsHttp: {
res: 'data',
url: 'link',
},
hide: true,
span: 24,
},
],
},
data: [],
settingForm: {},
settingOption: {
column: [
{
label: '账号额度',
labelTip: '代表租户可创建的最大额度,若不限制则默认为-1',
prop: 'accountNumber',
type: 'number',
span: 24,
},
{
label: '过期时间',
labelTip: '代表租户可使用的最后日期,若不限制则默认为空',
prop: 'expireTime',
type: 'date',
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
span: 24,
},
],
},
datasourceForm: {},
datasourceOption: {
column: [
{
label: '数据源',
prop: 'datasourceId',
search: true,
span: 24,
type: 'select',
dicUrl: '/blade-system/tenant-datasource/select',
props: {
label: 'name',
value: 'id',
},
rules: [
{
required: true,
message: '请选择数据源',
trigger: 'blur',
},
],
},
],
},
packageForm: {},
packageOption: {
column: [
{
label: '产品包',
prop: 'packageId',
search: true,
span: 24,
type: 'select',
dicUrl: '/blade-system/tenant-package/select',
props: {
label: 'packageName',
value: 'id',
},
},
{
label: '菜单预览',
prop: 'menuId',
span: 24,
type: 'tree',
dicData: [],
hide: true,
multiple: true,
props: {
label: 'title',
},
},
],
},
};
},
watch: {
'packageForm.packageId'() {
if (!validatenull(this.packageForm.packageId)) {
packageDetail(this.packageForm.packageId).then(res => {
this.packageForm.menuId = res.data.data.menuId;
this.initData();
});
}
},
},
computed: {
...mapGetters(['userInfo', 'permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.tenant_add, false),
viewBtn: this.validData(this.permission.tenant_view, false),
delBtn: this.validData(this.permission.tenant_delete, false),
editBtn: this.validData(this.permission.tenant_edit, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
tenantId() {
return this.selectionList[0].tenantId;
},
},
methods: {
initData() {
getMenuTree().then(res => {
const column = this.findObject(this.packageOption.column, 'menuId');
column.dicData = res.data.data;
});
},
rowSave(row, done, loading) {
add(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('删除后所选租户将进入回收站,是否继续?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return recycle(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
beforeOpen(done, type) {
if (['view'].includes(type)) {
getDetail(this.form.id).then(res => {
const data = res.data.data;
if (!(data.accountNumber > 0)) {
data.accountNumber = '不限制';
}
if (!data.expireTime) {
data.expireTime = '不限制';
}
this.form = data;
});
}
done();
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('删除后所选租户将进入回收站,是否继续?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return recycle(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
handleRecycle() {
this.recycleMode = true;
this.$refs.crud.option.editBtn = false;
this.$refs.crud.option.delBtn = false;
this.onLoad(this.page, this.query);
},
handleRecyclePass() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将所选租户进行恢复?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return pass(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
handleRecycleRemove() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将所选租户永久删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
handleRecycleBack() {
this.recycleMode = false;
this.$refs.crud.option.editBtn = true;
this.$refs.crud.option.delBtn = true;
this.onLoad(this.page, this.query);
},
handleSetting() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
if (this.selectionList.length === 1) {
getDetail(this.selectionList[0].id).then(res => {
const data = res.data.data;
this.settingForm.accountNumber = data.accountNumber;
this.settingForm.expireTime = data.expireTime;
});
} else {
this.settingForm.accountNumber = -1;
this.settingForm.expireTime = '';
}
this.box = true;
},
handleRowDatasource(row) {
getDetail(row.id).then(res => {
const data = res.data.data;
this.datasourceForm.tenantId = row.tenantId;
this.datasourceForm.datasourceId = data.datasourceId;
});
this.datasourceBox = true;
this.$nextTick(() => {
this.$refs.formDatasource.updateDic('datasourceId');
});
},
handleDatasource() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
if (this.selectionList.length !== 1) {
this.$message.warning('只能选择一条数据');
return;
}
getDetail(this.selectionList[0].id).then(res => {
const data = res.data.data;
this.datasourceForm.tenantId = this.selectionList[0].tenantId;
this.datasourceForm.datasourceId = data.datasourceId;
});
this.datasourceBox = true;
},
handleRowPackage(row) {
packageInfo(row.id).then(res => {
const data = res.data.data;
this.packageForm.tenantId = row.tenantId;
this.packageForm.packageId = data.id;
this.packageForm.menuId = data.menuId;
});
this.packageBox = true;
//更新字典远程数据
setTimeout(() => {
const form = this.$refs.formPackage;
form.updateDic('packageId');
}, 10);
},
handlePackage() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
if (this.selectionList.length !== 1) {
this.$message.warning('只能选择一条数据');
return;
}
if (this.selectionList.length === 1) {
packageInfo(this.selectionList[0].id).then(res => {
const data = res.data.data;
this.packageForm.tenantId = this.selectionList[0].tenantId;
this.packageForm.packageId = data.id;
this.packageForm.menuId = data.menuId;
});
} else {
this.packageForm.menuId = '';
}
this.packageBox = true;
//更新字典远程数据
setTimeout(() => {
const form = this.$refs.formPackage;
form.updateDic('packageId');
}, 10);
},
handleDatasourceSetting() {
this.datasourceSettingBox = true;
},
handlePackageSetting() {
this.packageSettingBox = true;
},
handleSubmit(form, done) {
setting(this.ids, form).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '配置成功!',
});
done();
this.box = false;
},
error => {
window.console.log(error);
done();
}
);
},
handleDatasourceSubmit(form, done) {
datasource(form.tenantId, form.datasourceId).then(
() => {
this.$message({
type: 'success',
message: '配置成功!',
});
done();
this.datasourceBox = false;
},
error => {
window.console.log(error);
done();
}
);
},
handlePackageSubmit(form, done) {
packageSetting(form.tenantId, form.packageId).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '配置成功!',
});
done();
this.packageBox = false;
},
error => {
window.console.log(error);
done();
}
);
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getList(
page.currentPage,
page.pageSize,
Object.assign(params, this.query, {
status_equal: this.recycleMode ? -1 : 1,
})
).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>
<style></style>

View File

@@ -0,0 +1,377 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
v-model:page="page"
:permission="permissionList"
:before-open="beforeOpen"
v-model="form"
ref="crud"
@row-update="rowUpdate"
@row-save="rowSave"
@row-del="rowDel"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button type="danger" icon="el-icon-delete" plain @click="handleDelete"
>删 除
</el-button>
</template>
<template #shardingConfig-form="{}">
<code-editor v-model="form.shardingConfig" height="300px" />
</template>
</avue-crud>
</basic-container>
</template>
<script>
import { getList, getDetail, add, update, remove } from '@/api/system/tenantdatasource';
import { mapGetters } from 'vuex';
import func from '@/utils/func';
export default {
data() {
return {
form: {},
query: {},
loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
selectionList: [],
option: {
height: 'auto',
calcHeight: 32,
dialogWidth: 900,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
grid: true,
selection: true,
dialogClickModal: false,
column: [
{
label: '名称',
prop: 'name',
width: 120,
span: 24,
search: true,
gridRow: true,
rules: [
{
required: true,
message: '请输入数据源名称',
trigger: 'blur',
},
],
},
{
label: '数据类型',
type: 'radio',
value: 1,
span: 24,
width: 120,
searchLabelWidth: 100,
row: true,
gridRow: true,
dicUrl: '/blade-system/dict/dictionary?code=datasource_category',
props: {
label: 'dictValue',
value: 'dictKey',
},
dataType: 'number',
prop: 'category',
search: true,
rules: [
{
required: true,
message: '请选择分类',
trigger: 'blur',
},
],
},
{
label: 'YAML',
prop: 'shardingConfig',
span: 24,
minRows: 5,
hide: true,
display: false,
gridRow: true,
slot: true,
type: 'textarea',
rules: [
{
required: true,
message: '请输入YAML配置',
trigger: 'blur',
},
],
},
{
label: '驱动类',
prop: 'driverClass',
type: 'select',
span: 24,
gridRow: true,
dicData: [
{
label: 'com.mysql.cj.jdbc.Driver',
value: 'com.mysql.cj.jdbc.Driver',
},
{
label: 'org.postgresql.Driver',
value: 'org.postgresql.Driver',
},
{
label: 'oracle.jdbc.OracleDriver',
value: 'oracle.jdbc.OracleDriver',
},
{
label: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
value: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
},
{
label: 'dm.jdbc.driver.DmDriver',
value: 'dm.jdbc.driver.DmDriver',
},
],
width: 200,
display: true,
rules: [
{
required: true,
message: '请输入驱动类',
trigger: 'blur',
},
],
},
{
label: '用户名',
prop: 'username',
width: 120,
display: true,
gridRow: true,
rules: [
{
required: true,
message: '请输入用户名',
trigger: 'blur',
},
],
},
{
label: '密码',
prop: 'password',
hide: true,
display: true,
rules: [
{
required: true,
message: '请输入密码',
trigger: 'blur',
},
],
},
{
label: '连接地址',
prop: 'url',
span: 24,
display: true,
gridRow: true,
hide: true,
rules: [
{
required: true,
message: '请输入连接地址',
trigger: 'blur',
},
],
},
{
label: '备注',
prop: 'remark',
span: 24,
minRows: 3,
hide: true,
type: 'textarea',
},
],
},
data: [],
};
},
watch: {
'form.category'() {
const category = func.toInt(this.form.category);
this.$refs.crud.option.column.filter(item => {
if (item.prop === 'driverClass') {
item.display = category === 1;
}
if (item.prop === 'url') {
item.display = category === 1;
}
if (item.prop === 'username') {
item.display = category === 1;
}
if (item.prop === 'password') {
item.display = category === 1;
}
if (item.prop === 'shardingConfig') {
item.display = category === 2;
}
});
},
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addBtn: true,
viewBtn: true,
delBtn: true,
editBtn: true,
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
rowSave(row, done, loading) {
add(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => {
this.form = res.data.data;
});
}
done();
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>
<style></style>

View File

@@ -0,0 +1,249 @@
<template>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
v-model:page="page"
:permission="permissionList"
:before-open="beforeOpen"
v-model="form"
ref="crud"
@row-update="rowUpdate"
@row-save="rowSave"
@row-del="rowDel"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button type="danger" icon="el-icon-delete" plain @click="handleDelete">删 除</el-button>
</template>
</avue-crud>
</template>
<script>
import { getList, getDetail, add, update, remove } from '@/api/system/tenantpackage';
import { mapGetters } from 'vuex';
import { getMenuTree } from '@/api/system/menu';
export default {
name: 'tenantPackage',
data() {
return {
form: {},
query: {},
loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
selectionList: [],
option: {
height: 'auto',
calcHeight: 32,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
selection: true,
dialogClickModal: false,
dialogWidth: 600,
column: [
{
label: '产品包名',
prop: 'packageName',
search: true,
span: 24,
rules: [
{
required: true,
message: '请输入产品包名称',
trigger: 'blur',
},
],
},
{
label: '菜单列表',
prop: 'menuId',
span: 24,
type: 'tree',
dicData: [],
hide: true,
multiple: true,
props: {
label: 'title',
},
rules: [
{
required: true,
message: '请选择菜单',
trigger: 'blur',
},
],
},
{
label: '备注',
prop: 'remark',
span: 24,
},
],
},
data: [],
};
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addBtn: true,
viewBtn: false,
delBtn: true,
editBtn: true,
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
initData() {
getMenuTree().then(res => {
const column = this.findObject(this.option.column, 'menuId');
column.dicData = res.data.data;
});
},
rowSave(row, done, loading) {
row.menuId = row.menuId.join(',');
add(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
loading();
window.console.log(error);
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
loading();
window.console.log(error);
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type) {
if (['add', 'edit'].includes(type)) {
this.initData();
}
if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => {
this.form = res.data.data;
});
}
done();
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>
<style></style>

View File

@@ -0,0 +1,365 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
v-model:page="page"
:permission="permissionList"
:before-open="beforeOpen"
v-model="form"
ref="crud"
@row-update="rowUpdate"
@row-save="rowSave"
@row-del="rowDel"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
plain
v-if="permission.topmenu_delete"
@click="handleDelete"
>删 除
</el-button>
<el-button
icon="el-icon-setting"
@click="handleMenuSetting"
v-if="permission.topmenu_setting"
plain
>菜单配置
</el-button>
</template>
<template #name="{ row }">
<i :class="row.source" style="margin-right: 5px" />
<span>{{ row.name }}</span>
</template>
<template #source="{ row }">
<div style="text-align: center">
<i :class="row.source"></i>
</div>
</template>
<template #sort="{ row }">
<el-input-number
v-model="row.sort"
@change="sortChange(row)"
:min="1"
:max="100"
></el-input-number>
</template>
</avue-crud>
<el-dialog title="下级菜单配置" append-to-body v-model="box" width="345px">
<el-tree
:data="menuGrantList"
show-checkbox
node-key="id"
ref="treeMenu"
:default-checked-keys="menuTreeObj"
:props="props"
>
</el-tree>
<template #footer>
<span class="dialog-footer">
<el-button @click="box = false">取 消</el-button>
<el-button type="primary" @click="submit">确 定</el-button>
</span>
</template>
</el-dialog>
</basic-container>
</template>
<script>
import {
getList,
getDetail,
add,
update,
remove,
grant,
grantTree,
getTopTree,
} from '@/api/system/topmenu';
import { mapGetters } from 'vuex';
import iconList from '@/config/iconList';
export default {
data() {
return {
form: {},
box: false,
query: {},
loading: true,
props: {
label: 'title',
value: 'key',
},
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
selectionList: [],
menuGrantList: [],
menuTreeObj: [],
option: {
height: 'auto',
calcHeight: 32,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
selection: true,
dialogWidth: 900,
dialogClickModal: false,
column: [
{
label: '菜单名',
prop: 'name',
search: true,
rules: [
{
required: true,
message: '请输入菜单名',
trigger: 'blur',
},
],
},
{
label: '菜单图标',
prop: 'source',
type: 'icon',
slot: true,
iconList: iconList,
rules: [
{
required: true,
message: '请输入菜单图标',
trigger: 'click',
},
],
},
{
label: '菜单编号',
prop: 'code',
search: true,
rules: [
{
required: true,
message: '请输入菜单编号',
trigger: 'blur',
},
],
},
{
label: '菜单排序',
prop: 'sort',
type: 'number',
slot: true,
rules: [
{
required: true,
message: '请输入菜单排序',
trigger: 'blur',
},
],
},
],
},
data: [],
};
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.topmenu_add, false),
viewBtn: this.validData(this.permission.topmenu_view, false),
delBtn: this.validData(this.permission.topmenu_delete, false),
editBtn: this.validData(this.permission.topmenu_edit, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
idsArray() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids;
},
},
methods: {
submit() {
const menuList = this.$refs.treeMenu.getCheckedKeys();
grant(this.idsArray, menuList).then(() => {
this.box = false;
this.$message({
type: 'success',
message: '操作成功!',
});
this.onLoad(this.page);
});
},
rowSave(row, done, loading) {
add(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
handleMenuSetting() {
if (this.selectionList.length !== 1) {
this.$message.warning('只能选择一条数据');
return;
}
this.menuTreeObj = [];
grantTree().then(res => {
this.menuGrantList = res.data.data.menu;
getTopTree(this.ids).then(res => {
this.menuTreeObj = res.data.data.menu;
this.box = true;
});
});
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => {
this.form = res.data.data;
});
}
done();
},
sortChange(row) {
update(row).then(
() => {
this.onLoad(this.page);
},
error => {
window.console.log(error);
}
);
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>
<style>
.none-border {
border: 0;
background-color: transparent !important;
}
</style>

809
src/views/system/user.vue Normal file
View File

@@ -0,0 +1,809 @@
<template>
<el-row>
<el-col :span="5">
<div class="box">
<el-scrollbar>
<basic-container>
<avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" />
</basic-container>
</el-scrollbar>
</div>
</el-col>
<el-col :span="19">
<basic-container>
<avue-crud
:option="userOption"
v-model:search="search"
:table-loading="loading"
:data="data"
ref="crud"
v-model="form"
:permission="permissionList"
@row-del="rowDel"
@row-update="rowUpdate"
@row-save="rowSave"
:before-open="beforeOpen"
v-model:page="page"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button
v-if="permission.user_add && !auditMode"
type="primary"
icon="el-icon-plus"
@click="$refs.crud.rowAdd()"
>Add
</el-button>
<el-button
type="danger"
plain
icon="el-icon-delete"
v-if="permission.user_delete && !auditMode"
@click="handleDelete"
>Delete
</el-button>
<el-button
type="primary"
plain
icon="el-icon-operation"
v-if="userInfo.authority.includes('admin') && !auditMode"
@click="handleAudit"
>Audit
</el-button>
<el-button
type="success"
plain
icon="el-icon-check"
v-if="userInfo.authority.includes('admin') && auditMode"
@click="handleAuditPass"
>Pass
</el-button>
<el-button
type="danger"
plain
icon="el-icon-close"
v-if="userInfo.authority.includes('admin') && auditMode"
@click="handleAuditRefuse"
>Reject
</el-button>
<el-button
type="primary"
plain
icon="el-icon-refresh-left"
v-if="userInfo.authority.includes('admin') && auditMode"
@click="handleAuditBack"
>Back
</el-button>
<el-button
type="info"
plain
v-if="permission.user_role && !auditMode"
icon="el-icon-user"
@click="handleGrant"
>Role
</el-button>
<el-button
type="info"
plain
v-if="permission.user_reset && !auditMode"
icon="el-icon-refresh"
@click="handleReset"
>Reset
</el-button>
<el-button
type="info"
plain
v-if="userInfo.authority.includes('admin') && !auditMode"
icon="el-icon-setting"
@click="handlePlatform"
>Platform
</el-button>
<el-button
type="info"
plain
v-if="userInfo.authority.includes('admin') && !auditMode"
icon="el-icon-coordinate"
@click="handleLock"
>Unlock
</el-button>
<el-button
type="success"
plain
v-if="userInfo.authority.includes('admin') && !auditMode"
icon="el-icon-upload"
@click="handleImport"
>Import
</el-button>
<el-button
type="warning"
plain
v-if="userInfo.authority.includes('admin') && !auditMode"
icon="el-icon-download"
@click="handleExport"
>Export
</el-button>
</template>
<template #menu="{ row, index, size }">
<el-button
text
type="primary"
icon="el-icon-view"
v-if="this.permission.user_view"
@click.stop="$refs.crud.rowView(row, index)"
>View
</el-button>
<el-button
text
type="primary"
icon="el-icon-edit"
v-if="this.permission.user_edit"
@click.stop="$refs.crud.rowEdit(row, index)"
>Edit
</el-button>
<el-dropdown @command="command => handleDropdownCommand(command, row, index)">
<el-button text type="primary" icon="el-icon-setting">More</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="setLeader" v-if="userInfo.authority.includes('admin')">
<el-icon><circle-close v-if="row.isLeader === 1" /><user v-else /></el-icon>
{{ row.isLeader === 1 ? 'Cancel leader' : 'Set leader' }}
</el-dropdown-item>
<el-dropdown-item command="delete" v-if="this.permission.user_delete">
<el-icon><delete /></el-icon>
Delete
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</template>
<template #tenantName="{ row }">
<el-tag>{{ row.tenantName }}</el-tag>
</template>
<template #roleName="{ row }">
<el-tag>{{ row.roleName }}</el-tag>
</template>
<template #deptName="{ row }">
<el-tag>{{ row.deptName }}</el-tag>
</template>
<template #userTypeName="{ row }">
<el-tag>{{ row.userTypeName }}</el-tag>
</template>
</avue-crud>
<el-dialog title="Role" append-to-body v-model="roleBox" width="345px">
<el-tree
:data="roleGrantList"
show-checkbox
check-strictly
default-expand-all
node-key="id"
ref="treeRole"
:default-checked-keys="roleTreeObj"
:props="props"
>
</el-tree>
<template #footer>
<span class="dialog-footer">
<el-button @click="roleBox = false">取 消</el-button>
<el-button type="primary" @click="submitRole">确 定</el-button>
</span>
</template>
</el-dialog>
<el-dialog title="ImportUser" append-to-body v-model="excelBox" width="555px">
<avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
<template #excelTemplate>
<el-button type="primary" @click="handleTemplate">
Download<i class="el-icon-download el-icon--right"></i>
</el-button>
</template>
</avue-form>
</el-dialog>
<el-dialog title="Platform" append-to-body v-model="platformBox">
<avue-crud
:option="platformOption"
:table-loading="platformLoading"
:data="platformData"
ref="platformCrud"
v-model="platformForm"
:before-open="platformBeforeOpen"
v-model:page="platformPage"
:permission="platformPermissionList"
@row-update="platformRowUpdate"
@search-change="platformSearchChange"
@search-reset="platformSearchReset"
@selection-change="platformSelectionChange"
@current-change="platformCurrentChange"
@size-change="platformSizeChange"
@refresh-change="platformRefreshChange"
@on-load="platformOnLoad"
>
<template #tenantName="{ row }">
<el-tag>{{ row.tenantName }}</el-tag>
</template>
<template #userTypeName="{ row }">
<el-tag>{{ row.userTypeName }}</el-tag>
</template>
</avue-crud>
</el-dialog>
</basic-container>
</el-col>
</el-row>
</template>
<script>
import {
getList,
getUser,
getUserPlatform,
remove,
update,
updatePlatform,
add,
grant,
resetPassword,
unlock,
auditPass,
auditRefuse,
setLeader,
getLeaderList,
} from '@/api/system/user';
import { exportBlob } from '@/api/common';
import { getDeptTree } from '@/api/system/dept';
import { getRoleTree } from '@/api/system/role';
import { getPostList } from '@/api/system/post';
import { mapGetters } from 'vuex';
import website from '@/config/website';
import { getToken } from '@/utils/auth';
import { downloadXls } from '@/utils/util';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
import func from '@/utils/func';
import { sensitive } from '@/utils/sensitive';
import { excelOption, platformOption, treeOption, userOption } from '@/option/system/user';
export default {
data() {
return {
form: {},
search: {},
sensitiveManager: null,
roleBox: false,
excelBox: false,
platformBox: false,
initFlag: true,
auditMode: false,
selectionList: [],
query: {},
loading: true,
platformLoading: false,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
platformPage: {
pageSize: 10,
currentPage: 1,
total: 0,
},
init: {
roleTree: [],
deptTree: [],
},
props: {
label: 'title',
value: 'key',
},
roleGrantList: [],
roleTreeObj: [],
treeDeptId: '',
treeData: [],
treeOption: treeOption,
userOption: userOption(this),
data: [],
platformQuery: {},
platformSelectionList: [],
platformData: [],
platformForm: {},
platformOption: platformOption,
excelForm: {},
excelOption: excelOption,
};
},
watch: {
'form.tenantId'() {
if (this.form.tenantId !== '' && this.initFlag) {
this.initData(this.form.tenantId);
}
},
'excelForm.isCovered'() {
if (this.excelForm.isCovered !== '') {
const column = this.findObject(this.excelOption.column, 'excelFile');
column.action = `/blade-system/user/import-user?isCovered=${this.excelForm.isCovered}`;
}
},
},
computed: {
...mapGetters(['userInfo', 'permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.user_add, false),
viewBtn: false,
delBtn: false,
editBtn: false,
};
},
platformPermissionList() {
return {
addBtn: false,
viewBtn: false,
delBtn: false,
editBtn: this.validData(this.permission.user_edit, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
mounted() {
// 非租户模式默认加载管理组数据
if (!website.tenantMode) {
this.initData(website.tenantId);
} else {
this.initData();
}
},
created() {
// 创建脱敏工具实例
this.sensitiveManager = sensitive.create({
fields: ['phone', 'email'], // 配置需要脱敏的字段
});
},
methods: {
nodeClick(data) {
this.treeDeptId = data.id;
this.page.currentPage = 1;
this.onLoad(this.page);
},
handleDropdownCommand(command, row, index) {
if (command === 'setLeader') {
this.handleSetLeader(row);
} else if (command === 'delete') {
this.$refs.crud.rowDel(row, index);
}
},
handleSetLeader(row) {
const tip = row.isLeader === 1 ? 'Confirmation for Cancel?' : 'Confirmation for Set?';
const message = row.isLeader === 1 ? 'Cancellation Success!' : 'Setting Success!';
this.$confirm(tip, {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'warning',
})
.then(() => {
return setLeader(row.id);
})
.then(() => {
this.$message({
type: 'success',
message: message,
});
this.onLoad(this.page);
});
},
initData(tenantId) {
getRoleTree(tenantId).then(res => {
const column = this.findObject(this.userOption.group, 'roleId');
column.dicData = res.data.data;
});
getDeptTree(tenantId).then(res => {
const column = this.findObject(this.userOption.group, 'deptId');
column.dicData = res.data.data;
});
getPostList(tenantId).then(res => {
const column = this.findObject(this.userOption.group, 'postId');
column.dicData = res.data.data;
});
getLeaderList(tenantId).then(res => {
const column = this.findObject(this.userOption.group, 'leaderId');
column.dicData = res.data.data;
});
},
submitRole() {
const roleList = this.$refs.treeRole.getCheckedKeys().join(',');
grant(this.ids, roleList).then(() => {
this.roleBox = false;
this.$message({
type: 'success',
message: 'Success!',
});
this.onLoad(this.page);
});
},
rowSave(row, done, loading) {
row.deptId = func.join(row.deptId);
row.roleId = func.join(row.roleId);
row.postId = func.join(row.postId);
row.leaderId = func.join(row.leaderId);
add(row).then(
() => {
this.initFlag = false;
this.onLoad(this.page);
this.$message({
type: 'success',
message: 'Success!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
row.deptId = func.join(row.deptId);
row.roleId = func.join(row.roleId);
row.postId = func.join(row.postId);
row.leaderId = func.join(row.leaderId);
// 获取需要提交的数据
const submitData = this.sensitiveManager.getSubmitData(row);
update(submitData).then(
() => {
this.initFlag = false;
this.onLoad(this.page);
this.$message({
type: 'success',
message: 'Success!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('Confirmation for DEL?', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: 'Success!',
});
});
},
searchReset() {
this.query = {};
this.treeDeptId = '';
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('please select one or more');
return;
}
this.$confirm('Confirmation for DEL?', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: 'Success!',
});
this.$refs.crud.toggleSelection();
});
},
handleAudit() {
this.auditMode = true;
this.onLoad(this.page, this.query);
},
handleAuditPass() {
if (this.selectionList.length === 0) {
this.$message.warning('please select one or more');
return;
}
this.$confirm('确定将选择数据通过审核?', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'warning',
})
.then(() => {
return auditPass(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: 'Success!',
});
this.$refs.crud.toggleSelection();
});
},
handleAuditRefuse() {
if (this.selectionList.length === 0) {
this.$message.warning('Please select at least one record');
return;
}
this.$confirm('确定将选择数据拒绝审核?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return auditRefuse(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: 'Success!',
});
this.$refs.crud.toggleSelection();
});
},
handleAuditBack() {
this.auditMode = false;
this.onLoad(this.page, this.query);
},
handleReset() {
if (this.selectionList.length === 0) {
this.$message.warning('Please select at least one record');
return;
}
this.$confirm('确定将选择账号密码重置为初始密码?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return resetPassword(this.ids);
})
.then(() => {
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
handleGrant() {
if (this.selectionList.length === 0) {
this.$message.warning('Please select at least one record');
return;
}
this.roleTreeObj = [];
if (this.selectionList.length === 1) {
this.roleTreeObj = this.selectionList[0].roleId.split(',');
}
getRoleTree().then(res => {
this.roleGrantList = res.data.data;
this.roleBox = true;
});
},
handlePlatform() {
this.platformBox = true;
},
handleLock() {
if (this.selectionList.length === 0) {
this.$message.warning('Please select at least one record');
return;
}
this.$confirm('确定将选择账号解封?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return unlock(this.ids);
})
.then(() => {
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleImport() {
this.excelBox = true;
},
uploadAfter(res, done, loading, column) {
window.console.log(column);
this.excelBox = false;
this.refreshChange();
done();
},
handleExport() {
const account = func.toStr(this.search.account);
const realName = func.toStr(this.search.realName);
this.$confirm('是否导出用户数据?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
NProgress.start();
exportBlob(
`/blade-system/user/export-user?${
this.website.tokenHeader
}=${getToken()}&account=${account}&realName=${realName}`
).then(res => {
downloadXls(res.data, `用户数据表${this.$dayjs().format('YYYY-MM-DD')}.xlsx`);
NProgress.done();
});
});
},
handleTemplate() {
exportBlob(
`/blade-system/user/export-template?${this.website.tokenHeader}=${getToken()}`
).then(res => {
downloadXls(res.data, '用户数据模板.xlsx');
});
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getUser(this.form.id).then(res => {
this.form = res.data.data;
if (this.form.hasOwnProperty('deptId')) {
this.form.deptId = func.split(this.form.deptId);
}
if (this.form.hasOwnProperty('roleId')) {
this.form.roleId = func.split(this.form.roleId);
}
if (this.form.hasOwnProperty('postId')) {
this.form.postId = func.split(this.form.postId);
}
if (this.form.hasOwnProperty('leaderId')) {
this.form.leaderId = func.split(this.form.leaderId);
}
if (this.form.sex === -1) {
this.form.sex = '';
}
// 保存初始脱敏数据
this.sensitiveManager.saveInitialData(this.form);
});
}
this.initFlag = true;
done();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getList(
page.currentPage,
page.pageSize,
Object.assign(params, this.query, { status: this.auditMode ? 0 : 1 }),
this.treeDeptId
).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
this.selectionClear();
});
},
platformRowUpdate(row, index, done, loading) {
updatePlatform(row.id, row.userType, row.userExt).then(
() => {
this.platformOnLoad(this.platformPage);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
platformBeforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getUserPlatform(this.platformForm.id).then(res => {
this.platformForm = res.data.data;
});
}
done();
},
platformSearchReset() {
this.platformQuery = {};
this.platformOnLoad(this.platformPage);
},
platformSearchChange(params, done) {
this.platformQuery = params;
this.platformPage.currentPage = 1;
this.platformOnLoad(this.platformPage, params);
done();
},
platformSelectionChange(list) {
this.platformSelectionList = list;
},
platformSelectionClear() {
this.platformSelectionList = [];
this.$refs.platformCrud.toggleSelection();
},
platformCurrentChange(currentPage) {
this.platformPage.currentPage = currentPage;
},
platformSizeChange(pageSize) {
this.platformPage.pageSize = pageSize;
},
platformRefreshChange() {
this.platformOnLoad(this.platformPage, this.platformQuery);
},
platformOnLoad(page, params = {}) {
this.platformLoading = true;
getList(
page.currentPage,
page.pageSize,
Object.assign(params, this.query),
this.treeDeptId
).then(res => {
const data = res.data.data;
this.platformPage.total = data.total;
this.platformData = data.records;
this.platformLoading = false;
this.selectionClear();
});
},
},
};
</script>
<style>
.box {
height: 800px;
}
.el-scrollbar {
height: 100%;
}
.box .el-scrollbar__wrap {
overflow: scroll;
}
</style>

View File

@@ -0,0 +1,113 @@
<template>
<div>
<basic-container>
<avue-form
:option="option"
v-model="form"
@tab-click="handleTabClick"
@submit="handleSubmit"
></avue-form>
</basic-container>
</div>
</template>
<script>
import option from '@/option/user/info';
import { getUserInfo, updateInfo, updatePassword } from '@/api/system/user';
import md5 from 'js-md5';
import func from '@/utils/func';
import { validatenull } from '@/utils/validate';
import { sensitive } from '@/utils/sensitive';
export default {
data() {
return {
index: 0,
option: option,
form: {},
sensitiveManager: null,
};
},
created() {
this.handleWitch();
},
methods: {
handleSubmit(form, done) {
if (this.index === 0) {
const submitData = this.sensitiveManager.getSubmitData(form);
updateInfo(submitData).then(
res => {
if (res.data.success) {
this.$message({
type: 'success',
message: '修改信息成功!',
});
} else {
this.$message({
type: 'error',
message: res.data.msg,
});
}
done();
},
error => {
window.console.log(error);
done();
}
);
} else {
updatePassword(md5(form.oldPassword), md5(form.newPassword), md5(form.newPassword1)).then(
res => {
if (res.data.success) {
this.$message({
type: 'success',
message: '修改密码成功!',
});
} else {
this.$message({
type: 'error',
message: res.data.msg,
});
}
done();
},
error => {
window.console.log(error);
done();
}
);
}
},
handleWitch() {
// 创建脱敏工具实例
this.sensitiveManager = sensitive.create({
fields: ['phone', 'email'], // 配置需要脱敏的字段
});
if (this.index === 0) {
getUserInfo().then(res => {
const user = res.data.data;
this.form = {
id: user.id,
avatar: user.avatar,
name: user.name,
realName: user.realName,
phone: user.phone,
email: user.email,
};
// 保存初始脱敏数据
this.sensitiveManager.saveInitialData(this.form);
});
}
},
handleTabClick(tabs) {
if (validatenull(tabs.index)) {
return;
}
this.index = func.toInt(tabs.index, 0);
this.handleWitch();
},
},
};
</script>
<style></style>

9
src/views/test.vue Normal file
View File

@@ -0,0 +1,9 @@
<template>
<basic-container>测试页</basic-container>
</template>
<script>
export default {};
</script>
<style></style>

579
src/views/tool/code.vue Normal file
View File

@@ -0,0 +1,579 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
ref="crud"
v-model="form"
:permission="permissionList"
v-model:page="page"
@row-del="rowDel"
@row-update="rowUpdate"
@row-save="rowSave"
:before-open="beforeOpen"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
v-if="permission.code_delete"
plain
@click="handleDelete"
>删 除
</el-button>
<el-tooltip
class="item"
effect="dark"
content="将选中的多重配置集合批量生成代码"
placement="top"
>
<el-button type="primary" plain icon="el-icon-refresh" @click="handleBuild"
>代码批量生成
</el-button>
</el-tooltip>
<el-tooltip
class="item"
effect="dark"
content="不通过多重配置直接生成最简化的CRUD代码"
placement="top"
>
<el-button type="info" plain icon="el-icon-cpu" @click="handleCodeGen"
>代码快速生成
</el-button>
</el-tooltip>
</template>
<template #menu-right>
<el-tooltip
class="item"
effect="dark"
content="通过可视化表单设计器快速生成单表模块"
placement="top"
>
<el-button
plain
v-if="userInfo.authority.includes('administrator')"
:loading="!componentLoaded"
icon="el-icon-connection"
@click="handleFormSetting"
>可视化表单设计器
</el-button>
</el-tooltip>
<el-tooltip
class="item"
effect="dark"
content="配置代码生成的默认参数后自动绑定"
placement="top"
>
<el-button
plain
v-if="userInfo.authority.includes('administrator')"
icon="el-icon-message-box"
@click="handleCodeSetting"
>默认配置管理
</el-button>
</el-tooltip>
</template>
<template #menu="scope">
<el-button
type="primary"
text
icon="el-icon-document-copy"
v-if="permission.code_edit"
class="none-border"
@click.stop="handleCopy(scope.row)"
>复制
</el-button>
<el-button
type="primary"
text
icon="el-icon-refresh"
v-if="userInfo.authority.includes('administrator')"
class="none-border"
@click.stop="handleBuildSingle(scope.row)"
>生成
</el-button>
</template>
</avue-crud>
<el-drawer title="代码快速生成" append-to-body v-model="codeGenBox" direction="rtl" size="50%">
<avue-form :option="genOption" v-model="genForm" @submit="handleCodeGenSubmit" />
</el-drawer>
<el-drawer
title="可视化表单管理"
append-to-body
v-model="formSettingBox"
direction="rtl"
size="1000px"
>
<form-setting></form-setting>
</el-drawer>
<el-drawer
title="默认配置管理"
append-to-body
v-model="codeSettingBox"
direction="rtl"
size="1000px"
>
<code-setting></code-setting>
</el-drawer>
</basic-container>
</template>
<script>
import { getList, getCode, build, remove, add, update, copy, buildFast } from '@/api/tool/code';
import { getEnableDetail, getTableForm } from '@/api/tool/codesetting';
import {
getDetail as modelDetail,
getTableInfoByName,
getTableList,
prototypeDetail,
} from '@/api/tool/model';
import { codeOption, genOption } from '@/option/tool/code';
import { validatejson, validatenull } from '@/utils/validate';
import { mapGetters } from 'vuex';
import { getMenuTree } from '@/api/system/menu';
import { loadFormDesignModule, loadFormModule } from '@/utils/module';
export default {
data() {
return {
form: {},
genForm: {},
selectionList: [],
componentLoaded: false,
loading: true,
loadingOption: {
lock: true,
text: '物理表读取中',
background: 'rgba(0, 0, 0, 0.7)',
},
addMode: false,
codeGenBox: false,
codeSettingBox: false,
codeSetting: {},
formSettingBox: false,
query: {},
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
option: codeOption,
genOption: genOption,
data: [],
};
},
created() {
// 懒加载表单设计器模块
Promise.all([loadFormModule(this.$app), loadFormDesignModule(this.$app)]).then(() => {
this.componentLoaded = true;
});
},
watch: {
'form.modelId'() {
if (!validatenull(this.form.modelId) && this.addMode) {
// 获取数据模型信息
modelDetail(this.form.modelId).then(res => {
const result = res.data;
if (result.success) {
const { modelName, modelTable, modelCode } = result.data;
const lowerModelCode = modelCode.toLowerCase();
//if (validatenull(this.form.tablePrefix)) {
this.form.tablePrefix = modelTable.split('_')[0] + '_';
//}
//if (validatenull(this.form.tableName)) {
this.form.tableName = modelTable;
//}
//if (validatenull(this.form.codeName)) {
this.form.codeName = modelName;
//}
if (validatenull(this.form.serviceName)) {
this.form.serviceName = `blade-${lowerModelCode}`;
}
//if (validatenull(this.form.pkName)) {
this.form.pkName = 'id';
//}
if (validatenull(this.form.packageName)) {
this.form.packageName = `org.springblade.${lowerModelCode}`;
}
//if (validatenull(this.form.subFkId) && !validatenull(this.form.tablePrefix)) {
this.form.subFkId = modelTable.replace(this.form.tablePrefix, '') + '_id';
//}
// 获取数据原型信息
prototypeDetail(this.form.modelId).then(res => {
const result = res.data;
if (result.success) {
const columnTreeId = this.findObject(this.option.group, 'treeId');
const columnTreePid = this.findObject(this.option.group, 'treePid');
const columnTreeName = this.findObject(this.option.group, 'treeName');
columnTreeId.dicData = result.data;
columnTreePid.dicData = result.data;
columnTreeName.dicData = result.data;
}
});
}
});
}
},
'form.templateType'() {
// 模版类型
const type = this.form.templateType;
// 主子表字段显隐
const columnSubModelId = this.findObject(this.option.group, 'subModelId');
const columnSubFkId = this.findObject(this.option.group, 'subFkId');
columnSubModelId.display = type === 'sub';
columnSubFkId.display = type === 'sub';
// 树表字段显隐
const columnTreeId = this.findObject(this.option.group, 'treeId');
const columnTreePid = this.findObject(this.option.group, 'treePid');
const columnTreeName = this.findObject(this.option.group, 'treeName');
columnTreeId.display = type === 'tree';
columnTreePid.display = type === 'tree';
columnTreeName.display = type === 'tree';
},
'genForm.datasourceId'() {
if (!validatenull(this.genForm.datasourceId)) {
const fullLoading = this.$loading(this.loadingOption);
getTableList(this.genForm.datasourceId)
.then(res => {
const column = this.findObject(this.genOption.column, 'modelTable');
column.dicData = res.data.data;
fullLoading.close();
})
.catch(() => {
fullLoading.close();
});
}
},
'genForm.modelTable'() {
if (!validatenull(this.genForm.modelTable)) {
const fullLoading = this.$loading(this.loadingOption);
getTableInfoByName(this.genForm.modelTable, this.genForm.datasourceId)
.then(res => {
const result = res.data;
if (result.success) {
// 赋默认值
const { comment, entityName } = result.data;
this.genForm.modelClass = entityName;
this.genForm.modelCode = entityName.replace(/^\S/, s => s.toLowerCase());
const lowerModelCode = this.genForm.modelCode.toLowerCase();
this.genForm.tablePrefix = this.genForm.modelTable.split('_')[0] + '_';
this.genForm.tableName = this.genForm.modelTable;
this.genForm.codeName = comment;
this.genForm.pkName = 'id';
if (validatenull(this.genForm.serviceName)) {
this.genForm.serviceName = `blade-${lowerModelCode}`;
}
if (validatenull(this.genForm.packageName)) {
this.genForm.packageName = `org.springblade.${lowerModelCode}`;
}
// 字段显隐
const columnModelForm = this.findObject(this.genOption.column, 'modelForm');
const columnModelClass = this.findObject(this.genOption.column, 'modelClass');
const columnModelCode = this.findObject(this.genOption.column, 'modelCode');
const columnTablePrefix = this.findObject(this.genOption.column, 'tablePrefix');
const columnTableName = this.findObject(this.genOption.column, 'tableName');
const columnCodeName = this.findObject(this.genOption.column, 'codeName');
const columnPkName = this.findObject(this.genOption.column, 'pkName');
this.genForm.modelForm = '';
getTableForm(this.genForm.modelTable).then(res => {
columnModelForm.dicData = res.data.data;
});
columnModelForm.display = true;
columnModelClass.display = true;
columnModelCode.display = true;
columnTablePrefix.display = true;
columnTableName.display = true;
columnCodeName.display = true;
columnPkName.display = true;
fullLoading.close();
}
})
.catch(() => {
fullLoading.close();
});
}
},
},
computed: {
...mapGetters(['userInfo', 'permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.code_add, false),
viewBtn: this.validData(this.permission.code_view, false),
delBtn: this.validData(this.permission.code_delete, false),
editBtn: this.validData(this.permission.code_edit, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
initData() {
getMenuTree().then(res => {
const column = this.findObject(this.option.group, 'menuId');
column.dicData = res.data.data;
});
},
initGenData() {
getMenuTree().then(res => {
const column = this.findObject(this.genOption.column, 'menuId');
column.dicData = res.data.data;
});
getEnableDetail().then(res => {
if (validatejson(res.data.data.settings)) {
this.codeSetting = JSON.parse(res.data.data.settings);
this.genForm = {
menuId: this.codeSetting.menuId,
serviceName: this.codeSetting.serviceName,
packageName: this.codeSetting.packageName,
baseMode: this.codeSetting.baseMode,
wrapMode: this.codeSetting.wrapMode,
feignMode: this.codeSetting.feignMode,
codeStyle: this.codeSetting.codeStyle,
apiPath: this.codeSetting.apiPath,
webPath: this.codeSetting.webPath,
};
this.$message({
type: 'success',
message: '默认配置加载成功',
});
}
});
},
initSetting() {
getEnableDetail().then(res => {
if (validatejson(res.data.data.settings)) {
this.codeSetting = JSON.parse(res.data.data.settings);
this.form = {
menuId: this.codeSetting.menuId,
serviceName: this.codeSetting.serviceName,
packageName: this.codeSetting.packageName,
baseMode: this.codeSetting.baseMode,
wrapMode: this.codeSetting.wrapMode,
feignMode: this.codeSetting.feignMode,
codeStyle: this.codeSetting.codeStyle,
apiPath: this.codeSetting.apiPath,
webPath: this.codeSetting.webPath,
};
this.$message({
type: 'success',
message: '默认配置加载成功',
});
}
});
},
rowSave(row, done, loading) {
add(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleCodeGen() {
this.initGenData();
this.codeGenBox = true;
},
handleFormSetting() {
this.formSettingBox = true;
},
handleCodeSetting() {
this.codeSettingBox = true;
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
handleBuild() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('是否生成选中模块的代码?', {
title: '代码生成确认',
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
return build(this.ids).then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
});
},
handleBuildSingle(row) {
this.$confirm(`是否生成选中模块 [${row.codeName}] 的代码?`, {
title: '代码生成确认',
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
return build(row.id).then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
});
},
handleCodeGenSubmit(form, done) {
buildFast(form).then(
() => {
this.$message({
type: 'success',
message: '代码生成成功!',
});
done();
this.codeGenBox = false;
},
error => {
window.console.log(error);
done();
}
);
},
handleCopy(row) {
copy(row.id).then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '复制成功!',
});
});
},
beforeOpen(done, type) {
if (['add'].includes(type)) {
this.addMode = true;
this.initSetting();
}
if (['add', 'edit'].includes(type)) {
this.initData();
}
if (['edit', 'view'].includes(type)) {
this.addMode = false;
getCode(this.form.id).then(res => {
this.form = res.data.data;
});
}
done();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>

View File

@@ -0,0 +1,281 @@
<template>
<basic-container>
<avue-crud
:option="option"
v-model:search="search"
v-model:page="page"
v-model="form"
:table-loading="loading"
:data="data"
:permission="permissionList"
:before-open="beforeOpen"
ref="crud"
@row-update="rowUpdate"
@row-save="rowSave"
@row-del="rowDel"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button type="danger" icon="el-icon-delete" plain @click="handleDelete"
>删 除
</el-button>
</template>
<template #menu="scope">
<el-button
type="primary"
text
icon="el-icon-circle-check"
@click.stop="handleEnable(scope.row)"
>启 用
</el-button>
</template>
<template #status="{ row }">
<el-tag>{{ row.status === 1 ? '否' : '是' }}</el-tag>
</template>
</avue-crud>
</basic-container>
</template>
<script>
import { getList, getDetail, add, update, remove, enable } from '@/api/tool/codesetting';
import { getMenuTree } from '@/api/system/menu';
import option from '@/option/tool/codesetting';
import { mapGetters } from 'vuex';
export default {
data() {
return {
form: {},
query: {},
search: {},
loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
selectionList: [],
option: option,
data: [],
};
},
computed: {
...mapGetters(['userInfo', 'permission']),
permissionList() {
return {
addBtn: true,
viewBtn: true,
delBtn: true,
editBtn: true,
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
initData() {
getMenuTree().then(res => {
const column = this.findObject(this.option.column, 'menuId');
column.dicData = res.data.data;
});
},
rowSettings(row) {
return JSON.stringify({
serviceName: row.serviceName,
packageName: row.packageName,
menuId: row.menuId,
baseMode: row.baseMode,
wrapMode: row.wrapMode,
feignMode: row.feignMode,
codeStyle: row.codeStyle,
apiPath: row.apiPath,
webPath: row.webPath,
});
},
rowSettingsForm(data) {
const row = JSON.parse(data);
return {
serviceName: row.serviceName,
packageName: row.packageName,
menuId: row.menuId,
baseMode: row.baseMode,
wrapMode: row.wrapMode,
feignMode: row.feignMode,
codeStyle: row.codeStyle,
apiPath: row.apiPath,
webPath: row.webPath,
};
},
rowSave(row, done, loading) {
const data = {
name: row.name,
code: row.code,
settings: this.rowSettings(row),
};
add(data).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
loading();
window.console.log(error);
}
);
},
rowUpdate(row, index, done, loading) {
const data = {
id: row.id,
name: row.name,
code: row.code,
settings: this.rowSettings(row),
};
update(data).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
loading();
console.log(error);
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
handleEnable(row) {
this.$confirm('是否确定启用这条配置?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return enable(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type) {
if (['add', 'edit'].includes(type)) {
this.initData();
}
if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => {
this.form = {
...this.form,
...this.rowSettingsForm(res.data.data.settings),
};
});
}
done();
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
let values = {
...params,
...this.query,
category: 1,
};
getList(page.currentPage, page.pageSize, values).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>
<style></style>

View File

@@ -0,0 +1,378 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
v-model:page="page"
:permission="permissionList"
:before-open="beforeOpen"
v-model="form"
ref="crud"
@row-update="rowUpdate"
@row-save="rowSave"
@row-del="rowDel"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
plain
v-if="permission.datasource_delete"
@click="handleDelete"
>删 除
</el-button>
</template>
</avue-crud>
</basic-container>
</template>
<script>
import { getList, getDetail, add, update, remove } from '@/api/tool/datasource';
import { mapGetters } from 'vuex';
import func from '@/utils/func';
export default {
data() {
return {
form: {},
query: {},
loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
selectionList: [],
option: {
height: 'auto',
calcHeight: 32,
dialogWidth: 900,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: true,
grid: true,
selection: true,
dialogClickModal: false,
column: [
{
label: '名称',
prop: 'name',
width: 120,
span: 24,
search: true,
gridRow: true,
rules: [
{
required: true,
message: '请输入数据源名称',
trigger: 'blur',
},
],
},
{
label: '数据类型',
type: 'radio',
value: 1,
span: 24,
width: 120,
searchLabelWidth: 100,
row: true,
gridRow: true,
display: false,
dicData: [
{
label: 'jdbc',
value: 1,
},
],
dataType: 'number',
prop: 'category',
rules: [
{
required: true,
message: '请选择分类',
trigger: 'blur',
},
],
},
{
label: 'YAML',
prop: 'shardingConfig',
span: 24,
minRows: 5,
hide: true,
display: false,
gridRow: true,
type: 'textarea',
rules: [
{
required: true,
message: '请输入YAML配置',
trigger: 'blur',
},
],
},
{
label: '驱动类',
prop: 'driverClass',
type: 'select',
span: 24,
gridRow: true,
dicData: [
{
label: 'com.mysql.cj.jdbc.Driver',
value: 'com.mysql.cj.jdbc.Driver',
},
{
label: 'org.postgresql.Driver',
value: 'org.postgresql.Driver',
},
{
label: 'oracle.jdbc.OracleDriver',
value: 'oracle.jdbc.OracleDriver',
},
{
label: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
value: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
},
{
label: 'dm.jdbc.driver.DmDriver',
value: 'dm.jdbc.driver.DmDriver',
},
],
width: 200,
display: true,
rules: [
{
required: true,
message: '请输入驱动类',
trigger: 'blur',
},
],
},
{
label: '用户名',
prop: 'username',
width: 120,
display: true,
gridRow: true,
rules: [
{
required: true,
message: '请输入用户名',
trigger: 'blur',
},
],
},
{
label: '密码',
prop: 'password',
hide: true,
display: true,
rules: [
{
required: true,
message: '请输入密码',
trigger: 'blur',
},
],
},
{
label: '连接地址',
prop: 'url',
span: 24,
display: true,
gridRow: true,
rules: [
{
required: true,
message: '请输入连接地址',
trigger: 'blur',
},
],
},
{
label: '备注',
prop: 'remark',
span: 24,
minRows: 3,
hide: true,
type: 'textarea',
},
],
},
data: [],
};
},
watch: {
'form.category'() {
const category = func.toInt(this.form.category);
this.$refs.crud.option.column.filter(item => {
if (item.prop === 'driverClass') {
item.display = category === 1;
}
if (item.prop === 'url') {
item.display = category === 1;
}
if (item.prop === 'username') {
item.display = category === 1;
}
if (item.prop === 'password') {
item.display = category === 1;
}
if (item.prop === 'shardingConfig') {
item.display = category === 2;
}
});
},
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.datasource_add, false),
viewBtn: this.validData(this.permission.datasource_view, false),
delBtn: this.validData(this.permission.datasource_delete, false),
editBtn: this.validData(this.permission.datasource_edit, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
rowSave(row, done, loading) {
add(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => {
this.form = res.data.data;
});
}
done();
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>
<style></style>

View File

@@ -0,0 +1,419 @@
<template>
<basic-container>
<avue-crud
:option="option"
v-model:search="search"
v-model:page="page"
v-model="form"
:table-loading="loading"
:data="data"
:permission="permissionList"
:before-open="beforeOpen"
ref="crud"
@row-update="rowUpdate"
@row-save="rowSave"
@row-del="rowDel"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button type="danger" icon="el-icon-delete" plain @click="handleDelete"
>删 除
</el-button>
</template>
<template #menu="scope">
<el-button type="primary" text icon="el-icon-setting" @click.stop="handleDesign(scope.row)"
>设 计
</el-button>
</template>
</avue-crud>
<el-dialog
title="可视化表单设计"
v-model="designBox"
:fullscreen="true"
:before-close="handleDesignClose"
append-to-body
>
<nf-form-design
ref="formDesign"
style="height: 90vh"
:options="options"
:toolbar="['clear', 'preview', 'import', 'generate']"
:includeFields="[
'group', // 分组
'dynamic', // 子表单
'title', // 标题
'table', // 表格
'input', // 输入框
'password', // 密码
'textarea', // 文本域
'number', // 数字
'ueditor', // 富文本
'map', // 地图选择器
'radio', // 单选
'checkbox', // 多选
'select', // 下拉选择
'tree', // 树形选择
'cascader', // 级联选择
'table-select', // 表格选择
'upload', // 上传
'year', // 年
'month', // 月
'week', // 周
'date', // 日期
'time', // 时间
'datetime', // 日期时间
'daterange', // 日期范围
'datetimerange', // 日期时间范围
'timerange', // 时间范围
'sign', // 签名
'switch', // 开关
'rate', // 评价
'color', // 颜色
'icon', // 图标
'slider', // 滑块
]"
:is-crud="isCrud"
>
<template #toolbar>
<el-button
style="padding: 0"
text
type="primary"
size="default"
icon="el-icon-download"
@click="handleSubmit"
>
保存
</el-button>
</template>
</nf-form-design>
</el-dialog>
</basic-container>
</template>
<script>
import { getList, getDetail, add, update, remove, getTablePrototype } from '@/api/tool/codesetting';
import option from '@/option/tool/formsetting';
import { mapGetters } from 'vuex';
import { validatenull } from '@/utils/validate';
import { getTableInfoByName, getTableList } from '@/api/tool/model';
import func from '@/utils/func';
export default {
data() {
return {
form: {},
query: {},
search: {},
loading: true,
loadingOption: {
lock: true,
text: '物理表读取中',
background: 'rgba(0, 0, 0, 0.7)',
},
designId: '',
designBox: false,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
selectionList: [],
option: option,
data: [],
modelTable: '',
datasourceId: '',
isCrud: true,
options: {},
// 默认不需要显示的字段名
hideFields: [
'id',
'tenant_id',
'create_user',
'create_dept',
'create_time',
'update_user',
'update_time',
'status',
'is_deleted',
],
};
},
computed: {
...mapGetters(['userInfo', 'permission']),
permissionList() {
return {
addBtn: true,
viewBtn: true,
delBtn: true,
editBtn: true,
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
watch: {
'form.datasourceId'() {
if (!validatenull(this.form.datasourceId)) {
this.datasourceId = this.form.datasourceId;
const fullLoading = this.$loading(this.loadingOption);
getTableList(this.form.datasourceId)
.then(res => {
const column = this.findObject(this.option.column, 'modelTable');
column.dicData = res.data.data;
fullLoading.close();
})
.catch(() => {
fullLoading.close();
});
}
},
'form.modelTable'() {
if (!validatenull(this.form.modelTable)) {
this.modelTable = this.form.modelTable;
const fullLoading = this.$loading(this.loadingOption);
getTableInfoByName(this.form.modelTable, this.form.datasourceId)
.then(res => {
const result = res.data;
if (result.success) {
// 赋默认值
const { comment } = result.data;
this.form.name = comment;
this.form.code = this.form.modelTable;
fullLoading.close();
}
})
.catch(() => {
fullLoading.close();
});
}
},
},
methods: {
rowSave(row, done, loading) {
const data = {
name: row.name,
code: row.code,
category: 2,
settings: row.settings,
};
add(data).then(
res => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
let design = {
id: res.data.data.id,
name: data.name,
code: data.code,
};
this.handleDesign(design);
done();
},
error => {
loading();
window.console.log(error);
}
);
},
rowUpdate(row, index, done, loading) {
const data = {
id: row.id,
name: row.name,
code: row.code,
settings: row.settings,
};
update(data).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
loading();
console.log(error);
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
handleDesign(design) {
this.designBox = true;
this.designId = design.id;
getDetail(design.id).then(res => {
const settings = res.data.data.settings;
if (!validatenull(settings)) {
this.options = JSON.parse(settings);
} else if (!validatenull(this.modelTable) && !validatenull(this.datasourceId)) {
getTablePrototype(this.modelTable, this.datasourceId).then(res => {
const result = res.data;
if (result.success) {
const column = result.data
.filter(field => {
return !validatenull(field.name) && !this.hideFields.includes(field.name);
})
.map(field => {
return {
type: 'input',
label: field.comment,
display: true,
prop: func.camelCaseString(field.name),
};
});
this.options = {
column: column,
};
this.loading = false;
}
});
}
});
},
handleDesignClose() {
this.modelTable = '';
this.datasourceId = '';
this.options = {};
this.designBox = false;
},
// 可视化表单提交
handleSubmit() {
// json, string, app
this.$refs.formDesign.getData('json').then(data => {
// 表单/表格option
console.log(data);
const row = {
id: this.designId,
settings: JSON.stringify(data),
};
update(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.designBox = false;
},
error => {
console.log(error);
}
);
this.$refs.formDesign.getChangeList().then(changeList => {
// 字段prop, type, label修改记录
console.log(changeList);
});
});
},
beforeOpen(done, type) {
if (['add', 'edit'].includes(type)) {
}
if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => {
this.form = {
...this.form,
};
});
}
done();
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
let values = {
...params,
...this.query,
category: 2,
};
getList(page.currentPage, page.pageSize, values).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>
<style></style>

393
src/views/tool/model.vue Normal file
View File

@@ -0,0 +1,393 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
:page="page"
:permission="permissionList"
:before-open="beforeOpen"
v-model="form"
v-loading.fullscreen.lock="fullscreenLoading"
ref="crud"
@row-update="rowUpdate"
@row-save="rowSave"
@row-del="rowDel"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button type="danger" icon="el-icon-delete" plain @click="handleDelete"
>删 除
</el-button>
</template>
<template #menu="{ row }">
<el-button
type="primary"
text
icon="el-icon-setting"
plain
class="none-border"
@click.stop="handleModel(row)"
>模型配置
</el-button>
</template>
<template #modelTable="{ row }">
<el-tag>{{ row.modelTable }}</el-tag>
</template>
</avue-crud>
<el-dialog title="数据库模型配置" v-model="modelBox" :fullscreen="true" append-to-body>
<avue-crud
ref="crudModel"
:option="optionModel"
:table-loading="loading"
:data="fields"
></avue-crud>
<template #footer>
<span class="dialog-footer">
<el-button type="danger" @click="modelBox = false">关 闭</el-button>
<el-button type="primary" @click="handleSubmit">提 交</el-button>
</span>
</template>
</el-dialog>
</basic-container>
</template>
<script>
import {
getList,
getDetail,
add,
update,
remove,
getTableList,
getTableInfoByName,
getModelPrototype,
submitModelPrototype,
} from '@/api/tool/model';
import { entityDic, option, optionModel } from '@/const/tool/model';
import { validatenull } from '@/utils/validate';
import { mapGetters } from 'vuex';
export default {
data() {
return {
form: {},
query: {},
loading: true,
loadingOption: {
lock: true,
text: '物理表读取中',
background: 'rgba(0, 0, 0, 0.7)',
},
fullscreenLoading: false,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
selectionList: [],
modelBox: false,
modelId: 0,
datasourceId: 1,
tableInfo: {},
active: 0,
stepStart: 0,
stepEnd: 4,
data: [],
option: option,
optionModel: optionModel,
formStep: {},
fields: [],
selectionModelList: [],
// 默认不需要显示的字段名
hideFields: [
'id',
'tenant_id',
'create_user',
'create_dept',
'create_time',
'update_user',
'update_time',
'status',
'is_deleted',
],
};
},
watch: {
'form.datasourceId'() {
if (!validatenull(this.form.datasourceId)) {
const fullLoading = this.$loading(this.loadingOption);
getTableList(this.form.datasourceId)
.then(res => {
const column = this.findObject(this.option.column, 'modelTable');
column.dicData = res.data.data;
fullLoading.close();
})
.catch(() => {
fullLoading.close();
});
}
},
'form.modelTable'() {
if (!validatenull(this.form.modelTable)) {
const fullLoading = this.$loading(this.loadingOption);
getTableInfoByName(this.form.modelTable, this.form.datasourceId)
.then(res => {
const result = res.data;
if (result.success) {
const { comment, entityName } = result.data;
//if (validatenull(this.form.modelClass)) {
this.form.modelClass = entityName;
//}
//if (validatenull(this.form.modelName)) {
this.form.modelName = comment;
//}
//if (validatenull(this.form.modelCode)) {
this.form.modelCode = entityName.replace(/^\S/, s => s.toLowerCase());
//}
fullLoading.close();
}
})
.catch(() => {
fullLoading.close();
});
}
},
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addBtn: true,
delBtn: true,
editBtn: true,
viewBtn: false,
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
rowSave(row, done, loading) {
add(row).then(
res => {
done();
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$confirm('是否进行模型配置?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
let model = {
id: res.data.data.id,
datasourceId: res.data.data.datasourceId,
};
this.handleModel(model);
});
},
error => {
loading();
window.console.log(error);
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
done();
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
},
error => {
loading();
window.console.log(error);
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getDetail(this.form.id).then(res => {
this.form = res.data.data;
});
}
done();
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionModelChange(list) {
this.selectionModelList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
onLoad(page, params = {}) {
this.loading = true;
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
this.loading = false;
this.selectionClear();
});
},
handleModel(row) {
this.fields = [];
this.modelBox = true;
this.loading = true;
this.modelId = row.id;
this.datasourceId = row.datasourceId;
getModelPrototype(this.modelId, this.datasourceId).then(res => {
const result = res.data;
if (result.success) {
this.fields = result.data;
this.fields.forEach(item => {
item.$cellEdit = true;
item.modelId = this.modelId;
// 根据字段物理类型自动适配实体类型
if (!validatenull(item.name)) {
item.jdbcName = item.name;
item.jdbcType = item.propertyType;
item.jdbcComment = item.comment;
if (item.propertyType === 'LocalDateTime') {
item.propertyType = 'Date';
item.propertyEntity = 'java.util.Date';
} else {
entityDic.forEach(d => {
if (d.label === item.propertyType) {
item.propertyType = d.label;
item.propertyEntity = d.value;
}
});
}
}
// 首次加载配置默认值
if (validatenull(item.id)) {
item.isList = 1;
item.isForm = 1;
item.isRow = 0;
item.isRequired = 0;
item.isQuery = 0;
item.componentType = 'input';
// 默认不需要显示的字段名配置
if (this.hideFields.includes(item.jdbcName)) {
item.isList = 0;
item.isForm = 0;
item.isRequired = 0;
}
}
});
this.loading = false;
}
});
},
handleSubmit() {
console.log(this.fields);
this.$confirm('确定提交模型配置?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
this.fields.forEach(item => {
entityDic.forEach(d => {
if (d.value === item.propertyEntity) {
item.propertyType = d.label;
}
});
});
submitModelPrototype(this.fields).then(res => {
const result = res.data;
if (result.success) {
this.$message.success(result.msg);
this.modelBox = false;
} else {
this.$message.error(result.msg);
}
});
});
},
},
};
</script>
<style scoped>
.none-border {
border: 0;
background-color: transparent !important;
}
.step-div {
margin-top: 30px;
}
</style>

45
src/views/util/affix.vue Normal file
View File

@@ -0,0 +1,45 @@
<template>
<div class="affix">
<avue-affix id="avue-view">
<span class="affix-affix">固定在最顶部</span>
</avue-affix>
<div class="affix-line"></div>
<avue-affix id="avue-view" :offset-top="50">
<span class="affix-affix">固定在距离顶部 50px 的位置</span>
</avue-affix>
<div class="affix-line"></div>
<avue-affix id="avue-view" :offset-top="100">
<span class="affix-affix">固定在距离顶部 100px 的位置</span>
</avue-affix>
<div class="affix-line"></div>
<avue-affix id="avue-view" :offset-top="150">
<span class="affix-affix">固定在距离顶部 150px 的位置</span>
</avue-affix>
<div style="height: 2000px">
<div style="padding: 15px 20px; font-size: 18px">往下拉就会出现图钉</div>
</div>
</div>
</template>
<script>
export default {};
</script>
<style lang="scss">
.affix {
position: relative;
background-color: #fff;
&-affix {
display: inline-block;
color: #fff;
padding: 10px 30px;
text-align: center;
background: rgba(0, 153, 229, 0.9);
}
&-line {
height: 100px;
}
}
</style>

26
src/views/util/cache.vue Normal file
View File

@@ -0,0 +1,26 @@
<template>
<basic-container>
<h3>这个页面会被 keep-alive</h3>
<el-tag
>在下面的输入框输入任意字符后,切换到其它页面,再回到此页时输入框文字保留,证明被缓存
</el-tag>
<br />
<br />
<el-tag>同时滚动下拉,返回时还会保持滚动条所在的位置</el-tag>
<br />
<br />
<el-input v-model="value" placeholder="input here" />
<div style="height: 1000px"></div>
</basic-container>
</template>
<script>
export default {
data() {
return {
value: '',
};
},
};
</script>

View File

@@ -0,0 +1,52 @@
<template>
<basic-container>
<h3>点击新增或编辑跳转到新的页面</h3>
<avue-crud :option="option" :data="data">
<template #menu-left>
<el-button type="primary" @click="handleForm()" icon="el-icon-plus">add</el-button>
</template>
<template #menu="{ row }">
<el-button type="primary" text @click="handleForm(row.id)" icon="el-icon-edit"
>edit
</el-button>
</template>
</avue-crud>
</basic-container>
</template>
<script>
export default {
data() {
return {
option: {
addBtn: false,
editBtn: false,
column: [
{
label: '姓名',
prop: 'name',
},
],
},
data: [
{
id: 1,
name: 'small',
},
],
};
},
methods: {
handleForm(id) {
this.$router.push({
path: '/form-detail/index',
query: {
id: id,
},
});
},
},
};
</script>
<style></style>

198
src/views/util/data.vue Normal file
View File

@@ -0,0 +1,198 @@
<template>
<basic-container>
<h3>数据展示</h3>
<avue-data-pay :option="option"></avue-data-pay>
</basic-container>
</template>
<script>
export default {
data() {
return {
option: {
span: 8,
data: [
{
title: '后台模版',
src: '/img/bg/vip1.png',
money: '299',
dismoney: '199',
tip: '/永久',
color: '#808695',
subtext: '购买',
click: () => {
this.box = true;
},
list: [
{
title: '点击体验',
href: 'https://cli1.avue.top',
check: true,
},
{
title: '面向全屏幕尺寸的响应式适配能力',
check: true,
},
{
title: '支持IE9+等系列浏览器',
check: true,
},
{
title: '全新的前端错误日志监控机制',
check: true,
},
{
title: '基于最新的avuex底层开发',
check: true,
},
{
title: '前端路由动态服务端加载',
check: true,
},
{
title: '灵活的多款主题自由配置',
check: true,
},
{
title: '模块的可拆卸化,达到开箱即用',
check: true,
},
{
title: '免费的私人git私服',
},
{
title: '专属会员群',
},
{
title: '前端最新干货分享',
},
{
title: '赠送 Avue-cli脚手架文档(价值¥59.99)',
href: 'https://www.kancloud.cn/smallwei/avue',
},
{
title: '赠送 Avue 修仙系列视频教程',
href: 'https://www.bilibili.com/video/av24644922',
check: true,
},
],
},
{
title: 'Avuex源码',
src: '/img/bg/vip2.png',
color: '#ffa820',
money: '999',
dismoney: '399',
tip: '/永久',
subtext: '购买',
click: () => {
this.box = true;
},
list: [
{
title: '一键集成表格的导出excel,打印,等功能',
check: true,
},
{
title: '底层代码可重用轻松对接多个UI框架',
check: true,
},
{
title: '底层更加完善的开发错误调试机制',
check: true,
},
{
title: '一套代码多个终端自适应',
check: true,
},
{
title: '一键集成表格的导出excel,打印,等常用功能',
check: true,
},
{
title: '表格的批量操作,表单的级联操作更加便捷',
check: true,
},
{
title: '新增大量常用组件(搜索,选项卡)',
check: true,
},
{
title: '新增大量全新可配置的骚属性',
check: true,
},
{
title: '丰富的数据展示模版组件包',
check: true,
},
{
title: '专属的开发者文档,助你快速掌握',
check: true,
},
{
title: '赠送 Avue-cli脚手架文档(价值¥59.99)',
href: 'https://www.kancloud.cn/smallwei/avue',
check: true,
},
{
title: '赠送 Avue 修仙系列视频教程',
href: 'https://www.bilibili.com/video/av24644922',
check: true,
},
],
},
{
title: '全家桶',
src: '/img/bg/vip3.png',
color: '#ef4868',
money: '999.99',
dismoney: '399.99',
tip: '/永久',
subtext: '购买',
click: () => {
this.box = true;
},
list: [
{
title: '授权商业化开发,永久更新授权使用',
check: true,
},
{
title: '后期更新和新产品将全部免费',
check: true,
},
{
title: '拥有avuex系列的全部特权和全部源码',
check: true,
},
{
title: '免费的私人git私服',
check: true,
},
{
title: '专属会员群',
check: true,
},
{
title: '前端最新干货分享',
check: true,
},
{
title: '赠送 Avue-cli脚手架文档(价值¥59.99)',
href: 'https://www.kancloud.cn/smallwei/avue',
check: true,
},
{
title: '赠送 Avue 修仙系列视频教程',
href: 'https://www.bilibili.com/video/av24644922',
check: true,
},
],
},
],
},
};
},
};
</script>
<style></style>

View File

@@ -0,0 +1,352 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
ref="crud"
v-model="form"
:permission="permissionList"
:before-open="beforeOpen"
:before-close="beforeClose"
@row-del="rowDel"
@row-update="rowUpdate"
@row-save="rowSave"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
v-if="permission.dict_delete"
plain
@click="handleDelete"
>删 除
</el-button>
</template>
<template #isSealed="{ row }">
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
</template>
<template #menu="scope">
<el-button
type="primary"
text
icon="el-icon-circle-plus"
@click.stop="handleAdd(scope.row, scope.index)"
>新增子项
</el-button>
</template>
</avue-crud>
</basic-container>
</template>
<script>
import { getList, remove, update, add, getDict, getDictTree } from '@/api/system/dict';
import { mapGetters } from 'vuex';
export default {
data() {
return {
form: {},
selectionList: [],
query: {},
loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
option: {
tip: false,
searchShow: true,
searchMenuSpan: 6,
tree: true,
border: true,
index: true,
selection: true,
viewBtn: true,
menuWidth: 300,
dialogWidth: 880,
column: [
{
label: '字典编号',
prop: 'code',
search: true,
span: 24,
rules: [
{
required: true,
message: '请输入字典编号',
trigger: 'blur',
},
],
},
{
label: '字典名称',
prop: 'dictValue',
search: true,
align: 'center',
rules: [
{
required: true,
message: '请输入字典名称',
trigger: 'blur',
},
],
},
{
label: '上级字典',
prop: 'parentId',
type: 'tree',
dicData: [],
hide: true,
props: {
label: 'title',
},
rules: [
{
required: false,
message: '请选择上级字典',
trigger: 'click',
},
],
},
{
label: '字典键值',
prop: 'dictKey',
type: 'number',
rules: [
{
required: true,
message: '请输入字典键值',
trigger: 'blur',
},
],
},
{
label: '字典排序',
prop: 'sort',
type: 'number',
rules: [
{
required: true,
message: '请输入字典排序',
trigger: 'blur',
},
],
},
{
label: '封存',
prop: 'isSealed',
type: 'select',
dicData: [
{
label: '否',
value: 0,
},
{
label: '是',
value: 1,
},
],
slot: true,
rules: [
{
required: true,
message: '请选择封存',
trigger: 'blur',
},
],
},
{
label: '字典备注',
prop: 'remark',
search: true,
hide: true,
},
],
},
data: [],
};
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.dict_add, false),
viewBtn: this.validData(this.permission.dict_view, false),
delBtn: this.validData(this.permission.dict_delete, false),
editBtn: this.validData(this.permission.dict_edit, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
mounted() {
getDictTree().then(res => {
const column = this.findObject(this.optionChild.column, 'parentId');
column.dicData = res.data.data;
});
},
methods: {
handleAdd(row) {
this.$refs.crud.value.code = row.code;
this.$refs.crud.value.parentId = row.id;
this.$refs.crud.option.column.filter(item => {
if (item.prop === 'code') {
item.value = row.code;
item.addDisabled = true;
}
if (item.prop === 'parentId') {
item.value = row.id;
item.addDisabled = true;
}
});
this.$refs.crud.rowAdd();
},
rowSave(row, done, loading) {
add(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getDict(this.form.id).then(res => {
this.form = res.data.data;
});
}
done();
},
beforeClose(done) {
this.$refs.crud.tableForm = {};
this.$refs.crud.value.code = '';
this.$refs.crud.value.parentId = '';
this.$refs.crud.value.addDisabled = false;
this.$refs.crud.option.column.filter(item => {
if (item.prop === 'code') {
item.value = '';
item.addDisabled = false;
}
if (item.prop === 'parentId') {
item.value = '';
item.addDisabled = false;
}
});
done();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
this.data = res.data.data;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>
<style></style>

View File

@@ -0,0 +1,469 @@
<template>
<div>
<basic-container>
<el-row>
<el-col :span="12">
<avue-crud
:option="option"
:table-loading="loading"
:data="dataParent"
:page="pageParent"
ref="crud"
v-model="formParent"
:permission="permissionList"
:before-open="beforeOpen"
@row-del="rowDel"
@row-update="rowUpdate"
@row-save="rowSave"
@row-click="handleRowClick"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoadParent"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
v-if="permission.dict_delete"
plain
@click="handleDelete"
>删 除
</el-button>
</template>
<template #isSealed="{ row }">
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
</template>
</avue-crud>
</el-col>
<el-col :span="12">
<avue-crud
:option="option"
:table-loading="loading"
:data="dataChild"
:page="pageChild"
ref="crudChild"
v-model="formChild"
:permission="permissionList"
:before-open="beforeOpenChild"
@row-del="rowDelChild"
@row-update="rowUpdateChild"
@row-save="rowSaveChild"
@search-change="searchChangeChild"
@search-reset="searchResetChild"
@selection-change="selectionChangeChild"
@current-change="currentChangeChild"
@size-change="sizeChangeChild"
@refresh-change="refreshChangeChild"
@on-load="onLoadChild"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
v-if="permission.dict_delete"
plain
@click="handleDelete"
>删 除
</el-button>
</template>
<template #isSealed="{ row }">
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
</template>
</avue-crud>
</el-col>
</el-row>
</basic-container>
</div>
</template>
<script>
import { getParentList, getChildList, remove, update, add, getDict } from '@/api/system/dict';
import { mapGetters } from 'vuex';
export default {
data() {
return {
parentId: 0,
formParent: {},
formChild: {},
selectionList: [],
query: {},
loading: true,
pageParent: {
pageSize: 10,
pageSizes: [10, 30, 50, 100, 200],
currentPage: 1,
total: 0,
},
pageChild: {
pageSize: 10,
pageSizes: [10, 30, 50, 100, 200],
currentPage: 1,
total: 0,
},
dataParent: [],
dataChild: [],
option: {
tip: false,
searchShow: true,
searchMenuSpan: 6,
tree: true,
border: true,
index: true,
selection: true,
viewBtn: true,
menuWidth: 300,
dialogWidth: 880,
column: [
{
label: '字典编号',
prop: 'code',
search: true,
span: 24,
rules: [
{
required: true,
message: '请输入字典编号',
trigger: 'blur',
},
],
},
{
label: '字典键值',
prop: 'dictKey',
type: 'number',
rules: [
{
required: true,
message: '请输入字典键值',
trigger: 'blur',
},
],
},
{
label: '字典名称',
prop: 'dictValue',
search: true,
align: 'center',
rules: [
{
required: true,
message: '请输入字典名称',
trigger: 'blur',
},
],
},
{
label: '字典排序',
prop: 'sort',
type: 'number',
rules: [
{
required: true,
message: '请输入字典排序',
trigger: 'blur',
},
],
},
{
label: '封存',
prop: 'isSealed',
type: 'select',
dicData: [
{
label: '否',
value: 0,
},
{
label: '是',
value: 1,
},
],
slot: true,
rules: [
{
required: true,
message: '请选择封存',
trigger: 'blur',
},
],
},
{
label: '字典备注',
prop: 'remark',
search: true,
hide: true,
},
],
},
};
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.dict_add, false),
viewBtn: this.validData(this.permission.dict_view, false),
delBtn: this.validData(this.permission.dict_delete, false),
editBtn: this.validData(this.permission.dict_edit, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
rowSave(row, done, loading) {
add(row).then(
() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleRowClick(row) {
this.parentId = row.id;
this.onLoadChild(this.pageChild);
},
searchReset() {
this.query = {};
this.onLoadParent(this.pageParent);
},
searchChange(params, done) {
this.query = params;
this.pageParent.currentPage = 1;
this.onLoadParent(this.pageParent, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getDict(this.formParent.id).then(res => {
this.formParent = res.data.data;
});
}
done();
},
currentChange(currentPage) {
this.pageParent.currentPage = currentPage;
},
sizeChange(pageSize) {
this.pageParent.pageSize = pageSize;
},
refreshChange() {
this.onLoadParent(this.page, this.query);
},
rowSaveChild(row, done, loading) {
add(row).then(
() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdateChild(row, index, done, loading) {
update(row).then(
() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDelChild(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
searchResetChild() {
this.query = {};
this.onLoadChild(this.pageChild);
},
searchChangeChild(params, done) {
this.query = params;
this.pageChild.currentPage = 1;
this.onLoadChild(this.pageChild, params);
done();
},
selectionChangeChild(list) {
this.selectionList = list;
},
selectionClearChild() {
this.selectionList = [];
this.$refs.crudChild.toggleSelection();
},
handleDeleteChild() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crudChild.toggleSelection();
});
},
beforeOpenChild(done, type) {
if (['edit', 'view'].includes(type)) {
getDict(this.formChild.id).then(res => {
this.formChild = res.data.data;
});
}
done();
},
currentChangeChild(currentPage) {
this.pageChild.currentPage = currentPage;
},
sizeChangeChild(pageSize) {
this.pageChild.pageSize = pageSize;
},
refreshChangeChild() {
this.onLoadChild(this.pageChild, this.query);
},
onLoadParent(page, params = {}) {
this.loading = true;
getParentList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(
res => {
const data = res.data.data;
this.pageParent.total = data.total;
this.dataParent = data.records;
this.loading = false;
this.selectionClear();
}
);
},
onLoadChild(page, params = {}) {
this.loading = true;
getChildList(
page.currentPage,
page.pageSize,
this.parentId,
Object.assign(params, this.query)
).then(res => {
const data = res.data.data;
this.pageChild.total = data.total;
this.dataChild = data.records;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>
<style></style>

View File

@@ -0,0 +1,474 @@
<template>
<div>
<basic-container>
<el-row>
<el-col :span="24">
<avue-crud
:option="option"
:table-loading="loading"
:data="dataParent"
:page="pageParent"
ref="crud"
v-model="formParent"
:permission="permissionList"
:before-open="beforeOpen"
@row-del="rowDel"
@row-update="rowUpdate"
@row-save="rowSave"
@row-click="handleRowClick"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoadParent"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
v-if="permission.dict_delete"
plain
@click="handleDelete"
>删 除
</el-button>
</template>
<template #isSealed="{ row }">
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
</template>
</avue-crud>
</el-col>
</el-row>
</basic-container>
<basic-container>
<el-row>
<el-col :span="24">
<avue-crud
:option="option"
:table-loading="loading"
:data="dataChild"
:page="pageChild"
ref="crudChild"
v-model="formChild"
:permission="permissionList"
:before-open="beforeOpenChild"
@row-del="rowDelChild"
@row-update="rowUpdateChild"
@row-save="rowSaveChild"
@search-change="searchChangeChild"
@search-reset="searchResetChild"
@selection-change="selectionChangeChild"
@current-change="currentChangeChild"
@size-change="sizeChangeChild"
@refresh-change="refreshChangeChild"
@on-load="onLoadChild"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
v-if="permission.dict_delete"
plain
@click="handleDelete"
>删 除
</el-button>
</template>
<template #isSealed="{ row }">
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
</template>
</avue-crud>
</el-col>
</el-row>
</basic-container>
</div>
</template>
<script>
import { getParentList, getChildList, remove, update, add, getDict } from '@/api/system/dict';
import { mapGetters } from 'vuex';
export default {
data() {
return {
parentId: 0,
formParent: {},
formChild: {},
selectionList: [],
query: {},
loading: true,
pageParent: {
pageSize: 5,
pageSizes: [5, 10, 30, 50, 100, 200],
currentPage: 1,
total: 0,
},
pageChild: {
pageSize: 5,
pageSizes: [5, 10, 30, 50, 100, 200],
currentPage: 1,
total: 0,
},
dataParent: [],
dataChild: [],
option: {
tip: false,
searchShow: true,
searchMenuSpan: 6,
tree: true,
border: true,
index: true,
selection: true,
viewBtn: true,
height: 300,
menuWidth: 300,
dialogWidth: 880,
column: [
{
label: '字典编号',
prop: 'code',
search: true,
span: 24,
rules: [
{
required: true,
message: '请输入字典编号',
trigger: 'blur',
},
],
},
{
label: '字典键值',
prop: 'dictKey',
type: 'number',
rules: [
{
required: true,
message: '请输入字典键值',
trigger: 'blur',
},
],
},
{
label: '字典名称',
prop: 'dictValue',
search: true,
align: 'center',
rules: [
{
required: true,
message: '请输入字典名称',
trigger: 'blur',
},
],
},
{
label: '字典排序',
prop: 'sort',
type: 'number',
rules: [
{
required: true,
message: '请输入字典排序',
trigger: 'blur',
},
],
},
{
label: '封存',
prop: 'isSealed',
type: 'select',
dicData: [
{
label: '否',
value: 0,
},
{
label: '是',
value: 1,
},
],
slot: true,
rules: [
{
required: true,
message: '请选择封存',
trigger: 'blur',
},
],
},
{
label: '字典备注',
prop: 'remark',
search: true,
hide: true,
},
],
},
};
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.dict_add, false),
viewBtn: this.validData(this.permission.dict_view, false),
delBtn: this.validData(this.permission.dict_delete, false),
editBtn: this.validData(this.permission.dict_edit, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
rowSave(row, done, loading) {
add(row).then(
() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleRowClick(row) {
this.parentId = row.id;
this.onLoadChild(this.pageChild);
},
searchReset() {
this.query = {};
this.onLoadParent(this.pageParent);
},
searchChange(params, done) {
this.query = params;
this.pageParent.currentPage = 1;
this.onLoadParent(this.pageParent, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getDict(this.formParent.id).then(res => {
this.formParent = res.data.data;
});
}
done();
},
currentChange(currentPage) {
this.pageParent.currentPage = currentPage;
},
sizeChange(pageSize) {
this.pageParent.pageSize = pageSize;
},
refreshChange() {
this.onLoadParent(this.page, this.query);
},
rowSaveChild(row, done, loading) {
add(row).then(
() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdateChild(row, index, done, loading) {
update(row).then(
() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDelChild(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
searchResetChild() {
this.query = {};
this.onLoadChild(this.pageChild);
},
searchChangeChild(params, done) {
this.query = params;
this.pageChild.currentPage = 1;
this.onLoadChild(this.pageChild, params);
done();
},
selectionChangeChild(list) {
this.selectionList = list;
},
selectionClearChild() {
this.selectionList = [];
this.$refs.crudChild.toggleSelection();
},
handleDeleteChild() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crudChild.toggleSelection();
});
},
beforeOpenChild(done, type) {
if (['edit', 'view'].includes(type)) {
getDict(this.formChild.id).then(res => {
this.formChild = res.data.data;
});
}
done();
},
currentChangeChild(currentPage) {
this.pageChild.currentPage = currentPage;
},
sizeChangeChild(pageSize) {
this.pageChild.pageSize = pageSize;
},
refreshChangeChild() {
this.onLoadChild(this.pageChild, this.query);
},
onLoadParent(page, params = {}) {
this.loading = true;
getParentList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(
res => {
const data = res.data.data;
this.pageParent.total = data.total;
this.dataParent = data.records;
this.loading = false;
this.selectionClear();
}
);
},
onLoadChild(page, params = {}) {
this.loading = true;
getChildList(
page.currentPage,
page.pageSize,
this.parentId,
Object.assign(params, this.query)
).then(res => {
const data = res.data.data;
this.pageChild.total = data.total;
this.dataChild = data.records;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>
<style></style>

View File

@@ -0,0 +1,465 @@
<template>
<el-row>
<el-col :span="11">
<basic-container>
<el-card class="box-card">
<template #header>
<div class="clearfix">
<span>字典列表</span>
</div>
</template>
<div class="clearfix">
<avue-crud
:option="optionParent"
:table-loading="loading"
:data="dataParent"
:page="pageParent"
ref="crud"
v-model="formParent"
:permission="permissionList"
:before-open="beforeOpen"
@row-del="rowDel"
@row-update="rowUpdate"
@row-save="rowSave"
@row-click="handleRowClick"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoadParent"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
v-if="permission.dict_delete"
plain
@click="handleDelete"
>删 除
</el-button>
</template>
<template #isSealed="{ row }">
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
</template>
</avue-crud>
</div>
</el-card>
</basic-container>
</el-col>
<el-col :span="13">
<basic-container>
<el-card class="box-card">
<template #header>
<div class="clearfix">
<span>[{{ dictValue }}] 字典详情</span>
</div>
</template>
<div class="clearfix">
<avue-crud
:option="optionChild"
:table-loading="loadingChild"
:data="dataChild"
ref="crudChild"
v-model="formChild"
:permission="permissionList"
:before-open="beforeOpenChild"
:before-close="beforeCloseChild"
@row-del="rowDelChild"
@row-update="rowUpdateChild"
@row-save="rowSaveChild"
@search-change="searchChangeChild"
@search-reset="searchResetChild"
@selection-change="selectionChangeChild"
@current-change="currentChangeChild"
@size-change="sizeChangeChild"
@refresh-change="refreshChangeChild"
@on-load="onLoadChild"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
v-if="permission.dict_delete"
plain
@click="handleDelete"
>删 除
</el-button>
</template>
<template #menu="scope">
<el-button
type="primary"
text
icon="el-icon-circle-plus"
@click.stop="handleAdd(scope.row, scope.index)"
v-if="userInfo.authority.includes('admin')"
>新增子项
</el-button>
</template>
<template #isSealed="{ row }">
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
</template>
</avue-crud>
</div>
</el-card>
</basic-container>
</el-col>
</el-row>
</template>
<script>
import {
getParentList,
getChildList,
remove,
update,
add,
getDict,
getDictTree,
} from '@/api/system/dict';
import { optionParent, optionChild } from '@/option/system/dict';
import { mapGetters } from 'vuex';
export default {
data() {
return {
dictValue: '暂无',
parentId: -1,
formParent: {},
formChild: {},
selectionList: [],
query: {},
loading: true,
loadingChild: true,
pageParent: {
pageSize: 10,
pageSizes: [10, 30, 50, 100, 200],
currentPage: 1,
total: 0,
},
pageChild: {
pageSize: 10,
pageSizes: [10, 30, 50, 100, 200],
currentPage: 1,
total: 0,
},
dataParent: [],
dataChild: [],
optionParent: optionParent,
optionChild: optionChild,
};
},
computed: {
...mapGetters(['userInfo', 'permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.dict_add, false),
delBtn: this.validData(this.permission.dict_delete, false),
editBtn: this.validData(this.permission.dict_edit, false),
viewBtn: false,
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
mounted() {
this.initData();
},
methods: {
initData() {
getDictTree().then(res => {
const column = this.findObject(this.optionChild.column, 'parentId');
column.dicData = res.data.data;
});
},
handleAdd(row) {
this.$refs.crudChild.value.dictValue = '';
this.$refs.crudChild.value.dictKey = '';
this.$refs.crudChild.value.sort = 0;
this.$refs.crudChild.value.isSealed = 0;
this.$refs.crudChild.value.remark = '';
this.$refs.crudChild.modelValue.parentId = row.id;
this.$refs.crudChild.option.column.filter(item => {
if (item.prop === 'parentId') {
item.value = row.id;
}
});
this.$refs.crudChild.rowAdd();
},
rowSave(row, done, loading) {
const form = {
...row,
dictKey: -1,
};
add(form).then(
() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
this.onLoadChild(this.pageChild);
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleRowClick(row) {
this.query = {};
this.parentId = row.id;
this.dictValue = row.dictValue;
this.$refs.crudChild.value.code = row.code;
this.$refs.crudChild.modelValue.parentId = row.id;
this.$refs.crudChild.option.column.filter(item => {
if (item.prop === 'code') {
item.value = row.code;
}
if (item.prop === 'parentId') {
item.value = row.id;
}
});
this.onLoadChild(this.pageChild);
},
searchReset() {
this.query = {};
this.onLoadParent(this.pageParent);
},
searchChange(params, done) {
this.query = params;
this.pageParent.currentPage = 1;
this.onLoadParent(this.pageParent, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getDict(this.formParent.id).then(res => {
this.formParent = res.data.data;
});
}
done();
},
currentChange(currentPage) {
this.pageParent.currentPage = currentPage;
},
sizeChange(pageSize) {
this.pageParent.pageSize = pageSize;
},
refreshChange() {
this.onLoadParent(this.pageParent, this.query);
},
rowSaveChild(row, done, loading) {
add(row).then(
() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdateChild(row, index, done, loading) {
update(row).then(
() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDelChild(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
searchResetChild() {
this.query = {};
this.onLoadChild(this.pageChild);
},
searchChangeChild(params, done) {
this.query = params;
this.pageChild.currentPage = 1;
this.onLoadChild(this.pageChild, params);
done();
},
selectionChangeChild(list) {
this.selectionList = list;
},
selectionClearChild() {
this.selectionList = [];
this.$refs.crudChild.toggleSelection();
},
handleDeleteChild() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crudChild.toggleSelection();
});
},
beforeOpenChild(done, type) {
if (['add', 'edit'].includes(type)) {
this.initData();
}
if (['edit', 'view'].includes(type)) {
getDict(this.formChild.id).then(res => {
this.formChild = res.data.data;
});
}
done();
},
beforeCloseChild(done) {
this.$refs.crudChild.modelValue.parentId = this.parentId;
this.$refs.crudChild.option.column.filter(item => {
if (item.prop === 'parentId') {
item.value = this.parentId;
}
});
done();
},
currentChangeChild(currentPage) {
this.pageChild.currentPage = currentPage;
},
sizeChangeChild(pageSize) {
this.pageChild.pageSize = pageSize;
},
refreshChangeChild() {
this.onLoadChild(this.pageChild, this.query);
},
onLoadParent(page, params = {}) {
this.loading = true;
getParentList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(
res => {
const data = res.data.data;
this.pageParent.total = data.total;
this.dataParent = data.records;
this.loading = false;
this.selectionClear();
}
);
},
onLoadChild(page, params = {}) {
this.loadingChild = true;
getChildList(
page.currentPage,
page.pageSize,
this.parentId,
Object.assign(params, this.query)
).then(res => {
this.dataChild = res.data.data;
this.loadingChild = false;
this.selectionClear();
});
},
},
};
</script>

View File

@@ -0,0 +1,459 @@
<template>
<el-row>
<el-col :span="11">
<basic-container>
<el-card class="box-card">
<template #header>
<div class="clearfix">
<span>业务字典列表</span>
</div>
</template>
<div class="clearfix">
<avue-crud
:option="optionParent"
:table-loading="loading"
:data="dataParent"
:page="pageParent"
ref="crud"
v-model="formParent"
:permission="permissionList"
:before-open="beforeOpen"
@row-del="rowDel"
@row-update="rowUpdate"
@row-save="rowSave"
@row-click="handleRowClick"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoadParent"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
v-if="permission.dict_delete"
plain
@click="handleDelete"
>删 除
</el-button>
</template>
<template #isSealed="{ row }">
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
</template>
</avue-crud>
</div>
</el-card>
</basic-container>
</el-col>
<el-col :span="13">
<basic-container>
<el-card class="box-card">
<template #header>
<div class="clearfix">
<span>[{{ dictValue }}] 业务字典详情</span>
</div>
</template>
<div class="clearfix">
<avue-crud
:option="optionChild"
:table-loading="loadingChild"
:data="dataChild"
ref="crudChild"
v-model="formChild"
:permission="permissionList"
:before-open="beforeOpenChild"
:before-close="beforeCloseChild"
@row-del="rowDelChild"
@row-update="rowUpdateChild"
@row-save="rowSaveChild"
@search-change="searchChangeChild"
@search-reset="searchResetChild"
@selection-change="selectionChangeChild"
@current-change="currentChangeChild"
@size-change="sizeChangeChild"
@refresh-change="refreshChangeChild"
@on-load="onLoadChild"
>
<template #menu-left>
<el-button
type="danger"
icon="el-icon-delete"
v-if="permission.dict_delete"
plain
@click="handleDelete"
>删 除
</el-button>
</template>
<template #menu="scope">
<el-button
type="primary"
text
icon="el-icon-circle-plus"
@click.stop="handleAdd(scope.row, scope.index)"
v-if="userInfo.authority.includes('admin')"
>新增子项
</el-button>
</template>
<template #isSealed="{ row }">
<el-tag>{{ row.isSealed === 0 ? '否' : '是' }}</el-tag>
</template>
</avue-crud>
</div>
</el-card>
</basic-container>
</el-col>
</el-row>
</template>
<script>
import {
getParentList,
getChildList,
remove,
update,
add,
getDict,
getDictTree,
} from '@/api/system/dictbiz';
import { optionParent, optionChild } from '@/option/system/dictbiz';
import { mapGetters } from 'vuex';
export default {
data() {
return {
dictValue: '暂无',
parentId: -1,
formParent: {},
formChild: {},
selectionList: [],
query: {},
loading: true,
loadingChild: true,
pageParent: {
pageSize: 10,
pageSizes: [10, 30, 50, 100, 200],
currentPage: 1,
total: 0,
},
pageChild: {
pageSize: 10,
pageSizes: [10, 30, 50, 100, 200],
currentPage: 1,
total: 0,
},
dataParent: [],
dataChild: [],
optionParent: optionParent,
optionChild: optionChild,
};
},
computed: {
...mapGetters(['userInfo', 'permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.dictbiz_add, false),
delBtn: this.validData(this.permission.dictbiz_delete, false),
editBtn: this.validData(this.permission.dictbiz_edit, false),
viewBtn: false,
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
mounted() {
this.initData();
},
methods: {
initData() {
getDictTree().then(res => {
const column = this.findObject(this.optionChild.column, 'parentId');
column.dicData = res.data.data;
});
},
handleAdd(row) {
this.$refs.crudChild.modelValue.parentId = row.id;
this.$refs.crudChild.option.column.filter(item => {
if (item.prop === 'parentId') {
item.value = row.id;
}
});
this.$refs.crudChild.rowAdd();
},
rowSave(row, done, loading) {
const form = {
...row,
dictKey: -1,
};
add(form).then(
() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdate(row, index, done, loading) {
update(row).then(
() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleRowClick(row) {
this.query = {};
this.parentId = row.id;
this.dictValue = row.dictValue;
this.$refs.crudChild.value.code = row.code;
this.$refs.crudChild.modelValue.parentId = row.id;
this.$refs.crudChild.option.column.filter(item => {
if (item.prop === 'code') {
item.value = row.code;
}
if (item.prop === 'parentId') {
item.value = row.id;
}
});
this.onLoadChild(this.pageChild);
},
searchReset() {
this.query = {};
this.onLoadParent(this.pageParent);
},
searchChange(params, done) {
this.query = params;
this.pageParent.currentPage = 1;
this.onLoadParent(this.pageParent, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoadParent(this.pageParent);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type) {
if (['edit', 'view'].includes(type)) {
getDict(this.formParent.id).then(res => {
this.formParent = res.data.data;
});
}
done();
},
currentChange(currentPage) {
this.pageParent.currentPage = currentPage;
},
sizeChange(pageSize) {
this.pageParent.pageSize = pageSize;
},
refreshChange() {
this.onLoadParent(this.pageParent, this.query);
},
rowSaveChild(row, done, loading) {
add(row).then(
() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowUpdateChild(row, index, done, loading) {
update(row).then(
() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
rowDelChild(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(row.id);
})
.then(() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
searchResetChild() {
this.query = {};
this.onLoadChild(this.pageChild);
},
searchChangeChild(params, done) {
this.query = params;
this.pageChild.currentPage = 1;
this.onLoadChild(this.pageChild, params);
done();
},
selectionChangeChild(list) {
this.selectionList = list;
},
selectionClearChild() {
this.selectionList = [];
this.$refs.crudChild.toggleSelection();
},
handleDeleteChild() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return remove(this.ids);
})
.then(() => {
this.onLoadChild(this.pageChild);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crudChild.toggleSelection();
});
},
beforeOpenChild(done, type) {
if (['add', 'edit'].includes(type)) {
this.initData();
}
if (['edit', 'view'].includes(type)) {
getDict(this.formChild.id).then(res => {
this.formChild = res.data.data;
});
}
done();
},
beforeCloseChild(done) {
this.$refs.crudChild.modelValue.parentId = this.parentId;
this.$refs.crudChild.option.column.filter(item => {
if (item.prop === 'parentId') {
item.value = this.parentId;
}
});
done();
},
currentChangeChild(currentPage) {
this.pageChild.currentPage = currentPage;
},
sizeChangeChild(pageSize) {
this.pageChild.pageSize = pageSize;
},
refreshChangeChild() {
this.onLoadChild(this.pageChild, this.query);
},
onLoadParent(page, params = {}) {
this.loading = true;
getParentList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(
res => {
const data = res.data.data;
this.pageParent.total = data.total;
this.dataParent = data.records;
this.loading = false;
this.selectionClear();
}
);
},
onLoadChild(page, params = {}) {
this.loadingChild = true;
getChildList(
page.currentPage,
page.pageSize,
this.parentId,
Object.assign(params, this.query)
).then(res => {
this.dataChild = res.data.data;
this.loadingChild = false;
this.selectionClear();
});
},
},
};
</script>

View File

@@ -0,0 +1,37 @@
<template>
<basic-container>
<h3>{{ $route.query.id ? '编辑' : '新增' }}</h3>
<avue-form :option="option" v-model="form">
<template #menu-form>
<el-button icon="el-icon-back" @click="handleBack()">返 回</el-button>
</template>
</avue-form>
</basic-container>
</template>
<script>
export default {
data() {
return {
form: {},
option: {
labelWidth: 110,
column: [
{
label: '姓名',
prop: 'name',
},
],
},
};
},
methods: {
handleBack() {
this.$router.$avueRouter.closeTag();
this.$router.back();
},
},
};
</script>
<style></style>

53
src/views/util/form.vue Normal file
View File

@@ -0,0 +1,53 @@
<template>
<basic-container>
<h3>表单例子</h3>
<avue-form :option="option" v-model="form"></avue-form>
</basic-container>
</template>
<script>
export default {
data() {
return {
form: {},
option: {
labelWidth: 110,
column: [
{
label: '用户名',
prop: 'username',
row: true,
},
{
label: '密码',
prop: 'password',
type: 'password',
row: true,
},
{
label: '再次输入密码',
prop: 'password',
type: 'newpassword',
row: true,
},
{
label: '申请日期',
prop: 'date',
type: 'date',
row: true,
},
{
label: '个性签名',
prop: 'textarea',
type: 'textarea',
minRows: 8,
row: true,
},
],
},
};
},
};
</script>
<style></style>

16
src/views/util/logs.vue Normal file
View File

@@ -0,0 +1,16 @@
<template>
<basic-container>
<h3>请打开浏览器控制台,然后点击下面的按钮</h3>
<el-button type="danger" @click="handleNewError">触发一个错误</el-button>
</basic-container>
</template>
<script>
export default {
methods: {
handleNewError() {
window.console.log(a); // eslint-disable-line
},
},
};
</script>

View File

@@ -0,0 +1,81 @@
<template>
<div>
<basic-container>
<h3>表格权限控制</h3>
<avue-crud ref="crud" :permission="permission" :option="option" :data="data">
<template #expand="scope">
{{ scope }}
</template>
</avue-crud>
</basic-container>
<basic-container>
权限开关
<el-switch
:active-value="false"
:inactive-value="true"
v-model="text"
active-color="#13ce66"
inactive-color="#ff4949"
>
</el-switch>
<p>
具体参考<a href="https://avuex.avue.top/#/doc/crud-permission"
>https://avuex.avue.top/#/doc/crud-permission</a
>
</p>
</basic-container>
</div>
</template>
<script>
export default {
data() {
return {
text: false,
permission: {},
option: {
expand: true,
column: [
{
label: '姓名',
prop: 'name',
},
{
label: '年龄',
prop: 'sex',
},
],
},
data: [
{
id: 1,
name: '张三',
sex: 12,
},
{
id: 2,
name: '李四',
sex: 20,
},
],
};
},
watch: {
text() {
if (this.text === true) {
this.permission = {
delBtn: false,
addBtn: false,
};
} else {
this.permission = {
delBtn: true,
addBtn: true,
};
}
},
},
};
</script>
<style></style>

95
src/views/util/store.vue Normal file
View File

@@ -0,0 +1,95 @@
<template>
<basic-container>
<h3>存储</h3>
<el-tag class="title">基本读写删(持久化存储)</el-tag>
<div class="box">
<el-button type="primary" @click="setItem({ name: 'username', value: 'avuex' })"
>set('username', 'avuex')
</el-button>
<el-button type="success" @click="getItem({ name: 'username' })">get('username')</el-button>
<el-button type="danger" @click="delItem({ name: 'username' })"
>remove('username')
</el-button>
</div>
<el-tag class="title">设置session(session存储)</el-tag>
<div class="box">
<el-button
type="primary"
@click="setItem({ name: 'username', value: 'avuex', type: 'session' })"
>set('username', 'avuex')
</el-button>
<el-button type="success" @click="getItem({ name: 'username', type: 'session' })"
>get('username')
</el-button>
<el-button type="danger" @click="delItem({ name: 'username', type: 'session' })"
>remove('username')
</el-button>
</div>
<el-tag class="title">获取所有可以获得的数据</el-tag>
<div class="box">
<el-button type="success" @click="getAll()">getAll(持久化存储)</el-button>
<el-button type="success" @click="getAll({ type: 'session' })"
>getAll(session存储)
</el-button>
<el-button type="danger" @click="clearAll()">delAll(持久化存储)</el-button>
<el-button type="danger" @click="clearAll({ type: 'session' })"
>delAll(session存储)
</el-button>
</div>
</basic-container>
</template>
<script>
import { setStore, getStore, removeStore, clearStore, getAllStore } from '@/utils/store';
export default {
name: 'store',
methods: {
setItem(params = {}) {
const { name, value, type } = params;
setStore({
name: name,
content: value,
type: type,
});
this.$message(`设置数据 ${name} = ${value}`);
},
getItem(params = {}) {
const { name, type } = params;
const content = getStore({
name: name,
type: type,
});
this.$message(`获取数据 ${name} = ${content}`);
},
delItem(params = {}) {
const { name, type } = params;
removeStore({ name, type });
this.$message(`删除数据 ${name}`);
},
clearAll(params = {}) {
clearStore(params);
this.$message(`清除全部数据完成`);
},
getAll(params = {}) {
const list = getAllStore(params);
window.console.log(list);
this.$message(`结果已经打印到控制台`);
},
},
};
</script>
<style lang="scss">
.title {
margin-bottom: 10px;
}
.box {
margin-bottom: 20px;
}
</style>

126
src/views/util/table.vue Normal file
View File

@@ -0,0 +1,126 @@
<template>
<basic-container>
<h3>表格例子</h3>
<avue-crud :option="option" v-model:page="page" :data="data" />
</basic-container>
</template>
<script>
export default {
data() {
return {
page: {
total: 122,
},
data: [
{
username: 'smallwei',
name: 'avue',
password: '123456',
newpassword: '123456',
date: '2019-01-01',
textarea: '这是一条很长很长很长很长很长很长很长很长的个性签名',
},
{
username: 'smallwei',
name: 'avue',
password: '123456',
newpassword: '123456',
date: '2019-01-01',
textarea: '这是一条很长很长很长很长很长很长很长很长的个性签名',
},
{
username: 'smallwei',
name: 'avue',
password: '123456',
newpassword: '123456',
date: '2019-01-01',
textarea: '这是一条很长很长很长很长很长很长很长很长的个性签名',
},
{
username: 'smallwei',
name: 'avue',
password: '123456',
newpassword: '123456',
date: '2019-01-01',
textarea: '这是一条很长很长很长很长很长很长很长很长的个性签名',
},
{
username: 'smallwei',
name: 'avue',
password: '123456',
newpassword: '123456',
date: '2019-01-01',
textarea: '这是一条很长很长很长很长很长很长很长很长的个性签名',
},
{
username: 'smallwei',
name: 'avue',
password: '123456',
newpassword: '123456',
date: '2019-01-01',
textarea: '这是一条很长很长很长很长很长很长很长很长的个性签名',
},
{
username: 'smallwei',
name: 'avue',
password: '123456',
newpassword: '123456',
date: '2019-01-01',
textarea: '这是一条很长很长很长很长很长很长很长很长的个性签名',
},
],
option: {
column: [
{
label: '用户名',
prop: 'username',
span: 14,
row: true,
},
{
label: '姓名',
prop: 'name',
span: 14,
row: true,
},
{
label: '密码',
prop: 'password',
type: 'password',
span: 14,
row: true,
},
{
label: '确认密码',
prop: 'newpassword',
type: 'password',
hide: true,
span: 14,
row: true,
},
{
label: '申请日期',
prop: 'date',
type: 'date',
span: 14,
row: true,
},
{
label: '个性签名',
prop: 'textarea',
type: 'textarea',
minRows: 8,
span: 24,
overHidden: true,
row: true,
},
],
},
};
},
};
</script>
<style></style>

18
src/views/util/tags.vue Normal file
View File

@@ -0,0 +1,18 @@
<template>
<basic-container>
<h3>标签</h3>
<el-button type="primary" @click="$router.push('/test/index')">打开一个页面</el-button>
<el-button type="primary" @click="$router.$avueRouter.closeTag('/test/index')"
>关闭打开的页面
</el-button>
<el-button type="primary" @click="$router.$avueRouter.closeTag()">关闭本标签</el-button>
</basic-container>
</template>
<script>
export default {
methods: {},
};
</script>
<style></style>

19
src/views/util/test.vue Normal file
View File

@@ -0,0 +1,19 @@
<template>
<div>
<basic-container>测试页</basic-container>
</div>
</template>
<script>
export default {
name: 'wel',
data() {
return {};
},
computed: {},
created() {},
methods: {},
};
</script>
<style scoped="scoped" lang="scss"></style>

26
src/views/util/top.vue Normal file
View File

@@ -0,0 +1,26 @@
<template>
<div>
<div style="height: 2000px; background-color: #fff">
<div style="padding: 15px 20px; font-size: 18px">往下拉就会出现返回菜单</div>
</div>
<avue-back-top id="avue-view"></avue-back-top>
<avue-back-top id="avue-view" :height="100" :bottom="200">
<div class="top">返回顶端</div>
</avue-back-top>
</div>
</template>
<script>
export default {};
</script>
<style scoped>
.top {
padding: 10px;
font-size: 14px;
background: rgba(0, 153, 229, 0.7);
color: #fff;
text-align: center;
border-radius: 2px;
}
</style>

196
src/views/wel/dashboard.vue Normal file
View File

@@ -0,0 +1,196 @@
<template>
<basic-container>
<div class="wel">
<basic-block
:width="width"
:height="height"
icon="el-icon-platform-eleme"
text="开始菜单1"
time="1"
background="/img/bg/bg3.jpg"
color="#d56259"
></basic-block>
<basic-block
:width="width"
:height="height"
icon="el-icon-eleme"
text="开始菜单2"
time="2"
background="/img/bg/bg2.jpg"
color="#419ce7"
></basic-block>
<basic-block
:width="width"
:height="height"
icon="el-icon-delete-solid"
text="开始菜单3"
time="3"
color="#56b69b"
></basic-block>
<basic-block
:width="width"
:height="height"
icon="el-icon-delete"
text="开始菜单4"
time="4"
color="#d44858"
></basic-block>
<basic-block
:width="width"
:height="height"
icon="el-icon-s-tools"
text="开始菜单5"
time="5"
color="#3a1f7e"
></basic-block>
<basic-block
:width="410"
:height="height"
icon="el-icon-setting"
text="开始菜单6"
time="6"
background="/img/bg/bg1.jpg"
dept="这是一段很长的很长很长很长的描述这是一段很长的很长很长很长的描述"
color="#422829"
></basic-block>
<basic-block
:width="width"
:height="height"
icon="el-icon-user-solid"
text="开始菜单7"
time="7"
color="#613cbd"
></basic-block>
<basic-block
:width="width"
:height="height"
icon="el-icon-star-off"
text="开始菜单8"
time="8"
color="#da542e"
></basic-block>
<basic-block
:width="width"
:height="height"
icon="el-icon-goods"
text="开始菜单9"
time="9"
color="#2e8aef"
></basic-block>
<basic-block
:width="width"
:height="height"
icon="el-icon-circle-check"
text="开始菜单10"
time="10"
color="#3d17b8"
></basic-block>
<basic-block
:width="width"
:height="height"
icon="el-icon-s-platform"
text="开始菜单11"
time="11"
color="#e31462"
></basic-block>
<basic-block
:width="width"
:height="height"
icon="el-icon-s-fold"
text="开始菜单12"
time="12"
color="#d9532d"
></basic-block>
<basic-block
:width="410"
:height="height"
icon="el-icon-s-open"
text="开始菜单13"
time="13"
dept="这是一段很长的很长很长很长的描述这是一段很长的很长很长很长的描述"
color="#b72147"
></basic-block>
<basic-block
:width="width"
:height="height"
icon="el-icon-s-flag"
text="开始菜单14"
time="14"
color="#01a100"
></basic-block>
<basic-block
:width="width"
:height="height"
icon="el-icon-s-data"
text="开始菜单15"
time="15"
color="#0c56bf"
></basic-block>
<basic-block
:width="width"
:height="height"
icon="el-icon-s-grid"
text="开始菜单16"
time="16"
color="#0098a9"
></basic-block>
<basic-block
:width="width"
:height="height"
icon="el-icon-s-release"
text="开始菜单17"
time="17"
background="/img/bg/bg2.jpg"
color="#209bdf"
></basic-block>
<basic-block
:width="width"
:height="height"
icon="el-icon-s-home"
text="开始菜单18"
time="18"
background="/img/bg/bg3.jpg"
color="#603bbc"
></basic-block>
<basic-block
:width="515"
:height="height"
icon="el-icon-s-promotion"
text="开始菜单19"
time="19"
dept="这是一段很长的很长很长很长的描述这是一段很长的很长很长很长的描述"
color="#009bad"
></basic-block>
<basic-block
:width="515"
:height="height"
icon="el-icon-s-custom"
text="开始菜单20"
time="20"
background="/img/bg/bg4.jpg"
dept="这是一段很长的很长很长很长的描述这是一段很长的很长很长很长的描述"
color="#d74e2a"
></basic-block>
</div>
</basic-container>
</template>
<script>
export default {
data() {
return {
width: 200,
height: 120,
};
},
};
</script>
<style lang="scss">
.wel {
display: flex;
flex-wrap: wrap;
width: 1100px;
margin: 0 auto;
}
</style>

135
src/views/wel/index.vue Normal file
View File

@@ -0,0 +1,135 @@
<template>
<div>
<el-row>
<el-col :span="24">
<third-register></third-register>
</el-col>
<el-col :span="24">
<basic-container>
<p style="text-align: center">
<img src="https://img.shields.io/badge/JDK-17+-green.svg" alt="Build Status" />
<img src="https://img.shields.io/badge/Spring%20Boot-3.2-blue.svg" alt="Downloads" />
</p>
</basic-container>
</el-col>
<el-col :span="15">
<basic-container>
<el-collapse v-model="activeNames" @change="handleChange">
<el-collapse-item title="Welcome to MemoryBlock Management System" name="1"/>
</el-collapse>
</basic-container>
</el-col>
<el-col :span="9">
<el-col :span="24">
<basic-container>
<div class="el-font-size">
<span>Product</span>
<el-divider direction="vertical" />
<span>
<el-tag>MemoryBlock Management System</el-tag>
</span>
<el-divider content-position="right"><i class="el-icon-star-off" /></el-divider>
<span>Website AUS</span>
<el-divider direction="vertical" />
<span>
<el-link href="https://memoryblock.com.au" target="_blank" type="primary"
>https://memoryblock.com.au</el-link
>
</span>
<el-divider content-position="right"><i class="el-icon-star-off" /></el-divider>
<span>Website USA</span>
<el-divider direction="vertical" />
<span>
<el-link href="https://memoryblock.com" target="_blank" type="primary"
>https://memoryblock.com</el-link
>
</span>
<el-divider content-position="right"><i class="el-icon-star-off" /></el-divider>
<!-- <span>获取文档</span>-->
<!-- <el-divider direction="vertical" />-->
<!-- <span class="tag-group">-->
<!-- <el-tag-->
<!-- type="success"-->
<!-- style="cursor: pointer"-->
<!-- onclick="window.open('https://sns.bladex.cn/note/view/1.html')"-->
<!-- >免费版</el-tag-->
<!-- >-->
<!-- <el-divider direction="vertical" />-->
<!-- <el-tooltip-->
<!-- class="item"-->
<!-- effect="dark"-->
<!-- content="前往商业群文件免费下载,每份授权有一个名额入群"-->
<!-- placement="top"-->
<!-- >-->
<!-- <el-tag type="danger" style="cursor: pointer">收费版</el-tag>-->
<!-- </el-tooltip>-->
<!-- </span>-->
<!-- <el-divider content-position="right"><i class="el-icon-star-off" /></el-divider>-->
<!-- <span>获取源码</span>-->
<!-- <el-divider direction="vertical" />-->
<!-- <span class="tag-group">-->
<!-- <el-tag-->
<!-- type="success"-->
<!-- effect="dark"-->
<!-- style="cursor: pointer"-->
<!-- onclick="window.open('https://gitee.com/smallc/SpringBlade')"-->
<!-- >开源版</el-tag-->
<!-- >-->
<!-- <el-divider direction="vertical" />-->
<!-- <el-tag-->
<!-- type="danger"-->
<!-- effect="dark"-->
<!-- style="cursor: pointer"-->
<!-- onclick="window.open('https://bladex.cn/#/vip')"-->
<!-- >商业版</el-tag-->
<!-- >-->
<!-- </span>-->
</div>
</basic-container>
</el-col>
<el-col :span="24">
<basic-container>
<el-collapse v-model="logActiveNames" @change="handleChange">
<el-collapse-item
title="1.0.0.RELEASE publish"
name="42"
>
<div>1.[ADD]Device Management</div>
<div>2.[ADD]Store Management</div>
</el-collapse-item>
</el-collapse>
</basic-container>
</el-col>
</el-col>
</el-row>
</div>
</template>
<script>
import { mapGetters } from 'vuex';
export default {
name: 'wel',
data() {
return {
activeNames: ['1', '2', '3', '5'],
logActiveNames: ['42'],
};
},
computed: {
...mapGetters(['userInfo']),
},
methods: {
handleChange(val) {
window.console.log(val);
},
},
};
</script>
<style>
.el-font-size {
font-size: 14px;
}
</style>