update 完成选房

This commit is contained in:
2021-05-30 20:28:09 +08:00
parent 0f44438d78
commit ccd914fb81
30 changed files with 650 additions and 43 deletions

View File

@@ -2,7 +2,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
namespace Ewide.Application.Entity namespace Ewide.Application
{ {
[Table("bs_house_code")] [Table("bs_house_code")]
[Comment("房屋编码表")] [Comment("房屋编码表")]

View File

@@ -7,7 +7,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Ewide.Application.Entity namespace Ewide.Application
{ {
[Table("bs_house_member_relation")] [Table("bs_house_member_relation")]
[Comment("房屋与人员关联表")] [Comment("房屋与人员关联表")]
@@ -21,6 +21,6 @@ namespace Ewide.Application.Entity
[Comment("bs_house_code主键Id")] [Comment("bs_house_code主键Id")]
[MaxLength(36)] [MaxLength(36)]
[Required] [Required]
public string CodeId { get; set; } public string HouseCodeId { get; set; }
} }
} }

View File

@@ -524,10 +524,45 @@
选房相关 选房相关
</summary> </summary>
</member> </member>
<member name="M:Ewide.Application.Service.HouseSelectorService.HouseSelectorList(Ewide.Application.QueryHouseSelectorInput)">
<summary>
获取人员允许绑定的房屋编码列表
</summary>
<param name="userId"></param>
<returns></returns>
</member>
<member name="M:Ewide.Application.Service.HouseSelectorService.HouseSelectedList(Ewide.Application.QueryHouseSelectorInput)">
<summary>
获取人员已经绑定的房屋编码列表
</summary>
<param name="userId"></param>
<returns></returns>
</member>
<member name="M:Ewide.Application.Service.HouseSelectorService.Select(Ewide.Application.HouseSelectInput)">
<summary>
从人员选择房屋
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="T:Ewide.Application.Service.HouseZoneService"> <member name="T:Ewide.Application.Service.HouseZoneService">
<summary> <summary>
片区相关 片区相关
</summary> </summary>
</member> </member>
<member name="M:Ewide.Application.Service.HouseZoneService.GetHouseZoneList(Ewide.Application.HouseZoneInput)">
<summary>
获取片区列表
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:Ewide.Application.Service.HouseZoneService.GetZoneByUser(System.String)">
<summary>
根据用户Id获取所在片区的Id
</summary>
<param name="userId"></param>
<returns></returns>
</member>
</members> </members>
</doc> </doc>

View File

