springboot html vue.js 前后分离代码示例

简介: springboot html vue.js 前后分离代码示例

1.html

<table class="table table-hover">
    <thead>
      <tr>
    <th style="width: 50px;" id="cts">
    <div class="checkbox d-inline">
         <input type="checkbox" name="fhcheckbox" id="zcheckbox">
         <label  style="max-height: 12px;" for="zcheckbox" class="cr"></label>
         </div>
        </th>
    <th style="width: 50px;">NO</th>
    <th>名称</th>
    <th>权限标识</th>
    <th>备注</th>
    <th>操作</th>
    </tr>
       </thead>
  <tbody>
    <!-- 开始循环 --> 
    <template v-for="(data,index) in varList">
    <tr>
      <td><div class="checkbox d-inline"><input type="checkbox" v-bind:id="'zcheckbox'+index" name='ids' v-bind:value="data.FHBUTTON_ID"<label  style="max-height: 12px;" v-bind:for="'zcheckbox'+index" class="cr"></label></div>
      </td>
      <td scope="row">{{page.showCount*(page.currentPage-1)+index+1}}</td>
      <td>{{data.NAME}}</td>
      <td>{{data.SHIRO_KEY}}</td>
      <td>{{data.BZ}}</td>
      <td>
        <a v-show="edit" title="修改" v-on:click="goEdit(data.FHBUTTON_ID);" style="cursor:pointer;"><i class="feather icon-edit-2"></i></a>
        <a v-show="del" title="删除" v-on:click="goDel(data.FHBUTTON_ID);" style="cursor:pointer;"><i class="feather icon-x"></i></a>
      </td>
    </tr>
    </template>
    <tr v-show="varList.length==0">
      <td colspan="10">没有相关数据</td>
    </tr>
  </tbody>
   </table>

2.js代码

var vm = new Vue({
  el: '#app',
  data:{
    varList: [],  //list
    page: [],   //分页类
    pd: []      //map
    },
  methods: {
        //初始执行
        init() {
          //复选框控制全选,全不选 
        $('#zcheckbox').click(function(){
           if($(this).is(':checked')){
             $("input[name='ids']").click();
           }else{
             $("input[name='ids']").attr("checked", false);
           }
        });
        this.getList();
        },
        //获取列表
        getList: function(){
          this.loading = true;
          $.ajax({
            xhrFields: {
                    withCredentials: true
                },
            type: "POST",
            url: httpurl+'fhbutton/list?showCount='+this.showCount+'&currentPage='+this.currentPage,
            data: {KEYWORDS:this.pd.KEYWORDS,tm:new Date().getTime()},
            dataType:"json",
            success: function(data){
             if("success" == data.result){
               vm.varList = data.varList;
               vm.page = data.page;
               vm.pd = data.pd;
               vm.hasButton();
               vm.loading = false;
               $("input[name='ids']").attr("checked", false);
             }else if ("exception" == data.result){
                  showException("按钮模块",data.exception);//显示异常
                 }
            }
          }).done().fail(function(){
                swal("登录失效!", "请求服务器无响应,稍后再试", "warning");
                setTimeout(function () {
                  window.location.href = "../../login.html";
                }, 2000);
            });
        }
  },
  mounted(){
        this.init();
    }
})

3.后台代码

package org.fh.controller.system;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.fh.controller.base.BaseController;
import org.fh.entity.Page;
import org.fh.entity.PageData;
import org.fh.service.system.FHlogService;
import org.fh.service.system.FhButtonService;
import org.fh.util.Jurisdiction;
import org.fh.util.Tools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
 * 说明:按钮管理处理类
 * 作者:FH Admin
 * from:fhadmin.cn
 */
@Controller
@RequestMapping("/fhbutton")
public class FhbuttonController extends BaseController {
  @Autowired
  private FhButtonService fhButtonService;
  @Autowired
    private FHlogService FHLOG;
  /**列表
   * @param page
   * @throws Exception
   */
  @RequestMapping(value="/list", produces="application/json;charset=UTF-8")
  @RequiresPermissions("fhbutton:list")
  @ResponseBody
  public Object list(Page page) throws Exception{
    Map<String,Object> map = new HashMap<String,Object>();
    String errInfo = "success";
    PageData pd = new PageData();
    pd = this.getPageData();
    String KEYWORDS = pd.getString("KEYWORDS");       //关键词检索条件
    if(Tools.notEmpty(KEYWORDS)){
      pd.put("KEYWORDS", KEYWORDS.trim());
    }
    page.setPd(pd);
    List<PageData>  varList = fhButtonService.list(page); //列出Fhbutton列表
    map.put("varList", varList);
    map.put("page", page);
    map.put("pd", pd);
    map.put("result", errInfo);
    return map;
  }
}

 

