Browse Source

完成 楼栋业主信息, 前后端

weiximei 6 years ago
parent
commit
3ec5275fb5
18 changed files with 693 additions and 133 deletions
  1. 7
    0
      CODE/smart-community/app-api/src/main/java/com/community/huiju/dao/TpBuildingOwnerInfoMapper.java
  2. 12
    5
      CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/TaUserServiceImpl.java
  3. 3
    0
      CODE/smart-community/community-common/src/main/java/com/community/commom/constant/Constant.java
  4. 14
    7
      CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/BuildingOwnerInfoController.java
  5. 29
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/dao/TaSysUserRoleMapper.java
  6. 47
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/model/TaSysUserRole.java
  7. 2
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/model/TaUser.java
  8. 3
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/model/TpBuildingOwnerInfo.java
  9. 16
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/service/ITaSysUserRoleService.java
  10. 190
    13
      CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/BuildingOwnerInfoServiceImpl.java
  11. 20
    0
      CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/TaSysUserRoleServiceImpl.java
  12. 5
    0
      CODE/smart-community/property-api/src/main/resources/mapper/TaSysUserRoleMapper.xml
  13. 51
    1
      VUECODE/smart-property-manage/src/api/buildingOwnerInfo.js
  14. 14
    0
      VUECODE/smart-property-manage/src/router/index.js
  15. 37
    1
      VUECODE/smart-property-manage/src/store/modules/buildingOwnerInfo.js
  16. 66
    41
      VUECODE/smart-property-manage/src/views/building/add/index.vue
  17. 93
    42
      VUECODE/smart-property-manage/src/views/building/edi/index.vue
  18. 84
    23
      VUECODE/smart-property-manage/src/views/building/index.vue

+ 7
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/dao/TpBuildingOwnerInfoMapper.java View File

2
 
2
 
3
 import com.community.huiju.model.TpBuildingOwnerInfo;
3
 import com.community.huiju.model.TpBuildingOwnerInfo;
4
 import org.apache.ibatis.annotations.Mapper;
4
 import org.apache.ibatis.annotations.Mapper;
5
+import org.apache.ibatis.annotations.Param;
6
+import org.apache.ibatis.annotations.Select;
7
+
8
+import java.util.List;
5
 
9
 
6
 @Mapper
10
 @Mapper
7
 public interface TpBuildingOwnerInfoMapper {
11
 public interface TpBuildingOwnerInfoMapper {
16
     int updateByPrimaryKeySelective(TpBuildingOwnerInfo record);
20
     int updateByPrimaryKeySelective(TpBuildingOwnerInfo record);
17
 
21
 
18
     int updateByPrimaryKey(TpBuildingOwnerInfo record);
22
     int updateByPrimaryKey(TpBuildingOwnerInfo record);
23
+
24
+    @Select("select * from tp_building_owner_info where community_id=#{communityId} and owner_tel=#{ownerTel}")
25
+    List<TpBuildingOwnerInfo> getByCommunityIdAndOwnerTel(@Param("communityId") Integer communityId, @Param("ownerTel") String ownerTel);
19
 }
26
 }

+ 12
- 5
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/TaUserServiceImpl.java View File

17
 import com.google.common.collect.Maps;
17
 import com.google.common.collect.Maps;
18
 import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
18
 import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
19
 import lombok.extern.slf4j.Slf4j;
19
 import lombok.extern.slf4j.Slf4j;
20
+import org.apache.commons.collections.CollectionUtils;
20
 import org.apache.commons.lang.StringUtils;
21
 import org.apache.commons.lang.StringUtils;
21
 import org.checkerframework.checker.units.qual.A;
22
 import org.checkerframework.checker.units.qual.A;
22
 import org.springframework.beans.BeanUtils;
23
 import org.springframework.beans.BeanUtils;
29
 import java.time.LocalDate;
30
 import java.time.LocalDate;
30
 import java.time.LocalDateTime;
31
 import java.time.LocalDateTime;
31
 import java.time.format.DateTimeFormatter;
32
 import java.time.format.DateTimeFormatter;
32
-import java.util.Date;
33
-import java.util.HashMap;
34
-import java.util.List;
35
-import java.util.Map;
33
+import java.util.*;
36
 import java.util.logging.SimpleFormatter;
34
 import java.util.logging.SimpleFormatter;
37
 
35
 
38
 /**
36
 /**
187
         user.setAcceptAgreementStatus("1");
185
         user.setAcceptAgreementStatus("1");
188
         user.setUserName(user.getLoginName());
186
         user.setUserName(user.getLoginName());
189
         user.setRemark("这是系统自动注册!");
187
         user.setRemark("这是系统自动注册!");
190
-        user.setVerifyStatus("1");
188
+        user.setVerifyStatus("0");
191
         user.setFaceStatus("0");
189
         user.setFaceStatus("0");
192
         //user.setLoginPassword(MD5Utils.encode(user.getLoginPassword()));
190
         //user.setLoginPassword(MD5Utils.encode(user.getLoginPassword()));
193
         taUserMapper.insertSelective(user);
191
         taUserMapper.insertSelective(user);
195
         user.setCreateUser(user.getId());
193
         user.setCreateUser(user.getId());
196
         user.setUpdateUser(user.getId());
194
         user.setUpdateUser(user.getId());
197
 
195
 
196
+        // 查询资料库
197
+        List<TpBuildingOwnerInfo> buildingOwnerInfoList = tpBuildingOwnerInfoMapper.getByCommunityIdAndOwnerTel(user.getCommunityId(), user.getLoginName());
198
+        if (CollectionUtils.isNotEmpty(buildingOwnerInfoList)) {
199
+            TpBuildingOwnerInfo buildingOwnerInfo = buildingOwnerInfoList.get(0);
200
+            user.setBuildingOwnerInfoId(buildingOwnerInfo.getId());
201
+            user.setVerifyStatus("1");
202
+        }
203
+
198
         // 更新
204
         // 更新
199
         taUserMapper.updateByPrimaryKeySelective(user);
205
         taUserMapper.updateByPrimaryKeySelective(user);
200
 
206
 
201
         // TODO 这里先默认 type=1 (业主), 后期需要和 资料库对接
207
         // TODO 这里先默认 type=1 (业主), 后期需要和 资料库对接
208
+        // TODO 资料库已经对接, 新注册的默认为 业主, 后期需要改为只有匹配了资料库后才是业主
202
         addOrUpdateUserRole(1,response,user,true);
209
         addOrUpdateUserRole(1,response,user,true);
203
 
210
 
204
 
211
 

+ 3
- 0
CODE/smart-community/community-common/src/main/java/com/community/commom/constant/Constant.java View File

81
 
81
 
82
     /**业主角色**/
82
     /**业主角色**/
83
     public static final String OWNER = "OWNER";
83
     public static final String OWNER = "OWNER";
84
+    public static final Integer OWNER_ID = 1;
84
 
85
 
85
     /**租客角色**/
86
     /**租客角色**/
86
     public static final String TENANT = "TENANT";
87
     public static final String TENANT = "TENANT";
88
+    public static final Integer TENANT_ID = 2;
87
 
89
 
88
     /**家属角色**/
90
     /**家属角色**/
89
     public static final String RELATION = "RELATION";
91
     public static final String RELATION = "RELATION";
92
+    public static final Integer RELATION_ID = 3;
90
     
93
     
91
     /** 工单回复的发起人 **/
94
     /** 工单回复的发起人 **/
92
     public static final String TICKET_USER_TYPE = "1";
95
     public static final String TICKET_USER_TYPE = "1";

+ 14
- 7
CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/BuildingOwnerInfoController.java View File

12
 import io.swagger.annotations.ApiOperation;
12
 import io.swagger.annotations.ApiOperation;
13
 import org.springframework.beans.factory.annotation.Autowired;
13
 import org.springframework.beans.factory.annotation.Autowired;
14
 import org.springframework.cloud.context.config.annotation.RefreshScope;
14
 import org.springframework.cloud.context.config.annotation.RefreshScope;
