update 项目管理

This commit is contained in:
2021-05-07 20:34:55 +08:00
parent be24cf2558
commit ab138ed22f
6 changed files with 67 additions and 48 deletions

View File

@@ -31,10 +31,6 @@ namespace Ewide.Application.Entity
[Required] [Required]
public string AreaId { get; set; } public string AreaId { get; set; }
[Comment("区域名称")]
[MaxLength(500)]
public string AreaName { get; set; }
[Comment("类型")] [Comment("类型")]
[Required] [Required]
public int Type { get; set; } public int Type { get; set; }

View File

@@ -14,7 +14,6 @@ namespace Ewide.Application.Service.HouseProjectInfo.Dto
public string Note { get; set; } public string Note { get; set; }
public int Sort { get; set; } public int Sort { get; set; }
public string AreaId { get; set; } public string AreaId { get; set; }
public string AreaName { get; set; }
public int Type { get; set; } public int Type { get; set; }
} }
public class AddProjectInput : HouseProjectInfoInput public class AddProjectInput : HouseProjectInfoInput

View File

@@ -63,7 +63,7 @@ namespace Ewide.Application.Service.HouseProjectInfo
public async Task UpdateProject(UpdateProjectInput input) public async Task UpdateProject(UpdateProjectInput input)
{ {
var project = input.Adapt<BsHouseProjectInfo>(); var project = input.Adapt<BsHouseProjectInfo>();
await project.UpdateExcludeAsync(new[] { nameof(BsHouseProjectInfo.AreaId), nameof(BsHouseProjectInfo.AreaName)}, true); await project.UpdateExcludeAsync(new[] { nameof(BsHouseProjectInfo.AreaId)}, true);
} }
/// <summary> /// <summary>
@@ -86,9 +86,11 @@ namespace Ewide.Application.Service.HouseProjectInfo
public async Task<dynamic> QueryProjectPageList([FromBody] HouseProjectInfoInput input) public async Task<dynamic> QueryProjectPageList([FromBody] HouseProjectInfoInput input)
{ {
var areaID = !string.IsNullOrEmpty(input.AreaId); var areaID = !string.IsNullOrEmpty(input.AreaId);
var areaCodeRep = Db.GetRepository<SysAreaCode>();
var projects = await _houseProjectInfoRep.DetachedEntities var projects = await _houseProjectInfoRep.DetachedEntities
.Where(areaID, p => p.AreaId == input.AreaId) .Join(areaCodeRep.DetachedEntities, p => p.AreaId, a => a.Code, (p, a) => new { p, AreaName = a.Name })
.Select(p => p.Adapt<HouseProjectOutput>()).ToPagedListAsync(input.PageNo, input.PageSize); .Where(areaID, x => x.p.AreaId == input.AreaId)
.Select(x => new { x.p.Id, x.p.Name, x.p.Note, x.p.Sort, x.p.AreaId, x.AreaName, x.p.Type }.Adapt<HouseProjectOutput>()).ToPagedListAsync(input.PageNo, input.PageSize);
return XnPageResult<HouseProjectOutput>.PageResult(projects); return XnPageResult<HouseProjectOutput>.PageResult(projects);
} }

View File

