代码生成模板添加公司选择组件

This commit is contained in:
thinkgem
2024-03-10 10:44:00 +08:00
parent e7c6e7e85b
commit c0aeef4881
9 changed files with 91 additions and 10 deletions

View File

@@ -197,6 +197,7 @@
<dict value="datetime" label="日期时间"/>
<dict value="userselect" label="人员选择"/>
<dict value="officeselect" label="机构选择"/>
<dict value="companyselect" label="公司选择"/>
<dict value="areaselect" label="区域选择"/>
</showType>
<!-- 字段验证 -->

View File

@@ -78,6 +78,7 @@
<%
var userselectExists = false;
var officeselectExists = false;
var companyselectExists = false;
var areaselectExists = false;
for(c in table.columnList){
if(c.isQuery == "1" && !c.isTreeEntityColumn){
@@ -85,6 +86,8 @@ for(c in table.columnList){
userselectExists = true;
}else if(c.showType == 'officeselect'){
officeselectExists = true;
}else if(c.showType == 'companyselect'){
companyselectExists = true;
}else if(c.showType == 'areaselect'){
areaselectExists = true;
}
@@ -94,6 +97,9 @@ for(c in table.columnList){
<% if(userselectExists || officeselectExists) { %>
import { officeTreeData } from '/@/api/sys/office';
<% } %>
<% if(companyselectExists) { %>
import { companyTreeData } from '/@/api/sys/company';
<% } %>
<% if(areaselectExists) { %>
import { areaTreeData } from '/@/api/sys/area';
<% } %>
@@ -206,6 +212,16 @@ for (c in table.columnList){
canSelectParent: false,
allowClear: true,
},
<% }else if(c.showType == 'companyselect'){
if (isNotBlank(c.attrName2)){ %>
fieldLabel: '${c.attrName2}',
<% } %>
component: 'TreeSelect',
componentProps: {
api: companyTreeData,
canSelectParent: false,
allowClear: true,
},
<% }else if(c.showType == 'areaselect'){
if (isNotBlank(c.attrName2)){ %>
fieldLabel: '${c.attrName2}',
@@ -532,6 +548,16 @@ for (c in table.columnList){
canSelectParent: false,
allowClear: true,
},
<% }else if(c.showType == 'companyselect'){
if (isNotBlank(c.attrName2)){ %>
dataLabel: '${c.attrName2}',
<% } %>
editComponent: 'TreeSelect',
editComponentProps: {
api: companyTreeData,
canSelectParent: false,
allowClear: true,
},
<% }else if(c.showType == 'areaselect'){
if (isNotBlank(c.attrName2)){ %>
dataLabel: '${c.attrName2}',

View File

@@ -115,6 +115,7 @@ if(table.isTreeEntity){
<%
var userselectExists = false;
var officeselectExists = false;
var companyselectExists = false;
var areaselectExists = false;
for(c in table.columnList){
if(c.isQuery == "1" && !c.isTreeEntityColumn){
@@ -122,6 +123,8 @@ for(c in table.columnList){
userselectExists = true;
}else if(c.showType == 'officeselect'){
officeselectExists = true;
}else if(c.showType == 'companyselect'){
companyselectExists = true;
}else if(c.showType == 'areaselect'){
areaselectExists = true;
}
@@ -131,6 +134,9 @@ for(c in table.columnList){
<% if(userselectExists || officeselectExists) { %>
import { officeTreeData } from '/@/api/sys/office';
<% } %>
<% if(companyselectExists) { %>
import { companyTreeData } from '/@/api/sys/company';
<% } %>
<% if(areaselectExists) { %>
import { areaTreeData } from '/@/api/sys/area';
<% } %>
@@ -239,6 +245,12 @@ for(c in table.columnList){
api: officeTreeData,
allowClear: true,
},
<% }else if(c.showType == 'companyselect'){ %>
component: 'TreeSelect',
componentProps: {
api: companyTreeData,
allowClear: true,
},
<% }else if(c.showType == 'areaselect'){ %>
component: 'TreeSelect',
componentProps: {
@@ -287,7 +299,7 @@ for(c in table.columnList){
%>
{
title: t('${c.columnLabel}'),
<% if(c.showType == "userselect" || c.showType == "officeselect" || c.showType == "areaselect"){ %>
<% if(c.showType == "userselect" || c.showType == "officeselect" || c.showType == "companyselect" || c.showType == "areaselect"){ %>
dataIndex: '${c.attrName2}',
<% }else{ %>
dataIndex: '${c.attrName}',

View File

@@ -12,6 +12,7 @@ import { ${className}ListData } from '/@/api/${moduleName}${isNotEmpty(subModule
<%
var userselectExists = false;
var officeselectExists = false;
var companyselectExists = false;
var areaselectExists = false;
for(c in table.columnList){
if(c.isQuery == "1" && !c.isTreeEntityColumn){
@@ -19,6 +20,8 @@ for(c in table.columnList){
userselectExists = true;
}else if(c.showType == 'officeselect'){
officeselectExists = true;
}else if(c.showType == 'companyselect'){
companyselectExists = true;
}else if(c.showType == 'areaselect'){
areaselectExists = true;
}
@@ -28,6 +31,9 @@ for(c in table.columnList){
<% if(userselectExists || officeselectExists) { %>
import { officeTreeData } from '/@/api/sys/office';
<% } %>
<% if(companyselectExists) { %>
import { companyTreeData } from '/@/api/sys/company';
<% } %>
<% if(areaselectExists) { %>
import { areaTreeData } from '/@/api/sys/area';
<% } %>
@@ -103,6 +109,12 @@ const searchForm: FormProps = {
api: officeTreeData,
allowClear: true,
},
<% }else if(c.showType == 'companyselect'){ %>
component: 'TreeSelect',
componentProps: {
api: companyTreeData,
allowClear: true,
},
<% }else if(c.showType == 'areaselect'){ %>
component: 'TreeSelect',
componentProps: {
@@ -151,7 +163,7 @@ for(c in table.columnList){
%>
{
title: t('${c.columnLabel}'),
<% if(c.showType == "userselect" || c.showType == "officeselect" || c.showType == "areaselect"){ %>
<% if(c.showType == "userselect" || c.showType == "officeselect" || c.showType == "companyselect" || c.showType == "areaselect"){ %>
dataIndex: '${c.attrName2}',
<% }else{ %>
dataIndex: '${c.attrName}',

View File

@@ -1,7 +1,7 @@
<script>
\//# // 初始化DataGrid对象
$('#dataGrid').dataGrid({
searchForm: $("#searchForm"),
searchForm: $('#searchForm'),
columnModel: [
<%
// 是否是第一列
@@ -48,7 +48,7 @@ $('#dataGrid').dataGrid({
{header:'\${text("${c.columnLabel}")}', name:'${c.attrName}', index:'a.${c.columnName}', width:150, align:"center", formatter: function(val, obj, row, act){
return js.getDictLabel(\"#{@DictUtils.getDictListJson('${c.optionMap['dictType']}')}", val, '\${text("未知")}', true);
}},
<% }else if(c.showType == "userselect" || c.showType == "officeselect" || c.showType == "areaselect"){ %>
<% }else if(c.showType == "userselect" || c.showType == "officeselect" || c.showType == "companyselect" || c.showType == "areaselect"){ %>
{header:'\${text("${c.columnLabel}")}', name:'${c.attrName2}', index:'a.${c.columnName}', width:150, align:"center"},
<% }else{
if (@StringUtils.inString(c.attrType, 'java.util.Date', 'Integer', 'Long')){

View File

@@ -1,7 +1,7 @@
<script>
var selectData = \"#{isNotBlank(selectData!) ? selectData! : '{}'}",
selectNum = 0, dataGrid = $('#dataGrid').dataGrid({
searchForm: $("#searchForm"),
searchForm: $('#searchForm'),
columnModel: [
<%
// 是否是第一列
@@ -44,7 +44,7 @@ selectNum = 0, dataGrid = $('#dataGrid').dataGrid({
{header:'\${text("${c.columnLabel}")}', name:'${c.attrName}', index:'a.${c.columnName}', width:150, align:"center", formatter: function(val, obj, row, act){
return js.getDictLabel(\"#{@DictUtils.getDictListJson('${c.optionMap['dictType']}')}", val, '\${text("未知")}', true);
}},
<% }else if(c.showType == "userselect" || c.showType == "officeselect" || c.showType == "areaselect"){ %>
<% }else if(c.showType == "userselect" || c.showType == "officeselect" || c.showType == "companyselect" || c.showType == "areaselect"){ %>
{header:'\${text("${c.columnLabel}")}', name:'${c.attrName2}', index:'a.${c.columnName}', width:150, align:"center"},
<% }else{
if (@StringUtils.inString(c.attrType, 'java.util.Date', 'Integer', 'Long')){
@@ -81,7 +81,7 @@ selectNum = 0, dataGrid = $('#dataGrid').dataGrid({
} %>', // 展开节点清理请求参数数据(一般设置查询条件的字段属性,否则在查询后,不能展开子节点数据)
<% } %>
autoGridHeight: function(){
var height = $(window).height() - $('#searchForm').height() - $('#dataGridPage').height() - 74;
var height = $(window).height() - $('#searchForm').height() - $('#dataGridPage').height() - 76;
$('.tags-input').height($('.ui-jqgrid').height() - 10);
return height;
},

View File

@@ -6,10 +6,10 @@ var treeselectExists = false;
for(child in table.childList){
%>
\//# // 初始化${child.comments}DataGrid对象
$("#${@StringUtils.uncap(child.className)}DataGrid").dataGrid({
$('#${@StringUtils.uncap(child.className)}DataGrid').dataGrid({
data: \"#{toJson(${className}.${@StringUtils.uncap(child.className)}List)}",
datatype: "local", // 设置本地数据
datatype: 'local', // 设置本地数据
autoGridHeight: function(){return 'auto'}, // 设置自动高度
\//# // 设置数据表格列
@@ -120,7 +120,25 @@ for (c in child.columnList){
}
}
},
<%
<%
}else if(c.showType == 'companyselect'){
treeselectExists = true;
%>
{header:'\${text("${c.columnLabel}")}', name:'${c.simpleAttrName}', width:150,
formatter: function(val, obj, row, act){
return js.val(row, '${c.attrName}')+'|'+js.val(row, '${c.attrName2}');
}, editable: true, edittype: "custom", editoptions: {
custom_element: function(val, editOptions) {
return js.template('treeselectTpl', {
id: 'company_'+editOptions.id, title: '公司选择',
name: '${c.attrName}', value: val.split('|')[0],
labelName: '${c.attrName2}', labelValue: val.split('|')[1],
url: '\${ctx}/sys/company/treeData', cssClass: '${cssClass}'
});
}
}
},
<%
}else if(c.showType == 'areaselect'){
treeselectExists = true;
%>

View File

@@ -147,6 +147,12 @@
path="${c.attrName}" labelPath="${c.attrName2}"
url="\${ctx}/sys/office/treeData"
class="${cssClass}" allowClear="true"/>
<%
} else if (c.showType == 'companyselect') {
%><${'#'}form:treeselect id="${c.simpleAttrName}" title="\${text('公司选择')}"
path="${c.attrName}" labelPath="${c.attrName2}"
url="\${ctx}/sys/company/treeData"
class="${cssClass}" allowClear="true"/>
<%
} else if (c.showType == 'areaselect') {
%><${'#'}form:treeselect id="${c.simpleAttrName}" title="\${text('区域选择')}"

View File

@@ -56,6 +56,12 @@
path="${c.attrName}" labelPath="${c.attrName2}"
url="\${ctx}/sys/office/treeData" allowClear="true"/>
</div>
<% }else if(c.showType == 'companyselect'){ %>
<div class="control-inline width-120" >
<${'#'}form:treeselect id="${c.simpleAttrName}" title="\${text('机构选择')}"
path="${c.attrName}" labelPath="${c.attrName2}"
url="\${ctx}/sys/company/treeData" allowClear="true"/>
</div>
<% }else if(c.showType == 'areaselect'){ %>
<div class="control-inline width-120" >
<${'#'}form:treeselect id="${c.simpleAttrName}" title="\${text('区域选择')}"