代码生成模板:新增Vue路由表单、新增Vue弹窗表单、新增仅后端模板
This commit is contained in:
@@ -5,10 +5,8 @@
|
|||||||
<config>
|
<config>
|
||||||
<!-- 模板分类 -->
|
<!-- 模板分类 -->
|
||||||
<tplCategory>
|
<tplCategory>
|
||||||
<category value="crud" label="单表/主子表 (增删改查)">
|
<category value="crud" label="单表/主子表 (增删改查) beetl">
|
||||||
<template>category-ref:dao</template>
|
<template>category-ref:crud_java</template>
|
||||||
<template>crud/service.xml</template>
|
|
||||||
<template>crud/controller.xml</template>
|
|
||||||
<template>crud/viewList.xml</template>
|
<template>crud/viewList.xml</template>
|
||||||
<template>crud/viewForm.xml</template>
|
<template>crud/viewForm.xml</template>
|
||||||
<template>crud/viewIndex.xml</template>
|
<template>crud/viewIndex.xml</template>
|
||||||
@@ -16,10 +14,8 @@
|
|||||||
<template>category-ref:dao</template>
|
<template>category-ref:dao</template>
|
||||||
</childTable>
|
</childTable>
|
||||||
</category>
|
</category>
|
||||||
<category value="crud_vue" label="单表/主子表 (增删改查)Vue">
|
<category value="crud_vue" label="单表/主子表 (增删改查) vue">
|
||||||
<template>category-ref:dao</template>
|
<template>category-ref:crud_java</template>
|
||||||
<template>crud/service.xml</template>
|
|
||||||
<template>crud/controller.xml</template>
|
|
||||||
<template>crud/vueApi.xml</template>
|
<template>crud/vueApi.xml</template>
|
||||||
<template>crud/vueList.xml</template>
|
<template>crud/vueList.xml</template>
|
||||||
<template>crud/vueForm.xml</template>
|
<template>crud/vueForm.xml</template>
|
||||||
@@ -29,95 +25,126 @@
|
|||||||
<template>category-ref:dao</template>
|
<template>category-ref:dao</template>
|
||||||
</childTable>
|
</childTable>
|
||||||
</category>
|
</category>
|
||||||
<category value="crud_only_vue" label="单表/主子表 (增删改查)仅Vue">
|
<category value="crud_only_vue" label="单表/主子表 (增删改查) 仅vue">
|
||||||
<template>crud/vueApi.xml</template>
|
<template>crud/vueApi.xml</template>
|
||||||
<template>crud/vueList.xml</template>
|
<template>crud/vueList.xml</template>
|
||||||
<template>crud/vueForm.xml</template>
|
<template>crud/vueForm.xml</template>
|
||||||
<template>crud/vueIndex.xml</template>
|
<template>crud/vueIndex.xml</template>
|
||||||
<template>crud/vueImport.xml</template>
|
<template>crud/vueImport.xml</template>
|
||||||
</category>
|
</category>
|
||||||
<category value="crud_select" label="单表/主子表 (增删改查,含 listselect 选择页面)">
|
<category value="crud_only_vue_modal" label="单表/主子表 (增删改查,弹窗表单) 仅vue ">
|
||||||
|
<template>category-ref:crud_only_vue</template>
|
||||||
|
</category>
|
||||||
|
<category value="crud_only_vue_modal_route" label="单表/主子表 (增删改查,路由表单) 仅vue ">
|
||||||
|
<template>crud/vueApi.xml</template>
|
||||||
|
<template>crud/vueList.xml</template>
|
||||||
|
<!--<template>crud/vueForm.xml</template>-->
|
||||||
|
<template>crud/vueFormRoute.xml</template>
|
||||||
|
<template>crud/vueIndex.xml</template>
|
||||||
|
<template>crud/vueImport.xml</template>
|
||||||
|
</category>
|
||||||
|
<category value="crud_select" label="单表/主子表 (增删改查,含 listselect 选择页面) beetl">
|
||||||
<template>category-ref:crud</template>
|
<template>category-ref:crud</template>
|
||||||
<template>crud/viewSelect.xml</template>
|
<template>crud/viewSelect.xml</template>
|
||||||
<childTable>
|
<childTable>
|
||||||
<template>category-ref:dao</template>
|
<template>category-ref:dao</template>
|
||||||
</childTable>
|
</childTable>
|
||||||
</category>
|
</category>
|
||||||
<category value="crud_select_vue" label="单表/主子表 (增删改查,含 listselect 选择页面)Vue">
|
<category value="crud_select_vue" label="单表/主子表 (增删改查,含 listselect 选择页面) vue">
|
||||||
<template>category-ref:crud_vue</template>
|
<template>category-ref:crud_vue</template>
|
||||||
<template>crud/vueSelect.xml</template>
|
<template>crud/vueSelect.xml</template>
|
||||||
<childTable>
|
<childTable>
|
||||||
<template>category-ref:dao</template>
|
<template>category-ref:dao</template>
|
||||||
</childTable>
|
</childTable>
|
||||||
</category>
|
</category>
|
||||||
<category value="crud_cloud" label="单表/主子表 (增删改查 Cloud,生成 Api/Client)">
|
<category value="crud_java" label="单表/主子表 (增删改查,只生成 java/mapper) 仅后端 ">
|
||||||
<template>crud_cloud/entity.xml</template>
|
<template>category-ref:dao</template>
|
||||||
<template>crud_cloud/mapper.xml</template>
|
<template>crud/service.xml</template>
|
||||||
<template>crud_cloud/dao.xml</template>
|
<template>crud/controller.xml</template>
|
||||||
<template>crud_cloud/api.xml</template>
|
<childTable>
|
||||||
<template>crud_cloud/client.xml</template>
|
<template>category-ref:dao</template>
|
||||||
<template>crud_cloud/service.xml</template>
|
</childTable>
|
||||||
<template>crud_cloud/controller.xml</template>
|
</category>
|
||||||
|
<category value="crud_cloud" label="单表/主子表 (增删改查 Cloud,生成 api/client) beetl">
|
||||||
|
<template>category-ref:crud_cloud_java</template>
|
||||||
<template>crud_cloud/viewList.xml</template>
|
<template>crud_cloud/viewList.xml</template>
|
||||||
<template>crud_cloud/viewForm.xml</template>
|
<template>crud_cloud/viewForm.xml</template>
|
||||||
<template>crud_cloud/viewIndex.xml</template>
|
<template>crud_cloud/viewIndex.xml</template>
|
||||||
<childTable>
|
<childTable>
|
||||||
<template>crud_cloud/mapper.xml</template>
|
<template>category-ref:dao_cloud</template>
|
||||||
<template>crud_cloud/entity.xml</template>
|
|
||||||
<template>crud_cloud/dao.xml</template>
|
|
||||||
</childTable>
|
</childTable>
|
||||||
</category>
|
</category>
|
||||||
<category value="crud_cloud_vue" label="单表/主子表 (增删改查 Cloud,生成 Api/Client)Vue">
|
<category value="crud_cloud_vue" label="单表/主子表 (增删改查 Cloud,生成 api/client) Vue">
|
||||||
<template>crud_cloud/entity.xml</template>
|
<template>category-ref:crud_cloud_java</template>
|
||||||
<template>crud_cloud/mapper.xml</template>
|
|
||||||
<template>crud_cloud/dao.xml</template>
|
|
||||||
<template>crud_cloud/api.xml</template>
|
|
||||||
<template>crud_cloud/client.xml</template>
|
|
||||||
<template>crud_cloud/service.xml</template>
|
|
||||||
<template>crud_cloud/controller.xml</template>
|
|
||||||
<template>crud/vueApi.xml</template>
|
<template>crud/vueApi.xml</template>
|
||||||
<template>crud/vueList.xml</template>
|
<template>crud/vueList.xml</template>
|
||||||
<template>crud/vueIndex.xml</template>
|
<template>crud/vueIndex.xml</template>
|
||||||
<template>crud/vueForm.xml</template>
|
<template>crud/vueForm.xml</template>
|
||||||
<template>crud/vueImport.xml</template>
|
<template>crud/vueImport.xml</template>
|
||||||
<childTable>
|
<childTable>
|
||||||
<template>crud_cloud/mapper.xml</template>
|
<template>category-ref:dao_cloud</template>
|
||||||
<template>crud_cloud/entity.xml</template>
|
|
||||||
<template>crud_cloud/dao.xml</template>
|
|
||||||
</childTable>
|
</childTable>
|
||||||
</category>
|
</category>
|
||||||
<category value="crud_cloud_select" label="单表/主子表 (增删改查 Cloud,含 listselect 选择页面)">
|
<category value="crud_cloud_select" label="单表/主子表 (增删改查 Cloud,含 listselect 选择页面) beetl">
|
||||||
<template>category-ref:crud_cloud</template>
|
<template>category-ref:crud_cloud</template>
|
||||||
<template>crud_cloud/viewSelect.xml</template>
|
<template>crud_cloud/viewSelect.xml</template>
|
||||||
<childTable>
|
<childTable>
|
||||||
<template>category-ref:dao</template>
|
<template>category-ref:dao_cloud</template>
|
||||||
</childTable>
|
</childTable>
|
||||||
</category>
|
</category>
|
||||||
<category value="treeGrid" label="树表/树结构表(增删改查)">
|
<category value="crud_cloud_select_vue" label="单表/主子表 (增删改查 Cloud,含 listselect 选择页面) vue">
|
||||||
|
<template>category-ref:crud_cloud</template>
|
||||||
|
<template>crud/vueSelect.xml</template>
|
||||||
|
<childTable>
|
||||||
|
<template>category-ref:dao_cloud</template>
|
||||||
|
</childTable>
|
||||||
|
</category>
|
||||||
|
<category value="crud_cloud_java" label="单表/主子表 (增删改查 Cloud,只生成 java/mapper) 仅后端">
|
||||||
|
<template>category-ref:dao_cloud</template>
|
||||||
|
<template>crud_cloud/api.xml</template>
|
||||||
|
<template>crud_cloud/client.xml</template>
|
||||||
|
<template>crud_cloud/service.xml</template>
|
||||||
|
<template>crud_cloud/controller.xml</template>
|
||||||
|
<childTable>
|
||||||
|
<template>category-ref:dao_cloud</template>
|
||||||
|
</childTable>
|
||||||
|
</category>
|
||||||
|
<category value="treeGrid" label="树表/树结构表(增删改查) beetl">
|
||||||
<template>category-ref:crud</template>
|
<template>category-ref:crud</template>
|
||||||
</category>
|
</category>
|
||||||
<category value="treeGrid_vue" label="树表/树结构表(增删改查)Vue">
|
<category value="treeGrid_vue" label="树表/树结构表(增删改查) vue">
|
||||||
<template>category-ref:crud_vue</template>
|
<template>category-ref:crud_vue</template>
|
||||||
</category>
|
</category>
|
||||||
<category value="treeGrid_only_vue" label="树表/树结构表(增删改查)仅Vue">
|
<category value="treeGrid_only_vue" label="树表/树结构表(增删改查) 仅vue">
|
||||||
<template>category-ref:crud_only_vue</template>
|
<template>category-ref:crud_only_vue</template>
|
||||||
</category>
|
</category>
|
||||||
<category value="treeGrid_cloud" label="树表/树结构表(增删改查 Cloud,生成 Api/Client)">
|
<category value="treeGrid_java" label="树表/树结构表(增删改查,只生成 java/mapper) 仅后端">
|
||||||
|
<template>category-ref:crud_java</template>
|
||||||
|
</category>
|
||||||
|
<category value="treeGrid_cloud" label="树表/树结构表(增删改查 Cloud,含 api/client) beetl">
|
||||||
<template>category-ref:crud_cloud</template>
|
<template>category-ref:crud_cloud</template>
|
||||||
</category>
|
</category>
|
||||||
<category value="treeGrid_cloud_vue" label="树表/树结构表(增删改查 Cloud,生成 Api/Client)Vue">
|
<category value="treeGrid_cloud_vue" label="树表/树结构表(增删改查 Cloud,含 api/client) vue">
|
||||||
<template>category-ref:crud_cloud_vue</template>
|
<template>category-ref:crud_cloud_vue</template>
|
||||||
</category>
|
</category>
|
||||||
<category value="service" label="业务层和持久层(dao/service,不含控制器和视图)">
|
<category value="treeGrid_cloud_java" label="树表/树结构表(增删改查 Cloud,只生成 java/mapper) 仅后端">
|
||||||
|
<template>category-ref:crud_cloud_java</template>
|
||||||
|
</category>
|
||||||
|
<category value="service" label="仅持久层和业务层(只生成 java/dao层/service层)">
|
||||||
<template>category-ref:dao</template>
|
<template>category-ref:dao</template>
|
||||||
<template>crud/service.xml</template>
|
<template>crud/service.xml</template>
|
||||||
</category>
|
</category>
|
||||||
<category value="dao" label="关系表/仅持久层(dao/mapper/entity)">
|
<category value="dao" label="仅持久层(只生成 java/entity/mapper/dao 文件)">
|
||||||
<template>crud/entity.xml</template>
|
<template>crud/entity.xml</template>
|
||||||
<template>crud/mapper.xml</template>
|
<template>crud/mapper.xml</template>
|
||||||
<template>crud/dao.xml</template>
|
<template>crud/dao.xml</template>
|
||||||
</category>
|
</category>
|
||||||
<category value="query" label="仅查询功能(不含增删改,仅数据展现)">
|
<category value="dao_cloud" label="仅持久层(只生成 Cloud 版 java/entity/mapper/dao 文件)">
|
||||||
|
<template>crud_cloud/entity.xml</template>
|
||||||
|
<template>crud_cloud/mapper.xml</template>
|
||||||
|
<template>crud_cloud/dao.xml</template>
|
||||||
|
</category>
|
||||||
|
<category value="query" label="仅查询功能(不含增删改,只生成数据查询列表和详情)">
|
||||||
<template>crud/entity.xml</template>
|
<template>crud/entity.xml</template>
|
||||||
<template>crud/mapper.xml</template>
|
<template>crud/mapper.xml</template>
|
||||||
<template>query/dao.xml</template>
|
<template>query/dao.xml</template>
|
||||||
|
|||||||
@@ -6,17 +6,18 @@
|
|||||||
<filePath>${frontDir}/src/views/${urlPrefix}</filePath>
|
<filePath>${frontDir}/src/views/${urlPrefix}</filePath>
|
||||||
<fileName>form.vue</fileName>
|
<fileName>form.vue</fileName>
|
||||||
<content><![CDATA[
|
<content><![CDATA[
|
||||||
|
<% var modalOrDrawer = @StringUtils.contains(table.tplCategory, '_modal') ? 'Modal' : 'Drawer'; %>
|
||||||
<!--
|
<!--
|
||||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||||
* No deletion without permission, or be held responsible to law.
|
* No deletion without permission, or be held responsible to law.
|
||||||
* @author ${functionAuthor}
|
* @author ${functionAuthor}
|
||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<BasicDrawer
|
<Basic${modalOrDrawer}
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
:showFooter="true"
|
:showFooter="true"
|
||||||
:okAuth="'${permissionPrefix}:edit'"
|
:okAuth="'${permissionPrefix}:edit'"
|
||||||
@register="registerDrawer"
|
@register="register${modalOrDrawer}"
|
||||||
@ok="handleSubmit"
|
@ok="handleSubmit"
|
||||||
width="60%"
|
width="60%"
|
||||||
>
|
>
|
||||||
@@ -56,11 +57,11 @@
|
|||||||
@validate="handleValidate"
|
@validate="handleValidate"
|
||||||
@complete="handleSubmit"
|
@complete="handleSubmit"
|
||||||
@success="handleSuccess"
|
@success="handleSuccess"
|
||||||
@close="closeDrawer"
|
@close="close${modalOrDrawer}"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<% } %>
|
<% } %>
|
||||||
</BasicDrawer>
|
</Basic${modalOrDrawer}>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup name="${compNamePrefix}Form">
|
<script lang="ts" setup name="${compNamePrefix}Form">
|
||||||
import { ref, unref, computed } from 'vue';
|
import { ref, unref, computed } from 'vue';
|
||||||
@@ -72,7 +73,7 @@
|
|||||||
<% if (table.childList.~size > 0){ %>
|
<% if (table.childList.~size > 0){ %>
|
||||||
import { BasicTable, useTable } from '/@/components/Table';
|
import { BasicTable, useTable } from '/@/components/Table';
|
||||||
<% } %>
|
<% } %>
|
||||||
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
|
import { Basic${modalOrDrawer}, use${modalOrDrawer}Inner } from '/@/components/${modalOrDrawer}';
|
||||||
import { ${ClassName}, ${className}Save, ${className}Form<% if(table.isTreeEntity){ %>, ${className}TreeData<% } %> } from '/@/api/${moduleName}${isNotEmpty(subModuleName)?'/'+subModuleName:''}/${className}';
|
import { ${ClassName}, ${className}Save, ${className}Form<% if(table.isTreeEntity){ %>, ${className}TreeData<% } %> } from '/@/api/${moduleName}${isNotEmpty(subModuleName)?'/'+subModuleName:''}/${className}';
|
||||||
<%
|
<%
|
||||||
var userselectExists = false;
|
var userselectExists = false;
|
||||||
@@ -106,14 +107,14 @@ for(c in table.columnList){
|
|||||||
const { showMessage } = useMessage();
|
const { showMessage } = useMessage();
|
||||||
const { meta } = unref(router.currentRoute);
|
const { meta } = unref(router.currentRoute);
|
||||||
const record = ref<${ClassName}>({} as ${ClassName});
|
const record = ref<${ClassName}>({} as ${ClassName});
|
||||||
|
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||||
|
const loadingRef = ref(false);
|
||||||
|
<% } %>
|
||||||
|
|
||||||
const getTitle = computed(() => ({
|
const getTitle = computed(() => ({
|
||||||
icon: meta.icon || 'ant-design:book-outlined',
|
icon: meta.icon || 'ant-design:book-outlined',
|
||||||
value: record.value.isNewRecord ? t('新增${functionNameSimple}') : t('编辑${functionNameSimple}'),
|
value: record.value.isNewRecord ? t('新增${functionNameSimple}') : t('编辑${functionNameSimple}'),
|
||||||
}));
|
}));
|
||||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
|
||||||
|
|
||||||
const loadingRef = ref(false);
|
|
||||||
<% } %>
|
|
||||||
|
|
||||||
const inputFormSchemas: FormSchema[] = [
|
const inputFormSchemas: FormSchema[] = [
|
||||||
<% if(table.isTreeEntity){ %>
|
<% if(table.isTreeEntity){ %>
|
||||||
@@ -217,7 +218,7 @@ for (c in table.columnList){
|
|||||||
},
|
},
|
||||||
<% }else{ %>
|
<% }else{ %>
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
<% }
|
<% }
|
||||||
var fieldValid = c.optionMap['fieldValid'], fvs = [], rules = [];
|
var fieldValid = c.optionMap['fieldValid'], fvs = [], rules = [];
|
||||||
if(isNotEmpty(fieldValid)){
|
if(isNotEmpty(fieldValid)){
|
||||||
var t = type.name(fieldValid);
|
var t = type.name(fieldValid);
|
||||||
@@ -280,7 +281,7 @@ for (c in table.columnList){
|
|||||||
}
|
}
|
||||||
} else { %>
|
} else { %>
|
||||||
rules: [<%
|
rules: [<%
|
||||||
if(c.isRequired == '1'){
|
if(c.isRequired == '1'){
|
||||||
%>{ required: true }, <%
|
%>{ required: true }, <%
|
||||||
}
|
}
|
||||||
for (var rule in rules){
|
for (var rule in rules){
|
||||||
@@ -595,8 +596,8 @@ for (c in table.columnList){
|
|||||||
}
|
}
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
const [register${modalOrDrawer}, { set${modalOrDrawer}Props, close${modalOrDrawer} }] = use${modalOrDrawer}Inner(async (data) => {
|
||||||
setDrawerProps({ loading: true });
|
set${modalOrDrawer}Props({ loading: true });
|
||||||
await resetFields();
|
await resetFields();
|
||||||
const res = await ${className}Form(data);
|
const res = await ${className}Form(data);
|
||||||
record.value = (res.${className} || {}) as ${ClassName};
|
record.value = (res.${className} || {}) as ${ClassName};
|
||||||
@@ -614,11 +615,11 @@ for (c in table.columnList){
|
|||||||
<% if(updateSchemas.~size > 0){ %>
|
<% if(updateSchemas.~size > 0){ %>
|
||||||
updateSchema([
|
updateSchema([
|
||||||
<% for(updateSchema in updateSchemas){
|
<% for(updateSchema in updateSchemas){
|
||||||
print(updateSchema + '\n');
|
print(updateSchema + '\n');
|
||||||
} %>
|
} %>
|
||||||
]);
|
]);
|
||||||
<% } %>
|
<% } %>
|
||||||
setDrawerProps({ loading: false });
|
set${modalOrDrawer}Props({ loading: false });
|
||||||
});
|
});
|
||||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||||
|
|
||||||
@@ -638,14 +639,14 @@ for (c in table.columnList){
|
|||||||
async function handleSubmit(<% if(toBoolean(table.optionMap['isBpmForm'])){ %>event: any<% } %>) {
|
async function handleSubmit(<% if(toBoolean(table.optionMap['isBpmForm'])){ %>event: any<% } %>) {
|
||||||
try {
|
try {
|
||||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||||
const data = event.formData; // 接受 BpmButton 传递过来的表单数据
|
loadingRef.value = true;
|
||||||
|
const data = event?.formData || (await validate()); // 接受 BpmButton 传递过来的表单数据
|
||||||
data.bpm = Object.assign(data.bpm || {}, record.value.bpm); // 流程信息
|
data.bpm = Object.assign(data.bpm || {}, record.value.bpm); // 流程信息
|
||||||
data.status = record.value.status; // 提交状态
|
data.status = record.value.status; // 提交状态
|
||||||
loadingRef.value = true;
|
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
const data = await validate();
|
const data = await validate();
|
||||||
<% } %>
|
<% } %>
|
||||||
setDrawerProps({ confirmLoading: true });
|
set${modalOrDrawer}Props({ confirmLoading: true });
|
||||||
const params: any = {
|
const params: any = {
|
||||||
isNewRecord: record.value.isNewRecord,
|
isNewRecord: record.value.isNewRecord,
|
||||||
<%
|
<%
|
||||||
@@ -666,7 +667,7 @@ for (c in table.columnList){
|
|||||||
// console.log('submit', params, data, record);
|
// console.log('submit', params, data, record);
|
||||||
const res = await ${className}Save(params, data);
|
const res = await ${className}Save(params, data);
|
||||||
showMessage(res.message);
|
showMessage(res.message);
|
||||||
setTimeout(closeDrawer);
|
setTimeout(close${modalOrDrawer});
|
||||||
emit('success', data);
|
emit('success', data);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (error && error.errorFields) {
|
if (error && error.errorFields) {
|
||||||
@@ -677,7 +678,7 @@ for (c in table.columnList){
|
|||||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||||
loadingRef.value = false;
|
loadingRef.value = false;
|
||||||
<% } %>
|
<% } %>
|
||||||
setDrawerProps({ confirmLoading: false });
|
set${modalOrDrawer}Props({ confirmLoading: false });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||||
|
|||||||
@@ -0,0 +1,748 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||||
|
No deletion without permission, or be held responsible to law. -->
|
||||||
|
<template>
|
||||||
|
<name>vueFormRoute</name>
|
||||||
|
<filePath>${frontDir}/src/views/${urlPrefix}</filePath>
|
||||||
|
<fileName>formRoute.vue</fileName>
|
||||||
|
<content><![CDATA[
|
||||||
|
<!--
|
||||||
|
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||||
|
* No deletion without permission, or be held responsible to law.
|
||||||
|
* @author ${functionAuthor}
|
||||||
|
-->
|
||||||
|
<template>
|
||||||
|
<FormPage
|
||||||
|
:config="formSettings"
|
||||||
|
:storeKey="'${moduleName}${isNotEmpty(subModuleName)?'-'+subModuleName:''}-${className}-route'"
|
||||||
|
:okAuth="'${permissionPrefix}:edit'"
|
||||||
|
:loading="loadingRef"
|
||||||
|
@close="handleClose"
|
||||||
|
@ok="handleSubmit"
|
||||||
|
>
|
||||||
|
<template #main>
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
</template>
|
||||||
|
<% for (child in table.childList){ %>
|
||||||
|
<template #${@StringUtils.uncap(child.className)}>
|
||||||
|
<BasicForm @register="register${child.className}Form">
|
||||||
|
<template #${@StringUtils.uncap(child.className)}List>
|
||||||
|
<BasicTable
|
||||||
|
@register="register${child.className}Table"
|
||||||
|
@row-click="handle${child.className}RowClick"
|
||||||
|
/>
|
||||||
|
<% if(table.tplCategory != 'query'){ %>
|
||||||
|
<a-button class="mt-2" @click="handle${child.className}Add" v-auth="'${permissionPrefix}:edit'">
|
||||||
|
<Icon icon="ant-design:plus-circle-outlined" /> {{ t('新增') }}
|
||||||
|
</a-button>
|
||||||
|
<% } %>
|
||||||
|
</template>
|
||||||
|
</BasicForm>
|
||||||
|
</template>
|
||||||
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||||
|
<template #actions>
|
||||||
|
<BpmButton
|
||||||
|
v-model:bpmEntity="record"
|
||||||
|
bpmEntityKey="id"
|
||||||
|
formKey="${table.optionMap['bpmFormKey']}"
|
||||||
|
completeText="提交"
|
||||||
|
:completeModal="true"
|
||||||
|
:loading="loadingRef"
|
||||||
|
:auth="'${permissionPrefix}:edit'"
|
||||||
|
@validate="handleValidate"
|
||||||
|
@complete="handleSubmit"
|
||||||
|
@success="handleSuccess"
|
||||||
|
@close="handleClose"
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<% } %>
|
||||||
|
<template #other>
|
||||||
|
<div>其它选项的内容,按需添加,也可以删除。</div>
|
||||||
|
</template>
|
||||||
|
</FormPage>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup name="${compNamePrefix}Form">
|
||||||
|
import { ref, unref, computed, onMounted } from 'vue';
|
||||||
|
import { useEmitter } from '/@/store/modules/user';
|
||||||
|
import { useI18n } from '/@/hooks/web/useI18n';
|
||||||
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
import { router } from '/@/router';
|
||||||
|
import { Icon } from '/@/components/Icon';
|
||||||
|
import { FormPage } from '/@/components/FormPage';
|
||||||
|
import { BasicForm, FormSchema, useForm } from '/@/components/Form';
|
||||||
|
<% if (table.childList.~size > 0){ %>
|
||||||
|
import { BasicTable, useTable } from '/@/components/Table';
|
||||||
|
<% } %>
|
||||||
|
import { ${ClassName}, ${className}Save, ${className}Form<% if(table.isTreeEntity){ %>, ${className}TreeData<% } %> } from '/@/api/${moduleName}${isNotEmpty(subModuleName)?'/'+subModuleName:''}/${className}';
|
||||||
|
<%
|
||||||
|
var userselectExists = false;
|
||||||
|
var officeselectExists = false;
|
||||||
|
var areaselectExists = false;
|
||||||
|
for(c in table.columnList){
|
||||||
|
if(c.isQuery == "1" && !c.isTreeEntityColumn){
|
||||||
|
if(c.showType == 'userselect'){
|
||||||
|
userselectExists = true;
|
||||||
|
}else if(c.showType == 'officeselect'){
|
||||||
|
officeselectExists = true;
|
||||||
|
}else if(c.showType == 'areaselect'){
|
||||||
|
areaselectExists = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
<% if(userselectExists || officeselectExists) { %>
|
||||||
|
import { officeTreeData } from '/@/api/sys/office';
|
||||||
|
<% } %>
|
||||||
|
<% if(areaselectExists) { %>
|
||||||
|
import { areaTreeData } from '/@/api/sys/area';
|
||||||
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||||
|
import { BpmButton } from '/@/components/Bpm';
|
||||||
|
<% } %>
|
||||||
|
import { useQuery } from '/@/hooks/web/usePage';
|
||||||
|
import { useTabs } from '/@/hooks/web/useTabs';
|
||||||
|
|
||||||
|
const formSettings = ref<any[]>([
|
||||||
|
{
|
||||||
|
label: '基础表单',
|
||||||
|
value: 'main',
|
||||||
|
show: true,
|
||||||
|
},
|
||||||
|
<% for (child in table.childList){ %>
|
||||||
|
{
|
||||||
|
label: '${child.comments}',
|
||||||
|
value: '${@StringUtils.uncap(child.className)}',
|
||||||
|
show: true,
|
||||||
|
},
|
||||||
|
<% } %>
|
||||||
|
{
|
||||||
|
label: '其它选项',
|
||||||
|
value: 'other',
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
const emitter = useEmitter();
|
||||||
|
|
||||||
|
const { t } = useI18n('${moduleName}${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${className}');
|
||||||
|
const { showMessage } = useMessage();
|
||||||
|
const { setTitle, close } = useTabs(router);
|
||||||
|
const record = ref<${ClassName}>({} as ${ClassName});
|
||||||
|
const loadingRef = ref<boolean>(false);
|
||||||
|
const query = useQuery();
|
||||||
|
|
||||||
|
const updateTabTitle = () => {
|
||||||
|
setTitle(record.value.isNewRecord ? t('新增${functionNameSimple}') : t('编辑${functionNameSimple}'));
|
||||||
|
};
|
||||||
|
|
||||||
|
const inputFormSchemas: FormSchema[] = [
|
||||||
|
<% if(table.isTreeEntity){ %>
|
||||||
|
{
|
||||||
|
label: t('上级${functionNameSimple}'),
|
||||||
|
field: 'parentCode',
|
||||||
|
fieldLabel: 'parentName',
|
||||||
|
component: 'TreeSelect',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
style: 'width: calc(50% - 60px)',
|
||||||
|
},
|
||||||
|
colProps: { lg: 24, md: 24 },
|
||||||
|
},
|
||||||
|
<% }
|
||||||
|
for (c in table.columnList){
|
||||||
|
if (c.isEdit == '1' && c.showType != 'hidden'){
|
||||||
|
// 如果是树结构的字段,则自动忽略
|
||||||
|
if(table.isTreeEntity && @StringUtils.inString(c.columnName, 'parent_code',
|
||||||
|
'parent_codes', 'tree_sorts', 'tree_leaf', 'tree_level', 'tree_names')
|
||||||
|
&& c.attrName != table.treeViewCodeAttrName
|
||||||
|
&& c.attrName != table.treeViewNameAttrName){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 是否强制新行获取,生成字段界面用户设定的
|
||||||
|
var isNewLine = @Global.YES.equals(c.optionMap['isNewLine']);
|
||||||
|
if (isBlank(c.optionMap['isNewLine'])){
|
||||||
|
if (c.showType == 'textarea'){
|
||||||
|
isNewLine = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
{
|
||||||
|
label: t('${c.columnLabel}'),
|
||||||
|
field: '${c.attrName}',
|
||||||
|
<% if(c.showType == 'input' || c.showType == 'textarea'){ %>
|
||||||
|
<% if (c.simpleAttrType == 'Integer' && c.attrName == 'treeSort'){ %>
|
||||||
|
helpMessage: '升序',
|
||||||
|
component: 'InputNumber',
|
||||||
|
defaultValue: '30',
|
||||||
|
<% }else{ %>
|
||||||
|
component: '${c.showType == 'input' ? 'Input' : 'InputTextArea'}',
|
||||||
|
<% } %>
|
||||||
|
<% if (c.dataLength != '0'){ %>
|
||||||
|
componentProps: {
|
||||||
|
maxlength: ${c.dataLength},
|
||||||
|
},
|
||||||
|
<% } %>
|
||||||
|
<% }else if(c.showType == 'select' || c.showType == 'select_multiple'){
|
||||||
|
var isMultiple = (c.showType == 'select_multiple'); %>
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
dictType: '${c.optionMap['dictType']}',
|
||||||
|
allowClear: true,
|
||||||
|
<% if(isMultiple){ %>
|
||||||
|
mode: 'multiple',
|
||||||
|
<% } %>
|
||||||
|
},
|
||||||
|
<% }else if(c.showType == 'radio' || c.showType == 'checkbox'){ %>
|
||||||
|
component: '${@StringUtils.cap(c.showType)}Group',
|
||||||
|
componentProps: {
|
||||||
|
dictType: '${c.optionMap['dictType']}',
|
||||||
|
},
|
||||||
|
<% }else if(c.showType == 'date' || c.showType == 'datetime'){
|
||||||
|
var isTime = (c.showType == 'datetime'); %>
|
||||||
|
component: 'DatePicker',
|
||||||
|
componentProps: {
|
||||||
|
format: 'YYYY-MM-DD${isTime?' HH:mm':''}',
|
||||||
|
showTime: ${isTime?'{ format: \'HH:mm\' \}':'false'},
|
||||||
|
},
|
||||||
|
<% }else if(c.showType == 'userselect'){
|
||||||
|
if (isNotBlank(c.attrName2)){ %>
|
||||||
|
fieldLabel: '${c.attrName2}',
|
||||||
|
<% } %>
|
||||||
|
component: 'TreeSelect',
|
||||||
|
componentProps: {
|
||||||
|
api: officeTreeData,
|
||||||
|
params: { isLoadUser: true, userIdPrefix: '' },
|
||||||
|
canSelectParent: false,
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
<% }else if(c.showType == 'officeselect'){
|
||||||
|
if (isNotBlank(c.attrName2)){ %>
|
||||||
|
fieldLabel: '${c.attrName2}',
|
||||||
|
<% } %>
|
||||||
|
component: 'TreeSelect',
|
||||||
|
componentProps: {
|
||||||
|
api: officeTreeData,
|
||||||
|
canSelectParent: false,
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
<% }else if(c.showType == 'areaselect'){
|
||||||
|
if (isNotBlank(c.attrName2)){ %>
|
||||||
|
fieldLabel: '${c.attrName2}',
|
||||||
|
<% } %>
|
||||||
|
component: 'TreeSelect',
|
||||||
|
componentProps: {
|
||||||
|
api: areaTreeData,
|
||||||
|
canSelectParent: false,
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
<% }else{ %>
|
||||||
|
component: 'Input',
|
||||||
|
<% }
|
||||||
|
var fieldValid = c.optionMap['fieldValid'], fvs = [], rules = [];
|
||||||
|
if(isNotEmpty(fieldValid)){
|
||||||
|
var t = type.name(fieldValid);
|
||||||
|
if (t == 'String[]' || t == 'ArrayList'){
|
||||||
|
fvs = fieldValid;
|
||||||
|
}else if(t == 'String' && isNotBlank(fieldValid)){
|
||||||
|
@fvs.add(fieldValid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(var fv in fvs){
|
||||||
|
if (fv == 'email'){
|
||||||
|
var s = { %>{ type: 'email', message: t('请输入邮箱地址') }<% };
|
||||||
|
@rules.add(s);
|
||||||
|
}
|
||||||
|
if (fv == 'number'){
|
||||||
|
var s = { %>{ pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/, message: t('请输入一个数值') }<% };
|
||||||
|
@rules.add(s);
|
||||||
|
}
|
||||||
|
if (fv == 'integer'){
|
||||||
|
var s = { %>{ pattern: /^-?\d+$/, message: t('请输入一个整数') }<% };
|
||||||
|
@rules.add(s);
|
||||||
|
}
|
||||||
|
if (fv == 'digits'){
|
||||||
|
var s = { %>{ pattern: /^\d+$/, message: t('请输入一个正整数') }<% };
|
||||||
|
@rules.add(s);
|
||||||
|
}
|
||||||
|
if (fv == 'userName'){
|
||||||
|
var s = { %>{ pattern: /^[\u0391-\uFFE5\w]+$/, message: t('请输入登录账号') }<% };
|
||||||
|
@rules.add(s);
|
||||||
|
}
|
||||||
|
if (fv == 'realName'){
|
||||||
|
var s = { %>{ pattern: /^[\u4e00-\u9fa5]{2,30}$/, message: t('请输入真实姓名') }<% };
|
||||||
|
@rules.add(s);
|
||||||
|
}
|
||||||
|
if (fv == 'abc'){
|
||||||
|
var s = { %>{ pattern: /^[a-zA-Z0-9_]*$/, message: t('请输入字母数字下划线') }<% };
|
||||||
|
@rules.add(s);
|
||||||
|
}
|
||||||
|
if (fv == 'mobile'){
|
||||||
|
var s = { %>{ pattern: /^1[3,4,5,6,7,8,9]\d{9}$/g, message: t('请输入手机号码') }<% };
|
||||||
|
@rules.add(s);
|
||||||
|
}
|
||||||
|
if (fv == 'simplePhone'){
|
||||||
|
var s = { %>{ pattern: /^(\d{3,4}-?)?\d{7,9}$/g, message: t('请输入固话号码') }<% };
|
||||||
|
@rules.add(s);
|
||||||
|
}
|
||||||
|
if (fv == 'phone'){
|
||||||
|
var s = { %>{ pattern: /(^0[1-9]{1}\d{8,10}$)|(^1[3,4,5,6,7,8,9]\d{9}$)/g, message: t('请输入固话或手机号码') }<% };
|
||||||
|
@rules.add(s);
|
||||||
|
}
|
||||||
|
if (fv == 'zipCode'){
|
||||||
|
var s = { %>{ pattern: /^[0-9]{6}$/, message: t('请输入邮政编码') }<% };
|
||||||
|
@rules.add(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(rules.~size == 0){
|
||||||
|
if(c.isRequired == '1'){
|
||||||
|
%> required: true,
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
} else { %>
|
||||||
|
rules: [<%
|
||||||
|
if(c.isRequired == '1'){
|
||||||
|
%>{ required: true }, <%
|
||||||
|
}
|
||||||
|
for (var rule in rules){
|
||||||
|
print(rule);
|
||||||
|
if (ruleLP.index < rules.~size) {
|
||||||
|
print(', ');
|
||||||
|
}
|
||||||
|
} %>],
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
if (isNewLine){ %>
|
||||||
|
colProps: { lg: 24, md: 24 },
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
},
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(toBoolean(table.optionMap['isImageUpload'])){
|
||||||
|
%>
|
||||||
|
{
|
||||||
|
label: t('图片上传'),
|
||||||
|
field: 'dataMap',
|
||||||
|
component: 'Upload',
|
||||||
|
componentProps: {
|
||||||
|
loadTime: computed(() => record.value.__t),
|
||||||
|
bizKey: computed(() => record.value.id),
|
||||||
|
bizType: '${className}_image',
|
||||||
|
uploadType: 'image',
|
||||||
|
},
|
||||||
|
colProps: { lg: 24, md: 24 },
|
||||||
|
},
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
if(toBoolean(table.optionMap['isFileUpload'])){
|
||||||
|
%>
|
||||||
|
{
|
||||||
|
label: t('附件上传'),
|
||||||
|
field: 'dataMap',
|
||||||
|
component: 'Upload',
|
||||||
|
componentProps: {
|
||||||
|
loadTime: computed(() => record.value.__t),
|
||||||
|
bizKey: computed(() => record.value.id),
|
||||||
|
bizType: '${className}_file',
|
||||||
|
uploadType: 'all',
|
||||||
|
},
|
||||||
|
colProps: { lg: 24, md: 24 },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
for (child in table.childList){ %>
|
||||||
|
|
||||||
|
const input${child.className}FormSchemas: FormSchema[] = [
|
||||||
|
{
|
||||||
|
field: '${@StringUtils.uncap(child.className)}List',
|
||||||
|
component: 'Input',
|
||||||
|
colProps: { lg: 24, md: 24 },
|
||||||
|
slot: '${@StringUtils.uncap(child.className)}List',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
if(false && toBoolean(table.optionMap['isBpmForm'])){
|
||||||
|
%>
|
||||||
|
|
||||||
|
const inputBpmFormSchemas: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: t('审批意见'),
|
||||||
|
field: 'bpm.comment',
|
||||||
|
component: 'InputTextArea',
|
||||||
|
componentProps: {
|
||||||
|
maxlength: 500,
|
||||||
|
},
|
||||||
|
colProps: { lg: 24, md: 24 },
|
||||||
|
show: () => record.value.bpm.status != '2',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('下一步流程信息'),
|
||||||
|
field: 'nextTaskInfo',
|
||||||
|
component: 'FormGroup',
|
||||||
|
colProps: { lg: 24, md: 24 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('要求完成时间'),
|
||||||
|
field: 'bpm.dueDate',
|
||||||
|
component: 'DatePicker',
|
||||||
|
componentProps: {
|
||||||
|
format: 'YYYY-MM-DD HH:mm',
|
||||||
|
showTime: { format: 'HH:mm' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('任务优先级'),
|
||||||
|
field: 'bpm.priority',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
dictType: 'bpm_task_priority',
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('下一步处理人'),
|
||||||
|
field: 'bpm.nextUserCodes',
|
||||||
|
component: 'ListSelect',
|
||||||
|
componentProps: {
|
||||||
|
selectType: 'empUserSelect',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
<%
|
||||||
|
var updateSchemas = [];
|
||||||
|
if(table.isTreeEntity){
|
||||||
|
var s = {
|
||||||
|
%> {
|
||||||
|
field: 'parentCode',
|
||||||
|
componentProps: {
|
||||||
|
api: ${className}TreeData,
|
||||||
|
params: {
|
||||||
|
excludeCode: record.value.id,
|
||||||
|
isShowRawName: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},<%
|
||||||
|
};
|
||||||
|
@updateSchemas.add(s);
|
||||||
|
}
|
||||||
|
for (c in table.columnList){
|
||||||
|
if (c.isPk == '1' && c.showType == 'input'){
|
||||||
|
var s = {
|
||||||
|
%> {
|
||||||
|
field: '${c.attrName}',
|
||||||
|
componentProps: {
|
||||||
|
disabled: !record.value.isNewRecord,
|
||||||
|
},
|
||||||
|
},<%
|
||||||
|
};
|
||||||
|
@updateSchemas.add(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
const [registerForm, formAction] = useForm({
|
||||||
|
labelWidth: 120,
|
||||||
|
schemas: inputFormSchemas,
|
||||||
|
<% var formColNum = table.optionMap['formColNum']; %>
|
||||||
|
baseColProps: { lg: ${formColNum=="1"?24:formColNum=="3"?8:12}, md: 24 },
|
||||||
|
});
|
||||||
|
<% for (child in table.childList){ %>
|
||||||
|
|
||||||
|
const [register${child.className}Form, ${@StringUtils.uncap(child.className)}Form] = useForm({
|
||||||
|
labelWidth: 120,
|
||||||
|
schemas: input${child.className}FormSchemas,
|
||||||
|
baseColProps: { lg: 24, md: 24 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const [register${child.className}Table, ${@StringUtils.uncap(child.className)}Table] = useTable({
|
||||||
|
actionColumn: {
|
||||||
|
width: 60,
|
||||||
|
actions: (record: Recordable) => [
|
||||||
|
{
|
||||||
|
icon: 'ant-design:delete-outlined',
|
||||||
|
color: 'error',
|
||||||
|
popConfirm: {
|
||||||
|
title: '是否确认删除',
|
||||||
|
confirm: handle${child.className}Delete.bind(this, record),
|
||||||
|
},
|
||||||
|
auth: '${permissionPrefix}:edit',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
rowKey: 'id',
|
||||||
|
pagination: false,
|
||||||
|
bordered: true,
|
||||||
|
size: 'small',
|
||||||
|
inset: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
async function set${child.className}TableData(_res: Recordable) {
|
||||||
|
${@StringUtils.uncap(child.className)}Table.setColumns([
|
||||||
|
<%
|
||||||
|
for (c in child.columnList){
|
||||||
|
if (c.isEdit != '1' || c.isPk == '1'){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(child.parentExists && child.parentTableFkName == c.columnName){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
{
|
||||||
|
title: t('${c.columnLabel}'),
|
||||||
|
dataIndex: '${c.attrName}',
|
||||||
|
<% if(c.showType == 'datetime'){ %>
|
||||||
|
width: 215,
|
||||||
|
<% }else{ %>
|
||||||
|
width: 130,
|
||||||
|
<% } %>
|
||||||
|
<% if ((isNotBlank(c.optionMap['dictType']) || @StringUtils.inString(c.attrType, 'java.util.Date', 'Integer', 'Long'))){ %>
|
||||||
|
align: 'center',
|
||||||
|
<% }else if (@StringUtils.inString(c.attrType, 'Float', 'Double')){ %>
|
||||||
|
align: 'right',
|
||||||
|
<% }else{ %>
|
||||||
|
align: 'left',
|
||||||
|
<% } %>
|
||||||
|
<% if(c.showType == 'select' || c.showType == 'select_multiple' || c.showType == 'checkbox' || c.showType == 'radio'){ %>
|
||||||
|
dictType: '${c.optionMap['dictType']}',
|
||||||
|
<% } %>
|
||||||
|
editRow: true,
|
||||||
|
<% if(c.showType == 'input' || c.showType == 'textarea'){ %>
|
||||||
|
<% if (c.simpleAttrType == 'Integer' && c.attrName == 'treeSort'){ %>
|
||||||
|
editComponent: 'InputNumber',
|
||||||
|
editDefaultValue: '30',
|
||||||
|
<% }else{ %>
|
||||||
|
editComponent: '${c.showType == 'input' ? 'Input' : 'InputTextArea'}',
|
||||||
|
<% } %>
|
||||||
|
<% if (c.dataLength != '0'){ %>
|
||||||
|
editComponentProps: {
|
||||||
|
maxlength: ${c.dataLength},
|
||||||
|
},
|
||||||
|
<% } %>
|
||||||
|
<% }else if(c.showType == 'select' || c.showType == 'select_multiple' || c.showType == 'radio' || c.showType == 'checkbox'){
|
||||||
|
var isMultiple = (c.showType == 'select_multiple'); %>
|
||||||
|
editComponent: 'Select',
|
||||||
|
editComponentProps: {
|
||||||
|
dictType: '${c.optionMap['dictType']}',
|
||||||
|
allowClear: true,
|
||||||
|
<% if(isMultiple){ %>
|
||||||
|
mode: 'multiple',
|
||||||
|
<% } %>
|
||||||
|
},
|
||||||
|
<% }else if(c.showType == 'date' || c.showType == 'datetime'){
|
||||||
|
var isTime = (c.showType == 'datetime'); %>
|
||||||
|
editComponent: 'DatePicker',
|
||||||
|
editComponentProps: {
|
||||||
|
format: 'YYYY-MM-DD${isTime?' HH:mm':''}',
|
||||||
|
showTime: ${isTime?'{ format: \'HH:mm\' \}':'false'},
|
||||||
|
},
|
||||||
|
<% }else if(c.showType == 'userselect'){
|
||||||
|
if (isNotBlank(c.attrName2)){ %>
|
||||||
|
dataLabel: '${c.attrName2}',
|
||||||
|
<% } %>
|
||||||
|
editComponent: 'TreeSelect',
|
||||||
|
editComponentProps: {
|
||||||
|
api: officeTreeData,
|
||||||
|
params: { isLoadUser: true, userIdPrefix: '' },
|
||||||
|
canSelectParent: false,
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
<% }else if(c.showType == 'officeselect'){
|
||||||
|
if (isNotBlank(c.attrName2)){ %>
|
||||||
|
dataLabel: '${c.attrName2}',
|
||||||
|
<% } %>
|
||||||
|
editComponent: 'TreeSelect',
|
||||||
|
editComponentProps: {
|
||||||
|
api: officeTreeData,
|
||||||
|
canSelectParent: false,
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
<% }else if(c.showType == 'areaselect'){
|
||||||
|
if (isNotBlank(c.attrName2)){ %>
|
||||||
|
dataLabel: '${c.attrName2}',
|
||||||
|
<% } %>
|
||||||
|
editComponent: 'TreeSelect',
|
||||||
|
editComponentProps: {
|
||||||
|
api: areaTreeData,
|
||||||
|
canSelectParent: false,
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
<% }else{ %>
|
||||||
|
editComponent: 'Input',
|
||||||
|
<% } %>
|
||||||
|
editRule: ${c.isRequired == '1'},
|
||||||
|
},
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
]);
|
||||||
|
${@StringUtils.uncap(child.className)}Table.setTableData(record.value.${@StringUtils.uncap(child.className)}List || []);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle${child.className}RowClick(record: Recordable) {
|
||||||
|
record.onEdit?.(true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle${child.className}Add() {
|
||||||
|
${@StringUtils.uncap(child.className)}Table.insertTableDataRecord({
|
||||||
|
id: new Date().getTime(),
|
||||||
|
isNewRecord: true,
|
||||||
|
editable: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle${child.className}Delete(record: Recordable) {
|
||||||
|
${@StringUtils.uncap(child.className)}Table.deleteTableDataRecord(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function get${child.className}List() {
|
||||||
|
let ${@StringUtils.uncap(child.className)}ListValid = true;
|
||||||
|
let ${@StringUtils.uncap(child.className)}List: Recordable[] = [];
|
||||||
|
for (const record of ${@StringUtils.uncap(child.className)}Table.getDataSource()) {
|
||||||
|
if (!(await record.onEdit?.(false, true))) {
|
||||||
|
${@StringUtils.uncap(child.className)}ListValid = false;
|
||||||
|
}
|
||||||
|
${@StringUtils.uncap(child.className)}List.push({
|
||||||
|
...record,
|
||||||
|
id: !!record.isNewRecord ? '' : record.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
for (const record of ${@StringUtils.uncap(child.className)}Table.getDelDataSource()) {
|
||||||
|
if (!!record.isNewRecord) continue;
|
||||||
|
${@StringUtils.uncap(child.className)}List.push({
|
||||||
|
...record,
|
||||||
|
status: '1',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!${@StringUtils.uncap(child.className)}ListValid) {
|
||||||
|
throw { errorFields: [{ name: ['${@StringUtils.uncap(child.className)}List'] }] };
|
||||||
|
}
|
||||||
|
return ${@StringUtils.uncap(child.className)}List;
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
async function resetFields() {
|
||||||
|
await formAction.resetFields();
|
||||||
|
<% for (child in table.childList){ %>
|
||||||
|
await ${@StringUtils.uncap(child.className)}Form.resetFields();
|
||||||
|
<% } %>
|
||||||
|
}
|
||||||
|
|
||||||
|
async function setFieldsValue(values: Recordable) {
|
||||||
|
await formAction.setFieldsValue(values);
|
||||||
|
<% for (child in table.childList){ %>
|
||||||
|
await ${@StringUtils.uncap(child.className)}Form.setFieldsValue(values);
|
||||||
|
<% } %>
|
||||||
|
}
|
||||||
|
|
||||||
|
async function validate(): Promise<Recordable<any>> {
|
||||||
|
return Object.assign(
|
||||||
|
await formAction.validate(),
|
||||||
|
<% for (child in table.childList){ %>
|
||||||
|
await ${@StringUtils.uncap(child.className)}Form.validate(),
|
||||||
|
<% } %>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await resetFields();
|
||||||
|
const res = await ${className}Form(unref(query));
|
||||||
|
record.value = (res.${className} || {}) as ${ClassName};
|
||||||
|
record.value.__t = new Date().getTime();
|
||||||
|
<% if(table.isTreeEntity){ %>
|
||||||
|
if (data.parentCode && data.parentName) {
|
||||||
|
record.value.parentCode = data.parentCode;
|
||||||
|
record.value.parentName = data.parentName;
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
setFieldsValue(record.value);
|
||||||
|
<% for (child in table.childList){ %>
|
||||||
|
set${child.className}TableData(res);
|
||||||
|
<% } %>
|
||||||
|
<% if(updateSchemas.~size > 0){ %>
|
||||||
|
formAction.updateSchema([
|
||||||
|
<% for(updateSchema in updateSchemas){
|
||||||
|
print(updateSchema + '\n');
|
||||||
|
} %>
|
||||||
|
]);
|
||||||
|
<% } %>
|
||||||
|
updateTabTitle();
|
||||||
|
});
|
||||||
|
|
||||||
|
function handleClose() {
|
||||||
|
setTimeout(close);
|
||||||
|
}
|
||||||
|
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||||
|
|
||||||
|
async function handleValidate(_event: any, formData: any) {
|
||||||
|
try {
|
||||||
|
const data = await validate();
|
||||||
|
formData(true, data); // 将表单数据传递给 BpmButton
|
||||||
|
} catch (error: any) {
|
||||||
|
if (error && error.errorFields) {
|
||||||
|
showMessage(t('common.validateError'));
|
||||||
|
}
|
||||||
|
console.log('error', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
async function handleSubmit(<% if(toBoolean(table.optionMap['isBpmForm'])){ %>event: any<% } %>) {
|
||||||
|
try {
|
||||||
|
loadingRef.value = true;
|
||||||
|
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||||
|
const data = event?.formData || (await validate()); // 接受 BpmButton 传递过来的表单数据
|
||||||
|
data.bpm = Object.assign(data.bpm || {}, record.value.bpm); // 流程信息
|
||||||
|
data.status = record.value.status; // 提交状态
|
||||||
|
<% } else { %>
|
||||||
|
const data = await validate();
|
||||||
|
<% } %>
|
||||||
|
const params: any = {
|
||||||
|
isNewRecord: record.value.isNewRecord,
|
||||||
|
<%
|
||||||
|
for (c in table.columnList){
|
||||||
|
if (c.isPk == '1' || c.showType == 'hidden'){ %>
|
||||||
|
${c.attrName}: record.value.${c.attrName},
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
};
|
||||||
|
<% for (child in table.childList){ %>
|
||||||
|
data.${@StringUtils.uncap(child.className)}List = await get${child.className}List();
|
||||||
|
<% } %>
|
||||||
|
<% if(table.isTreeEntity){ %>
|
||||||
|
data.oldParentCode = record.value.parentCode;
|
||||||
|
<% } %>
|
||||||
|
// console.log('submit', params, data, record);
|
||||||
|
const res = await ${className}Save(params, data);
|
||||||
|
showMessage(res.message);
|
||||||
|
emitter.emit('${moduleName}${isNotEmpty(subModuleName)?'-'+subModuleName:''}-${className}-reload');
|
||||||
|
handleClose();
|
||||||
|
} catch (error: any) {
|
||||||
|
if (error && error.errorFields) {
|
||||||
|
showMessage(t('common.validateError'));
|
||||||
|
}
|
||||||
|
console.log('error', error);
|
||||||
|
} finally {
|
||||||
|
loadingRef.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||||
|
|
||||||
|
async function handleSuccess() {
|
||||||
|
emitter.emit('${moduleName}${isNotEmpty(subModuleName)?'-'+subModuleName:''}-${className}-reload');
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
</script>
|
||||||
|
<% %>
|
||||||
|
]]>
|
||||||
|
</content>
|
||||||
|
</template>
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
<filePath>${frontDir}/src/views/${urlPrefix}</filePath>
|
<filePath>${frontDir}/src/views/${urlPrefix}</filePath>
|
||||||
<fileName>list.vue</fileName>
|
<fileName>list.vue</fileName>
|
||||||
<content><![CDATA[
|
<content><![CDATA[
|
||||||
|
<% var modalOrDrawer = @StringUtils.contains(table.tplCategory, '_modal') ? 'Modal' : 'Drawer'; %>
|
||||||
<!--
|
<!--
|
||||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||||
* No deletion without permission, or be held responsible to law.
|
* No deletion without permission, or be held responsible to law.
|
||||||
@@ -81,7 +82,9 @@ if(table.isTreeEntity){
|
|||||||
%>
|
%>
|
||||||
</template>
|
</template>
|
||||||
</BasicTable>
|
</BasicTable>
|
||||||
<InputForm @register="registerDrawer" @success="handleSuccess" />
|
<% if(!@StringUtils.contains(table.tplCategory, '_route')) { %>
|
||||||
|
<InputForm @register="register${modalOrDrawer}" @success="handleSuccess" />
|
||||||
|
<% } %>
|
||||||
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
<FormImport @register="registerImportModal" @success="handleSuccess" />
|
<FormImport @register="registerImportModal" @success="handleSuccess" />
|
||||||
<% } %>
|
<% } %>
|
||||||
@@ -93,6 +96,9 @@ if(table.isTreeEntity){
|
|||||||
<script lang="ts" setup name="${compNamePrefix}List">
|
<script lang="ts" setup name="${compNamePrefix}List">
|
||||||
import { unref<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableFk'])){ %>, watch<% }
|
import { unref<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableFk'])){ %>, watch<% }
|
||||||
%><% if(table.isTreeEntity){ %>, nextTick<% } %> } from 'vue';
|
%><% if(table.isTreeEntity){ %>, nextTick<% } %> } from 'vue';
|
||||||
|
<% if(@StringUtils.contains(table.tplCategory, '_route')) { %>
|
||||||
|
import { useEmitter } from '/@/store/modules/user';
|
||||||
|
<% } %>
|
||||||
import { useI18n } from '/@/hooks/web/useI18n';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
||||||
import { useMessage } from '/@/hooks/web/useMessage';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
@@ -128,28 +134,38 @@ for(c in table.columnList){
|
|||||||
<% if(areaselectExists) { %>
|
<% if(areaselectExists) { %>
|
||||||
import { areaTreeData } from '/@/api/sys/area';
|
import { areaTreeData } from '/@/api/sys/area';
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(modalOrDrawer == 'Drawer' && !@StringUtils.contains(table.tplCategory, '_route')){ %>
|
||||||
import { useDrawer } from '/@/components/Drawer';
|
import { useDrawer } from '/@/components/Drawer';
|
||||||
<% if(toBoolean(table.optionMap['isBpmForm']) || toBoolean(table.optionMap['isImportExport'])){ %>
|
<% } %>
|
||||||
|
<% if(modalOrDrawer == 'Modal' || (toBoolean(table.optionMap['isBpmForm'])
|
||||||
|
|| toBoolean(table.optionMap['isImportExport']))){ %>
|
||||||
import { useModal } from '/@/components/Modal';
|
import { useModal } from '/@/components/Modal';
|
||||||
<% } %>
|
<% } %>
|
||||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||||
import { BpmRuntimeTrace } from '/@/components/Bpm';
|
import { BpmRuntimeTrace } from '/@/components/Bpm';
|
||||||
<% } %>
|
<% } %>
|
||||||
import { FormProps } from '/@/components/Form';
|
import { FormProps } from '/@/components/Form';
|
||||||
|
<% if(!@StringUtils.contains(table.tplCategory, '_route')) { %>
|
||||||
import InputForm from './form.vue';
|
import InputForm from './form.vue';
|
||||||
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
import FormImport from './formImport.vue';
|
import FormImport from './formImport.vue';
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableFk'])){ %>
|
<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableFk'])){ %>
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
treeCode: String,
|
treeCode: String,
|
||||||
});
|
});
|
||||||
|
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(@StringUtils.contains(table.tplCategory, '_route')) { %>
|
||||||
|
|
||||||
|
const emitter = useEmitter();
|
||||||
|
<% } %>
|
||||||
|
|
||||||
const { t } = useI18n('${moduleName}${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${className}');
|
const { t } = useI18n('${moduleName}${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${className}');
|
||||||
const { showMessage } = useMessage();
|
const { showMessage } = useMessage();
|
||||||
const { meta } = unref(router.currentRoute);
|
const { meta } = unref(router.currentRoute);
|
||||||
|
|
||||||
const getTitle = {
|
const getTitle = {
|
||||||
icon: meta.icon || 'ant-design:book-outlined',
|
icon: meta.icon || 'ant-design:book-outlined',
|
||||||
value: meta.title || t('${functionNameSimple}管理'),
|
value: meta.title || t('${functionNameSimple}管理'),
|
||||||
@@ -378,8 +394,12 @@ for(c in table.columnList){
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const [registerDrawer, { openDrawer }] = useDrawer();
|
<% if(!@StringUtils.contains(table.tplCategory, '_route')) { %>
|
||||||
const [registerTable, { reload<% if(table.isTreeEntity){ %>, expandAll, collapseAll, expandCollapse<% } %>, getForm }] = useTable({
|
const [register${modalOrDrawer}, { open${modalOrDrawer} }] = use${modalOrDrawer}();
|
||||||
|
<% } %>
|
||||||
|
const [registerTable, { reload<% if(table.isTreeEntity){ %>, expandAll, collapseAll, expandCollapse<% } %><%
|
||||||
|
if (table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableFk'])
|
||||||
|
|| toBoolean(table.optionMap['isImportExport'])){ %>, getForm<% } %> }] = useTable({
|
||||||
api: ${className}ListData,
|
api: ${className}ListData,
|
||||||
beforeFetch: (params) => {
|
beforeFetch: (params) => {
|
||||||
return params;
|
return params;
|
||||||
@@ -423,7 +443,14 @@ for(c in table.columnList){
|
|||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
function handleForm(record: Recordable) {
|
function handleForm(record: Recordable) {
|
||||||
openDrawer(true, record);
|
<% if(!@StringUtils.contains(table.tplCategory, '_route')) { %>
|
||||||
|
open${modalOrDrawer}(true, record);
|
||||||
|
<% } else { %>
|
||||||
|
router.push({
|
||||||
|
path: '/${urlPrefix}/formRoute',
|
||||||
|
query: record,
|
||||||
|
});
|
||||||
|
<% } %>
|
||||||
}
|
}
|
||||||
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
|
||||||
@@ -476,6 +503,10 @@ for(c in table.columnList){
|
|||||||
traceModel(true, { formKey: '${table.optionMap['bpmFormKey']}', bizKey: record.id });
|
traceModel(true, { formKey: '${table.optionMap['bpmFormKey']}', bizKey: record.id });
|
||||||
}
|
}
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(@StringUtils.contains(table.tplCategory, '_route')) { %>
|
||||||
|
|
||||||
|
emitter.on('${moduleName}${isNotEmpty(subModuleName)?'-'+subModuleName:''}-${className}-reload', reload, true);
|
||||||
|
<% } %>
|
||||||
</script>
|
</script>
|
||||||
<% %>
|
<% %>
|
||||||
]]>
|
]]>
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ export default {
|
|||||||
tableProps,
|
tableProps,
|
||||||
itemCode: '<% for(pk in table.pkList){ %>${pk.attrName}<% } %>',
|
itemCode: '<% for(pk in table.pkList){ %>${pk.attrName}<% } %>',
|
||||||
itemName: '<% for(pk in table.pkList){ %>${pk.attrName}<% } %>',
|
itemName: '<% for(pk in table.pkList){ %>${pk.attrName}<% } %>',
|
||||||
|
isShowCode: false,
|
||||||
};
|
};
|
||||||
<% %>
|
<% %>
|
||||||
]]>
|
]]>
|
||||||
|
|||||||
Reference in New Issue
Block a user