• Jeecg-boot中的popup弹框使用(基于表p_user_info),表格显示添加其它关联表的字段


    1、在Online表单开发中的页面属性设置fixed_point_itype_id字段为popup弹框;

    2、在‘校验字段’中输入:

    字典Table:fixed_point_itype_id

    字典Code:id,city,county,org_name,windows

    字典Text:fixed_point_itype_id,city,county,org_name,windows

    并在高级里面选择‘单选’:(请根据实现情况选择单、多选)

    之后测试功能,若已经符合功能需求,生成代码:

    3、复制文件到相应的文件夹:

    根据生成的sql文件生成权限、菜单。

    4、重新发布java后台,并测试。

    5、修改UserInfo.data.ts文件中的BasicColumn关联标识fixedPointItypeId为fixedPointItypeId_dictText,让表格中的Id显示为对应的值。本步骤非必要。

    6、在UserInfoForm.vue中添加以下关联字段city,county,org_name,windows代码:

    1. <a-col :span="24">
    2. <a-form-item label="城市" v-bind="validateInfos.city">
    3. <a-input readOnly v-model:value="formData.city" placeholder="请输入城市" :disabled="disabled">a-input>
    4. a-form-item>
    5. a-col>
    6. <a-col :span="24">
    7. <a-form-item label="区县" v-bind="validateInfos.county">
    8. <a-input readOnly v-model:value="formData.county" placeholder="请输入区县" :disabled="disabled">a-input>
    9. a-form-item>
    10. a-col>
    11. <a-col :span="24">
    12. <a-form-item label="机构名称" v-bind="validateInfos.orgName">
    13. <a-input readOnly v-model:value="formData.orgName" placeholder="请输入机构名称" :disabled="disabled">a-input>
    14. a-form-item>
    15. a-col>
    16. <a-col :span="24">
    17. <a-form-item label="办理窗口" v-bind="validateInfos.windows">
    18. <a-input readOnly v-model:value="formData.windows" placeholder="请输入办理窗口" :disabled="disabled">a-input>
    19. a-form-item>
    20. a-col>

    7、在文件UserInfo.data.ts中的 BasicColumn[] 添加表格字段:

    1. {
    2. title: '城市',
    3. align: "center",
    4. dataIndex: 'city'
    5. },
    6. {
    7. title: '区县',
    8. align: "center",
    9. dataIndex: 'county'
    10. },
    11. { title: '机构名称',
    12. align: "center",
    13. dataIndex: 'orgName'
    14. },
    15. { title: '项目窗口',
    16. align: "center",
    17. dataIndex: 'windows',
    18. defaultHidden: true
    19. },

    在 FormSchema[] 中添加表单数据:

    1. {
    2. label: '城市',
    3. field: 'city',
    4. component: 'Input',
    5. },
    6. {
    7. label: '区县',
    8. field: 'county',
    9. component: 'Input',
    10. },
    11. {
    12. label: '机构名称',
    13. field: 'orgName',
    14. component: 'Input',
    15. },
    16. {
    17. label: '办理窗口',
    18. field: 'windows',
    19. component: 'Input',
    20. },

    8、后台java

    8.1、UserInfoMapper.xml:

    1. "1.0" encoding="UTF-8"?>
    2. mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
    3. <mapper namespace="org.jeecg.modules.xiaomai.setting.base.mapper.UserInfoMapper">
    4. <select id="pageList" resultType="org.jeecg.modules.xiaomai.setting.base.entity.UserInfo">
    5. SELECT u.*, p.city, p.county, p.org_name, i.windows FROM p_user_info u
    6. LEFT JOIN p_fixed_point_itype i ON u.fixed_point_itype_id = i.id
    7. LEFT JOIN p_fixed_point p ON i.fixed_point_id = p.id
    8. ${ew.customSqlSegment}
    9. select>
    10. mapper>

    其中的org.jeecg.modules.xiaomai.setting.base.entity.UserInfo为返回对象,可以另外创建新的VO对象,这里直接使用实现对象UserInfo,并在UserInfo里面添加对应的city等非同步数据的字段。

    8.2、UserIfno.java:

    1. @TableField(exist = false)
    2. @Excel(name = "城市", width = 15)
    3. @ApiModelProperty(value = "城市")
    4. private String city;
    5. @TableField(exist = false)
    6. @Excel(name = "区县", width = 15)
    7. @ApiModelProperty(value = "区县")
    8. private String county;
    9. @TableField(exist = false)
    10. @Excel(name = "机构名称", width = 15)
    11. @ApiModelProperty(value = "机构名称")
    12. private String orgName;
    13. @TableField(exist = false)
    14. @Excel(name = "办理窗口", width = 15)
    15. @ApiModelProperty(value = "办理窗口")
    16. private String windows;

    注意: @TableField(exist = false)

    若需要使用’关联标识‘的字典则可以直接添加: 

    @Dict(dictTable = "p_fixed_point_itype", dicText = "windows", dicCode = "id")

    1. /**关联标识*/
    2. @Excel(name = "关联标识", width = 15)
    3. @ApiModelProperty(value = "关联标识")
    4. @Dict(dictTable = "p_fixed_point_itype", dicText = "windows", dicCode = "id")
    5. private String fixedPointItypeId;

    8.3、UserInfoMapper.java:

    1. public interface UserInfoMapper extends BaseMapper {
    2. IPage pageList(IPage page, @Param(Constants.WRAPPER) Wrapper wrapper);
    3. }

    8.4、IUserInfoService.java,UserInfoServiceImpl.java:

    1. public interface IUserInfoService extends IService {
    2. IPage pageList(Page page, QueryWrapper queryWrapper);
    3. }
    4. public class UserInfoServiceImpl extends ServiceImpl implements IUserInfoService {
    5. @Resource
    6. private UserInfoMapper userInfoMapper;
    7. @Override
    8. public IPage pageList(Page page, QueryWrapper queryWrapper) {
    9. return userInfoMapper.pageList(page, queryWrapper);
    10. }
    11. }

    8.5、UserInfoController.java直接调用pageList

    1. @ApiOperation(value="用户扩展-分页列表查询", notes="用户扩展-分页列表查询")
    2. @GetMapping(value = "/list")
    3. public Result> queryPageList(UserInfo userInfo,
    4. @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
    5. @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
    6. HttpServletRequest req) {
    7. QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(userInfo, req.getParameterMap());
    8. Page page = new Page(pageNo, pageSize);
    9. // IPage pageList = userInfoService.page(page, queryWrapper);
    10. IPage pageList = userInfoService.pageList(page, queryWrapper);
    11. return Result.OK(pageList);
    12. }

    9、如页面默认值不正确

    在components/...Form.vue中添加下列代码:
    import {formData2String} from "@/utils/xm_tools";
    并在函数edit中使用formData2String:
     

    1. function edit(record) {
    2. nextTick(() => {
    3. resetFields();
    4. //赋值
    5. //Object.assign(formData, record);
    6. //数字转字符
    7. Object.assign(formData, formData2String(tmpData));
    8. });

    10、form页面默认值:
    在formData设置默认值,

    1. const formData = reactive<Record>({
    2. id: '',
    3. customerPageId: '',
    4. title: '',
    5. type: 1,
    6. content: '',
    7. orderbyNum: 1,
    8. });


    在add方法中使用formData代替{}:
     

    1. function add() {
    2. edit(formData/*{}*/);
    3. }

    附:

    1. export function formData2String(formData) {
    2. if(!formData){
    3. return formData;
    4. }
    5. // 其实是jquery中$.isNumeric的源码,多么简洁且优雅。
    6. //!isNaN(parseFloat(value)) && isFinite(value);
    7. //输出对象内的属性值👇
    8. console.log("打印👉属性值");//打印👉属性值
    9. console.log(formData);//打印👉属性值
    10. for (let propName in formData) {
    11. console.log(formData[propName]);//打印👉属性值
    12. if(isNumber(formData[propName])){
    13. formData[propName] = formData[propName] + "";
    14. }
    15. }
    16. return formData;
    17. }

  • 相关阅读:
    问题 R: 超级楼梯(递推,基础DP)查表
    tomcat安装与基本使用
    Springboot毕设项目美食点评系统gb9o5(java+VUE+Mybatis+Maven+Mysql)
    对Redis布隆过滤器的实现
    Linux下的常见指令及权限理解(上)
    [附源码]SSM计算机毕业设计拾穗在线培训考试系统JAVA
    Excel 文件比较工具 xlCompare 11.01 Crack
    Java学习多态之向上转型
    『力扣每日一题11』:转换成小写字母
    Python实现人工神经网络回归模型(MLPRegressor算法)并基于网格搜索(GridSearchCV)进行优化项目实战
  • 原文地址:https://blog.csdn.net/ptianfeng/article/details/138147020