15
-import org.springframework.web.bind.annotation.PostMapping;
16
-import org.springframework.web.bind.annotation.RequestBody;
17
-import org.springframework.web.bind.annotation.RequestMapping;
18
-import org.springframework.web.bind.annotation.RequestMethod;
19
-import org.springframework.web.bind.annotation.RequestParam;
20
-import org.springframework.web.bind.annotation.RestController;
15
+import org.springframework.web.bind.annotation.*;
21
 import org.springframework.web.multipart.MultipartFile;
16
 import org.springframework.web.multipart.MultipartFile;
22
 
17
 
23
 import javax.servlet.http.HttpSession;
18
 import javax.servlet.http.HttpSession;
55
         return responseBean;
50
         return responseBean;
56
     }
51
     }
57
 
52
 
53
+    @ApiOperation(value = "获取楼栋业主信息详情", notes = "获取楼栋业主信息详情")
54
+    @ApiImplicitParams({
55
+            @ApiImplicitParam(paramType = "query", dataTypeClass = Integer.class, name = "id",value = "楼栋业主信息Id")
56
+    })
57
+    @RequestMapping(value = "/building/{id}", method = RequestMethod.GET)
58
+    public ResponseBean getById(@PathVariable(value = "id") Integer id) {
59
+        ResponseBean responseBean = new ResponseBean();
60
+        responseBean.addSuccess(iBuildingOwnerInfoService.getById(id));
61
+        return responseBean;
62
+
63
+    }
64
+
58
     @ApiOperation(value = "修改楼栋业务信息", notes = "修改楼栋业主信息")
65
     @ApiOperation(value = "修改楼栋业务信息", notes = "修改楼栋业主信息")