目录
相关文章
|
8天前
|
JavaScript 安全 Java
如何使用 Spring Boot 和 Ant Design Pro Vue 实现动态路由和菜单功能,快速搭建前后端分离的应用框架
本文介绍了如何使用 Spring Boot 和 Ant Design Pro Vue 实现动态路由和菜单功能,快速搭建前后端分离的应用框架。首先,确保开发环境已安装必要的工具,然后创建并配置 Spring Boot 项目,包括添加依赖和配置 Spring Security。接着,创建后端 API 和前端项目,配置动态路由和菜单。最后,运行项目并分享实践心得,包括版本兼容性、安全性、性能调优等方面。
62 1
|
10天前
|
JavaScript 前端开发 开发者
如何在 Visual Studio Code (VSCode) 中使用 ESLint 和 Prettier 来检查代码规范并自动格式化 Vue.js 代码。
【10月更文挑战第7天】随着前端开发技术的快速发展,代码规范和格式化工具变得尤为重要。本文介绍了如何在 Visual Studio Code (VSCode) 中使用 ESLint 和 Prettier 来检查代码规范并自动格式化 Vue.js 代码。通过安装和配置这两个工具,可以确保代码风格一致,提升团队协作效率和代码质量。
126 2
|
13天前
|
JavaScript 前端开发 内存技术
js文件的入口代码及需要入口代码的原因
js文件的入口代码及需要入口代码的原因
28 0
|
10天前
|
JavaScript
webpack学习五:webpack的配置文件webpack.config.js分离,分离成开发环境配置文件和生产环境配置文件
这篇文章介绍了如何将webpack的配置文件分离成开发环境和生产环境的配置文件,以提高打包效率。
20 1
webpack学习五:webpack的配置文件webpack.config.js分离,分离成开发环境配置文件和生产环境配置文件
|
4天前
|
JavaScript Java PHP
快速对比:Django、Spring Boot、Node.js 和 PHP
快速对比:Django、Spring Boot、Node.js 和 PHP
23 7
|
8天前
|
JavaScript 前端开发 开发者
如何在 VSCode 中使用 ESLint 和 Prettier 检查并自动格式化 Vue.js 代码,提升团队协作效率和代码质量。
【10月更文挑战第9天】随着前端开发技术的发展,代码规范和格式化工具变得至关重要。本文介绍如何在 VSCode 中使用 ESLint 和 Prettier 检查并自动格式化 Vue.js 代码,提升团队协作效率和代码质量。通过安装插件、配置 ESLint 和 Prettier,以及设置 VSCode,实现代码实时检查和格式化,确保代码风格一致。
9 2
|
9天前
|
JavaScript 安全 Java
如何使用 Spring Boot 和 Ant Design Pro Vue 构建一个具有动态路由和菜单功能的前后端分离应用
【10月更文挑战第8天】本文介绍了如何使用 Spring Boot 和 Ant Design Pro Vue 构建一个具有动态路由和菜单功能的前后端分离应用。首先,通过 Spring Initializr 创建并配置 Spring Boot 项目,实现后端 API 和安全配置。接着,使用 Ant Design Pro Vue 脚手架创建前端项目,配置动态路由和菜单,并创建相应的页面组件。最后,通过具体实践心得,分享了版本兼容性、安全性、性能调优等注意事项,帮助读者快速搭建高效且易维护的应用框架。
18 3
|
8天前
|
XML 前端开发 JavaScript
前端开发进阶:从HTML到React.js
【10月更文挑战第9天】前端开发进阶:从HTML到React.js
|
9天前
|
JavaScript 前端开发 开发者
如何在 Visual Studio Code (VSCode) 中使用 ESLint 和 Prettier 检查并自动格式化 Vue.js 代码,提升代码质量和团队协作效率。
【10月更文挑战第8天】本文介绍了如何在 Visual Studio Code (VSCode) 中使用 ESLint 和 Prettier 检查并自动格式化 Vue.js 代码,提升代码质量和团队协作效率。通过安装 VSCode 插件、配置 ESLint 和 Prettier,实现代码规范检查和自动格式化,确保代码风格一致,提高可读性和维护性。
9 2
|
10天前
|
JavaScript 安全 Java
如何使用 Spring Boot 和 Ant Design Pro Vue 构建一个具有动态路由和菜单功能的前后端分离应用
【10月更文挑战第7天】本文介绍了如何使用 Spring Boot 和 Ant Design Pro Vue 构建一个具有动态路由和菜单功能的前后端分离应用。首先,通过 Spring Initializr 创建 Spring Boot 项目并配置 Spring Security。接着,实现后端 API 以提供菜单数据。在前端部分,使用 Ant Design Pro Vue 脚手架创建项目,并配置动态路由和菜单。最后,启动前后端服务,实现高效、美观且功能强大的应用框架。
13 2