见习之星考核过程(上传文件)

This commit is contained in:
paidaxing444 2020-08-31 18:12:34 +08:00
parent b54aa4397f
commit 77d127f37b
7 changed files with 138 additions and 11 deletions

View File

@ -3,6 +3,8 @@ package com.ruoyi.web.controller.jxzxkhgl;
import java.util.List;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.jxzxkhgl.domain.TsbzJxzxkhgcwjsj;
import com.ruoyi.jxzxkhgl.service.ITsbzJxzxkhgcwjsjService;
import com.ruoyi.web.controller.common.SchoolCommonController;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
@ -36,6 +38,8 @@ public class TsbzJxzxkhgcsjController extends BaseController {
private ITsbzJxzxkhgcsjService tsbzJxzxkhgcsjService;
@Autowired
private SchoolCommonController schoolCommonController;
@Autowired
private ITsbzJxzxkhgcwjsjService tsbzJxzxkhgcwjsjService;
/**
* 查询考核过程数据列表
@ -80,8 +84,27 @@ public class TsbzJxzxkhgcsjController extends BaseController {
@Log(title = "考核过程数据", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TsbzJxzxkhgcsj tsbzJxzxkhgcsj) {
tsbzJxzxkhgcsj.setId(schoolCommonController.getUuid());
String uuid = schoolCommonController.getUuid();
tsbzJxzxkhgcsj.setId(uuid);
tsbzJxzxkhgcsj.setCreateuserid(SecurityUtils.getLoginUser().getUser().getUserId());
String filePaths = tsbzJxzxkhgcsj.getFilepath();
String fileNames = tsbzJxzxkhgcsj.getFilename();
if (!schoolCommonController.isStringEmpty(filePaths) && !schoolCommonController.isStringEmpty(fileNames)) {
String[] strArrFilePath = filePaths.split(";");
String[] strArrFileName = fileNames.split(";");
TsbzJxzxkhgcwjsj tsbzJxzxkhgcwjsj = null;
for (int i = 0; i < strArrFilePath.length; i++) {
tsbzJxzxkhgcwjsj = new TsbzJxzxkhgcwjsj();
tsbzJxzxkhgcwjsj.setFilepath(strArrFilePath[i]);
tsbzJxzxkhgcwjsj.setFilename(strArrFileName[i]);
tsbzJxzxkhgcwjsj.setGcid(uuid);
tsbzJxzxkhgcwjsj.setCreateuserid(SecurityUtils.getLoginUser().getUser().getUserId());
tsbzJxzxkhgcwjsjService.insertTsbzJxzxkhgcwjsj(tsbzJxzxkhgcwjsj);
}
}
return toAjax(tsbzJxzxkhgcsjService.insertTsbzJxzxkhgcsj(tsbzJxzxkhgcsj));
}
@ -92,6 +115,27 @@ public class TsbzJxzxkhgcsjController extends BaseController {
@Log(title = "考核过程数据", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TsbzJxzxkhgcsj tsbzJxzxkhgcsj) {
//1先清空文件数据;
String[] tmp = new String[1];
tmp[0] = tsbzJxzxkhgcsj.getId();
tsbzJxzxkhgcwjsjService.deleteTsbzJxzxkhgcwjsjByGcIds(tmp);
//2再重新创建;
String filePaths = tsbzJxzxkhgcsj.getFilepath();
String fileNames = tsbzJxzxkhgcsj.getFilename();
if (!schoolCommonController.isStringEmpty(filePaths) && !schoolCommonController.isStringEmpty(fileNames)) {
String[] strArrFilePath = filePaths.split(";");
String[] strArrFileName = fileNames.split(";");
TsbzJxzxkhgcwjsj tsbzJxzxkhgcwjsj = null;
for (int i = 0; i < strArrFilePath.length; i++) {
tsbzJxzxkhgcwjsj = new TsbzJxzxkhgcwjsj();
tsbzJxzxkhgcwjsj.setFilepath(strArrFilePath[i]);
tsbzJxzxkhgcwjsj.setFilename(strArrFileName[i]);
tsbzJxzxkhgcwjsj.setGcid(tsbzJxzxkhgcsj.getId());
tsbzJxzxkhgcwjsj.setCreateuserid(SecurityUtils.getLoginUser().getUser().getUserId());
tsbzJxzxkhgcwjsjService.insertTsbzJxzxkhgcwjsj(tsbzJxzxkhgcwjsj);
}
}
return toAjax(tsbzJxzxkhgcsjService.updateTsbzJxzxkhgcsj(tsbzJxzxkhgcsj));
}
@ -102,6 +146,9 @@ public class TsbzJxzxkhgcsjController extends BaseController {
@Log(title = "考核过程数据", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids) {
//清空考核数据先清空文件数据
tsbzJxzxkhgcwjsjService.deleteTsbzJxzxkhgcwjsjByGcIds(ids);
return toAjax(tsbzJxzxkhgcsjService.deleteTsbzJxzxkhgcsjByIds(ids));
}
}

View File

@ -43,6 +43,18 @@ public class TsbzJxzxkhgcsj extends BaseEntity {
@Excel(name = "创建人")
private Long createuserid;
/**
* 文件名称
*/
@Excel(name = "文件名称")
private String filename;
/**
* 文件路径
*/
@Excel(name = "文件路径")
private String filepath;
private TsbzJxzxkhzbx tsbzJxzxkhzbx;
public void setId(String id) {
@ -93,6 +105,22 @@ public class TsbzJxzxkhgcsj extends BaseEntity {
this.tsbzJxzxkhzbx = tsbzJxzxkhzbx;
}
public void setFilename(String filename) {
this.filename = filename;
}
public String getFilename() {
return filename;
}
public void setFilepath(String filepath) {
this.filepath = filepath;
}
public String getFilepath() {
return filepath;
}
@Override
public String toString() {
@ -104,6 +132,8 @@ public class TsbzJxzxkhgcsj extends BaseEntity {
.append("createuserid", getCreateuserid())
.append("createTime", getCreateTime())
.append("tsbzJxzxkhzbx", getTsbzJxzxkhzbx())
.append("filename", getFilename())
.append("filepath", getFilepath())
.toString();
}
}

View File

@ -58,4 +58,12 @@ public interface TsbzJxzxkhgcwjsjMapper {
* @return 结果
*/
public int deleteTsbzJxzxkhgcwjsjByIds(Long[] ids);
/**
* 批量删除考核过程文件数据
*
* @param gcids 需要删除的考核过程文件数据ID
* @return 结果
*/
public int deleteTsbzJxzxkhgcwjsjByGcIds(String[] gcids);
}

View File

@ -58,4 +58,12 @@ public interface ITsbzJxzxkhgcwjsjService {
* @return 结果
*/
public int deleteTsbzJxzxkhgcwjsjById(Long id);
/**
* 批量删除考核过程文件数据
*
* @param gcids 需要删除的考核过程文件数据ID
* @return 结果
*/
public int deleteTsbzJxzxkhgcwjsjByGcIds(String[] gcids);
}

View File

@ -76,6 +76,16 @@ public class TsbzJxzxkhgcwjsjServiceImpl implements ITsbzJxzxkhgcwjsjService {
return tsbzJxzxkhgcwjsjMapper.deleteTsbzJxzxkhgcwjsjByIds(ids);
}
/**
* 批量删除考核过程文件数据
*
* @param gcids 需要删除的考核过程文件数据ID
* @return 结果
*/
public int deleteTsbzJxzxkhgcwjsjByGcIds(String[] gcids) {
return tsbzJxzxkhgcwjsjMapper.deleteTsbzJxzxkhgcwjsjByGcIds(gcids);
}
/**
* 删除考核过程文件数据信息
*

View File

@ -73,4 +73,11 @@
</foreach>
</delete>
<delete id="deleteTsbzJxzxkhgcwjsjByGcIds" parameterType="String">
delete from tsbz_jxzxkhgcwjsj where gcid in
<foreach item="gcid" collection="array" open="(" separator="," close=")">
#{gcid}
</foreach>
</delete>
</mapper>

View File

@ -112,8 +112,8 @@
<el-form-item label="内容" prop="content">
<el-input v-model="form.content" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="选择文件" prop="fileurl">
<el-input v-model="form.fileurl" v-if="false" />
<el-form-item label="选择文件" prop="filepath">
<el-input v-model="form.filepath" v-if="false" />
<el-upload
class="upload-demo"
:action="uploadFileUrl"
@ -121,7 +121,7 @@
:on-preview="handlePreview"
:on-remove="handleRemove"
:before-remove="beforeRemove"
:limit="1"
:limit="filecount"
:on-exceed="handleExceed"
:file-list="fileList"
:on-success="handleAvatarSuccess"
@ -154,6 +154,7 @@ export default {
name: "Jxzxkhgcsj",
data() {
return {
filecount: 1,
khnr: "",
//
loading: true,
@ -210,17 +211,23 @@ export default {
},
methods: {
handleAvatarSuccess(res, file) {
//console.log(res);
//console.log(res, file);
if (res.code == "200") {
this.form.fileurl = res.fileName;
this.form.filepath = this.form.filepath + res.fileName + ";";
this.form.filename = this.form.filename + file.name + ";";
} else {
this.msgError(res.msg);
}
//console.log(this.form.filepath, this.form.filename);
},
handleRemove(file, fileList) {
//console.log(file, fileList);
if (file.response.code == "200") {
this.form.fileurl = "";
this.form.filepath = this.form.filepath.replace(
file.response.fileName + ";",
""
);
this.form.filename = this.form.filename.replace(file.name + ";", "");
}
},
handlePreview(file) {
@ -228,9 +235,11 @@ export default {
},
handleExceed(files, fileList) {
this.$message.warning(
`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
files.length + fileList.length
} 个文件`
`当前限制选择 ` +
this.filecount +
` 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
files.length + fileList.length
} 个文件`
);
},
beforeRemove(file, fileList) {
@ -280,6 +289,8 @@ export default {
createuserid: null,
createTime: null,
khnr: null,
filepath: "",
filename: "",
};
this.resetForm("form");
this.fileList = [];
@ -304,7 +315,8 @@ export default {
handleUpdate(row) {
this.reset();
const id = row.id || this.ids;
//console.log("id:" + row.tsbzJxzxkhzbx.khnr);
//console.log("tjsl:" + row.tsbzJxzxkhzbx.tjsl);
this.filecount = row.tsbzJxzxkhzbx.tjsl;
if (id != "") {
getJxzxkhgcsj(id).then((response) => {
@ -350,6 +362,11 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
console.log(ids);
if (ids.length <= 0) {
this.msgError("数据已清空");
return;
}
this.$confirm("是否确认清空考核过程数据的数据项?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",