优化代码生成
This commit is contained in:
parent
a3d0a2b403
commit
5bce7e0464
@ -176,5 +176,24 @@ $if(replaceDto.ShowBtnExport)
|
||||
return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName });
|
||||
}
|
||||
$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-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['${replaceDto.PermissionPrefix}:export']">导出</el-button>
|
||||
</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
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
@ -54,7 +49,7 @@ ${VueViewListContent}
|
||||
${VueViewFormContent}
|
||||
</el-row>
|
||||
</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 @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
@ -72,7 +67,7 @@ import {
|
||||
$if(replaceDto.ShowBtnExport)
|
||||
export${genTable.BusinessName},
|
||||
$end
|
||||
$if(genTable.SortField != "" && genTable.SortField != null)
|
||||
$if(showCustomInput)
|
||||
changeSort
|
||||
$end
|
||||
} from '@/api/${genTable.ModuleName}/${lowerBusinessName}.js';
|
||||
@ -124,13 +119,8 @@ $elseif(item.HtmlType == "datetime" && item.IsQuery == true)
|
||||
//${item.ColumnComment}时间范围
|
||||
dateRange${item.CsharpField}: [],
|
||||
$elseif(item.HtmlType == "customInput")
|
||||
editIndex = -1; //不加editIndex,整个列都会一块变成可编辑
|
||||
showEditSort = false;
|
||||
editIndex: -1,
|
||||
$end
|
||||
$end
|
||||
$if(genTable.SortField != "" && genTable.SortField != null)
|
||||
// 是否显示编辑排序
|
||||
showEditSort: false,
|
||||
$end
|
||||
// 数据列表
|
||||
dataList: [],
|
||||
@ -286,6 +276,27 @@ $if((item.HtmlType == "radio" || item.HtmlType == "select" || item.HtmlType == "
|
||||
return this.selectDictLabel(this.${item.CsharpFieldFl}Options, row.${item.CsharpFieldFl});
|
||||
},
|
||||
$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
|
||||
/** 提交按钮 */
|
||||
submitForm: function () {
|
||||
|
||||
@ -67,7 +67,7 @@ export function export${genTable.BusinessName}(query) {
|
||||
})
|
||||
}
|
||||
|
||||
$if(genTable.SortField != "" && genTable.SortField != null)
|
||||
$if(showCustomInput)
|
||||
//排序
|
||||
export function changeSort(data) {
|
||||
return request({
|
||||
|
||||
@ -186,10 +186,9 @@ namespace ZR.CodeGenerator
|
||||
sb.AppendLine($" end-placeholder=\"结束日期\" placeholder=\"请选择{dbFieldInfo.ColumnComment}\" ></el-date-picker>");
|
||||
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-option v-for=\"item in {columnName}Options\" :key=\"item.dictValue\" :label=\"item.dictLabel\" :value=\"item.dictValue\"></el-option>");
|
||||
sb.AppendLine(" </el-select>");
|
||||
@ -220,12 +219,13 @@ namespace ZR.CodeGenerator
|
||||
string formatter = GetFormatter(dbFieldInfo.HtmlType, columnName);
|
||||
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(@" <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-else>{{{{scope.row.{columnName}}}}}</span>");
|
||||
sb.AppendLine($@" <span v-show=""editIndex != scope.$index"" @click=""editCurrRow(scope.$index,'rowkeY')"">{{{{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(@" </el-table-column>");
|
||||
}
|
||||
@ -239,7 +239,7 @@ namespace ZR.CodeGenerator
|
||||
sb.AppendLine(" </template>");
|
||||
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(@" <template slot-scope=""scope"">");
|
||||
|
||||
@ -447,6 +447,7 @@ namespace ZR.CodeGenerator
|
||||
{
|
||||
//Engine.Current.Clean();
|
||||
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模板引擎全局变量
|
||||
Engine.Configure((options) =>
|
||||
{
|
||||
@ -461,6 +462,7 @@ namespace ZR.CodeGenerator
|
||||
options.Data.Set("options", dto.GenOptions);
|
||||
options.Data.Set("genTable", dto.GenTable);
|
||||
options.Data.Set("btns", dto.CheckedBtn);
|
||||
options.Data.Set("showCustomInput", showCustomInput);
|
||||
options.Data.Set("tool", new CodeGeneratorTool());
|
||||
options.Data.Set("codeTool", new CodeGenerateTemplate());
|
||||
options.EnableCache = true;
|
||||
|
||||
@ -111,6 +111,10 @@ namespace ZR.CodeGenerator
|
||||
public static string HTML_EDITOR = "editor";
|
||||
// 自定义排序
|
||||
public static string HTML_SORT = "sort";
|
||||
/// <summary>
|
||||
/// 自定义输入框
|
||||
/// </summary>
|
||||
public static string HTML_CUSTOM_INPUT = "customInput";
|
||||
//颜色选择器
|
||||
public static string HTML_COLORPICKER = "colorPicker";
|
||||
//switch开关
|
||||
|
||||
@ -84,6 +84,7 @@
|
||||
<el-option label="图片上传" value="imageUpload" />
|
||||
<el-option label="文件上传" value="fileUpload" />
|
||||
<el-option label="富文本控件" value="editor" />
|
||||
<el-option label="自定义输入框" value="customInput" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -157,7 +158,7 @@ export default {
|
||||
getGenTable(tableId).then((res) => {
|
||||
this.columns = res.data.columns;
|
||||
this.info = res.data.info;
|
||||
this.tables = res.data.tables;//子表
|
||||
this.tables = res.data.tables; //子表
|
||||
});
|
||||
/** 查询字典下拉列表 */
|
||||
listType({ pageSize: 100 }).then((response) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user