parent
b9606c77c0
commit
2b948c24a7
@ -0,0 +1,127 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-table
|
||||
ref="multipleTable"
|
||||
:data="tableData"
|
||||
:default-sort="{prop: 'date', order: 'descending'}"
|
||||
border
|
||||
stripe
|
||||
style="width: 90%">
|
||||
<el-table-column
|
||||
type="selection">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
fixed
|
||||
label="编号"
|
||||
prop="id"
|
||||
width="100">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="评论名称"
|
||||
prop="comment_detail"
|
||||
width="800">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column>
|
||||
<template slot-scope="scope">
|
||||
<el-button size="small" type="danger" @click="deleteLD(scope.row.id)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div style="margin-top: 20px">
|
||||
<el-button type="danger" @click="allDeleteLD()">批量删除</el-button>
|
||||
<el-button @click="toggleSelection()">取消选择</el-button>
|
||||
</div>
|
||||
<el-pagination
|
||||
:page-size="pageSize"
|
||||
:total="total"
|
||||
background
|
||||
layout="prev, pager, next"
|
||||
@current-change="page">
|
||||
</el-pagination>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "StudentHistory",
|
||||
methods: {
|
||||
page(currentPage) {
|
||||
const _this = this
|
||||
let id = window.location.pathname.split('/')[3];
|
||||
axios.get('http://localhost:8181/comment/findAllPaged/' + (currentPage) + '/10').then(function (resp) {
|
||||
console.log(resp.data)
|
||||
_this.tableData = resp.data
|
||||
_this.pageSize = 10
|
||||
})
|
||||
axios.get('http://localhost:8181/comment/findAllNum').then(function (resp) {
|
||||
_this.total = resp.data
|
||||
})
|
||||
|
||||
},
|
||||
deleteLD(id) {
|
||||
const _this = this
|
||||
axios.get('http://localhost:8181/comment/delete/' + id).then(function (resp) {
|
||||
location.reload();
|
||||
})
|
||||
},
|
||||
allDeleteLD() {
|
||||
let arrLength = this.$refs.multipleTable.selection.length;
|
||||
for (let i = 0; i < arrLength; i++) {
|
||||
axios.get('http://localhost:8181/comment/delete/' + this.$refs.multipleTable.selection[i].id)
|
||||
}
|
||||
location.reload();
|
||||
},
|
||||
toggleSelection(rows) {
|
||||
if (rows) {
|
||||
rows.forEach(row => {
|
||||
this.$refs.multipleTable.toggleRowSelection(row);
|
||||
});
|
||||
} else {
|
||||
this.$refs.multipleTable.clearSelection();
|
||||
}
|
||||
},
|
||||
handleSelectionChange(val) {
|
||||
this.multipleSelection = val;
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
pageSize: 20,
|
||||
total: 11,
|
||||
tableData: [{
|
||||
id: 1,
|
||||
comment_detail: '挺好的',
|
||||
}]
|
||||
}
|
||||
},
|
||||
created() {
|
||||
const _this = this
|
||||
let id = window.location.pathname.split('/')[3];
|
||||
let type = window.location.pathname.split('/')[2];
|
||||
axios.get('http://localhost:8181/user/checkUseridAndType/' + id + '/' + type).then(function (resp) {
|
||||
if (resp.data != 'success') {
|
||||
_this.$router.push("/NoAuthority")
|
||||
} else {
|
||||
let login_id = _this.$cookieStore.getCookie("login_id")
|
||||
console.log(login_id)
|
||||
if (login_id != id) {
|
||||
_this.$router.push("/NoAuthority")
|
||||
}
|
||||
}
|
||||
})
|
||||
axios.get('http://localhost:8181/comment/findAllPaged/1/10').then(function (resp) {
|
||||
console.log(resp.data)
|
||||
_this.tableData = resp.data
|
||||
_this.pageSize = 10
|
||||
})
|
||||
axios.get('http://localhost:8181/comment/findAllNum').then(function (resp) {
|
||||
_this.total = resp.data
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
@ -0,0 +1,80 @@
|
||||
<template>
|
||||
|
||||
<el-form ref="ruleForm" :model="ruleForm" :rules="rules" class="demo-ruleForm" label-width="100px">
|
||||
<h4>请在这里写下对本系统的匿名评论。</h4>
|
||||
<el-form-item label="评论" maxlength="255" prop="comment_detail">
|
||||
<el-input v-model="ruleForm.comment_detail" :rows="10" maxlength="255" show-word-limit type="textarea"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
|
||||
<el-button @click="resetForm('ruleForm')">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: "StudentAppForm",
|
||||
data() {
|
||||
return {
|
||||
ruleForm: {
|
||||
userid: '',
|
||||
comment_detail: '',
|
||||
},
|
||||
rules: {
|
||||
comment_detail: [
|
||||
{required: true, message: '评论不能为空', trigger: 'blur'}
|
||||
],
|
||||
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
submitForm(formName) {
|
||||
const _this = this
|
||||
let id = window.location.pathname.split('/')[3];
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
this.ruleForm.userid = id
|
||||
|
||||
axios.post('http://localhost:8181/comment/save', this.ruleForm).then(function (resp) {
|
||||
if (resp.data == 'success') {
|
||||
_this.$alert('保存成功', '消息', {
|
||||
confirmButtonText: '确定',
|
||||
callback: action => {
|
||||
_this.$router.push('/user/student/' + id + '/history')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
resetForm(formName) {
|
||||
this.$refs[formName].resetFields();
|
||||
},
|
||||
},
|
||||
created() {
|
||||
const _this = this
|
||||
let id = window.location.pathname.split('/')[3];
|
||||
let type = window.location.pathname.split('/')[2];
|
||||
axios.get('http://localhost:8181/user/checkUseridAndType/' + id + '/' + type).then(function (resp) {
|
||||
if (resp.data != 'success') {
|
||||
_this.$router.push("/NoAuthority")
|
||||
} else {
|
||||
let login_id = _this.$cookieStore.getCookie("login_id")
|
||||
console.log(login_id)
|
||||
if (login_id != id) {
|
||||
_this.$router.push("/NoAuthority")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
Loading…
Reference in new issue