update 字典表增加扩展字段
This commit is contained in:
@@ -30,6 +30,9 @@ namespace Ewide.Core
|
||||
[Comment("编码")]
|
||||
public string Code { get; set; }
|
||||
|
||||
[Comment("扩展编码,以json形式存储")]
|
||||
public string ExtCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
|
||||
@@ -3889,6 +3889,11 @@
|
||||
编码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Ewide.Core.Service.DictDataInput.ExtCode">
|
||||
<summary>
|
||||
扩展编码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Ewide.Core.Service.DictDataInput.Sort">
|
||||
<summary>
|
||||
排序
|
||||
|
||||
@@ -23,6 +23,11 @@ namespace Ewide.Core.Service
|
||||
/// </summary>
|
||||
public virtual string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 扩展编码
|
||||
/// </summary>
|
||||
public virtual string ExtCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
|
||||
@@ -71,7 +71,10 @@ namespace Ewide.Core.Service
|
||||
if (isExist) throw Oops.Oh(ErrorCode.D3003);
|
||||
//datatype 的code 为null 则不能添加
|
||||
var dataType = _sysDictTypeRep.Where(s => s.Id == input.TypeId).FirstOrDefault();
|
||||
if (string.IsNullOrEmpty(dataType.Code)) throw new Exception("此处类型不能添加数据");
|
||||
if (string.IsNullOrEmpty(dataType.Code)) throw Oops.Oh("此处类型不能添加数据");
|
||||
|
||||
input.ExtCode = CheckExtCode(input.ExtCode);
|
||||
|
||||
var dictData = input.Adapt<SysDictData>();
|
||||
await _sysDictDataRep.InsertAsync(dictData);
|
||||
}
|
||||
@@ -119,6 +122,8 @@ namespace Ewide.Core.Service
|
||||
isExist = await _sysDictDataRep.AnyAsync(u => (u.Value == input.Value || u.Code == input.Code) && u.TypeId == input.TypeId && u.Id != input.Id, false);
|
||||
if (isExist) throw Oops.Oh(ErrorCode.D3003);
|
||||
|
||||
input.ExtCode = CheckExtCode(input.ExtCode);
|
||||
|
||||
var dictData = input.Adapt<SysDictData>();
|
||||
await _sysDictDataRep.UpdateAsync(dictData, ignoreNullValues: true);
|
||||
}
|
||||
@@ -159,13 +164,14 @@ namespace Ewide.Core.Service
|
||||
public async Task<dynamic> GetDictDataListByDictTypeId(string dictTypeId)
|
||||
{
|
||||
return await _sysDictDataRep.DetachedEntities.Where(u => u.SysDictType.Id == dictTypeId)
|
||||
.Where(u => u.Status != CommonStatus.DELETED).OrderBy(u => u.Sort)
|
||||
.Select(u => new
|
||||
{
|
||||
u.Code,
|
||||
u.Value,
|
||||
u.Remark
|
||||
}).ToListAsync();
|
||||
.Where(u => u.Status != CommonStatus.DELETED).OrderBy(u => u.Sort)
|
||||
.Select(u => new
|
||||
{
|
||||
u.Code,
|
||||
u.Value,
|
||||
ExtCode = String.IsNullOrEmpty(u.ExtCode) ? null : Newtonsoft.Json.JsonConvert.DeserializeObject<object>(u.ExtCode),
|
||||
u.Remark
|
||||
}).ToListAsync();
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
@@ -183,6 +189,7 @@ namespace Ewide.Core.Service
|
||||
{
|
||||
u.Code,
|
||||
u.Value,
|
||||
ExtCode = String.IsNullOrEmpty(u.ExtCode) ? null : Newtonsoft.Json.JsonConvert.DeserializeObject<object>(u.ExtCode),
|
||||
u.Remark
|
||||
}));
|
||||
}
|
||||
@@ -202,5 +209,23 @@ namespace Ewide.Core.Service
|
||||
u.Delete();
|
||||
});
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
private string CheckExtCode(string extCode)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(extCode))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (extCode.StartsWith('{') && extCode.EndsWith('}'))
|
||||
{
|
||||
return Newtonsoft.Json.JsonConvert.SerializeObject(Newtonsoft.Json.JsonConvert.DeserializeObject(extCode));
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
<Auth auth="sysDictData:edit" slot="code" slot-scope="text, record">
|
||||
<a-input placeholder="请输入字典值" v-model="record.code" />
|
||||
</Auth>
|
||||
<Auth auth="sysDictData:edit" slot="extCode" slot-scope="text, record">
|
||||
<a-input placeholder="请输入扩展值" v-model="record.extCode" />
|
||||
</Auth>
|
||||
<Auth auth="sysDictData:edit" slot="sort" slot-scope="text, record">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
@@ -108,6 +111,13 @@ export default {
|
||||
scopedSlots: { customRender: 'code' },
|
||||
width: '15%',
|
||||
},
|
||||
{
|
||||
title: '扩展值',
|
||||
dataIndex: 'extCode',
|
||||
sorter: true,
|
||||
scopedSlots: { customRender: 'extCode' },
|
||||
width: '15%',
|
||||
},
|
||||
{
|
||||
title: '排序',
|
||||
dataIndex: 'sort',
|
||||
|
||||
Reference in New Issue
Block a user