在列表页message.html添加权限

var detailFlag = [[${@permission.hasPermi('system:message:detail')}]];

添加访问路径

detailUrl: prefix + "/detail/{id}",

添加查看详情按钮

actions.push('<a class="btn btn-info btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.messageId + '\')"><i class="fa fa-edit"></i>查看详情</a> ');

若依的ry-ui.js文件中有查看详情功能,不用手动添加

// 详细信息
            detail: function(id, width, height) {
            	table.set();
            	var _url = $.operate.detailUrl(id);
            	var options = {
                    title: table.options.modalName + "详细",
                    width: width,
                    height: height,
                    url: _url,
                    skin: 'layui-layer-gray', 
                    btn: ['关闭'],
                    yes: function (index, layero) {
                        layer.close(index);
                    }
                };
            	$.modal.openOptions(options);
            },
            // 详细访问地址
            detailUrl: function(id) {
            	var url = "/404.html";
            	if ($.common.isNotEmpty(id)) {
            	    url = table.options.detailUrl.replace("{id}", id);
            	} else {
            	    var id = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
            	    if (id.length == 0) {
                        $.modal.alertWarning("请至少选择一条记录");
                        return;
            	    }
            	    url = table.options.detailUrl.replace("{id}", id);
            	}
                return url;
            },

在控制器ZdMessageController中复制一份修改方法改改就行了

/**
     * 留言详情
     */
    @GetMapping("/detail/{messageId}")
    public String detail(@PathVariable("messageId") Long messageId, ModelMap mmap)
    {

        //更新阅读状态和阅读时间
        ZdMessage message = new ZdMessage();
        message.setMessageId(messageId);
        message.setReadStatus("1");
        message.setReadTime(new Date());
        zdMessageService.updateZdMessage(message);

        System.out.println("获取留言详情");
        ZdMessage zdMessage = zdMessageService.selectZdMessageById(messageId);
        mmap.put("zdMessage", zdMessage);
        return prefix + "/detail";
    }

添加详情页detail.html, 复制edit.html改改就好了

Logo

快速构建 Web 应用程序

更多推荐