优化代码生成
This commit is contained in:
parent
a3d0a2b403
commit
5bce7e0464
@ -176,5 +176,24 @@ $if(replaceDto.ShowBtnExport)
|
|||||||
return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName });
|
return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName });
|
||||||
}
|
}
|
||||||
$end
|
$end
|
||||||
|
|
||||||
|
$if(showCustomInput)
|
||||||
|
/// <summary>
|
||||||
|
/// 保存排序
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[ActionPermissionFilter(Permission = "${replaceDto.PermissionPrefix}:update")]
|
||||||
|
[HttpGet("ChangeSort")]
|
||||||
|
[Log(Title = "保存排序", BusinessType = BusinessType.UPDATE)]
|
||||||
|
public IActionResult ChangeSort(int id = 0, int value = 0)
|
||||||
|
{
|
||||||
|
if (id <= 0) { return ToResponse(ApiResult.Error(101, "请求参数错误")); }
|
||||||
|
bool result = false;//TODO 自行实现;
|
||||||
|
|
||||||
|
return SUCCESS(result);
|
||||||
|
}
|
||||||
|
$end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -23,11 +23,6 @@ $if(replaceDto.ShowBtnExport)
|
|||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['${replaceDto.PermissionPrefix}:export']">导出</el-button>
|
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['${replaceDto.PermissionPrefix}:export']">导出</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
$end
|
|
||||||
$if(genTable.SortField != "" && 1 == 2)
|
|
||||||
<el-col :span="1.5">
|
|
||||||
<el-button type="info" plain icon="el-icon-edit" size="mini" @click="handleShowSort" v-hasPermi="['${replaceDto.PermissionPrefix}:update']">修改排序</el-button>
|
|
||||||
</el-col>
|
|
||||||
$end
|
$end
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -54,7 +49,7 @@ ${VueViewListContent}
|
|||||||
${VueViewFormContent}
|
${VueViewFormContent}
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-form>
|
</el-form>
|
||||||
<div slot="footer" class="dialog-footer" v-if="btnSubmitVisible">
|
<div slot="footer" class="dialog-footer">
|
||||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
<el-button @click="cancel">取 消</el-button>
|
<el-button @click="cancel">取 消</el-button>
|
||||||
</div>
|
</div>
|
||||||
@ -72,7 +67,7 @@ import {
|
|||||||
$if(replaceDto.ShowBtnExport)
|
$if(replaceDto.ShowBtnExport)
|
||||||
export${genTable.BusinessName},
|
export${genTable.BusinessName},
|
||||||
$end
|
$end
|
||||||
$if(genTable.SortField != "" && genTable.SortField != null)
|
$if(showCustomInput)
|
||||||
changeSort
|
changeSort
|
||||||
$end
|
$end
|
||||||
} from '@/api/${genTable.ModuleName}/${lowerBusinessName}.js';
|
} from '@/api/${genTable.ModuleName}/${lowerBusinessName}.js';
|
||||||
@ -124,13 +119,8 @@ $elseif(item.HtmlType == "datetime" && item.IsQuery == true)
|
|||||||
//${item.ColumnComment}时间范围
|
//${item.ColumnComment}时间范围
|
||||||
dateRange${item.CsharpField}: [],
|
dateRange${item.CsharpField}: [],
|
||||||
$elseif(item.HtmlType == "customInput")
|
$elseif(item.HtmlType == "customInput")
|
||||||
editIndex = -1; //不加editIndex,整个列都会一块变成可编辑
|
editIndex: -1,
|
||||||
showEditSort = false;
|
|
||||||
$end
|
$end
|
||||||
$end
|
|
||||||
$if(genTable.SortField != "" && genTable.SortField != null)
|
|
||||||
// 是否显示编辑排序
|
|
||||||
showEditSort: false,
|
|
||||||
$end
|
$end
|
||||||
// 数据列表
|
// 数据列表
|
||||||
dataList: [],
|
dataList: [],
|
||||||
@ -286,6 +276,27 @@ $if((item.HtmlType == "radio" || item.HtmlType == "select" || item.HtmlType == "
|
|||||||
return this.selectDictLabel(this.${item.CsharpFieldFl}Options, row.${item.CsharpFieldFl});
|
return this.selectDictLabel(this.${item.CsharpFieldFl}Options, row.${item.CsharpFieldFl});
|
||||||
},
|
},
|
||||||
$end
|
$end
|
||||||
|
$if(item.HtmlType == "customInput")
|
||||||
|
// 显示编辑排序
|
||||||
|
editCurrRow(rowId, str) {
|
||||||
|
this.editIndex = rowId;
|
||||||
|
let id = rowId + str;
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
document.getElementById(id).focus();
|
||||||
|
}, 100);
|
||||||
|
},
|
||||||
|
// 保存排序
|
||||||
|
handleChangeSort(info) {
|
||||||
|
this.editIndex = -1;
|
||||||
|
changeSort({ value: info.${item.CsharpFieldFl}, id: info.${replaceDto.FistLowerPk} }).then(
|
||||||
|
(response) => {
|
||||||
|
this.msgSuccess("修改成功");
|
||||||
|
this.getList();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
$end
|
||||||
$end
|
$end
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
submitForm: function () {
|
submitForm: function () {
|
||||||
|
|||||||
@ -67,7 +67,7 @@ export function export${genTable.BusinessName}(query) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
$if(genTable.SortField != "" && genTable.SortField != null)
|
$if(showCustomInput)
|
||||||
//排序
|
//排序
|
||||||
export function changeSort(data) {
|
export function changeSort(data) {
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@ -186,10 +186,9 @@ namespace ZR.CodeGenerator
|
|||||||
sb.AppendLine($" end-placeholder=\"结束日期\" placeholder=\"请选择{dbFieldInfo.ColumnComment}\" ></el-date-picker>");
|
sb.AppendLine($" end-placeholder=\"结束日期\" placeholder=\"请选择{dbFieldInfo.ColumnComment}\" ></el-date-picker>");
|
||||||
sb.AppendLine(" </el-form-item>");
|
sb.AppendLine(" </el-form-item>");
|
||||||
}
|
}
|
||||||
else if ((dbFieldInfo.HtmlType == GenConstants.HTML_SELECT || dbFieldInfo.HtmlType == GenConstants.HTML_RADIO))
|
else if (dbFieldInfo.HtmlType == GenConstants.HTML_SELECT || dbFieldInfo.HtmlType == GenConstants.HTML_RADIO)
|
||||||
{
|
{
|
||||||
//string value = CodeGeneratorTool.IsNumber(dbFieldInfo.CsharpType) ? "parseInt(item.dictValue)" : "item.dictValue";
|
sb.AppendLine($" <el-form-item label=\"{labelName}\" prop=\"{columnName}\">");
|
||||||
sb.AppendLine($" <el-form-item label=\"{ labelName}\" prop=\"{columnName}\">");
|
|
||||||
sb.AppendLine($" <el-select v-model=\"queryParams.{columnName}\" placeholder=\"请选择{dbFieldInfo.ColumnComment}\" size=\"small\" >");
|
sb.AppendLine($" <el-select v-model=\"queryParams.{columnName}\" placeholder=\"请选择{dbFieldInfo.ColumnComment}\" size=\"small\" >");
|
||||||
sb.AppendLine($" <el-option v-for=\"item in {columnName}Options\" :key=\"item.dictValue\" :label=\"item.dictLabel\" :value=\"item.dictValue\"></el-option>");
|
sb.AppendLine($" <el-option v-for=\"item in {columnName}Options\" :key=\"item.dictValue\" :label=\"item.dictLabel\" :value=\"item.dictValue\"></el-option>");
|
||||||
sb.AppendLine(" </el-select>");
|
sb.AppendLine(" </el-select>");
|
||||||
@ -220,12 +219,13 @@ namespace ZR.CodeGenerator
|
|||||||
string formatter = GetFormatter(dbFieldInfo.HtmlType, columnName);
|
string formatter = GetFormatter(dbFieldInfo.HtmlType, columnName);
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
//自定义排序字段
|
//自定义排序字段
|
||||||
if (GenConstants.HTML_SORT.Equals(dbFieldInfo.HtmlType) && !dbFieldInfo.IsPk && CodeGeneratorTool.IsNumber(dbFieldInfo.CsharpType))
|
if (GenConstants.HTML_CUSTOM_INPUT.Equals(dbFieldInfo.HtmlType) && !dbFieldInfo.IsPk)
|
||||||
{
|
{
|
||||||
sb.AppendLine($@" <el-table-column prop=""{columnName}"" label=""{label}"" width=""90"" sortable align=""center"">");
|
sb.AppendLine($@" <el-table-column prop=""{columnName}"" label=""{label}"" width=""90"" sortable align=""center"">");
|
||||||
sb.AppendLine(@" <template slot-scope=""scope"">");
|
sb.AppendLine(@" <template slot-scope=""scope"">");
|
||||||
sb.AppendLine($@" <el-input size=""mini"" style=""width:50px"" controls-position=""no"" v-model.number=""scope.row.{columnName}"" @blur=""handleChangeSort(scope.row, scope.row.{columnName})"" v-if=""showEditSort"" />");
|
sb.AppendLine($@" <span v-show=""editIndex != scope.$index"" @click=""editCurrRow(scope.$index,'rowkeY')"">{{{{scope.row.{columnName}}}}}</span>");
|
||||||
sb.AppendLine($" <span v-else>{{{{scope.row.{columnName}}}}}</span>");
|
sb.AppendLine(@" <el-input :id=""scope.$index+'rowkeY'"" size=""mini"" v-show=""(editIndex == scope.$index)""");
|
||||||
|
sb.AppendLine($@" v-model=""scope.row.{columnName}"" @blur=""handleChangeSort(scope.row)""></el-input>");
|
||||||
sb.AppendLine(@" </template>");
|
sb.AppendLine(@" </template>");
|
||||||
sb.AppendLine(@" </el-table-column>");
|
sb.AppendLine(@" </el-table-column>");
|
||||||
}
|
}
|
||||||
@ -239,7 +239,7 @@ namespace ZR.CodeGenerator
|
|||||||
sb.AppendLine(" </template>");
|
sb.AppendLine(" </template>");
|
||||||
sb.AppendLine(" </el-table-column>");
|
sb.AppendLine(" </el-table-column>");
|
||||||
}
|
}
|
||||||
else if (dbFieldInfo.IsList && !string.IsNullOrEmpty(dbFieldInfo.DictType))
|
else if (dbFieldInfo.IsList && !string.IsNullOrEmpty(formatter))
|
||||||
{
|
{
|
||||||
sb.AppendLine($@" <el-table-column label=""{label}"" align=""center"" prop=""{columnName}"">");
|
sb.AppendLine($@" <el-table-column label=""{label}"" align=""center"" prop=""{columnName}"">");
|
||||||
sb.AppendLine(@" <template slot-scope=""scope"">");
|
sb.AppendLine(@" <template slot-scope=""scope"">");
|
||||||
|
|||||||
@ -447,6 +447,7 @@ namespace ZR.CodeGenerator
|
|||||||
{
|
{
|
||||||
//Engine.Current.Clean();
|
//Engine.Current.Clean();
|
||||||
dto.GenTable.Columns = dto.GenTable.Columns.OrderBy(x => x.Sort).ToList();
|
dto.GenTable.Columns = dto.GenTable.Columns.OrderBy(x => x.Sort).ToList();
|
||||||
|
bool showCustomInput = dto.GenTable.Columns.Any(f => f.HtmlType.Equals(GenConstants.HTML_CUSTOM_INPUT, StringComparison.OrdinalIgnoreCase));
|
||||||
//jnt模板引擎全局变量
|
//jnt模板引擎全局变量
|
||||||
Engine.Configure((options) =>
|
Engine.Configure((options) =>
|
||||||
{
|
{
|
||||||
@ -461,6 +462,7 @@ namespace ZR.CodeGenerator
|
|||||||
options.Data.Set("options", dto.GenOptions);
|
options.Data.Set("options", dto.GenOptions);
|
||||||
options.Data.Set("genTable", dto.GenTable);
|
options.Data.Set("genTable", dto.GenTable);
|
||||||
options.Data.Set("btns", dto.CheckedBtn);
|
options.Data.Set("btns", dto.CheckedBtn);
|
||||||
|
options.Data.Set("showCustomInput", showCustomInput);
|
||||||
options.Data.Set("tool", new CodeGeneratorTool());
|
options.Data.Set("tool", new CodeGeneratorTool());
|
||||||
options.Data.Set("codeTool", new CodeGenerateTemplate());
|
options.Data.Set("codeTool", new CodeGenerateTemplate());
|
||||||
options.EnableCache = true;
|
options.EnableCache = true;
|
||||||
|
|||||||
@ -111,6 +111,10 @@ namespace ZR.CodeGenerator
|
|||||||
public static string HTML_EDITOR = "editor";
|
public static string HTML_EDITOR = "editor";
|
||||||
// 自定义排序
|
// 自定义排序
|
||||||
public static string HTML_SORT = "sort";
|
public static string HTML_SORT = "sort";
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义输入框
|
||||||
|
/// </summary>
|
||||||
|
public static string HTML_CUSTOM_INPUT = "customInput";
|
||||||
//颜色选择器
|
//颜色选择器
|
||||||
public static string HTML_COLORPICKER = "colorPicker";
|
public static string HTML_COLORPICKER = "colorPicker";
|
||||||
//switch开关
|
//switch开关
|
||||||
|
|||||||
@ -84,6 +84,7 @@
|
|||||||
<el-option label="图片上传" value="imageUpload" />
|
<el-option label="图片上传" value="imageUpload" />
|
||||||
<el-option label="文件上传" value="fileUpload" />
|
<el-option label="文件上传" value="fileUpload" />
|
||||||
<el-option label="富文本控件" value="editor" />
|
<el-option label="富文本控件" value="editor" />
|
||||||
|
<el-option label="自定义输入框" value="customInput" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@ -157,7 +158,7 @@ export default {
|
|||||||
getGenTable(tableId).then((res) => {
|
getGenTable(tableId).then((res) => {
|
||||||
this.columns = res.data.columns;
|
this.columns = res.data.columns;
|
||||||
this.info = res.data.info;
|
this.info = res.data.info;
|
||||||
this.tables = res.data.tables;//子表
|
this.tables = res.data.tables; //子表
|
||||||
});
|
});
|
||||||
/** 查询字典下拉列表 */
|
/** 查询字典下拉列表 */
|
||||||
listType({ pageSize: 100 }).then((response) => {
|
listType({ pageSize: 100 }).then((response) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user