补写4/10日科技政策查询系统课堂作业

发布时间 2023-05-24 21:22:07作者: 云不会Java

整体外部页面使用的Vue + element的方式搭建现成的模板界面

当时主要问题在于分页查询界面一直出现问题、

当时的主要原因在于修改mapper相关内容时,target里的mapper没有实时同步导致出错

 以下是policy.html界面代码

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
img.middle {
vertical-align: middle;
}

.el-table .warning-row {
background: oldlace;

}

.el-table .success-row {
background: #f0f9eb;
}
.el-tooltip_popper {
max-width: 120px;
}
.rapAddress{
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
#sss {
margin-left: 35%;
height: 100%;
width: 100%;
text-align: center;
font-size: 50px;
color: #3a8ee6;
}
</style>

</head>
<body>
<div id="app">

<span id="sss"><img class="middle" src="imgs/LOGO.png" alt="W3School" width="180" height="167"> 科技政策查询系统</span><br><br>
<!--搜索表单-->
<el-form :inline="true" :model="policy" class="demo-form-inline">

<!-- <el-form-item label="当前状态">-->
<!-- <el-select v-model="policy.status" placeholder="当前状态">-->
<!-- <el-option label="启用" value="1"></el-option>-->
<!-- <el-option label="禁用" value="0"></el-option>-->
<!-- </el-select>-->
<!-- </el-form-item>-->

<el-form-item label="政策名称">
<el-input v-model="policy.name" placeholder="政策名称"></el-input>
</el-form-item>

<el-form-item label="发文字号">
<el-input v-model="policy.document" placeholder="发文字号"></el-input>
</el-form-item>

<el-form-item label="发文机构">
<el-input v-model="policy.organ" placeholder="发文机构"></el-input>
</el-form-item>

<el-form-item label="全文检索">
<el-input v-model="policy.text" placeholder="全文检索"></el-input>
</el-form-item>

<el-form-item>
<el-button type="primary" @click="onSubmit">查询</el-button>
</el-form-item>
</el-form>

<!--按钮-->

<el-row>
<el-button type="danger" plain @click="deleteByIds">批量删除</el-button>
<el-button type="primary" plain @click="dialogVisible = true">新增</el-button>
</el-row>

<!--添加数据对话框表单-->
<el-dialog
title="政策内容"
:visible.sync="dialogVisible"
width="30%"
:data="tableData"
>
<template>

</template>


</el-dialog>



<!-- <el-table-column prop="messageContent" label="发布内容" width="300" :formatter="stateFormat"></el-table-column>-->
<!--表格-->
<template>
<el-table
:show-overflow-tooltip="true"
:data="tableData"
style="width: 100%"
:row-class-name="tableRowClassName"
@selection-change="handleSelectionChange"
>
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column
type="index"
width="50">
</el-table-column>

<el-table-column
show-overflow-tooltip
:formatter="stateFormat"
prop="name"

label="政策名称"
align="center"
width="300">
<!-- <template slot-scope="scope">-->
<!-- <el-tooltip class="item" effect="dark" :content="scope.row.name" placement="top">-->
<!-- <span class="rapAddress">{{scope.row.name}}</span>-->
<!-- </el-tooltip>-->
<!-- </template>-->
<template slot-scope="scope">
<div @click="selectSpecific2(scope.row)" style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
{{scope.row.name}}
</div>
</template>
</el-table-column>

<el-table-column
:formatter="stateFormat"
prop="organ"
label="发文机构"
align="center"
>
</el-table-column>
<el-table-column
prop="pubData"
align="center"
label="颁布日期">
</el-table-column>
<el-table-column
prop="type"
align="center"
label="政策分类">
</el-table-column>


<el-table-column
fixed="right"
label="操作"
width="120">
<template slot-scope="scope">
<el-button
@click.native.prevent="deleteRow(scope.$index, tableData)"
type="primary">
删除
</el-button>
</template>
</el-table-column>

</el-table>
</template>

