Commit 09240bbb authored by 水落(YangLei)'s avatar 水落(YangLei)

feat: 任务页面开发

parent dd8c1d90
<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>
...@@ -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;
}, },
......
...@@ -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>
<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