实现作业上传自动创建文件夹
This commit is contained in:
@@ -6,6 +6,7 @@ import com.fjy.spring.exception.UserException;
|
||||
import com.fjy.spring.service.WorkDetailService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
@@ -25,4 +26,9 @@ public class DataController {
|
||||
new UserException(ResultEnum.EMPTY_DATA);
|
||||
return null;
|
||||
}
|
||||
|
||||
@PostMapping("/home/dofeedback")
|
||||
public void doFeedback(){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,4 +24,19 @@ public class NavController {
|
||||
public String toHomePage(){
|
||||
return "/home/home";
|
||||
}
|
||||
|
||||
@GetMapping(value = {"/feedback"})
|
||||
public String toFeedbackPage(){
|
||||
return "/home/feedback";
|
||||
}
|
||||
|
||||
@GetMapping(value = {"/about"})
|
||||
public String toAboutPage(){
|
||||
return "/home/about";
|
||||
}
|
||||
|
||||
@GetMapping(value = {"/user"})
|
||||
public String toUserPage(){
|
||||
return "/home/user";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,9 @@ public class UpLoadController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/moreUpload")
|
||||
public void moreUpload(HttpServletRequest request) {
|
||||
public void moreUpload(HttpServletRequest request,
|
||||
@RequestParam(value = "courseName",required = false) String courseName,
|
||||
@RequestParam(value = "folder",required = false) String folder) {
|
||||
|
||||
MultipartHttpServletRequest multipartHttpServletRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> files = multipartHttpServletRequest.getFileMap();
|
||||
@@ -132,7 +134,7 @@ public class UpLoadController {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String dateNowStr = sdf.format(date);
|
||||
//String uploadUrl = request.getSession().getServletContext().getRealPath("/") + "upload/";
|
||||
String uploadUrl = serverProperties.getFilePath()+ "upload/";
|
||||
String uploadUrl = serverProperties.getFilePath()+ "upload/"+courseName+"/"+folder+"/";
|
||||
|
||||
File dir = new File(uploadUrl);
|
||||
if (!dir.exists()) {
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
var dt = new Date();
|
||||
var month = dt.getMonth()+1;
|
||||
var day = dt.getDate();
|
||||
var year = dt.getFullYear();
|
||||
var cur = year + '-' + month + '-' + day;
|
||||
function DateDiff(sDate1, sDate2){ //sDate1和sDate2是2002-12-18格式
|
||||
var aDate, oDate1, oDate2, iDays
|
||||
aDate = sDate1.split("-")
|
||||
oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]) //转换为12-18-2002格式
|
||||
aDate = sDate2.split("-")
|
||||
oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0])
|
||||
iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 /24) //把相差的毫秒数转换为天数
|
||||
return iDays
|
||||
}
|
||||
var Main = {
|
||||
data() {
|
||||
var checkName = (rule, value, callback) => {
|
||||
@@ -35,6 +49,9 @@ var Main = {
|
||||
}
|
||||
};
|
||||
return {
|
||||
feedbackForm: {
|
||||
content: ''
|
||||
},
|
||||
activeIndex: '1',
|
||||
dialogVisible: false,
|
||||
ruleForm2: {
|
||||
@@ -73,7 +90,28 @@ var Main = {
|
||||
activeName:'login',
|
||||
fileList: [],
|
||||
DownloadList: [],
|
||||
tableHomeworkData: [],
|
||||
tableHomeworkData: [
|
||||
{
|
||||
workid: 1,
|
||||
colfileid: 56,
|
||||
workname: "实验报告",
|
||||
worktime: "2018-02-06 20:44:08.0",
|
||||
colfilename: "2018 服务器装机.xlsx",
|
||||
coursename: "信息安全",
|
||||
workremark: "3000字以上",
|
||||
workfolder: "第一次作业"
|
||||
},
|
||||
{
|
||||
workid: 1,
|
||||
colfileid: 56,
|
||||
workname: "实验报告2",
|
||||
worktime: "2018-02-08 20:44:08.0",
|
||||
colfilename: "2018 服务器装机.xlsx",
|
||||
coursename: "决策支持系统",
|
||||
workremark: "3000字以上",
|
||||
workfolder: "第一次作业"
|
||||
}
|
||||
],
|
||||
tableData2: [{
|
||||
date: '2016-05-02',
|
||||
}, {
|
||||
@@ -113,6 +151,7 @@ var Main = {
|
||||
.then(function (response) {
|
||||
console.log(response.data);
|
||||
that.tableHomeworkData = response.data;
|
||||
//that.limitTime = response.data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
@@ -121,6 +160,12 @@ var Main = {
|
||||
|
||||
},
|
||||
methods: {
|
||||
uploadURL(row){
|
||||
return "http://localhost:8080/cms/moreUpload?courseName="+row.coursename+"&folder="+row.workfolder;
|
||||
},
|
||||
limitTime(row){
|
||||
return DateDiff(row.worktime.replace(/([^\s]+)\s.*/, "$1"), cur);
|
||||
},
|
||||
submitForm(formName) {
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
|
||||
26
src/main/resources/templates/home/about.html
Normal file
26
src/main/resources/templates/home/about.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
<head th:include="dist/thymeleaf/common_head :: header('关于')">
|
||||
</head>
|
||||
<body>
|
||||
<div th:insert="~{dist/thymeleaf/common_head :: #body_js}"></div>
|
||||
<div id="app">
|
||||
<el-container>
|
||||
<el-container>
|
||||
<el-header th:include="dist/thymeleaf/layout :: header"></el-header>
|
||||
<el-main>
|
||||
<el-col :md="4" :lg="4" :xl="4" class="hidden-sm-and-down">
|
||||
<el-card th:include="dist/thymeleaf/layout :: userbox"></el-card>
|
||||
</el-col>
|
||||
<el-col :md="14" :lg="14" :xl="14" :sm="18" :xs="23" :offset="1"></el-col>
|
||||
<el-col :md="5" :lg="5" :sm="5" :xl="5" class="hidden-xs-only"></el-col>
|
||||
</el-main>
|
||||
<el-footer th:include="dist/thymeleaf/layout :: footer"></el-footer>
|
||||
</el-container>
|
||||
</el-container>
|
||||
</div>
|
||||
<script th:src="@{js/homePage.js}"></script>
|
||||
<script th:src="@{js/msg.js}"></script>
|
||||
</body>
|
||||
</html>
|
||||
40
src/main/resources/templates/home/feedback.html
Normal file
40
src/main/resources/templates/home/feedback.html
Normal file
@@ -0,0 +1,40 @@
|
||||
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
<head th:include="dist/thymeleaf/common_head :: header('意见反馈')">
|
||||
</head>
|
||||
<body>
|
||||
<div th:insert="~{dist/thymeleaf/common_head :: #body_js}"></div>
|
||||
<div id="app">
|
||||
<el-container>
|
||||
<el-container>
|
||||
<el-header th:include="dist/thymeleaf/layout :: header"></el-header>
|
||||
<el-main>
|
||||
<el-col :md="4" :lg="4" :xl="4" class="hidden-sm-and-down">
|
||||
<el-card th:include="dist/thymeleaf/layout :: userbox"></el-card>
|
||||
</el-col>
|
||||
<el-col :md="14" :lg="14" :xl="14" :sm="18" :xs="23" :offset="1">
|
||||
<el-form :model="feedbackForm" ref="feedbackForm" class="demo-ruleForm" action="/cms/home/dofeedback">
|
||||
<el-form-item label="反馈内容" prop="content" :rules="[
|
||||
{ required: true, message: '反馈内容不能为空'}
|
||||
]">
|
||||
<el-input type="textarea" v-model.number="feedbackForm.content" auto-complete="off"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="submitForm('feedbackForm')">提交</el-button>
|
||||
<el-button @click="resetForm('feedbackForm')">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-col>
|
||||
<el-col :md="5" :lg="5" :sm="5" :xl="5" class="hidden-xs-only">
|
||||
|
||||
</el-col>
|
||||
</el-main>
|
||||
<el-footer th:include="dist/thymeleaf/layout :: footer"></el-footer>
|
||||
</el-container>
|
||||
</el-container>
|
||||
</div>
|
||||
<script th:src="@{js/homePage.js}"></script>
|
||||
<script th:src="@{js/msg.js}"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -5,7 +5,6 @@
|
||||
</head>
|
||||
<body>
|
||||
<div th:insert="~{dist/thymeleaf/common_head :: #body_js}"></div>
|
||||
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
|
||||
<!--<div id="app">
|
||||
<el-container>
|
||||
<el-aside th:include="dist/thymeleaf/layout :: asider"></el-aside>
|
||||
@@ -97,21 +96,9 @@
|
||||
<el-header th:include="dist/thymeleaf/layout :: header"></el-header>
|
||||
<el-main>
|
||||
<el-col :md="4" :lg="4" :xl="4" class="hidden-sm-and-down">
|
||||
<el-card class="box-card">
|
||||
<div slot="header" class="clearfix">
|
||||
<!--下面两行报错正常-->
|
||||
<span th:text="${#httpServletRequest.getSession().getAttribute('USER_SESSION').colname}">用户名</span><br>
|
||||
<span th:text="${#httpServletRequest.getSession().getAttribute('USER_SESSION').colstudentno}"></span>
|
||||
</div>
|
||||
<div class="item">
|
||||
<el-button type="text" @click="ClickToJump('home')">首页</el-button><br>
|
||||
<el-button type="text" @click="ClickToJump('user')">个人中心</el-button><br>
|
||||
<el-button type="text" @click="ClickToJump('about')">关于</el-button><br>
|
||||
<el-button type="text" @click="ClickToJump('feedback')">意见反馈</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-card th:include="dist/thymeleaf/layout :: userbox"></el-card>
|
||||
</el-col>
|
||||
<el-col :md="14" :lg="14" :xl="14" :sm="18" :xs="23" offset=1>
|
||||
<el-col :md="14" :lg="14" :xl="14" :sm="18" :xs="23" :offset="1">
|
||||
<el-row>
|
||||
<el-col :span="23">
|
||||
<div class="grid-content bg-purple-dark">
|
||||
@@ -137,6 +124,20 @@
|
||||
{{ props.row.colfilename }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item label="提交作业">
|
||||
<el-upload class="upload-demo" ref="upload"
|
||||
:action="uploadURL(props.row)"
|
||||
:on-preview="handlePreview"
|
||||
:on-remove="handleRemove" :file-list="fileList" :auto-upload="false"
|
||||
name="imageFile">
|
||||
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
|
||||
<el-button style="margin-left: 10px;" size="small" type="success"
|
||||
@click="submitUpload">
|
||||
上传到服务器
|
||||
</el-button>
|
||||
<!--<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>-->
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -146,14 +147,14 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="提交时间" prop="worktime">
|
||||
</el-table-column>
|
||||
<el-table-column fixed="right" label="操作">
|
||||
<!--<el-table-column fixed="right" label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-button @click="dialogVisible = true" type="success" plain
|
||||
size="small">
|
||||
上传作业
|
||||
提交作业
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table-column>-->
|
||||
</el-table>
|
||||
<!--<el-table :data="tableData1" style="width: 100%">
|
||||
<el-table-column prop="subject" label="科目">
|
||||
@@ -174,7 +175,7 @@
|
||||
</el-table-column>
|
||||
</el-table>-->
|
||||
</template>
|
||||
<el-dialog title="上传作业" :visible.sync="dialogVisible" width="50%"
|
||||
<!--<el-dialog title="上传作业" :visible.sync="dialogVisible" width="50%"
|
||||
:before-close="dialogClose">
|
||||
<el-row>
|
||||
<el-col :span="23">
|
||||
@@ -186,7 +187,7 @@
|
||||
<el-col :span="23">
|
||||
<div class="grid-content bg-purple-dark">
|
||||
<el-upload class="upload-demo" ref="upload"
|
||||
action="https://jsonplaceholder.typicode.com/posts/"
|
||||
action="http://localhost:8080/cms/moreUpload?courseName=tableHomeworkData.row.coursename&folder=tableHomeworkData.row.workfolder"
|
||||
:on-preview="handlePreview"
|
||||
:on-remove="handleRemove" :file-list="fileList" :auto-upload="false"
|
||||
name="imageFile">
|
||||
@@ -204,7 +205,7 @@
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="dialogVisible = false">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</el-dialog>-->
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<script src="https://unpkg.com/vue/dist/vue.js"></script>
|
||||
<!-- 引入组件库 -->
|
||||
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
|
||||
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
|
||||
<div id="app">
|
||||
<el-container>
|
||||
<!--<el-aside width="200px">
|
||||
@@ -84,12 +85,13 @@
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :md="14" :lg="14" :xl="14" :sm="18" :xs="23" offset=1>
|
||||
<el-col :md="14" :lg="14" :xl="14" :sm="18" :xs="23" :offset="1">
|
||||
<el-row>
|
||||
<el-col :span="23">
|
||||
<div class="grid-content bg-purple-dark">
|
||||
<template>
|
||||
<el-table :data="tableHomeworkData" style="width: 100%">
|
||||
<el-table :data="tableHomeworkData" style="width: 100%"
|
||||
:default-sort="{prop: 'worktime', order: 'descending'}">
|
||||
<el-table-column type="expand">
|
||||
<template slot-scope="props">
|
||||
<el-form label-position="left" inline class="demo-table-expand">
|
||||
@@ -110,14 +112,28 @@
|
||||
{{ props.row.colfilename }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item label="作业提交">
|
||||
<el-upload class="upload-demo" ref="upload"
|
||||
action="http://localhost:8080/cms/moreUpload?courseName={ props.row.coursename }&folder={ props.row.workfolder }"
|
||||
:on-preview="handlePreview"
|
||||
:on-remove="handleRemove" :file-list="fileList" :auto-upload="false"
|
||||
name="imageFile">
|
||||
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
|
||||
<el-button style="margin-left: 10px;" size="small" type="success"
|
||||
@click="submitUpload">
|
||||
上传到服务器
|
||||
</el-button>
|
||||
<!--<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>-->
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="科目" prop="coursename">
|
||||
<el-table-column label="科目" sortable prop="coursename">
|
||||
</el-table-column>
|
||||
<el-table-column label="内容" prop="workname">
|
||||
<el-table-column label="内容" sortable prop="workname">
|
||||
</el-table-column>
|
||||
<el-table-column label="提交时间" prop="worktime">
|
||||
<el-table-column label="提交时间" sortable prop="worktime">
|
||||
</el-table-column>
|
||||
<el-table-column fixed="right" label="操作">
|
||||
<template slot-scope="scope">
|
||||
@@ -221,6 +237,18 @@
|
||||
</el-table-column>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-form :model="feedbackForm" ref="feedbackForm" class="demo-ruleForm">
|
||||
<el-form-item label="反馈内容" prop="content" :rules="[
|
||||
{ required: true, message: '反馈内容不能为空'}
|
||||
]">
|
||||
<el-input type="textarea" v-model.number="feedbackForm.content"
|
||||
auto-complete="off"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="submitForm('feedbackForm')">提交</el-button>
|
||||
<el-button @click="resetForm('feedbackForm')">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@@ -232,9 +260,19 @@
|
||||
<el-card class="box-card hidden-xs-only">
|
||||
<div slot="header" class="clearfix">
|
||||
<span>作业提交倒计时</span>
|
||||
<span style="color: red"> 功能未完成</span>
|
||||
</div>
|
||||
<div v-for="o in 4" :key="o" class="text item">
|
||||
{{'倒计时 ' + o }}
|
||||
<div class="text item">
|
||||
<template slot-scope="props">
|
||||
<el-table :data="tableHomeworkData" style="width: 100%" :default-sort="{prop: 'worktime', order: 'descending'}">
|
||||
<el-table-column prop="coursename" label="科目" sortable width="180">
|
||||
</el-table-column>
|
||||
<el-table-column @prop="limitTime(props.row)" label="日期" sortable width="180">
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
<!--<span>{{ limitTime[0].coursename }}{{ limitTime[0].workname }}</span><br>
|
||||
距离提交日期还有<span> {{ limitTime[0].time }}</span>天-->
|
||||
</div>
|
||||
</el-card>
|
||||
<!--<template>
|
||||
|
||||
Reference in New Issue
Block a user