mirror of
https://github.com/TangSengDaoDao/TangSengDaoDaoManager
synced 2025-06-03 23:58:10 +00:00
refactor: 🎨代码优化
This commit is contained in:
parent
1bad94bb0b
commit
822ba93ae6
@ -1,36 +0,0 @@
|
|||||||
import request from '@/utils/axios';
|
|
||||||
|
|
||||||
// 获取口令列表
|
|
||||||
export function commandGet(params?: any) {
|
|
||||||
return request({
|
|
||||||
url: '/manager/web3/laboratory',
|
|
||||||
method: 'get',
|
|
||||||
params
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 新增口令
|
|
||||||
export function commandPost(data: any) {
|
|
||||||
return request({
|
|
||||||
url: '/manager/web3/laboratory',
|
|
||||||
method: 'post',
|
|
||||||
data
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 编辑口令
|
|
||||||
export function commandPut(data: any, id: string) {
|
|
||||||
return request({
|
|
||||||
url: `/manager/web3/laboratory/${id}`,
|
|
||||||
method: 'put',
|
|
||||||
data
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除口令
|
|
||||||
export function commandDelete(id: string) {
|
|
||||||
return request({
|
|
||||||
url: `/manager/web3/laboratory/${id}`,
|
|
||||||
method: 'delete'
|
|
||||||
});
|
|
||||||
}
|
|
@ -17,12 +17,3 @@ export function commonAppversionPost(data: any) {
|
|||||||
data
|
data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 系统机器人菜单列表
|
|
||||||
export function robotMenusGet(params: any) {
|
|
||||||
return request({
|
|
||||||
url: '/manager/robot/menus',
|
|
||||||
method: 'get',
|
|
||||||
params
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
@ -26,34 +26,6 @@ const home: Menu.MenuOptions = {
|
|||||||
isLink: '',
|
isLink: '',
|
||||||
title: 'APP升级'
|
title: 'APP升级'
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
component: '/tool/command',
|
|
||||||
name: 'toolCommand',
|
|
||||||
path: '/tool/command',
|
|
||||||
meta: {
|
|
||||||
icon: 'i-bd-command',
|
|
||||||
isAffix: false,
|
|
||||||
isFull: false,
|
|
||||||
isHide: false,
|
|
||||||
isKeepAlive: true,
|
|
||||||
isLink: '',
|
|
||||||
title: '口令管理'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
component: '/tool/systemrobotmenu',
|
|
||||||
name: 'toolSystemrobotmenu',
|
|
||||||
path: '/tool/systemrobotmenu',
|
|
||||||
meta: {
|
|
||||||
icon: 'i-bd-application-two',
|
|
||||||
isAffix: false,
|
|
||||||
isFull: false,
|
|
||||||
isHide: true,
|
|
||||||
isKeepAlive: true,
|
|
||||||
isLink: '',
|
|
||||||
title: '系统机器人菜单列表'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
@ -1,146 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-dialog
|
|
||||||
:model-value="value"
|
|
||||||
:width="600"
|
|
||||||
:align-center="true"
|
|
||||||
:close-on-click-modal="false"
|
|
||||||
:close-on-press-escape="false"
|
|
||||||
:draggable="true"
|
|
||||||
:z-index="99"
|
|
||||||
:title="title"
|
|
||||||
@close="onClose"
|
|
||||||
>
|
|
||||||
<el-form :model="formData" label-width="96px">
|
|
||||||
<el-form-item label="口令">
|
|
||||||
<el-input v-model="formData.short_url" placeholder="请输入口令" />
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item label="地址">
|
|
||||||
<el-input v-model="formData.url" placeholder="请输入地址" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<el-space>
|
|
||||||
<el-button @click="onClose">取消</el-button>
|
|
||||||
<el-button type="primary" :loading="loaging" @click="onConfirm">保存</el-button>
|
|
||||||
</el-space>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" name="CommandDialog" setup>
|
|
||||||
import { ref } from 'vue';
|
|
||||||
import { ElMessage } from 'element-plus';
|
|
||||||
// API 接口
|
|
||||||
import { commandPost, commandPut } from '@/api/command';
|
|
||||||
|
|
||||||
interface IProps {
|
|
||||||
value: boolean;
|
|
||||||
title: string;
|
|
||||||
type: 'add' | 'edit';
|
|
||||||
data: object;
|
|
||||||
}
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<IProps>(), {
|
|
||||||
value: false,
|
|
||||||
title: '新增口令',
|
|
||||||
type: 'add'
|
|
||||||
});
|
|
||||||
|
|
||||||
const content = ref('');
|
|
||||||
const loaging = ref<boolean>(false);
|
|
||||||
const formData = ref({
|
|
||||||
short_url: '',
|
|
||||||
url: ''
|
|
||||||
});
|
|
||||||
|
|
||||||
const emits = defineEmits<{
|
|
||||||
(e: 'update:value', item: boolean): void;
|
|
||||||
(e: 'ok', item: any): void;
|
|
||||||
}>();
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.value,
|
|
||||||
(n, _o) => {
|
|
||||||
if (n && props.type === 'edit') {
|
|
||||||
formData.value = props.data as any;
|
|
||||||
}
|
|
||||||
if (!n) {
|
|
||||||
formData.value = {
|
|
||||||
short_url: '',
|
|
||||||
url: ''
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// 取消
|
|
||||||
const onClose = () => {
|
|
||||||
emits('update:value', false);
|
|
||||||
};
|
|
||||||
|
|
||||||
// 新增口令
|
|
||||||
const addBanner = () => {
|
|
||||||
loaging.value = true;
|
|
||||||
commandPost(formData.value)
|
|
||||||
.then((res: any) => {
|
|
||||||
loaging.value = false;
|
|
||||||
if (res.status == 200) {
|
|
||||||
ElMessage.success('新增成功!');
|
|
||||||
content.value = '';
|
|
||||||
onClose();
|
|
||||||
emits('ok', true);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
loaging.value = false;
|
|
||||||
if (err.status == 400) {
|
|
||||||
ElMessage.error(err.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 编辑口令
|
|
||||||
const editBanner = () => {
|
|
||||||
loaging.value = true;
|
|
||||||
commandPut(formData.value, (props.data as any).id)
|
|
||||||
.then((res: any) => {
|
|
||||||
loaging.value = false;
|
|
||||||
if (res.status == 200) {
|
|
||||||
ElMessage.success('编辑成功!');
|
|
||||||
content.value = '';
|
|
||||||
onClose();
|
|
||||||
emits('ok', true);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
loaging.value = false;
|
|
||||||
if (err.status == 400) {
|
|
||||||
ElMessage.error(err.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
// 保存
|
|
||||||
const onConfirm = () => {
|
|
||||||
if (props.type === 'add') {
|
|
||||||
addBanner();
|
|
||||||
}
|
|
||||||
if (props.type === 'edit') {
|
|
||||||
editBanner();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.bd-uplod {
|
|
||||||
::v-deep(.el-upload--picture-card) {
|
|
||||||
height: 78px;
|
|
||||||
width: 78px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar {
|
|
||||||
height: 78px;
|
|
||||||
width: 78px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
@ -1,220 +0,0 @@
|
|||||||
<template>
|
|
||||||
<bd-page class="flex-col">
|
|
||||||
<div class="flex-1 el-card border-none flex-col box-border overflow-hidden">
|
|
||||||
<div class="h-50px pl-12px pr-12px box-border flex items-center justify-between bd-title">
|
|
||||||
<div class="bd-title-left">
|
|
||||||
<p class="m-0 font-600">口令管理</p>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center h-50px">
|
|
||||||
<el-form inline>
|
|
||||||
<el-form-item class="mb-0 !mr-16px">
|
|
||||||
<el-input v-model="queryFrom.keyword" placeholder="名称" clearable />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item class="mb-0 !mr-16px">
|
|
||||||
<el-button type="primary" @click="getTableList">查询</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item class="mb-0 !mr-0">
|
|
||||||
<el-button type="primary" @click="onCommandAddClick">新增口令</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex-1 overflow-hidden p-12px">
|
|
||||||
<el-table v-loading="loadTable" :data="tableData" :border="true" style="width: 100%; height: 100%">
|
|
||||||
<el-table-column type="index" :width="42" :align="'center'" :fixed="'left'">
|
|
||||||
<template #header>
|
|
||||||
<i-bd-drag class="cursor-pointer" size="16" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column v-for="item in column" v-bind="item" :key="item.prop">
|
|
||||||
<template #default="scope">
|
|
||||||
<template v-if="item.render">
|
|
||||||
<component :is="item.render" :row="scope.row"> </component>
|
|
||||||
</template>
|
|
||||||
<template v-else-if="item.formatter">
|
|
||||||
<slot :name="item.prop" :row="scope.row">{{ item.formatter(scope.row) }}</slot>
|
|
||||||
</template>
|
|
||||||
<template v-else-if="item.prop">
|
|
||||||
<slot :name="item.prop" :row="scope.row">{{ scope.row[item.prop!] }}</slot>
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</div>
|
|
||||||
<div class="bd-card-footer pl-12px pr-12px mb-12px flex items-center justify-between">
|
|
||||||
<div></div>
|
|
||||||
<el-pagination
|
|
||||||
v-model:current-page="queryFrom.page_index"
|
|
||||||
v-model:page-size="queryFrom.page_size"
|
|
||||||
:page-sizes="[15, 20, 30, 50, 100]"
|
|
||||||
:background="true"
|
|
||||||
layout="total, sizes, prev, pager, next, jumper"
|
|
||||||
:total="total"
|
|
||||||
@size-change="onSizeChange"
|
|
||||||
@current-change="onCurrentChange"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- 口令操作 -->
|
|
||||||
<CommandDialog
|
|
||||||
v-model:value="commandDialogValue"
|
|
||||||
:title="commandDialogTitle"
|
|
||||||
:type="commandDialogType"
|
|
||||||
:data="commandDialogData"
|
|
||||||
@ok="onCommandOk"
|
|
||||||
/>
|
|
||||||
</bd-page>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<route lang="yaml">
|
|
||||||
meta:
|
|
||||||
title: 口令管理
|
|
||||||
isAffix: false
|
|
||||||
</route>
|
|
||||||
|
|
||||||
<script lang="tsx" name="command" setup>
|
|
||||||
import { ElButton, ElSpace, ElMessage, ElMessageBox } from 'element-plus';
|
|
||||||
import CommandDialog from './components/CommandDialog.vue';
|
|
||||||
|
|
||||||
// API接口
|
|
||||||
import { commandGet, commandDelete } from '@/api/command';
|
|
||||||
/**
|
|
||||||
* 表格
|
|
||||||
*/
|
|
||||||
const column = reactive<Column.ColumnOptions[]>([
|
|
||||||
{
|
|
||||||
prop: 'short_url',
|
|
||||||
label: '口令名称'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
prop: 'url',
|
|
||||||
label: '地址'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
prop: 'create_at',
|
|
||||||
label: '创建时间'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
prop: 'operation',
|
|
||||||
label: '操作',
|
|
||||||
width: 150,
|
|
||||||
align: 'center',
|
|
||||||
render: (scope: any) => {
|
|
||||||
return (
|
|
||||||
<ElSpace>
|
|
||||||
<ElButton type="primary" onClick={() => onCommandEidt(scope.row)}>
|
|
||||||
编辑
|
|
||||||
</ElButton>
|
|
||||||
<ElButton type="danger" onClick={() => onCommandDel(scope.row)}>
|
|
||||||
删除
|
|
||||||
</ElButton>
|
|
||||||
</ElSpace>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
const tableData = ref<any[]>([]);
|
|
||||||
const loadTable = ref<boolean>(false);
|
|
||||||
// 分页
|
|
||||||
const total = ref(0);
|
|
||||||
|
|
||||||
// 查询
|
|
||||||
const queryFrom = reactive({
|
|
||||||
keyword: '',
|
|
||||||
page_size: 15,
|
|
||||||
page_index: 1
|
|
||||||
});
|
|
||||||
|
|
||||||
// 搜索
|
|
||||||
const getTableList = () => {
|
|
||||||
loadTable.value = true;
|
|
||||||
commandGet(queryFrom)
|
|
||||||
.then((res: any) => {
|
|
||||||
loadTable.value = false;
|
|
||||||
tableData.value = res.list;
|
|
||||||
total.value = res.count;
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
loadTable.value = false;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 分页page-size
|
|
||||||
const onSizeChange = (size: number) => {
|
|
||||||
queryFrom.page_size = size;
|
|
||||||
getTableList();
|
|
||||||
};
|
|
||||||
|
|
||||||
// 分页page-size
|
|
||||||
const onCurrentChange = (current: number) => {
|
|
||||||
queryFrom.page_index = current;
|
|
||||||
getTableList();
|
|
||||||
};
|
|
||||||
|
|
||||||
// 新增口令
|
|
||||||
const commandDialogValue = ref(false);
|
|
||||||
const commandDialogTitle = ref('新增口令');
|
|
||||||
const commandDialogType = ref<'add' | 'edit'>('add');
|
|
||||||
const onCommandAddClick = () => {
|
|
||||||
commandDialogTitle.value = '新增口令';
|
|
||||||
commandDialogType.value = 'add';
|
|
||||||
commandDialogValue.value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 编辑口令
|
|
||||||
const commandDialogData = ref({});
|
|
||||||
const onCommandEidt = (item: any) => {
|
|
||||||
commandDialogTitle.value = `编辑${item.short_url}`;
|
|
||||||
commandDialogData.value = item;
|
|
||||||
commandDialogType.value = 'edit';
|
|
||||||
commandDialogValue.value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 保存口令
|
|
||||||
const onCommandOk = () => {
|
|
||||||
getTableList();
|
|
||||||
};
|
|
||||||
|
|
||||||
// 删除口令
|
|
||||||
const onCommandDel = (item: any) => {
|
|
||||||
ElMessageBox.confirm(`确定要对该口令吗?`, `操作提示`, {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
closeOnClickModal: false,
|
|
||||||
type: 'warning'
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
commandDelete(item.id)
|
|
||||||
.then((_res: any) => {
|
|
||||||
getTableList();
|
|
||||||
ElMessage({
|
|
||||||
type: 'success',
|
|
||||||
message: `口令删除成功!`
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
if (err.status == 400) {
|
|
||||||
ElMessage.error(err.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
ElMessage({
|
|
||||||
type: 'info',
|
|
||||||
message: '取消成功!'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
getTableList();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
// 样式
|
|
||||||
.bd-title {
|
|
||||||
border-bottom: 1px solid var(--el-card-border-color);
|
|
||||||
}
|
|
||||||
</style>
|
|
@ -1,141 +0,0 @@
|
|||||||
<template>
|
|
||||||
<bd-page class="flex-col">
|
|
||||||
<!-- 布局 -->
|
|
||||||
<div class="flex-1 el-card border-none flex-col box-border overflow-hidden">
|
|
||||||
<div class="h-50px pl-12px pr-12px box-border flex items-center justify-between bd-title">
|
|
||||||
<div class="bd-title-left">
|
|
||||||
<p class="m-0 font-600">系统机器人菜单列表</p>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center h-50px"></div>
|
|
||||||
</div>
|
|
||||||
<div class="flex-1 overflow-hidden p-12px">
|
|
||||||
<el-table v-loading="loadTable" :data="tableData" :border="true" style="width: 100%; height: 100%">
|
|
||||||
<el-table-column type="index" :width="42" :align="'center'" :fixed="'left'">
|
|
||||||
<template #header>
|
|
||||||
<i-bd-setting class="cursor-pointer" size="16" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column v-for="item in column" v-bind="item" :key="item.prop">
|
|
||||||
<template #default="scope">
|
|
||||||
<template v-if="item.render">
|
|
||||||
<component :is="item.render" :row="scope.row"> </component>
|
|
||||||
</template>
|
|
||||||
<template v-else-if="item.formatter">
|
|
||||||
<slot :name="item.prop" :row="scope.row">{{ item.formatter(scope.row) }}</slot>
|
|
||||||
</template>
|
|
||||||
<template v-else-if="item.prop">
|
|
||||||
<slot :name="item.prop" :row="scope.row">{{ scope.row[item.prop!] }}</slot>
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</bd-page>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<route lang="yaml">
|
|
||||||
meta:
|
|
||||||
title: 系统机器人菜单列表
|
|
||||||
isAffix: false
|
|
||||||
</route>
|
|
||||||
|
|
||||||
<script lang="tsx" setup>
|
|
||||||
import { ElSpace, ElButton, ElTag, ElText } from 'element-plus';
|
|
||||||
// API 接口
|
|
||||||
import { robotMenusGet } from '@/api/tool';
|
|
||||||
/**
|
|
||||||
* 表格
|
|
||||||
*/
|
|
||||||
const column = reactive<Column.ColumnOptions[]>([
|
|
||||||
{
|
|
||||||
prop: 'cmd',
|
|
||||||
label: '命令',
|
|
||||||
width: 140,
|
|
||||||
render: (scope: any) => {
|
|
||||||
return (
|
|
||||||
<ElText type="primary" class={'cursor-pointer'}>
|
|
||||||
{scope.row['cmd']}
|
|
||||||
</ElText>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
prop: 'robot_id',
|
|
||||||
label: '机器人ID',
|
|
||||||
width: 140
|
|
||||||
},
|
|
||||||
{
|
|
||||||
prop: 'remark',
|
|
||||||
label: '说明'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
prop: 'type',
|
|
||||||
label: '类型',
|
|
||||||
align: 'center',
|
|
||||||
width: 80,
|
|
||||||
render: (scope: any) => {
|
|
||||||
return <ElTag>{scope.row['type']}</ElTag>;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
prop: 'created_at',
|
|
||||||
label: '创建时间',
|
|
||||||
width: 170
|
|
||||||
},
|
|
||||||
{
|
|
||||||
prop: 'updated_at',
|
|
||||||
label: '更新时间',
|
|
||||||
width: 170
|
|
||||||
},
|
|
||||||
{
|
|
||||||
prop: 'operation',
|
|
||||||
label: '操作',
|
|
||||||
align: 'center',
|
|
||||||
fixed: 'right',
|
|
||||||
width: 120,
|
|
||||||
render: (scope: any) => {
|
|
||||||
return (
|
|
||||||
<ElSpace>
|
|
||||||
<ElButton type="danger" onClick={() => aa(scope.row)}>
|
|
||||||
删除
|
|
||||||
</ElButton>
|
|
||||||
</ElSpace>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
const tableData = ref<any[]>([]);
|
|
||||||
const loadTable = ref<boolean>(false);
|
|
||||||
|
|
||||||
// 查询
|
|
||||||
const queryFrom = reactive({
|
|
||||||
robot_id: 'u_10000',
|
|
||||||
page_size: 15,
|
|
||||||
page_index: 1
|
|
||||||
});
|
|
||||||
|
|
||||||
const getTableList = () => {
|
|
||||||
loadTable.value = true;
|
|
||||||
robotMenusGet(queryFrom).then((res: any) => {
|
|
||||||
loadTable.value = false;
|
|
||||||
tableData.value = res;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const aa = (a: any) => {
|
|
||||||
console.log(a);
|
|
||||||
};
|
|
||||||
|
|
||||||
// 初始化
|
|
||||||
onMounted(() => {
|
|
||||||
getTableList();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
// 样式
|
|
||||||
.bd-title {
|
|
||||||
border-bottom: 1px solid var(--el-card-border-color);
|
|
||||||
}
|
|
||||||
</style>
|
|
Loading…
x
Reference in New Issue
Block a user