feat: 添加代码生成器模块
This commit is contained in:
412
Yi.RuoYi.Vue3/src/views/code/field/components/FieldList.vue
Normal file
412
Yi.RuoYi.Vue3/src/views/code/field/components/FieldList.vue
Normal file
@@ -0,0 +1,412 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form
|
||||
:model="queryParams"
|
||||
ref="queryRef"
|
||||
:inline="true"
|
||||
v-show="showSearch"
|
||||
label-width="68px"
|
||||
>
|
||||
|
||||
<el-form-item label="当前选择表:" label-width="120px" >
|
||||
|
||||
<el-input v-if="props.table.name!=null" v-model="props.table.name" disabled />
|
||||
<span v-else>无</span>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="字段名称" prop="name">
|
||||
<el-input
|
||||
v-model="queryParams.name"
|
||||
placeholder="请输入字段名称"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery"
|
||||
>搜索</el-button
|
||||
>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="Plus"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['system:config:add']"
|
||||
>新增</el-button
|
||||
>
|
||||
<!-- :disabled="props.table.name==null" -->
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="Edit"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['system:config:edit']"
|
||||
>修改</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Delete"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['system:config:remove']"
|
||||
>删除</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="Download"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['system:config:export']"
|
||||
>导出</el-button
|
||||
>
|
||||
</el-col>
|
||||
|
||||
<right-toolbar
|
||||
v-model:showSearch="showSearch"
|
||||
@queryTable="getList"
|
||||
></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="dataList"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="名称" align="center" prop="name" />
|
||||
<el-table-column label="类型" align="center" prop="fieldType" >
|
||||
<template #default="scope">
|
||||
<el-tag>{{getFieldTypeEnum(scope.row.fieldType)}}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="长度" align="center" prop="length" >
|
||||
<template #default="scope">
|
||||
{{ scope.row.length==0?'-':scope.row.length }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="是否必填" align="center" prop="isRequired" >
|
||||
<template #default="scope">
|
||||
<el-switch disabled v-model="scope.row.isRequired" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="是否主键" align="center" prop="isKey" >
|
||||
<template #default="scope">
|
||||
<el-switch disabled v-model="scope.row.isKey" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="是否自增" align="center" prop="isAutoAdd" >
|
||||
<template #default="scope">
|
||||
<el-switch disabled v-model="scope.row.isAutoAdd" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="描述"
|
||||
align="center"
|
||||
prop="Description"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
label="操作"
|
||||
align="center"
|
||||
width="150"
|
||||
class-name="small-padding fixed-width"
|
||||
>
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
type="text"
|
||||
icon="Edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['system:config:edit']"
|
||||
>修改</el-button
|
||||
>
|
||||
<el-button
|
||||
type="text"
|
||||
icon="Delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['system:config:remove']"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="Number(total)"
|
||||
v-model:page="queryParams.skipCount"
|
||||
v-model:limit="queryParams.maxResultCount"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改字段配置对话框 -->
|
||||
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
||||
<el-form ref="dataRef" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入字段名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="类型" prop="fieldType">
|
||||
<el-select
|
||||
v-model="form.fieldType"
|
||||
class="m-2"
|
||||
placeholder="请选择一个类型"
|
||||
size="large"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in fieldList"
|
||||
:key="item.value"
|
||||
:label="item.lable"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="长度" prop="length">
|
||||
<el-input v-model="form.length" placeholder="请输入字段长度" />
|
||||
</el-form-item>
|
||||
<el-form-item label="是否必须" prop="isRequired">
|
||||
<el-switch v-model="form.isRequired" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="是否主键" prop="isKey">
|
||||
<el-switch v-model="form.isKey" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="是否自增" prop="isAutoAdd">
|
||||
<el-switch v-model="form.isAutoAdd" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="字段排序" prop="orderNum">
|
||||
<el-input-number v-model="form.orderNum" />
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<el-form-item label="字段描述" prop="description">
|
||||
<el-input
|
||||
v-model="form.description"
|
||||
type="textarea"
|
||||
placeholder="请输入字段描述"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
listData,
|
||||
getData,
|
||||
addData,
|
||||
updateData,
|
||||
delData,
|
||||
getType
|
||||
} from "@/api/webfirst/fieldApi";
|
||||
import { computed, onMounted, defineProps, ref } from "vue";
|
||||
|
||||
const { proxy } = getCurrentInstance();
|
||||
const { sys_yes_no } = proxy.useDict("sys_yes_no");
|
||||
const props = defineProps(["table"]);
|
||||
|
||||
const tableOptions = computed(() => props.table);
|
||||
|
||||
const dataList = ref([]);
|
||||
const open = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
const title = ref("");
|
||||
const dateRange = ref([]);
|
||||
const fieldList=ref([]);
|
||||
const data = reactive({
|
||||
form: {
|
||||
tableId: props.table.id,
|
||||
orderNum:0
|
||||
},
|
||||
queryParams: {
|
||||
skipCount: 1,
|
||||
maxResultCount: 10,
|
||||
name: undefined,
|
||||
// props.table.id
|
||||
},
|
||||
rules: {
|
||||
name: [{ required: true, message: "字段名称不能为空", trigger: "blur" }],
|
||||
fieldType: [
|
||||
{ required: true, message: "字段类型不能为空", trigger: "blur" },
|
||||
],
|
||||
// configValue: [{ required: true, message: "字段键值不能为空", trigger: "blur" }]
|
||||
},
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
const getFieldTypeEnum=(field)=>{
|
||||
return fieldList.value.filter(x=>x.value==field)[0].lable;
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props,
|
||||
(val) => {
|
||||
getList();
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
function getTypeList()
|
||||
{
|
||||
getType().then((response)=>{
|
||||
fieldList.value=response.data;
|
||||
});
|
||||
}
|
||||
|
||||
/** 查询字段列表 */
|
||||
function getList() {
|
||||
loading.value = true;
|
||||
listData({
|
||||
...proxy.addDateRange(queryParams.value, dateRange.value),
|
||||
tableId: props.table.id,
|
||||
}).then((response) => {
|
||||
dataList.value = response.data.items;
|
||||
total.value = response.data.totalCount;
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
/** 取消按钮 */
|
||||
function cancel() {
|
||||
open.value = false;
|
||||
reset();
|
||||
}
|
||||
/** 表单重置 */
|
||||
function reset() {
|
||||
form.value = {
|
||||
id: undefined,
|
||||
name: undefined,
|
||||
description: undefined,
|
||||
orderNum: undefined,
|
||||
length: undefined,
|
||||
fieldType: undefined,
|
||||
isRequired: false,
|
||||
isKey: false,
|
||||
isAutoAdd: false,
|
||||
tableId: props.table.id,
|
||||
orderNum:0
|
||||
};
|
||||
proxy.resetForm("dataRef");
|
||||
}
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
queryParams.value.skipCount = 1;
|
||||
getList();
|
||||
}
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
dateRange.value = [];
|
||||
proxy.resetForm("queryRef");
|
||||
handleQuery();
|
||||
}
|
||||
/** 多选框选中数据 */
|
||||
function handleSelectionChange(selection) {
|
||||
ids.value = selection.map((item) => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
}
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd() {
|
||||
if(props.table.id==undefined)
|
||||
{
|
||||
proxy.$modal.msgWarning('请先选择一张表后再添加字段');
|
||||
return;
|
||||
}
|
||||
reset();
|
||||
open.value = true;
|
||||
title.value = "添加字段";
|
||||
}
|
||||
/** 修改按钮操作 */
|
||||
function handleUpdate(row) {
|
||||
reset();
|
||||
const configId = row.id || ids.value;
|
||||
getData(configId).then((response) => {
|
||||
form.value = response.data;
|
||||
open.value = true;
|
||||
title.value = "修改字段";
|
||||
});
|
||||
}
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["dataRef"].validate((valid) => {
|
||||
if (valid) {
|
||||
if (form.value.id != undefined) {
|
||||
updateData(form.value).then((response) => {
|
||||
proxy.$modal.msgSuccess("修改成功");
|
||||
open.value = false;
|
||||
getList();
|
||||
});
|
||||
} else {
|
||||
addData(form.value).then((response) => {
|
||||
proxy.$modal.msgSuccess("新增成功");
|
||||
open.value = false;
|
||||
getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/** 删除按钮操作 */
|
||||
function handleDelete(row) {
|
||||
const configIds = row.id || ids.value;
|
||||
proxy.$modal
|
||||
.confirm('是否确认删除字段编号为"' + configIds + '"的数据项?')
|
||||
.then(function () {
|
||||
return delData(configIds);
|
||||
})
|
||||
.then(() => {
|
||||
getList();
|
||||
proxy.$modal.msgSuccess("删除成功");
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
/** 导出按钮操作 */
|
||||
function handleExport() {
|
||||
proxy.download(
|
||||
"system/config/export",
|
||||
{
|
||||
...queryParams.value,
|
||||
},
|
||||
`config_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
}
|
||||
/** 刷新缓存按钮操作 */
|
||||
function handleRefreshCache() {
|
||||
refreshCache().then(() => {
|
||||
proxy.$modal.msgSuccess("刷新缓存成功");
|
||||
});
|
||||
}
|
||||
getTypeList();
|
||||
getList();
|
||||
</script>
|
||||
32
Yi.RuoYi.Vue3/src/views/code/field/components/TableList.vue
Normal file
32
Yi.RuoYi.Vue3/src/views/code/field/components/TableList.vue
Normal file
@@ -0,0 +1,32 @@
|
||||
<template>
|
||||
<h3 class="title">数据表选择</h3>
|
||||
<el-menu
|
||||
default-active="2"
|
||||
class="el-menu-vertical-demo"
|
||||
>
|
||||
<el-menu-item v-for="(item,i) in dataList" :index="'data-'+i" :key="i" @click="menuClick(item)">
|
||||
<el-icon><setting /></el-icon>
|
||||
<span>{{item.name}}</span>
|
||||
</el-menu-item>
|
||||
</el-menu>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import useTable from '../hooks/useTable'
|
||||
const emit = defineEmits(['selectTable'])
|
||||
|
||||
function menuClick(item) {
|
||||
emit('selectTable',item)
|
||||
}
|
||||
const {dataList}=useTable();
|
||||
</script>
|
||||
<style scoped>
|
||||
.el-menu-item{
|
||||
justify-content: center;
|
||||
max-height: 1000px;
|
||||
}
|
||||
.title
|
||||
{
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
11
Yi.RuoYi.Vue3/src/views/code/field/hooks/useTable.js
Normal file
11
Yi.RuoYi.Vue3/src/views/code/field/hooks/useTable.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import {listData} from "@/api/webfirst/tableApi.js"
|
||||
|
||||
const useTable=()=>{
|
||||
const dataList=ref([]);
|
||||
onMounted( async() => {
|
||||
const response= await listData();
|
||||
dataList.value=response.data.items;
|
||||
});
|
||||
return {dataList};
|
||||
}
|
||||
export default useTable;
|
||||
28
Yi.RuoYi.Vue3/src/views/code/field/index.vue
Normal file
28
Yi.RuoYi.Vue3/src/views/code/field/index.vue
Normal file
@@ -0,0 +1,28 @@
|
||||
<template>
|
||||
<el-row>
|
||||
<el-col :span="4"> <TableList @selectTable="selectTable"></TableList></el-col>
|
||||
<el-col :span="20"> <FieldList class="fileList" :table="table"></FieldList></el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref ,watch} from 'vue'
|
||||
import FieldList from './components/FieldList.vue'
|
||||
import TableList from './components/TableList.vue'
|
||||
const table=ref({});
|
||||
const options = ref({})
|
||||
const selectTable=(table)=>{
|
||||
options.value = table
|
||||
}
|
||||
watch(() => options.value,val => {
|
||||
table.value = val
|
||||
},{deep:true})
|
||||
</script>
|
||||
<style scoped>
|
||||
.fileList{
|
||||
|
||||
|
||||
}
|
||||
.tableList{
|
||||
|
||||
}
|
||||
</style>
|
||||
384
Yi.RuoYi.Vue3/src/views/code/table/index.vue
Normal file
384
Yi.RuoYi.Vue3/src/views/code/table/index.vue
Normal file
@@ -0,0 +1,384 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form
|
||||
:model="queryParams"
|
||||
ref="queryRef"
|
||||
:inline="true"
|
||||
v-show="showSearch"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-form-item label="表名称" prop="name">
|
||||
<el-input
|
||||
v-model="queryParams.name"
|
||||
placeholder="请输入表名称"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
@keyup.enter="handleQuery"
|
||||
prop="name"
|
||||
/>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="表编号" prop="code">
|
||||
<el-input v-model="queryParams.code" placeholder="请输入表编号" clearable style="width: 240px"
|
||||
@keyup.enter="handleQuery" prop="code" />
|
||||
</el-form-item> -->
|
||||
<!-- <el-form-item label="状态" prop="isDeleted">
|
||||
<el-select
|
||||
v-model="queryParams.isDeleted"
|
||||
placeholder="状态"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in sys_normal_disable"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item> -->
|
||||
<!-- <el-form-item label="创建时间" style="width: 308px">
|
||||
<el-date-picker
|
||||
v-model="dateRange"
|
||||
value-format="YYYY-MM-DD"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
></el-date-picker>
|
||||
</el-form-item> -->
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery"
|
||||
>搜索</el-button
|
||||
>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="Plus"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['webfirst:table:add']"
|
||||
>新增</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="Edit"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['webfirst:table:edit']"
|
||||
>修改</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Delete"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['webfirst:table:remove']"
|
||||
>删除</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="Download"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['webfirst:table:export']"
|
||||
>导出</el-button
|
||||
>
|
||||
</el-col>
|
||||
|
||||
<!-- <el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="Switch"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['webfirst:table:export']"
|
||||
>同步数据库WebToDb</el-button
|
||||
>
|
||||
</el-col> -->
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="Switch"
|
||||
@click="handleWebToCode"
|
||||
:disabled="ids.length==0"
|
||||
v-hasPermi="['webfirst:table:export']"
|
||||
>代码生成WebToCode</el-button
|
||||
>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Switch"
|
||||
@click="handleCodeToWeb"
|
||||
v-hasPermi="['webfirst:table:export']"
|
||||
>实体同步CodeToWeb</el-button
|
||||
>
|
||||
</el-col>
|
||||
<right-toolbar
|
||||
v-model:showSearch="showSearch"
|
||||
@queryTable="getList"
|
||||
></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="dataList"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
|
||||
<!-----------------------这里开始就是数据表单的全部列------------------------>
|
||||
|
||||
<el-table-column
|
||||
label="表名称"
|
||||
align="center"
|
||||
prop="name"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
|
||||
<el-table-column
|
||||
label="描述"
|
||||
align="center"
|
||||
prop="description"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<!-- <el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
width="180"
|
||||
>
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||
</template>
|
||||
</el-table-column> -->
|
||||
<el-table-column
|
||||
label="操作"
|
||||
align="center"
|
||||
class-name="small-padding fixed-width"
|
||||
>
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
type="text"
|
||||
icon="Edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['business:article:edit']"
|
||||
>修改</el-button
|
||||
>
|
||||
<el-button
|
||||
type="text"
|
||||
icon="Delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['business:article:remove']"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="Number(total)"
|
||||
v-model:page="queryParams.skipCount"
|
||||
v-model:limit="queryParams.maxResultCount"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- ---------------------这里是新增和更新的对话框--------------------- -->
|
||||
<el-dialog :title="title" v-model="open" width="600px" append-to-body>
|
||||
<el-form ref="dataRef" :model="form" :rules="rules" label-width="100px">
|
||||
<el-form-item label="表名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入表名称" />
|
||||
</el-form-item>
|
||||
|
||||
<!-- <el-form-item label="状态" prop="isDeleted">
|
||||
<el-radio-group v-model="form.isDeleted">
|
||||
<el-radio
|
||||
v-for="dict in sys_normal_disable"
|
||||
:key="dict.value"
|
||||
:label="JSON.parse(dict.value)"
|
||||
>{{ dict.label }}</el-radio
|
||||
>
|
||||
</el-radio-group>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="描述" prop="description">
|
||||
<el-input
|
||||
v-model="form.description"
|
||||
type="textarea"
|
||||
placeholder="请输入内容"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
listData,
|
||||
getData,
|
||||
delData,
|
||||
addData,
|
||||
updateData,
|
||||
} from "@/api/webfirst/tableApi";
|
||||
import { codeToWeb,webToCode } from "@/api/webfirst/webfirstApi";
|
||||
const { proxy } = getCurrentInstance();
|
||||
const { sys_normal_disable } = proxy.useDict("sys_normal_disable");
|
||||
|
||||
const dataList = ref([]);
|
||||
const open = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
const title = ref("");
|
||||
const dateRange = ref([]);
|
||||
const data = reactive({
|
||||
form: {},
|
||||
queryParams: {
|
||||
skipCount: 1,
|
||||
maxResultCount: 10,
|
||||
name: undefined,
|
||||
code: undefined,
|
||||
},
|
||||
rules: {
|
||||
code: [{ required: true, message: "表编号不能为空", trigger: "blur" }],
|
||||
name: [{ required: true, message: "表名称不能为空", trigger: "blur" }],
|
||||
},
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询列表 */
|
||||
function getList() {
|
||||
loading.value = true;
|
||||
listData(proxy.addDateRange(queryParams.value, dateRange.value)).then(
|
||||
(response) => {
|
||||
dataList.value = response.data.items;
|
||||
total.value = response.data.totalCount;
|
||||
loading.value = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
/** 取消按钮 */
|
||||
function cancel() {
|
||||
open.value = false;
|
||||
reset();
|
||||
}
|
||||
|
||||
/** 表单重置 */
|
||||
function reset() {
|
||||
proxy.resetForm("dataRef");
|
||||
}
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
queryParams.value.skipCount = 1;
|
||||
getList();
|
||||
}
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
dateRange.value = [];
|
||||
proxy.resetForm("queryRef");
|
||||
handleQuery();
|
||||
}
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd() {
|
||||
reset();
|
||||
open.value = true;
|
||||
title.value = "添加表";
|
||||
}
|
||||
/** 多选框选中数据 */
|
||||
function handleSelectionChange(selection) {
|
||||
ids.value = selection.map((item) => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
}
|
||||
/** 修改按钮操作 */
|
||||
function handleUpdate(row) {
|
||||
reset();
|
||||
const id = row.id || ids.value;
|
||||
getData(id).then((response) => {
|
||||
form.value = response.data;
|
||||
open.value = true;
|
||||
title.value = "修改表";
|
||||
});
|
||||
}
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["dataRef"].validate((valid) => {
|
||||
if (valid) {
|
||||
if (form.value.id != undefined) {
|
||||
updateData(form.value.id, form.value).then((response) => {
|
||||
proxy.$modal.msgSuccess("修改成功");
|
||||
open.value = false;
|
||||
getList();
|
||||
});
|
||||
} else {
|
||||
addData(form.value).then((response) => {
|
||||
proxy.$modal.msgSuccess("新增成功");
|
||||
open.value = false;
|
||||
getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/** 删除按钮操作 */
|
||||
function handleDelete(row) {
|
||||
const delIds = row.id || ids.value;
|
||||
proxy.$modal
|
||||
.confirm('是否确认删除编号为"' + delIds + '"的数据项?')
|
||||
.then(function () {
|
||||
return delData(delIds);
|
||||
})
|
||||
.then(() => {
|
||||
getList();
|
||||
proxy.$modal.msgSuccess("删除成功");
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
/** 导出按钮操作 */
|
||||
function handleExport() {}
|
||||
|
||||
/** CodeToWeb */
|
||||
const handleCodeToWeb = async () => {
|
||||
await codeToWeb();
|
||||
proxy.$modal.msgSuccess("实体同步成功");
|
||||
getList();
|
||||
};
|
||||
|
||||
/** CodeToWeb */
|
||||
const handleWebToCode = async () => {
|
||||
const response= await webToCode(ids.value);
|
||||
if(response.statusCode==200)
|
||||
{
|
||||
proxy.$modal.msgSuccess("代码生成成功");
|
||||
}
|
||||
|
||||
};
|
||||
getList();
|
||||
</script>
|
||||
@@ -0,0 +1,32 @@
|
||||
<template>
|
||||
<el-row>
|
||||
<el-col :offset="6" :span="8">
|
||||
<el-input v-model="oldStr" placeholder="输入需替换内容"></el-input>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-input v-model="newStr" placeholder="输入替换后内容"></el-input>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="2" class="btn">
|
||||
<el-button @click="replace" type="primary" :disabled="oldStr==''||newStr==''">替换字符串</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const props = defineProps(['text'])
|
||||
const emit = defineEmits(['handleText'])
|
||||
const oldStr=ref("");
|
||||
const newStr=ref("");
|
||||
const replace=()=>{
|
||||
const resultStr= props.text.replace(new RegExp(oldStr.value,'g'),newStr.value);
|
||||
emit("handleText",resultStr);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.btn{
|
||||
justify-content: right;
|
||||
display: flex;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,36 @@
|
||||
<template>
|
||||
<p><el-icon><InfoFilled /></el-icon> 以下模板变量将会被替换:</p>
|
||||
<p v-for="(item,i) in text" :key="i">
|
||||
<el-text class="mx-1" type="primary">【{{item.oldValue}}】</el-text>替换为
|
||||
<el-text class="mx-1" type="Default">【{{item.newValue}}】</el-text>
|
||||
</p>
|
||||
</template>
|
||||
<script setup>
|
||||
const text=[
|
||||
{
|
||||
oldValue:"@model",
|
||||
newValue:"实体名字,小写开头"
|
||||
},
|
||||
{
|
||||
oldValue:"@Model",
|
||||
newValue:"实体名字,大写开头"
|
||||
},
|
||||
{
|
||||
oldValue:"@namespace",
|
||||
newValue:"命名空间"
|
||||
},
|
||||
{
|
||||
oldValue:"@field",
|
||||
newValue:"实体字段"
|
||||
}
|
||||
]
|
||||
</script>
|
||||
<style scoped>
|
||||
.mx-1
|
||||
{
|
||||
margin-right: 10px;
|
||||
}
|
||||
p{
|
||||
padding-left: 100px;
|
||||
}
|
||||
</style>
|
||||
377
Yi.RuoYi.Vue3/src/views/code/template/index.vue
Normal file
377
Yi.RuoYi.Vue3/src/views/code/template/index.vue
Normal file
@@ -0,0 +1,377 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form
|
||||
:model="queryParams"
|
||||
ref="queryRef"
|
||||
:inline="true"
|
||||
v-show="showSearch"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-form-item label="模板名称" prop="name">
|
||||
<el-input
|
||||
v-model="queryParams.name"
|
||||
placeholder="请输入模板名称"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
@keyup.enter="handleQuery"
|
||||
prop="name"
|
||||
/>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="模板编号" prop="code">
|
||||
<el-input v-model="queryParams.code" placeholder="请输入模板编号" clearable style="width: 240px"
|
||||
@keyup.enter="handleQuery" prop="code" />
|
||||
</el-form-item> -->
|
||||
<!-- <el-form-item label="创建时间" style="width: 308px">
|
||||
<el-date-picker
|
||||
v-model="dateRange"
|
||||
value-format="YYYY-MM-DD"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
></el-date-picker>
|
||||
</el-form-item> -->
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery"
|
||||
>搜索</el-button
|
||||
>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="Plus"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['webfirst:template:add']"
|
||||
>新增</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="Edit"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['webfirst:template:edit']"
|
||||
>修改</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Delete"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['webfirst:template:remove']"
|
||||
>删除</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="Download"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['webfirst:template:export']"
|
||||
>导出</el-button
|
||||
>
|
||||
</el-col>
|
||||
<right-toolbar
|
||||
v-model:showSearch="showSearch"
|
||||
@queryTable="getList"
|
||||
></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="dataList"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
|
||||
<!-----------------------这里开始就是数据表单的全部列------------------------>
|
||||
|
||||
<el-table-column
|
||||
label="模板名称"
|
||||
align="center"
|
||||
prop="name"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
label="生成路径"
|
||||
align="center"
|
||||
prop="buildPath"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
|
||||
<!-- <el-table-column label="备注" align="center" prop="remarks" :show-overflow-tooltip="true" /> -->
|
||||
<!-- <el-table-column label="状态" align="center" prop="isDeleted">
|
||||
<template #default="scope">
|
||||
<dict-tag
|
||||
:options="sys_normal_disable"
|
||||
:value="scope.row.isDeleted"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column> -->
|
||||
<el-table-column
|
||||
label="备注"
|
||||
align="center"
|
||||
prop="remarks"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<!-- <el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
width="180"
|
||||
>
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||
</template>
|
||||
</el-table-column> -->
|
||||
<el-table-column
|
||||
label="操作"
|
||||
align="center"
|
||||
class-name="small-padding fixed-width"
|
||||
>
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
type="text"
|
||||
icon="Edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['webfirst:template:edit']"
|
||||
>修改</el-button
|
||||
>
|
||||
<el-button
|
||||
type="text"
|
||||
icon="Delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['webfirst:template:remove']"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="Number(total)"
|
||||
v-model:page="queryParams.skipCount"
|
||||
v-model:limit="queryParams.maxResultCount"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- ---------------------这里是新增和更新的对话框--------------------- -->
|
||||
<el-dialog :title="title" v-model="open" width="1200px" append-to-body>
|
||||
<el-form ref="dataRef" :model="form" :rules="rules" label-width="100px">
|
||||
<el-form-item label="模板名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入模板名称" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="构建路径" prop="buildPath">
|
||||
|
||||
<el-input v-model="form.buildPath" placeholder="请输入构建路径" />
|
||||
<el-button type="primary" @click="openDir(form.buildPath)">打开目录</el-button>
|
||||
</el-form-item>
|
||||
|
||||
<!-- <el-form-item label="状态" prop="isDeleted">
|
||||
<el-radio-group v-model="form.isDeleted">
|
||||
<el-radio
|
||||
v-for="dict in sys_normal_disable"
|
||||
:key="dict.value"
|
||||
:label="JSON.parse(dict.value)"
|
||||
>{{ dict.label }}</el-radio
|
||||
>
|
||||
</el-radio-group>
|
||||
</el-form-item> -->
|
||||
|
||||
<TempalteTip/>
|
||||
<el-form-item label="模板内容" prop="templateStr">
|
||||
<el-input
|
||||
v-model="form.templateStr"
|
||||
type="textarea"
|
||||
:rows="30"
|
||||
placeholder="请输入模板内容"
|
||||
></el-input>
|
||||
|
||||
</el-form-item>
|
||||
|
||||
<ReplaceText style="margin-bottom: 15px;" :text="form.templateStr" @handleText='hanldeReplaceText'></ReplaceText>
|
||||
|
||||
|
||||
|
||||
<el-form-item label="备注" prop="remarks">
|
||||
<el-input
|
||||
v-model="form.remarks"
|
||||
type="textarea"
|
||||
placeholder="请输入内容"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
listData,
|
||||
getData,
|
||||
delData,
|
||||
addData,
|
||||
updateData,
|
||||
} from "@/api/webfirst/templateApi";
|
||||
import {openPath} from "@/api/webfirst/webfirstApi";
|
||||
import { ref } from "@vue/reactivity";
|
||||
import ReplaceText from './components/ReplaceText'
|
||||
import TempalteTip from './components/TempalteTip.vue'
|
||||
const { proxy } = getCurrentInstance();
|
||||
const { sys_normal_disable } = proxy.useDict("sys_normal_disable");
|
||||
|
||||
const dataList = ref([]);
|
||||
const open = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
const title = ref("");
|
||||
const dateRange = ref([]);
|
||||
const data = reactive({
|
||||
form: {},
|
||||
queryParams: {
|
||||
skipCount: 1,
|
||||
maxResultCount: 10,
|
||||
name: undefined,
|
||||
},
|
||||
rules: {
|
||||
name: [{ required: true, message: "模板名称不能为空", trigger: "blur" }],
|
||||
buildPath: [
|
||||
{ required: true, message: "构建路径不能为空", trigger: "blur" },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询列表 */
|
||||
function getList() {
|
||||
loading.value = true;
|
||||
listData(proxy.addDateRange(queryParams.value, dateRange.value)).then(
|
||||
(response) => {
|
||||
dataList.value = response.data.items;
|
||||
total.value = response.data.totalCount;
|
||||
loading.value = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
/** 取消按钮 */
|
||||
function cancel() {
|
||||
open.value = false;
|
||||
reset();
|
||||
}
|
||||
|
||||
/** 表单重置 */
|
||||
function reset() {
|
||||
proxy.resetForm("dataRef");
|
||||
}
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
queryParams.value.skipCount = 1;
|
||||
getList();
|
||||
}
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
dateRange.value = [];
|
||||
proxy.resetForm("queryRef");
|
||||
handleQuery();
|
||||
}
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd() {
|
||||
reset();
|
||||
open.value = true;
|
||||
title.value = "添加模板";
|
||||
}
|
||||
/** 多选框选中数据 */
|
||||
function handleSelectionChange(selection) {
|
||||
ids.value = selection.map((item) => item.id);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
}
|
||||
/** 修改按钮操作 */
|
||||
function handleUpdate(row) {
|
||||
reset();
|
||||
const id = row.id || ids.value;
|
||||
getData(id).then((response) => {
|
||||
form.value = response.data;
|
||||
open.value = true;
|
||||
title.value = "修改模板";
|
||||
});
|
||||
}
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["dataRef"].validate((valid) => {
|
||||
if (valid) {
|
||||
if (form.value.id != undefined) {
|
||||
updateData(form.value.id, form.value).then((response) => {
|
||||
proxy.$modal.msgSuccess("修改成功");
|
||||
open.value = false;
|
||||
getList();
|
||||
});
|
||||
} else {
|
||||
addData(form.value).then((response) => {
|
||||
proxy.$modal.msgSuccess("新增成功");
|
||||
open.value = false;
|
||||
getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/** 删除按钮操作 */
|
||||
function handleDelete(row) {
|
||||
const delIds = row.id || ids.value;
|
||||
proxy.$modal
|
||||
.confirm('是否确认删除编号为"' + delIds + '"的数据项?')
|
||||
.then(function () {
|
||||
return delData(delIds);
|
||||
})
|
||||
.then(() => {
|
||||
getList();
|
||||
proxy.$modal.msgSuccess("删除成功");
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
/** 导出按钮操作 */
|
||||
function handleExport() {}
|
||||
|
||||
|
||||
/** 处理字符串替换 */
|
||||
function hanldeReplaceText(text)
|
||||
{
|
||||
form.value.templateStr=text;
|
||||
}
|
||||
getList();
|
||||
|
||||
/** 打开目录 */
|
||||
async function openDir(path)
|
||||
{
|
||||
const response= await openPath(path);
|
||||
if(response.statusCode==200)
|
||||
{
|
||||
proxy.$modal.msgSuccess("目录打开成功");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user