Commit fd9786b6 by jianshuqin

优化:组件功能

parent 94a340ea
using Bailun.DC.Models.Component.Enum;
using System.Collections.Generic;
namespace Bailun.DC.Models.Component.DTO
{
......@@ -43,5 +44,10 @@ namespace Bailun.DC.Models.Component.DTO
/// 数据库
/// </summary>
public DBEnum? DataDb { get; set; }
/// <summary>
/// 选项
/// </summary>
public IEnumerable<OptionDTO> listOption { get; set; }
}
}
......@@ -13,6 +13,11 @@
public int? ParentId { get; set; }
/// <summary>
/// 父名称
/// </summary>
public string ParentName { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
......
namespace Bailun.DC.Models.Component.DTO
{
/// <summary>
/// 选项
/// </summary>
public class OptionDTO
{
/// <summary>
/// 字段名称
/// </summary>
public object Value { get; set; }
/// <summary>
/// 操作
/// </summary>
public string Display { get; set; }
}
}
\ No newline at end of file
using Bailun.DC.Models.Component.Enum;
using Dapper;
using System;
namespace Bailun.DC.Models.Component.Entity
......@@ -29,7 +30,7 @@ namespace Bailun.DC.Models.Component.Entity
public DictionaryCategoryEnum? category { get; set; }
/// <summary>
/// 类型:1:SQL
/// 类型:1:SQL 2:配置
/// </summary>
public DictionaryTypeEnum? type { get; set; }
......@@ -51,11 +52,13 @@ namespace Bailun.DC.Models.Component.Entity
/// <summary>
/// 是否删除: 1:是; 0:否
/// </summary>
[IgnoreUpdate]
public bool is_delete { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[IgnoreUpdate]
public DateTime gmt_create { get; set; }
/// <summary>
......
......@@ -101,6 +101,7 @@ namespace Bailun.DC.Models.Component.Entity
/// <summary>
/// 是否删除: 1:是; 0:否
/// </summary>
[IgnoreUpdate]
public bool is_delete { get; set; }
/// <summary>
......
......@@ -147,6 +147,7 @@ namespace Bailun.DC.Models.Component.Entity
/// <summary>
/// 是否删除
/// </summary>
[IgnoreUpdate]
public bool is_delete { get; set; }
/// <summary>
......
namespace Bailun.DC.Models.Component.Entity
using Dapper;
namespace Bailun.DC.Models.Component.Entity
{
/// <summary>
/// 菜单组件
......@@ -16,6 +18,12 @@
public int parentid { get; set; }
/// <summary>
/// 父名称
/// </summary>
[NotMapped]
public string parent_name { get; set; }
/// <summary>
/// 名称
/// </summary>
public string name { get; set; }
......@@ -38,6 +46,7 @@
/// <summary>
/// 是否删除:(默认否)
/// </summary>
[IgnoreUpdate]
public bool? delstatus { get; set; }
/// <summary>
......
......@@ -15,7 +15,7 @@ namespace Bailun.DC.Models.Component.Enum
}
/// <summary>
/// 字典类型:1: SQL
/// 字典类型:1: SQL 2: 配置
/// </summary>
public enum DictionaryTypeEnum
{
......@@ -23,6 +23,11 @@ namespace Bailun.DC.Models.Component.Enum
/// SQL
/// </summary>
[Description("SQL")]
SQL = 1
SQL = 1,
/// <summary>
/// 配置
/// </summary>
[Description("配置")]
CONFIG = 2
}
}
......@@ -3,6 +3,7 @@ using Bailun.DC.Models.Component.Entity;
using Bailun.DC.Models.Component.Enum;
using Dapper;
using MySql.Data.MySqlClient;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -40,6 +41,9 @@ namespace Bailun.DC.Services.Component
list = db.Query(entity.value, sqlparam);
}
break;
case DictionaryTypeEnum.CONFIG:
list = DeserializeCollection<dynamic>(entity.value);
break;
}
}
}
......@@ -87,15 +91,22 @@ namespace Bailun.DC.Services.Component
DataDb = entity.data_db,
Method = entity.method,
Type = entity.type,
Value = entity.value
};
switch (dto.Type)
{
case DictionaryTypeEnum.SQL:
dto.Value = entity.value;
break;
case DictionaryTypeEnum.CONFIG:
dto.listOption = DeserializeCollection<OptionDTO>(entity.value);
break;
}
}
}
return dto;
}
/// <summary>
/// 保存字典组件
/// </summary>
......@@ -115,7 +126,7 @@ namespace Bailun.DC.Services.Component
category = dto.Category,
type = dto.Type,
method = dto.Method,
value = dto.Value,
value = dto.Type == DictionaryTypeEnum.CONFIG ? JsonConvert.SerializeObject(dto.listOption) : dto.Value,
data_db = dto.DataDb,
gmt_create = DateTime.Now,
gmt_modified = DateTime.Now,
......@@ -216,10 +227,27 @@ namespace Bailun.DC.Services.Component
{
result.Message = "名称不能为空";
}
else if (!dto.Category.HasValue)
{
result.Message = "分类不能为空";
}
else if (!dto.Type.HasValue)
{
result.Message = "类型不能为空";
}
else if (dto.Type == DictionaryTypeEnum.SQL && string.IsNullOrWhiteSpace(dto.Value))
{
result.Message = "SQL不能为空";
}
else if (dto.Type == DictionaryTypeEnum.CONFIG && (dto.listOption == null || dto.listOption.Count() == 0))
{
result.Message = "选项不能为空";
}
else if (DB.QueryFirstOrDefault<int>($"select count(id) from dc_component_dictionary where code = @code {(dto.Id > 0 ? "and id <> @id" : string.Empty)}", new { id = dto.Id, code = dto.Code }) > 0)
{
result.Message = "编码重复";
}else
}
else
{
result.Result = true;
}
......
......@@ -31,7 +31,7 @@ namespace Bailun.DC.Services.Component
{
DynamicParameters sqlparam = new DynamicParameters();
sqlparam.Add("id", id);
entity = db.QueryFirstOrDefault<dc_menu>($"select * from dc_menu where id = @id", sqlparam);
entity = db.QueryFirstOrDefault<dc_menu>($"select t1.*,t2.name as parent_name from dc_menu t1 left join dc_menu t2 on t1.parentid = t2.id where t1.id = @id", sqlparam);
}
if (entity != null)
{
......@@ -43,6 +43,7 @@ namespace Bailun.DC.Services.Component
IsSys = entity.is_sys,
Name = entity.name,
ParentId = entity.parentid,
ParentName = entity.parent_name,
Path = entity.path,
Sort = entity.sort
};
......
......@@ -44,8 +44,8 @@
this.$refs.dialogForm.closeDialog();
},
//查询数据
onSearch: function () {
this.$refs.tableQuery.onSearch();
onSearch: function (firstPage) {
this.$refs.tableQuery.onSearch(null, firstPage);
}
}
})
......
......@@ -44,18 +44,18 @@
if (title) {
Vue.set(that.dialog, "name", title);
}
if (that.dialog.listItem && that.dialog.listItem.constructor === String) {
Vue.set(that.dialog, "listItem", JSON.parse(that.dialog.listItem));
if (that.dialog.listFormItem && that.dialog.listFormItem.constructor === String) {
Vue.set(that.dialog, "listFormItem", JSON.parse(that.dialog.listFormItem));
}
if (form && that.dialog.listItem && that.dialog.listItem.length) {
that.dialog.listItem.forEach(function (item) {
if (item.type == "select" && (!item.listOption || item.listOption.length) && form[item.prop] && form[item.propname] && item.value && item.display) {
if (form && that.dialog.listFormItem && that.dialog.listFormItem.length) {
that.dialog.listFormItem.forEach(function (item) {
if (item.type == "select" && (!item.listOption || item.listOption.length) && form[item.prop] && form[item.propname]) {
var listOption = [];
var listPropValue = Array.isArray(form[item.prop]) ? form[item.prop] : [form[item.prop]]
listPropValue.forEach(function (l, i) {
var option = {};
option[item.value] = l;
option[item.display] = Array.isArray(form[item.propname]) ? form[item.propname][i] : form[item.propname];
option[item.value || "value"] = l;
option[item.display || "display"] = Array.isArray(form[item.propname]) ? form[item.propname][i] : form[item.propname];
listOption.push(option);
})
Vue.set(item, "listOption", listOption);
......
......@@ -34,8 +34,12 @@
val = undefined;
}
if (val) {
if (this.item.type == 'select' && val && val.constructor == Number) {
if (this.item.type == 'select' && this.item.listOption && this.item.listOption.length) {
if (this.item.listOption[0].value.constructor == String && val.constructor == Number) {
val = val.toString();
} else if (this.item.listOption[0].value.constructor == Number && !isNaN(parseInt(val))) {
val = parseInt(val);
}
}
if (this.item.type == 'daterange' && val.constructor == Array && val.length > 1 && val[0].constructor == String && val[1].constructor == String) {
val = [new Date(val[0]), new Date(val[1])];
......@@ -115,6 +119,8 @@
} else {
that.$set(that, "item_value", that.item.defaultValue)
}
} else if (that.form && item.prop && that.form[item.prop]) {
that.$set(that, "item_value", that.form[item.prop])
}
}
}, function (error) {
......
......@@ -90,10 +90,12 @@
}
},
//查询
onSearch: function (listFilter) {
onSearch: function (listFilter, firstPage) {
var that = this;
//设置当前第一页
if (firstPage == null || firstPage == true) {
Vue.set(that.filterParams, 'currentPage', 1);
}
Vue.set(that.filterParams, 'code', that.code);
//获取过虑条件
this.getFilter(listFilter);
......
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