@@ -6,7 +6,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Ewide.Application.Service.HouseCode.Dto namespace Ewide.Application
{ {
public class HouseCodeInput public class HouseCodeInput
{ {

View File

@@ -7,10 +7,18 @@ using System.Threading.Tasks;
namespace Ewide.Application namespace Ewide.Application
{ {
public class HouseSelectorInput public class HouseSelectInput
{ {
[Required(ErrorMessage = "区域编码不可为空")] [Required(ErrorMessage = "用户Id不能为空")]
[MinLength(9, ErrorMessage = "区域编码长度必须为9位及以上")] public string UserId { get; set; }
public string AreaCode { get; set; }
[Required(ErrorMessage = "房屋编码Id不能为空")]
public string[] Ids { get; set; }
}
public class QueryHouseSelectorInput : QueryHouseCodeInput
{
[Required(ErrorMessage = "用户Id不能为空")]
public string UserId { get; set; }
} }
} }

View File

@@ -1,5 +1,7 @@
using Ewide.Core; using Dapper;
using Ewide.Core.Extension;
using Furion.DatabaseAccessor; using Furion.DatabaseAccessor;
using Furion.DatabaseAccessor.Extensions;
using Furion.DependencyInjection; using Furion.DependencyInjection;
using Furion.DynamicApiController; using Furion.DynamicApiController;
using Furion.FriendlyException; using Furion.FriendlyException;
@@ -17,5 +19,153 @@ namespace Ewide.Application.Service
[ApiDescriptionSettings(Name = "HouseSelector", Order = 180)] [ApiDescriptionSettings(Name = "HouseSelector", Order = 180)]
public class HouseSelectorService : IHouseSelectorService, IDynamicApiController, ITransient public class HouseSelectorService : IHouseSelectorService, IDynamicApiController, ITransient
{ {
private readonly IDapperRepository _dapperRep;
private readonly IRepository<BsHouseMemberRelation> _bsHouseMemberRelationRep;
private readonly IRepository<BsHouseCode> _bsHouseCodeRep;
private readonly IHouseZoneService _houseZoneService;
public HouseSelectorService(
IDapperRepository dapperRep,
IRepository<BsHouseMemberRelation> bsHouseMemberRelationRep,
IRepository<BsHouseCode> bsHouseCodeRep,
IHouseZoneService houseZoneService
)
{
_dapperRep = dapperRep;
_bsHouseMemberRelationRep = bsHouseMemberRelationRep;
_bsHouseCodeRep = bsHouseCodeRep;
_houseZoneService = houseZoneService;
}
/// <summary>
/// 获取人员允许绑定的房屋编码列表
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
[HttpPost("/houseSelector/selectorPage")]
public async Task<dynamic> HouseSelectorList([FromBody] QueryHouseSelectorInput input)
{
var sql = @"SELECT
HC.*,AA.Name AreaName,RA.Name RoadName,CA.Name CommName,Proj.AreaCode,Proj.Note,CONCAT(Proj.`Name`,'(',Proj.Note,')') FullProjName
FROM bs_house_code HC
LEFT JOIN bs_house_projectinfo Proj ON Proj.Id=HC.ProjectId
LEFT JOIN sys_area_code CA ON CA.Code = Proj.AreaCode
LEFT JOIN sys_area_code RA ON RA.AdCode = SUBSTR(CA.AdCode,1,9)
LEFT JOIN sys_area_code AA ON AA.AdCode = SUBSTR(CA.AdCode,1,6)
LEFT JOIN bs_house_member_relation HM ON HC.Id = HM.HouseCodeId
INNER JOIN (SELECT * FROM sys_emp WHERE Id = @UserId) E ON HC.ZoneId = E.OrgId
WHERE 1=1
AND HM.Id IS NULL
AND HC.Address LIKE @Address
AND HC.HouseCode LIKE @HouseCode";
return await _dapperRep.QueryPageData(sql, input, param: new
{
input.UserId,
Address = "%" + input.Address + "%",
HouseCode = "%" + input.HouseCode + "%"
});
}
/// <summary>
/// 获取人员已经绑定的房屋编码列表
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
[HttpPost("/houseSelector/selectedPage")]
public async Task<dynamic> HouseSelectedList([FromBody] QueryHouseSelectorInput input)
{
var sql = @"SELECT
HC.*,AA.Name AreaName,RA.Name RoadName,CA.Name CommName,Proj.AreaCode,Proj.Note,CONCAT(Proj.`Name`,'(',Proj.Note,')') FullProjName
FROM bs_house_code HC
LEFT JOIN bs_house_projectinfo Proj ON Proj.Id=HC.ProjectId
LEFT JOIN sys_area_code CA ON CA.Code = Proj.AreaCode
LEFT JOIN sys_area_code RA ON RA.AdCode = SUBSTR(CA.AdCode,1,9)
LEFT JOIN sys_area_code AA ON AA.AdCode = SUBSTR(CA.AdCode,1,6)
INNER JOIN (SELECT * FROM bs_house_member_relation WHERE SysUserId = @UserId) HM ON HC.Id = HM.HouseCodeId
WHERE 1=1
AND HC.Address LIKE @Address
AND HC.HouseCode LIKE @HouseCode";
return await _dapperRep.QueryPageData(sql, input, param: new
{
input.UserId,
Address = "%" + input.Address + "%",
HouseCode = "%" + input.HouseCode + "%"
});
}
/// <summary>
/// 从人员选择房屋
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/houseSelector/select")]
[UnitOfWork]
public async Task Select([FromBody] HouseSelectInput input)
{
#region
var ids = input.Ids.Distinct().ToList();
if (ids.Count == 0) throw Oops.Oh("没有选中任何房屋");
// 验证当前用户是否安全员 **须补充
// 已经被选中的房屋,从ids中剔除
var houseSelected = await _bsHouseMemberRelationRep.DetachedEntities
.Where(p => ids.Contains(p.HouseCodeId))
.Select(p => p.HouseCodeId)
.ToListAsync();
if (houseSelected.Count > 0)
{
houseSelected.ForEach(p =>
{
var index = ids.IndexOf(p);
if (index > -1)
{
ids.RemoveAt(index);
}
});
}
if (ids.Count == 0) throw Oops.Oh("当前房屋在此之前已经全部被选中,请确认");
// 从用户所在片区中过滤房屋
var zoneId = await _houseZoneService.GetZoneByUser(input.UserId);
var house = await _bsHouseCodeRep.DetachedEntities.Where(p => ids.Contains(p.Id) && p.ZoneId == zoneId).Select(p => p.Id).ToListAsync();
if (house.Count == 0) throw Oops.Oh("选中的房屋错误");
#endregion
// 选定房屋
house.ForEach(p =>
{
new BsHouseMemberRelation
{
SysUserId = input.UserId,
HouseCodeId = p
}.Insert();
});
}
[HttpPost("/houseSelector/revoke")]
[UnitOfWork]
public async Task Revoke([FromBody] HouseSelectInput input)
{
var ids = input.Ids.Distinct().ToList();
if (ids.Count == 0) throw Oops.Oh("没有选中任何房屋");
var selected = await _bsHouseMemberRelationRep.Where(p => ids.Contains(p.HouseCodeId) && p.SysUserId == input.UserId).ToListAsync();
selected.ForEach(p =>
{
p.Delete();
});
}
public async Task SelectMember()
{
}
} }
} }

View File

@@ -9,5 +9,10 @@ namespace Ewide.Application.Service
{ {
public interface IHouseSelectorService public interface IHouseSelectorService
{ {
Task<dynamic> HouseSelectorList([FromQuery] QueryHouseSelectorInput input);
Task<dynamic> HouseSelectedList([FromQuery] QueryHouseSelectorInput input);
Task Select([FromBody] HouseSelectInput input);
Task Revoke([FromBody] HouseSelectInput input);
Task SelectMember();
} }
} }

View File

@@ -6,6 +6,7 @@ using Furion.FriendlyException;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -17,13 +18,28 @@ namespace Ewide.Application.Service
[ApiDescriptionSettings(Name = "HouseZone", Order = 180)] [ApiDescriptionSettings(Name = "HouseZone", Order = 180)]
public class HouseZoneService : IHouseZoneService, IDynamicApiController, ITransient public class HouseZoneService : IHouseZoneService, IDynamicApiController, ITransient
{ {
private readonly IRepository<SysOrg> _sysOrgRep;
private readonly IRepository<SysEmp> _sysEmpRep;
public HouseZoneService(
IRepository<SysOrg> sysOrgRep,
IRepository<SysEmp> sysEmpRep
)
{
_sysOrgRep = sysOrgRep;
_sysEmpRep = sysEmpRep;
}
/// <summary>
/// 获取片区列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/houseZone/list")] [HttpGet("/houseZone/list")]
public async Task<dynamic> GetHouseZoneList([FromQuery] HouseZoneInput input) public async Task<dynamic> GetHouseZoneList([FromQuery] HouseZoneInput input)
{ {
var areaCode = input.AreaCode.Substring(0, 9); var areaCode = input.AreaCode.Substring(0, 9);
var _sysOrgRep = Db.GetRepository<SysOrg>();
var road = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(p => p.AreaCode == areaCode); var road = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(p => p.AreaCode == areaCode);
if (road == null) throw Oops.Oh("街道编码错误"); if (road == null) throw Oops.Oh("未在组织机构中配置街道");
return await _sysOrgRep.DetachedEntities return await _sysOrgRep.DetachedEntities
.Where(p => p.Pid == road.Id) .Where(p => p.Pid == road.Id)
.Where(p => p.Type == (int)OrgType.) .Where(p => p.Type == (int)OrgType.)
@@ -35,5 +51,20 @@ namespace Ewide.Application.Service
}) })
.ToListAsync(); .ToListAsync();
} }
/// <summary>
/// 根据用户Id获取所在片区的Id
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
[HttpGet("houseZone/getByUser")]
public async Task<string> GetZoneByUser([FromQuery][Required(ErrorMessage = "用户Id不能为空")] string userId)
{
var data = await _sysEmpRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == userId);
if(data == null) throw Oops.Oh("用户不在组织机构中");
var org = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == data.OrgId && p.Type == (int)OrgType.);
if(org == null) throw Oops.Oh("用户不在片区中");
return org.Id;
}
} }
} }

