Commit fd9786b6 by jianshuqin

优化:组件功能

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