Commit de76161c authored by liudong1993's avatar liudong1993

Merge branch 'master' of http://gitlab.oytour.com/Kui2/mall.oytour.com into sdzq-ld

parents f655cc0e 8c4220a9
......@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Common.Plugin;
namespace Mall.Model.Extend.TradePavilion
{
......@@ -10,6 +11,8 @@ namespace Mall.Model.Extend.TradePavilion
/// </summary>
public class RB_Custom_Form_Extend : RB_Custom_Form
{
public string FormTypeStr { get { return this.FormType.GetEnumName(); } }
/// <summary>
/// 表单内容
/// </summary>
......@@ -26,6 +29,11 @@ namespace Mall.Model.Extend.TradePavilion
/// </summary>
public string CompKey { get; set; }
/// <summary>
/// 是否选中
/// </summary>
public bool isCked { get; set; }
/// <summary>
/// 组件对象
/// </summary>
......
......@@ -10,5 +10,9 @@ namespace Mall.Model.Extend.User
/// </summary>
public class RB_Tenant_Plug_Extend: RB_Tenant_Plug
{
/// <summary>
/// 插件类型
/// </summary>
public string QPlugTypeStr { get; set; }
}
}
......@@ -6,6 +6,8 @@ using System.Text;
using VT.FW.AOP.CustomerAttribute;
using Mall.Common.Enum;
using VT.FW.DB;
using Newtonsoft.Json.Linq;
using Mall.Common.Plugin;
namespace Mall.Module.TradePavilion
{
......@@ -42,6 +44,27 @@ namespace Mall.Module.TradePavilion
return custom_FormRepository.GetCustomFormListRepository(query);
}
/// <summary>
/// 检查表单是否存在
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool CheckExistsCustomFormModule(RB_Custom_Form_Extend model)
{
IList<WhereHelper> list = new List<WhereHelper>
{
new WhereHelper(nameof(RB_Custom_Form_Extend.FormType), model.FormType),
new WhereHelper(nameof(RB_Custom_Form_Extend.Status), (int)DateStateEnum.Normal),
new WhereHelper(nameof(RB_Custom_Form_Extend.TenantId), model.TenantId)
};
if (model.Id > 0)
{
list.Add(new WhereHelper(nameof(RB_Custom_Form_Extend.Id), model.Id, OperatorEnum.NotEqual));
}
return custom_FormRepository.Exists(list);
}
/// <summary>
/// 新增修改自定义表单
/// </summary>
......@@ -61,7 +84,7 @@ namespace Mall.Module.TradePavilion
{ nameof(RB_Custom_Form_Extend.UpdateBy),model.UpdateBy},
{ nameof(RB_Custom_Form_Extend.UpdateDate),model.UpdateDate},
};
custom_FormRepository.Update(fileds, new WhereHelper(nameof(RB_Custom_Form_Extend.Id), model.Id));
flag= custom_FormRepository.Update(fileds, new WhereHelper(nameof(RB_Custom_Form_Extend.Id), model.Id));
}
else
{
......@@ -80,10 +103,106 @@ namespace Mall.Module.TradePavilion
public RB_Custom_Form_Extend GetCustomFormModule(object Id)
{
var extModel = custom_FormRepository.GetEntity<RB_Custom_Form_Extend>(Id);
if (extModel != null)
{
extModel.FormDataList = AnalyzeFormComponent(extModel.FormData);
}
return extModel;
}
/// <summary>
/// 解析表单组件
/// </summary>
/// <param name="formData"></param>
/// <returns></returns>
public List<FormDataItem> AnalyzeFormComponent(string formData)
{
List<FormDataItem> dataList = new List<FormDataItem>();
if (!string.IsNullOrEmpty(formData))
{
JArray jArray = JArray.Parse(formData);
if (jArray != null && jArray.Count > 0)
{
foreach (var jItem in jArray)
{
JObject jObj = JObject.Parse(jItem.ToString());
FormDataItem dataItem = new FormDataItem()
{
CompKey = jObj.GetStringValue("CompKey"),
CompData = new object(),
isCked=false,
};
if (!string.IsNullOrEmpty(dataItem.CompKey))
{
switch (dataItem.CompKey)
{
//单行文本
case "SingleLineText":
JObject singleObj = JObject.Parse(jObj.GetStringValue("CompData"));
TextItem txtItem = new TextItem()
{
Name = singleObj.GetStringValue("Name"),
WordsLength = singleObj.GetInt("WordsLength"),
IsRequire = singleObj.GetBoolValue("IsRequire"),
};
dataItem.CompData = txtItem;
break;
//多行文本
case "MultiLineText":
JObject multiObj = JObject.Parse(jObj.GetStringValue("CompData"));
TextItem multiItem = new TextItem()
{
Name = multiObj.GetStringValue("Name"),
WordsLength = multiObj.GetInt("WordsLength"),
IsRequire = multiObj.GetBoolValue("IsRequire"),
};
dataItem.CompData = multiItem;
break;
//下拉框
case "DorpDownList":
JObject dropdownObj = JObject.Parse(jObj.GetStringValue("CompData"));
SelectItem selectItem = new SelectItem()
{
Name = dropdownObj.GetStringValue("Name"),
IsMultiple = dropdownObj.GetBoolValue("IsMultiple"),
IsRequire = dropdownObj.GetBoolValue("IsRequire"),
OptionValue = "",
};
dataItem.CompData = selectItem;
break;
//图片上传组件
case "ImageUploadComp":
JObject imgObj = JObject.Parse(jObj.GetStringValue("CompData"));
UploadItem imgItem = new UploadItem()
{
Name = imgObj.GetStringValue("Name"),
FileCount = imgObj.GetInt("FileCount"),
FileSizeLimit = imgObj.GetInt("FileSizeLimit"),
};
dataItem.CompData = imgItem;
break;
//视频上传组件
case "VideoUploadComp":
JObject videoObj = JObject.Parse(jObj.GetStringValue("CompData"));
UploadItem videoItem = new UploadItem()
{
Name = videoObj.GetStringValue("Name"),
FileCount = videoObj.GetInt("FileCount"),
FileSizeLimit = videoObj.GetInt("FileSizeLimit"),
};
dataItem.CompData = videoItem;
break;
}
dataList.Add(dataItem);
}
}
}
}
return dataList;
}
/// <summary>
/// 根据编号删除自定义表单
/// </summary>
......
......@@ -39,7 +39,7 @@ namespace Mall.Module.User
bool flag = false;
if (list != null && list.Count > 0)
{
tenant_PlugRepository.DeleteOne(new WhereHelper(nameof(RB_Tenant_Menu_Extend.TenantId), list[0].TenantId));
tenant_PlugRepository.DeleteTenantPlugRepository(list[0].TenantId, list[0].QPlugTypeStr);
foreach (var item in list)
{
flag = tenant_PlugRepository.Insert(item) > 0;
......
......@@ -49,5 +49,18 @@ WHERE 1=1
}
return Get<RB_Tenant_Plug_Extend>(builder.ToString(), parameters).ToList();
}
/// <summary>
/// 根据类型和商户号删除插件
/// </summary>
/// <param name="TenantId"></param>
/// <param name="QPlugTypeStr"></param>
/// <returns></returns>
public bool DeleteTenantPlugRepository(int TenantId, string QPlugTypeStr)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(" DELETE FROM RB_Tenant_Plug WHERE TenantId={0} AND PlugId IN (SELECT PlugId FROM rb_plugin WHERE PlugType IN({1})) ", TenantId, QPlugTypeStr);
return base.Execute(builder.ToString()) > 0;
}
}
}
......@@ -43,7 +43,15 @@ namespace Mall.WebApi.Controllers.MallBase
query.TenantId = RequestParm.TenantId;
var list = customFormModule.GetCustomFormPageModule(pageModel.pageIndex, pageModel.pageSize, out long rowsCount, query);
pageModel.count = Convert.ToInt32(rowsCount);
pageModel.pageData = list;
pageModel.pageData = list.Select(qitem => new
{
qitem.Id,
qitem.FormType,
qitem.FormTypeStr,
qitem.FormName,
qitem.FormDataList,
CreateDate = Common.ConvertHelper.FormatTime(qitem.CreateDate),
});
return ApiResult.Success(data: pageModel);
}
......@@ -81,6 +89,15 @@ namespace Mall.WebApi.Controllers.MallBase
FormType = (Common.Enum.TradePavilion.CustomFormTypeEnum)parms.GetInt("FormType")
};
var formData = parms.GetStringValue("FormData");
List<FormDataItem> dataList = customFormModule.AnalyzeFormComponent(formData);
if (dataList != null && dataList.Count > 0)
{
model.FormData = Common.Plugin.JsonHelper.Serialize(dataList);
}
else
{
model.FormData = "";
}
model.MallBaseId = RequestParm.MallBaseId;
model.TenantId = RequestParm.TenantId;
model.CreateBy = base.UserInfo.TenantId;
......@@ -88,8 +105,12 @@ namespace Mall.WebApi.Controllers.MallBase
model.CreateDate = DateTime.Now;
model.UpdateDate = DateTime.Now;
model.Status = Common.Enum.DateStateEnum.Normal;
if (customFormModule.CheckExistsCustomFormModule(model))
{
return ApiResult.Failed(message: "已存在此类型的表单!");
};
var flag = customFormModule.SetCustomFormModule(model);
return flag ? ApiResult.Success() : ApiResult.Failed();
return flag ? ApiResult.Success(data:model) : ApiResult.Failed();
}
/// <summary>
......
......@@ -718,6 +718,10 @@ namespace Mall.WebApi.Controllers.User
{
PlugTypeName = "其他组件";
}
else if (item.Key == 4)
{
PlugTypeName = "表单组件";
}
result.Add(new
{
Id="",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment