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 @@
<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;
},
......
......@@ -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>
<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>
......@@ -95,6 +95,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