View File

@@ -10,5 +10,6 @@ namespace Ewide.Application.Service
public interface IHouseZoneService public interface IHouseZoneService
{ {
Task<dynamic> GetHouseZoneList([FromQuery] HouseZoneInput input); Task<dynamic> GetHouseZoneList([FromQuery] HouseZoneInput input);
Task<string> GetZoneByUser([FromQuery] string userId);
} }
} }

View File

@@ -33,11 +33,13 @@ namespace Ewide.Core
/// </summary> /// </summary>
[Description("自定义数据")] [Description("自定义数据")]
DEFINE = 5, DEFINE = 5,
/// <summary> /// <summary>
/// 本部门所在区域及以下区域 /// 本部门所在区域及以下区域
/// </summary> /// </summary>
[Description("本部门所在区域及以下区域")] [Description("本部门所在区域及以下区域")]
AREA_WITH_CHILD = 6, AREA_WITH_CHILD = 6,
/// <summary> /// <summary>
/// 本部门所在区域数据 不包括下面区域 /// 本部门所在区域数据 不包括下面区域
/// </summary> /// </summary>

View File

@@ -9,6 +9,7 @@ namespace Ewide.Core.Service
Task AddOrg(AddOrgInput input); Task AddOrg(AddOrgInput input);
Task DeleteOrg(DeleteOrgInput input); Task DeleteOrg(DeleteOrgInput input);
Task<List<string>> GetDataScopeListByDataScopeType(int dataScopeType, string orgId); Task<List<string>> GetDataScopeListByDataScopeType(int dataScopeType, string orgId);
List<string> GetDataScopeList(List<string> dataScopes);
Task<SysOrg> GetOrg([FromQuery] QueryOrgInput input); Task<SysOrg> GetOrg([FromQuery] QueryOrgInput input);
Task<List<OrgOutput>> GetOrgList([FromQuery] OrgInput input); Task<List<OrgOutput>> GetOrgList([FromQuery] OrgInput input);
Task<dynamic> GetOrgTree([FromQuery] OrgInput input); Task<dynamic> GetOrgTree([FromQuery] OrgInput input);

