vue

<template>
  <div>
    <div style="margin: 20px"></div>
    <el-button type="primary" @click="addBtn()" v-hasPermi="['student:student:add']">添加</el-button>
<!--    <div style="width: 200px">-->
<!--      <h1>学生姓名:</h1> <el-input v-model="input.name" placeholder="请输入内容"></el-input>-->
<!--      <h1>学生年龄:</h1> <el-input v-model="input.age" placeholder="请输入内容"></el-input>-->
<!--    </div>-->
<!--    <el-button type="success" @click="inputSelect()">搜索</el-button>-->

<!--    模糊查询-->
    <div style="margin: 20px"></div>
    <el-form :inline="true" :model="input" class="demo-form-inline" ref="queryForm">
      <el-form-item label="学生姓名:">
        <el-input v-model="input.name" placeholder="学生姓名:"></el-input>
      </el-form-item>
      <el-form-item label="学生年龄:">
        <el-input v-model="input.age" placeholder="学生年龄:"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="success" @click="inputSelect()">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-button icon="el-icon-refresh" size="mini" @click="resetQuery()">重置</el-button>
    <el-button
      type="danger"
      plain
      icon="el-icon-delete"
      size="mini"
      :disabled="multiple"
      @click="DeleteMor"
    >删除</el-button>

    <el-table
      :data="tableData"
      style="width: 100%"
      @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column
        prop="id"
        label="id"
        width="180">
      </el-table-column>
      <el-table-column
        prop="name"
        label="名字"
        width="180">
      </el-table-column>
      <el-table-column
        prop="age"
        label="年龄"
        width="180">
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row.id)"
            v-hasPermi="['student:student:update']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row.id)"
            v-hasPermi="['student:student:delete']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 添加 -->
    <el-dialog title="收货地址" :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item label="学生姓名" :label-width="formLabelWidth">
          <el-input v-model="form.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="学生年龄" :label-width="formLabelWidth">
          <el-input v-model="form.age" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="formOk()">确 定</el-button>
      </div>
    </el-dialog>
<!--    分页组件-->
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="input.pageNum"
      :limit.sync="input.pageSize"
      @pagination="getList"
    />
  </div>
</template>
<script>
import { listNotice,delNotice,addNotice,getNotice,updateNotice,delMor } from "@/api/student/student";
export default {
  data() {
    return {
      tableData: [],
      dialogFormVisible : false,
      openStatus : false,
      form : {},
      input : {
        pageNum: 1,
        pageSize: 10
      },
      formLabelWidth: '120px',
      total : 0,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
    }
  },
  created() {
    this.getList();
  },
  methods: {
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },
    /** 查询公告列表 */
    getList() {
      listNotice(this.input).then(response => {
        this.tableData = response.rows;
        this.total = response.total;
      });
    },
    /** 重置 */
    resetQuery(){
      this.$nextTick(() => {
        this.input = {
        };
      });

    },
    /** 点击删除按钮 */
    handleDelete(id){
      this.$modal.confirm('是否确认删除学生编号为"' + id + '"的数据项?').then(function() {
        return delNotice(id);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 删除多条数据 */
    DeleteMor(){
      const noticeIds = this.ids
      this.$modal.confirm('是否确认删除公告编号为"' + noticeIds + '"的数据项?').then(function() {
        return delMor(noticeIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 点击确定按钮事件 */
    formOk(){
      if(this.openStatus){
        updateNotice(this.form).then(response => {
          this.$modal.msgSuccess("修改成功");
          this.dialogFormVisible = false;
          this.getList();
        });
      }else {
        addNotice(this.form).then(response => {
          this.$modal.msgSuccess("新增成功");
          this.dialogFormVisible = false;
          this.getList();
        });
      }
    },
    /** 点击添加事件 */
    addBtn(){
      this.openStatus = false;
      this.form = {};
      this.dialogFormVisible = true
    },
    /** 点击修改按钮 */
    handleUpdate(id){
      this.openStatus = true;
      getNotice(id).then(response => {
        this.form = response.data[0];
        this.dialogFormVisible = true;
      });
    },
    /** 点模糊查询搜索按钮 */
    inputSelect(){
      this.getList()
    }
  }
}
</script>
<style>
</style>

js

import request from '@/utils/request'
// 查询列表
export function listNotice(query) {
  return request({
    url: '/student/student/list',
    method: 'get',
    params: query
  })
}

// 删除学生
export function delNotice(id) {
  return request({
    url: '/student/student/delete?id=' + id,
    method: 'get'
  })
}
// 新增学生
export function addNotice(data) {
  return request({
    url: '/student/student/add',
    method: 'post',
    data: data
  })
}
// 根据id查询
export function getNotice(id) {
  return request({
    url: '/student/student/selectById?id=' + id,
    method: 'get'
  })
}
// 修改学生数据
export function updateNotice(data) {
  return request({
    url: '/student/student/update',
    method: 'post',
    data: data
  })
}
// 删除多条
export function delMor(id) {
  return request({
    url: '/student/student/deleteMor/' + id,
    method: 'get'
  })
}

java controller

/**
 * 批量删除
 */
@PreAuthorize("@ss.hasPermi('student:student:delete')")
@Log(title = "通知公告", businessType = BusinessType.DELETE)
@GetMapping("deleteMor/{Ids}")
public AjaxResult remove(@PathVariable Long[] Ids)
{
    return toAjax(studentService.deleteIds(Ids));
}

xml

<delete id="deleteIds" parameterType="Long">
    delete from student where id in
    <foreach item="ids" collection="array" open="(" separator="," close=")">
        #{ids}
    </foreach>
</delete>