2021-07-13 19:45:21 +08:00
|
|
|
|
<template>
|
|
|
|
|
<div>
|
2021-09-18 00:10:17 +08:00
|
|
|
|
<div class="gva-table-box">
|
2021-09-14 19:49:06 +08:00
|
|
|
|
<div class="gva-btn-list">
|
2024-07-25 21:29:20 +08:00
|
|
|
|
<el-button type="primary" icon="plus" @click="goAutoCode(null)">
|
|
|
|
|
新增
|
|
|
|
|
</el-button>
|
2021-09-14 19:49:06 +08:00
|
|
|
|
</div>
|
2021-09-18 00:10:17 +08:00
|
|
|
|
<el-table :data="tableData">
|
2024-06-16 00:27:40 +08:00
|
|
|
|
<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">
|
2024-07-25 21:29:20 +08:00
|
|
|
|
<template #default="scope">
|
|
|
|
|
{{
|
|
|
|
|
formatDate(scope.row.CreatedAt)
|
|
|
|
|
}}
|
|
|
|
|
</template>
|
2021-09-18 00:10:17 +08:00
|
|
|
|
</el-table-column>
|
2023-09-14 18:47:47 +08:00
|
|
|
|
<el-table-column
|
|
|
|
|
align="left"
|
|
|
|
|
label="结构体名"
|
|
|
|
|
min-width="150"
|
|
|
|
|
prop="structName"
|
|
|
|
|
/>
|
|
|
|
|
<el-table-column
|
|
|
|
|
align="left"
|
|
|
|
|
label="结构体描述"
|
|
|
|
|
min-width="150"
|
|
|
|
|
prop="structCNName"
|
|
|
|
|
/>
|
|
|
|
|
<el-table-column
|
|
|
|
|
align="left"
|
|
|
|
|
label="表名称"
|
|
|
|
|
min-width="150"
|
|
|
|
|
prop="tableName"
|
|
|
|
|
/>
|
|
|
|
|
<el-table-column
|
|
|
|
|
align="left"
|
|
|
|
|
label="回滚标记"
|
|
|
|
|
min-width="150"
|
|
|
|
|
prop="flag"
|
|
|
|
|
>
|
2021-09-18 00:10:17 +08:00
|
|
|
|
<template #default="scope">
|
2024-06-16 00:27:40 +08:00
|
|
|
|
<el-tag v-if="scope.row.flag" type="danger" effect="dark">
|
2021-09-18 00:10:17 +08:00
|
|
|
|
已回滚
|
|
|
|
|
</el-tag>
|
2024-07-25 21:29:20 +08:00
|
|
|
|
<el-tag v-else type="success" effect="dark">
|
|
|
|
|
未回滚
|
|
|
|
|
</el-tag>
|
2021-09-18 00:10:17 +08:00
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
2024-06-16 00:27:40 +08:00
|
|
|
|
<el-table-column align="left" label="操作" min-width="240">
|
2021-09-18 00:10:17 +08:00
|
|
|
|
<template #default="scope">
|
|
|
|
|
<div>
|
2023-09-14 18:47:47 +08:00
|
|
|
|
<el-button
|
|
|
|
|
type="primary"
|
|
|
|
|
link
|
|
|
|
|
:disabled="scope.row.flag === 1"
|
2024-07-25 21:29:20 +08:00
|
|
|
|
@click="addFuncBtn(scope.row)"
|
2024-06-16 00:27:40 +08:00
|
|
|
|
>
|
2024-07-25 21:29:20 +08:00
|
|
|
|
增加方法
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
type="primary"
|
|
|
|
|
link
|
|
|
|
|
:disabled="scope.row.flag === 1"
|
|
|
|
|
@click="openDialog(scope.row)"
|
2024-06-16 00:27:40 +08:00
|
|
|
|
>
|
2024-07-25 21:29:20 +08:00
|
|
|
|
回滚
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button type="primary" link @click="goAutoCode(scope.row)">
|
|
|
|
|
复用
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button type="primary" link @click="deleteRow(scope.row)">
|
|
|
|
|
删除
|
|
|
|
|
</el-button>
|
2021-09-18 00:10:17 +08:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
<div class="gva-pagination">
|
|
|
|
|
<el-pagination
|
|
|
|
|
:current-page="page"
|
|
|
|
|
:page-size="pageSize"
|
|
|
|
|
:page-sizes="[10, 30, 50, 100]"
|
|
|
|
|
:total="total"
|
|
|
|
|
layout="total, sizes, prev, pager, next, jumper"
|
|
|
|
|
@current-change="handleCurrentChange"
|
|
|
|
|
@size-change="handleSizeChange"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2021-07-13 19:45:21 +08:00
|
|
|
|
</div>
|
2024-06-16 00:27:40 +08:00
|
|
|
|
<el-dialog
|
|
|
|
|
v-model="dialogFormVisible"
|
2024-07-25 21:29:20 +08:00
|
|
|
|
:title="dialogFormTitle"
|
2024-06-16 00:27:40 +08:00
|
|
|
|
:before-close="closeDialog"
|
|
|
|
|
width="600px"
|
|
|
|
|
>
|
|
|
|
|
<el-form :inline="true" :model="formData" label-width="80px">
|
|
|
|
|
<el-form-item label="选项:">
|
|
|
|
|
<el-checkbox
|
|
|
|
|
v-model="formData.deleteApi"
|
2024-07-25 21:29:20 +08:00
|
|
|
|
label="删除接口"
|
|
|
|
|
/>
|
2024-06-16 00:27:40 +08:00
|
|
|
|
<el-checkbox
|
|
|
|
|
v-model="formData.deleteMenu"
|
2024-07-25 21:29:20 +08:00
|
|
|
|
label="删除菜单"
|
|
|
|
|
/>
|
2024-06-16 00:27:40 +08:00
|
|
|
|
<el-checkbox
|
|
|
|
|
v-model="formData.deleteTable"
|
2024-07-25 21:29:20 +08:00
|
|
|
|
label="删除表"
|
2024-06-16 00:27:40 +08:00
|
|
|
|
@change="deleteTableCheck"
|
2024-07-25 21:29:20 +08:00
|
|
|
|
/>
|
2024-06-16 00:27:40 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<div class="dialog-footer">
|
2024-07-25 21:29:20 +08:00
|
|
|
|
<el-button @click="closeDialog">
|
|
|
|
|
取 消
|
|
|
|
|
</el-button>
|
2024-06-16 00:27:40 +08:00
|
|
|
|
<el-popconfirm
|
|
|
|
|
title="此操作将回滚生成文件和勾选项目, 是否继续?"
|
|
|
|
|
@confirm="enterDialog"
|
|
|
|
|
>
|
|
|
|
|
<template #reference>
|
2024-07-25 21:29:20 +08:00
|
|
|
|
<el-button type="primary">
|
|
|
|
|
确 定
|
|
|
|
|
</el-button>
|
2024-06-16 00:27:40 +08:00
|
|
|
|
</template>
|
|
|
|
|
</el-popconfirm>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</el-dialog>
|
2024-07-25 21:29:20 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-drawer
|
|
|
|
|
v-model="funcFlag"
|
|
|
|
|
size="60%"
|
|
|
|
|
:show-close="false"
|
|
|
|
|
>
|
|
|
|
|
<template #header>
|
|
|
|
|
<div class="flex justify-between items-center">
|
|
|
|
|
<span class="text-lg">操作栏</span>
|
|
|
|
|
<div>
|
|
|
|
|
<el-button
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="runFunc"
|
|
|
|
|
>
|
|
|
|
|
生成
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="closeFunc"
|
|
|
|
|
>
|
|
|
|
|
取消
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<div class="">
|
|
|
|
|
<el-form label-position="top" :model="autoFunc" label-width="80px">
|
|
|
|
|
<el-form-item label="包名:">
|
|
|
|
|
<el-input v-model="autoFunc.package" placeholder="请输入包名" disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="结构体名:">
|
|
|
|
|
<el-input v-model="autoFunc.structName" placeholder="请输入结构体名" disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="前端文件名:">
|
|
|
|
|
<el-input v-model="autoFunc.packageName" placeholder="请输入文件名" disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="后端文件名:">
|
|
|
|
|
<el-input v-model="autoFunc.humpPackageName" placeholder="请输入文件名" disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="描述:">
|
|
|
|
|
<el-input v-model="autoFunc.description" placeholder="请输入描述" disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="缩写:">
|
|
|
|
|
<el-input v-model="autoFunc.abbreviation" placeholder="请输入缩写" disabled />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="方法名:">
|
|
|
|
|
<el-input v-model="autoFunc.funcName" placeholder="请输入方法名" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="方法:">
|
|
|
|
|
<el-select v-model="autoFunc.method" placeholder="请选择方法">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in ['GET', 'POST', 'PUT', 'DELETE']"
|
|
|
|
|
:key="item"
|
|
|
|
|
:label="item"
|
|
|
|
|
:value="item"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
2024-07-26 11:22:30 +08:00
|
|
|
|
<el-form-item label="路由path:">
|
|
|
|
|
<el-input v-model="autoFunc.router" placeholder="路由path" />
|
|
|
|
|
<div>API路径: [{{ autoFunc.method }}] /{{ autoFunc.abbreviation }}/{{ autoFunc.router }}</div>
|
|
|
|
|
</el-form-item>
|
2024-07-25 21:29:20 +08:00
|
|
|
|
</el-form>
|
|
|
|
|
</div>
|
|
|
|
|
</el-drawer>
|
2021-07-13 19:45:21 +08:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
2021-12-30 20:48:57 +08:00
|
|
|
|
<script setup>
|
2024-07-25 21:29:20 +08:00
|
|
|
|
import { getSysHistory, rollback, delSysHistory,addFunc } from "@/api/autoCode.js";
|
2024-06-16 00:27:40 +08:00
|
|
|
|
import { useRouter } from "vue-router";
|
|
|
|
|
import { ElMessage, ElMessageBox } from "element-plus";
|
|
|
|
|
import { ref } from "vue";
|
|
|
|
|
import { formatDate } from "@/utils/format";
|
2023-09-14 18:47:47 +08:00
|
|
|
|
|
|
|
|
|
defineOptions({
|
2024-06-16 00:27:40 +08:00
|
|
|
|
name: "AutoCodeAdmin",
|
|
|
|
|
});
|
2023-09-14 18:47:47 +08:00
|
|
|
|
|
2024-06-16 00:27:40 +08:00
|
|
|
|
const formData = ref({
|
|
|
|
|
id: undefined,
|
|
|
|
|
deleteApi: true,
|
|
|
|
|
deleteMenu: true,
|
|
|
|
|
deleteTable: false,
|
|
|
|
|
});
|
2021-07-13 19:45:21 +08:00
|
|
|
|
|
2024-06-16 00:27:40 +08:00
|
|
|
|
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([]);
|
2021-12-30 20:48:57 +08:00
|
|
|
|
|
2024-07-25 21:29:20 +08:00
|
|
|
|
const autoFunc = ref({
|
|
|
|
|
package:"",
|
|
|
|
|
funcName:"",
|
|
|
|
|
structName:"",
|
|
|
|
|
packageName:"",
|
|
|
|
|
description:"",
|
|
|
|
|
abbreviation:"",
|
|
|
|
|
humpPackageName:"",
|
|
|
|
|
businessDB:"",
|
|
|
|
|
method:"",
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const addFuncBtn = (row) => {
|
|
|
|
|
const req = JSON.parse(row.request)
|
|
|
|
|
autoFunc.value.package = req.package
|
|
|
|
|
autoFunc.value.structName = req.structName
|
|
|
|
|
autoFunc.value.packageName = req.packageName
|
|
|
|
|
autoFunc.value.description = req.description
|
|
|
|
|
autoFunc.value.abbreviation = req.abbreviation
|
|
|
|
|
autoFunc.value.humpPackageName = req.humpPackageName
|
|
|
|
|
autoFunc.value.businessDB = req.businessDB
|
|
|
|
|
funcFlag.value = true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const funcFlag = ref(false);
|
|
|
|
|
|
|
|
|
|
const closeFunc = () => {
|
|
|
|
|
funcFlag.value = false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const runFunc = () =>{
|
|
|
|
|
// funcFlag.value = false;
|
|
|
|
|
addFunc(autoFunc.value)
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-30 20:48:57 +08:00
|
|
|
|
// 分页
|
|
|
|
|
const handleSizeChange = (val) => {
|
2024-06-16 00:27:40 +08:00
|
|
|
|
pageSize.value = val;
|
|
|
|
|
getTableData();
|
|
|
|
|
};
|
2021-12-30 20:48:57 +08:00
|
|
|
|
|
|
|
|
|
const handleCurrentChange = (val) => {
|
2024-06-16 00:27:40 +08:00
|
|
|
|
page.value = val;
|
|
|
|
|
getTableData();
|
|
|
|
|
};
|
2021-12-30 20:48:57 +08:00
|
|
|
|
|
|
|
|
|
// 查询
|
2024-06-16 00:27:40 +08:00
|
|
|
|
const getTableData = async () => {
|
2021-12-30 20:48:57 +08:00
|
|
|
|
const table = await getSysHistory({
|
|
|
|
|
page: page.value,
|
2024-06-16 00:27:40 +08:00
|
|
|
|
pageSize: pageSize.value,
|
|
|
|
|
});
|
2021-12-30 20:48:57 +08:00
|
|
|
|
if (table.code === 0) {
|
2024-06-16 00:27:40 +08:00
|
|
|
|
tableData.value = table.data.list;
|
|
|
|
|
total.value = table.data.total;
|
|
|
|
|
page.value = table.data.page;
|
|
|
|
|
pageSize.value = table.data.pageSize;
|
2021-12-30 20:48:57 +08:00
|
|
|
|
}
|
2024-06-16 00:27:40 +08:00
|
|
|
|
};
|
2021-12-30 20:48:57 +08:00
|
|
|
|
|
2024-06-16 00:27:40 +08:00
|
|
|
|
getTableData();
|
2021-12-30 20:48:57 +08:00
|
|
|
|
|
2024-06-16 00:27:40 +08:00
|
|
|
|
const deleteRow = async (row) => {
|
|
|
|
|
ElMessageBox.confirm("此操作将删除本历史, 是否继续?", "提示", {
|
|
|
|
|
confirmButtonText: "确定",
|
|
|
|
|
cancelButtonText: "取消",
|
|
|
|
|
type: "warning",
|
|
|
|
|
}).then(async () => {
|
|
|
|
|
const res = await delSysHistory({ id: Number(row.ID) });
|
2021-12-30 20:48:57 +08:00
|
|
|
|
if (res.code === 0) {
|
2024-06-16 00:27:40 +08:00
|
|
|
|
ElMessage.success("删除成功");
|
|
|
|
|
getTableData();
|
2021-07-13 19:45:21 +08:00
|
|
|
|
}
|
2024-06-16 00:27:40 +08:00
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 打开弹窗
|
|
|
|
|
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) => {
|
2022-06-18 23:21:19 +08:00
|
|
|
|
if (flag) {
|
2024-06-16 00:27:40 +08:00
|
|
|
|
ElMessageBox.confirm(
|
|
|
|
|
`此操作将删除自动创建的文件和api(会删除表!!!), 是否继续?`,
|
|
|
|
|
"提示",
|
|
|
|
|
{
|
|
|
|
|
closeOnClickModal: false,
|
|
|
|
|
distinguishCancelAndClose: true,
|
|
|
|
|
confirmButtonText: "确定",
|
|
|
|
|
cancelButtonText: "取消",
|
|
|
|
|
type: "warning",
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
.then(() => {
|
|
|
|
|
ElMessageBox.confirm(
|
|
|
|
|
`此操作将删除自动创建的文件和api(会删除表!!!), 请继续确认!!!`,
|
|
|
|
|
"会删除表",
|
|
|
|
|
{
|
|
|
|
|
closeOnClickModal: false,
|
|
|
|
|
distinguishCancelAndClose: true,
|
|
|
|
|
confirmButtonText: "确定",
|
|
|
|
|
cancelButtonText: "取消",
|
|
|
|
|
type: "warning",
|
2022-06-18 23:21:19 +08:00
|
|
|
|
}
|
2024-06-16 00:27:40 +08:00
|
|
|
|
).catch(() => {
|
|
|
|
|
formData.value.deleteTable = false;
|
|
|
|
|
});
|
2022-06-18 23:21:19 +08:00
|
|
|
|
})
|
2024-06-16 00:27:40 +08:00
|
|
|
|
.catch(() => {
|
|
|
|
|
formData.value.deleteTable = false;
|
|
|
|
|
});
|
2022-06-18 23:21:19 +08:00
|
|
|
|
}
|
2024-06-16 00:27:40 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const enterDialog = async () => {
|
|
|
|
|
const res = await rollback(formData.value);
|
|
|
|
|
if (res.code === 0) {
|
|
|
|
|
ElMessage.success("回滚成功");
|
|
|
|
|
getTableData();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2021-12-30 20:48:57 +08:00
|
|
|
|
const goAutoCode = (row) => {
|
|
|
|
|
if (row) {
|
2024-06-16 00:27:40 +08:00
|
|
|
|
router.push({
|
|
|
|
|
name: "autoCodeEdit",
|
|
|
|
|
params: {
|
|
|
|
|
id: row.ID,
|
|
|
|
|
},
|
|
|
|
|
});
|
2021-12-30 20:48:57 +08:00
|
|
|
|
} else {
|
2024-06-16 00:27:40 +08:00
|
|
|
|
router.push({ name: "autoCode" });
|
2021-07-13 19:45:21 +08:00
|
|
|
|
}
|
2024-06-16 00:27:40 +08:00
|
|
|
|
};
|
2021-07-13 19:45:21 +08:00
|
|
|
|
</script>
|