update 组织机构新增区域选择

This commit is contained in:
2021-04-30 14:02:36 +08:00
parent fdb4b4897b
commit 7a57ba34ed
14 changed files with 106 additions and 37 deletions

View File

@@ -5588,7 +5588,7 @@
状态(字典 0正常 1停用 2删除 状态(字典 0正常 1停用 2删除
</summary> </summary>
</member> </member>
<member name="P:Ewide.Core.Service.OrgInput.AreaNumberCode"> <member name="P:Ewide.Core.Service.OrgInput.AreaCode">
<summary> <summary>
机构所在区域 机构所在区域
</summary> </summary>
@@ -5603,7 +5603,7 @@
编码 编码
</summary> </summary>
</member> </member>
<member name="P:Ewide.Core.Service.AddOrgInput.AreaNumberCode"> <member name="P:Ewide.Core.Service.AddOrgInput.AreaCode">
<summary> <summary>
机构所在区域 机构所在区域
</summary> </summary>

View File

@@ -67,8 +67,8 @@ namespace Ewide.Core.Service
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet("/sysApp/page")] [HttpPost("/sysApp/page")]
public async Task<dynamic> QueryAppPageList([FromQuery] AppInput input) public async Task<dynamic> QueryAppPageList([FromBody] AppInput input)
{ {
var apps = await _sysAppRep.DetachedEntities var apps = await _sysAppRep.DetachedEntities
.Where( .Where(

View File

@@ -80,6 +80,7 @@ namespace Ewide.Core.Service.Area
return new TreeBuildUtil<AreaTreeNode>().DoTreeBuild(cachedAreaCodes.Select(u => new AreaTreeNode return new TreeBuildUtil<AreaTreeNode>().DoTreeBuild(cachedAreaCodes.Select(u => new AreaTreeNode
{ {
Code = u.Code, Code = u.Code,
AdCode = u.AdCode,
ParentCode = u.ParentCode, ParentCode = u.ParentCode,
Name = u.Name, Name = u.Name,
LevelType = u.LevelType, LevelType = u.LevelType,
@@ -97,7 +98,7 @@ namespace Ewide.Core.Service.Area
var AreaCodes = await _areaCodeRep.DetachedEntities var AreaCodes = await _areaCodeRep.DetachedEntities
.Where(input.LevelType.HasValue, a => a.LevelType == input.LevelType) .Where(input.LevelType.HasValue, a => a.LevelType == input.LevelType)
.Where(!string.IsNullOrEmpty(input.Code), a => a.Code.StartsWith(input.Code)) .Where(!string.IsNullOrEmpty(input.Code), a => a.Code.StartsWith(input.Code))
.Where(!string.IsNullOrEmpty(input.ShowCode), a => a.AdCode.StartsWith(input.ShowCode)) .Where(!string.IsNullOrEmpty(input.AdCode), a => a.AdCode.StartsWith(input.AdCode))
.Where(!string.IsNullOrEmpty(input.Name), a => a.Name.StartsWith(input.Name)) .Where(!string.IsNullOrEmpty(input.Name), a => a.Name.StartsWith(input.Name))
.ToPageData(input); .ToPageData(input);
return XnPageResult<SysAreaCode>.PageResult(AreaCodes); return XnPageResult<SysAreaCode>.PageResult(AreaCodes);

View File

@@ -10,7 +10,7 @@ namespace Ewide.Core.Service.Area.Dto
public class AreaCodeInput : XnInputBase public class AreaCodeInput : XnInputBase
{ {
public string Code { get; set; } public string Code { get; set; }
public string ShowCode { get; set; } public string AdCode { get; set; }
public string Name { get; set; } public string Name { get; set; }
public int? LevelType { get; set; } public int? LevelType { get; set; }
public string Note { get; set; } public string Note { get; set; }
@@ -18,7 +18,7 @@ namespace Ewide.Core.Service.Area.Dto
} }
public class UpdateAreaCodeInput public class UpdateAreaCodeInput
{ {
public string ShowCode { get; set; } public string AdCode { get; set; }
public string Name { get; set; } public string Name { get; set; }
public int? LevelType { get; set; } public int? LevelType { get; set; }
public string Note { get; set; } public string Note { get; set; }

View File

@@ -49,7 +49,7 @@ namespace Ewide.Core.Service
/// <summary> /// <summary>
/// 机构所在区域 /// 机构所在区域
/// </summary> /// </summary>
public virtual string AreaNumberCode { get; set; } public virtual string AreaCode { get; set; }
} }
public class AddOrgInput : OrgInput public class AddOrgInput : OrgInput
@@ -69,7 +69,7 @@ namespace Ewide.Core.Service
/// 机构所在区域 /// 机构所在区域
/// </summary> /// </summary>
[Required(ErrorMessage = "机构所在区域不能为空")] [Required(ErrorMessage = "机构所在区域不能为空")]
public override string AreaNumberCode { get; set; } public override string AreaCode { get; set; }
} }
public class DeleteOrgInput public class DeleteOrgInput

View File

@@ -48,7 +48,7 @@ namespace Ewide.Core.Service
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost("/sysOrg/page")] [HttpPost("/sysOrg/page")]
public async Task<dynamic> QueryOrgPageList([FromForm] PageOrgInput input) public async Task<dynamic> QueryOrgPageList([FromBody] PageOrgInput input)
{ {
var dataScopeList = GetDataScopeList(await GetUserDataScopeIdList()); var dataScopeList = GetDataScopeList(await GetUserDataScopeIdList());

View File

@@ -21,6 +21,7 @@
@import './lib/form.less'; @import './lib/form.less';
@import './lib/description.less'; @import './lib/description.less';
@import './lib/select.less'; @import './lib/select.less';
@import './lib/cascader.less';
@import './lib/dropdown.less'; @import './lib/dropdown.less';
@import './lib/modal.less'; @import './lib/modal.less';
@import './lib/tree-layout.less'; @import './lib/tree-layout.less';

View File

@@ -0,0 +1,4 @@
@import (reference) '~@/assets/style/extend.less';
.ant-cascader-picker-arrow {
transform: scaleY(.75);
}

View File

@@ -51,14 +51,16 @@
.ant-input-number, .ant-input-number,
.ant-mentions, .ant-mentions,
.ant-select-selection, .ant-select-selection,
.ant-input-group-addon { .ant-input-group-addon,
.ant-cascader-picker,
.ant-cascader-input.ant-input {
z-index: 1; z-index: 1;
text-align: left; text-align: left;
color: lighten(@black, 10%); color: lighten(@black, 10%);
border: 0; border: 0;
background-color: lighten(@black, 95%); background-color: lighten(@black, 95%) !important;
} }
.ant-mentions { .ant-mentions {
textarea { textarea {
@@ -86,6 +88,11 @@
.focus(); .focus();
} }
} }
.ant-cascader-picker:focus {
.ant-cascader-input {
.focus();
}
}
.ant-input-group { .ant-input-group {
.ant-row-flex { .ant-row-flex {
.ant-select { .ant-select {

View File

@@ -2,7 +2,7 @@ export default {
/** /**
* 系统应用列表 * 系统应用列表
*/ */
getAppPage: ['/sysApp/page', 'get'], getAppPage: ['/sysApp/page', 'post'],
/** /**
* 系统应用列表 * 系统应用列表
*/ */

View File

@@ -1,25 +1,16 @@
export default { export default {
/** /**
* 发送记录查询 * 发送记录查询
*
* @author yubaoshan
* @date 2020/7/3 22:11
*/ */
smsPage: ['/sms/page', 'get'], smsPage: ['/sms/page', 'get'],
/** /**
* 验证短信验证码 * 验证短信验证码
*
* @author yubaoshan
* @date 2020/7/3 22:12
*/ */
sysSendLoginMessage: ['/sms/sendLoginMessage', 'post'], sysSendLoginMessage: ['/sms/sendLoginMessage', 'post'],
/** /**
* 验证短信验证码 * 验证短信验证码
*
* @author yubaoshan
* @date 2020/7/3 22:12
*/ */
sysValidateMessage: ['/sms/validateMessage', 'post'], sysValidateMessage: ['/sms/validateMessage', 'post'],

View File

@@ -55,7 +55,7 @@ export default {
if (valid) { if (valid) {
this.confirmLoading = true; this.confirmLoading = true;
this.$api this.$api
.sysOrgAdd(this.$refs['form-body'].form) .sysOrgAdd(this.$refs['form-body'].onGetData())
.then(({ success }) => { .then(({ success }) => {
if (success) { if (success) {
this.$message.success('新增成功'); this.$message.success('新增成功');

View File

@@ -47,7 +47,7 @@ export default {
if (valid) { if (valid) {
this.confirmLoading = true; this.confirmLoading = true;
this.$api this.$api
.sysOrgEdit(this.$refs['form-body'].form) .sysOrgEdit(this.$refs['form-body'].onGetData())
.then(({ success }) => { .then(({ success }) => {
if (success) { if (success) {
this.$message.success('编辑成功'); this.$message.success('编辑成功');

View File

@@ -18,6 +18,15 @@
v-model="form.pid" v-model="form.pid"
/> />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="所属区域" prop="areaCode">
<a-cascader
:field-names="{ label: 'name', value: 'code', children: 'children' }"
:options="areaData"
change-on-select
placeholder="请选择所属区域"
v-model="form.areaCode"
/>
</a-form-model-item>
<a-form-model-item label="排序" prop="sort"> <a-form-model-item label="排序" prop="sort">
<a-input-number <a-input-number
:max="1000" :max="1000"
@@ -48,11 +57,13 @@ export default {
name: [{ required: true, message: '请输入机构名称' }], name: [{ required: true, message: '请输入机构名称' }],
code: [{ required: true, message: '请输入唯一编码' }], code: [{ required: true, message: '请输入唯一编码' }],
pid: [{ required: true, message: '请选择上级机构' }], pid: [{ required: true, message: '请选择上级机构' }],
areaCode: [{ required: true, message: '请选择所属区域' }],
}, },
loading: false, loading: false,
orgData: [], orgData: [],
areaData: [],
}; };
}, },
methods: { methods: {
@@ -64,8 +75,44 @@ export default {
if (orgId) { if (orgId) {
this.form.pid = orgId; this.form.pid = orgId;
} else if (record) { } else if (record) {
this.form = this.$_.cloneDeep(record); // 从字符串areaCode查找到整个层级
const areaCode = [];
const findCode = (data, level) => {
level = level || 0;
for (let i = 0; i < data.length; i++) {
const item = data[i];
areaCode[level] = item.code;
if (item.code === record.areaCode) {
areaCode.length = level + 1;
return true;
} }
if (item.children && item.children.length) {
const found = findCode(item.children, level + 1);
if (found) {
return true;
}
}
}
};
if (record.areaCode) {
findCode(this.areaData);
}
this.form = this.$_.cloneDeep({
...record,
areaCode,
});
}
},
onGetData() {
const submitForm = this.$_.cloneDeep(this.form);
submitForm.areaCode = submitForm.areaCode[submitForm.areaCode.length - 1];
return submitForm;
}, },
/** /**
@@ -89,6 +136,7 @@ export default {
async onInit() { async onInit() {
this.loading = true; this.loading = true;
await this.onLoadOrgData(); await this.onLoadOrgData();
await this.onLoadAreaData();
this.loading = false; this.loading = false;
}, },
@@ -106,6 +154,23 @@ export default {
]; ];
}); });
}, },
onLoadAreaData() {
return this.$api.getAreaTree().then(({ data }) => {
// 为了防止出现空的层级选择,删除所有空children节点
const clearChiildren = (data) => {
data.forEach((item) => {
if (item.children && item.children.length) {
clearChiildren(item.children);
} else {
delete item.children;
}
});
};
clearChiildren(data);
this.areaData = data;
});
},
}, },
}; };
</script> </script>