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;
  }
}

 

目录
相关文章
|
4天前
|
JavaScript
鼠标事件(点击换色)分别使用js和jQuery代码实现
鼠标事件(点击换色)分别使用js和jQuery代码实现
12 1
|
1天前
|
JavaScript 前端开发 iOS开发
优秀的JavaScript代码技巧大分享
优秀的JavaScript代码技巧大分享
12 3
|
1天前
|
JavaScript 前端开发 测试技术
编写高质量JavaScript代码怎么做
编写高质量JavaScript代码怎么做
11 2
|
3天前
|
前端开发 JavaScript Java
SpringBoot+Vue+token实现(表单+图片)上传、图片地址保存到数据库。上传图片保存位置自己定义、图片可以在前端回显(一))
这篇文章详细介绍了在SpringBoot+Vue项目中实现表单和图片上传的完整流程,包括前端上传、后端接口处理、数据库保存图片路径,以及前端图片回显的方法,同时探讨了图片资源映射、token验证、过滤器配置等相关问题。
|
3天前
|
前端开发 数据库
SpringBoot+Vue+token实现(表单+图片)上传、图片地址保存到数据库。上传图片保存位置到项目中的静态资源下、图片可以在前端回显(二))
这篇文章是关于如何在SpringBoot+Vue+token的环境下实现表单和图片上传的优化篇,主要改进是将图片保存位置从磁盘指定位置改为项目中的静态资源目录,使得图片资源可以跨环境访问,并在前端正确回显。
|
3天前
|
前端开发 数据库
SpringBoot+Vue实现商品不能重复加入购物车、购物车中展示商品的信息、删除商品重点提示等操作。如何点击图片实现图片放大
这篇文章介绍了如何在SpringBoot+Vue框架下实现购物车功能,包括防止商品重复加入、展示商品信息、删除商品时的提示,以及点击图片放大的前端实现。
SpringBoot+Vue实现商品不能重复加入购物车、购物车中展示商品的信息、删除商品重点提示等操作。如何点击图片实现图片放大
|
4天前
|
JSON JavaScript 前端开发
基于SpringBoot + Vue实现单个文件上传(带上Token和其它表单信息)的前后端完整过程
本文介绍了在SpringBoot + Vue项目中实现单个文件上传的同时携带Token和其它表单信息的前后端完整流程,包括后端SpringBoot的文件上传处理和前端Vue使用FormData进行表单数据和文件的上传。
15 0
基于SpringBoot + Vue实现单个文件上传(带上Token和其它表单信息)的前后端完整过程
|
4天前
|
JavaScript 前端开发 easyexcel
基于SpringBoot + EasyExcel + Vue + Blob实现导出Excel文件的前后端完整过程
本文展示了基于SpringBoot + EasyExcel + Vue + Blob实现导出Excel文件的完整过程,包括后端使用EasyExcel生成Excel文件流,前端通过Blob对象接收并触发下载的操作步骤和代码示例。
20 0
基于SpringBoot + EasyExcel + Vue + Blob实现导出Excel文件的前后端完整过程
|
4天前
|
数据库
elementUi使用dialog的进行信息的添加、删除表格数据时进行信息提示。删除或者添加成功的信息提示(SpringBoot+Vue+MybatisPlus)
这篇文章介绍了如何在基于SpringBoot+Vue+MybatisPlus的项目中使用elementUI的dialog组件进行用户信息的添加和删除操作,包括弹窗表单的设置、信息提交、数据库操作以及删除前的信息提示和确认。
elementUi使用dialog的进行信息的添加、删除表格数据时进行信息提示。删除或者添加成功的信息提示(SpringBoot+Vue+MybatisPlus)
|
4天前
|
SQL 前端开发 Java
在IDEA中使用Maven将SpringBoot项目打成jar包、同时运行打成的jar包(前后端项目分离)
这篇文章介绍了如何在IntelliJ IDEA中使用Maven将Spring Boot项目打包成可运行的jar包,并提供了运行jar包的方法。同时,还讨论了如何解决jar包冲突问题,并提供了在IDEA中同时启动Vue前端项目和Spring Boot后端项目的步骤。
在IDEA中使用Maven将SpringBoot项目打成jar包、同时运行打成的jar包(前后端项目分离)