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删除
</summary>
</member>
<member name="P:Ewide.Core.Service.OrgInput.AreaNumberCode">
<member name="P:Ewide.Core.Service.OrgInput.AreaCode">
<summary>
机构所在区域
</summary>
@@ -5603,7 +5603,7 @@
编码
</summary>
</member>
<member name="P:Ewide.Core.Service.AddOrgInput.AreaNumberCode">
<member name="P:Ewide.Core.Service.AddOrgInput.AreaCode">
<summary>
机构所在区域
</summary>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -21,6 +21,7 @@
@import './lib/form.less';
@import './lib/description.less';
@import './lib/select.less';
@import './lib/cascader.less';
@import './lib/dropdown.less';
@import './lib/modal.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-mentions,
.ant-select-selection,
.ant-input-group-addon {
.ant-input-group-addon,
.ant-cascader-picker,
.ant-cascader-input.ant-input {
z-index: 1;
text-align: left;
color: lighten(@black, 10%);
border: 0;
background-color: lighten(@black, 95%);
background-color: lighten(@black, 95%) !important;
}
.ant-mentions {
textarea {
@@ -86,6 +88,11 @@
.focus();
}
}
.ant-cascader-picker:focus {
.ant-cascader-input {
.focus();
}
}
.ant-input-group {
.ant-row-flex {
.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 {
/**
* 发送记录查询
*
* @author yubaoshan
* @date 2020/7/3 22:11
*/
smsPage: ['/sms/page', 'get'],
/**
* 验证短信验证码
*
* @author yubaoshan
* @date 2020/7/3 22:12
*/
sysSendLoginMessage: ['/sms/sendLoginMessage', 'post'],
/**
* 验证短信验证码
*
* @author yubaoshan
* @date 2020/7/3 22:12
*/
sysValidateMessage: ['/sms/validateMessage', 'post'],

View File

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

View File

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

View File

@@ -18,6 +18,15 @@
v-model="form.pid"
/>
</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-input-number
:max="1000"
@@ -48,11 +57,13 @@ export default {
name: [{ required: true, message: '请输入机构名称' }],
code: [{ required: true, message: '请输入唯一编码' }],
pid: [{ required: true, message: '请选择上级机构' }],
areaCode: [{ required: true, message: '请选择所属区域' }],
},
loading: false,
orgData: [],
areaData: [],
};
},
methods: {
@@ -64,8 +75,44 @@ export default {
if (orgId) {
this.form.pid = orgId;
} 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() {
this.loading = true;
await this.onLoadOrgData();
await this.onLoadAreaData();
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>