View File

@@ -74,7 +74,7 @@ namespace Ewide.Core.Service
/// </summary> /// </summary>
/// <param name="dataScopes"></param> /// <param name="dataScopes"></param>
/// <returns></returns> /// <returns></returns>
private List<string> GetDataScopeList(List<string> dataScopes) public List<string> GetDataScopeList(List<string> dataScopes)
{ {
var dataScopeList = new List<string>(); var dataScopeList = new List<string>();
// 如果是超级管理员则获取所有组织机构,否则只获取其数据范围的机构数据 // 如果是超级管理员则获取所有组织机构,否则只获取其数据范围的机构数据

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Ewide.Core.Service.Role namespace Ewide.Core.Service
{ {
public interface ISysRoleAreaService public interface ISysRoleAreaService
{ {

View File

@@ -36,6 +36,7 @@
@import './lib/authority-view.less'; @import './lib/authority-view.less';
@import './lib/icon-selector.less'; @import './lib/icon-selector.less';
@import './lib/anchor.less'; @import './lib/anchor.less';
@import './lib/disabled.less';
@import './theme/primary.less'; @import './theme/primary.less';
// @import './lib/font-weight.less'; // @import './lib/font-weight.less';
@import './public.less'; @import './public.less';

View File

@@ -0,0 +1,36 @@
@import (reference) '~@/assets/style/extend.less';
.ant-btn-primary-disabled,
.ant-btn-primary.disabled,
.ant-btn-primary[disabled],
.ant-btn-primary-disabled:hover,
.ant-btn-primary.disabled:hover,
.ant-btn-primary[disabled]:hover,
.ant-btn-primary-disabled:focus,
.ant-btn-primary.disabled:focus,
.ant-btn-primary[disabled]:focus,
.ant-btn-primary-disabled:active,
.ant-btn-primary.disabled:active,
.ant-btn-primary[disabled]:active,
.ant-btn-primary-disabled.active,
.ant-btn-primary.disabled.active,
.ant-btn-primary[disabled].active {
opacity: .5;
color: @btn-primary-color;
border-color: @btn-primary-bg;
background-color: @btn-primary-bg;
box-shadow: @btn-primary-shadow;
text-shadow: @btn-text-shadow;
}
.ant-radio-button-wrapper-disabled:first-child,
.ant-radio-button-wrapper-disabled:hover {
opacity: .5;
color: @radio-button-color;
background-color: @radio-button-bg;
}
.ant-radio-button-wrapper-disabled.ant-radio-button-wrapper-checked {
opacity: .5;
color: @btn-primary-color;
border-color: @btn-primary-bg;
background-color: @btn-primary-bg;
box-shadow: @btn-primary-shadow;
}

View File

@@ -2,9 +2,17 @@
.ant-radio-button-wrapper { .ant-radio-button-wrapper {
margin-right: @padding-xs; margin-right: @padding-xs;
margin-bottom: @padding-xs; margin-bottom: @padding-xs;
border-left: @border-width-base @border-style-base @normal-color;
&:not(:first-child) { &:not(:first-child) {
&::before { &::before {
left: 0; content: none;
} }
} }
} }
.ant-radio-button-wrapper-checked {
&:not(.ant-radio-button-wrapper-disabled),
&:not(.ant-radio-button-wrapper-disabled):hover {
box-shadow: none;
}
}

View File

@@ -391,7 +391,6 @@
padding: 0 @padding-md 0 @padding-lg; padding: 0 @padding-md 0 @padding-lg;
color: @logo-color; color: @logo-color;
background-color: @nav-background;
box-shadow: @logo-box-shadow; box-shadow: @logo-box-shadow;
img { img {
max-height: 100%; max-height: 100%;

View File

@@ -0,0 +1,6 @@
export default {
houseSelect: ['/houseSelector/select', 'post'],
houseSelectRevoke: ['/houseSelector/revoke', 'post'],
houseSelectorPage: ['/houseSelector/selectorPage', 'post'],
houseSelectedPage: ['/houseSelector/selectedPage', 'post'],
}

View File

@@ -0,0 +1,13 @@
import houseProjectInfo from './houseProjectInfo'
import houseZone from './houseZone'
import houseCode from './houseCode'
import houseMember from './houseMember'
import houseSelector from './houseSelector'
export default {
...houseProjectInfo,
...houseZone,
...houseCode,
...houseMember,
...houseSelector
}

View File

@@ -1,11 +1,5 @@
import houseProjectInfo from './houseProjectInfo' import houseSafety from './houseSafety'
import houseZone from './houseZone'
import houseCode from './houseCode'
import houseMember from './houseMember'
export default { export default {
...houseProjectInfo, ...houseSafety,
...houseZone,
...houseCode,
...houseMember
} }

View File

@@ -502,9 +502,12 @@ export default {
} }
this.loading = true; this.loading = true;
await this.getProjects(autoChange); try {
await this.getZones(autoChange); await this.getProjects(autoChange);
this.loading = false; await this.getZones(autoChange);
} finally {
this.loading = false;
}
}, },
async getProjects(autoChange = false) { async getProjects(autoChange = false) {

View File

@@ -30,7 +30,7 @@
<a-button <a-button
@click="openContentWindow({ @click="openContentWindow({
title: '房屋表单', title: '房屋表单',
path: 'business/house/houseInfo/form', path: 'business/house/info/form',
});" });"
>(test)打开表单</a-button> >(test)打开表单</a-button>
</div> </div>

View File

@@ -78,7 +78,7 @@
<div slot="avatar"> <div slot="avatar">
<yo-image :id="record.avatar" :size="48" icon="user" shape="square" type="avatar" /> <yo-image :id="record.avatar" :size="48" icon="user" shape="square" type="avatar" />
<a-button <a-button
@click="$refs['selector-modal'].onOpen()" @click="onOpenSelector(record)"
class="block w-100-p mt-xxs" class="block w-100-p mt-xxs"
size="small" size="small"
type="primary" type="primary"
@@ -344,6 +344,10 @@ export default {
record.statusChanging = false; record.statusChanging = false;
}); });
}, },
onOpenSelector(record) {
this.$refs['selector-modal'].onOpen({ userId: record.id });
},
}, },
}; };
</script> </script>

