update 项目管理

This commit is contained in:
2021-05-06 19:21:14 +08:00
parent aa32dcf8e7
commit 3cca6b0e48
9 changed files with 341 additions and 72 deletions

View File

@@ -23,7 +23,7 @@
<param name="input"></param>
<returns></returns>
</member>
<member name="M:Ewide.Application.Service.HouseProjectInfo.HouseProjectInfoService.UpdateProject(Ewide.Application.Service.HouseProjectInfo.Dto.AddProjectInput)">
<member name="M:Ewide.Application.Service.HouseProjectInfo.HouseProjectInfoService.UpdateProject(Ewide.Application.Service.HouseProjectInfo.Dto.UpdateProjectInput)">
<summary>
编辑项目
</summary>

View File

@@ -13,39 +13,27 @@ namespace Ewide.Application.Service.HouseProjectInfo.Dto
public string Name { get; set; }
public string Note { 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 DateTime? CreatedTime { get; set; }
public DateTime? UpdatedTime { get; set; }
public string CreatedUserId { get; set; }
public string CreatedUserName { get; set; }
public string UpdatedUserId { get; set; }
public string UpdatedUserName { get; set; }
}
public class AddProjectInput : HouseProjectInfoInput
{
[Required(ErrorMessage = "项目ID不可为空")]
public string ID { get; set; }
}
public class UpdateProjectInput
public class UpdateProjectInput : HouseProjectInfoInput
{
public string ID { get; set; }
public string Note { get; set; }
public int Type { get; set; }
public DateTime? UpdatedTime { get; set; }
public string UpdatedUserId { get; set; }
public string UpdatedUserName { get; set; }
[Required(ErrorMessage = "项目ID不可为空")]
public string Id { get; set; }
}
public class DeleteProjectInput
{
[Required(ErrorMessage = "项目ID不可为空")]
public string ID { get; set; }
public string Id { get; set; }
}
public class QueryProjectInput : AddProjectInput
public class QueryProjectInput : UpdateProjectInput
{
}

View File

@@ -8,18 +8,12 @@ namespace Ewide.Application.Service.HouseProjectInfo.Dto
{
public class HouseProjectOutput
{
public string ID { get; set; }
public string Id { get; set; }
public string Name { get; set; }
public string Note { 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 DateTime CreatedTime { get; set; }
public DateTime UpdatedTime { get; set; }
public string CreatedUserId { get; set; }
public string CreatedUserName { get; set; }
public string UpdatedUserId { get; set; }
public string UpdatedUserName { get; set; }
}
}

View File

@@ -50,7 +50,7 @@ namespace Ewide.Application.Service.HouseProjectInfo
[HttpPost("/houseProjectInfo/delete")]
public async Task DeleteProject(DeleteProjectInput input)
{
var project = _houseProjectInfoRep.FirstOrDefault(p => p.Id == input.ID) ;
var project = _houseProjectInfoRep.FirstOrDefault(p => p.Id == input.Id) ;
await project.DeleteNowAsync();
}
@@ -60,10 +60,10 @@ namespace Ewide.Application.Service.HouseProjectInfo
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/houseProjectInfo/edit")]
public async Task UpdateProject(AddProjectInput input)
public async Task UpdateProject(UpdateProjectInput input)
{
var project = input.Adapt<BsHouseProjectInfo>();
await project.UpdateNowAsync();
await project.UpdateExcludeAsync(new[] { nameof(BsHouseProjectInfo.AreaId), nameof(BsHouseProjectInfo.AreaName)}, true);
}
/// <summary>
@@ -82,14 +82,14 @@ namespace Ewide.Application.Service.HouseProjectInfo
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/houseProjectInfo/page")]
public async Task<dynamic> QueryProjectPageList([FromQuery] HouseProjectInfoInput input)
[HttpPost("/houseProjectInfo/page")]
public async Task<dynamic> QueryProjectPageList([FromBody] HouseProjectInfoInput input)
{
var areaID = !string.IsNullOrEmpty(input.AreaID);
var areaID = !string.IsNullOrEmpty(input.AreaId);
var projects = await _houseProjectInfoRep.DetachedEntities
.Where(areaID, p => p.AreaId == input.AreaID)
.Select(p => p.Adapt<BsHouseProjectInfo>()).ToPagedListAsync(input.PageNo, input.PageSize);
return XnPageResult<BsHouseProjectInfo>.PageResult(projects);
.Where(areaID, p => p.AreaId == input.AreaId)
.Select(p => p.Adapt<HouseProjectOutput>()).ToPagedListAsync(input.PageNo, input.PageSize);
return XnPageResult<HouseProjectOutput>.PageResult(projects);
}
/// <summary>
@@ -100,7 +100,7 @@ namespace Ewide.Application.Service.HouseProjectInfo
[HttpGet("/houseProjectInfo/detail")]
public async Task<dynamic> GetProject([FromQuery] QueryProjectInput input)
{
var user = await _houseProjectInfoRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == input.ID);
var user = await _houseProjectInfoRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == input.Id);
var userDto = user.Adapt<UserOutput>();
return userDto;

