生成主机秘钥卡片视图.

This commit is contained in:
lijiahangmax
2023-10-07 23:24:12 +08:00
parent da6e1e2eee
commit 34ef997514
18 changed files with 281 additions and 40 deletions

View File

@@ -18,6 +18,7 @@ import com.orion.ops.framework.mybatis.core.domain.BaseDO;
import com.orion.ops.framework.mybatis.core.mapper.IMapper;
import com.orion.ops.launch.generator.engine.VelocityTemplateEngine;
import com.orion.ops.launch.generator.template.Table;
import com.orion.ops.launch.generator.template.Template;
import org.apache.ibatis.annotations.Mapper;
import java.io.File;
@@ -41,7 +42,7 @@ public class CodeGenerator {
// 作者
String author = Const.ORION_AUTHOR;
// 模块
String module = "infra";
String module = "asset";
// 生成的表
Table[] tables = {
// Template.create("preference", "用户偏好", "preference")
@@ -55,6 +56,11 @@ public class CodeGenerator {
// .values("value", 1, 2)
// .color("blue", "green")
// .build(),
Template.create("host_key", "主机秘钥", "host")
.vue("asset", "host-key")
.enableCardView()
.enableDrawerForm()
.build()
};
// jdbc 配置 - 使用配置文件
File yamlFile = new File("orion-ops-launch/src/main/resources/application-dev.yaml");

View File

@@ -138,13 +138,13 @@ public class VelocityTemplateEngine extends AbstractTemplateEngine {
@NotNull TableInfo tableInfo) {
// 生成文件副本
List<CustomFile> files = originCustomerFile.stream().map(s ->
new CustomFile.Builder()
.enableFileOverride()
.templatePath(s.getTemplatePath())
.filePath(s.getFilePath())
.fileName(s.getFileName())
.packageName(s.getPackageName())
.build())
new CustomFile.Builder()
.enableFileOverride()
.templatePath(s.getTemplatePath())
.filePath(s.getFilePath())
.fileName(s.getFileName())
.packageName(s.getPackageName())
.build())
.collect(Collectors.toList());
// 获取 table
Table table = tables.get(tableInfo.getName());
@@ -324,7 +324,7 @@ public class VelocityTemplateEngine extends AbstractTemplateEngine {
.collect(Collectors.toList());
// 设置前端元数据
Table table = tables.get(tableInfo.getName());
Map<String, Object> vueMeta = this.pickTableMeta(table, "enableDrawerForm", "enableRowSelection", "module", "feature");
Map<String, Object> vueMeta = this.pickTableMeta(table, "module", "feature", "enableDrawerForm", "enableRowSelection", "enableCardView");
// 模块名称实体
vueMeta.put("moduleEntity", VariableStyles.SPINE.toBigHump(table.getModule()));
// 模块名称实体

View File

@@ -270,7 +270,7 @@ public class ${table.serviceImplName} implements ${table.serviceName} {
#end
.and(Strings.isNotEmpty(searchValue), c -> c
#foreach($field in ${table.fields})
.eq(${type}DO::get${field.capitalName}, searchValue)
.eq(${type}DO::get${field.capitalName}, searchValue)#if($foreach.hasNext).or()#end
#end
);
}

View File

@@ -26,4 +26,5 @@ VALUES
(@TMP_SUB_ID, '创建$table.comment', '${package.ModuleName}:${typeHyphen}:create', 3, 20),
(@TMP_SUB_ID, '修改$table.comment', '${package.ModuleName}:${typeHyphen}:update', 3, 30),
(@TMP_SUB_ID, '删除$table.comment', '${package.ModuleName}:${typeHyphen}:delete', 3, 40),
(@TMP_SUB_ID, '导出$table.comment', '${package.ModuleName}:${typeHyphen}:export', 3, 50);
(@TMP_SUB_ID, '导出$table.comment', '${package.ModuleName}:${typeHyphen}:export', 3, 50),
(@TMP_SUB_ID, '导入$table.comment', '${package.ModuleName}:${typeHyphen}:import', 3, 60);

View File

@@ -1,5 +1,6 @@
<template>
<card-list v-model:searchValue="formModel.searchValue"
search-input-placeholder="输入xxx"
create-card-position="head"
:card-height="172"
:loading="loading"
@@ -13,6 +14,10 @@
@reset="reset"
@search="fetchCardData"
@page-change="fetchCardData">
<!-- 标题 -->
<template #title="{ record }">
{{ record.id }}
</template>
<!-- 拓展操作 -->
<template #extra="{ record }">
<a-space>
@@ -44,7 +49,7 @@
size="small"
ref="formRef"
label-align="right"
:style="{ width: '300px' }"
:style="{ width: '320px' }"
:label-col-props="{ span: 6 }"
:wrapper-col-props="{ span: 18 }">
#foreach($field in ${table.fields})
@@ -88,7 +93,7 @@
import { usePagination, useColLayout } from '@/types/card';
import { computed, reactive, ref } from 'vue';
import useLoading from '@/hooks/loading';
import { dataColor, objectTruthKeyCount, resetObject } from '@/utils';
import { objectTruthKeyCount, resetObject } from '@/utils';
import fieldConfig from '../types/card.fields';
import { delete${vue.featureEntity}, get${vue.featureEntity}Page, ${vue.featureEntity}QueryRequest, ${vue.featureEntity}QueryResponse } from '@/api/${vue.module}/${vue.feature}';
import { Message } from '@arco-design/web-vue';
@@ -142,7 +147,7 @@
// 重置条件
const reset = () => {
resetObject(formModel']);
resetObject(formModel);
fetchCardData();
};

View File

@@ -12,7 +12,7 @@
@openAdd="() =>#if($vue.enableDrawerForm) drawer#else modal#end.openAdd()"
@openUpdate="(e) =>#if($vue.enableDrawerForm) drawer#else modal#end.openUpdate(e)" />
#else
<!-- 表-表格 -->
<!-- 表-表格 -->
<${vue.feature}-table ref="table"
@openAdd="() =>#if($vue.enableDrawerForm) drawer#else modal#end.openAdd()"
@openUpdate="(e) =>#if($vue.enableDrawerForm) drawer#else modal#end.openUpdate(e)" />
@@ -21,12 +21,12 @@
<!-- 添加修改模态框 -->
<${vue.feature}-form-drawer ref="drawer"
@added="modalAddCallback"
@updated="modalAddCallback" />
@updated="modalUpdateCallback" />
#else
<!-- 添加修改模态框 -->
<${vue.feature}-form-modal ref="modal"
@added="modalAddCallback"
@updated="modalAddCallback" />
@updated="modalUpdateCallback" />
#end
</div>
</template>
@@ -38,6 +38,12 @@
</script>
<script lang="ts" setup>
#if($vue.enableCardView)
import { computed, ref } from 'vue';
import { useAppStore } from '@/store';
#else
import { ref } from 'vue';
#end
#if($vue.enableCardView)
import ${vue.featureEntity}CardList from './components/${vue.feature}-card-list.vue';
#end
@@ -47,11 +53,6 @@
#else
import ${vue.featureEntity}FormModal from './components/${vue.feature}-form-modal.vue';
#end
#if($vue.enableCardView)
import { useAppStore } from '@/store';
#end
import { ref } from 'vue';
const table = ref();
#if($vue.enableCardView)

View File

@@ -1,11 +1,15 @@
import { CardField, CardFieldConfig } from '@/types/card';
import { dateFormat } from '@/utils';
export const fieldConfig = {
const fieldConfig = {
rowGap: '10px',
labelSpan: 8,
fields: [
#foreach($field in ${table.fields}){
{
label: 'id',
dataIndex: 'id',
slotName: 'id',
}, #foreach($field in ${table.fields})#if("$!field.propertyName" != "id"){
label: '${field.comment}',
dataIndex: '${field.propertyName}',
slotName: '${field.propertyName}',
@@ -16,7 +20,30 @@ export const fieldConfig = {
return record.${field.propertyName} && dateFormat(new Date(record.${field.propertyName}));
},
#end
}, #end
}, #end#end{
label: '创建时间',
dataIndex: 'createTime',
slotName: 'createTime',
render: ({ record }) => {
return dateFormat(new Date(record.createTime));
},
}, {
label: '修改时间',
dataIndex: 'updateTime',
slotName: 'updateTime',
render: ({ record }) => {
return dateFormat(new Date(record.updateTime));
},
}, {
label: '创建人',
dataIndex: 'creator',
slotName: 'creator',
}, {
label: '修改人',
dataIndex: 'updater',
slotName: 'updater',
}
] as CardField[]
} as CardFieldConfig;
export default fieldConfig;