View File

@@ -9,10 +9,10 @@
> >
<a-tabs :animated="false" :tab-bar-style="{ marginBottom: 0 }" default-active-key="1"> <a-tabs :animated="false" :tab-bar-style="{ marginBottom: 0 }" default-active-key="1">
<a-tab-pane key="1" tab="选房"> <a-tab-pane key="1" tab="选房">
<selector-list /> <selector-list :user-id="userId" @reload-all="onReloadAll" ref="selector-list" />
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="2" tab="已选"> <a-tab-pane key="2" tab="已选">
<selected-list /> <selected-list :user-id="userId" @reload-all="onReloadAll" ref="selected-list" />
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
</a-modal> </a-modal>
@@ -34,12 +34,14 @@ export default {
/** 其他成员属性 */ /** 其他成员属性 */
/* ... */ /* ... */
userId: '',
}; };
}, },
methods: { methods: {
onOpen(param) { onOpen(param) {
this.visible = true; this.visible = true;
this.userId = param.userId;
}, },
/** /**
@@ -55,6 +57,14 @@ export default {
/** 当前组件的其他方法 */ /** 当前组件的其他方法 */
/* ... */ /* ... */
onReloadAll() {
if (this.$refs['selector-list']) {
this.$refs['selector-list'].onReloadData();
}
if (this.$refs['selected-list']) {
this.$refs['selected-list'].onReloadData();
}
},
}, },
}; };
</script> </script>

