优化代码生成

This commit is contained in:
不做码农 2022-01-24 21:35:19 +08:00
parent e4d666f001
commit d4b80587d6
4 changed files with 10 additions and 12 deletions

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<!-- :model属性用于表单验证使用 比如下面的el-form-item 的 prop属性用于对表单值进行验证操作 --> <!-- :model属性用于表单验证使用 比如下面的el-form-item 的 prop属性用于对表单值进行验证操作 -->
<el-form :model="queryParams" label-position="left" inline ref="queryForm" :label-width="labelWidth" v-show="showSearch" @submit.native.prevent> <el-form :model="queryParams" size="small" label-position="right" inline ref="queryForm" :label-width="labelWidth" v-show="showSearch" @submit.native.prevent>
${vueQueryFormHtml} ${vueQueryFormHtml}
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
@ -176,15 +176,13 @@ $end
getList() { getList() {
$foreach(item in genTable.Columns) $foreach(item in genTable.Columns)
$if(item.HtmlType == "datetime" && item.IsQuery == true) $if(item.HtmlType == "datetime" && item.IsQuery == true)
this.queryParams["begin${item.CsharpField}"] = this.addDateRange2(this.dateRange${item.CsharpField}, 0); this.addDateRange(this.queryParams, this.dateRange${item.CsharpField}, '${item.CsharpField}');
this.queryParams["end${item.CsharpField}"] = this.addDateRange2(this.dateRange${item.CsharpField}, 1);
$end $end
$end $end
this.loading = true; this.loading = true;
treelist${genTable.BusinessName}(this.queryParams).then(res => { treelist${genTable.BusinessName}(this.queryParams).then(res => {
if (res.code == 200) { if (res.code == 200) {
this.dataList = res.data; this.dataList = res.data;
//this.total = res.data.totalNum;
this.loading = false; this.loading = false;
} }
}) })

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<!-- :model属性用于表单验证使用 比如下面的el-form-item 的 prop属性用于对表单值进行验证操作 --> <!-- :model属性用于表单验证使用 比如下面的el-form-item 的 prop属性用于对表单值进行验证操作 -->
<el-form :model="queryParams" label-position="left" inline ref="queryForm" :label-width="labelWidth" v-show="showSearch" @submit.native.prevent> <el-form :model="queryParams" size="small" label-position="right" inline ref="queryForm" :label-width="labelWidth" v-show="showSearch" @submit.native.prevent>
${vueQueryFormHtml} ${vueQueryFormHtml}
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
@ -169,7 +169,7 @@ $end
getList() { getList() {
$foreach(item in genTable.Columns) $foreach(item in genTable.Columns)
$if(item.HtmlType == "datetime" && item.IsQuery == true) $if(item.HtmlType == "datetime" && item.IsQuery == true)
this.addDateRange(this.queryParams, this.dateRange${item.CsharpField}, ${item.CsharpField}); this.addDateRange(this.queryParams, this.dateRange${item.CsharpField}, '${item.CsharpField}');
$end $end
$end $end
this.loading = true; this.loading = true;

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<!-- :model属性用于表单验证使用 比如下面的el-form-item 的 prop属性用于对表单值进行验证操作 --> <!-- :model属性用于表单验证使用 比如下面的el-form-item 的 prop属性用于对表单值进行验证操作 -->
<el-form :model="queryParams" label-position="left" inline ref="queryForm" :label-width="labelWidth" v-show="showSearch" @submit.native.prevent> <el-form :model="queryParams" size="small" label-position="right" inline ref="queryForm" :label-width="labelWidth" v-show="showSearch" @submit.native.prevent>
${vueQueryFormHtml} ${vueQueryFormHtml}
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
@ -150,7 +150,7 @@ $end
getList() { getList() {
$foreach(item in genTable.Columns) $foreach(item in genTable.Columns)
$if(item.HtmlType == "datetime" && item.IsQuery == true) $if(item.HtmlType == "datetime" && item.IsQuery == true)
this.addDateRange(this.queryParams, this.dateRange${item.CsharpField}, ${item.CsharpField}); this.addDateRange(this.queryParams, this.dateRange${item.CsharpField}, '${item.CsharpField}');
$end $end
$end $end
this.loading = true; this.loading = true;

View File

@ -180,23 +180,23 @@ namespace ZR.CodeGenerator
if (dbFieldInfo.HtmlType == GenConstants.HTML_DATETIME) if (dbFieldInfo.HtmlType == GenConstants.HTML_DATETIME)
{ {
sb.AppendLine($" <el-form-item label=\"{labelName}\">"); sb.AppendLine($" <el-form-item label=\"{labelName}\">");
sb.AppendLine($" <el-date-picker v-model=\"dateRange{dbFieldInfo.CsharpField}\" size=\"small\" type=\"datetimerange\" range-separator=\"-\" start-placeholder=\"开始日期\""); sb.AppendLine($" <el-date-picker v-model=\"dateRange{dbFieldInfo.CsharpField}\" style=\"width: 240px\" value-format=\"yyyy-MM-dd\" type=\"daterange\" range-separator=\"-\" start-placeholder=\"开始日期\"");
sb.AppendLine($" end-placeholder=\"\" placeholder=\"请选择{dbFieldInfo.ColumnComment}\" :picker-options=\"{{ firstDayOfWeek: 1}}\"></el-date-picker>"); sb.AppendLine($" end-placeholder=\"\" placeholder=\"请选择{dbFieldInfo.ColumnComment}\" :picker-options=\"{{ firstDayOfWeek: 1}}\"></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)
{ {
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}\" >");
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>");
sb.AppendLine(" </el-form-item>"); sb.AppendLine(" </el-form-item>");
} }
else if (dbFieldInfo.IsQuery) else
{ {
string inputNumTxt = CodeGeneratorTool.IsNumber(dbFieldInfo.CsharpType) ? ".number" : ""; string inputNumTxt = CodeGeneratorTool.IsNumber(dbFieldInfo.CsharpType) ? ".number" : "";
sb.AppendLine($" <el-form-item label=\"{ labelName}\" prop=\"{columnName}\">"); sb.AppendLine($" <el-form-item label=\"{ labelName}\" prop=\"{columnName}\">");
sb.AppendLine($" <el-input v-model{inputNumTxt}=\"queryParams.{columnName}\" placeholder=\"请输入{dbFieldInfo.ColumnComment}\" size=\"small\"/>"); sb.AppendLine($" <el-input v-model{inputNumTxt}=\"queryParams.{columnName}\" placeholder=\"请输入{dbFieldInfo.ColumnComment}\" />");
sb.AppendLine(" </el-form-item>"); sb.AppendLine(" </el-form-item>");
} }