<!--分页工具条-->
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[5, 10, 15, 20]"
:page-size="5"
layout="total, sizes, prev, pager, next, jumper"
:total="totalCount">
</el-pagination>

</div>


<script src="js/vue.js"></script>
<script src="element-ui/lib/index.js"></script>
<link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css">

<script src="js/axios-0.18.0.js"></script>

<script>
new Vue({
el: "#app",


mounted(){
this.selectAll()
},
methods: {

selectSpecific2(row){
location.href="content.jsp?id="+row.id
},
// 格式化表格消息内容
stateFormat(row, column, cellValue) {
// console.log(row , column , cellValue)
if (!cellValue) return "";
if (cellValue.length > 10) {
//最长固定显示10个字符
return cellValue.slice(0, 10) + "...";
}
return cellValue;
},

//执行批量删除品牌
deleteByIds(){
//1.创建ID数组,从this.multipleSelection中获取
//console.log(this.multipleSelection);
for (let i = 0; i < this.multipleSelection.length; i ++) {
let selectionElement = this.multipleSelection[i];
this.selectedIds[i] = selectionElement.id;
}
//2.发送ajax请求
var _this = this;
axios({
method:"post",
url:"http://localhost:8080/brand-case/brand/deleteByIds",
data:_this.selectedIds
}).then(function (resp){
if(resp.data == "success!"){
_this.selectAll();
_this.$message({
showClose: true,
message: '恭喜你,删除成功',
type: 'success'
});
}
})
},

open() {
this.$message({
showClose: true,
message: '恭喜你,添加成功',
type: 'success'
});
},

//查询分页数据
selectAll(){
var _this = this;

axios({
method:"post",
url:"http://localhost:8080/policy/policy/selectByPageAndCondition?currentPage="+this.currentPage+"&pageSize="+this.pageSize,
data:this.policy
}).then(function (resp){
console.log(resp.data);
_this.tableData = resp.data.rows;
_this.totalCount = resp.data.totalCount;
})
},

tableRowClassName({row, rowIndex}) {
if (rowIndex%4 === 1) {
return 'warning-row';
} else if (rowIndex%4=== 3) {
return 'success-row';
}
return '';
},


// 复选框选中后执行的方法
handleSelectionChange(val) {
this.multipleSelection = val;

console.log(this.multipleSelection)
},


// 查询方法
onSubmit() {
console.log(this.brand);
this.selectAll()
},


// 添加数据

addBrand(){
var _this = this;

axios({
method:"post",
url:"http://localhost:8080/brand-case/brand/add",
data:_this.brand
}).then(function (resp){
if(resp.data == "success!"){
_this.dialogVisible = false;
_this.selectAll();
_this.open();
}
})
},


//分页
handleSizeChange(val) {
console.log(`每页 ${val} 条`);
this.pageSize = val;
this.selectAll();
},
handleCurrentChange(val) {
console.log(`当前页: ${val}`);
this.currentPage = val;
this.selectAll();
},

//删除指定品牌
deleteRow(index, rows) {
rows.splice(index, 1);
}

},
data() {
return {

//数据总条数
totalCount: 100,
//每页展示数
pageSize: 5,
//被选中的ID数组
selectedIds:[],
// 当前页码
currentPage: 1,
// 添加数据对话框是否展示的标记
dialogVisible: false,

// 品牌模型数据
policy: {
id:"",
name: '四川',
type: '',
pubData: '',
organ: '',
document:'',
text:''
},
// 复选框选中数据集合
multipleSelection: [],
// 表格数据
tableData: [{
name: '华为',
type: '华为科技有限公司',
pubData: '100',
organ: "1"
}, {
name: '华为',
type: '华为科技有限公司',
pubData: '100',
organ: "1"
}, {
name: '华为',
type: '华为科技有限公司',
pubData: '100',
organ: "1"
}, {
name: '华为',
type: '华为科技有限公司',
pubData: '100',
organ: "1"
}]
}
}
})

</script>

</body>
</html>