更新wtm
This commit is contained in:
1 parent
f119665d29
commit
3467d4aa9d
60 files changed
+1932
-397
No files matched your search
@@ -1,7 +1,9 @@
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
@@ -48,8 +50,9 @@ namespace WalkingTec.Mvvm.Mvc.Binders
|
||||
.MethodInfo
|
||||
.CustomAttributes
|
||||
.Where(x => x.AttributeType == typeof(StringNeedLTGTAttribute)).Count();
|
||||
|
||||
if (count == 0)
|
||||
var count2 = (bindingContext.ModelMetadata as DefaultModelMetadata)?.Attributes?.PropertyAttributes?
|
||||
.Where(x => x.GetType() == typeof(JsonConverterAttribute)).Count();
|
||||
if (count == 0 && (count2==null || count2 == 0))
|
||||
{
|
||||
value = HttpUtility.HtmlEncode(value);
|
||||
}
|
||||
|
||||
@@ -134,21 +134,21 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
{
|
||||
get
|
||||
{
|
||||
/*if (_sharedir == null)
|
||||
if (_sharedir == null)
|
||||
{
|
||||
var up = Directory.GetParent(MainDir);
|
||||
var sharedir = up.GetDirectories().Where(x => x.Name.ToLower().EndsWith(".shared")).FirstOrDefault();
|
||||
if (string.IsNullOrEmpty(Area))
|
||||
{
|
||||
if (string.IsNullOrEmpty(Area))
|
||||
{
|
||||
sharedir = Directory.CreateDirectory(sharedir.FullName + $"{Path.DirectorySeparatorChar}Pages{Path.DirectorySeparatorChar}{ModelName}");
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
sharedir = Directory.CreateDirectory(sharedir.FullName + $"{Path.DirectorySeparatorChar}Pages{Path.DirectorySeparatorChar}{Area}{Path.DirectorySeparatorChar}{ModelName}");
|
||||
}
|
||||
|
||||
_sharedir = sharedir.FullName;
|
||||
}*/
|
||||
}
|
||||
return _sharedir;
|
||||
}
|
||||
}
|
||||
@@ -433,6 +433,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}ClientApp{Path.DirectorySeparatorChar}src{Path.DirectorySeparatorChar}pages{Path.DirectorySeparatorChar}{ModelName.ToLower()}{Path.DirectorySeparatorChar}store{Path.DirectorySeparatorChar}index.ts", GetResource("index.txt", "Spa.Vue.store").Replace("$modelname$", ModelName.ToLower()), Encoding.UTF8);
|
||||
File.WriteAllText($"{MainDir}{Path.DirectorySeparatorChar}ClientApp{Path.DirectorySeparatorChar}src{Path.DirectorySeparatorChar}pages{Path.DirectorySeparatorChar}{ModelName.ToLower()}{Path.DirectorySeparatorChar}store{Path.DirectorySeparatorChar}api.ts", GenerateVUEView("store.api", apipneeded), Encoding.UTF8);
|
||||
}
|
||||
#region 设置react和vue的默认页面和默认菜单,vue3不需要这部分
|
||||
var index = File.ReadAllText($"{MainDir}{Path.DirectorySeparatorChar}ClientApp{Path.DirectorySeparatorChar}src{Path.DirectorySeparatorChar}pages{Path.DirectorySeparatorChar}index.ts");
|
||||
if (index.Contains($"path: '/{ModelName.ToLower()}'") == false)
|
||||
{
|
||||
@@ -499,9 +500,10 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
if(UI == UIEnum.Blazor)
|
||||
if (UI == UIEnum.Blazor)
|
||||
{
|
||||
File.WriteAllText($"{ShareDir}{Path.DirectorySeparatorChar}Index.razor", GenerateBlazorView("Index"), Encoding.UTF8);
|
||||
File.WriteAllText($"{ShareDir}{Path.DirectorySeparatorChar}Create.razor", GenerateBlazorView("Create"), Encoding.UTF8);
|
||||
@@ -509,8 +511,29 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
File.WriteAllText($"{ShareDir}{Path.DirectorySeparatorChar}Details.razor", GenerateBlazorView("Details"), Encoding.UTF8);
|
||||
File.WriteAllText($"{ShareDir}{Path.DirectorySeparatorChar}Import.razor", GenerateBlazorView("Import"), Encoding.UTF8);
|
||||
}
|
||||
if (UI == UIEnum.VUE3)
|
||||
{
|
||||
//Todo 生成vue3页面
|
||||
var pathvue3 = $"{MainDir}{Path.DirectorySeparatorChar}ClientApp{Path.DirectorySeparatorChar}src{Path.DirectorySeparatorChar}views{Path.DirectorySeparatorChar}{Area.ToLower()}{Path.DirectorySeparatorChar}{ModelName.ToLower()}{Path.DirectorySeparatorChar}";
|
||||
if (Directory.Exists(pathvue3) == false)
|
||||
{
|
||||
Directory.CreateDirectory(pathvue3);
|
||||
}
|
||||
var pathapi = $"{MainDir}{Path.DirectorySeparatorChar}ClientApp{Path.DirectorySeparatorChar}src{Path.DirectorySeparatorChar}api{Path.DirectorySeparatorChar}{Area.ToLower()}{Path.DirectorySeparatorChar}{ModelName}{Path.DirectorySeparatorChar}";
|
||||
if (Directory.Exists(pathapi) == false)
|
||||
{
|
||||
Directory.CreateDirectory(pathapi);
|
||||
}
|
||||
File.WriteAllText($"{pathvue3}index.vue", GenerateVue3View("Index"), Encoding.UTF8);
|
||||
File.WriteAllText($"{pathvue3}create.vue", GenerateVue3View("Create"), Encoding.UTF8);
|
||||
File.WriteAllText($"{pathvue3}edit.vue", GenerateVue3View("Edit"), Encoding.UTF8);
|
||||
File.WriteAllText($"{pathvue3}details.vue", GenerateVue3View("Details"), Encoding.UTF8);
|
||||
File.WriteAllText($"{pathvue3}import.vue", GenerateVue3View("Import"), Encoding.UTF8);
|
||||
|
||||
File.WriteAllText($"{pathapi}index.ts", GenerateVue3View("indexapi"), Encoding.UTF8);
|
||||
}
|
||||
}
|
||||
/*var test = GenerateTest();
|
||||
var test = GenerateTest();
|
||||
if (test != "")
|
||||
{
|
||||
if (UI == UIEnum.LayUI && IsApi == false)
|
||||
@@ -521,7 +544,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
{
|
||||
File.WriteAllText($"{TestDir}{Path.DirectorySeparatorChar}{ModelName}ApiTest.cs", test, Encoding.UTF8);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
public string GenerateController()
|
||||
@@ -535,7 +558,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
else
|
||||
{
|
||||
dir = "Spa";
|
||||
if(UI == UIEnum.Blazor)
|
||||
if (UI == UIEnum.Blazor)
|
||||
{
|
||||
dir = "Spa.Blazor";
|
||||
}
|
||||
@@ -766,7 +789,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
{
|
||||
var middleType = modelType.GetSingleProperty(pro.FieldName).PropertyType.GenericTypeArguments[0];
|
||||
var middlename = DC.GetPropertyNameByFk(middleType, pro.SubIdField);
|
||||
if(typeof(IPersistPoco).IsAssignableFrom(Type.GetType(pro.RelatedField)))
|
||||
if (typeof(IPersistPoco).IsAssignableFrom(Type.GetType(pro.RelatedField)))
|
||||
{
|
||||
selectstring += $@"
|
||||
{pro.SubField + "_view" + prefix} = x.{pro.FieldName}.Where(y=>y.{middlename}.IsValid==true).Select(y=>y.{middlename}.{pro.SubField}).ToSepratedString(null,"",""), ";
|
||||
@@ -1043,7 +1066,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
{
|
||||
checktype = proType.GetGenericArguments()[0];
|
||||
}
|
||||
if(checktype == typeof(bool) && proType.IsNullable() == false)
|
||||
if (checktype == typeof(bool) && proType.IsNullable() == false)
|
||||
{
|
||||
fieldstr.Append($@"<wt:switch field=""{pre}.{item.FieldName}"" />");
|
||||
|
||||
@@ -1141,7 +1164,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
Type modelType = Type.GetType(SelectedModel);
|
||||
if (UI == UIEnum.LayUI && IsApi == false)
|
||||
{
|
||||
if (typeof(IBasePoco).IsAssignableFrom( modelType) || typeof(IPersistPoco).IsAssignableFrom(modelType))
|
||||
if (typeof(IBasePoco).IsAssignableFrom(modelType) || typeof(IPersistPoco).IsAssignableFrom(modelType))
|
||||
{
|
||||
rv = GetResource($"ControllerTest.txt").Replace("$cns$", ControllerNs).Replace("$tns$", TestNs).Replace("$vns$", VMNs).Replace("$model$", ModelName).Replace("$mns$", ModelNS).Replace("$dns$", DataNs);
|
||||
}
|
||||
@@ -1223,7 +1246,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
if (pro.Value == "$fk$")
|
||||
{
|
||||
mpros += $@"
|
||||
v2.{ pro.Key} = v1.{pro.Key}; ";
|
||||
v2.{pro.Key} = v1.{pro.Key}; ";
|
||||
|
||||
}
|
||||
else
|
||||
@@ -1260,29 +1283,29 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
string del = $"Assert.AreEqual(data, null);";
|
||||
string mdel = @"Assert.AreEqual(data1, null);
|
||||
Assert.AreEqual(data2, null);";
|
||||
if (typeof(IPersistPoco).IsAssignableFrom( modelType))
|
||||
if (typeof(IPersistPoco).IsAssignableFrom(modelType))
|
||||
{
|
||||
del = $"Assert.AreEqual(data.IsValid, false);";
|
||||
mdel = @"Assert.AreEqual(data1.IsValid, false);
|
||||
Assert.AreEqual(data2.IsValid, false);";
|
||||
del = $"Assert.AreEqual(data, null);";
|
||||
mdel = @"Assert.AreEqual(data1, null);
|
||||
Assert.AreEqual(data2, null);";
|
||||
}
|
||||
|
||||
rv = rv.Replace("$cpros$", cpros).Replace("$epros$", epros).Replace("$pros$", pros).Replace("$mpros$", mpros)
|
||||
.Replace("$assert$", assert).Replace("$eassert$", eassert).Replace("$fc$", fc).Replace("$add$", add).Replace("$del$", del).Replace("$mdel$", mdel)
|
||||
.Replace("$linkedpros$", linkedpros).Replace("$linkedfc$", linkedfc).Replace("$meassert$", meassert);
|
||||
|
||||
rv = GetRelatedNamespace(FieldInfos.Where(x=>string.IsNullOrEmpty( x.RelatedField) == false).ToList(), rv);
|
||||
rv = GetRelatedNamespace(FieldInfos.Where(x => string.IsNullOrEmpty(x.RelatedField) == false).ToList(), rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
private string GenerateAddFKModel(string keyname, Type t, List<Type> exist)
|
||||
{
|
||||
if(exist == null)
|
||||
if (exist == null)
|
||||
{
|
||||
exist = new List<Type>();
|
||||
}
|
||||
if(exist.Contains(t) == true)
|
||||
if (exist.Contains(t) == true)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
@@ -1666,7 +1689,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldstr.AppendLine($@" <Col span={{24}}>
|
||||
fieldstr.AppendLine($@" <Col span={{24}}>
|
||||
<FormItem {{...props}} fieId=""Entity.{item.FieldName}"" layout=""row"" />
|
||||
</Col>");
|
||||
}
|
||||
@@ -2127,7 +2150,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
public string GenerateBlazorView(string name)
|
||||
{
|
||||
string pagepath = string.IsNullOrEmpty(Area) ? $"/{ModelName}" : $"/{Area}/{ModelName}";
|
||||
if(name != "Index")
|
||||
if (name != "Index")
|
||||
{
|
||||
pagepath += $"/{name}";
|
||||
}
|
||||
@@ -2307,7 +2330,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
controltype = "WTDateRange";
|
||||
}
|
||||
}
|
||||
if(controltype == "Select" || controltype == "MultiSelect")
|
||||
if (controltype == "Select" || controltype == "MultiSelect")
|
||||
{
|
||||
ph = "PlaceHolder=\"@WtmBlazor.Localizer[\"Sys.All\"]\"";
|
||||
}
|
||||
@@ -2336,7 +2359,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
");
|
||||
}
|
||||
|
||||
return rv.Replace("$columns$", fieldstr.ToString()).Replace("$searchfields$",fieldstr2.ToString()).Replace("$init$", apiinit.ToString()).Replace("$fieldinit$", fieldinit.ToString());
|
||||
return rv.Replace("$columns$", fieldstr.ToString()).Replace("$searchfields$", fieldstr2.ToString()).Replace("$init$", apiinit.ToString()).Replace("$fieldinit$", fieldinit.ToString());
|
||||
}
|
||||
|
||||
|
||||
@@ -2371,7 +2394,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
}
|
||||
else
|
||||
{
|
||||
bindfield = "Entity."+ item.FieldName;
|
||||
bindfield = "Entity." + item.FieldName;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(item.RelatedField) == false)
|
||||
@@ -2488,7 +2511,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
private List<SelectedItem> {item.Key} = new List<SelectedItem>();
|
||||
");
|
||||
}
|
||||
return rv.Replace("$formfields$", fieldstr.ToString()).Replace("$fieldinit$", fieldinit.ToString()).Replace("$init$", apiinit.ToString());
|
||||
return rv.Replace("$formfields$", fieldstr.ToString()).Replace("$fieldinit$", fieldinit.ToString()).Replace("$init$", apiinit.ToString());
|
||||
}
|
||||
if (name == "Details")
|
||||
{
|
||||
@@ -2606,6 +2629,426 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
return rv;
|
||||
}
|
||||
|
||||
public string GenerateVue3View(string name)
|
||||
{
|
||||
string pagepath = string.IsNullOrEmpty(Area) ? $"/{ModelName}" : $"/{Area.ToLower()}/{ModelName}";
|
||||
|
||||
var rv = GetResource($"{name}.txt", "Spa.Vue3")
|
||||
.Replace("$modelname$", ModelName)
|
||||
.Replace("$vmnamespace$", VMNs)
|
||||
.Replace("$des$", ModuleName)
|
||||
.Replace("$controllername$", $"{ControllerNs};{ModelName}")
|
||||
.Replace("$pagepath$", pagepath);
|
||||
Type modelType = Type.GetType(SelectedModel);
|
||||
if (name == "Index")
|
||||
{
|
||||
StringBuilder fieldstr = new StringBuilder();
|
||||
StringBuilder fieldstr2 = new StringBuilder();
|
||||
StringBuilder searchentity = new StringBuilder();
|
||||
var pros = FieldInfos.Where(x => x.IsListField == true).ToList();
|
||||
var pros2 = FieldInfos.Where(x => x.IsSearcherField == true).ToList();
|
||||
List<PropertyInfo> existSubPro = new List<PropertyInfo>();
|
||||
Dictionary<string, string> apis = new Dictionary<string, string>();
|
||||
Dictionary<string, string> multiapis = new Dictionary<string, string>();
|
||||
for (int i = 0; i < pros.Count; i++)
|
||||
{
|
||||
var item = pros[i];
|
||||
var mpro = modelType.GetSingleProperty(item.FieldName);
|
||||
string render = "";
|
||||
string template = "text";
|
||||
string newname = item.FieldName;
|
||||
var property = modelType.GetSingleProperty(item.FieldName);
|
||||
string label = property.GetPropertyDisplayName();
|
||||
if (mpro.PropertyType.IsBoolOrNullableBool())
|
||||
{
|
||||
template = "switch";
|
||||
}
|
||||
//if (mpro.PropertyType == typeof(DateTime) || mpro.PropertyType == typeof(DateTime?))
|
||||
//{
|
||||
// render = "FormatString=\"yyyy-MM-dd HH: mm: ss\"";
|
||||
|
||||
//}
|
||||
if (string.IsNullOrEmpty(item.RelatedField) == false)
|
||||
{
|
||||
var subtype = Type.GetType(item.RelatedField);
|
||||
string prefix = "";
|
||||
if (subtype == typeof(FileAttachment))
|
||||
{
|
||||
if (item.FieldName.ToLower().Contains("photo") || item.FieldName.ToLower().Contains("pic") || item.FieldName.ToLower().Contains("icon") || item.FieldName.ToLower().Contains("zhaopian") || item.FieldName.ToLower().Contains("tupian"))
|
||||
{
|
||||
template = "image";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
var fk = DC.GetFKName2(modelType, item.FieldName);
|
||||
newname = fk;
|
||||
}
|
||||
else
|
||||
{
|
||||
var subpro = subtype.GetSingleProperty(item.SubField);
|
||||
existSubPro.Add(subpro);
|
||||
int count = existSubPro.Where(x => x.Name == subpro.Name).Count();
|
||||
if (count > 1)
|
||||
{
|
||||
prefix = count + "";
|
||||
}
|
||||
newname = item.SubField + "_view" + prefix;
|
||||
}
|
||||
}
|
||||
fieldstr.Append($@"
|
||||
{{title:'{label}',key: '{newname}',type: '{template}',isCheck: true}},");
|
||||
|
||||
}
|
||||
for (int i = 0; i < pros2.Count; i++)
|
||||
{
|
||||
string controltype = "input";
|
||||
string sitems = "";
|
||||
string bindfield = "";
|
||||
string ph = "";
|
||||
var item = pros2[i];
|
||||
var property = modelType.GetSingleProperty(item.FieldName);
|
||||
string label = property.GetPropertyDisplayName();
|
||||
if (item.SubField == "`file")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(item.RelatedField) == false)
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.SubIdField) == true)
|
||||
{
|
||||
var fk = DC.GetFKName2(modelType, item.FieldName);
|
||||
bindfield = fk;
|
||||
}
|
||||
else
|
||||
{
|
||||
bindfield = $"Selected{item.FieldName}IDs";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bindfield = item.FieldName;
|
||||
}
|
||||
|
||||
searchentity.AppendLine($@" {bindfield}: null,");
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(item.RelatedField) == false)
|
||||
{
|
||||
var subtype = Type.GetType(item.RelatedField);
|
||||
var tempname = $"All{subtype.Name}s";
|
||||
if (string.IsNullOrEmpty(item.SubIdField) == true)
|
||||
{
|
||||
controltype = "select";
|
||||
sitems += $@"
|
||||
<el-option v-for=""item in state{ModelName}.{tempname}"" :key=""item.Value"" :value=""item.Value"" :label=""item.Text""></el-option>";
|
||||
}
|
||||
else
|
||||
{
|
||||
ph += " multiple";
|
||||
}
|
||||
ph += $" :data=\"state{ModelName}.{tempname}\"";
|
||||
if (apis.ContainsKey(tempname) == false && multiapis.ContainsKey(tempname) == false)
|
||||
{
|
||||
if (controltype == "select")
|
||||
{
|
||||
apis.Add(tempname, $"/api/{ModelName}/Get{subtype.Name}s");
|
||||
}
|
||||
else
|
||||
{
|
||||
multiapis.Add(tempname, $"/api/{ModelName}/Get{subtype.Name}s");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var proType = modelType.GetSingleProperty(item.FieldName)?.PropertyType;
|
||||
Type checktype = proType;
|
||||
if (proType.IsNullable())
|
||||
{
|
||||
checktype = proType.GetGenericArguments()[0];
|
||||
}
|
||||
if (checktype == typeof(bool))
|
||||
{
|
||||
controltype = "select";
|
||||
sitems = $@"
|
||||
<el-option :key=""1"" :value=true :label=""$t('message._system.common.vm.tips_bool_true')""></el-option>
|
||||
<el-option :key=""0"" :value=false :label=""$t('message._system.common.vm.tips_bool_false')""></el-option>
|
||||
";
|
||||
}
|
||||
else if (checktype.IsEnum())
|
||||
{
|
||||
controltype = "select";
|
||||
var es = checktype.ToListItems();
|
||||
for (int a = 0; a < es.Count; a++)
|
||||
{
|
||||
var e = es[a];
|
||||
sitems += $@"
|
||||
<el-option key=""{e.Value}"" value=""{e.Value}"" label=""{e.Text}""></el-option>";
|
||||
}
|
||||
|
||||
}
|
||||
else if (checktype.IsNumber())
|
||||
{
|
||||
controltype = "input-number";
|
||||
}
|
||||
else if (checktype == typeof(string))
|
||||
{
|
||||
}
|
||||
else if (checktype == typeof(DateTime))
|
||||
{
|
||||
controltype = "date-picker";
|
||||
}
|
||||
}
|
||||
if (controltype == "Select" || controltype == "MultiSelect")
|
||||
{
|
||||
ph = "PlaceHolder=\"@WtmBlazor.Localizer[\"Sys.All\"]\"";
|
||||
}
|
||||
//<{controltype} @bind-Value=""@SearchModel.{bindfield}"" {sitems} {ph}/>
|
||||
fieldstr2.Append($@"
|
||||
<el-col :xs=""24"" :lg=""12"" class=""mb20"">
|
||||
<el-form-item ref=""{bindfield}_FormItem"" prop=""{bindfield}"" label=""{label}"">
|
||||
<el-{controltype} v-model=""searchData{ModelName}.{bindfield}""{ph} clearable>{sitems}</el-{controltype}>
|
||||
</el-form-item>
|
||||
</el-col>");
|
||||
}
|
||||
StringBuilder apiinit = new StringBuilder();
|
||||
StringBuilder fieldinit = new StringBuilder();
|
||||
foreach (var item in apis)
|
||||
{
|
||||
apiinit.Append(@$"
|
||||
other.getSelectList('{item.Value}',[],false).then(x=>{{state{ModelName}.{item.Key} = x}});
|
||||
");
|
||||
fieldinit.Append($@"
|
||||
{item.Key}: [] as any[],");
|
||||
|
||||
}
|
||||
foreach (var item in multiapis)
|
||||
{
|
||||
apiinit.Append(@$"
|
||||
other.getSelectList('{item.Value}',[],false).then(x=>{{state{ModelName}.{item.Key} = x}});
|
||||
");
|
||||
fieldinit.Append($@"
|
||||
{item.Key}: [] as any[],");
|
||||
}
|
||||
|
||||
|
||||
return rv.Replace("$columns$", fieldstr.ToString()).Replace("$searchentity$", searchentity.ToString()).Replace("$searchfields$", fieldstr2.ToString()).Replace("$init$", apiinit.ToString()).Replace("$fieldinit$", fieldinit.ToString());
|
||||
}
|
||||
|
||||
if (name == "Create" || name == "Edit" || name == "Details")
|
||||
{
|
||||
StringBuilder fieldstr = new StringBuilder();
|
||||
StringBuilder fieldentityinit = new StringBuilder();
|
||||
StringBuilder selectfieldinit = new StringBuilder();
|
||||
var pros = FieldInfos.Where(x => x.IsFormField == true).ToList();
|
||||
|
||||
if (name != "Create")
|
||||
{
|
||||
fieldentityinit.AppendLine($@" ID: null,");
|
||||
}
|
||||
//生成表单model
|
||||
Dictionary<string, string> apis = new Dictionary<string, string>();
|
||||
Dictionary<string, string> multiapis = new Dictionary<string, string>();
|
||||
|
||||
|
||||
for (int i = 0; i < pros.Count; i++)
|
||||
{
|
||||
var item = pros[i];
|
||||
string controltype = "el-input";
|
||||
string sitems = "";
|
||||
string bindfield = "";
|
||||
string ph = "";
|
||||
var property = modelType.GetSingleProperty(item.FieldName);
|
||||
string label = property.GetPropertyDisplayName();
|
||||
bool isrequired = property.IsPropertyRequired();
|
||||
var fktest = DC.GetFKName2(modelType, item.FieldName);
|
||||
if (string.IsNullOrEmpty(fktest) == false)
|
||||
{
|
||||
isrequired = modelType.GetSingleProperty(fktest).IsPropertyRequired();
|
||||
}
|
||||
string rules = "";
|
||||
if (isrequired == true)
|
||||
{
|
||||
rules = $@" :rules=""[{{ required: true, message:'{label}为必填项',trigger:'blur'}}]""";
|
||||
}
|
||||
if (string.IsNullOrEmpty(item.RelatedField) == false && string.IsNullOrEmpty(item.SubIdField) == true)
|
||||
{
|
||||
var fk = DC.GetFKName2(modelType, item.FieldName);
|
||||
fieldentityinit.AppendLine($@" {fk}: null,");
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldentityinit.AppendLine($@" {item.FieldName}: null,");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(item.RelatedField) == false)
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.SubIdField) == true)
|
||||
{
|
||||
var fk = DC.GetFKName2(modelType, item.FieldName);
|
||||
bindfield = "Entity." + fk;
|
||||
}
|
||||
else
|
||||
{
|
||||
bindfield = $"Selected{item.FieldName}IDs";
|
||||
selectfieldinit.AppendLine($@" {bindfield}: [],");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bindfield = "Entity." + item.FieldName;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(item.RelatedField) == false)
|
||||
{
|
||||
var subtype = Type.GetType(item.RelatedField);
|
||||
if (item.SubField == "`file")
|
||||
{
|
||||
if (item.FieldName.ToLower().Contains("photo") || item.FieldName.ToLower().Contains("pic") || item.FieldName.ToLower().Contains("icon") || item.FieldName.ToLower().Contains("zhaopian") || item.FieldName.ToLower().Contains("tupian"))
|
||||
{
|
||||
controltype = "wtm-upload-image";
|
||||
}
|
||||
else
|
||||
{
|
||||
controltype = "wtm-upload-file";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var tempname = $"All{subtype.Name}s";
|
||||
if (string.IsNullOrEmpty(item.SubIdField) == true)
|
||||
{
|
||||
controltype = "el-select";
|
||||
sitems = $@"
|
||||
<el-option v-for=""item in state{ModelName}.{tempname}"" :key=""item.Value"" :value=""item.Value"" :label=""item.Text""></el-option>";
|
||||
}
|
||||
else
|
||||
{
|
||||
controltype = "el-transfer";
|
||||
ph += $@" :data=""state{ModelName}.{tempname}""";
|
||||
}
|
||||
|
||||
//sitems = $"Items=\"@{tempname}\"";
|
||||
if (apis.ContainsKey(tempname) == false && multiapis.ContainsKey(tempname) == false)
|
||||
{
|
||||
if (controltype == "el-select")
|
||||
{
|
||||
apis.Add(tempname, $"/api/{ModelName}/Get{subtype.Name}s");
|
||||
}
|
||||
else
|
||||
{
|
||||
multiapis.Add(tempname, $"/api/{ModelName}/Get{subtype.Name}s");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var proType = modelType.GetSingleProperty(item.FieldName)?.PropertyType;
|
||||
Type checktype = proType;
|
||||
if (proType.IsNullable())
|
||||
{
|
||||
checktype = proType.GetGenericArguments()[0];
|
||||
}
|
||||
if (checktype == typeof(bool))
|
||||
{
|
||||
controltype = "el-select";
|
||||
sitems = $@"
|
||||
<el-option :key=""1"" :value=true :label=""$t('message._system.common.vm.tips_bool_true')""></el-option>
|
||||
<el-option :key=""0"" :value=false :label=""$t('message._system.common.vm.tips_bool_false')""></el-option>
|
||||
";
|
||||
}
|
||||
else if (checktype.IsEnum())
|
||||
{
|
||||
controltype = "el-select";
|
||||
var es = checktype.ToListItems();
|
||||
for (int a = 0; a < es.Count; a++)
|
||||
{
|
||||
var e = es[a];
|
||||
sitems += $@"
|
||||
<el-option key=""{e.Value}"" value=""{e.Value}"" label=""{e.Text}""></el-option>";
|
||||
}
|
||||
|
||||
}
|
||||
else if (checktype.IsNumber())
|
||||
{
|
||||
controltype = "el-input-number";
|
||||
}
|
||||
else if (checktype == typeof(string))
|
||||
{
|
||||
}
|
||||
else if (checktype == typeof(DateTime))
|
||||
{
|
||||
controltype = "el-date-picker";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (name == "Details")
|
||||
{
|
||||
ph += " disabled";
|
||||
}
|
||||
if (controltype == "el-transfer")
|
||||
{
|
||||
fieldstr.Append($@"
|
||||
<el-col :xs=""24"" :lg=""24"" class=""mb20"">
|
||||
<el-form-item ref=""{bindfield.Replace(".", "_")}_FormItem"" prop=""{bindfield}"" label=""{label}""{rules}>
|
||||
<{controltype} v-model=""state{ModelName}.vmModel.{bindfield}""{ph} clearable>{sitems}</{controltype}>
|
||||
</el-form-item>
|
||||
</el-col>");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
fieldstr.Append($@"
|
||||
<el-col :xs=""24"" :lg=""12"" class=""mb20"">
|
||||
<el-form-item ref=""{bindfield.Replace(".", "_")}_FormItem"" prop=""{bindfield}"" label=""{label}""{rules}>
|
||||
<{controltype} v-model=""state{ModelName}.vmModel.{bindfield}""{ph} clearable>{sitems}</{controltype}>
|
||||
</el-form-item>
|
||||
</el-col>");
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder apiinit = new StringBuilder();
|
||||
StringBuilder fieldinit = new StringBuilder();
|
||||
foreach (var item in apis)
|
||||
{
|
||||
apiinit.Append(@$"
|
||||
other.getSelectList('{item.Value}',[],false).then(x=>{{state{ModelName}.{item.Key} = x}});
|
||||
");
|
||||
fieldinit.Append($@"
|
||||
{item.Key}: [] as any[],");
|
||||
|
||||
}
|
||||
foreach (var item in multiapis)
|
||||
{
|
||||
apiinit.Append(@$"
|
||||
other.getSelectList('{item.Value}',[],false).then(x=>{{state{ModelName}.{item.Key} = x}});
|
||||
");
|
||||
fieldinit.Append($@"
|
||||
{item.Key}: [] as any[],");
|
||||
}
|
||||
|
||||
return rv.Replace("$formfields$", fieldstr.ToString()).Replace("$fieldinit$", fieldinit.ToString()).Replace("$selectfieldinit$", selectfieldinit.ToString())
|
||||
.Replace("$fieldentityinit$", fieldentityinit.ToString()).Replace("$init$", apiinit.ToString());
|
||||
}
|
||||
|
||||
if (name == "indexapi")
|
||||
{
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
public string GetResource(string fileName, string subdir = "")
|
||||
{
|
||||
//获取编译在程序中的Controller原始代码文本
|
||||
|
||||
@@ -19,9 +19,6 @@ using WalkingTec.Mvvm.Core.Json;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.AspNetCore.Mvc.ViewEngines;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
using System.Dynamic;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
|
||||
namespace WalkingTec.Mvvm.Mvc.Filters
|
||||
{
|
||||
@@ -98,7 +95,7 @@ namespace WalkingTec.Mvvm.Mvc.Filters
|
||||
if (context.HttpContext.Items.ContainsKey("DONOTUSE_REQUESTBODY"))
|
||||
{
|
||||
string body = context.HttpContext.Items["DONOTUSE_REQUESTBODY"].ToString();
|
||||
var joption = new JsonSerializerOptions();
|
||||
var joption = new JsonSerializerOptions(Core.CoreProgram.DefaultJsonOption);
|
||||
joption.Converters.Add(new BodyConverter());
|
||||
try
|
||||
{
|
||||
@@ -366,7 +363,7 @@ namespace WalkingTec.Mvvm.Mvc.Filters
|
||||
if (context.Result is PartialViewResult pvr)
|
||||
{
|
||||
model = pvr.Model as BaseVM;
|
||||
context.HttpContext.Response.WriteAsync($"<script>ff.ResizeChart('{model?.ViewDivId}')</script>");
|
||||
context.HttpContext.Response.WriteAsync($"<script>try{{ff.ResizeChart('{model?.ViewDivId}')}}catch{{}}</script>");
|
||||
}
|
||||
|
||||
//如果是来自Error,则已经记录过日志,跳过
|
||||
|
||||
@@ -194,6 +194,10 @@ namespace WalkingTec.Mvvm.Mvc.Filters
|
||||
{
|
||||
context.Result = ctrl.Forbid(JwtBearerDefaults.AuthenticationScheme);
|
||||
}
|
||||
else if(controller is BaseApiController bac)
|
||||
{
|
||||
context.Result = bac.Forbid();
|
||||
}
|
||||
else
|
||||
{
|
||||
ContentResult cr = new ContentResult()
|
||||
@@ -234,8 +238,12 @@ namespace WalkingTec.Mvvm.Mvc.Filters
|
||||
{
|
||||
context.Result = ctrl.Forbid(JwtBearerDefaults.AuthenticationScheme);
|
||||
}
|
||||
else
|
||||
{
|
||||
else if (controller is BaseApiController bac)
|
||||
{
|
||||
context.Result = bac.Forbid();
|
||||
}
|
||||
else
|
||||
{
|
||||
ContentResult cr = new ContentResult()
|
||||
{
|
||||
Content = MvcProgram._localizer["Sys.NoPrivilege"],
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
|
||||
<template>
|
||||
<div class="card-fill layout-padding">
|
||||
<el-card shadow="hover" class="layout-padding-auto" >
|
||||
<el-form ref="formRef$modelname$" :model="state$modelname$.vmModel" label-width="100px">
|
||||
<el-row>
|
||||
$formfields$
|
||||
</el-row>
|
||||
|
||||
<div style="text-align:right;">
|
||||
<WtmButton @click="onSubmit$modelname$" type="primary" :button-text="$t('message._system.common.vm.submit')" style="margin-top:15px;"/>
|
||||
<WtmButton @click="onClose$modelname$" type="primary" :button-text="$t('message._system.common.vm.cancel')" style="margin-top:15px;"/>
|
||||
</div>
|
||||
</el-form>
|
||||
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<script setup lang="ts" name="message._system.common.vm.add;false">
|
||||
import { ElMessageBox, ElMessage } from 'element-plus';
|
||||
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
|
||||
import { $modelname$Api } from '/@/api$pagepath$';
|
||||
import other from '/@/utils/other';
|
||||
import fileApi from '/@/api/file';
|
||||
import { useRouter } from "vue-router";
|
||||
const ci = getCurrentInstance() as any;
|
||||
|
||||
// 定义变量内容
|
||||
const formRef$modelname$ = ref();
|
||||
const state$modelname$ = reactive({
|
||||
vmModel: {
|
||||
Entity:{
|
||||
$fieldentityinit$
|
||||
},
|
||||
$selectfieldinit$
|
||||
},
|
||||
|
||||
$fieldinit$
|
||||
});
|
||||
|
||||
// 取消
|
||||
const onClose$modelname$ = () => {
|
||||
closeDialog();
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit$modelname$ = () => {
|
||||
formRef$modelname$.value?.validate((valid: boolean, fields: any) => {
|
||||
if (valid) {
|
||||
$modelname$Api().add(state$modelname$.vmModel).then(() => {
|
||||
ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
|
||||
emit('refresh');
|
||||
closeDialog();
|
||||
}).catch((error) => {
|
||||
other.setFormError(ci, error);
|
||||
})
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
// 页面加载时
|
||||
onMounted(() => {
|
||||
$init$
|
||||
});
|
||||
|
||||
// 定义子组件向父组件传值/事件
|
||||
const emit = defineEmits(['refresh','closeDialog']);
|
||||
// 关闭弹窗
|
||||
const closeDialog = () => {
|
||||
emit('closeDialog');
|
||||
};
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
|
||||
<template>
|
||||
<div class="card-fill layout-padding">
|
||||
<el-card shadow="hover" class="layout-padding-auto" >
|
||||
<el-form ref="formRef$modelname$" :model="state$modelname$.vmModel" label-width="100px">
|
||||
<el-row>
|
||||
$formfields$
|
||||
</el-row>
|
||||
|
||||
<div style="text-align:right;">
|
||||
<WtmButton @click="onClose$modelname$" type="primary" :button-text="$t('message._system.common.vm.cancel')" style="margin-top:15px;"/>
|
||||
</div>
|
||||
</el-form>
|
||||
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<script setup lang="ts" name="message._system.common.vm.detail;false">
|
||||
import { ElMessageBox, ElMessage } from 'element-plus';
|
||||
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
|
||||
import { $modelname$Api } from '/@/api$pagepath$';
|
||||
import other from '/@/utils/other';
|
||||
import fileApi from '/@/api/file';
|
||||
import { useRouter } from "vue-router";
|
||||
const ci = getCurrentInstance() as any;
|
||||
|
||||
// 定义变量内容
|
||||
const formRef$modelname$ = ref();
|
||||
const state$modelname$ = reactive({
|
||||
vmModel: {
|
||||
Entity:{
|
||||
$fieldentityinit$
|
||||
},
|
||||
$selectfieldinit$
|
||||
},
|
||||
|
||||
$fieldinit$
|
||||
});
|
||||
|
||||
// 取消
|
||||
const onClose$modelname$ = () => {
|
||||
closeDialog();
|
||||
};
|
||||
|
||||
|
||||
// 页面加载时
|
||||
onMounted(() => {
|
||||
$init$
|
||||
if (ci.attrs["wtmdata"]) {
|
||||
state$modelname$.vmModel.Entity.ID = ci.attrs["wtmdata"].ID;
|
||||
}
|
||||
else if (useRouter().currentRoute.value.query.id) {
|
||||
state$modelname$.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
|
||||
}
|
||||
$modelname$Api().get(state$modelname$.vmModel.Entity.ID ?? "").then((data: any) => other.setValue(state$modelname$.vmModel, data));
|
||||
});
|
||||
|
||||
// 定义子组件向父组件传值/事件
|
||||
const emit = defineEmits(['refresh','closeDialog']);
|
||||
// 关闭弹窗
|
||||
const closeDialog = () => {
|
||||
emit('closeDialog');
|
||||
};
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
|
||||
<template>
|
||||
<div class="card-fill layout-padding">
|
||||
<el-card shadow="hover" class="layout-padding-auto" >
|
||||
<el-form ref="formRef$modelname$" :model="state$modelname$.vmModel" label-width="100px">
|
||||
<el-row>
|
||||
$formfields$
|
||||
</el-row>
|
||||
|
||||
<div style="text-align:right;">
|
||||
<WtmButton @click="onSubmit$modelname$" type="primary" :button-text="$t('message._system.common.vm.submit')" style="margin-top:15px;"/>
|
||||
<WtmButton @click="onClose$modelname$" type="primary" :button-text="$t('message._system.common.vm.cancel')" style="margin-top:15px;"/>
|
||||
</div>
|
||||
</el-form>
|
||||
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<script setup lang="ts" name="message._system.common.vm.edit;false">
|
||||
import { ElMessageBox, ElMessage } from 'element-plus';
|
||||
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
|
||||
import { $modelname$Api } from '/@/api$pagepath$';
|
||||
import other from '/@/utils/other';
|
||||
import fileApi from '/@/api/file';
|
||||
import { useRouter } from "vue-router";
|
||||
const ci = getCurrentInstance() as any;
|
||||
|
||||
// 定义变量内容
|
||||
const formRef$modelname$ = ref();
|
||||
const state$modelname$ = reactive({
|
||||
vmModel: {
|
||||
Entity:{
|
||||
$fieldentityinit$
|
||||
},
|
||||
$selectfieldinit$
|
||||
},
|
||||
|
||||
$fieldinit$
|
||||
});
|
||||
|
||||
// 取消
|
||||
const onClose$modelname$ = () => {
|
||||
closeDialog();
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit$modelname$ = () => {
|
||||
formRef$modelname$.value?.validate((valid: boolean, fields: any) => {
|
||||
if (valid) {
|
||||
$modelname$Api().edit(state$modelname$.vmModel).then(() => {
|
||||
ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
|
||||
emit('refresh');
|
||||
closeDialog();
|
||||
}).catch((error) => {
|
||||
other.setFormError(ci, error);
|
||||
})
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
// 页面加载时
|
||||
onMounted(() => {
|
||||
$init$
|
||||
if (ci.attrs["wtmdata"]) {
|
||||
state$modelname$.vmModel.Entity.ID = ci.attrs["wtmdata"].ID;
|
||||
}
|
||||
else if (useRouter().currentRoute.value.query.id) {
|
||||
state$modelname$.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
|
||||
}
|
||||
$modelname$Api().get(state$modelname$.vmModel.Entity.ID ?? "").then((data: any) => other.setValue(state$modelname$.vmModel, data));
|
||||
});
|
||||
|
||||
// 定义子组件向父组件传值/事件
|
||||
const emit = defineEmits(['refresh','closeDialog']);
|
||||
// 关闭弹窗
|
||||
const closeDialog = () => {
|
||||
emit('closeDialog');
|
||||
};
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
|
||||
<template>
|
||||
<div class="card-fill layout-padding">
|
||||
<el-card shadow="hover" class="layout-padding-auto" >
|
||||
|
||||
<el-form ref="formRef" :model="state.vmModel" label-width="90px" >
|
||||
<WtmImportor url="/api/$modelname$/GetExcelTemplate" v-model="state.vmModel.UploadFileId" :files="state.vmModel.files"/>
|
||||
<div v-if="state.errorFileId" style="margin-top: 10px;vertical-align: bottom;">
|
||||
<el-button @click="onErrorFile" size="small" type="danger">{{ $t('message._system.common.vm.importtip') }}</el-button>
|
||||
</div>
|
||||
</el-form>
|
||||
<footer class="el-dialog__footer" style="padding: unset;padding-top: 10px;">
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="onCancel" >{{$t('message._system.common.vm.cancel')}}</el-button>
|
||||
<el-button :disabled="state.vmModel.UploadFileId===null" type="primary" @click="onSubmit" >{{$t('message._system.common.vm.submit')}}</el-button>
|
||||
</span>
|
||||
</footer>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<script setup lang="ts" name="message._system.common.vm.import;false">
|
||||
import { ElMessageBox, ElMessage } from 'element-plus';
|
||||
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
|
||||
import { $modelname$Api } from '/@/api$pagepath$';
|
||||
import other from '/@/utils/other';
|
||||
import fileApi from '/@/api/file';
|
||||
import { useRouter } from "vue-router";
|
||||
const ci = getCurrentInstance() as any;
|
||||
|
||||
|
||||
// 定义变量内容
|
||||
const formRef = ref();
|
||||
const state = reactive({
|
||||
vmModel: {
|
||||
UploadFileId: null,
|
||||
files: []
|
||||
},
|
||||
errorFileId: null
|
||||
});
|
||||
// 取消
|
||||
const onCancel = () => {
|
||||
closeDialog();
|
||||
};
|
||||
|
||||
const onSubmit = () => {
|
||||
$modelname$Api().import(state.vmModel)
|
||||
.then((res) => {
|
||||
ElMessage.success(ci.proxy.$t('message._system.common.vm.importsuc',{count:res}));
|
||||
emit('refresh');
|
||||
closeDialog();
|
||||
})
|
||||
.catch((error) => {
|
||||
state.errorFileId = error.FormError['Entity.ErrorFileId']
|
||||
ElMessage.error(error.FormError['Entity.Import']);
|
||||
});
|
||||
}
|
||||
|
||||
const onErrorFile = () => {
|
||||
fileApi().downloadFile(state.errorFileId);
|
||||
}
|
||||
|
||||
// 页面加载时
|
||||
onMounted(() => {
|
||||
|
||||
});
|
||||
|
||||
// 定义子组件向父组件传值/事件
|
||||
const emit = defineEmits(['refresh','closeDialog']);
|
||||
// 关闭弹窗
|
||||
const closeDialog = () => {
|
||||
emit('closeDialog');
|
||||
};
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
|
||||
<template>
|
||||
<div class="card-fill layout-padding">
|
||||
<el-card shadow="hover" class="layout-padding-auto" >
|
||||
<WtmSearcher v-model="searchData$modelname$" @search="getTableData$modelname$">
|
||||
<el-row>
|
||||
$searchfields$
|
||||
</el-row>
|
||||
|
||||
</WtmSearcher>
|
||||
|
||||
<div style="text-align: right;">
|
||||
<WtmButton v-auth="'/api/$modelname$/Add'" icon='fa fa-plus' type='primary' :button-text="$t('message._system.common.vm.add')" @click="OnCreateClick()"/>
|
||||
<WtmButton v-auth="'/api/$modelname$/BatchDelete'" icon='fa fa-trash' type='danger' :button-text="$t('message._system.common.vm.batchdelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
|
||||
<WtmButton v-auth="'/api/$modelname$/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message._system.common.vm.import')" @click="OnImportClick()"/>
|
||||
<WtmButton v-auth="'/api/$modelname$/$modelname$ExportExcel'" icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message._system.common.vm.export')" @click="onExport()"/>
|
||||
|
||||
</div>
|
||||
<WtmTable ref="tableRef$modelname$" v-bind="tableData$modelname$">
|
||||
<template #operation>
|
||||
<el-table-column :label="$t('message._system.common.vm.operate')" width="180">
|
||||
<template v-slot="scope">
|
||||
<el-button text type="primary" @click="OnEditrowClick(scope.row)" v-auth="'/api/$modelname$/Edit'">{{ $t('message._system.common.vm.edit') }}</el-button>
|
||||
<el-button text type="primary" @click="OnDetailsrowClick(scope.row)" v-auth="'/api/$modelname$/{id}'">{{ $t('message._system.common.vm.detail') }}</el-button>
|
||||
<el-popconfirm :title="$t('message._system.common.vm.deletetip')" @confirm="onDelete(scope.row)">
|
||||
<template #reference>
|
||||
<el-button text type="danger" v-auth="'/api/$modelname$/BatchDelete'">{{ $t('message._system.common.vm.delete') }}</el-button>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</template>
|
||||
</WtmTable>
|
||||
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<script setup lang="ts" name="$des$;true;$controllername$">
|
||||
import { ElMessageBox, ElMessage } from 'element-plus';
|
||||
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
|
||||
import { $modelname$Api } from '/@/api$pagepath$';
|
||||
import other from '/@/utils/other';
|
||||
import fileApi from '/@/api/file';
|
||||
import { useRouter } from "vue-router";
|
||||
const ci = getCurrentInstance() as any;
|
||||
|
||||
const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
|
||||
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
|
||||
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
|
||||
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));
|
||||
|
||||
const state$modelname$ = reactive({
|
||||
$fieldinit$
|
||||
});
|
||||
|
||||
const searchData$modelname$ = ref({
|
||||
$searchentity$
|
||||
});
|
||||
|
||||
// 定义变量内容
|
||||
const tableRef$modelname$ = ref();
|
||||
const tableData$modelname$ = ref({
|
||||
// 列表数据(必传)
|
||||
data: [],
|
||||
// 表头内容(必传,注意格式)
|
||||
header: [
|
||||
$columns$
|
||||
],
|
||||
// 配置项(必传)
|
||||
config: {
|
||||
total: 0, // 列表总数
|
||||
loading: true, // loading 加载
|
||||
isSerialNo: true, // 是否显示表格序号
|
||||
isSelection: true, // 是否显示表格多选
|
||||
isOperate: true, // 是否显示表格操作栏
|
||||
}
|
||||
});
|
||||
// 初始化表格数据
|
||||
const getTableData$modelname$ = () => {
|
||||
tableRef$modelname$.value.doSearch($modelname$Api().search, searchData$modelname$.value)
|
||||
.catch((error: any) => {
|
||||
other.setFormError(ci, error);
|
||||
});
|
||||
};
|
||||
const OnCreateClick = () => {
|
||||
other.openDialog(ci.proxy.$t('message._system.common.vm.add'), CreateDialog, null, getTableData$modelname$)
|
||||
};
|
||||
|
||||
const OnEditrowClick = (row: any) => {
|
||||
other.openDialog(ci.proxy.$t('message._system.common.vm.edit'), EditDialog, row, getTableData$modelname$)
|
||||
};
|
||||
|
||||
const OnDetailsrowClick = (row: any) => {
|
||||
other.openDialog(ci.proxy.$t('message._system.common.vm.detail'), DetailsDialog, row, getTableData$modelname$)
|
||||
};
|
||||
|
||||
// 删除
|
||||
const onDelete = (row: any) => {
|
||||
$modelname$Api().delete([row.ID]).then(() => { getTableData$modelname$()})
|
||||
};
|
||||
|
||||
const onBatchDelete = () => {
|
||||
const selectedrows = tableRef$modelname$.value.getSelectedRows();
|
||||
const selectedids = selectedrows.map((x: any) => x.ID);
|
||||
if (selectedids.length > 0)
|
||||
$modelname$Api().delete(selectedids).then(() => { getTableData$modelname$()})
|
||||
else
|
||||
ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
|
||||
};
|
||||
|
||||
const OnImportClick = () => {
|
||||
other.openDialog(ci.proxy.$t('message._system.common.vm.import'), ImportDialog, null, getTableData$modelname$)
|
||||
};
|
||||
|
||||
const onExport = () => {
|
||||
const selected = tableRef$modelname$.value.getSelectedRows();
|
||||
if (selected.length > 0) {
|
||||
$modelname$Api().exportById(selected.map((x: any) => x.ID));
|
||||
}
|
||||
else {
|
||||
$modelname$Api().export({});
|
||||
}
|
||||
};
|
||||
|
||||
// 页面加载时
|
||||
onMounted(() => {
|
||||
$init$
|
||||
getTableData$modelname$();
|
||||
|
||||
});
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import request from '/@/utils/request';
|
||||
import other from '/@/utils/other';
|
||||
|
||||
function $modelname$Api() {
|
||||
return {
|
||||
search: (data: object) => {
|
||||
return request({
|
||||
url: '/api/$modelname$/Search',
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
},
|
||||
get: (data: number|string) => {
|
||||
return request({
|
||||
url: '/api/$modelname$/'+data,
|
||||
method: 'get'
|
||||
});
|
||||
},
|
||||
add:(data: object)=>{
|
||||
return request({
|
||||
url:'/api/$modelname$/Add',
|
||||
method:'post',
|
||||
data
|
||||
});
|
||||
},
|
||||
edit:(data: object)=>{
|
||||
return request({
|
||||
url:'/api/$modelname$/edit',
|
||||
method:'put',
|
||||
data
|
||||
});
|
||||
},
|
||||
batchedit:(data: object)=>{
|
||||
return request({
|
||||
url:'/api/$modelname$/batchedit',
|
||||
method:'post',
|
||||
data
|
||||
});
|
||||
},
|
||||
delete:(data: Array<number>|Array<string>)=>{
|
||||
return request({
|
||||
url:'/api/$modelname$/BatchDelete',
|
||||
method:'post',
|
||||
data
|
||||
});
|
||||
},
|
||||
export: (data: object) => {
|
||||
return request<any,Blob>({
|
||||
responseType: "blob",
|
||||
url: '/api/$modelname$/ExportExcel',
|
||||
method: 'post',
|
||||
data,
|
||||
}).then((data)=>{other.downloadFile(data)});;
|
||||
},
|
||||
exportById: (data: Array<number>|Array<string>) => {
|
||||
return request<any,Blob>({
|
||||
url: '/api/$modelname$/ExportExcelByIds',
|
||||
method: 'post',
|
||||
data,
|
||||
}).then((data)=>{other.downloadFile(data)});
|
||||
},
|
||||
import: (data: object) => {
|
||||
return request({
|
||||
url: '/api/$modelname$/Import',
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export {$modelname$Api}
|
||||
@@ -47,6 +47,7 @@ using Microsoft.AspNetCore.SpaServices.Extensions;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using WalkingTec.Mvvm.Core.Support.Quartz;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace WalkingTec.Mvvm.Mvc
|
||||
{
|
||||
@@ -602,7 +603,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtOptions.SecurityKey)),
|
||||
LifetimeValidator = (DateTime? notBefore, DateTime? expires, SecurityToken securityToken, TokenValidationParameters validationParameters) =>
|
||||
{
|
||||
if(expires == null)
|
||||
if (expires == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -610,7 +611,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
{
|
||||
return expires.Value > DateTime.UtcNow;
|
||||
}
|
||||
},
|
||||
},
|
||||
ValidateLifetime = true
|
||||
};
|
||||
})
|
||||
@@ -766,7 +767,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
gd.IsSpa = isspa == true || test != null;
|
||||
gd.AllModule = GetAllModules(controllers);
|
||||
var modules = Utils.ResetModule(gd.AllModule, false);
|
||||
gd.CustomUserType = gd.GetTypesAssignableFrom<FrameworkUserBase>().Where(x => x.Name.ToLower() == "frameworkuser").FirstOrDefault();
|
||||
gd.CustomUserType = gd.GetPocoTypesAssignableFrom<FrameworkUserBase>().Where(x => x.Name.ToLower() == "frameworkuser").FirstOrDefault();
|
||||
gd.SetMenuGetFunc(() =>
|
||||
{
|
||||
var menus = new List<SimpleMenu>();
|
||||
@@ -793,14 +794,30 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
var tenantsCacheKey = nameof(GlobalData.AllTenant);
|
||||
if (cache.TryGetValue(tenantsCacheKey, out tenants) == false)
|
||||
{
|
||||
tenants = new List<FrameworkTenant>();
|
||||
if (configs?.EnableTenant == true)
|
||||
{
|
||||
using (var dc = configs.Connections.Where(x => x.Key.ToLower() == "default").FirstOrDefault().CreateDC())
|
||||
{
|
||||
tenants = dc.Set<FrameworkTenant>().IgnoreQueryFilters().Where(x => x.Enabled).ToList();
|
||||
var cusTenantType = gd.GetPocoTypesAssignableFrom<FrameworkTenant>().FirstOrDefault();
|
||||
if (cusTenantType != null)
|
||||
{
|
||||
var set = dc.GetType().GetMethod("Set", Type.EmptyTypes).MakeGenericMethod(cusTenantType);
|
||||
var q = set.Invoke(dc, null) as IQueryable<FrameworkTenant>;
|
||||
tenants = q.IgnoreQueryFilters().Where(x => x.Enabled).ToList();
|
||||
}
|
||||
var _all = dc.Set<FrameworkTenant>().IgnoreQueryFilters().Where(x => x.Enabled).ToList();
|
||||
foreach (var item in _all)
|
||||
{
|
||||
if(tenants.Any(x=>x.ID == item.ID) == false)
|
||||
{
|
||||
tenants.Add(item);
|
||||
}
|
||||
}
|
||||
tenants = tenants.OrderBy(x => x.CreateTime).ToList();
|
||||
foreach (var item in tenants)
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.TDomain)==false)
|
||||
if (string.IsNullOrEmpty(item.TDomain) == false)
|
||||
{
|
||||
Regex r = new Regex("(http://|https://)?(.+)(/)?");
|
||||
var m = r.Match(item.TDomain);
|
||||
@@ -809,10 +826,28 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
item.TDomain = m.Groups[2].Value;
|
||||
}
|
||||
}
|
||||
item.Attributes = new Dictionary<string, object>();
|
||||
if (cusTenantType != null)
|
||||
{
|
||||
var cuspros = cusTenantType.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).Where(x => x.PropertyType.IsListOf<TopBasePoco>() == false && typeof(TopBasePoco).IsAssignableFrom(x.PropertyType) == false).ToList();
|
||||
foreach (var pro in cuspros)
|
||||
{
|
||||
if (item.Attributes.ContainsKey(pro.Name) == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
item.Attributes.Add(pro.Name, pro.GetValue(item));
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if(tenants == null)
|
||||
if (tenants == null)
|
||||
{
|
||||
tenants = new List<FrameworkTenant>();
|
||||
}
|
||||
|
||||
@@ -50,19 +50,39 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
|
||||
options.JsonSerializerOptions.NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString;
|
||||
options.JsonSerializerOptions.AllowTrailingCommas = true;
|
||||
options.JsonSerializerOptions.Converters.Add(new NullableConverter<int>());
|
||||
options.JsonSerializerOptions.Converters.Add(new NullableConverter<long>());
|
||||
options.JsonSerializerOptions.Converters.Add(new NullableConverter<decimal>());
|
||||
options.JsonSerializerOptions.Converters.Add(new NullableConverter<short>());
|
||||
options.JsonSerializerOptions.Converters.Add(new NullableConverter<float>());
|
||||
options.JsonSerializerOptions.Converters.Add(new NullableConverter<double>());
|
||||
options.JsonSerializerOptions.Converters.Add(new NullableConverter<bool>());
|
||||
options.JsonSerializerOptions.Converters.Add(new NullableConverter<DateTime>());
|
||||
options.JsonSerializerOptions.Converters.Add(new NullableConverter<Guid>());
|
||||
options.JsonSerializerOptions.Converters.Add(new NullableEnumConverter());
|
||||
options.JsonSerializerOptions.Converters.Add(new BoolStringConverter());
|
||||
options.JsonSerializerOptions.Converters.Add(new DateRangeConverter());
|
||||
options.JsonSerializerOptions.Converters.Add(new DateTimeConverter());
|
||||
options.JsonSerializerOptions.Converters.Add(new StringIgnoreLTGTConverter());
|
||||
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
|
||||
options.JsonSerializerOptions.Converters.Add(new BoolStringConverter());
|
||||
options.JsonSerializerOptions.Converters.Add(new DateRangeConverter());
|
||||
options.JsonSerializerOptions.Converters.Add(new PocoConverter());
|
||||
options.JsonSerializerOptions.Converters.Add(new TypeConverter());
|
||||
options.JsonSerializerOptions.Converters.Add(new DynamicDataConverter());
|
||||
Core.CoreProgram.DefaultJsonOption = options.JsonSerializerOptions;
|
||||
JsonSerializerOptions jsonOptions2 = new JsonSerializerOptions();
|
||||
jsonOptions2.PropertyNamingPolicy = null;
|
||||
jsonOptions2.NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString;
|
||||
options.JsonSerializerOptions.NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString;
|
||||
jsonOptions2.AllowTrailingCommas = true;
|
||||
jsonOptions2.Converters.Add(new NullableConverter<int>());
|
||||
jsonOptions2.Converters.Add(new NullableConverter<long>());
|
||||
jsonOptions2.Converters.Add(new NullableConverter<decimal>());
|
||||
jsonOptions2.Converters.Add(new NullableConverter<short>());
|
||||
jsonOptions2.Converters.Add(new NullableConverter<float>());
|
||||
jsonOptions2.Converters.Add(new NullableConverter<double>());
|
||||
jsonOptions2.Converters.Add(new NullableConverter<bool>());
|
||||
jsonOptions2.Converters.Add(new NullableConverter<DateTime>());
|
||||
jsonOptions2.Converters.Add(new NullableConverter<Guid>());
|
||||
jsonOptions2.Converters.Add(new NullableEnumConverter());
|
||||
jsonOptions2.Converters.Add(new DateTimeConverter());
|
||||
jsonOptions2.Converters.Add(new JsonStringEnumConverter());
|
||||
jsonOptions2.Converters.Add(new BoolStringConverter());
|
||||
|
||||
@@ -145,6 +145,32 @@ Layout = null;
|
||||
</wt:fieldset>
|
||||
|
||||
}
|
||||
else if (Model.UI == WalkingTec.Mvvm.Core.UIEnum.VUE3)
|
||||
{
|
||||
var viewdir = Model.MainDir + $"\\ClientApp\\src\\views\\{(string.IsNullOrEmpty(Model.Area)?"":$"{Model.Area}\\")}" + Model.ModelName.ToLower();
|
||||
var apidir = Model.MainDir + $"\\ClientApp\\src\\api\\{(string.IsNullOrEmpty(Model.Area) ? "" : $"{Model.Area}\\")}" + Model.ModelName.ToLower();
|
||||
<wt:fieldset title="VUE Views">
|
||||
<wt:linkbutton text="@preview" window-width="600" post-current-form="true" size=" ButtonSizeEnum.Mini"
|
||||
target=" ButtonTargetEnum.Layer" url="/_CodeGen/Preview?PreviewFile=Index&ui=vue3" />
|
||||
@viewdir\index.vue<br />
|
||||
<wt:linkbutton text="@preview" window-width="600" post-current-form="true" size=" ButtonSizeEnum.Mini"
|
||||
target=" ButtonTargetEnum.Layer" url="/_CodeGen/Preview?PreviewFile=Create&ui=vue3" />
|
||||
@viewdir\create.vue<br />
|
||||
<wt:linkbutton text="@preview" window-width="600" post-current-form="true" size=" ButtonSizeEnum.Mini"
|
||||
target=" ButtonTargetEnum.Layer" url="/_CodeGen/Preview?PreviewFile=Edit&ui=vue3" />
|
||||
@viewdir\edit.vue<br />
|
||||
<wt:linkbutton text="@preview" window-width="600" post-current-form="true" size=" ButtonSizeEnum.Mini"
|
||||
target=" ButtonTargetEnum.Layer" url="/_CodeGen/Preview?PreviewFile=Details&ui=vue3" />
|
||||
@viewdir\details.vue<br />
|
||||
<wt:linkbutton text="@preview" window-width="600" post-current-form="true" size=" ButtonSizeEnum.Mini"
|
||||
target=" ButtonTargetEnum.Layer" url="/_CodeGen/Preview?PreviewFile=Import&ui=vue3" />
|
||||
@viewdir\import.vue <br />
|
||||
<wt:linkbutton text="@preview" window-width="600" post-current-form="true" size=" ButtonSizeEnum.Mini"
|
||||
target=" ButtonTargetEnum.Layer" url="/_CodeGen/Preview?PreviewFile=indexapi&ui=vue3" />
|
||||
@apidir\index.vue <br />
|
||||
</wt:fieldset>
|
||||
|
||||
}
|
||||
else if (Model.UI == WalkingTec.Mvvm.Core.UIEnum.Blazor)
|
||||
{
|
||||
var viewdir = Model.ShareDir;
|
||||
|
||||
@@ -21,6 +21,17 @@
|
||||
<None Remove="GeneratorFiles\Spa\Blazor\Edit.txt" />
|
||||
<None Remove="GeneratorFiles\Spa\Blazor\Import.txt" />
|
||||
<None Remove="GeneratorFiles\Spa\Blazor\Index.txt" />
|
||||
<None Remove="GeneratorFiles\Spa\Vue3\Create.txt" />
|
||||
<None Remove="GeneratorFiles\Spa\Vue3\Details.txt" />
|
||||
<None Remove="GeneratorFiles\Spa\Vue3\Edit.txt" />
|
||||
<None Remove="GeneratorFiles\Spa\Vue3\Import.txt" />
|
||||
<None Remove="GeneratorFiles\Spa\Vue3\Index.txt" />
|
||||
<None Remove="GeneratorFiles\Spa\Vue3\indexapi.txt" />
|
||||
<None Remove="GeneratorFiles\Spa\Vue\Create.txt" />
|
||||
<None Remove="GeneratorFiles\Spa\Vue\Details.txt" />
|
||||
<None Remove="GeneratorFiles\Spa\Vue\Edit.txt" />
|
||||
<None Remove="GeneratorFiles\Spa\Vue\Import.txt" />
|
||||
<None Remove="GeneratorFiles\Spa\Vue\index.txt" />
|
||||
<EmbeddedResource Include="framework_layui.js" />
|
||||
<EmbeddedResource Include="GeneratorFiles\ApiTest.txt" />
|
||||
<EmbeddedResource Include="GeneratorFiles\ApiTestTopPoco.txt" />
|
||||
@@ -57,6 +68,12 @@
|
||||
<EmbeddedResource Include="GeneratorFiles\Mvc\CreateView.txt" />
|
||||
<EmbeddedResource Include="GeneratorFiles\Mvc\DeleteView.txt" />
|
||||
<EmbeddedResource Include="GeneratorFiles\Mvc\DetailsView.txt" />
|
||||
<EmbeddedResource Include="GeneratorFiles\Spa\Vue3\Create.txt" />
|
||||
<EmbeddedResource Include="GeneratorFiles\Spa\Vue3\Details.txt" />
|
||||
<EmbeddedResource Include="GeneratorFiles\Spa\Vue3\Edit.txt" />
|
||||
<EmbeddedResource Include="GeneratorFiles\Spa\Vue3\Import.txt" />
|
||||
<EmbeddedResource Include="GeneratorFiles\Spa\Vue3\Index.txt" />
|
||||
<EmbeddedResource Include="GeneratorFiles\Spa\Vue3\indexapi.txt" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -65,7 +82,9 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="6.0.0" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.0" />
|
||||
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta14" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.4.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.4.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.4.0" />
|
||||
<PackageReference Include="VueCliMiddleware" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -101,7 +101,12 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
List<string> apineeded = new List<string>();
|
||||
ViewData["code"] = vm.GenerateVUEView(vm.PreviewFile,apineeded);
|
||||
}
|
||||
else if(vm.UI == UIEnum.Blazor)
|
||||
else if (vm.UI == UIEnum.VUE3)
|
||||
{
|
||||
List<string> apineeded = new List<string>();
|
||||
ViewData["code"] = vm.GenerateVue3View(vm.PreviewFile);
|
||||
}
|
||||
else if (vm.UI == UIEnum.Blazor)
|
||||
{
|
||||
ViewData["code"] = vm.GenerateBlazorView(vm.PreviewFile);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
, string _DONOT_USE_CURRENTCS
|
||||
)
|
||||
{
|
||||
string cs = string.IsNullOrEmpty(_DONOT_USE_CURRENTCS) ? "default" : _DONOT_USE_CURRENTCS;
|
||||
string cs =_DONOT_USE_CURRENTCS;
|
||||
Wtm.CurrentCS = cs;
|
||||
var listVM = Wtm.CreateVM(_DONOT_USE_VMNAME, null, null, true) as IBasePagedListVM<TopBasePoco, ISearcher>;
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
//var vmType = Type.GetType(_DONOT_USE_VMNAME);
|
||||
//var vmCreater = vmType.GetConstructor(Type.EmptyTypes);
|
||||
//var listVM = vmCreater.Invoke(null) as BaseVM;
|
||||
Wtm.CurrentCS = (string.IsNullOrEmpty(_DONOT_USE_CS) == true) ? "default" : _DONOT_USE_CS;
|
||||
Wtm.CurrentCS = _DONOT_USE_CS;
|
||||
var listVM = Wtm.CreateVM(_DONOT_USE_VMNAME, null, null, true) as IBasePagedListVM<TopBasePoco, BaseSearcher>;
|
||||
listVM.FC = qs;
|
||||
if (listVM is IBasePagedListVM<TopBasePoco, ISearcher>)
|
||||
@@ -210,7 +210,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[ActionDescription("Export")]
|
||||
public IActionResult GetExportExcel(string _DONOT_USE_VMNAME, string _DONOT_USE_CS = "default")
|
||||
public IActionResult GetExportExcel(string _DONOT_USE_VMNAME, string _DONOT_USE_CS)
|
||||
{
|
||||
var qs = new Dictionary<string, object>();
|
||||
foreach (var item in Request.Query.Keys)
|
||||
@@ -226,7 +226,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
}
|
||||
var instanceType = Type.GetType(_DONOT_USE_VMNAME);
|
||||
|
||||
Wtm.CurrentCS = (string.IsNullOrEmpty(_DONOT_USE_CS) == true) ? "default" : _DONOT_USE_CS;
|
||||
Wtm.CurrentCS = _DONOT_USE_CS;
|
||||
var listVM = Wtm.CreateVM(_DONOT_USE_VMNAME) as IBasePagedListVM<TopBasePoco, ISearcher>;
|
||||
|
||||
listVM.FC = qs;
|
||||
@@ -253,9 +253,9 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[ActionDescription("DownloadTemplate")]
|
||||
public IActionResult GetExcelTemplate(string _DONOT_USE_VMNAME, string _DONOT_USE_CS = "default")
|
||||
public IActionResult GetExcelTemplate(string _DONOT_USE_VMNAME, string _DONOT_USE_CS)
|
||||
{
|
||||
Wtm.CurrentCS = _DONOT_USE_CS ?? "default";
|
||||
//Wtm.CurrentCS = _DONOT_USE_CS ?? "default";
|
||||
var importVM = Wtm.CreateVM(_DONOT_USE_VMNAME) as IBaseImport<BaseTemplateVM>;
|
||||
var qs = new Dictionary<string, string>();
|
||||
foreach (var item in Request.Query.Keys)
|
||||
@@ -325,7 +325,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("UploadFileRoute")]
|
||||
public IActionResult Upload([FromServices] WtmFileProvider fp, string sm = null, string groupName = null, string subdir = null, string extra = null, bool IsTemprory = true, string _DONOT_USE_CS = "default")
|
||||
public IActionResult Upload([FromServices] WtmFileProvider fp, string sm = null, string groupName = null, string subdir = null, string extra = null, bool IsTemprory = true, string _DONOT_USE_CS=null)
|
||||
{
|
||||
var FileData = Request.Form.Files[0];
|
||||
var file = fp.Upload(FileData.FileName, FileData.Length, FileData.OpenReadStream(), groupName, subdir, extra, sm, Wtm.CreateDC(cskey: _DONOT_USE_CS));
|
||||
@@ -334,7 +334,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("UploadFileRoute")]
|
||||
public IActionResult UploadImage([FromServices] WtmFileProvider fp, string sm = null, string groupName = null, string subdir = null, string extra = null, bool IsTemprory = true, string _DONOT_USE_CS = "default", int? width = null, int? height = null)
|
||||
public IActionResult UploadImage([FromServices] WtmFileProvider fp, string sm = null, string groupName = null, string subdir = null, string extra = null, bool IsTemprory = true, string _DONOT_USE_CS = null, int? width = null, int? height = null)
|
||||
{
|
||||
if (width == null && height == null)
|
||||
{
|
||||
@@ -368,7 +368,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
|
||||
[HttpPost]
|
||||
[ActionDescription("UploadForLayUIRichTextBox")]
|
||||
public IActionResult UploadForLayUIRichTextBox([FromServices] WtmFileProvider fp, string _DONOT_USE_CS = "default", string groupName = null, string subdir = null)
|
||||
public IActionResult UploadForLayUIRichTextBox([FromServices] WtmFileProvider fp, string _DONOT_USE_CS = null, string groupName = null, string subdir = null)
|
||||
{
|
||||
var FileData = Request.Form.Files[0];
|
||||
var file = fp.Upload(FileData.FileName, FileData.Length, FileData.OpenReadStream(), groupName, subdir, dc: Wtm.CreateDC(cskey: _DONOT_USE_CS));
|
||||
@@ -387,13 +387,13 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
}
|
||||
|
||||
[ActionDescription("GetFileName")]
|
||||
public IActionResult GetFileName([FromServices] WtmFileProvider fp, Guid id, string _DONOT_USE_CS = "default")
|
||||
public IActionResult GetFileName([FromServices] WtmFileProvider fp, Guid id, string _DONOT_USE_CS)
|
||||
{
|
||||
return Ok(fp.GetFileName(id.ToString(), Wtm.CreateDC(cskey: _DONOT_USE_CS)));
|
||||
}
|
||||
|
||||
[ActionDescription("GetFile")]
|
||||
public async Task<IActionResult> GetFile([FromServices] WtmFileProvider fp, string id, bool stream = false, string _DONOT_USE_CS = "default", int? width = null, int? height = null)
|
||||
public async Task<IActionResult> GetFile([FromServices] WtmFileProvider fp, string id, bool stream = false, string _DONOT_USE_CS = null, int? width = null, int? height = null)
|
||||
{
|
||||
var file = fp.GetFile(id, true, Wtm.CreateDC(cskey: _DONOT_USE_CS));
|
||||
if (file == null)
|
||||
@@ -463,7 +463,7 @@ namespace WalkingTec.Mvvm.Mvc
|
||||
}
|
||||
|
||||
[ActionDescription("ViewFile")]
|
||||
public IActionResult ViewFile([FromServices] WtmFileProvider fp, string id, string width, string _DONOT_USE_CS = "default")
|
||||
public IActionResult ViewFile([FromServices] WtmFileProvider fp, string id, string width, string _DONOT_USE_CS = null)
|
||||
{
|
||||
var file = fp.GetFile(id, false, Wtm.CreateDC(cskey: _DONOT_USE_CS));
|
||||
string html = string.Empty;
|
||||
|
||||
@@ -162,37 +162,45 @@ window.ff = {
|
||||
if (para !== undefined) {
|
||||
getpost = "Post";
|
||||
}
|
||||
$.ajax({
|
||||
type: getpost,
|
||||
url: url,
|
||||
data: para,
|
||||
success: function (data, textStatus, request) {
|
||||
if (request.getResponseHeader('IsScript') === 'true') {
|
||||
eval(data);
|
||||
}
|
||||
else {
|
||||
data = '<div class="layui-card donotuse_pdiv"><div class="layui-card-body donotuse_pdiv" id=\"' + $.cookie("divid") + '\" >' + data + "</div></div>";
|
||||
var child = window.open("/Home/PIndex#/_framework/redirect");
|
||||
child.document.close();
|
||||
$(child.document).ready(function () {
|
||||
setTimeout(function () {
|
||||
$('#LAY_app_body', child.document).html(data);
|
||||
$(child.document).attr("title", title);
|
||||
}, 500);
|
||||
});
|
||||
}
|
||||
layer.close(index);
|
||||
},
|
||||
error: function (a, b, c) {
|
||||
layer.close(index);
|
||||
if (a.responseText !== undefined && a.responseText !== "") {
|
||||
layer.alert(a.responseText);
|
||||
}
|
||||
else {
|
||||
layer.alert(ff.DONOTUSE_Text_LoadFailed);
|
||||
}
|
||||
}
|
||||
var child = window.open("/Home/PIndex/#" + url);
|
||||
$(child.document).ready(function() {
|
||||
setTimeout(function() {
|
||||
$(child.document).attr("title", title);
|
||||
}, 500);
|
||||
});
|
||||
layer.close(index);
|
||||
// $.ajax({
|
||||
// type: getpost,
|
||||
// url: url,
|
||||
// data: para,
|
||||
// success: function (data, textStatus, request) {
|
||||
// if (request.getResponseHeader('IsScript') === 'true') {
|
||||
// eval(data);
|
||||
// }
|
||||
// else {
|
||||
// data = '<div class="layui-card donotuse_pdiv"><div class="layui-card-body donotuse_pdiv" id=\"' + $.cookie("divid") + '\" >' + data + "</div></div>";
|
||||
// var child = window.open("/Home/PIndex/#/_framework/redirect");
|
||||
// child.document.close();
|
||||
// $(child.document).ready(function () {
|
||||
// setTimeout(function() {
|
||||
// debugger;
|
||||
// $('#LAY_app_body', child.document).html(data);
|
||||
// $(child.document).attr("title", title);
|
||||
// }, 500);
|
||||
// });
|
||||
// }
|
||||
// layer.close(index);
|
||||
// },
|
||||
// error: function (a, b, c) {
|
||||
// layer.close(index);
|
||||
// if (a.responseText !== undefined && a.responseText !== "") {
|
||||
// layer.alert(a.responseText);
|
||||
// }
|
||||
// else {
|
||||
// layer.alert(ff.DONOTUSE_Text_LoadFailed);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
else {
|
||||
layer.close(index);
|
||||
@@ -264,7 +272,7 @@ window.ff = {
|
||||
url = $("#" + formId).attr("action");
|
||||
}
|
||||
var d = null;
|
||||
if (searchervm !== undefined && searchervm !== null && searchervm !== "") {
|
||||
if ($("#" + formId).find("a[IsSearchButton]").length>0) {
|
||||
d = ff.GetSearchFormData(formId, searchervm);
|
||||
}
|
||||
else {
|
||||
@@ -553,7 +561,7 @@ window.ff = {
|
||||
this.SetCookie("windowids", wids.join());
|
||||
}
|
||||
else {
|
||||
if (layui.setter == undefined || layui.setter.pageTabs == undefined) {
|
||||
if (layui.setter == undefined || layui.setter.pageTabs == undefined || window.location.href.toLocaleLowerCase().indexOf("/home/pindex/")>-1) {
|
||||
window.close();
|
||||
}
|
||||
else if (layui.setter.pageTabs === false || $('.layadmin-tabsbody-item').length === 0) {
|
||||
@@ -599,7 +607,7 @@ window.ff = {
|
||||
}
|
||||
},
|
||||
|
||||
ChainChange: function (url, self) {
|
||||
ChainChange: function (url, self, usedefaultvalue) {
|
||||
var form = layui.form;
|
||||
var linkto = self.attributes["wtm-linkto"];
|
||||
if (linkto == undefined) {
|
||||
@@ -653,7 +661,11 @@ window.ff = {
|
||||
var item = null;
|
||||
|
||||
if (controltype === "tree") {
|
||||
window[comboid].update({ data: ff.getTreeItems(data.Data) });
|
||||
var df = [];
|
||||
if (usedefaultvalue == true) {
|
||||
df = eval(comboid + "defaultvalues");
|
||||
}
|
||||
window[comboid].update({ data: ff.getTreeItems(data.Data,df) });
|
||||
}
|
||||
if (controltype === "transfer") {
|
||||
layui.transfer.reload(targetid, {
|
||||
@@ -662,16 +674,32 @@ window.ff = {
|
||||
}
|
||||
|
||||
if (controltype === "combo") {
|
||||
window[comboid].update({ data: ff.getComboItems(data.Data) });
|
||||
var df = [];
|
||||
if (usedefaultvalue == true) {
|
||||
df = eval(comboid + "defaultvalues");
|
||||
}
|
||||
window[comboid].update({ data: ff.getComboItems(data.Data, df, usedefaultvalue) });
|
||||
}
|
||||
if (controltype === "checkbox") {
|
||||
for (i = 0; i < data.Data.length; i++) {
|
||||
item = data.Data[i];
|
||||
if (item.Selected === true) {
|
||||
target.append("<input type='checkbox' name = '" + targetname + "' value = '" + item.Value + "' title = '" + item.Text + "' checked />");
|
||||
}
|
||||
if (usedefaultvalue == true) {
|
||||
var df = [];
|
||||
df = eval(comboid + "defaultvalues");
|
||||
if (df.indexOf(item.Value) > -1) {
|
||||
target.append("<input type='checkbox' name = '" + targetname + "' value = '" + item.Value + "' title = '" + item.Text + "' checked />");
|
||||
}
|
||||
else {
|
||||
target.append("<input type='checkbox' name = '" + targetname + "' value = '" + item.Value + "' title = '" + item.Text + "' />");
|
||||
}
|
||||
}
|
||||
else {
|
||||
target.append("<input type='checkbox' name = '" + targetname + "' value = '" + item.Value + "' title = '" + item.Text + "' />");
|
||||
if (item.Selected === true) {
|
||||
target.append("<input type='checkbox' name = '" + targetname + "' value = '" + item.Value + "' title = '" + item.Text + "' checked />");
|
||||
}
|
||||
else {
|
||||
target.append("<input type='checkbox' name = '" + targetname + "' value = '" + item.Value + "' title = '" + item.Text + "' />");
|
||||
}
|
||||
}
|
||||
}
|
||||
form.render('checkbox', targetfilter);
|
||||
@@ -679,11 +707,23 @@ window.ff = {
|
||||
if (controltype === "radio") {
|
||||
for (i = 0; i < data.Data.length; i++) {
|
||||
item = data.Data[i];
|
||||
if (item.Selected === true) {
|
||||
target.append("<input type='radio' name = '" + targetname + "' value = '" + item.Value + "' title = '" + item.Text + "' checked />");
|
||||
}
|
||||
if (usedefaultvalue == true) {
|
||||
var df = [];
|
||||
df = eval(comboid + "defaultvalues");
|
||||
if (df.indexOf(item.Value) > -1) {
|
||||
target.append("<input type='radio' name = '" + targetname + "' value = '" + item.Value + "' title = '" + item.Text + "' checked />");
|
||||
}
|
||||
else {
|
||||
target.append("<input type='radio' name = '" + targetname + "' value = '" + item.Value + "' title = '" + item.Text + "' />");
|
||||
}
|
||||
}
|
||||
else {
|
||||
target.append("<input type='radio' name = '" + targetname + "' value = '" + item.Value + "' title = '" + item.Text + "' />");
|
||||
if (item.Selected === true) {
|
||||
target.append("<input type='radio' name = '" + targetname + "' value = '" + item.Value + "' title = '" + item.Text + "' checked />");
|
||||
}
|
||||
else {
|
||||
target.append("<input type='radio' name = '" + targetname + "' value = '" + item.Value + "' title = '" + item.Text + "' />");
|
||||
}
|
||||
}
|
||||
}
|
||||
form.render('radio', targetfilter);
|
||||
@@ -727,6 +767,7 @@ window.ff = {
|
||||
window[controlid].update({ data: da });
|
||||
}
|
||||
if (controltype === "checkbox") {
|
||||
target[0].innerHTML = "";
|
||||
for (i = 0; i < data.Data.length; i++) {
|
||||
item = data.Data[i];
|
||||
if (item.Selected === true || svals.indexOf(item.Value) > -1) {
|
||||
@@ -787,10 +828,13 @@ window.ff = {
|
||||
var tableid = tables[i].id;
|
||||
var loaddata = layui.table.cache[tableid];
|
||||
if (loaddata == undefined || loaddata.length == 0) {
|
||||
var subpro = tables[i].attributes["subpro"].value;
|
||||
if (subpro != undefined && subpro != "") {
|
||||
filter[subpro + ".length"] = "0";
|
||||
try {
|
||||
var subpro = tables[i].attributes["subpro"].value;
|
||||
if (subpro != undefined && subpro != "") {
|
||||
filter[subpro + ".length"] = "0";
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -823,7 +867,7 @@ window.ff = {
|
||||
return;
|
||||
}
|
||||
var itemname = item.name;
|
||||
if (/_DONOTUSE_(.*?)\[(\d?)\]\.(.*?)$/.test(itemname)) {
|
||||
if (/_DONOTUSE_(.*?)\[(.*?)\]\.(.*?)$/.test(itemname)) {
|
||||
var name1 = RegExp.$1;
|
||||
var number = RegExp.$2;
|
||||
var name2 = RegExp.$3;
|
||||
@@ -840,7 +884,7 @@ window.ff = {
|
||||
return;
|
||||
}
|
||||
var issub = false;
|
||||
if (/(.*?)\[(\-?\d?)\]\.(.*?)$/.test(itemname)) {
|
||||
if (/(.*?)\[(.*?)\]\.(.*?)$/.test(itemname)) {
|
||||
var name1 = RegExp.$1;
|
||||
var number = RegExp.$2;
|
||||
var name2 = RegExp.$3;
|
||||
@@ -889,13 +933,27 @@ window.ff = {
|
||||
},
|
||||
|
||||
GetSearchFormData: function (formId, listvm) {
|
||||
var data = ff.GetFormData(formId);
|
||||
var data = ff.GetFormData(formId, listvm);
|
||||
for (var attr in data) {
|
||||
if (attr.startsWith(listvm + ".")) {
|
||||
data[attr.replace(listvm + ".", "")] = data[attr];
|
||||
delete data[attr];
|
||||
}
|
||||
}
|
||||
var tc = $("#" + formId).closest("div[wtm-ctype='tc']")
|
||||
if (tc.length > 0) {
|
||||
var obj = eval(tc[0].id + "selected");
|
||||
if (obj !== undefined && obj !== null) {
|
||||
for (var item in obj) {
|
||||
if (listvm == "") {
|
||||
data["Searcher."+item] = obj[item];
|
||||
}
|
||||
else {
|
||||
data[item] = obj[item];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return data;
|
||||
},
|
||||
|
||||
@@ -906,8 +964,13 @@ window.ff = {
|
||||
}
|
||||
var tempwhere = {};
|
||||
$.extend(tempwhere, defaultcondition);
|
||||
|
||||
$.extend(tempwhere, formData);
|
||||
for (let item in tempwhere) {
|
||||
if (item.startsWith("Searcher.") == false) {
|
||||
tempwhere["Searcher." + item] = tempwhere[item];
|
||||
}
|
||||
}
|
||||
|
||||
var form = $('<form method="POST" action="' + url + '">');
|
||||
for (var attr in tempwhere) {
|
||||
if (tempwhere[attr] != null) {
|
||||
@@ -948,7 +1011,7 @@ window.ff = {
|
||||
|
||||
var searcher = $('form[chartlink*="' + chartid + '"]');
|
||||
if (searcher !== undefined && searcher.length > 0) {
|
||||
postdata = ff.GetFormData(searcher[0].id);
|
||||
postdata = ff.GetSearchFormData(searcher[0].id,"Searcher");
|
||||
}
|
||||
$.ajax({
|
||||
cache: false,
|
||||
@@ -1012,8 +1075,8 @@ window.ff = {
|
||||
var re3 = /(.*?)<input hidden name='(.*?)\.id' .*?\/>(.*?)/ig;
|
||||
for (val in data) {
|
||||
if (typeof (data[val]) == 'string') {
|
||||
data[val] = data[val].replace(/\[\d?\]/ig, "[" + loaddata.length + "]");
|
||||
data[val] = data[val].replace(/_\d?_/ig, "_" + loaddata.length + "_");
|
||||
data[val] = data[val].replace(/\[\d+\]/ig, "[" + loaddata.length + "]");
|
||||
data[val] = data[val].replace(/_\d+_/ig, "_" + loaddata.length + "_");
|
||||
data[val] = data[val].replace(re, "$1 onchange=\"ff.gridcellchange(this,'" + gridid + "'," + loaddata.length + ",'" + val + "',0)\" />$2");
|
||||
data[val] = data[val].replace(re2, "$1 onchange=\"ff.gridcellchange(this,'" + gridid + "'," + loaddata.length + ",'" + val + "',1)\" >$2");
|
||||
data[val] = data[val].replace(re3, "$1 <input hidden name=\"$2.id\" value='" + data["ID"] + "'/> $3");
|
||||
@@ -1026,14 +1089,16 @@ window.ff = {
|
||||
layui.table.render(option);
|
||||
},
|
||||
|
||||
SetGridCellDate: function (id) {
|
||||
SetGridCellDate: function (id,dt) {
|
||||
layui.use('laydate', function () {
|
||||
var laydate = layui.laydate;
|
||||
laydate.render({
|
||||
elem: '#' + id
|
||||
, type: dt
|
||||
, show: true
|
||||
, closeStop: '#' + id
|
||||
, done: function (value, date, endDate) {
|
||||
document.getElementById(id).value = value;
|
||||
document.getElementById(id).onchange();
|
||||
}
|
||||
});
|
||||
@@ -1067,9 +1132,14 @@ window.ff = {
|
||||
for (var i = 0; i < loaddata.length; i++) {
|
||||
for (val in loaddata[i]) {
|
||||
if (typeof (loaddata[i][val]) == 'string') {
|
||||
loaddata[i][val] = loaddata[i][val].replace(/\[\d?\]/ig, "[" + i + "]");
|
||||
loaddata[i][val] = loaddata[i][val].replace(/_\d?_/ig, "_" + i + "_");
|
||||
loaddata[i][val] = loaddata[i][val].replace("/onchange=\".*?\"/", "onchange=\"ff.gridcellchange(this,'" + gridid + "'," + i + ",'" + val + "')\"");
|
||||
loaddata[i][val] = loaddata[i][val].replace(/\[\d+\]/ig, "[" + i + "]");
|
||||
loaddata[i][val] = loaddata[i][val].replace(/_\d+_/ig, "_" + i + "_");
|
||||
if (/<input .*?\s*\/>.*?/.test(loaddata[i][val])) {
|
||||
loaddata[i][val] = loaddata[i][val].replace(/onchange=\".*?\"/ig, "onchange=\"ff.gridcellchange(this,'" + gridid + "'," + i + ",'" + val + "',0)\"");
|
||||
}
|
||||
if (/<select .*?\s*>.*?<\/select>/.test(loaddata[i][val])) {
|
||||
loaddata[i][val] = loaddata[i][val].replace(/onchange=\".*?\"/ig, "onchange=\"ff.gridcellchange(this,'" + gridid + "'," + i + ",'" + val + "',1)\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1178,22 +1248,24 @@ window.ff = {
|
||||
return rv;
|
||||
},
|
||||
|
||||
getComboItems: function (data, svals) {
|
||||
getComboItems: function (data, svals, useDefaultvalue) {
|
||||
var rv = [];
|
||||
if (svals == undefined || svals == null) {
|
||||
svals = [];
|
||||
}
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var item = {};
|
||||
item.value = data[i].Value;
|
||||
item.name = data[i].Text;
|
||||
item.disabled = data[i].Disabled;
|
||||
item.selected = data[i].Selected || svals.indexOf(data[i].Value) > -1;
|
||||
item.icon = data[i].Icon;
|
||||
if (data[i].Children != null && data[i].Children.length > 0) {
|
||||
item.children = this.getTreeItems(data[i].Children, svals);
|
||||
if (data != null) {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var item = {};
|
||||
item.value = data[i].Value;
|
||||
item.name = data[i].Text;
|
||||
item.disabled = data[i].Disabled;
|
||||
item.selected = useDefaultvalue == true ? svals.indexOf(data[i].Value) > -1 : data[i].Selected;
|
||||
item.icon = data[i].Icon;
|
||||
if (data[i].Children != null && data[i].Children.length > 0) {
|
||||
item.children = this.getTreeItems(data[i].Children, svals);
|
||||
}
|
||||
rv.push(item);
|
||||
}
|
||||
rv.push(item);
|
||||
}
|
||||
return rv;
|
||||
},
|
||||
@@ -1247,12 +1319,13 @@ window.ff = {
|
||||
|
||||
var hidAreas = [' input[wtm-tag=wtmselector]'];
|
||||
// 多选下拉框
|
||||
var multiCombos = $('#' + formId + ' select[wtm-combo=MULTI_COMBO]');
|
||||
var multiCombos = $('#' + formId + ' div[wtm-ctype=combo]').add($('#' + formId + ' div[wtm-ctype=tree]'));
|
||||
if (multiCombos && multiCombos.length > 0) {
|
||||
for (i = 0; i < multiCombos.length; i++) {
|
||||
var name = multiCombos.attr('lay-filter');
|
||||
hidAreas.push(" input[name='" + name + "']");
|
||||
multiCombos.each(function () {
|
||||
let name = $(this).attr('id');
|
||||
window[name].setValue([]);
|
||||
}
|
||||
);
|
||||
}
|
||||
for (var i = 0; i < hidAreas.length; i++) {
|
||||
var hiddenAreas = $('#' + formId + hidAreas[i]);
|
||||
|
||||
Reference in new issue
Block a user