59
     @ApiImplicitParams({
66
     @ApiImplicitParams({
60
             @ApiImplicitParam(paramType = "body", dataTypeClass = String.class, name = "parameter",value = "id编号;building栋;" +
67
             @ApiImplicitParam(paramType = "body", dataTypeClass = String.class, name = "parameter",value = "id编号;building栋;" +
73
 
80
 
74
     @ApiOperation(value = "添加楼栋业务信息", notes = "添加楼栋业务信息")
81
     @ApiOperation(value = "添加楼栋业务信息", notes = "添加楼栋业务信息")
75
     @ApiImplicitParams({
82
     @ApiImplicitParams({
76
-            @ApiImplicitParam(paramType = "body", dataTypeClass = String.class, name = "parameter", value = "id编号;building栋;" +
83
+            @ApiImplicitParam(paramType = "body", dataTypeClass = String.class, name = "parameter", value = "building栋;" +
77
                     "unit单元;level楼层;roomNo户号;" +
84
                     "unit单元;level楼层;roomNo户号;" +
78
                     "ownerName业主姓名;" +
85
                     "ownerName业主姓名;" +
79
                     "ownerTel业主手机号"),
86
                     "ownerTel业主手机号"),

+ 29
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/dao/TaSysUserRoleMapper.java View File

1
+package com.community.huiju.dao;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.community.huiju.model.TaSysUserRole;
5
+import org.apache.ibatis.annotations.Delete;
6
+import org.apache.ibatis.annotations.Mapper;
7
+import org.apache.ibatis.annotations.Param;
8
+
9
+/**
10
+ * <p>
11
+ * app端用户是那些角色 Mapper 接口
12
+ * </p>
13
+ *
14
+ * @author weiximei
15
+ * @since 2018-12-21
16
+ */
17
+@Mapper
18
+public interface TaSysUserRoleMapper extends BaseMapper<TaSysUserRole> {
19
+
20
+    /**
21
+     * 根据 用户id 和 小区Id  删除数据
22
+     * @param communityId
23
+     * @param userId
24
+     * @return
25
+     */
26
+    @Delete("delete from ta_sys_user_role where community_id=#{communityId} and user_id=#{userId}")
27
+    int deleteByCommunityIdAndUserId(@Param("communityId") Integer communityId, @Param("userId") Integer userId);
28
+
29
+}

+ 47
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/model/TaSysUserRole.java View File

1
+package com.community.huiju.model;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import com.baomidou.mybatisplus.annotation.TableName;
6
+import lombok.Data;
7
+import lombok.EqualsAndHashCode;
8
+import lombok.experimental.Accessors;
9
+
10
+import java.io.Serializable;
11
+
12
+/**
13
+ * <p>
14
+ * app端用户是那些角色
15
+ * </p>
16
+ *
17
+ * @author weiximei
18
+ * @since 2018-12-21
19
+ */
20
+@Data
21
+@EqualsAndHashCode(callSuper = false)
22
+@Accessors(chain = true)
23
+@TableName("ta_sys_user_role")
24
+public class TaSysUserRole implements Serializable {
25
+
26
+    private static final long serialVersionUID = 1L;
27
+
28
+    @TableId(value = "id", type = IdType.AUTO)
29
+    private Integer id;
30
+
31
+    /**
32
+     * 小区id
33
+     */
34
+    private Integer communityId;
35
+
36
+    /**
37
+     * 用户ID
38
+     */
39
+    private Integer userId;
40
+
41
+    /**
42
+     * 角色ID
43
+     */
44
+    private Integer roleId;
45
+
46
+
47
+}

+ 2
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/model/TaUser.java View File

23
 
23
 
24
     private static final long serialVersionUID = 1L;
24
     private static final long serialVersionUID = 1L;
25
 
25
 
26
+    private Integer id;
27
+
26
     /**
28
     /**
27
      * 小区id
29
      * 小区id
28
      */
30
      */

+ 3
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/model/TpBuildingOwnerInfo.java View File

1
 package com.community.huiju.model;
1
 package com.community.huiju.model;
2
 
2
 
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
3
 import com.baomidou.mybatisplus.annotation.TableName;
5
 import com.baomidou.mybatisplus.annotation.TableName;
4
 import lombok.Data;
6
 import lombok.Data;
5
 import lombok.EqualsAndHashCode;
7
 import lombok.EqualsAndHashCode;
27
     /**
29
     /**
28
      * 主键
30
      * 主键
29
      */
31
      */
32
+    @TableId(value = "id", type = IdType.AUTO)
30
     private Integer id;
33
     private Integer id;
31
 
34
 
32
     /**
35
     /**

+ 16
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/ITaSysUserRoleService.java View File

1
+package com.community.huiju.service;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.community.huiju.model.TaSysUserRole;
5
+
6
+/**
7
+ * <p>
8
+ * app端用户是那些角色 服务类
9
+ * </p>
10
+ *
11
+ * @author weiximei
12
+ * @since 2018-12-21
13
+ */
14
+public interface ITaSysUserRoleService extends IService<TaSysUserRole> {
15
+
16
+}

+ 190
- 13
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/BuildingOwnerInfoServiceImpl.java View File

11
 import com.community.commom.utils.AccountValidatorUtil;
11
 import com.community.commom.utils.AccountValidatorUtil;
12
 import com.community.commom.utils.BeanTools;
12
 import com.community.commom.utils.BeanTools;
13
 
13
 
14
+import com.community.huiju.dao.TaSysUserRoleMapper;
14
 import com.community.huiju.dao.TaUserMapper;
15
 import com.community.huiju.dao.TaUserMapper;
16
+import com.community.huiju.dao.UserMapper;
15
 import com.community.huiju.exception.WisdomException;
17
 import com.community.huiju.exception.WisdomException;
18
+import com.community.huiju.model.TaSysUserRole;
16
 import com.community.huiju.model.TaUser;
19
 import com.community.huiju.model.TaUser;
17
 
20
 
18
 import com.community.huiju.dao.TpBuildingOwnerInfoMapper;
21
 import com.community.huiju.dao.TpBuildingOwnerInfoMapper;
19
 import com.community.huiju.model.TpBuildingOwnerInfo;
22
 import com.community.huiju.model.TpBuildingOwnerInfo;
20
 
23
 
24
+import com.community.huiju.model.User;
21
 import com.community.huiju.service.IBuildingOwnerInfoService;
25
 import com.community.huiju.service.IBuildingOwnerInfoService;
22
 import com.google.common.collect.Maps;
26
 import com.google.common.collect.Maps;
23
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
27
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
58
     
62
     
59
     @Autowired
63
     @Autowired
60
     private TaUserMapper taUserMapper;
64
     private TaUserMapper taUserMapper;
65
+
66
+    @Autowired
67
+    private UserMapper userMapper;
68
+
69
+    @Autowired
70
+    private TaSysUserRoleMapper taSysUserRoleMapper;
61
     
71
     
62
     public static final Logger logger = LoggerFactory.getLogger(BuildingOwnerInfoServiceImpl.class);
72
     public static final Logger logger = LoggerFactory.getLogger(BuildingOwnerInfoServiceImpl.class);
63
     
73
     
87
         QueryWrapper<TpBuildingOwnerInfo> queryWrapper = new QueryWrapper<>();
97
         QueryWrapper<TpBuildingOwnerInfo> queryWrapper = new QueryWrapper<>();
88
         queryWrapper.allEq(map,false);
98
         queryWrapper.allEq(map,false);
89
         queryWrapper.like(tpBuildingOwnerInfo.getOwnerName() != null,"owner_name", tpBuildingOwnerInfo.getOwnerName());
99
         queryWrapper.like(tpBuildingOwnerInfo.getOwnerName() != null,"owner_name", tpBuildingOwnerInfo.getOwnerName());
100
+        queryWrapper.ne("verify_status", 2);
90
 
101
 
91
         // 分页查询
102
         // 分页查询
92
         IPage<TpBuildingOwnerInfo> infoIPage = tpBuildingOwnerInfoMapper.selectPage(page, queryWrapper);
103
         IPage<TpBuildingOwnerInfo> infoIPage = tpBuildingOwnerInfoMapper.selectPage(page, queryWrapper);
96
         // 获取数据
107
         // 获取数据
97
         List<TpBuildingOwnerInfo> list = infoIPage.getRecords();
108
         List<TpBuildingOwnerInfo> list = infoIPage.getRecords();
98
 
109
 
99
-        retMap.put("data", list);
110
+        retMap.put("list", list);
100
         retMap.put("total", infoIPage.getTotal());
111
         retMap.put("total", infoIPage.getTotal());
101
         retMap.put("pageNum", infoIPage.getCurrent());
112
         retMap.put("pageNum", infoIPage.getCurrent());
102
         retMap.put("pageSize", infoIPage.getSize());
113
         retMap.put("pageSize", infoIPage.getSize());
103
 
114
 
104
-        responseBean.addSuccess(list);
115
+        responseBean.addSuccess(retMap);
105
 
116
 
106
         return responseBean;
117
         return responseBean;
107
     }
118
     }
113
         ResponseBean responseBean = new ResponseBean();
124
         ResponseBean responseBean = new ResponseBean();
114
 
125
 
115
         TpBuildingOwnerInfo tpBuildingOwnerInfo = JSONObject.parseObject(parameter, TpBuildingOwnerInfo.class);
126
         TpBuildingOwnerInfo tpBuildingOwnerInfo = JSONObject.parseObject(parameter, TpBuildingOwnerInfo.class);
127
+        if (!AccountValidatorUtil.isPhone(tpBuildingOwnerInfo.getOwnerTel())){
128
+            responseBean.addError("请输入正取的手机号!");
129
+            return responseBean;
130
+        }
131
+
132
+
116
         TpBuildingOwnerInfo oldTpBuildingOwnerInfo = tpBuildingOwnerInfoMapper.selectById(tpBuildingOwnerInfo.getId());
133
         TpBuildingOwnerInfo oldTpBuildingOwnerInfo = tpBuildingOwnerInfoMapper.selectById(tpBuildingOwnerInfo.getId());
117
         if (null == oldTpBuildingOwnerInfo) {
134
         if (null == oldTpBuildingOwnerInfo) {
118
             throw new WisdomException("%s 数据不存在!", tpBuildingOwnerInfo.getId());
135
             throw new WisdomException("%s 数据不存在!", tpBuildingOwnerInfo.getId());
119
         }
136
         }
120
 
137
 
138
+        // 物业端的用户,也就是正在操作的物业人员
139
+        User user = userMapper.selectById(userId);
140
+
141
+        /**
142
+         * 修改的时候, 如果提交上来的数据和要被修改的数据是一样的! 直接返回操作成功!
143
+         */
144
+
145
+        // 标记是否修改了手机号
146
+        boolean phoneBool = false;
147
+
148
+        // 校验楼栋信息表
149
+        QueryWrapper<TpBuildingOwnerInfo> queryWrapper = new QueryWrapper<>();
150
+        // 小区ID
151
+        queryWrapper.eq("community_id", user.getCommunityId());
152
+        // 栋
153
+        queryWrapper.eq("building", tpBuildingOwnerInfo.getBuilding());
154
+        // 单元
155
+        queryWrapper.eq("unit", tpBuildingOwnerInfo.getUnit());
156
+        // 楼层
157
+        queryWrapper.eq("level", tpBuildingOwnerInfo.getLevel());
158
+        // 房号
159
+        queryWrapper.eq("room_no", tpBuildingOwnerInfo.getRoomNo());
160
+        TpBuildingOwnerInfo selectBuild = tpBuildingOwnerInfoMapper.selectOne(queryWrapper);
161
+        // 如果数据查询到了, 并且手机号和传上来的手机号是一样的是, 代表就是原数据, 直接返回操作成功
162
+        if (null != selectBuild && selectBuild.getOwnerTel().equals(tpBuildingOwnerInfo.getOwnerTel())) {
163
+            tpBuildingOwnerInfoMapper.updateById(tpBuildingOwnerInfo);
164
+            responseBean.addSuccess("操作成功!");
165
+            return responseBean;
166
+
167
+            // 如果 传上来的 楼栋,单元,楼层,单元,户号 查询出来的数据, 和 要修改的数据的id是匹配的, 就表示是只修改手机号
168
+        } else if (null != selectBuild && (tpBuildingOwnerInfo.getId().intValue() == selectBuild.getId().intValue())) {
169
+            // 此时要验证手机号是否存在楼栋资料库库里面
170
+            // 校验楼栋信息表里面的业主手机号
171
+            QueryWrapper<TpBuildingOwnerInfo> queryWrapperPhone = new QueryWrapper<>();
172
+            queryWrapperPhone.eq("owner_tel", tpBuildingOwnerInfo.getOwnerTel());
173
+            TpBuildingOwnerInfo selectBuildPhone = tpBuildingOwnerInfoMapper.selectOne(queryWrapper);
174
+
175
+            // 如果 通过手机号查询出来的楼栋信息数据的 id 和 传上来的 楼栋,单元,楼层,单元,户号 查询出来的数据的id 匹配, 那么就表示这个手机号已经绑定了其他的楼栋信息
176
+            if (selectBuildPhone.getId().intValue() != selectBuild.getId().intValue()){
177
+                responseBean.addError("该手机号已存在!");
178
+                return responseBean;
179
+            }
180
+
181
+            // 开始修改手机号
182
+            phoneBool = true;
183
+
184
+            // 查询到了数据, 就表示新数据, 在库里面已经存在! 可能就是别业主的! 不能被修改为当前这个业主的!
185
+        } else if (null != selectBuild && phoneBool == false){
186
+            responseBean.addError("该户号已存在!");
187
+            return responseBean;
188
+        }
189
+
190
+        // 开始修改手机号操作!
191
+
121
         BeanTools.copyProperties(tpBuildingOwnerInfo, oldTpBuildingOwnerInfo);
192
         BeanTools.copyProperties(tpBuildingOwnerInfo, oldTpBuildingOwnerInfo);
122
 
193
 
123
         oldTpBuildingOwnerInfo.setUpdateDate(LocalDateTime.now());
194
         oldTpBuildingOwnerInfo.setUpdateDate(LocalDateTime.now());
125
 
196
 
126
         int row = tpBuildingOwnerInfoMapper.updateById(oldTpBuildingOwnerInfo);
197
         int row = tpBuildingOwnerInfoMapper.updateById(oldTpBuildingOwnerInfo);
127
         if (row <= 0) {
198
         if (row <= 0) {
199
+            log.error("修改操作! 修改楼栋信息表数据失败! 更新ID: ", oldTpBuildingOwnerInfo.getId());
200
+            throw new WisdomException("操作失败!");
201
+        }
202
+
203
+        // 修改 APP 端业主用户的手机号信息!
204
+        // 开始匹配 APP 端用户表
205
+        QueryWrapper<TaUser> taUserQueryWrapper = new QueryWrapper<>();
206
+        taUserQueryWrapper.eq("login_name", tpBuildingOwnerInfo.getOwnerTel());
207
+        taUserQueryWrapper.eq("community_id", tpBuildingOwnerInfo.getCommunityId());
208
+        // 查询 APP 端业主
209
+        TaUser appOwnerUser = taUserMapper.selectOne(taUserQueryWrapper);
210
+        if (null != appOwnerUser) {
211
+            // 修改手机号
212
+            appOwnerUser.setLoginName(tpBuildingOwnerInfo.getOwnerTel());
213
+            row = taUserMapper.updateById(appOwnerUser);
214
+
215
+            // 更新APP端用户的角色身份为 业主
216
+            updateAppRole(tpBuildingOwnerInfo.getCommunityId(), appOwnerUser.getId(), Constant.OWNER_ID);
217
+        }
218
+
219
+
220
+
221
+        if (row <= 0) {
222
+            log.error("修改操作! 修改楼栋信息表过程中, 修改 APP 端失败信息失败!");
128
             throw new WisdomException("操作失败!");
223
             throw new WisdomException("操作失败!");
129
         } else {
224
         } else {
130
             responseBean.addSuccess("操作成功!");
225
             responseBean.addSuccess("操作成功!");
138
         ResponseBean responseBean = new ResponseBean();
233
         ResponseBean responseBean = new ResponseBean();
139
 
234
 
140
         TpBuildingOwnerInfo tpBuildingOwnerInfo = JSONObject.parseObject(parameter, TpBuildingOwnerInfo.class);
235
         TpBuildingOwnerInfo tpBuildingOwnerInfo = JSONObject.parseObject(parameter, TpBuildingOwnerInfo.class);
236
+        // 物业端的用户,也就是正在操作的物业人员
237
+        User user = userMapper.selectById(userId);
238
+        if (!AccountValidatorUtil.isPhone(tpBuildingOwnerInfo.getOwnerTel())){
239
+            responseBean.addError("请输入正取的手机号!");
240
+            return responseBean;
241
+        }
242
+
243
+        QueryWrapper<TpBuildingOwnerInfo> queryWrapperPhone = new QueryWrapper<>();
244
+        // 校验楼栋信息表里面的业主手机号
245
+        queryWrapperPhone.eq("owner_tel", tpBuildingOwnerInfo.getOwnerTel());
246
+        TpBuildingOwnerInfo selectBuild = tpBuildingOwnerInfoMapper.selectOne(queryWrapperPhone);
247
+        if (null != selectBuild) {
248
+            responseBean.addError("该手机号已经录入!");
249
+            return responseBean;
250
+        }
251
+
252
+        // 校验楼栋信息表
253
+        QueryWrapper<TpBuildingOwnerInfo> queryWrapper = new QueryWrapper<>();
254
+        // 小区ID
255
+        queryWrapper.eq("community_id", user.getCommunityId());
256
+        // 栋
257
+        queryWrapper.eq("building", tpBuildingOwnerInfo.getBuilding());
258
+        // 单元
259
+        queryWrapper.eq("unit", tpBuildingOwnerInfo.getUnit());
260
+        // 楼层
261
+        queryWrapper.eq("level", tpBuildingOwnerInfo.getLevel());
262
+        // 房号
263
+        queryWrapper.eq("room_no", tpBuildingOwnerInfo.getRoomNo());
264
+        selectBuild = tpBuildingOwnerInfoMapper.selectOne(queryWrapper);
265
+        if (null != selectBuild) {
266
+            responseBean.addError("该楼层的户号,已存在!");
267
+            return responseBean;
268
+        }
269
+
141
         // 主键是自增的, 所以设置为 null
270
         // 主键是自增的, 所以设置为 null
142
         tpBuildingOwnerInfo.setId(null);
271
         tpBuildingOwnerInfo.setId(null);
143
         tpBuildingOwnerInfo.setUpdateUser(userId);
272
         tpBuildingOwnerInfo.setUpdateUser(userId);
144
         tpBuildingOwnerInfo.setUpdateDate(LocalDateTime.now());
273
         tpBuildingOwnerInfo.setUpdateDate(LocalDateTime.now());
145
         tpBuildingOwnerInfo.setCreateDate(LocalDateTime.now());
274
         tpBuildingOwnerInfo.setCreateDate(LocalDateTime.now());
146
         tpBuildingOwnerInfo.setCreateUser(userId);
275
         tpBuildingOwnerInfo.setCreateUser(userId);
276
+        tpBuildingOwnerInfo.setVerifyStatus("0");
277
+
278
+        // 添加的时候, 默认是当前操作的小区
279
+        tpBuildingOwnerInfo.setCommunityId(user.getCommunityId());
147
 
280
 
148
         int row = tpBuildingOwnerInfoMapper.insert(tpBuildingOwnerInfo);
281
         int row = tpBuildingOwnerInfoMapper.insert(tpBuildingOwnerInfo);
282
+        if (row <= 0) {
283
+            log.error("添加操作! 楼栋业主信息表 失败!");
284
+            throw new WisdomException("操作失败!");
285
+        }
286
+
287
+        // 开始匹配 APP 端用户表
288
+        QueryWrapper<TaUser> taUserQueryWrapper = new QueryWrapper<>();
289
+        taUserQueryWrapper.eq("login_name", tpBuildingOwnerInfo.getOwnerTel());
290
+        taUserQueryWrapper.eq("community_id", tpBuildingOwnerInfo.getCommunityId());
291
+        // 查询 APP 端业主
292
+        TaUser appOwnerUser = taUserMapper.selectOne(taUserQueryWrapper);
293
+        if (null != appOwnerUser) {
294
+            // 更新 APP 端用户认证的状态
295
+            appOwnerUser.setBuildingOwnerInfoId(tpBuildingOwnerInfo.getId());
296
+            // 认证状态  0 是未认证    1是认证通过   2是已作废
297
+            // 标记位已认证
298
+            appOwnerUser.setVerifyStatus("1");
299
+            row = taUserMapper.updateById(appOwnerUser);
300
+            if (row <= 0) {
301
+                log.error("添加操作! 楼栋业主信息表 过程中 修改 APP 端用户认证的状态失败! ");
302
+                throw new WisdomException("操作失败!");
303
+            }
304
+
305
+            // 更新 楼栋业主信息表 的认证,关联状态
306
+            // 认证状态  0 是未认证    1是认证通过   2是已作废
307
+            tpBuildingOwnerInfo.setVerifyStatus("1");
308
+            // 关联状态   0 未关联  1 是已关联
309
+            tpBuildingOwnerInfo.setPairStatus("1");
310
+            row = tpBuildingOwnerInfoMapper.updateById(tpBuildingOwnerInfo);
311
+            if (row <= 0) {
312
+                log.error("添加操作! 更新 楼栋业主信息表 的认证,关联状态 失败!");
313
+                throw new WisdomException("操作失败!");
314
+            }
315
+
316
+            // 更新APP端用户的角色身份为 业主
317
+            updateAppRole(tpBuildingOwnerInfo.getCommunityId(), appOwnerUser.getId(), Constant.OWNER_ID);
318
+        }
319
+
320
+
149
         if (row <= 0) {
321
         if (row <= 0) {
150
             throw new WisdomException("操作失败!");
322
             throw new WisdomException("操作失败!");
151
         } else {
323
         } else {
155
         return responseBean;
327
         return responseBean;
156
     }
328
     }
157
 
329
 
330
+    /**
331
+     * 修改 APP 端用户的角色
332
+     * @param communityId 小区Id
333
+     * @param appUserId APP 端用户Id
334
+     * @param roleId 角色Id
335
+     */
336
+    private void updateAppRole(Integer communityId, Integer appUserId, Integer roleId) {
337
+        // 更新APP端用户的角色身份
338
+        taSysUserRoleMapper.deleteByCommunityIdAndUserId(communityId, appUserId);
339
+        TaSysUserRole taSysUserRole = new TaSysUserRole();
340
+        taSysUserRole.setUserId(appUserId);
341
+        taSysUserRole.setRoleId(Constant.OWNER_ID);
342
+        taSysUserRole.setCommunityId(communityId);
343
+        taSysUserRoleMapper.insert(taSysUserRole);
344
+    }
345
+
158
     @Override
346
     @Override
159
     public ResponseBean getBuildingOrUnitOrNumber(String parameter,Integer communityId) {
347
     public ResponseBean getBuildingOrUnitOrNumber(String parameter,Integer communityId) {
160
 
348
 
191
          *
379
          *
192
          */
380
          */
193
 
381
 
194
-        String column = null;
195
-        if (null == tpBuildingOwnerInfo.getBuilding()) {
196
-            column = "building";
197
-        } else if (null == tpBuildingOwnerInfo.getUnit()) {
198
-            column = "unit";
199
-        } else if (null == tpBuildingOwnerInfo.getLevel()){
200
-            column = "level";
201
-        } else if (null == tpBuildingOwnerInfo.getRoomNo()) {
202
-            column = "room_no";
203
-        }
204
-        queryWrapper.groupBy(column);
205
         List<TpBuildingOwnerInfo> selectList = tpBuildingOwnerInfoMapper.selectList(queryWrapper);
382
         List<TpBuildingOwnerInfo> selectList = tpBuildingOwnerInfoMapper.selectList(queryWrapper);
206
 
383
 
207
         responseBean.addSuccess(selectList);
384
         responseBean.addSuccess(selectList);

+ 20
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/TaSysUserRoleServiceImpl.java View File

1
+package com.community.huiju.service.impl;
2
+
3
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4
+import com.community.huiju.dao.TaSysUserRoleMapper;
5
+import com.community.huiju.model.TaSysUserRole;
6
+import com.community.huiju.service.ITaSysUserRoleService;
7
+import org.springframework.stereotype.Service;
8
+
9
+/**
10
+ * <p>
11
+ * app端用户是那些角色 服务实现类
12
+ * </p>
13
+ *
14
+ * @author weiximei
15
+ * @since 2018-12-21
16
+ */
17
+@Service
18
+public class TaSysUserRoleServiceImpl extends ServiceImpl<TaSysUserRoleMapper, TaSysUserRole> implements ITaSysUserRoleService {
19
+
20
+}

+ 5
- 0
CODE/smart-community/property-api/src/main/resources/mapper/TaSysUserRoleMapper.xml View File

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.community.huiju.dao.TaSysUserRoleMapper">
4
+
5
+</mapper>

+ 51
- 1
VUECODE/smart-property-manage/src/api/buildingOwnerInfo.js View File

15
   return request(config)
15
   return request(config)
16
 }
16
 }
17
 
17
 
18
-// 获取楼栋业主信息
18
+// 获取楼栋业主信息列表
19
 export function buildingList(data) {
19
 export function buildingList(data) {
20
   return request({
20
   return request({
21
     url: '/building/list',
21
     url: '/building/list',
32
   })
32
   })
33
 }
33
 }
34
 
34
 
35
+// 批量删除 楼栋业主信息
36
+export function deleteBuilding(data) {
37
+  return request({
38
+    url: '/building/delete',
39
+    method: 'delete',
40
+    data
41
+  })
42
+}
43
+
44
+// 添加楼栋业主信息
45
+export function addBuilding(data) {
46
+  return request({
47
+    url: '/building/add',
48
+    method: 'post',
49
+    data: {
50
+      building: data.building,
51
+      unit: data.unit,
52
+      level: data.level,
53
+      roomNo: data.roomNo,
54
+      ownerName: data.ownerName,
55
+      ownerTel: data.ownerTel
56
+    }
57
+  })
58
+}
59
+
60
+// 修改楼栋业主信息
61
+export function updateBuilding(data) {
62
+  return request({
63
+    url: '/building/update',
64
+    method: 'put',
65
+    data: {
66
+      id: data.id,
67
+      building: data.building,
68
+      unit: data.unit,
69
+      level: data.level,
70
+      roomNo: data.roomNo,
71
+      ownerName: data.ownerName,
72
+      ownerTel: data.ownerTel
73
+    }
74
+  })
75
+}
76
+
77
+// 根据楼栋信息 id 查询
78
+export function getByIdBuildingId(buildingId) {
79
+  return request({
80
+    url: '/building/' + buildingId,
81
+    method: 'get'
82
+  })
83
+}
84
+

+ 14
- 0
VUECODE/smart-property-manage/src/router/index.js View File

74
         name: 'batch-import',
74
         name: 'batch-import',
75
         hidden: true,
75
         hidden: true,
76
         meta: { title: '批量导入楼栋信息', icon: 'table' }
76
         meta: { title: '批量导入楼栋信息', icon: 'table' }
77
+      },
78
+      {
79
+        path: '/building/add',
80
+        component: () => import('@/views/building/add/index'),
81
+        name: 'building-add',
82
+        hidden: true,
83
+        meta: { title: '添加楼栋业主资料', icon: 'table' }
84
+      },
85
+      {
86
+        path: '/building/edi',
87
+        component: () => import('@/views/building/edi/index'),
88
+        name: 'building-edi',
89
+        hidden: true,
90
+        meta: { title: '修改楼栋业主资料', icon: 'table' }
77
       }
91
       }
78
     ]
92
     ]
79
   },
93
   },

+ 37
- 1
VUECODE/smart-property-manage/src/store/modules/buildingOwnerInfo.js View File

1
-import { buildingAddress, buildingList } from '@/api/buildingOwnerInfo'
1
+import { buildingAddress, buildingList, deleteBuilding, addBuilding, updateBuilding, getByIdBuildingId } from '@/api/buildingOwnerInfo'
2
 
2
 
3
 const buildingOwnerInfo = {
3
 const buildingOwnerInfo = {
4
   state: {
4
   state: {
30
           reject(error)
30
           reject(error)
31
         })
31
         })
32
       })
32
       })