View File

@@ -1,3 +1,285 @@
<template> <template>
<div></div> <!--
</template> 普通查询表格
v 1.2
2021-04-30
Lufthafen
-->
<a-card :bordered="false" class="mb-none">
<yo-table
:auto-load="false"
:columns="columns"
:load-data="loadData"
:row-selection="{ selectedRowKeys: selectedRowKeys, onChange: (keys) => selectedRowKeys = keys }"
@query="onQuery"
@resetQuery="onResetQuery"
ref="table"
>
<Auth auth="houseSelector:selectedPage" slot="query">
<!-- 此处添加查询表单控件 -->
<!-- ... -->
<a-form-model-item label="编号">
<a-input-number
:formatter="(number) => number && `000${number}`.slice(-3)"
:max="999"
:min="1"
:precision="0"
:step="1"
placeholder="请输入房屋序号"
v-model="query.no"
/>
</a-form-model-item>
<a-form-model-item label="房屋性质">
<a-radio-group @change="onChangeQueryType" button-style="solid" v-model="query.type">
<a-radio-button :value="0">全部</a-radio-button>
<a-radio-button
:key="item.code"
:value="+item.code"
v-for="item in codes.type"
>{{item.value}}</a-radio-button>
</a-radio-group>
</a-form-model-item>
<a-form-model-item label="行业" v-if="query.type == 2">
<a-select class="w-150" placeholder="请选择行业" v-model="query.industry">
<a-select-option
:key="item.code"
:value="+item.code"
v-for="item in codes.industry"
>{{item.value}}</a-select-option>
</a-select>
</a-form-model-item>
<a-form-model-item label="地址">
<a-input placeholder="请输入地址" v-model="query.address" />
</a-form-model-item>
<a-form-model-item label="房屋唯一编码">
<a-input placeholder="请输入房屋唯一编码" v-model="query.houseCode" />
</a-form-model-item>
</Auth>
<Auth auth="houseSelector:revoke" slot="operator">
<a-popconfirm
:disabled="!selectedRowKeys.length"
@confirm="onHouseSelectRevoke"
placement="bottomLeft"
title="是否确认撤销"
>
<a-button :disabled="!selectedRowKeys.length" :loading="saving" type="danger">撤销</a-button>
</a-popconfirm>
</Auth>
<!-- 格式化字段内容 -->
<!-- ... -->
<template slot="houseCode" slot-scope="text, record">
<span>{{`${record.areaName}-${record.roadName}-${record.commName}-${record.note}-${`000${record.no}`.slice(-3)}`}}</span>
</template>
<template slot="type" slot-scope="text, record">
<span>{{bindCodeValue(text, 'type') + (text === 2 ? `(${bindCodeValue(record.industry, 'industry')})` : '')}}</span>
</template>
</yo-table>
</a-card>
</template>
<script>
/* 在此管理整个页面需要的接口名称 */
const api = {
page: 'houseSelectedPage',
/* ... */
};
export default {
props: ['userId'],
data() {
return {
api,
/* 查询条件 */
query: {
type: 0,
},
/* 表格字段 */
columns: [
{
title: '房屋编码',
dataIndex: 'houseCode',
sorter: true,
scopedSlots: { customRender: 'houseCode' },
width: 300,
},
{
title: '房屋性质及行业',
dataIndex: 'type',
sorter: true,
scopedSlots: { customRender: 'type' },
width: 150,
},
{
title: '地址',
dataIndex: 'address',
sorter: true,
},
{
title: '登记时间',
dataIndex: 'createdTime',
sorter: true,
width: 150,
},
],
/* 字典编码储存格式 */
codes: {
type: [],
industry: [],
},
options: {},
selectedRowKeys: [],
saving: false,
};
},
async created() {
/** 按需加载字典编码 */
await this.onLoadCodes();
this.onQuery();
},
methods: {
/**
* 必要的方法
* 传给yo-table以示意数据接口及其参数和返回的数据结构
*/
loadData(params) {
const query = this.$_.cloneDeep(this.query);
if (!query.userId) {
query.userId = this.userId;
}
return this.$api[api.page]({
...params,
...query,
}).then((res) => {
return res.data;
});
},
/**
* 有查询功能时的必要方法
* 加载数据时初始化分页信息
*/
onQuery() {
this.$refs.table.onReloadData(true);
},
/**
* 有查询功能时的必要方法
* 重置查询条件
*/
onResetQuery() {
/** 在这里重置查询条件时,可对特殊的字段做保留处理 */
this.query = {
type: 0,
};
this.onQuery();
},
/**
* 必要方法
* 重新列表数据
*/
onReloadData() {
this.$refs.table.onReloadData();
},
/**
* 必要方法
* 加载字典数据
* 如果不需要获取相应的字典数据,此方法内容可空
*/
onLoadCodes() {
return this.$api
.sysDictTypeDropDowns({ code: ['dic_house_type', 'dic_house_industry'] })
.then(({ data: { dic_house_type, dic_house_industry } }) => {
this.codes.type = dic_house_type;
this.codes.industry = dic_house_industry;
});
},
/**
* 必要方法
* 绑定数据字典值
*/
bindCodeValue(code, name) {
const c = this.codes[name].find((p) => p.code == code);
if (c) {
return c.value;
}
return null;
},
/**
* 必要方法
* 从列表页调用窗口的打开方法
*/
onOpen(record) {
this.openContentWindow({
key: record ? record.id : 'business/house/code/form',
title: record ? '修改房屋编码' : '新增房屋编码',
subTitle:
record &&
`${record.areaName}-${record.roadName}-${record.commName}-${record.note}-${`000${record.no}`.slice(-3)}`,
path: 'business/house/code/form',
param: {
record,
},
});
},
/**
* 必要方法
* 可以用做一系列操作的公共回调,此方法中会重新加载当前列表
*/
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();
});
},
onChangeQueryType() {
if (this.query.type < 2 && this.query.hasOwnProperty('industry')) {
this.$delete(this.query, 'industry');
}
},
onHouseSelectRevoke() {
this.saving = true;
this.$refs.table.onLoading();
this.$api
.houseSelectRevoke({ ids: this.selectedRowKeys, userId: this.userId })
.then(({ success }) => {
this.$message.success('选房成功');
})
.finally(() => {
this.saving = false;
this.selectedRowKeys = [];
this.$emit('reload-all');
});
},
},
};
</script>

