fix 代码生成功能完善
This commit is contained in:
parent
0f84ec41ea
commit
690d82676f
@ -4,12 +4,13 @@ export function getItems(f: Function, query: Object) {
|
||||
return f(query);
|
||||
}
|
||||
|
||||
export function setItems(response: any, k: string, v: string):Array<ItemOptions> {
|
||||
export function setItems(response: any, k: string, v: string,rk:string):Array<ItemOptions> {
|
||||
const data: Array<ItemOptions> = [];
|
||||
k = k || 'id';
|
||||
v = v || 'name';
|
||||
if (response.data && response.data.list && response.data.list.length > 0) {
|
||||
response.data.list.forEach((e: any) => {
|
||||
rk = rk || 'list'
|
||||
if (response.data && response['data'][rk] && response['data'][rk].length > 0) {
|
||||
response['data'][rk].forEach((e: any) => {
|
||||
data.push({
|
||||
key: e[k].toString(),
|
||||
value: e[v].toString(),
|
||||
|
@ -72,3 +72,12 @@ export function batchGenCode(ids:number[]){
|
||||
data: {ids}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
export function syncTable(tableId:number){
|
||||
return request({
|
||||
url: '/api/v1/system/tools/gen/syncTable',
|
||||
method: 'post',
|
||||
data: {tableId}
|
||||
})
|
||||
}
|
||||
|
@ -9,6 +9,11 @@ export interface TableData {
|
||||
updateTime:string;
|
||||
}
|
||||
|
||||
export interface DictOpt{
|
||||
dictName :string;
|
||||
dictType:string;
|
||||
}
|
||||
|
||||
export interface TableColumns {
|
||||
columnId: number;
|
||||
tableId: number;
|
||||
@ -22,7 +27,6 @@ export interface TableColumns {
|
||||
isPk: boolean;
|
||||
isIncrement: boolean;
|
||||
isRequired: boolean;
|
||||
isInsert: boolean;
|
||||
isEdit: boolean;
|
||||
isList: boolean;
|
||||
isDetail: boolean;
|
||||
|
@ -51,19 +51,6 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="插入" width="50">
|
||||
<template #default="scope">
|
||||
<el-checkbox
|
||||
v-model="scope.row.isInsert"
|
||||
:disabled="
|
||||
scope.row.isPk == '1' ||
|
||||
scope.row.columnName == 'created_at' ||
|
||||
scope.row.columnName == 'created_by' ||
|
||||
scope.row.columnName == 'updated_by'
|
||||
"
|
||||
></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="编辑" width="50">
|
||||
<template #default="scope">
|
||||
<el-checkbox
|
||||
@ -126,7 +113,10 @@
|
||||
<el-select v-model="scope.row.htmlType" :disabled="scope.row.htmlField == info.treeParentCode">
|
||||
<el-option label="文本框" value="input" />
|
||||
<el-option label="文本域" value="textarea" />
|
||||
<el-option label="下拉框" value="select" />
|
||||
<el-option label="下拉单选框" value="select" />
|
||||
<el-option label="下拉多选框" value="selects" />
|
||||
<el-option label="树形单选框" value="treeSelect" />
|
||||
<el-option label="树形多选框" value="treeSelects" />
|
||||
<el-option label="单选框" value="radio" />
|
||||
<el-option label="复选框" value="checkbox" />
|
||||
<el-option label="日期控件" value="date" />
|
||||
@ -227,7 +217,7 @@
|
||||
<script lang="ts">
|
||||
import {defineComponent, inject, onBeforeMount, ref} from 'vue';
|
||||
import type { FormInstance } from 'element-plus';
|
||||
import {TableDataInfo} from '/@/views/system/tools/gen/component/model';
|
||||
import {DictOpt, TableDataInfo} from '/@/views/system/tools/gen/component/model';
|
||||
import {getRelationTable} from "/@/api/system/tools/gen";
|
||||
import {optionselect} from "/@/api/system/dict/type";
|
||||
export default defineComponent({
|
||||
@ -237,7 +227,7 @@ export default defineComponent({
|
||||
const info = inject<TableDataInfo>('tableData') as TableDataInfo;
|
||||
// 表格的高度
|
||||
const tableHeight = ref(document.documentElement.scrollHeight - 300 + 'px');
|
||||
const dictOptions = ref([])
|
||||
const dictOptions = ref(<DictOpt[]>[])
|
||||
const relationTable = ref<TableDataInfo[]>([])
|
||||
onBeforeMount(()=>{
|
||||
//获取字典选项
|
||||
|
@ -77,10 +77,11 @@
|
||||
<el-table-column prop="className" label="实体" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column prop="createTime" label="创建时间" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column prop="updateTime" label="更新时间" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column label="操作" width="300">
|
||||
<el-table-column label="操作" width="320">
|
||||
<template #default="scope">
|
||||
<el-button size="small" text type="primary" @click="handlePreview(scope.row)"><el-icon><ele-View /></el-icon>预览</el-button>
|
||||
<el-button size="small" text type="primary" @click="handleEditTable(scope.row)"><el-icon><ele-EditPen /></el-icon>编辑</el-button>
|
||||
<el-button size="small" text type="primary" @click="handleSyncTable(scope.row)"><el-icon><ele-Refresh /></el-icon>同步</el-button>
|
||||
<el-button size="small" text type="primary" @click="handleGenTable(scope.row)"><el-icon><ele-Download /></el-icon>生成代码</el-button>
|
||||
<el-button size="small" text type="primary" @click="onRowDel(scope.row)"><el-icon><ele-DeleteFilled /></el-icon>删除</el-button>
|
||||
</template>
|
||||
@ -102,7 +103,7 @@
|
||||
<script lang="ts">
|
||||
import {toRefs, reactive, onMounted, ref, defineComponent} from 'vue';
|
||||
import {ElMessageBox, ElMessage, FormInstance} from 'element-plus';
|
||||
import {getTableList,deleteTables,batchGenCode} from "/@/api/system/tools/gen";
|
||||
import {getTableList, deleteTables, batchGenCode, syncTable} from "/@/api/system/tools/gen";
|
||||
import {TableData,TableDataState} from "/@/views/system/tools/gen/component/model"
|
||||
import importTable from "/@/views/system/tools/gen/component/importTable.vue";
|
||||
import { useRouter } from 'vue-router';
|
||||
@ -244,6 +245,14 @@ export default defineComponent({
|
||||
const tableId = row?.tableId || state.ids[0];
|
||||
router.push({ path: "/system/tools/gen/edit", query: { tableId: tableId } });
|
||||
}
|
||||
const handleSyncTable=((row:TableData)=>{
|
||||
const tableId = row?.tableId || state.ids[0];
|
||||
syncTable(tableId).then((res:any)=>{
|
||||
if (res.code === 0) {
|
||||
ElMessage.success('同步成功');
|
||||
}
|
||||
})
|
||||
})
|
||||
return {
|
||||
addPostRef,
|
||||
editPostRef,
|
||||
@ -260,6 +269,7 @@ export default defineComponent({
|
||||
openImportTable,
|
||||
handleEditTable,
|
||||
handlePreview,
|
||||
handleSyncTable,
|
||||
...toRefs(state),
|
||||
};
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user