33
+    },
34
+    DeleteBuilding({ commit }, data) { // 批量删除
35
+      return new Promise((resolve, reject) => {
36
+        deleteBuilding(data).then(response => {
37
+          resolve(response)
38
+        }).catch(error => {
39
+          reject(error)
40
+        })
41
+      })
42
+    },
43
+    UpdateBuilding({ commit }, data) { // 修改楼栋业主信息
44
+      return new Promise((resolve, reject) => {
45
+        updateBuilding(data).then(response => {
46
+          resolve(response)
47
+        }).catch(error => {
48
+          reject(error)
49
+        })
50
+      })
51
+    },
52
+    AddBuilding({ commit }, data) { // 修改楼栋业主信息
53
+      return new Promise((resolve, reject) => {
54
+        addBuilding(data).then(response => {
55
+          resolve(response)
56
+        }).catch(error => {
57
+          reject(error)
58
+        })
59
+      })
60
+    },
61
+    GetByIdBuildingId({ commit }, data) { // 根据楼栋信息id查询
62
+      return new Promise((resolve, reject) => {
63
+        getByIdBuildingId(data).then(response => {
64
+          resolve(response)
65
+        }).catch(error => {
66
+          reject(error)
67
+        })
68
+      })
33
     }
69
     }
34
   }
