Browse Source

租房类修改提交

master^2
主管理员 6 months ago
parent
commit
7deb2f80d4
34 changed files with 1795 additions and 31 deletions
  1. +1
    -1
      admin-pc/.env.development
  2. +1
    -1
      admin-pc/.env.production
  3. +2
    -0
      module-common/src/main/java/org/jeecg/api/bean/HousePageList.java
  4. +50
    -7
      module-common/src/main/java/org/jeecg/api/controller/ApiIndexController.java
  5. +9
    -0
      module-common/src/main/java/org/jeecg/api/service/ApiIndexService.java
  6. +33
    -0
      module-common/src/main/java/org/jeecg/api/service/impl/ApiIndexServiceImpl.java
  7. +229
    -0
      module-common/src/main/java/org/jeecg/modules/commCity/controller/CommCityController.java
  8. +63
    -0
      module-common/src/main/java/org/jeecg/modules/commCity/entity/CommCity.java
  9. +22
    -0
      module-common/src/main/java/org/jeecg/modules/commCity/mapper/CommCityMapper.java
  10. +9
    -0
      module-common/src/main/java/org/jeecg/modules/commCity/mapper/xml/CommCityMapper.xml
  11. +38
    -0
      module-common/src/main/java/org/jeecg/modules/commCity/service/ICommCityService.java
  12. +191
    -0
      module-common/src/main/java/org/jeecg/modules/commCity/service/impl/CommCityServiceImpl.java
  13. +353
    -0
      module-common/src/main/java/org/jeecg/modules/commCity/vue/CommCityList.vue
  14. +156
    -0
      module-common/src/main/java/org/jeecg/modules/commCity/vue/modules/CommCityModal.vue
  15. +82
    -0
      module-common/src/main/java/org/jeecg/modules/commCity/vue3/CommCity.api.ts
  16. +38
    -0
      module-common/src/main/java/org/jeecg/modules/commCity/vue3/CommCity.data.ts
  17. +272
    -0
      module-common/src/main/java/org/jeecg/modules/commCity/vue3/CommCityList.vue
  18. +87
    -0
      module-common/src/main/java/org/jeecg/modules/commCity/vue3/components/CommCityModal.vue
  19. +1
    -1
      module-common/src/main/java/org/jeecg/modules/commonHome/controller/CommonHomeController.java
  20. +14
    -1
      module-common/src/main/java/org/jeecg/modules/commonHome/entity/CommonHome.java
  21. +1
    -1
      module-common/src/main/java/org/jeecg/modules/commonHome/mapper/CommonHomeMapper.java
  22. +1
    -1
      module-common/src/main/java/org/jeecg/modules/commonHome/service/ICommonHomeService.java
  23. +1
    -1
      module-common/src/main/java/org/jeecg/modules/commonHome/service/impl/CommonHomeServiceImpl.java
  24. +25
    -0
      module-common/src/main/java/org/jeecg/modules/commonHome/vue/CommonHomeList.vue
  25. +15
    -0
      module-common/src/main/java/org/jeecg/modules/commonHome/vue/modules/CommonHomeForm.vue
  26. +42
    -0
      module-common/src/main/java/org/jeecg/modules/commonHome/vue3/CommonHome.data.ts
  27. +1
    -1
      module-common/src/main/java/org/jeecg/modules/commonNews/controller/CommonNewsController.java
  28. +9
    -1
      module-common/src/main/java/org/jeecg/modules/commonNews/entity/CommonNews.java
  29. +1
    -1
      module-common/src/main/java/org/jeecg/modules/commonNews/mapper/CommonNewsMapper.java
  30. +1
    -1
      module-common/src/main/java/org/jeecg/modules/commonNews/service/ICommonNewsService.java
  31. +1
    -1
      module-common/src/main/java/org/jeecg/modules/commonNews/service/impl/CommonNewsServiceImpl.java
  32. +13
    -6
      module-common/src/main/java/org/jeecg/modules/commonNews/vue/CommonNewsList.vue
  33. +10
    -0
      module-common/src/main/java/org/jeecg/modules/commonNews/vue/modules/CommonNewsForm.vue
  34. +23
    -6
      module-common/src/main/java/org/jeecg/modules/commonNews/vue3/CommonNews.data.ts

+ 1
- 1
admin-pc/.env.development View File

@ -1,5 +1,5 @@
NODE_ENV=development
VUE_APP_API_BASE_URL=http://localhost:8001/houserent-admin/
VUE_APP_API_BASE_URL=http://localhost:8000/houserent-admin/
VUE_APP_CAS_BASE_URL=http://cas.example.org:8443/cas
VUE_APP_ONLINE_BASE_URL=http://fileview.jeecg.com/onlinePreview


+ 1
- 1
admin-pc/.env.production View File

@ -1,4 +1,4 @@
NODE_ENV=production
VUE_APP_API_BASE_URL=http://localhost:8001/houserent-admin/
VUE_APP_API_BASE_URL=http://localhost:8000/houserent-admin/
VUE_APP_CAS_BASE_URL=http://localhost:8888/cas
VUE_APP_ONLINE_BASE_URL=http://fileview.jeecg.com/onlinePreview

+ 2
- 0
module-common/src/main/java/org/jeecg/api/bean/HousePageList.java View File

