v2.6.6版本发布 (#1784)
* 前端支持顶部菜单栏模式 * 自动化代码单条获取方法不再需要取data.xxx直接取用data * 自动化代码支持选择索引 * 自动化代码回滚支持自行选择是否删除菜单、API、表 * 日志增加定期清理功能 * 权限配置API部分,支持根据API真实path进行筛选 * 修复了一些已知bug * 修复了一个sql注入漏洞 --------- Co-authored-by: xuedinge <781408517@qq.com> Co-authored-by: Qing Liang <106448173+xue-ding-e@users.noreply.github.com> Co-authored-by: wall-js <wall_js@foxmail.com> Co-authored-by: Wall <307606056@qq.com> Co-authored-by: leooza <leooza@163.com> Co-authored-by: piexlMax(奇淼 <qimiaojiangjizhao@gmail.com> Co-authored-by: hxl <52553624@qq.com> Co-authored-by: zsc1003 <11476303+zsc1003@user.noreply.gitee.com>
This commit is contained in:
@@ -2,29 +2,17 @@
|
||||
<div>
|
||||
<div class="gva-table-box">
|
||||
<div class="gva-btn-list">
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="plus"
|
||||
@click="goAutoCode(null)"
|
||||
>新增</el-button>
|
||||
<el-button type="primary" icon="plus" @click="goAutoCode(null)"
|
||||
>新增</el-button
|
||||
>
|
||||
</div>
|
||||
<el-table :data="tableData">
|
||||
<el-table-column
|
||||
type="selection"
|
||||
width="55"
|
||||
/>
|
||||
<el-table-column
|
||||
align="left"
|
||||
label="id"
|
||||
width="60"
|
||||
prop="ID"
|
||||
/>
|
||||
<el-table-column
|
||||
align="left"
|
||||
label="日期"
|
||||
width="180"
|
||||
>
|
||||
<template #default="scope">{{ formatDate(scope.row.CreatedAt) }}</template>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column align="left" label="id" width="60" prop="ID" />
|
||||
<el-table-column align="left" label="日期" width="180">
|
||||
<template #default="scope">{{
|
||||
formatDate(scope.row.CreatedAt)
|
||||
}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="left"
|
||||
@@ -51,53 +39,28 @@
|
||||
prop="flag"
|
||||
>
|
||||
<template #default="scope">
|
||||
<el-tag
|
||||
v-if="scope.row.flag"
|
||||
type="danger"
|
||||
|
||||
effect="dark"
|
||||
>
|
||||
<el-tag v-if="scope.row.flag" type="danger" effect="dark">
|
||||
已回滚
|
||||
</el-tag>
|
||||
<el-tag
|
||||
v-else
|
||||
|
||||
type="success"
|
||||
effect="dark"
|
||||
>
|
||||
未回滚
|
||||
</el-tag>
|
||||
<el-tag v-else type="success" effect="dark"> 未回滚 </el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="left"
|
||||
label="操作"
|
||||
min-width="240"
|
||||
>
|
||||
<el-table-column align="left" label="操作" min-width="240">
|
||||
<template #default="scope">
|
||||
<div>
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
:disabled="scope.row.flag === 1"
|
||||
@click="rollbackFunc(scope.row,true)"
|
||||
>回滚(删表)</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
:disabled="scope.row.flag === 1"
|
||||
@click="rollbackFunc(scope.row,false)"
|
||||
>回滚(不删表)</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
@click="goAutoCode(scope.row)"
|
||||
>复用</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
link
|
||||
@click="deleteRow(scope.row)"
|
||||
>删除</el-button>
|
||||
@click="openDialog(scope.row)"
|
||||
>回滚</el-button
|
||||
>
|
||||
<el-button type="primary" link @click="goAutoCode(scope.row)"
|
||||
>复用</el-button
|
||||
>
|
||||
<el-button type="primary" link @click="deleteRow(scope.row)"
|
||||
>删除</el-button
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -114,114 +77,185 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<el-dialog
|
||||
:title="dialogFormTitle"
|
||||
v-model="dialogFormVisible"
|
||||
:before-close="closeDialog"
|
||||
width="600px"
|
||||
>
|
||||
<el-form :inline="true" :model="formData" label-width="80px">
|
||||
<el-form-item label="选项:">
|
||||
<el-checkbox
|
||||
label="删除接口"
|
||||
v-model="formData.deleteApi"
|
||||
></el-checkbox>
|
||||
<el-checkbox
|
||||
label="删除菜单"
|
||||
v-model="formData.deleteMenu"
|
||||
></el-checkbox>
|
||||
<el-checkbox
|
||||
label="删除表"
|
||||
v-model="formData.deleteTable"
|
||||
@change="deleteTableCheck"
|
||||
></el-checkbox>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="closeDialog">取 消</el-button>
|
||||
<el-popconfirm
|
||||
title="此操作将回滚生成文件和勾选项目, 是否继续?"
|
||||
@confirm="enterDialog"
|
||||
>
|
||||
<template #reference>
|
||||
<el-button type="primary">确 定</el-button>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { getSysHistory, rollback, delSysHistory } from '@/api/autoCode.js'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { ref } from 'vue'
|
||||
import { formatDate } from '@/utils/format'
|
||||
import { getSysHistory, rollback, delSysHistory } from "@/api/autoCode.js";
|
||||
import { useRouter } from "vue-router";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
import { ref } from "vue";
|
||||
import { formatDate } from "@/utils/format";
|
||||
|
||||
defineOptions({
|
||||
name: 'AutoCodeAdmin'
|
||||
})
|
||||
name: "AutoCodeAdmin",
|
||||
});
|
||||
|
||||
const router = useRouter()
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
deleteApi: true,
|
||||
deleteMenu: true,
|
||||
deleteTable: false,
|
||||
});
|
||||
|
||||
const page = ref(1)
|
||||
const total = ref(0)
|
||||
const pageSize = ref(10)
|
||||
const tableData = ref([])
|
||||
const router = useRouter();
|
||||
const dialogFormVisible = ref(false);
|
||||
const dialogFormTitle = ref("");
|
||||
|
||||
const page = ref(1);
|
||||
const total = ref(0);
|
||||
const pageSize = ref(10);
|
||||
const tableData = ref([]);
|
||||
|
||||
// 分页
|
||||
const handleSizeChange = (val) => {
|
||||
pageSize.value = val
|
||||
getTableData()
|
||||
}
|
||||
pageSize.value = val;
|
||||
getTableData();
|
||||
};
|
||||
|
||||
const handleCurrentChange = (val) => {
|
||||
page.value = val
|
||||
getTableData()
|
||||
}
|
||||
page.value = val;
|
||||
getTableData();
|
||||
};
|
||||
|
||||
// 查询
|
||||
const getTableData = async() => {
|
||||
const getTableData = async () => {
|
||||
const table = await getSysHistory({
|
||||
page: page.value,
|
||||
pageSize: pageSize.value
|
||||
})
|
||||
pageSize: pageSize.value,
|
||||
});
|
||||
if (table.code === 0) {
|
||||
tableData.value = table.data.list
|
||||
total.value = table.data.total
|
||||
page.value = table.data.page
|
||||
pageSize.value = table.data.pageSize
|
||||
tableData.value = table.data.list;
|
||||
total.value = table.data.total;
|
||||
page.value = table.data.page;
|
||||
pageSize.value = table.data.pageSize;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
getTableData()
|
||||
getTableData();
|
||||
|
||||
const deleteRow = async(row) => {
|
||||
ElMessageBox.confirm('此操作将删除本历史, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async() => {
|
||||
const res = await delSysHistory({ id: Number(row.ID) })
|
||||
const deleteRow = async (row) => {
|
||||
ElMessageBox.confirm("此操作将删除本历史, 是否继续?", "提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}).then(async () => {
|
||||
const res = await delSysHistory({ id: Number(row.ID) });
|
||||
if (res.code === 0) {
|
||||
ElMessage.success('删除成功')
|
||||
getTableData()
|
||||
ElMessage.success("删除成功");
|
||||
getTableData();
|
||||
}
|
||||
})
|
||||
}
|
||||
const rollbackFunc = async(row, flag) => {
|
||||
});
|
||||
};
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (row) => {
|
||||
dialogFormTitle.value = "回滚:" + row.structName;
|
||||
formData.value.id = row.ID;
|
||||
dialogFormVisible.value = true;
|
||||
};
|
||||
|
||||
// 关闭弹窗
|
||||
const closeDialog = () => {
|
||||
dialogFormVisible.value = false;
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
deleteApi: true,
|
||||
deleteMenu: true,
|
||||
deleteTable: false,
|
||||
};
|
||||
};
|
||||
|
||||
// 确认删除表
|
||||
const deleteTableCheck = (flag) => {
|
||||
if (flag) {
|
||||
ElMessageBox.confirm(`此操作将删除自动创建的文件和api(会删除表!!!), 是否继续?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async() => {
|
||||
ElMessageBox.confirm(`此操作将删除自动创建的文件和api(会删除表!!!), 请继续确认!!!`, '会删除表', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async() => {
|
||||
ElMessageBox.confirm(`此操作将删除自动创建的文件和api(会删除表!!!), 请继续确认!!!`, '会删除表', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async() => {
|
||||
const res = await rollback({ id: Number(row.ID), deleteTable: flag })
|
||||
if (res.code === 0) {
|
||||
ElMessage.success('回滚成功')
|
||||
getTableData()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
} else {
|
||||
ElMessageBox.confirm(`此操作将删除自动创建的文件和api, 是否继续?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(async() => {
|
||||
const res = await rollback({ id: Number(row.ID), deleteTable: flag })
|
||||
if (res.code === 0) {
|
||||
ElMessage.success('回滚成功')
|
||||
getTableData()
|
||||
ElMessageBox.confirm(
|
||||
`此操作将删除自动创建的文件和api(会删除表!!!), 是否继续?`,
|
||||
"提示",
|
||||
{
|
||||
closeOnClickModal: false,
|
||||
distinguishCancelAndClose: true,
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}
|
||||
})
|
||||
)
|
||||
.then(() => {
|
||||
ElMessageBox.confirm(
|
||||
`此操作将删除自动创建的文件和api(会删除表!!!), 请继续确认!!!`,
|
||||
"会删除表",
|
||||
{
|
||||
closeOnClickModal: false,
|
||||
distinguishCancelAndClose: true,
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}
|
||||
).catch(() => {
|
||||
formData.value.deleteTable = false;
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
formData.value.deleteTable = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const enterDialog = async () => {
|
||||
const res = await rollback(formData.value);
|
||||
if (res.code === 0) {
|
||||
ElMessage.success("回滚成功");
|
||||
getTableData();
|
||||
}
|
||||
};
|
||||
|
||||
const goAutoCode = (row) => {
|
||||
if (row) {
|
||||
router.push({ name: 'autoCodeEdit', params: {
|
||||
id: row.ID
|
||||
}})
|
||||
router.push({
|
||||
name: "autoCodeEdit",
|
||||
params: {
|
||||
id: row.ID,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
router.push({ name: 'autoCode' })
|
||||
router.push({ name: "autoCode" });
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user