View File

@@ -10,12 +10,12 @@
:auto-load="false" :auto-load="false"
:columns="columns" :columns="columns"
:load-data="loadData" :load-data="loadData"
:row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: (keys) => selectedRowKeys = keys }"
@query="onQuery" @query="onQuery"
@resetQuery="onResetQuery" @resetQuery="onResetQuery"
ref="table" ref="table"
> >
<Auth auth="houseCode:page" slot="query"> <Auth auth="houseSelector:selectorPage" slot="query">
<!-- 此处添加查询表单控件 --> <!-- 此处添加查询表单控件 -->
<!-- ... --> <!-- ... -->
<a-form-model-item label="编号"> <a-form-model-item label="编号">
@@ -55,8 +55,13 @@
<a-input placeholder="请输入房屋唯一编码" v-model="query.houseCode" /> <a-input placeholder="请输入房屋唯一编码" v-model="query.houseCode" />
</a-form-model-item> </a-form-model-item>
</Auth> </Auth>
<Auth auth="houseCode:add" slot="operator"> <Auth auth="houseSelector:select" slot="operator">
<a-button type="primary">确认选择</a-button> <a-button
:disabled="!selectedRowKeys.length"
:loading="saving"
@click="onHouseSelect"
type="primary"
>确认选择</a-button>
</Auth> </Auth>
<!-- 格式化字段内容 --> <!-- 格式化字段内容 -->
<!-- ... --> <!-- ... -->
@@ -72,17 +77,17 @@
<script> <script>
/* 在此管理整个页面需要的接口名称 */ /* 在此管理整个页面需要的接口名称 */
const api = { const api = {
page: 'houseCodePage', page: 'houseSelectorPage',
/* ... */ /* ... */
}; };
export default { export default {
props: ['userId'],
data() { data() {
return { return {
api, api,
name: '',
/* 查询条件 */ /* 查询条件 */
query: { query: {
type: 0, type: 0,
@@ -126,6 +131,8 @@ export default {
options: {}, options: {},
selectedRowKeys: [], selectedRowKeys: [],
saving: false,
}; };
}, },
@@ -141,8 +148,8 @@ export default {
*/ */
loadData(params) { loadData(params) {
const query = this.$_.cloneDeep(this.query); const query = this.$_.cloneDeep(this.query);
if (query.areaCode) { if (!query.userId) {
query.areaCode = query.areaCode[query.areaCode.length - 1]; query.userId = this.userId;
} }
return this.$api[api.page]({ return this.$api[api.page]({
@@ -257,8 +264,19 @@ export default {
} }
}, },
onSelectChange(selectedRowKeys) { onHouseSelect() {
this.selectedRowKeys = selectedRowKeys; this.saving = true;
this.$refs.table.onLoading();
this.$api
.houseSelect({ ids: this.selectedRowKeys, userId: this.userId })
.then(({ success }) => {
this.$message.success('选房成功');
})
.finally(() => {
this.saving = false;
this.selectedRowKeys = [];
this.$emit('reload-all');
});
}, },
}, },
}; };