Commit 16a99e67 authored by 陈浩玮's avatar 陈浩玮

Merge branch 'master' of...

Merge branch 'master' of http://platform.kuopu.net:9999/gitlab/product/kim3-web-vue/starter-web-vue into feature/chw
parents 1a58c36d a31ea9e5
<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 @@
<div class="tw-text-right tw-mt-2">
<a-space>
<a-button @click="queryForm = {}">重置</a-button>
<a-button @click="queryForm = { ...initQuery }">重置</a-button>
<a-button type="primary" @click="getData">查询</a-button>
</a-space>
</div>
......@@ -39,7 +39,7 @@
:closable="false"
:drawerStyle="drawerStyle"
:bodyStyle="bodyStyle"
:width="addBtn.width"
:width="addBtn.width || 600"
destroyOnClose
>
<div class="tw-overflow-y-hidden">
......@@ -73,9 +73,15 @@ export default {
noPage: Boolean,
},
data() {
this.initQuery = {
pageNum: 1,
pageSize: 10,
};
return {
data: [],
queryForm: {},
queryForm: {
...this.initQuery,
},
loading: false,
addVisible: false,
submitLoading: false,
......@@ -106,14 +112,24 @@ export default {
async getData() {
this.loading = true;
try {
const res = await request(this.url, METHOD.GET);
if (this.formatData) this.data = this.formatData(res);
else this.data = res;
this.noPage ? await this.getDataNoPage() : await this.getDataWithPage();
} catch (error) {
// todo
}
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() {
this.addVisible = true;
},
......@@ -124,12 +140,12 @@ export default {
this.submitLoading = true;
try {
await this.addBtn?.onOk();
this.addVisible = false;
this.getData();
} catch (error) {
// todo
}
this.submitLoading = false;
this.addVisible = false;
},
showAdd() {
this.addVisible = true;
......
......@@ -8,7 +8,7 @@ export default {
},
//大量共享的方法
getters: {
user: (state) => {
user: state => {
if (!state.user) {
try {
const user = localStorage.getItem(process.env.VUE_APP_USER_KEY);
......@@ -19,31 +19,27 @@ export default {
}
return state.user;
},
permissions: (state) => {
permissions: state => {
if (!state.permissions) {
try {
const permissions = localStorage.getItem(process.env.VUE_APP_PERMISSIONS_KEY);
state.permissions = JSON.parse(permissions);
state.permissions = state.permissions ? state.permissions : [];
state.permissions = [];
} catch (e) {
console.error(e.message);
}
}
return state.permissions;
},
roles: (state) => {
roles: state => {
if (!state.roles) {
try {
const roles = localStorage.getItem(process.env.VUE_APP_ROLES_KEY);
state.roles = JSON.parse(roles);
state.roles = state.roles ? state.roles : [];
state.roles = [];
} catch (e) {
console.error(e.message);
}
}
return state.roles;
},
routesConfig: (state) => {
routesConfig: state => {
if (!state.routesConfig) {
try {
const routesConfig = localStorage.getItem(process.env.VUE_APP_ROUTES_KEY);
......
......@@ -37,7 +37,6 @@ export default {
addBtn: {
text: '新建',
title: '菜单配置',
width: 400,
onOk() {
return vm.$refs['addForm']?.submit();
},
......
<template>
<a-form-model layout="vertical" :model="form" :rules="rules">
<a-form-model-item label="父级" v-if="isAdd">
<MenuTree @check="onCheck" :value="checkedKeys" checkStrictly />
<a-form-model layout="vertical" :model="form" :rules="rules" ref="form">
<a-form-model-item label="父级" extra="没选择代表根目录" v-if="isAdd">
<MenuTree v-model="form.parentMenuId" />
</a-form-model-item>
<a-form-model-item label="类型">
<a-radio-group v-model="form.menuType" :disabled="isEdit">
......@@ -32,7 +32,7 @@
<script>
import { addMenuApi } from '@/api';
import MenuTree from '@/components/menu_tree/index.vue';
import MenuTree from '@/components/menu_tree/select.vue';
export default {
components: { MenuTree },
......@@ -40,16 +40,12 @@ export default {
type: 0,
form: {
menuType: 'CATALOG',
parentMenuId: 0,
parentMenuId: null,
menuName: '',
},
rules: {
menuUrl: [{ required: true }],
},
checkedKeys: {
checked: [],
halfChecked: [],
},
}),
computed: {
isAdd() {
......@@ -60,12 +56,9 @@ export default {
},
},
methods: {
submit() {
return addMenuApi({ ...this.form, parentMenuId: this.checkedKeys.checked[0] ?? 0 });
},
onCheck(checkedKeys) {
const checked = checkedKeys.checked.slice(-1);
this.checkedKeys = { checked };
async submit() {
await this.$refs['form'].validate();
return addMenuApi({ ...this.form, parentMenuId: this.form.parentMenuId ?? 0 });
},
setEdit(data) {
this.type = 1;
......
<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>
<Form ref="form" />
</template>
......@@ -26,7 +26,7 @@ export default {
components: { Form, PopconfirmDelete },
data() {
return {
addBtn: { width: 400, onOk: () => this.$refs['form']?.submit() },
addBtn: { onOk: () => this.$refs['form']?.submit() },
};
},
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>
......@@ -102,6 +102,11 @@ const options = {
name: '日志管理',
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