70
   }
35
 }
71
 }

+ 66
- 41
VUECODE/smart-property-manage/src/views/building/add/index.vue View File

1
 <template>
1
 <template>
2
   <div class="root">
2
   <div class="root">
3
-    <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm">
4
-      <el-form-item label="栋" prop="name">
5
-        <el-input v-model="ruleForm.name"/>
3
+    <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="add-ruleForm">
4
+      <el-form-item label="栋" prop="building">
5
+        <el-input v-model="ruleForm.building"/>
6
       </el-form-item>
6
       </el-form-item>
7
-      <el-form-item label="单元" prop="region">
8
-        <el-input v-model="ruleForm.name"/>
7
+      <el-form-item label="单元" prop="unit">
8
+        <el-input v-model="ruleForm.unit"/>
9
       </el-form-item>
9
       </el-form-item>
10
-      <el-form-item label="楼层" required>
11
-        <el-input v-model="ruleForm.name"/>
10
+      <el-form-item label="楼层" prop="level">
11
+        <el-input v-model="ruleForm.level"/>
12
       </el-form-item>
12
       </el-form-item>
13
-      <el-form-item label="户号" prop="delivery">
14
-        <el-switch v-model="ruleForm.delivery"/>
13
+      <el-form-item label="户号" prop="roomNo">
14
+        <el-input v-model="ruleForm.roomNo"/>
15
       </el-form-item>