@ -6,6 +6,8 @@ import lombok.Data;
@Data
public class HousePageList {
private String iconClass;
private String classId;
/**显示条数*/
@ApiModelProperty(value = "显示条数" )


+ 50
- 7
module-common/src/main/java/org/jeecg/api/controller/ApiIndexController.java View File

@ -8,11 +8,9 @@ import org.jeecg.api.bean.HousePageList;
import org.jeecg.api.service.ApiIndexService;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.commonHome.entity.CommonHome;
import org.jeecg.modules.commonNews.entity.CommonNews;
import org.jeecg.modules.hanHaiMember.service.IHanHaiMemberService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -70,17 +68,47 @@ public class ApiIndexController {
return apiIndexService.getMyHousePageList(token,bean);
}
//查询经济人发布的
@ApiOperation(value="查询经济人发布的", notes="查询经济人发布的")
@GetMapping(value = "/getMyVipPageList")
public Result<?> getMyVipPageList(@RequestHeader("X-Access-Token") String token,HousePageList bean)
{
return apiIndexService.getMyHousePageList(token,bean);
}
//发布或编辑房源
@ApiOperation(value="发布或编辑房源", notes="发布或编辑房源")
@GetMapping(value = "/saveOrUpdateHouse")
@PostMapping(value = "/saveOrUpdateHouse")
public Result<?> saveOrUpdateHouse(@RequestHeader("X-Access-Token") String token, CommonHome home)
{
return apiIndexService.saveOrUpdateHouse(token,home);
}
//删除房源信息
@ApiOperation(value="删除房源信息", notes="删除房源信息")
@GetMapping(value = "/deleteHouse")
public Result<?> deleteHouse(@RequestHeader("X-Access-Token") String token,String houseId)
{
return apiIndexService.deleteHouse(token,houseId);
}
//经纪人账号密码登录
@ApiOperation(value="经纪人账号密码登录", notes="经纪人账号密码登录")
@GetMapping(value = "/login")
@PostMapping(value = "/login")
public Result<?> login(@RequestHeader("X-Access-Token") String token,String username,String password)
{
return apiIndexService.login(username,password);
@ -89,7 +117,7 @@ public class ApiIndexController {
//房东输入邀请码登录
@ApiOperation(value="房东输入邀请码登录", notes="房东输入邀请码登录")
@GetMapping(value = "/loginByInviteCode")
@PostMapping(value = "/loginByInviteCode")
public Result<?> loginByInviteCode(@RequestHeader("X-Access-Token") String token,String inviteCode)
{
return apiIndexService.loginByInviteCode(inviteCode);
@ -113,6 +141,17 @@ public class ApiIndexController {
}
//发布或编辑发现
@ApiOperation(value="发布或编辑发现", notes="发布或编辑发现")
@PostMapping(value = "/saveOrUpdateFind")
public Result<?> saveOrUpdateFind(@RequestHeader("X-Access-Token") String token, CommonNews news)
{
return apiIndexService.saveOrUpdateFind(token,news);
}
//获取发现列表详情
@ApiOperation(value="获取发现列表详情", notes="获取发现列表详情")
@GetMapping(value = "/getFindDetail")
@ -120,4 +159,8 @@ public class ApiIndexController {
{
return apiIndexService.getFindDetail(houseId);
}
}

+ 9
- 0
module-common/src/main/java/org/jeecg/api/service/ApiIndexService.java View File

@ -3,6 +3,7 @@ package org.jeecg.api.service;
import org.jeecg.api.bean.HousePageList;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.commonHome.entity.CommonHome;
import org.jeecg.modules.commonNews.entity.CommonNews;
import org.springframework.web.bind.annotation.RequestHeader;
public interface ApiIndexService {
@ -27,6 +28,9 @@ public interface ApiIndexService {
//发布或编辑房源
Result<?> saveOrUpdateHouse(String token, CommonHome home);
//删除房源信息
Result<?> deleteHouse(String token,String houseId);
//经济人账号密码登录
Result<?> login(String username, String password);
@ -43,8 +47,13 @@ public interface ApiIndexService {
//获取发现列表页面数据带分页
Result<?> getFindPageList(HousePageList bean);
//发布或编辑发现
Result<?> saveOrUpdateFind(String token, CommonNews news);
//获取发现列表详情
Result<?> getFindDetail(String houseId);
}

+ 33
- 0
module-common/src/main/java/org/jeecg/api/service/impl/ApiIndexServiceImpl.java View File

@ -3,6 +3,7 @@ package org.jeecg.api.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.jeecg.api.bean.HousePageList;
import org.jeecg.api.service.ApiIndexService;
import org.jeecg.api.untils.HttpConf;
@ -78,6 +79,24 @@ public class ApiIndexServiceImpl implements ApiIndexService {
.lambdaQuery()
.orderByDesc(CommonHome::getCreateTime)
.page(page);
if(pageBean.getClassId()!=null){
page1 = homeService
.lambdaQuery()
.eq(CommonHome::getClassId,pageBean.getClassId())
.orderByDesc(CommonHome::getCreateTime)
.page(page);
}
//如果区域标识不为空
if(StringUtils.isNotBlank(pageBean.getIconClass())){
page1 = homeService
.lambdaQuery()
.eq(CommonHome::getIconClass,pageBean.getIconClass())
.orderByDesc(CommonHome::getCreateTime)
.page(page);
}
return Result.OK(page1);
}
@ -100,6 +119,7 @@ public class ApiIndexServiceImpl implements ApiIndexService {
.eq(CommonHome::getUserId,hanHaiMember.getId())
.orderByDesc(CommonHome::getCreateTime)
.page(page);
return Result.OK(page1);
}
@ -115,6 +135,13 @@ public class ApiIndexServiceImpl implements ApiIndexService {
return Result.OK("发布成功");
}
//删除房源信息
@Override
public Result<?> deleteHouse(String token,String houseId) {
homeService.removeById(houseId);
return Result.OK("删除成功");
}
//经济人账号密码登录
@Override
@ -151,6 +178,12 @@ public class ApiIndexServiceImpl implements ApiIndexService {
return Result.OK(page1);
}
//发布或编辑发现
@Override
public Result<?> saveOrUpdateFind(String token, CommonNews news){
newsService.saveOrUpdate(news);
return Result.OK("发布成功");
}
//获取发现列表详情


+ 229
- 0
module-common/src/main/java/org/jeecg/modules/commCity/controller/CommCityController.java View File

@ -0,0 +1,229 @@
package org.jeecg.modules.commCity.controller;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.commCity.entity.CommCity;
import org.jeecg.modules.commCity.service.ICommCityService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
/**
* @Description: 城市列表
* @Author: jeecg-boot
* @Date: 2024-12-05
* @Version: V1.0
*/
@Api(tags="城市列表")
@RestController
@RequestMapping("/commCity/commCity")
@Slf4j
public class CommCityController extends JeecgController<CommCity, ICommCityService>{
@Autowired
private ICommCityService commCityService;
/**
* 分页列表查询
*
* @param commCity
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "城市列表-分页列表查询")
@ApiOperation(value="城市列表-分页列表查询", notes="城市列表-分页列表查询")
@GetMapping(value = "/rootList")
public Result<IPage<CommCity>> queryPageList(CommCity commCity,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
String hasQuery = req.getParameter("hasQuery");
if(hasQuery != null && "true".equals(hasQuery)){
QueryWrapper<CommCity> queryWrapper = QueryGenerator.initQueryWrapper(commCity, req.getParameterMap());
List<CommCity> list = commCityService.queryTreeListNoPage(queryWrapper);
IPage<CommCity> pageList = new Page<>(1, 10, list.size());
pageList.setRecords(list);
return Result.OK(pageList);
}else{
String parentId = commCity.getPid();
if (oConvertUtils.isEmpty(parentId)) {
parentId = "0";
}
commCity.setPid(null);
QueryWrapper<CommCity> queryWrapper = QueryGenerator.initQueryWrapper(commCity, req.getParameterMap());
// 使用 eq 防止模糊查询
queryWrapper.eq("pid", parentId);
Page<CommCity> page = new Page<CommCity>(pageNo, pageSize);
IPage<CommCity> pageList = commCityService.page(page, queryWrapper);
return Result.OK(pageList);
}
}
/**
* 获取子数据
* @param commCity
* @param req
* @return
*/
//@AutoLog(value = "城市列表-获取子数据")
@ApiOperation(value="城市列表-获取子数据", notes="城市列表-获取子数据")
@GetMapping(value = "/childList")
public Result<IPage<CommCity>> queryPageList(CommCity commCity,HttpServletRequest req) {
QueryWrapper<CommCity> queryWrapper = QueryGenerator.initQueryWrapper(commCity, req.getParameterMap());
List<CommCity> list = commCityService.list(queryWrapper);
IPage<CommCity> pageList = new Page<>(1, 10, list.size());
pageList.setRecords(list);
return Result.OK(pageList);
}
/**
* 批量查询子节点
* @param parentIds 父ID多个采用半角逗号分割
* @return 返回 IPage
* @param parentIds
* @return
*/
//@AutoLog(value = "城市列表-批量获取子数据")
@ApiOperation(value="城市列表-批量获取子数据", notes="城市列表-批量获取子数据")
@GetMapping("/getChildListBatch")
public Result getChildListBatch(@RequestParam("parentIds") String parentIds) {
try {
QueryWrapper<CommCity> queryWrapper = new QueryWrapper<>();
List<String> parentIdList = Arrays.asList(parentIds.split(","));
queryWrapper.in("pid", parentIdList);
List<CommCity> list = commCityService.list(queryWrapper);
IPage<CommCity> pageList = new Page<>(1, 10, list.size());
pageList.setRecords(list);
return Result.OK(pageList);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("批量查询子节点失败:" + e.getMessage());
}
}
/**
* 添加
*
* @param commCity
* @return
*/
@AutoLog(value = "城市列表-添加")
@ApiOperation(value="城市列表-添加", notes="城市列表-添加")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody CommCity commCity) {
commCityService.addCommCity(commCity);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param commCity
* @return
*/
@AutoLog(value = "城市列表-编辑")
@ApiOperation(value="城市列表-编辑", notes="城市列表-编辑")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody CommCity commCity) {
commCityService.updateCommCity(commCity);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "城市列表-通过id删除")
@ApiOperation(value="城市列表-通过id删除", notes="城市列表-通过id删除")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
commCityService.deleteCommCity(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "城市列表-批量删除")
@ApiOperation(value="城市列表-批量删除", notes="城市列表-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.commCityService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
//@AutoLog(value = "城市列表-通过id查询")
@ApiOperation(value="城市列表-通过id查询", notes="城市列表-通过id查询")
@GetMapping(value = "/queryById")
public Result<CommCity> queryById(@RequestParam(name="id",required=true) String id) {
CommCity commCity = commCityService.getById(id);
if(commCity==null) {
return Result.error("未找到对应数据");
}
return Result.OK(commCity);
}
/**
* 导出excel
*
* @param request
* @param commCity
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, CommCity commCity) {
return super.exportXls(request, commCity, CommCity.class, "城市列表");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, CommCity.class);
}
}

+ 63
- 0
module-common/src/main/java/org/jeecg/modules/commCity/entity/CommCity.java View File

@ -0,0 +1,63 @@
package org.jeecg.modules.commCity.entity;
import java.io.Serializable;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.UnsupportedEncodingException;
/**
* @Description: 城市列表
* @Author: jeecg-boot
* @Date: 2024-12-05
* @Version: V1.0
*/
@Data
@TableName("comm_city")
@ApiModel(value="comm_city对象", description="城市列表")
public class CommCity implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private java.lang.String id;
/**创建人*/
@ApiModelProperty(value = "创建人")
private java.lang.String createBy;
/**创建日期*/
@ApiModelProperty(value = "创建日期")
private java.util.Date createTime;
/**更新人*/
@ApiModelProperty(value = "更新人")
private java.lang.String updateBy;
/**更新日期*/
@ApiModelProperty(value = "更新日期")
private java.util.Date updateTime;
/**父级节点*/
@Excel(name = "父级节点", width = 15)
@ApiModelProperty(value = "父级节点")
private java.lang.String pid;
/**是否有子节点*/
@Excel(name = "是否有子节点", width = 15, dicCode = "yn")
@Dict(dicCode = "yn")
@ApiModelProperty(value = "是否有子节点")
private java.lang.String hasChild;
/**地址名称*/
@Excel(name = "地址名称", width = 15)
@ApiModelProperty(value = "地址名称")
private java.lang.String title;
/**排序*/
@Excel(name = "排序", width = 15)
@ApiModelProperty(value = "排序")
private java.lang.Integer sort;
}

+ 22
- 0
module-common/src/main/java/org/jeecg/modules/commCity/mapper/CommCityMapper.java View File

@ -0,0 +1,22 @@
package org.jeecg.modules.commCity.mapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.commCity.entity.CommCity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 城市列表
* @Author: jeecg-boot
* @Date: 2024-12-05
* @Version: V1.0
*/
public interface CommCityMapper extends BaseMapper<CommCity> {
/**
* 编辑节点状态
* @param id
* @param status
*/
void updateTreeNodeStatus(@Param("id") String id,@Param("status") String status);
}

+ 9
- 0
module-common/src/main/java/org/jeecg/modules/commCity/mapper/xml/CommCityMapper.xml View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.commCity.mapper.CommCityMapper">
<update id="updateTreeNodeStatus" parameterType="java.lang.String">
update comm_city set has_child = #{status} where id = #{id}
</update>
</mapper>

+ 38
- 0
module-common/src/main/java/org/jeecg/modules/commCity/service/ICommCityService.java View File

@ -0,0 +1,38 @@
package org.jeecg.modules.commCity.service;
import org.jeecg.modules.commCity.entity.CommCity;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.common.exception.JeecgBootException;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.List;
/**
* @Description: 城市列表
* @Author: jeecg-boot
* @Date: 2024-12-05
* @Version: V1.0
*/
public interface ICommCityService extends IService<CommCity> {
/**根节点父ID的值*/
public static final String ROOT_PID_VALUE = "0";
/**树节点有子节点状态值*/
public static final String HASCHILD = "1";
/**树节点无子节点状态值*/
public static final String NOCHILD = "0";
/**新增节点*/
void addCommCity(CommCity commCity);
/**修改节点*/
void updateCommCity(CommCity commCity) throws JeecgBootException;
/**删除节点*/
void deleteCommCity(String id) throws JeecgBootException;
/**查询所有数据,无分页*/
List<CommCity> queryTreeListNoPage(QueryWrapper<CommCity> queryWrapper);
}

+ 191
- 0
module-common/src/main/java/org/jeecg/modules/commCity/service/impl/CommCityServiceImpl.java View File

@ -0,0 +1,191 @@
package org.jeecg.modules.commCity.service.impl;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.commCity.entity.CommCity;
import org.jeecg.modules.commCity.mapper.CommCityMapper;
import org.jeecg.modules.commCity.service.ICommCityService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: 城市列表
* @Author: jeecg-boot
* @Date: 2024-12-05
* @Version: V1.0
*/
@Service
public class CommCityServiceImpl extends ServiceImpl<CommCityMapper, CommCity> implements ICommCityService {
@Override
public void addCommCity(CommCity commCity) {
//新增时设置hasChild为0
commCity.setHasChild(ICommCityService.NOCHILD);
if(oConvertUtils.isEmpty(commCity.getPid())){
commCity.setPid(ICommCityService.ROOT_PID_VALUE);
}else{
//如果当前节点父ID不为空 则设置父节点的hasChildren 为1
CommCity parent = baseMapper.selectById(commCity.getPid());
if(parent!=null && !"1".equals(parent.getHasChild())){
parent.setHasChild("1");
baseMapper.updateById(parent);
}
}
baseMapper.insert(commCity);
}
@Override
public void updateCommCity(CommCity commCity) {
CommCity entity = this.getById(commCity.getId());
if(entity==null) {
throw new JeecgBootException("未找到对应实体");
}
String old_pid = entity.getPid();
String new_pid = commCity.getPid();
if(!old_pid.equals(new_pid)) {
updateOldParentNode(old_pid);
if(oConvertUtils.isEmpty(new_pid)){
commCity.setPid(ICommCityService.ROOT_PID_VALUE);
}
if(!ICommCityService.ROOT_PID_VALUE.equals(commCity.getPid())) {
baseMapper.updateTreeNodeStatus(commCity.getPid(), ICommCityService.HASCHILD);
}
}
baseMapper.updateById(commCity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteCommCity(String id) throws JeecgBootException {
//查询选中节点下所有子节点一并删除
id = this.queryTreeChildIds(id);
if(id.indexOf(",")>0) {
StringBuffer sb = new StringBuffer();
String[] idArr = id.split(",");
for (String idVal : idArr) {
if(idVal != null){
CommCity commCity = this.getById(idVal);
String pidVal = commCity.getPid();
//查询此节点上一级是否还有其他子节点
List<CommCity> dataList = baseMapper.selectList(new QueryWrapper<CommCity>().eq("pid", pidVal).notIn("id",Arrays.asList(idArr)));
if((dataList == null || dataList.size()==0) && !Arrays.asList(idArr).contains(pidVal)
&& !sb.toString().contains(pidVal)){
//如果当前节点原本有子节点 现在木有了更新状态
sb.append(pidVal).append(",");
}
}
}
//批量删除节点
baseMapper.deleteBatchIds(Arrays.asList(idArr));
//修改已无子节点的标识
String[] pidArr = sb.toString().split(",");
for(String pid : pidArr){
this.updateOldParentNode(pid);
}
}else{
CommCity commCity = this.getById(id);
if(commCity==null) {
throw new JeecgBootException("未找到对应实体");
}
updateOldParentNode(commCity.getPid());
baseMapper.deleteById(id);
}
}
@Override
public List<CommCity> queryTreeListNoPage(QueryWrapper<CommCity> queryWrapper) {
List<CommCity> dataList = baseMapper.selectList(queryWrapper);
List<CommCity> mapList = new ArrayList<>();
for(CommCity data : dataList){
String pidVal = data.getPid();
//递归查询子节点的根节点
if(pidVal != null && !"0".equals(pidVal)){
CommCity rootVal = this.getTreeRoot(pidVal);
if(rootVal != null && !mapList.contains(rootVal)){
mapList.add(rootVal);
}
}else{
if(!mapList.contains(data)){
mapList.add(data);
}
}
}
return mapList;
}
/**
* 根据所传pid查询旧的父级节点的子节点并修改相应状态值
* @param pid
*/
private void updateOldParentNode(String pid) {
// if(!ICommCityService.ROOT_PID_VALUE.equals(pid)) {
// Integer count = baseMapper.selectCount(new QueryWrapper<CommCity>().eq("pid", pid));
// if(count==null || count<=1) {
// baseMapper.updateTreeNodeStatus(pid, ICommCityService.NOCHILD);
// }
// }
}
/**
* 递归查询节点的根节点
* @param pidVal
* @return
*/
private CommCity getTreeRoot(String pidVal){
CommCity data = baseMapper.selectById(pidVal);
if(data != null && !"0".equals(data.getPid())){
return this.getTreeRoot(data.getPid());
}else{
return data;
}
}
/**
* 根据id查询所有子节点id
* @param ids
* @return
*/
private String queryTreeChildIds(String ids) {
//获取id数组
String[] idArr = ids.split(",");
StringBuffer sb = new StringBuffer();
for (String pidVal : idArr) {
if(pidVal != null){
if(!sb.toString().contains(pidVal)){
if(sb.toString().length() > 0){
sb.append(",");
}
sb.append(pidVal);
this.getTreeChildIds(pidVal,sb);
}
}
}
return sb.toString();
}
/**
* 递归查询所有子节点
* @param pidVal
* @param sb
* @return
*/
private StringBuffer getTreeChildIds(String pidVal,StringBuffer sb){
List<CommCity> dataList = baseMapper.selectList(new QueryWrapper<CommCity>().eq("pid", pidVal));
if(dataList != null && dataList.size()>0){
for(CommCity tree : dataList) {
if(!sb.toString().contains(tree.getId())){
sb.append(",").append(tree.getId());
}
this.getTreeChildIds(tree.getId(),sb);
}
}
return sb;
}
}

+ 353
- 0
module-common/src/main/java/org/jeecg/modules/commCity/vue/CommCityList.vue View File

@ -0,0 +1,353 @@
<template>
<a-card :bordered="false">
<!-- 查询区域 -->
<div class="table-page-search-wrapper">
<a-form layout="inline" @keyup.enter.native="searchQuery">
<a-row :gutter="24">
</a-row>
</a-form>
</div>
<!-- 查询区域-END -->
<!-- 操作按钮区域 -->
<div class="table-operator">
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
<a-button type="primary" icon="download" @click="handleExportXls('城市列表')">导出</a-button>
<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
<a-button type="primary" icon="import">导入</a-button>
</a-upload>
<!-- 高级查询区域 -->
<j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
<a-dropdown v-if="selectedRowKeys.length > 0">
<a-menu slot="overlay">
<a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
</a-menu>
<a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
</a-dropdown>
</div>
<!-- table区域-begin -->
<div>
<div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
<i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>
<a style="margin-left: 24px" @click="onClearSelected">清空</a>
</div>
<a-table
ref="table"
size="middle"
rowKey="id"
class="j-table-force-nowrap"
:scroll="{x:true}"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
:expandedRowKeys="expandedRowKeys"
@change="handleTableChange"
@expand="handleExpand"
v-bind="tableProps">
<template slot="imgSlot" slot-scope="text,record">
<span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
<img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
</template>
<template slot="fileSlot" slot-scope="text">
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
<a-button
v-else
:ghost="true"
type="primary"
icon="download"
size="small"
@click="downloadFile(text)">
下载
</a-button>
</template>
<span slot="action" slot-scope="text, record">
<a @click="handleEdit(record)">编辑</a>
<a-divider type="vertical" />
<a-dropdown>
<a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
<a-menu slot="overlay">
<a-menu-item>
<a @click="handleAddChild(record)">添加下级</a>
</a-menu-item>
<a-menu-item>
<a-popconfirm title="确定删除吗?" @confirm="() => handleDeleteNode(record.id)" placement="topLeft">
<a>删除</a>
</a-popconfirm>
</a-menu-item>
</a-menu>
</a-dropdown>
</span>
</a-table>
</div>
<commCity-modal ref="modalForm" @ok="modalFormOk"></commCity-modal>
</a-card>
</template>
<script>
import { getAction, deleteAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import CommCityModal from './modules/CommCityModal'
import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
import { filterObj } from '@/utils/util';
export default {
name: "CommCityList",
mixins:[JeecgListMixin],
components: {
CommCityModal
},
data () {
return {
description: '城市列表管理页面',
//
columns: [
{
title:'地址名称',
align:"left",
dataIndex: 'title'
},
{
title:'排序',
align:"left",
dataIndex: 'sort'
},
{
title: '操作',
dataIndex: 'action',
align:"center",
fixed:"right",
width:147,
scopedSlots: { customRender: 'action' },
}
],
url: {
list: "/commCity/commCity/rootList",
childList: "/commCity/commCity/childList",
getChildListBatch: "/commCity/commCity/getChildListBatch",
delete: "/commCity/commCity/delete",
deleteBatch: "/commCity/commCity/deleteBatch",
exportXlsUrl: "/commCity/commCity/exportXls",
importExcelUrl: "commCity/commCity/importExcel",
},
expandedRowKeys:[],
hasChildrenField:"hasChild",
pidField:"pid",
dictOptions: {},
loadParent: false,
superFieldList:[],
}
},
created() {
this.getSuperFieldList();
},
computed: {
importExcelUrl(){
return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
},
tableProps() {
let _this = this
return {
//
rowSelection: {
selectedRowKeys: _this.selectedRowKeys,
onChange: (selectedRowKeys) => _this.selectedRowKeys = selectedRowKeys
}
}
}
},
methods: {
loadData(arg){
if(arg==1){
this.ipagination.current=1
}
this.loading = true
let params = this.getQueryParams()
params.hasQuery = 'true'
getAction(this.url.list,params).then(res=>{
if(res.success){
let result = res.result
if(Number(result.total)>0){
this.ipagination.total = Number(result.total)
this.dataSource = this.getDataByResult(res.result.records)
return this.loadDataByExpandedRows(this.dataSource)
}else{
this.ipagination.total=0
this.dataSource=[]
}
}else{
this.$message.warning(res.message)
}
}).finally(()=>{
this.loading = false
})
},
//
loadDataByExpandedRows(dataList) {
if (this.expandedRowKeys.length > 0) {
return getAction(this.url.getChildListBatch,{ parentIds: this.expandedRowKeys.join(',') }).then(res=>{
if (res.success && res.result.records.length>0) {
//
let records = res.result.records
const listMap = new Map();
for (let item of records) {
let pid = item[this.pidField];
if (this.expandedRowKeys.join(',').includes(pid)) {
let mapList = listMap.get(pid);
if (mapList == null) {
mapList = [];
}
mapList.push(item);
listMap.set(pid, mapList);
}
}
let childrenMap = listMap;
let fn = (list) => {
if(list) {
list.forEach(data => {
if (this.expandedRowKeys.includes(data.id)) {
data.children = this.getDataByResult(childrenMap.get(data.id))
fn(data.children)
}
})
}
}
fn(dataList)
}
})
} else {
return Promise.resolve()
}
},
getQueryParams(arg) {
//
let sqp = {}
let param = {}
if(this.superQueryParams){
sqp['superQueryParams']=encodeURI(this.superQueryParams)
sqp['superQueryMatchType'] = this.superQueryMatchType
}
if(arg){
param = Object.assign(sqp, this.isorter ,this.filters);
}else{
param = Object.assign(sqp, this.queryParam, this.isorter ,this.filters);
}
if(JSON.stringify(this.queryParam) === "{}" || arg){
param.hasQuery = 'false'
}else{
param.hasQuery = 'true'
}
param.field = this.getQueryField();
param.pageNo = this.ipagination.current;
param.pageSize = this.ipagination.pageSize;
return filterObj(param);
},
searchReset() {
//
this.expandedRowKeys = []
this.queryParam = {}
this.loadData(1);
},
getDataByResult(result){
if(result){
return result.map(item=>{
//
if(item[this.hasChildrenField]=='1'){
let loadChild = { id: item.id+'_loadChild', name: 'loading...', isLoading: true }
item.children = [loadChild]
}
return item
})
}
},
handleExpand(expanded, record){
//
if (expanded) {
this.expandedRowKeys.push(record.id)
if (record.children.length>0 && record.children[0].isLoading === true) {
let params = this.getQueryParams(1);//
params[this.pidField] = record.id
params.hasQuery = 'false'
params.superQueryParams=""
getAction(this.url.childList,params).then((res)=>{
if(res.success){
if(res.result.records){
record.children = this.getDataByResult(res.result.records)
this.dataSource = [...this.dataSource]
}else{
record.children=''
record.hasChildrenField='0'
}
}else{
this.$message.warning(res.message)
}
})
}
}else{
let keyIndex = this.expandedRowKeys.indexOf(record.id)
if(keyIndex>=0){
this.expandedRowKeys.splice(keyIndex, 1);
}
}
},
handleAddChild(record){
this.loadParent = true
let obj = {}
obj[this.pidField] = record['id']
this.$refs.modalForm.add(obj);
},
handleDeleteNode(id) {
if(!this.url.delete){
this.$message.error("请设置url.delete属性!")
return
}
var that = this;
deleteAction(that.url.delete, {id: id}).then((res) => {
if (res.success) {
that.loadData(1)
} else {
that.$message.warning(res.message);
}
});
},
batchDel(){
if(this.selectedRowKeys.length<=0){
this.$message.warning('请选择一条记录!');
return false;
}else{
let ids = "";
let that = this;
that.selectedRowKeys.forEach(function(val) {
ids+=val+",";
});
that.$confirm({
title:"确认删除",
content:"是否删除选中数据?",
onOk: function(){
that.handleDeleteNode(ids)
that.onClearSelected();
}
});
}
},
getSuperFieldList(){
let fieldList=[];
fieldList.push({type:'string',value:'pid',text:'父级节点',dictCode:''})
fieldList.push({type:'string',value:'title',text:'地址名称',dictCode:''})
fieldList.push({type:'int',value:'sort',text:'排序',dictCode:''})
this.superFieldList = fieldList
}
}
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>

+ 156
- 0
module-common/src/main/java/org/jeecg/modules/commCity/vue/modules/CommCityModal.vue View File

@ -0,0 +1,156 @@
<template>
<j-modal
:title="title"
:width="width"
:visible="visible"
:confirmLoading="confirmLoading"
switchFullscreen
@ok="handleOk"
@cancel="handleCancel"
cancelText="关闭">
<a-spin :spinning="confirmLoading">
<a-form-model ref="form" :model="model" :rules="validatorRules">
<a-form-model-item label="父级节点" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pid">
<j-tree-select
ref="treeSelect"
placeholder="请选择父级节点"
v-model="model.pid"
dict="comm_city,name,id"
pidField="pid"
pidValue="0"
hasChildField="has_child"
>
</j-tree-select>
</a-form-model-item>
<a-form-model-item label="地址名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="title">
<a-input v-model="model.title" placeholder="请输入地址名称" ></a-input>
</a-form-model-item>
<a-form-model-item label="排序" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sort">
<a-input-number v-model="model.sort" placeholder="请输入排序" style="width: 100%" />
</a-form-model-item>
</a-form-model>
</a-spin>
</j-modal>
</template>
<script>
import { httpAction } from '@/api/manage'
import { validateDuplicateValue } from '@/utils/util'
export default {
name: "CommCityModal",
components: {
},
data () {
return {
title:"操作",
width:800,
visible: false,
model:{
},
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
confirmLoading: false,
validatorRules: {
},
url: {
add: "/commCity/commCity/add",
edit: "/commCity/commCity/edit",
},
expandedRowKeys:[],
pidField:"pid"
}
},
created () {
//model
this.modelDefault = JSON.parse(JSON.stringify(this.model));
},
methods: {
add (obj) {
this.modelDefault.pid=''
this.edit(Object.assign(this.modelDefault , obj));
},
edit (record) {
this.model = Object.assign({}, record);
this.visible = true;
},
close () {
this.$emit('close');
this.visible = false;
this.$refs.form.clearValidate()
},
handleOk () {
const that = this;
//
this.$refs.form.validate(valid => {
if (valid) {
that.confirmLoading = true;
let httpurl = '';
let method = '';
if(!this.model.id){
httpurl+=this.url.add;
method = 'post';
}else{
httpurl+=this.url.edit;
method = 'put';
}
if(this.model.id && this.model.id === this.model[this.pidField]){
that.$message.warning("父级节点不能选择自己");
that.confirmLoading = false;
return;
}
httpAction(httpurl,this.model,method).then((res)=>{
if(res.success){
that.$message.success(res.message);
this.$emit('ok');
}else{
that.$message.warning(res.message);
}
}).finally(() => {
that.confirmLoading = false;
that.close();
})
}else{
return false
}
})
},
handleCancel () {
this.close()
},
submitSuccess(formData,flag){
if(!formData.id){
let treeData = this.$refs.treeSelect.getCurrTreeData()
this.expandedRowKeys=[]
this.getExpandKeysByPid(formData[this.pidField],treeData,treeData)
this.$emit('ok',formData,this.expandedRowKeys.reverse());
}else{
this.$emit('ok',formData,flag);
}
},
getExpandKeysByPid(pid,arr,all){
if(pid && arr && arr.length>0){
for(let i=0;i<arr.length;i++){
if(arr[i].key==pid){
this.expandedRowKeys.push(arr[i].key)
this.getExpandKeysByPid(arr[i]['parentId'],all,all)
}else{
this.getExpandKeysByPid(pid,arr[i].children,all)
}
}
}
}
}
}
</script>

+ 82
- 0
module-common/src/main/java/org/jeecg/modules/commCity/vue3/CommCity.api.ts View File

@ -0,0 +1,82 @@
import {defHttp} from "/@/utils/http/axios";
import {Modal} from 'ant-design-vue';
enum Api {
list = '/commCity/commCity/rootList',
save='/commCity/commCity/add',
edit='/commCity/commCity/edit',
deleteCommCity = '/sys/commCity/delete',
deleteBatch = '/commCity/commCity/deleteBatch',
importExcel = '/commCity/commCity/importExcel',
exportXls = '/commCity/commCity/exportXls',
loadTreeData = '/commCity/commCity/loadTreeRoot',
getChildList = '/commCity/commCity/childList',
getChildListBatch = '/commCity/commCity/getChildListBatch',
}
/**
* api
* @param params
*/
export const getExportUrl = Api.exportXls;
/**
* api
* @param params
*/
export const getImportUrl = Api.importExcel;
/**
*
* @param params
*/
export const list = (params) =>
defHttp.get({url: Api.list, params});
/**
*
*/
export const deleteCommCity = (params,handleSuccess) => {
return defHttp.delete({url: Api.deleteCommCity, params}, {joinParamsToUrl: true}).then(() => {
handleSuccess();
});
}
/**
*
* @param params
*/
export const batchDeleteCommCity = (params, handleSuccess) => {
Modal.confirm({
title: '确认删除',
content: '是否删除选中数据',
okText: '确认',
cancelText: '取消',
onOk: () => {
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
handleSuccess();
});
}
});
}
/**
*
* @param params
*/
export const saveOrUpdateDict = (params, isUpdate) => {
let url = isUpdate ? Api.edit : Api.save;
return defHttp.post({url: url, params});
}
/**
*
* @param params
*/
export const loadTreeData = (params) =>
defHttp.get({url: Api.loadTreeData,params});
/**
*
* @param params
*/
export const getChildList = (params) =>
defHttp.get({url: Api.getChildList, params});
/**
*
* @param params
*/
export const getChildListBatch = (params) =>
defHttp.get({url: Api.getChildListBatch, params},{isTransformResponse:false});

+ 38
- 0
module-common/src/main/java/org/jeecg/modules/commCity/vue3/CommCity.data.ts View File

@ -0,0 +1,38 @@
import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
{
title: '地址名称',
align:"center",
dataIndex: 'title'
},
{
title: '排序',
align:"center",
dataIndex: 'sort'
},
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
{
label: '父级节点',
field: 'pid',
component: 'Input',
},
{
label: '地址名称',
field: 'title',
component: 'Input',
},
{
label: '排序',
field: 'sort',
component: 'InputNumber',
},
];

+ 272
- 0
module-common/src/main/java/org/jeecg/modules/commCity/vue3/CommCityList.vue View File

@ -0,0 +1,272 @@
<template>
<div class="p-4">
<!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection" :expandedRowKeys="expandedRowKeys" @expand="handleExpand" @fetch-success="onFetchSuccess">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" @click="handleCreate" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0">
<template #overlay>
<a-menu>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined"></Icon>
删除
</a-menu-item>
</a-menu>
</template>
<a-button>批量操作
<Icon icon="ant-design:down-outlined"></Icon>
</a-button>
</a-dropdown>
</template>
<!--操作栏-->
<template #action="{ record }">
<TableAction :actions="getTableAction(record)"/>
</template>
</BasicTable>
<!--字典弹窗-->
<CommCityModal @register="registerModal" @success="handleSuccess"/>
</div>
</template>
<script lang="ts" name="commCity-commCity" setup>
//ts
import {ref, computed, unref, toRaw, nextTick} from 'vue';
import {BasicTable, useTable, TableAction} from '/src/components/Table';
import {useModal} from '/src/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage'
import CommCityModal from './components/CommCityModal.vue';
import {columns} from './CommCity.data';
import {list, deleteCommCity, batchDeleteCommCity, getExportUrl,getImportUrl, getChildList,getChildListBatch} from './CommCity.api';
const expandedRowKeys = ref([]);
//model
const [registerModal, {openModal}] = useModal();
//table
const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({
tableProps:{
title: '城市列表',
columns,
canResize:false,
actionColumn: {
width: 120,
},
},
exportConfig: {
name:"城市列表",
url: getExportUrl,
},
importConfig: {
url: getImportUrl,
success: importSuccess
},
})
const [registerTable, {reload, collapseAll, updateTableDataRecord, findTableDataRecord,getDataSource},{ rowSelection, selectedRowKeys }] = tableContext
/**
* 新增事件
*/
function handleCreate() {
openModal(true, {
isUpdate: false,
});
}
/**
* 编辑事件
*/
async function handleEdit(record) {
openModal(true, {
record,
isUpdate: true,
});
}
/**
* 详情
*/
async function handleDetail(record) {
openModal(true, {
record,
isUpdate: true,
hideFooter: true,
});
}
/**
* 删除事件
*/
async function handleDelete(record) {
await deleteCommCity({id: record.id}, importSuccess);
}
/**
* 批量删除事件
*/
async function batchHandleDelete() {
const ids = selectedRowKeys.value.filter(item => !item.includes('loading'))
await batchDeleteCommCity({ids: ids}, importSuccess);
}
/**
* 导入
*/
function importSuccess() {
reload() && (expandedRowKeys.value = []);
}
/**
* 添加下级
*/
function handleAddSub(record) {
openModal(true, {
record,
isUpdate: false,
});
}
/**
* 成功回调
*/
async function handleSuccess({isUpdate, values, expandedArr}) {
if (isUpdate) {
//
updateTableDataRecord(values.id, values);
} else {
if(!values['pid']){
//
reload();
}else{
//
expandedRowKeys.value = [];
for (let key of unref(expandedArr)) {
await expandTreeNode(key)
}
}
}
}
/**
* 接口请求成功后回调
*/
function onFetchSuccess(result) {
getDataByResult(result.items)&&loadDataByExpandedRows();
}
/**
* 根据已展开的行查询数据用于保存后刷新时异步加载子级的数据
*/
async function loadDataByExpandedRows() {
if (unref(expandedRowKeys).length > 0) {
const res = await getChildListBatch({ parentIds: unref(expandedRowKeys).join(',')});
if (res.success && res.result.records.length>0) {
//
let records = res.result.records
const listMap = new Map();
for (let item of records) {
let pid = item['pid'];
if (unref(expandedRowKeys).includes(pid)) {
let mapList = listMap.get(pid);
if (mapList == null) {
mapList = [];
}
mapList.push(item);
listMap.set(pid, mapList);
}
}
let childrenMap = listMap;
let fn = (list) => {
if(list) {
list.forEach(data => {
if (unref(expandedRowKeys).includes(data.id)) {
data.children = getDataByResult(childrenMap.get(data.id))
fn(data.children)
}
})
}
};
fn(getDataSource())
}
}
}
/**
* 处理数据集
*/
function getDataByResult(result){
if(result && result.length>0){
return result.map(item=>{
//
if(item["hasChild"]=='1'){
let loadChild = { id: item.id+'_loadChild', name: 'loading...', isLoading: true }
item.children = [loadChild]
}
return item
})
}
}
/**
*树节点展开合并
* */
async function handleExpand(expanded, record) {
// (expanded)(children)(isLoading)
if (expanded) {
expandedRowKeys.value.push(record.id)
if (record.children.length > 0 && !!record.children[0].isLoading) {
let result = await getChildList({pid: record.id});
result=result.records?result.records:result;
if (result && result.length > 0) {
record.children = getDataByResult(result);
} else {
record.children = null
record.hasChild = '0'
}
}
} else {
let keyIndex = expandedRowKeys.value.indexOf(record.id)
if (keyIndex >= 0) {
expandedRowKeys.value.splice(keyIndex, 1);
}
}
}
/**
*操作表格后处理树节点展开合并
* */
async function expandTreeNode(key) {
let record = findTableDataRecord(key)
expandedRowKeys.value.push(key);
let result = await getChildList({pid: key});
if (result && result.length > 0) {
record.children = getDataByResult(result);
} else {
record.children = null
record.hasChild = '0'
}
updateTableDataRecord(key, record);
}
/**
* 操作栏
*/
function getTableAction(record) {
return [
{
label: '编辑',
onClick: handleEdit.bind(null, record),
},
{
label: '删除',
popConfirm: {
title: '确定删除吗?',
confirm: handleDelete.bind(null, record),
},
},
{
label: '添加下级',
onClick: handleAddSub.bind(null, {pid: record.id}),
}
]
}
</script>
<style scoped>
</style>

+ 87
- 0
module-common/src/main/java/org/jeecg/modules/commCity/vue3/components/CommCityModal.vue View File

@ -0,0 +1,87 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit">
<BasicForm @register="registerForm"/>
</BasicModal>
</template>
<script lang="ts" setup>
import {ref, computed, unref} from 'vue';
import {BasicModal, useModalInner} from '/src/components/Modal';
import {BasicForm, useForm} from '/src/components/Form';
import {formSchema} from '../commCity.data';
import {loadTreeData, saveOrUpdateDict} from '../commCity.api';
// emit
const emit = defineEmits(['register', 'success']);
const isUpdate = ref(true);
const expandedRowKeys = ref([]);
const treeData = ref([]);
//
const [registerForm, {resetFields, setFieldsValue, validate, updateSchema}] = useForm({
schemas: formSchema,
showActionButtonGroup: false,
labelCol: {
xs: { span: 24 },
sm: { span: 4 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 18 },
},
});
//
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => {
//
await resetFields();
expandedRowKeys.value = [];
setModalProps({confirmLoading: false, minHeight: 80});
isUpdate.value = !!data?.isUpdate;
if (data?.record) {
//
await setFieldsValue({
...data.record,
});
}
//
treeData.value = await loadTreeData({'async': false,'pcode':''});
updateSchema({
field: 'pid',
componentProps: {treeData},
});
});
//
const getTitle = computed(() => (!unref(isUpdate) ? '新增字典' : '编辑字典'));
/**
* 根据pid获取展开的节点
* @param pid
* @param arr
*/
function getExpandKeysByPid(pid,arr){
if(pid && arr && arr.length>0){
for(let i=0;i<arr.length;i++){
if(arr[i].key==pid && unref(expandedRowKeys).indexOf(pid)<0){
expandedRowKeys.value.push(arr[i].key);
getExpandKeysByPid(arr[i]['parentId'],unref(treeData))
}else{
getExpandKeysByPid(pid,arr[i].children)
}
}
}
}
//
async function handleSubmit() {
try {
let values = await validate();
setModalProps({confirmLoading: true});
//
await saveOrUpdateDict(values, isUpdate.value);
//
closeModal();
//
await getExpandKeysByPid(values['pid'],unref(treeData))
//(isUpdate:;values:;expandedArr:)
emit('success', {isUpdate: unref(isUpdate), values:{...values},expandedArr: unref(expandedRowKeys).reverse()});
} finally {
setModalProps({confirmLoading: false});
}
}
</script>

+ 1
- 1
module-common/src/main/java/org/jeecg/modules/commonHome/controller/CommonHomeController.java View File

@ -39,7 +39,7 @@ import org.jeecg.common.aspect.annotation.AutoLog;
/**
* @Description: 房源信息表
* @Author: jeecg-boot
* @Date: 2024-12-03
* @Date: 2024-12-05
* @Version: V1.0
*/
@Api(tags="房源信息表")


+ 14
- 1
module-common/src/main/java/org/jeecg/modules/commonHome/entity/CommonHome.java View File

@ -20,7 +20,7 @@ import lombok.experimental.Accessors;
/**
* @Description: 房源信息表
* @Author: jeecg-boot
* @Date: 2024-12-03
* @Date: 2024-12-05
* @Version: V1.0
*/
@Data
@ -225,4 +225,17 @@ public class CommonHome implements Serializable {
@Excel(name = "用户", width = 15)
@ApiModelProperty(value = "用户")
private java.lang.String userId;
/**经度*/
@Excel(name = "经度", width = 15)
@ApiModelProperty(value = "经度")
private java.lang.String longitude;
/**纬度*/
@Excel(name = "纬度", width = 15)
@ApiModelProperty(value = "纬度")
private java.lang.String latitude;
/**所属区域*/
@Excel(name = "所属区域", width = 15, dictTable = "common_icon_image", dicText = "title", dicCode = "id")
@Dict(dictTable = "common_icon_image", dicText = "title", dicCode = "id")
@ApiModelProperty(value = "所属区域")
private java.lang.String iconClass;
}

+ 1
- 1
module-common/src/main/java/org/jeecg/modules/commonHome/mapper/CommonHomeMapper.java View File

@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 房源信息表
* @Author: jeecg-boot
* @Date: 2024-12-03
* @Date: 2024-12-05
* @Version: V1.0
*/
public interface CommonHomeMapper extends BaseMapper<CommonHome> {


+ 1
- 1
module-common/src/main/java/org/jeecg/modules/commonHome/service/ICommonHomeService.java View File

@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: 房源信息表
* @Author: jeecg-boot
* @Date: 2024-12-03
* @Date: 2024-12-05
* @Version: V1.0
*/
public interface ICommonHomeService extends IService<CommonHome> {


+ 1
- 1
module-common/src/main/java/org/jeecg/modules/commonHome/service/impl/CommonHomeServiceImpl.java View File

@ -10,7 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: 房源信息表
* @Author: jeecg-boot
* @Date: 2024-12-03
* @Date: 2024-12-05
* @Version: V1.0
*/
@Service


+ 25
- 0
module-common/src/main/java/org/jeecg/modules/commonHome/vue/CommonHomeList.vue View File

@ -14,6 +14,13 @@
<j-search-select-tag placeholder="请选择所属分类" v-model="queryParam.commonClass" dict="common_icon_image,title,id"/>
</a-form-item>
</a-col>
<template v-if="toggleSearchStatus">
<a-col :xl="6" :lg="7" :md="8" :sm="24">
<a-form-item label="所属区域">
<j-search-select-tag placeholder="请选择所属区域" v-model="queryParam.iconClass" dict="common_icon_image,title,id"/>
</a-form-item>
</a-col>
</template>
<a-col :xl="6" :lg="7" :md="8" :sm="24">
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
<a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
@ -373,6 +380,21 @@
align:"center",
dataIndex: 'userId'
},
{
title:'经度',
align:"center",
dataIndex: 'longitude'
},
{
title:'纬度',
align:"center",
dataIndex: 'latitude'
},
{
title:'所属区域',
align:"center",
dataIndex: 'iconClass_dictText'
},
{
title: '操作',
dataIndex: 'action',
@ -452,6 +474,9 @@
fieldList.push({type:'Text',value:'homeImage',text:'产权证照片',dictCode:''})
fieldList.push({type:'Text',value:'homeBz',text:'备注',dictCode:''})
fieldList.push({type:'string',value:'userId',text:'用户',dictCode:''})
fieldList.push({type:'string',value:'longitude',text:'经度',dictCode:''})
fieldList.push({type:'string',value:'latitude',text:'纬度',dictCode:''})
fieldList.push({type:'sel_search',value:'iconClass',text:'所属区域',dictTable:"common_icon_image", dictText:'title', dictCode:'id'})
this.superFieldList = fieldList
}
}


+ 15
- 0
module-common/src/main/java/org/jeecg/modules/commonHome/vue/modules/CommonHomeForm.vue View File

@ -223,6 +223,21 @@
<a-input v-model="model.userId" placeholder="请输入用户" ></a-input>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="经度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="longitude">
<a-input v-model="model.longitude" placeholder="请输入经度" ></a-input>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="纬度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="latitude">
<a-input v-model="model.latitude" placeholder="请输入纬度" ></a-input>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="所属区域" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="iconClass">
<j-search-select-tag v-model="model.iconClass" dict="common_icon_image,title,id" />
</a-form-model-item>
</a-col>
</a-row>
</a-form-model>
</j-form-container>


+ 42
- 0
module-common/src/main/java/org/jeecg/modules/commonHome/vue3/CommonHome.data.ts View File

@ -235,6 +235,21 @@ export const columns: BasicColumn[] = [
align:"center",
dataIndex: 'userId'
},
{
title: '经度',
align:"center",
dataIndex: 'longitude'
},
{
title: '纬度',
align:"center",
dataIndex: 'latitude'
},
{
title: '所属区域',
align:"center",
dataIndex: 'iconClass_dictText'
},
];
//查询数据
export const searchFormSchema: FormSchema[] = [
@ -256,6 +271,15 @@ export const searchFormSchema: FormSchema[] = [
},
colProps: {span: 6},
},
{
label: "所属区域",
field: "iconClass",
component: 'JSearchSelect',
componentProps:{
dict:"common_icon_image,title,id"
},
colProps: {span: 6},
},
];
//表单数据
export const formSchema: FormSchema[] = [
@ -495,4 +519,22 @@ export const formSchema: FormSchema[] = [
field: 'userId',
component: 'Input',
},
{
label: '经度',
field: 'longitude',
component: 'Input',
},
{
label: '纬度',
field: 'latitude',
component: 'Input',
},
{
label: '所属区域',
field: 'iconClass',
component: 'JSearchSelect',
componentProps:{
dict:"common_icon_image,title,id"
},
},
];

+ 1
- 1
module-common/src/main/java/org/jeecg/modules/commonNews/controller/CommonNewsController.java View File

@ -39,7 +39,7 @@ import org.jeecg.common.aspect.annotation.AutoLog;
/**
* @Description: 新闻动态表
* @Author: jeecg-boot
* @Date: 2024-12-03
* @Date: 2024-12-05
* @Version: V1.0
*/
@Api(tags="新闻动态表")


+ 9
- 1
module-common/src/main/java/org/jeecg/modules/commonNews/entity/CommonNews.java View File

@ -20,7 +20,7 @@ import lombok.experimental.Accessors;
/**
* @Description: 新闻动态表
* @Author: jeecg-boot
* @Date: 2024-12-03
* @Date: 2024-12-05
* @Version: V1.0
*/
@Data
@ -80,4 +80,12 @@ public class CommonNews implements Serializable {
@Dict(dictTable = "han_hai_member", dicText = "nick_name", dicCode = "id")
@ApiModelProperty(value = "发布人")
private java.lang.String userId;
/**说明*/
@Excel(name = "说明", width = 15)
@ApiModelProperty(value = "说明")
private java.lang.String descValue;
/**图标*/
@Excel(name = "图标", width = 15)
@ApiModelProperty(value = "图标")
private java.lang.String logoImage;
}

+ 1
- 1
module-common/src/main/java/org/jeecg/modules/commonNews/mapper/CommonNewsMapper.java View File

@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 新闻动态表
* @Author: jeecg-boot
* @Date: 2024-12-03
* @Date: 2024-12-05
* @Version: V1.0
*/
public interface CommonNewsMapper extends BaseMapper<CommonNews> {


+ 1
- 1
module-common/src/main/java/org/jeecg/modules/commonNews/service/ICommonNewsService.java View File

@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: 新闻动态表
* @Author: jeecg-boot
* @Date: 2024-12-03
* @Date: 2024-12-05
* @Version: V1.0
*/
public interface ICommonNewsService extends IService<CommonNews> {


+ 1
- 1
module-common/src/main/java/org/jeecg/modules/commonNews/service/impl/CommonNewsServiceImpl.java View File

@ -10,7 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: 新闻动态表
* @Author: jeecg-boot
* @Date: 2024-12-03
* @Date: 2024-12-05
* @Version: V1.0
*/
@Service


+ 13
- 6
module-common/src/main/java/org/jeecg/modules/commonNews/vue/CommonNewsList.vue View File

@ -139,12 +139,6 @@
dataIndex: 'image',
scopedSlots: {customRender: 'imgSlot'}
},
{
title:'星闻内容',
align:"center",
dataIndex: 'details',
scopedSlots: {customRender: 'htmlSlot'}
},
{
title:'价格',
align:"center",
@ -171,6 +165,17 @@
align:"center",
dataIndex: 'userId_dictText'
},
{
title:'说明',
align:"center",
dataIndex: 'descValue'
},
{
title:'图标',
align:"center",
dataIndex: 'logoImage',
scopedSlots: {customRender: 'imgSlot'}
},
{
title: '操作',
dataIndex: 'action',
@ -214,6 +219,8 @@
fieldList.push({type:'string',value:'titleSub',text:'说明',dictCode:''})
fieldList.push({type:'Text',value:'iconMp',text:'视频',dictCode:''})
fieldList.push({type:'sel_search',value:'userId',text:'发布人',dictTable:"han_hai_member", dictText:'nick_name', dictCode:'id'})
fieldList.push({type:'string',value:'descValue',text:'说明',dictCode:''})
fieldList.push({type:'Text',value:'logoImage',text:'图标',dictCode:''})
this.superFieldList = fieldList
}
}


+ 10
- 0
module-common/src/main/java/org/jeecg/modules/commonNews/vue/modules/CommonNewsForm.vue View File

@ -43,6 +43,16 @@
<j-search-select-tag v-model="model.userId" dict="han_hai_member,nick_name,id" />
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="说明" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="descValue">
<a-input v-model="model.descValue" placeholder="请输入说明" ></a-input>
</a-form-model-item>
</a-col>
<a-col :span="24">
<a-form-model-item label="图标" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="logoImage">
<j-image-upload isMultiple v-model="model.logoImage" ></j-image-upload>
</a-form-model-item>
</a-col>
</a-row>
</a-form-model>
</j-form-container>


+ 23
- 6
module-common/src/main/java/org/jeecg/modules/commonNews/vue3/CommonNews.data.ts View File

@ -21,12 +21,6 @@ export const columns: BasicColumn[] = [
dataIndex: 'image',
customRender:render.renderAvatar,
},
{
title: '星闻内容',
align:"center",
dataIndex: 'details',
slots: { customRender: 'htmlSlot' },
},
{
title: '价格',
align:"center",
@ -53,6 +47,17 @@ export const columns: BasicColumn[] = [
align:"center",
dataIndex: 'userId_dictText'
},
{
title: '说明',
align:"center",
dataIndex: 'descValue'
},
{
title: '图标',
align:"center",
dataIndex: 'logoImage',
customRender:render.renderAvatar,
},
];
//查询数据
export const searchFormSchema: FormSchema[] = [
@ -106,4 +111,16 @@ export const formSchema: FormSchema[] = [
dict:"han_hai_member,nick_name,id"
},
},
{
label: '说明',
field: 'descValue',
component: 'Input',
},
{
label: '图标',
field: 'logoImage',
component: 'JImageUpload',
componentProps:{
},
},
];

Loading…
Cancel
Save