@@ -10,6 +10,10 @@
<a-icon slot="indicator" spin type="loading" /> <a-icon slot="indicator" spin type="loading" />
<div class="yo-form-group"> <div class="yo-form-group">
<!-- 表单控件 --> <!-- 表单控件 -->
<a-form-model-item label="所属区域" prop="areaId">
<!-- <a-tree-select :dropdown-style="{ maxHeight: '300px', overflow: 'auto' }" :tree-data="areaData" :replace-fields="{ value: 'code', title: 'name', children: 'children' }" placeholder="请选择所属区域" tree-default-expand-all v-model="form.areaId" /> -->
<a-cascader :field-names="{ label: 'name', value: 'code', children: 'children' }" :options="areaData" expand-trigger="hover" placeholder="请选择所属区域" v-model="form.areaCode" />
</a-form-model-item>
<a-form-model-item label="项目名称" prop="name"> <a-form-model-item label="项目名称" prop="name">
<a-input placeholder="请输入项目名称" v-model="form.name" /> <a-input placeholder="请输入项目名称" v-model="form.name" />
</a-form-model-item> </a-form-model-item>
@@ -19,6 +23,12 @@
<a-form-model-item label="备注" prop="note"> <a-form-model-item label="备注" prop="note">
<a-textarea :rows="4" placeholder="请输入备注" v-model="form.note"></a-textarea> <a-textarea :rows="4" placeholder="请输入备注" v-model="form.note"></a-textarea>
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="类型" prop="type">
<a-radio-group v-model="form.type">
<a-radio-button :value="1"> 住宅 </a-radio-button>
<a-radio-button :value="2"> 非住宅 </a-radio-button>
</a-radio-group>
</a-form-model-item>
<!-- ... --> <!-- ... -->
</div> </div>
</a-spin> </a-spin>
@@ -28,11 +38,7 @@
/* 表单内容默认值 */ /* 表单内容默认值 */
const defaultForm = { const defaultForm = {
/* ... */ /* ... */
areaId: '330266001001',
areaName: '测试社区',
type: 1,
}; };
export default { export default {
data() { data() {
return { return {
@@ -48,6 +54,7 @@ export default {
loading: false, loading: false,
/** 其他成员属性 */ /** 其他成员属性 */
areaData: [],
/* ... */ /* ... */
}; };
}, },
@@ -58,11 +65,38 @@ export default {
* 在打开编辑页时允许填充数据 * 在打开编辑页时允许填充数据
*/ */
onFillData(params) { onFillData(params) {
// 从字符串areaCode查找到整个层级
const areaCodeDeault = params.record ? params.record.areaId : params.pid ? params.pid : '';
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 === areaCodeDeault) {
areaCode.length = level + 1;
return true;
}
if (item.children && item.children.length) {
const found = findCode(item.children, level + 1);
if (found) {
return true;
}
}
}
};
if (areaCodeDeault) {
findCode(this.areaData);
}
/** 将默认数据覆盖到form */ /** 将默认数据覆盖到form */
this.form = this.$_.cloneDeep({ this.form = this.$_.cloneDeep({
...defaultForm, ...defaultForm,
...params.record, ...params.record,
/** 在此处添加其他默认数据转换 */ /** 在此处添加其他默认数据转换 */
areaCode: areaCode,
/* ... */ /* ... */
}); });
}, },
@@ -116,11 +150,17 @@ export default {
async onInit(params) { async onInit(params) {
this.loading = true; this.loading = true;
/** 可以在这里await获取一些异步数据 */ /** 可以在这里await获取一些异步数据 */
this.areaData = await this.onLoadAreaData();
/* ... */ /* ... */
this.loading = false; this.loading = false;
}, },
/** 当前组件的其他方法 */ /** 当前组件的其他方法 */
onLoadAreaData() {
return this.$api.getAreaTree().then((res) => {
return res.data;
});
},
/* ... */ /* ... */
}, },
}; };

View File