15
       </el-form-item>
16
-      <el-form-item label="业主姓名" prop="type">
17
-        <el-input v-model="ruleForm.name"/>
16
+      <el-form-item label="业主姓名" prop="ownerName">
17
+        <el-input v-model="ruleForm.ownerName"/>
18
       </el-form-item>
18
       </el-form-item>
19
-      <el-form-item label="业主手机号" prop="resource">
20
-        <el-input v-model="ruleForm.name"/>
19
+      <el-form-item label="业主手机号" prop="ownerTel">
20
+        <el-input v-model="ruleForm.ownerTel"/>
21
       </el-form-item>
21
       </el-form-item>
22
       <el-form-item>
22
       <el-form-item>
23
         <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
23
         <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
32
   data() {
32
   data() {
33
     return {
33
     return {
34
       ruleForm: {
34
       ruleForm: {
35
-        name: '',
36
-        region: '',
37
-        date1: '',
38
-        date2: '',
39
-        delivery: false,
40
-        type: [],
41
-        resource: '',
42
-        desc: ''
35
+        building: '',
36
+        unit: '',
37
+        level: '',
38
+        roomNo: '',
39
+        ownerName: '',
40
+        ownerTel: ''
43
       },
41
       },
44
       rules: {
42
       rules: {
45
-        name: [
46
-          { required: true, message: '请输入活动名称', trigger: 'blur' },
47
-          { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
43
+        building: [
44
+          { required: true, message: '请输入楼栋', trigger: 'blur' }
48
         ],
45
         ],
49
-        region: [
50
-          { required: true, message: '请选择活动区域', trigger: 'change' }
46
+        unit: [
47
+          { required: true, message: '请输入单元', trigger: 'blur' }
51
         ],
48
         ],
52
-        date1: [
53
-          { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
49
+        level: [
50
+          { required: true, message: '请输入楼层', trigger: 'blur' }
54
         ],
51
         ],
55
-        date2: [
56
-          { type: 'date', required: true, message: '请选择时间', trigger: 'change' }
52
+        roomNo: [
53
+          { required: true, message: '请输入户号', trigger: 'blur' }
57
         ],
54
         ],
58
-        type: [
59
-          { type: 'array', required: true, message: '请至少选择一个活动性质', trigger: 'change' }
55
+        ownerName: [
56
+          { required: true, message: '请输入姓名', trigger: 'blur' }
60
         ],
57
         ],
61
-        resource: [
62
-          { required: true, message: '请选择活动资源', trigger: 'change' }
63
-        ],
64
-        desc: [
65
-          { required: true, message: '请填写活动形式', trigger: 'blur' }
58
+        ownerTel: [
59
+          { required: true, message: '请输入手机号', trigger: 'blur' },
60
+          { min: 11, max: 11, required: true, message: '请输入11位手机号', trigger: 'blur' }
66
         ]
61
         ]
67
       }
62
       }
68
     }
63
     }
69
   },
64
   },
70
   methods: {
65
   methods: {
71
-    submitForm(formName) {
66
+    submitForm(formName) { // 提交
72
       this.$refs[formName].validate((valid) => {
67
       this.$refs[formName].validate((valid) => {
73
         if (valid) {
68
         if (valid) {
74
-          alert('submit!')
69
+          this.addBuilding()
75
         } else {
70
         } else {
76
           console.log('error submit!!')
71
           console.log('error submit!!')
77
           return false
72
           return false
78
         }
73
         }
79
       })
74
       })
80
     },
75
     },
81
-    resetForm(formName) {
76
+    resetForm(formName) { // 重置
82
       this.$refs[formName].resetFields()
77
       this.$refs[formName].resetFields()
78
+    },
79
+    addBuilding() {
80
+      // 加载框
81
+      const loading = this.$loading({
82
+        lock: true,
83
+        text: 'Loading',
84
+        spinner: 'el-icon-loading',
85
+        background: 'rgba(0, 0, 0, 0.7)'
86
+      })
87
+      this.$store.dispatch('AddBuilding', this.ruleForm).then((res) => {
88
+        if (res.code === '0') {
89
+          this.$message({
90
+            message: res.message,
91
+            type: 'success'
92
+          })
93
+          this.$router.push({ name: 'building-index' })
94
+          loading.close()
95
+          return
96
+        }
97
+        this.$message.error(res.message)
98
+        loading.close()
99
+      }).catch(() => {
100
+        loading.close()
101
+        console.log('error AddBuilding')
102
+      })
83
     }
103
     }
84
   }
104
   }
85
 }
105
 }
86
 </script>
106
 </script>
87
 
107
 
88
 <style scoped>
108
 <style scoped>
89
-
109
+.add-ruleForm{
110
+  width: 800px;
111
+  margin-left: auto;
112
+  margin-right: auto;
113
+  margin-top: 50px;
114
+}
90
 </style>
115
 </style>

+ 93
- 42
VUECODE/smart-property-manage/src/views/building/edi/index.vue View File

1
 <template>
1
 <template>
2
   <div class="root">
2
   <div class="root">
3
-    <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm">
4
-      <el-form-item label="栋" prop="name">
5
-        <el-input v-model="ruleForm.name"/>
3
+    <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="add-ruleForm">
4
+      <el-form-item v-show="false" label="编号" >
5
+        <el-input v-model="ruleForm.id" disabled/>
6
       </el-form-item>
6
       </el-form-item>
7
-      <el-form-item label="单元" prop="region">
8
-        <el-input v-model="ruleForm.name"/>
7
+      <el-form-item label="栋" prop="building">
8
+        <el-input v-model="ruleForm.building"/>
9
       </el-form-item>
9
       </el-form-item>
10
-      <el-form-item label="楼层" required>
11
-        <el-input v-model="ruleForm.name"/>
10
+      <el-form-item label="单元" prop="unit">
11
+        <el-input v-model="ruleForm.unit"/>
12
       </el-form-item>
12
       </el-form-item>
13
-      <el-form-item label="户号" prop="delivery">
14
-        <el-switch v-model="ruleForm.delivery"/>
13
+      <el-form-item label="楼层" prop="level">
14
+        <el-input v-model="ruleForm.level"/>
15
       </el-form-item>
15
       </el-form-item>
16
-      <el-form-item label="业主姓名" prop="type">
17
-        <el-input v-model="ruleForm.name"/>
16
+      <el-form-item label="户号" prop="roomNo">
17
+        <el-input v-model="ruleForm.roomNo"/>
18
       </el-form-item>
18
       </el-form-item>
19
-      <el-form-item label="业主手机号" prop="resource">
20
-        <el-input v-model="ruleForm.name"/>
19
+      <el-form-item label="业主姓名" prop="ownerName">
20
+        <el-input v-model="ruleForm.ownerName"/>
21
+      </el-form-item>
22
+      <el-form-item label="业主手机号" prop="ownerTel">
23
+        <el-input v-model="ruleForm.ownerTel"/>
21
       </el-form-item>
24
       </el-form-item>
22
       <el-form-item>
25
       <el-form-item>
23
         <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
26
         <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
24
-        <el-button @click="resetForm('ruleForm')">重置</el-button>
27
+        <el-button @click="backIndex">返回</el-button>
25
       </el-form-item>
28
       </el-form-item>
26
     </el-form>
29
     </el-form>
27
   </div>
30
   </div>
