Commit a31ea9e5 authored by 陈浩玮's avatar 陈浩玮

Merge branch 'feature/shuiluo' into 'master'

Feature/shuiluo

See merge request product/kim3-web-vue/starter-web-vue!3
parents 7ebe2e6e 09240bbb
<template>
<a-table-column :title="title">
<template #default="row">
<template v-for="btn of basicBtns">
<PopconfirmDelete
:url="`/api/v1/roles/${row.roleId}`"
:cb="refreshTable"
:key="btn.label"
v-if="btn.type === 'del'"
/>
<a @click="() => btn?.click(row, btn)" :key="btn.label">{{ btn.label }}</a>
<a-divider type="vertical" :key="btn.label + 'divider'" />
</template>
<template v-if="moreBtns.length">
<a-popover>
<template slot="content">
<a v-for="btn of moreBtns" :key="btn.label" @click="() => btn?.click(row, btn)">
{{ btn.label }}
</a>
</template>
<a>...</a>
</a-popover>
</template>
</template>
</a-table-column>
</template>
<script>
export default {
props: {
title: {
type: String,
default: '操作',
},
buttons: {
type: Array,
default: () => [
{
label: '查看',
onClick(row) {},
type: 'del',
},
],
},
},
computed: {
basicBtns() {
return this.buttons.length > 3 ? this.buttons.slice(0, 3) : this.buttons;
},
moreBtns() {
return this.buttons.length > 3 ? this.buttons.slice(3) : [];
},
},
};
</script>
<template>
<a-tree-select
show-search
style="width: 100%"
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
placeholder="请选择"
allow-clear
tree-default-expand-all
:treeData="treeData"
:replaceFields="replaceFields"
v-bind="$attrs"
v-on="$listeners"
/>
</template>
<script>
import { getMenuDataApi } from '@/api';
import { convertListToTree } from '@/utils';
export default {
model: {
prop: 'value',
event: 'change',
},
data() {
return {
treeData: [],
replaceFields: {
title: 'menuName',
key: 'menuId',
value: 'menuId',
},
};
},
async mounted() {
this.treeData = convertListToTree(await getMenuDataApi(), true);
console.log(this.treeData);
},
};
</script>
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<div class="tw-text-right tw-mt-2"> <div class="tw-text-right tw-mt-2">
<a-space> <a-space>
<a-button @click="queryForm = {}">重置</a-button> <a-button @click="queryForm = { ...initQuery }">重置</a-button>
<a-button type="primary" @click="getData">查询</a-button> <a-button type="primary" @click="getData">查询</a-button>
</a-space> </a-space>
</div> </div>
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
:closable="false" :closable="false"
:drawerStyle="drawerStyle" :drawerStyle="drawerStyle"
:bodyStyle="bodyStyle" :bodyStyle="bodyStyle"
:width="addBtn.width" :width="addBtn.width || 600"
destroyOnClose destroyOnClose
> >
<div class="tw-overflow-y-hidden"> <div class="tw-overflow-y-hidden">
...@@ -73,9 +73,15 @@ export default { ...@@ -73,9 +73,15 @@ export default {
noPage: Boolean, noPage: Boolean,
}, },
data() { data() {
this.initQuery = {
pageNum: 1,
pageSize: 10,
};
return { return {
data: [], data: [],
queryForm: {}, queryForm: {
...this.initQuery,
},
loading: false, loading: false,
addVisible: false, addVisible: false,
submitLoading: false, submitLoading: false,
...@@ -106,14 +112,24 @@ export default { ...@@ -106,14 +112,24 @@ export default {
async getData() { async getData() {
this.loading = true; this.loading = true;
try { try {
const res = await request(this.url, METHOD.GET); this.noPage ? await this.getDataNoPage() : await this.getDataWithPage();
if (this.formatData) this.data = this.formatData(res);
else this.data = res;
} catch (error) { } catch (error) {
// todo // todo
} }
this.loading = false; this.loading = false;
}, },
async getDataNoPage() {
const res = await request(this.url, METHOD.GET);
if (this.formatData) this.data = this.formatData(res);
else this.data = res;
},
async getDataWithPage() {
const res = await request(this.url, METHOD.GET, this.queryForm);
if (this.formatData) this.data = this.formatData(res);
else this.data = res.records;
},
add() { add() {
this.addVisible = true; this.addVisible = true;
}, },
...@@ -124,12 +140,12 @@ export default { ...@@ -124,12 +140,12 @@ export default {
this.submitLoading = true; this.submitLoading = true;
try { try {
await this.addBtn?.onOk(); await this.addBtn?.onOk();
this.addVisible = false;
this.getData(); this.getData();
} catch (error) { } catch (error) {
// todo // todo
} }
this.submitLoading = false; this.submitLoading = false;
this.addVisible = false;
}, },
showAdd() { showAdd() {
this.addVisible = true; this.addVisible = true;
......
...@@ -8,7 +8,7 @@ export default { ...@@ -8,7 +8,7 @@ export default {
}, },
//大量共享的方法 //大量共享的方法
getters: { getters: {
user: (state) => { user: state => {
if (!state.user) { if (!state.user) {
try { try {
const user = localStorage.getItem(process.env.VUE_APP_USER_KEY); const user = localStorage.getItem(process.env.VUE_APP_USER_KEY);
...@@ -19,31 +19,27 @@ export default { ...@@ -19,31 +19,27 @@ export default {
} }
return state.user; return state.user;
}, },
permissions: (state) => { permissions: state => {
if (!state.permissions) { if (!state.permissions) {
try { try {
const permissions = localStorage.getItem(process.env.VUE_APP_PERMISSIONS_KEY); state.permissions = [];
state.permissions = JSON.parse(permissions);
state.permissions = state.permissions ? state.permissions : [];
} catch (e) { } catch (e) {
console.error(e.message); console.error(e.message);
} }
} }
return state.permissions; return state.permissions;
}, },
roles: (state) => { roles: state => {
if (!state.roles) { if (!state.roles) {
try { try {
const roles = localStorage.getItem(process.env.VUE_APP_ROLES_KEY); state.roles = [];
state.roles = JSON.parse(roles);
state.roles = state.roles ? state.roles : [];
} catch (e) { } catch (e) {
console.error(e.message); console.error(e.message);
} }
} }
return state.roles; return state.roles;
}, },
routesConfig: (state) => { routesConfig: state => {
if (!state.routesConfig) { if (!state.routesConfig) {
try { try {
const routesConfig = localStorage.getItem(process.env.VUE_APP_ROUTES_KEY); const routesConfig = localStorage.getItem(process.env.VUE_APP_ROUTES_KEY);
......
...@@ -37,7 +37,6 @@ export default { ...@@ -37,7 +37,6 @@ export default {
addBtn: { addBtn: {
text: '新建', text: '新建',
title: '菜单配置', title: '菜单配置',
width: 400,
onOk() { onOk() {
return vm.$refs['addForm']?.submit(); return vm.$refs['addForm']?.submit();
}, },
......
<template> <template>
<a-form-model layout="vertical" :model="form" :rules="rules"> <a-form-model layout="vertical" :model="form" :rules="rules" ref="form">
<a-form-model-item label="父级" v-if="isAdd"> <a-form-model-item label="父级" extra="没选择代表根目录" v-if="isAdd">
<MenuTree @check="onCheck" :value="checkedKeys" checkStrictly /> <MenuTree v-model="form.parentMenuId" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="类型"> <a-form-model-item label="类型">
<a-radio-group v-model="form.menuType" :disabled="isEdit"> <a-radio-group v-model="form.menuType" :disabled="isEdit">
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<script> <script>
import { addMenuApi } from '@/api'; import { addMenuApi } from '@/api';
import MenuTree from '@/components/menu_tree/index.vue'; import MenuTree from '@/components/menu_tree/select.vue';
export default { export default {
components: { MenuTree }, components: { MenuTree },
...@@ -40,16 +40,12 @@ export default { ...@@ -40,16 +40,12 @@ export default {
type: 0, type: 0,
form: { form: {
menuType: 'CATALOG', menuType: 'CATALOG',
parentMenuId: 0, parentMenuId: null,
menuName: '', menuName: '',
}, },
rules: { rules: {
menuUrl: [{ required: true }], menuUrl: [{ required: true }],
}, },
checkedKeys: {
checked: [],
halfChecked: [],
},
}), }),
computed: { computed: {
isAdd() { isAdd() {
...@@ -60,12 +56,9 @@ export default { ...@@ -60,12 +56,9 @@ export default {
}, },
}, },
methods: { methods: {
submit() { async submit() {
return addMenuApi({ ...this.form, parentMenuId: this.checkedKeys.checked[0] ?? 0 }); await this.$refs['form'].validate();
}, return addMenuApi({ ...this.form, parentMenuId: this.form.parentMenuId ?? 0 });
onCheck(checkedKeys) {
const checked = checkedKeys.checked.slice(-1);
this.checkedKeys = { checked };
}, },
setEdit(data) { setEdit(data) {
this.type = 1; this.type = 1;
......
<template> <template>
<my-table url="/api/v1/roles" rowKey="roleId" :addBtn="addBtn" ref="table"> <my-table url="/api/v1/roles" rowKey="roleId" :addBtn="addBtn" ref="table" noPage>
<template #add> <template #add>
<Form ref="form" /> <Form ref="form" />
</template> </template>
...@@ -26,7 +26,7 @@ export default { ...@@ -26,7 +26,7 @@ export default {
components: { Form, PopconfirmDelete }, components: { Form, PopconfirmDelete },
data() { data() {
return { return {
addBtn: { width: 400, onOk: () => this.$refs['form']?.submit() }, addBtn: { onOk: () => this.$refs['form']?.submit() },
}; };
}, },
methods: { methods: {
......
<template>
<my-table url="/api/v1/schedules" rowKey="taskId">
<a-table-column title="任务名称" data-index="taskName" />
<a-table-column title="调度规则" data-index="taskRule" />
<a-table-column title="实现类" data-index="implementClass" />
<a-table-column title="说明" data-index="remark" />
<a-table-column title="操作" data-index="remark" />
</my-table>
</template>
<script>
export default {};
</script>
...@@ -95,6 +95,11 @@ const options = { ...@@ -95,6 +95,11 @@ const options = {
name: '日志管理', name: '日志管理',
component: () => import('@/pages/system/view/log'), component: () => import('@/pages/system/view/log'),
}, },
{
path: 'task_management',
name: '任务管理',
component: () => import('@/pages/system/view/task/index.vue'),
},
], ],
}, },
], ],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment