update 新增机构类型

This commit is contained in:
2021-05-21 16:10:08 +08:00
parent e4696f678e
commit c8530039eb
7 changed files with 83 additions and 29 deletions

View File

@@ -37,6 +37,12 @@ namespace Ewide.Core
[Comment("编码")]
public string Code { get; set; }
/// <summary>
/// 机构类型
/// </summary>
[Comment("机构类型")]
public int Type { get; set; }
/// <summary>
/// 联系人
/// </summary>

View File

@@ -1338,6 +1338,11 @@
编码
</summary>
</member>
<member name="P:Ewide.Core.SysOrg.Type">
<summary>
机构类型
</summary>
</member>
<member name="P:Ewide.Core.SysOrg.Contacts">
<summary>
联系人
@@ -5520,6 +5525,11 @@
编码
</summary>
</member>
<member name="P:Ewide.Core.Service.OrgInput.Type">
<summary>
机构类型
</summary>
</member>
<member name="P:Ewide.Core.Service.OrgInput.Tel">
<summary>
电话

View File

@@ -22,7 +22,7 @@ namespace Ewide.Core.Extension
return orderStr;
}
private static string OrderBuilder<T>(PageInputBase pageInput, bool descSort = true)
private static string OrderBuilder<T>(PageInputBase pageInput, bool descSort = false)
{
var type = typeof(T);
var hasId = type.GetProperty("Id") != null;

View File

@@ -99,7 +99,7 @@ namespace Ewide.Core.Service
{
var isExist = await _sysDictTypeRep.AnyAsync(u => u.Name == input.Name, false);
if (isExist) throw Oops.Oh(ErrorCode.D3001);
var dictTypeEntity = _sysDictTypeRep.Where(s => s.Pid == input.Pid).FirstOrDefault();
var dictTypeEntity = _sysDictTypeRep.Where(s => s.Id == input.Pid).FirstOrDefault();
if (dictTypeEntity != null && dictTypeEntity.Code != null) throw new Exception("此类型下不能添加子类型");
var dictType = input.Adapt<SysDictType>();
dictType.Pids = await CreateNewPids(input.Pid);
@@ -132,14 +132,14 @@ namespace Ewide.Core.Service
[HttpPost("/sysDictType/edit"),]
public async Task UpdateDictType(UpdateDictTypeInput input)
{
var isExist = await _sysDictTypeRep.AnyAsync(u => u.Id == input.Id, false);
if (!isExist) throw Oops.Oh(ErrorCode.D3000);
if (input.Id == input.Pid) throw Oops.Oh(ErrorCode.D4006);
var result = _sysDictTypeRep.Where(u => u.Id == input.Id).Select(s => new { s.Name, s.Id, s.Code }).ToList().First();
if (result == null) throw Oops.Oh(ErrorCode.D3000);
if (result.Name == input.Name) throw Oops.Oh(ErrorCode.D3001);
// 如果是编辑父id不能为自己的子节点
//var childIdList = await _sysDictTypeRep.DetachedEntities.Where(u => u.Pids.Contains(input.Id.ToString()))
// .Select(u => u.Id).ToListAsync();
//if (childIdList.Contains(input.Pid)) throw Oops.Oh(ErrorCode.D4006);
// 排除自己并且判断与其他是否相同
isExist = await _sysDictTypeRep.AnyAsync(u => (u.Name == input.Name || u.Code == input.Code) && u.Id != input.Id, false);
if (isExist) throw Oops.Oh(ErrorCode.D3001);
var dictType = input.Adapt<SysDictType>();
dictType.Pids = await CreateNewPids(input.Pid);

View File

@@ -27,6 +27,11 @@ namespace Ewide.Core.Service
/// </summary>
public virtual string Code { get; set; }
/// <summary>
/// 机构类型
/// </summary>
public virtual int Type { get; set; }
/// <summary>
/// 电话
/// </summary>

View File

@@ -17,6 +17,15 @@
<a-form-model-item label="唯一编码" prop="code">
<a-input placeholder="请输入唯一编码" v-model="form.code" />
</a-form-model-item>
<a-form-model-item label="机构类型" prop="type">
<a-select placeholder="请选择机构类型" v-model="form.type">
<a-select-option
:key="item.code"
:value="+item.code"
v-for="item in codes.type"
>{{ item.value }}</a-select-option>
</a-select>
</a-form-model-item>
<a-form-model-item label="上级机构" prop="pid">
<a-tree-select
:dropdown-style="{ maxHeight: '300px', overflow: 'auto' }"
@@ -68,8 +77,9 @@ export default {
form: {},
/** 验证格式 */
rules: {
name: [{ required: true, message: '请输入机构名称' }],
code: [{ required: true, message: '请输入唯一编码' }],
name: [{ required: true, message: '请输入机构名称', trigger: 'blur' }],
code: [{ required: true, message: '请输入唯一编码', trigger: 'blur' }],
type: [{ required: true, message: '请选择机构类型' }],
pid: [{ required: true, message: '请选择上级机构' }],
areaCode: [{ required: true, message: '请选择所属区域' }],
/* ... */
@@ -77,6 +87,11 @@ export default {
/** 加载异步数据状态 */
loading: false,
codes: {
type: [],
},
orgData: [],
areaData: [],
/** 其他成员属性 */
@@ -176,6 +191,7 @@ export default {
async onInit(params) {
this.loading = true;
/** 可以在这里await获取一些异步数据 */
await this.onLoadCodes();
await this.onLoadOrgData();
await this.onLoadAreaData();
/* ... */
@@ -184,6 +200,17 @@ export default {
/** 当前组件的其他方法 */
/* ... */
onLoadCodes() {
this.$api
.$queue([
this.$api.sysDictTypeDropDownAwait({ code: 'org_type' }),
/* ... */
])
.then(([org_type]) => {
this.codes.type = org_type.data;
/* ... */
});
},
onLoadOrgData() {
return this.$api.getOrgTree().then(({ data }) => {
this.orgData = [

View File

@@ -33,6 +33,9 @@
</Auth>
<!-- 格式化字段内容 -->
<!-- ... -->
<template slot="type" slot-scope="text">
<span>{{ bindCodeValue(text, 'type') }}</span>
</template>
<!-- 添加操作控件 -->
<span slot="action" slot-scope="text, record">
<yo-table-actions>
@@ -109,6 +112,12 @@ export default {
dataIndex: 'code',
sorter: true,
},
{
title: '机构类型',
dataIndex: 'type',
sorter: true,
scopedSlots: { customRender: 'type' },
},
{
title: '排序',
width: '80px',
@@ -123,15 +132,14 @@ export default {
],
/* 字典编码储存格式 */
// codes: {
// code1: [],
// code2: [],
// },
codes: {
type: [],
},
};
},
created() {
/** 按需加载字典编码 */
//this.onLoadCodes();
this.onLoadCodes();
/** 根据权限添加操作列 */
const flag = this.$auth(/* ... */);
@@ -193,19 +201,17 @@ export default {
* 加载字典数据
* 如果不需要获取相应的字典数据,此方法内容可空
*/
//onLoadCodes() {
// this.$api
// .$queue([
// this.$api.sysDictTypeDropDownAwait({ code: 'code1' }),
// this.$api.sysDictTypeDropDownAwait({ code: 'code2' }),
// /* ... */
// ])
// .then(([code1, code2]) => {
// this.codes.code1 = code1.data;
// this.codes.code2 = code2.data;
// /* ... */
// });
// },
onLoadCodes() {
this.$api
.$queue([
this.$api.sysDictTypeDropDownAwait({ code: 'org_type' }),
/* ... */
])
.then(([org_type]) => {
this.codes.type = org_type.data;
/* ... */
});
},
/**
* 必要方法