32
   data() {
35
   data() {
33
     return {
36
     return {
34
       ruleForm: {
37
       ruleForm: {
35
-        name: '',
36
-        region: '',
37
-        date1: '',
38
-        date2: '',
39
-        delivery: false,
40
-        type: [],
41
-        resource: '',
42
-        desc: ''
38
+        id: '',
39
+        building: '',
40
+        unit: '',
41
+        level: '',
42
+        roomNo: '',
43
+        ownerName: '',
44
+        ownerTel: ''
43
       },
45
       },
46
+      listQuery: [], // 查询的参数
44
       rules: {
47
       rules: {
45
-        name: [
46
-          { required: true, message: '请输入活动名称', trigger: 'blur' },
47
-          { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
48
-        ],
49
-        region: [
50
-          { required: true, message: '请选择活动区域', trigger: 'change' }
48
+        building: [
49
+          { required: true, message: '请输入楼栋', trigger: 'blur' }
51
         ],
50
         ],
52
-        date1: [
53
-          { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
51
+        unit: [
52
+          { required: true, message: '请输入单元', trigger: 'blur' }
54
         ],
53
         ],
55
-        date2: [
56
-          { type: 'date', required: true, message: '请选择时间', trigger: 'change' }
54
+        level: [
55
+          { required: true, message: '请输入楼层', trigger: 'blur' }
57
         ],
56
         ],
58
-        type: [
59
-          { type: 'array', required: true, message: '请至少选择一个活动性质', trigger: 'change' }
57
+        roomNo: [
58
+          { required: true, message: '请输入户号', trigger: 'blur' }
60
         ],
59
         ],
61
-        resource: [
62
-          { required: true, message: '请选择活动资源', trigger: 'change' }
60
+        ownerName: [
61
+          { required: true, message: '请输入姓名', trigger: 'blur' }
63
         ],
62
         ],
64
-        desc: [
65
-          { required: true, message: '请填写活动形式', trigger: 'blur' }
63
+        ownerTel: [
64
+          { required: true, message: '请输入手机号', trigger: 'blur' },
65
+          { min: 11, max: 11, required: true, message: '请输入11位手机号', trigger: 'blur' }
66
         ]
66
         ]
67
       }
67
       }
68
     }
68
     }
69
   },
69
   },
70
+  mounted() {
71
+    this.listQuery = this.$route.params.listQuery
72
+    this.getById(this.$route.params.id)
73
+  },
70
   methods: {
74
   methods: {
71
-    submitForm(formName) {
75
+    submitForm(formName) { // 提交
72
       this.$refs[formName].validate((valid) => {
76
       this.$refs[formName].validate((valid) => {
73
         if (valid) {
77
         if (valid) {
74
-          alert('submit!')
78
+          this.updateBuilding()
75
         } else {
79
         } else {
76
           console.log('error submit!!')
80
           console.log('error submit!!')
77
           return false
81
           return false
78
         }
82
         }
79
       })
83
       })
80
     },
84
     },
81
-    resetForm(formName) {
85
+    resetForm(formName) { // 重置
82
       this.$refs[formName].resetFields()
86
       this.$refs[formName].resetFields()
87
+    },
88
+    updateBuilding() {
89
+      // 加载框
90
+      const loading = this.$loading({
91
+        lock: true,
92
+        text: 'Loading',
93
+        spinner: 'el-icon-loading',
94
+        background: 'rgba(0, 0, 0, 0.7)'
95
+      })
96
+      this.$store.dispatch('UpdateBuilding', this.ruleForm).then((res) => {
97
+        if (res.code === '0') {
98
+          this.$message({
99
+            message: res.message,
100
+            type: 'success'
101
+          })
102
+          this.$router.push({ name: 'building-index', params: { listQuery: this.listQuery }})
103
+          loading.close()
104
+          return
105
+        }
106
+        this.$message.error(res.message)
107
+        loading.close()
108
+      }).catch(() => {
109
+        loading.close()
110
+        console.log('error AddBuilding')
111
+      })
112
+    },
113
+    getById(buildingId) { // 根据楼栋信息 id 查询楼栋信息
114
+      this.$store.dispatch('GetByIdBuildingId', buildingId).then((res) => {
115
+        const data = res.data
116
+        this.ruleForm.id = data.id
117
+        this.ruleForm.building = data.building
118
+        this.ruleForm.unit = data.unit
119
+        this.ruleForm.level = data.level
120
+        this.ruleForm.roomNo = data.roomNo
121
+        this.ruleForm.ownerName = data.ownerName
122
+        this.ruleForm.ownerTel = data.ownerTel
123
+      }).catch(() => {
124
+        console.log('error GetByIdBuildingId')
125
+      })
126
+    },
127
+    backIndex() { // 返回楼栋信息列表
128
+      this.$router.push({ name: 'building-index', params: { listQuery: this.listQuery }})
83
     }
129
     }
84
   }
130
   }
85
 }
131
 }
86
 </script>
132
 </script>
87
 
133
 
88
 <style scoped>
134
 <style scoped>
89
-
135
+.add-ruleForm{
136
+  width: 800px;
137
+  margin-left: auto;
138
+  margin-right: auto;
139
+  margin-top: 50px;
140
+}
90
 </style>
141
 </style>

+ 84
- 23
VUECODE/smart-property-manage/src/views/building/index.vue View File

36
             :value="item.roomNo"/>
36
             :value="item.roomNo"/>
37
         </el-select>
37
         </el-select>
38
         <el-form-item label="业主名称">
38
         <el-form-item label="业主名称">
39
-          <el-input placeholder="业主名称" />
39
+          <el-input v-model="listQuery.ownerName" placeholder="业主名称" />
40
         </el-form-item>
40
         </el-form-item>
41
       </el-form-item>
41
       </el-form-item>
42
       <el-form-item>
42
       <el-form-item>
43
-        <el-button type="info">清空</el-button>
44
-        <el-button type="primary" @click="dataQuery">查询</el-button>
43
+        <el-button type="info" @click="emptyListQuery">清空</el-button>
44
+        <el-button type="primary" @click="conditionsQuery">查询</el-button>
45
       </el-form-item>
45
       </el-form-item>
46
     </el-form>
46
     </el-form>
47
     <div class="operation">
47
     <div class="operation">
48
       <div>
48
       <div>
49
-        <el-button type="primary">添加</el-button>
50
-        <el-button type="warning">修改</el-button>
51
-        <el-button type="danger">删除</el-button>
49
+        <el-button type="primary" @click="addBuilding">添加</el-button>
50
+        <el-button type="warning" @click="ediBuilding(-1)">修改</el-button>
51
+        <el-button type="danger" @click="deleteData">删除</el-button>
52
       </div>
52
       </div>
53
       <div>
53
       <div>
54
         <el-button type="success" @click="dialogBatchImport">批量导入楼栋信息</el-button>
54
         <el-button type="success" @click="dialogBatchImport">批量导入楼栋信息</el-button>
70
       <el-table-column prop="ownerName" label="业主姓名"/>
70
       <el-table-column prop="ownerName" label="业主姓名"/>
71
       <el-table-column prop="ownerTel" label="手机号码" />
71
       <el-table-column prop="ownerTel" label="手机号码" />
72
       <el-table-column prop="pairStatus" label="关联业主状态" >
72
       <el-table-column prop="pairStatus" label="关联业主状态" >
73
-        <template slot-scope="scope">{{ scope.row.pairStatus === 1 ? '已关联':'未管理' }}</template>
73
+        <template slot-scope="scope">{{ scope.row.pairStatus === '1' ? '已关联':'未关联' }}</template>
74
       </el-table-column>
74
       </el-table-column>
75
       <el-table-column prop="createDate" label="创建时间" />
75
       <el-table-column prop="createDate" label="创建时间" />
76
     </el-table>
76
     </el-table>
79
         :current-page="listQuery.pageNum"
79
         :current-page="listQuery.pageNum"
80
         :page-sizes="[10, 20, 50, 100]"
80
         :page-sizes="[10, 20, 50, 100]"
81
         :page-size="listQuery.pageSize"
81
         :page-size="listQuery.pageSize"