View File

@@ -13,7 +13,7 @@ namespace Ewide.Application.Service.HouseProjectInfo
{
Task AddProject(AddProjectInput input);
Task DeleteProject(DeleteProjectInput input);
Task UpdateProject(AddProjectInput input);
Task UpdateProject(UpdateProjectInput input);
Task<BsHouseProjectInfo> GetProjectById([FromRoute] string id);
Task<dynamic> GetProject([FromQuery] QueryProjectInput input);
Task<dynamic> QueryProjectPageList([FromQuery] HouseProjectInfoInput input);

View File

@@ -1,3 +1,7 @@
export default {
getHouseProjectPage :['/houseProjectInfo/page','get'],
getHouseProjectPage: ['/houseProjectInfo/page', 'post'],
houseProejctAdd: ['/houseProjectInfo/add', 'post'],
houseProejctEdit: ['/houseProjectInfo/edit', 'post'],
houseProejctDelete: ['/houseProjectInfo/delete', 'post'],
houseProejctDetail:['/houseProjectInfo/detail','get']
}

View File

@@ -195,8 +195,8 @@ export default {
const { key } = data[i]
this.list.push({
key,
id: data[i][this.replaceFields.value],
title: data[i][this.replaceFields.title]
[this.replaceFields.value]: data[i][this.replaceFields.value],
[this.replaceFields.title]: data[i][this.replaceFields.title]
})
if (data[i][this.replaceFields.children]) {
this.generateList(data[i][this.replaceFields.children])

View File

@@ -0,0 +1,127 @@
<template>
<!--
普通编辑窗体
v 1.2
2021-04-30
Lufthafen
-->
<a-form-model :model="form" :rules="rules" class="yo-form" ref="form">
<a-spin :spinning="loading">
<a-icon slot="indicator" spin type="loading" />
<div class="yo-form-group">
<!-- 表单控件 -->
<a-form-model-item label="项目名称" prop="name">
<a-input placeholder="请输入项目名称" v-model="form.name" />
</a-form-model-item>
<a-form-model-item label="排序" prop="sort">
<a-input placeholder="请输入排序" v-model="form.sort"> </a-input>
</a-form-model-item>
<a-form-model-item label="备注" prop="note">
<a-textarea :rows="4" placeholder="请输入备注" v-model="form.note"></a-textarea>
</a-form-model-item>
<!-- ... -->
</div>
</a-spin>
</a-form-model>
</template>
<script>
/* 表单内容默认值 */
const defaultForm = {
/* ... */
areaId: '330266001001',
areaName: '测试社区',
type: 1,
};
export default {
data() {
return {
/** 表单数据 */
form: {},
/** 验证格式 */
rules: {
/* ... */
note: [{ required: true, message: '请输入备注' }],
},
/** 加载异步数据状态 */
loading: false,
/** 其他成员属性 */
/* ... */
};
},
methods: {
/**
* 必要的方法
* 在打开编辑页时允许填充数据
*/
onFillData(params) {
/** 将默认数据覆盖到form */
this.form = this.$_.cloneDeep({
...defaultForm,
...params.record,
/** 在此处添加其他默认数据转换 */
/* ... */
});
},
/**
* 必要方法
* 验证表单并获取表单数据
*/
onGetData() {
return new Promise((reslove, reject) => {
this.$refs.form.validate((valid) => {
if (valid) {
const record = this.$_.cloneDeep(this.form);
/** 验证通过后可以对数据进行转换得到想要提交的格式 */
/* ... */
reslove(record);
} else {
reject();
}
});
});
},
/**
* 必要的方法
* 在外部窗口进行保存时调用表单验证
*/
onValidate(callback) {
this.$refs.form.validate(callback);
},
/**
* 必要的方法
* 在外部窗口关闭或重置时对表单验证进行初始化
*/
onResetFields() {
setTimeout(() => {
this.$refs.form.resetFields();
/** 在这里可以初始化当前组件中其他属性 */
/* ... */
}, 300);
},
/**
* 必要方法
* 加载当前表单中所需要的异步数据
*/
async onInit(params) {
this.loading = true;
/** 可以在这里await获取一些异步数据 */
/* ... */
this.loading = false;
},
/** 当前组件的其他方法 */
/* ... */
},
};
</script>

View File

@@ -1,41 +1,146 @@
<template>
<yo-tree-layout :load-data="loadTreeData" @select="onSelect" default-expanded-keys ref="tree-layout">
<container></container>
<!--
普通树查询表格
v 1.2
2021-04-30
Lufthafen
-->
<yo-tree-layout :load-data="loadTreeData" @select="onSelect" default-expanded-keys ref="tree-layout" :replace-fields="{ value: 'code', title: 'name', children: 'children' }">
<container>
<a-card :bordered="false">
<yo-table :columns="columns" :load-data="loadData" @query="onQuery" @resetQuery="onResetQuery" ref="table">
<Auth auth="authCode:page" slot="query">
<!-- 此处添加查询表单控件 -->
<a-form-model-item label="项目名称">
<a-input placeholder="请输入项目名称" v-model="query.name" />
</a-form-model-item>
<!-- ... -->
</Auth>
<Auth auth="authCode:add" slot="operator">
<a-button @click="onOpen('add-form')" icon="plus">新增项目</a-button>
</Auth>
<!-- 格式化字段内容 -->
<span slot="houseType" slot-scope="text">{{ bindCodeValue(text, 'houseType') }}</span>
<!-- ... -->
<!-- 添加操作控件 -->
<span slot="action" slot-scope="text, record">
<yo-table-actions>
<Auth auth="authCode:edit">
<a @click="onOpen('edit-form', record)">编辑</a>
</Auth>
<Auth auth="authCode:delete">
<a-popconfirm @confirm="onDelete(record)" placement="topRight" title="是否确认删除">
<a>删除</a>
</a-popconfirm>
</Auth>
<!-- 可在此处添加其他操作控件 -->
<!-- ... -->
</yo-table-actions>
</span>
</yo-table>
</a-card>
</container>
<!-- 新增表单 -->
<yo-modal-form :action="$api[api.add]" :title="'新增' + name" @ok="onReloadData" ref="add-form">
<form-body />
</yo-modal-form>
<!-- 编辑表单 -->
<yo-modal-form :action="$api[api.edit]" :title="'编辑' + name" @ok="onReloadData" ref="edit-form">
<form-body />
</yo-modal-form>
</yo-tree-layout>
</template>
<script>
/* 需要引用YoTreeLayout组件 */
import YoTreeLayout from '@/components/yoTreeLayout';
import FormBody from './form';
/* 在此管理整个页面需要的接口名称 */
const api = {
tree: 'getAreaTree',
page: 'getHouseProjectPage',
add: 'houseProejctAdd',
edit: 'houseProejctEdit',
delete: 'houseProejctDelete',
/* ... */
};
export default {
components: {
YoTreeLayout,
FormBody,
},
data() {
return {
query: {},
api,
name: '项目',
/* 查询条件 */
query: { name: '' },
/* 表格字段 */
columns: [
{
title: '项目名称',
width: '400px',
dataIndex: 'name',
sorter: true,
},
{
title: '社区',
dataIndex: 'areaName',
sorter: true,
},
{
title: '类型',
dataIndex: 'type',
scopedSlots: { customRender: 'houseType' },
sorter: true,
},
],
/* 字典编码储存格式 */
codes: {
houseType: [],
},
};
},
created() {},
created() {
this.onLoadCodes();
/** 根据权限添加操作列 */
const flag = this.$auth(/* ... */);
if (flag) {
this.columns.push({
title: '操作',
width: '150px',
dataIndex: 'action',
scopedSlots: { customRender: 'action' },
});
}
},
methods: {
/**
* 树形选择界面必要的方法
* 传给yo-table-layout以示意数据接口
*/
loadTreeData() {
return this.$api.getAreaTree().then((res) => {
return this.$api[api.tree]().then((res) => {
return res.data;
});
},
/**
* 树形选择界面必要的方法
* 选择树节点事件
*/
onSelect([id]) {
/** 在选择事件中可以对右侧表格添加父节点id的查询条件 */
this.query = {
pid: id,
};
@@ -47,14 +152,12 @@ export default {
* 传给yo-table以示意数据接口及其参数和返回的数据结构
*/
loadData(params) {
return this.$api
.getHouseProjectPage({
...params,
...this.query,
})
.then((res) => {
return res.data;
});
return this.$api[api.page]({
...params,
...this.query,
}).then((res) => {
return res.data;
});
},
/**
@@ -65,7 +168,12 @@ export default {
this.$refs.table.onReloadData(true);
},
onReset() {
/**
* 必要方法
* 重新列表数据
*/
onResetQuery() {
/* 与普通查询页不同的是,这里的父节点参数不应该在重置后被清空 */
Object.keys(this.query).forEach((p) => {
if (p !== 'pid') {
this.query[p] = undefined;
@@ -83,25 +191,73 @@ export default {
this.$refs['tree-layout'].onReloadData();
},
/**
* 必要方法
* 加载字典数据
* 如果不需要获取相应的字典数据,此方法内容可空
*/
onLoadCodes() {
this.$api
.$queue([
this.$api.sysDictTypeDropDownAwait({ code: 'dic_house_type' }),
/* ... */
])
.then(([houseType]) => {
this.codes.houseType = houseType.data;
/* ... */
});
},
/**
* 必要方法
* 绑定数据字典值
*/
bindCodeValue(code, name) {
const c = this.codes[name].find((p) => p.code == code);
if (c) {
return c.value;
}
return null;
},
/**
* 有编辑新增功能的必要方法
* 从列表页调用窗口的打开方法
*/
// onOpen(formName, record) {
// this.$refs[formName].onOpen(record, this.query['pid']);
// },
onOpen(formName, record) {
this.$refs[formName].onOpen({
record,
pid: this.query.pid,
/* 按需添加其他参数 */
/* ... */
});
},
// onDelete(record) {
// this.$api.sysOrgDelete(record).then(({ success }) => {
// if (success) {
// this.$message.success('删除成功');
// this.onReloadData();
// if (this.query['pid'] == record.id) {
// delete this.query.pid;
// }
// }
// });
// },
/**
* 必要方法
* 可以用做一系列操作的公共回调,此方法中会重新加载当前列表
*/
onResult(success, successMessage) {
if (success) {
this.$message.success(successMessage);
this.onReloadData();
}
},
/**
* 必要方法
* 删除时调用
*/
onDelete(record) {
this.$refs.table.onLoading();
this.$api[api.delete](record)
.then(({ success }) => {
this.onResult(success, '删除成功');
})
.finally(() => {
this.$refs.table.onLoaded();
});
},
},
};
</script>
</script>