add. crontab dev
This commit is contained in:
parent
97a04523e0
commit
a7f605d524
@ -16,12 +16,12 @@
|
|||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</ele-card>
|
</ele-card>
|
||||||
<crontab-list v-if="type == 'list'" />
|
<task-list v-if="type == 'task'" />
|
||||||
</ele-page>
|
</ele-page>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import CrontabList from './list/index.vue';
|
import TaskList from './task/index.vue';
|
||||||
|
|
||||||
const type = ref('list');
|
const type = ref('task');
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -1,148 +0,0 @@
|
|||||||
<!-- 角色权限分配弹窗 -->
|
|
||||||
<template>
|
|
||||||
<ele-modal
|
|
||||||
:width="460"
|
|
||||||
title="分配权限"
|
|
||||||
position="center"
|
|
||||||
v-model="visible"
|
|
||||||
:body-style="{ padding: '12px 0 12px 22px' }"
|
|
||||||
@open="handleOpen"
|
|
||||||
>
|
|
||||||
<ele-loading
|
|
||||||
:loading="authLoading"
|
|
||||||
:spinner-style="{ background: 'transparent' }"
|
|
||||||
:style="{
|
|
||||||
paddingRight: '20px',
|
|
||||||
height: 'calc(100vh - 192px)',
|
|
||||||
maxHeight: 'calc(100dvh - 192px)',
|
|
||||||
minHeight: '100px',
|
|
||||||
overflow: 'auto'
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<el-tree
|
|
||||||
ref="treeRef"
|
|
||||||
show-checkbox
|
|
||||||
:data="authData"
|
|
||||||
node-key="menuId"
|
|
||||||
:default-expand-all="true"
|
|
||||||
:props="{ label: 'title' }"
|
|
||||||
:default-checked-keys="checkedKeys"
|
|
||||||
:style="{ '--ele-tree-item-height': '28px' }"
|
|
||||||
>
|
|
||||||
<template #default="scope">
|
|
||||||
<div>
|
|
||||||
<el-icon
|
|
||||||
v-if="scope.data.icon"
|
|
||||||
:size="16"
|
|
||||||
style="margin-right: 6px; vertical-align: -5px"
|
|
||||||
>
|
|
||||||
<component :is="scope.data.icon" />
|
|
||||||
</el-icon>
|
|
||||||
<span style="vertical-align: -2px">{{ scope.data.title }}</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</el-tree>
|
|
||||||
</ele-loading>
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="handleCancel">取消</el-button>
|
|
||||||
<el-button type="primary" :loading="loading" @click="save">
|
|
||||||
保存
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</ele-modal>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { ref, nextTick } from 'vue';
|
|
||||||
import type { ElTree } from 'element-plus';
|
|
||||||
import { EleMessage, toTree, eachTree } from 'ele-admin-plus';
|
|
||||||
import { listRoleMenus, updateRoleMenus } from '@/api/system/role';
|
|
||||||
import type { Role } from '@/api/system/role/model';
|
|
||||||
import type { Menu } from '@/api/system/menu/model';
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
/** 当前角色数据 */
|
|
||||||
data?: Role | null;
|
|
||||||
}>();
|
|
||||||
|
|
||||||
/** 弹窗是否打开 */
|
|
||||||
const visible = defineModel({ type: Boolean });
|
|
||||||
|
|
||||||
/** 树组件实例 */
|
|
||||||
const treeRef = ref<InstanceType<typeof ElTree> | null>(null);
|
|
||||||
|
|
||||||
/** 权限数据 */
|
|
||||||
const authData = ref<Menu[]>([]);
|
|
||||||
|
|
||||||
/** 权限数据请求状态 */
|
|
||||||
const authLoading = ref(false);
|
|
||||||
|
|
||||||
/** 提交状态 */
|
|
||||||
const loading = ref(false);
|
|
||||||
|
|
||||||
/** 角色权限选中的keys */
|
|
||||||
const checkedKeys = ref<number[]>([]);
|
|
||||||
|
|
||||||
/** 查询权限数据 */
|
|
||||||
const query = () => {
|
|
||||||
authData.value = [];
|
|
||||||
checkedKeys.value = [];
|
|
||||||
if (!props.data) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
authLoading.value = true;
|
|
||||||
listRoleMenus(props.data.roleId)
|
|
||||||
.then((data) => {
|
|
||||||
authLoading.value = false;
|
|
||||||
// 转成树形结构的数据
|
|
||||||
authData.value = toTree({
|
|
||||||
data: data,
|
|
||||||
idField: 'menuId',
|
|
||||||
parentIdField: 'parentId'
|
|
||||||
});
|
|
||||||
// 回显选中的数据
|
|
||||||
nextTick(() => {
|
|
||||||
const cks: number[] = [];
|
|
||||||
eachTree(authData.value, (d) => {
|
|
||||||
if (d.menuId && d.checked && !d.children?.length) {
|
|
||||||
cks.push(d.menuId);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
checkedKeys.value = cks;
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
authLoading.value = false;
|
|
||||||
EleMessage.error({ message: e.message, plain: true });
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/** 关闭弹窗 */
|
|
||||||
const handleCancel = () => {
|
|
||||||
visible.value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** 保存权限分配 */
|
|
||||||
const save = () => {
|
|
||||||
loading.value = true;
|
|
||||||
const ids =
|
|
||||||
(treeRef.value?.getCheckedKeys?.() ?? []).concat(
|
|
||||||
treeRef.value?.getHalfCheckedKeys?.() ?? []
|
|
||||||
) ?? [];
|
|
||||||
updateRoleMenus(props.data?.roleId, ids as unknown as number[])
|
|
||||||
.then((msg) => {
|
|
||||||
loading.value = false;
|
|
||||||
EleMessage.success({ message: msg, plain: true });
|
|
||||||
handleCancel();
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
loading.value = false;
|
|
||||||
EleMessage.error({ message: e.message, plain: true });
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/** 弹窗打开事件 */
|
|
||||||
const handleOpen = () => {
|
|
||||||
query();
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
@ -8,21 +8,8 @@
|
|||||||
>
|
>
|
||||||
<el-row :gutter="8">
|
<el-row :gutter="8">
|
||||||
<el-col :lg="6" :md="8" :sm="12" :xs="24">
|
<el-col :lg="6" :md="8" :sm="12" :xs="24">
|
||||||
<el-form-item label="角色名称">
|
<el-form-item label="任务名称">
|
||||||
<el-input
|
<el-input clearable v-model.trim="form.name" placeholder="请输入" />
|
||||||
clearable
|
|
||||||
v-model.trim="form.roleName"
|
|
||||||
placeholder="请输入"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :lg="6" :md="8" :sm="12" :xs="24">
|
|
||||||
<el-form-item label="角色标识">
|
|
||||||
<el-input
|
|
||||||
clearable
|
|
||||||
v-model.trim="form.roleCode"
|
|
||||||
placeholder="请输入"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :lg="12" :md="8" :sm="24" :xs="24">
|
<el-col :lg="12" :md="8" :sm="24" :xs="24">
|
||||||
@ -38,17 +25,14 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useFormData } from '@/utils/use-form-data';
|
import { useFormData } from '@/utils/use-form-data';
|
||||||
import type { RoleParam } from '@/api/system/role/model';
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'search', where?: RoleParam): void;
|
(e: 'search', where?: any): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
/** 表单数据 */
|
/** 表单数据 */
|
||||||
const [form, resetFields] = useFormData<RoleParam>({
|
const [form, resetFields] = useFormData<any>({
|
||||||
roleName: '',
|
name: ''
|
||||||
roleCode: '',
|
|
||||||
comments: ''
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 搜索 */
|
/** 搜索 */
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- 搜索表单 -->
|
<!-- 搜索表单 -->
|
||||||
<role-search @search="reload" />
|
<task-search @search="reload" />
|
||||||
<ele-card :body-style="{ paddingTop: '8px' }">
|
<ele-card :body-style="{ paddingTop: '8px' }">
|
||||||
<!-- 表格 -->
|
<!-- 表格 -->
|
||||||
<ele-pro-table
|
<ele-pro-table
|
||||||
@ -22,14 +22,6 @@
|
|||||||
>
|
>
|
||||||
添加
|
添加
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
|
||||||
type="danger"
|
|
||||||
class="ele-btn-icon"
|
|
||||||
:icon="DeleteOutlined"
|
|
||||||
@click="remove()"
|
|
||||||
>
|
|
||||||
删除
|
|
||||||
</el-button>
|
|
||||||
</template>
|
</template>
|
||||||
<template #action="{ row }">
|
<template #action="{ row }">
|
||||||
<el-link type="primary" underline="never" @click="openEdit(row)">
|
<el-link type="primary" underline="never" @click="openEdit(row)">
|
||||||
@ -51,7 +43,7 @@
|
|||||||
</ele-pro-table>
|
</ele-pro-table>
|
||||||
</ele-card>
|
</ele-card>
|
||||||
<!-- 编辑弹窗 -->
|
<!-- 编辑弹窗 -->
|
||||||
<role-edit v-model="showEdit" :data="current" @done="reload" />
|
<task-edit v-model="showEdit" :data="current" @done="reload" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
@ -63,9 +55,9 @@
|
|||||||
DatasourceFunction,
|
DatasourceFunction,
|
||||||
Columns
|
Columns
|
||||||
} from 'ele-admin-plus/es/ele-pro-table/types';
|
} from 'ele-admin-plus/es/ele-pro-table/types';
|
||||||
import { PlusOutlined, DeleteOutlined } from '@/components/icons';
|
import { PlusOutlined } from '@/components/icons';
|
||||||
import RoleSearch from './components/role-search.vue';
|
import TaskSearch from './components/task-search.vue';
|
||||||
import RoleEdit from './components/role-edit.vue';
|
import TaskEdit from './components/task-edit.vue';
|
||||||
import { removeRoles } from '@/api/system/role';
|
import { removeRoles } from '@/api/system/role';
|
||||||
import type { Role, RoleParam } from '@/api/system/role/model';
|
import type { Role, RoleParam } from '@/api/system/role/model';
|
||||||
import { pageCrontab } from '@/api/system/dev-crontab';
|
import { pageCrontab } from '@/api/system/dev-crontab';
|
||||||
@ -91,21 +83,33 @@
|
|||||||
align: 'center'
|
align: 'center'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'roleName',
|
prop: 'name',
|
||||||
label: '角色名称',
|
label: '任务名称',
|
||||||
sortable: 'custom',
|
|
||||||
minWidth: 120
|
minWidth: 120
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'roleCode',
|
prop: 'command',
|
||||||
label: '角色标识',
|
label: '命令内容',
|
||||||
sortable: 'custom',
|
|
||||||
minWidth: 120
|
minWidth: 120
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'comments',
|
prop: 'remark',
|
||||||
label: '备注',
|
label: '备注',
|
||||||
sortable: 'custom',
|
minWidth: 140
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'status',
|
||||||
|
label: '状态',
|
||||||
|
minWidth: 140
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'expression',
|
||||||
|
label: '执行周期',
|
||||||
|
minWidth: 140
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'last_time',
|
||||||
|
label: '上次执行时间',
|
||||||
minWidth: 140
|
minWidth: 140
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Loading…
Reference in New Issue
Block a user