@@ -80,7 +80,7 @@ export default {
name: '项目', name: '项目',
/* 查询条件 */ /* 查询条件 */
query: { name: '' }, query: {},
/* 表格字段 */ /* 表格字段 */
columns: [ columns: [
@@ -94,6 +94,11 @@ export default {
dataIndex: 'areaName', dataIndex: 'areaName',
sorter: true, sorter: true,
}, },
{
title: '备注',
dataIndex: 'note',
sorter: true,
},
{ {
title: '类型', title: '类型',
dataIndex: 'type', dataIndex: 'type',
@@ -225,6 +230,10 @@ export default {
* 从列表页调用窗口的打开方法 * 从列表页调用窗口的打开方法
*/ */
onOpen(formName, record) { onOpen(formName, record) {
// if (formName == 'add-form' && !this.query.pid) {
// this.$message.warn('请选择项目所属街道', 0.5);
// return null;
// }
this.$refs[formName].onOpen({ this.$refs[formName].onOpen({
record, record,
pid: this.query.pid, pid: this.query.pid,

View File

@@ -16,17 +16,8 @@
<a-input allow-clear placeholder="请输入姓名、账号、手机号" v-model="query.searchValue" /> <a-input allow-clear placeholder="请输入姓名、账号、手机号" v-model="query.searchValue" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="状态"> <a-form-model-item label="状态">
<a-select <a-select :style="{ width: '170px' }" allow-clear placeholder="请选择状态" v-model="query.searchStatus">
:style="{ width: '170px' }" <a-select-option :key="i" :value="item.code" v-for="(item, i) in codes.find((p) => p.code === 'common_status').values">{{ item.value }}</a-select-option>
allow-clear
placeholder="请选择状态"
v-model="query.searchStatus"
>
<a-select-option
:key="i"
:value="item.code"
v-for="(item, i) in codes.find(p => p.code === 'common_status').values"
>{{ item.value }}</a-select-option>
</a-select> </a-select>
</a-form-model-item> </a-form-model-item>
<a-form-model-item> <a-form-model-item>
@@ -75,14 +66,7 @@
<a-list-item-meta> <a-list-item-meta>
<div slot="title">{{ record.nickName || record.name }}</div> <div slot="title">{{ record.nickName || record.name }}</div>
<div slot="description">{{ record.account }}</div> <div slot="description">{{ record.account }}</div>
<yo-image <yo-image :id="record.avatar" :size="48" icon="user" shape="square" slot="avatar" type="avatar" />
:id="record.avatar"
:size="48"
icon="user"
shape="square"
slot="avatar"
type="avatar"
/>
</a-list-item-meta> </a-list-item-meta>
<div class="yo-list-content--h"> <div class="yo-list-content--h">
<div class="yo-list-content--h--item"> <div class="yo-list-content--h--item">
@@ -95,13 +79,7 @@
</div> </div>
<Auth auth="sysUser:changeStatus"> <Auth auth="sysUser:changeStatus">
<div class="yo-list-content--h--item"> <div class="yo-list-content--h--item">
<a-switch <a-switch :checked="!record.status" :checked-children="bindCodeValue(0, 'common_status')" :loading="record.statusChanging" :un-checked-children="bindCodeValue(1, 'common_status')" @change="(checked) => onSetUserStatus(record, checked)" />
:checked="!record.status"
:checked-children="bindCodeValue(0, 'common_status')"
:loading="record.statusChanging"
:un-checked-children="bindCodeValue(1, 'common_status')"
@change="checked => onSetUserStatus(record, checked)"
/>
</div> </div>
</Auth> </Auth>
</div> </div>
@@ -216,15 +194,10 @@ export default {
* 加载字典数据时的必要方法 * 加载字典数据时的必要方法
*/ */
onLoadCodes() { onLoadCodes() {
this.$api this.$api.$queue([this.$api.sysDictTypeDropDownAwait({ code: 'sex' }), this.$api.sysDictTypeDropDownAwait({ code: 'common_status' })]).then(([sex, commonStatus]) => {
.$queue([ this.codes.find((p) => p.code === 'sex').values = sex.data;
this.$api.sysDictTypeDropDownAwait({ code: 'sex' }), this.codes.find((p) => p.code === 'common_status').values = commonStatus.data;
this.$api.sysDictTypeDropDownAwait({ code: 'common_status' }), });
])
.then(([sex, commonStatus]) => {
this.codes.find((p) => p.code === 'sex').values = sex.data;
this.codes.find((p) => p.code === 'common_status').values = commonStatus.data;
});
}, },
bindCodeValue(code, name) { bindCodeValue(code, name) {
const c = this.codes.find((p) => p.code == name).values.find((p) => p.code == code); const c = this.codes.find((p) => p.code == name).values.find((p) => p.code == code);