82
-        :total="400"
82
+        :total="total"
83
         layout="total, sizes, prev, pager, next, jumper"
83
         layout="total, sizes, prev, pager, next, jumper"
84
         @size-change="handleSizeChange"
84
         @size-change="handleSizeChange"
85
         @current-change="handleCurrentChange"/>
85
         @current-change="handleCurrentChange"/>
102
         pageNum: 1,
102
         pageNum: 1,
103
         pageSize: 10
103
         pageSize: 10
104
       },
104
       },
105
-      total: '', // 数据总数
105
+      total: 0, // 数据总数
106
       buildingInfoLists: [],
106
       buildingInfoLists: [],
107
       buildingList: [],
107
       buildingList: [],
108
       unitList: [],
108
       unitList: [],
109
       levelList: [],
109
       levelList: [],
110
       roomNoList: [],
110
       roomNoList: [],
111
-      listLoading: true // 加载圈
111
+      listLoading: true, // 加载圈
112
+      deleteIds: [] // 需要删除的id集合
112
     }
113
     }
113
   },
114
   },
114
   computed: {
115
   computed: {
125
     }
126
     }
126
   },
127
   },
127
   mounted() {
128
   mounted() {
128
-    console.log('获取楼栋')
129
     // 获取栋
129
     // 获取栋
130
     this.getBuild()
130
     this.getBuild()
131
+
132
+    const query = this.$route.params.listQuery
133
+    if (query !== undefined) {
134
+      this.listQuery = query
135
+    }
136
+
131
     // 获取数据
137
     // 获取数据
132
     this.dataQuery()
138
     this.dataQuery()
133
   },
139
   },
138
     ]),
144
     ]),
139
     handleSizeChange(val) {
145
     handleSizeChange(val) {
140
       console.log(`每页 ${val} 条`)
146
       console.log(`每页 ${val} 条`)
147
+      this.listQuery.pageSize = val
148
+      this.listQuery.pageNum = 1
149
+      // 获取数据
150
+      this.dataQuery()
141
     },
151
     },
142
     handleCurrentChange(val) {
152
     handleCurrentChange(val) {
143
       console.log(`当前页: ${val}`)
153
       console.log(`当前页: ${val}`)
154
+      this.listQuery.pageNum = val
155
+      // 获取数据
156
+      this.dataQuery()
144
     },
157
     },
145
     dialogBatchImport() {
158
     dialogBatchImport() {
146
       this.$router.push({ name: 'batch-import' })
159
       this.$router.push({ name: 'batch-import' })
147
     },
160
     },
148
-    handleSelectionChange(data) {
149
-
161
+    handleSelectionChange(data) { // 表格多选框
162
+      console.log('多选框的值:', data)
163
+      // 设置为 空
164
+      this.deleteIds = []
165
+      for (let i = 0; i < data.length; i++) {
166
+        this.deleteIds.push(data[i].id)
167
+      }
150
     },
168
     },
151
     getBuild() { // 获取楼栋
169
     getBuild() { // 获取楼栋
152
       this.listQuery.building = ''
170
       this.listQuery.building = ''
153
       this.$store.dispatch('BuildingAddress', this.listQuery).then((res) => {
171
       this.$store.dispatch('BuildingAddress', this.listQuery).then((res) => {
154
         this.buildingList = res.data
172
         this.buildingList = res.data
155
-        // console.log(res)
156
       }).catch(() => {
173
       }).catch(() => {
157
         console.log('error BuildingAddress')
174
         console.log('error BuildingAddress')
158
       })
175
       })
161
       this.listQuery.unit = ''
178
       this.listQuery.unit = ''
162
       this.$store.dispatch('BuildingAddress', this.listQuery).then((res) => {
179
       this.$store.dispatch('BuildingAddress', this.listQuery).then((res) => {
163
         this.unitList = res.data
180
         this.unitList = res.data
164
-        console.log(res)
165
       }).catch(() => {
181
       }).catch(() => {
166
         console.log('error BuildingAddress')
182
         console.log('error BuildingAddress')
167
       })
183
       })
170
       this.listQuery.level = ''
186
       this.listQuery.level = ''
171
       this.$store.dispatch('BuildingAddress', this.listQuery).then((res) => {
187
       this.$store.dispatch('BuildingAddress', this.listQuery).then((res) => {
172
         this.levelList = res.data
188
         this.levelList = res.data
173
-        console.log(res)
174
       }).catch(() => {
189
       }).catch(() => {
175
         console.log('error BuildingAddress')
190
         console.log('error BuildingAddress')
176
       })
191
       })
179
       this.listQuery.roomNo = ''
194
       this.listQuery.roomNo = ''
180
       this.$store.dispatch('BuildingAddress', this.listQuery).then((res) => {
195
       this.$store.dispatch('BuildingAddress', this.listQuery).then((res) => {
181
         this.roomNoList = res.data
196
         this.roomNoList = res.data
182
-        console.log(res)
183
       }).catch(() => {
197
       }).catch(() => {
184
         console.log('error BuildingAddress')
198
         console.log('error BuildingAddress')
185
       })
199
       })
197
           break
211
           break
198
       }
212
       }
199
     },
213
     },
214
+    conditionsQuery() { // 条件查询
215
+      this.listQuery.pageNum = 1
216
+      this.dataQuery()
217
+    },
200
     dataQuery() { // 查询数据
218
     dataQuery() { // 查询数据
201
       this.listLoading = true
219
       this.listLoading = true
202
-      // this.BuildingInfoList(this.listQuery).then((res) => {
203
-      //   this.listLoading = false
204
-      // }).catch(() => {
205
-      //   console.log('get UserCommunity list error')
206
-      // })
207
       this.$store.dispatch('BuildingInfoList', this.listQuery).then((res) => {
220
       this.$store.dispatch('BuildingInfoList', this.listQuery).then((res) => {
208
-        this.$data.buildingInfoLists = res.data
221
+        const resData = res.data
222
+        this.buildingInfoLists = resData.list
223
+        this.listQuery.pageNum = resData.pageNum
224
+        this.listQuery.pageSize = resData.pageSize
225
+        this.total = resData.total
209
         this.listLoading = false
226
         this.listLoading = false
210
       }).catch(() => {
227
       }).catch(() => {
211
         this.listLoading = false
228
         this.listLoading = false
212
         console.log('error BuildingInfoList')
229
         console.log('error BuildingInfoList')
213
       })
230
       })
231
+    },
232
+    emptyListQuery() { // 清空按钮
233
+      this.listQuery.building = ''
234
+      this.listQuery.unit = ''
235
+      this.listQuery.level = ''
236
+      this.listQuery.roomNo = ''
237
+      this.listQuery.ownerName = ''
238
+      this.listQuery.pageNum = 1
239
+      // 获取数据
240
+      this.dataQuery()
241
+    },
242
+    deleteData() { // 删除
243
+      this.$confirm('您确定要删除吗?')
244
+        .then(_ => {
245
+          this.$store.dispatch('DeleteBuilding', this.deleteIds).then((res) => {
246
+            if (res.code === '0') {
247
+              this.$message({
248
+                message: res.message,
249
+                type: 'success'
250
+              })
251
+              // 获取数据
252
+              this.dataQuery()
253
+              return
254
+            }
255
+            this.$message.error(res.message)
256
+          }).catch(() => {
257
+            console.log('error deleteBuilding')
258
+          })
259
+        }).catch(_ => {})
260
+    },
261
+    addBuilding() { // 添加楼栋业主信息资料
262
+      this.$router.push({ name: 'building-add' })
263
+    },
264
+    ediBuilding(buildId) { // 修改楼栋业主信息资料
265
+      const ids = this.deleteIds
266
+      if (ids.length > 1) {
267
+        this.$message.error('只能选择一行数据进行修改!')
268
+        return
269
+      }
270
+      if (ids < 1) {
271
+        this.$message.error('请选择一行数据进行修改!')
272
+        return
273
+      }
274
+      this.$router.push({ name: 'building-edi', params: { id: ids[0], listQuery: this.listQuery }})
214
     }
275
     }
215
   }
276
   }
216
 }
277
 }