Commit 0321965b authored by wuqinghua's avatar wuqinghua

2022-3-8 吴卿华

parent 910cf076
package com.zehong.web.controller.supervise;
import java.io.File;
import java.text.ParseException;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -16,7 +12,7 @@ import com.zehong.system.domain.TEmployedPeopleInfo;
import com.zehong.system.service.ITEmployedPeopleInfoService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
/**
* 从业人员信息Controller
......@@ -72,7 +68,7 @@ public class TEmployedPeopleInfoController extends BaseController
@PreAuthorize("@ss.hasPermi('regulation:supervise:add')")
@Log(title = "从业人员信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add( TEmployedPeopleInfo tEmployedPeopleInfo) throws ParseException {
public AjaxResult add(@RequestBody TEmployedPeopleInfo tEmployedPeopleInfo) throws ParseException {
//根据企业id查询企业名称
String EnterpriseName = tEmployedPeopleInfoService.selectEnterpriseName(tEmployedPeopleInfo.getBeyondEnterpriseId());
tEmployedPeopleInfo.setBeyondEnterpriseName(EnterpriseName);
......@@ -112,41 +108,5 @@ public class TEmployedPeopleInfoController extends BaseController
return AjaxResult.success(tEmployedPeopleInfoService.selectTEnterprise());
}
/**
* 图片上传接口
* @param file
* @return
*/
@ResponseBody
@RequestMapping("/addParent")
public String upFile(@RequestParam("file") MultipartFile file) {
String path = "D:\\img";
String fileName = file.getOriginalFilename();//获取文件名称
String suffixName=fileName.substring(fileName.lastIndexOf("."));//获取文件后缀
//uuid+文件名
fileName= UUID.randomUUID().toString().replace("-", "").toLowerCase()+suffixName;//重新生成文件名
System.out.println(fileName);
System.out.println("type::" + suffixName);
System.out.println("filename::" + fileName);
File targetFile = new File(path);
if (!targetFile.exists()) {
// 判断文件夹是否未空,空则创建
targetFile.mkdirs();
}
File saveFile = new File(targetFile, fileName);
try {
//指定本地存入路径
file.transferTo(saveFile);
System.out.println("执行成功");
String path1 = path + fileName;
//图片存储地址
System.out.println(path1);
return path1;
} catch (Exception e) {
e.printStackTrace();
System.out.println("执行失败");
return "failed";
}
}
}
......@@ -7,6 +7,7 @@ import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.core.userdetails.UserDetailsService;
......@@ -143,4 +144,14 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
{
auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder());
}
/**
* 静态资源放行
* @param web
*/
@Override
public void configure(WebSecurity web) {
web.ignoring().antMatchers("/static/**","/index.html","/login");
}
}
......@@ -57,7 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectTEmployedPeopleInfoById" parameterType="Long" resultMap="TEmployedPeopleInfoResult">
select employed_people_id, employed_people_name, id_card, certificate_num, beyond_enterprise_name, beyond_enterprise_id, register_examination_type, people_occupation, issue_date, certificate_change, create_by, create_time, update_by, update_time, is_del, remarks from t_employed_people_info
select employed_people_id, employed_people_name, id_card, certificate_num, beyond_enterprise_name, beyond_enterprise_id, register_examination_type, people_occupation, issue_date, certificate_change, create_by, create_time, update_by, update_time, is_del, remarks,avatar_address from t_employed_people_info
where employed_people_id = #{employedPeopleId} and is_del='0'
</select>
......@@ -119,6 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="isDel != null">is_del = #{isDel},</if>
<if test="remarks != null">remarks = #{remarks},</if>
<if test="avatarAddress != null">avatar_address = #{avatarAddress},</if>
</trim>
where employed_people_id = #{employedPeopleId}
</update>
......
......@@ -83,6 +83,11 @@
<el-table v-loading="loading" :data="infoList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="照片" align="center" >
<template scope="List">
<img :src="List.row.avatarAddress" width="100px">
</template>
</el-table-column>
<el-table-column label="姓名" align="center" prop="employedPeopleName" />
<el-table-column label="身份证号" align="center" prop="idCard" />
<el-table-column label="技能岗位证书编号" align="center" prop="certificateNum" />
......@@ -139,20 +144,14 @@
<el-row>
<el-col :span="22">
<el-form-item label="上传头像" prop="idCard">
<el-upload
class="upload-demo"
:on-preview="handlePreview"
:on-remove="handleRemove"
:on-change="fileChange"
:before-upload="beforeUploadFile"
:before-remove="beforeRemove"
:limit="1"
:on-exceed="handleExceed"
:file-list="fileList">
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/jpeg/png格式,且不超过10MB</div>
</el-upload>
<el-form-item label="上传照片">
<FileUpload
listType="picture"
@resFun="getFileInfo"
@remove="listRemove"
:fileArr="fileList">
</FileUpload>
<el-input v-show="false" disabled v-model="form.avatarAddress"></el-input>
</el-form-item>
</el-col>
</el-row>
......@@ -232,15 +231,18 @@
<script>
import { listInfo, getInfo, delInfo, addInfo, updateInfo, exportInfo, selectTEnterprise,addFile} from "@/api/regulation/supervise";
import FileUpload from '@/components/FileSuperviseUpload';
export default {
name: "Info",
components: {
FileUpload,
},
data() {
return {
//头像
//头像 这个数组只用做前端展示已经上传的图片名称使用 不存放真实的文件数据
fileList: [],
//头像 这个数据存储file文件数据 向后台发送文件数据
fileLists: [],
//头像数据
fileo :{
name: "",
......@@ -297,41 +299,17 @@ export default {
this.getList();
},
methods: {
/**上传头像方法*/
handleRemove(file, fileList) {
console.log(file, fileList);
},
handlePreview(file) {
console.log(file);
},
handleExceed(files, fileList) {
this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
},
// 上传文件之前的钩子, 参数为上传的文件,若返回 false 或者返回 Promise 且被 reject,则停止上传
beforeUploadFile(file) {
let extension = file.name.substring(file.name.lastIndexOf('.') + 1);
let size = file.size / 1024 / 1024;
const isIMG =
file.type === 'image/jpg' ||
file.type === 'image/jpeg' ||
file.type === 'image/png'
if (!isIMG) {
this.$message.error('上传头像图片只支持jpg、jpeg、png格式!')
}
if (size > 10) {
this.$message.warning('图片大小不得超过10M');
}
},
// 文件状态改变时的钩子
fileChange(file, fileList) {
this.fileList = [];
this.fileo.name=file.name;
this.fileo.url=file.raw;
this.fileList.push(this.fileo);
/**上传头像*/
getFileInfo(res){
this.form.dealPlan = res.fileName;
this.form.avatarAddress = res.url;
this.fileList.push({
name: res.fileName,
url: uploadfile,
});
},
beforeRemove(file, fileList) {
return this.$confirm(`确定移除 ${ file.name }?`);
listRemove(e) {
this.form.dealPlan = "";
this.fileList = [];
},
/** 查询从业人员信息列表 */
......@@ -368,7 +346,8 @@ export default {
updateBy: null,
updateTime: null,
isDel: null,
remarks: null
remarks: null,
avatarAddress:null
};
this.resetForm("form");
},
......@@ -423,40 +402,12 @@ export default {
this.getList();
});
} else {
// if (this.fileList.length === 0) {
// this.$message.warning('请上传图片');
// } else {
let file= new FormData();
file.append('file', this.fileList[0]);
// axios({
// method: "post",
// url: `${this.url}/transferRelationshipFile`,
// headers: {
// 'Content-type': 'multipart/form-data'
// },
// data: form
// }).then(function (response) {
// loading.close()
// that.$message({
// message: '图片上传完成',
// type: 'success'
// });
// })
//先传图片 返回图片存储地址
addFile(file).then(response => {
//传form表单
addInfo(this.form).then(response => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
});
});
// }
}
}
});
......@@ -491,86 +442,6 @@ export default {
}).catch(() => {});
},
/**
* 文件提交方法
*/
uploadFile() {
let that = this;
//是否清空数据
let accumulate;
if (this.fileList.length === 0) {
this.$message.warning('请上传文件');
} else {
this.$confirm('是否清空现有数据?', '提示', {
confirmButtonText: '是',
cancelButtonText: '否',
type: 'warning'
/**
* 这个是清空方法 走这个
*/
}).then(() => {
accumulate = 0;
this.$message({
type: 'success',
message: '已清空'
});
let form = new FormData();
form.append('file', this.fileList[0]);
const loading = this.$loading({
lock: true,
text: '数据正在上传中',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
axios({
method: "post",
url: `${this.url}/transferRelationshipFile?Accumulate=` + accumulate,
headers: {
'Content-type': 'multipart/form-data'
},
data: form
}).then(function (response) {
loading.close()
that.$message({
message: '数据上传完成',
type: 'success'
});
})
/**
* 这个是取消清空方法 走这个
*/
}).catch(() => {
accumulate = 1;
this.$message({
type: 'success',
message: '取消清空',
});
let form = new FormData();
form.append('file', this.fileList[0]);
const loading = this.$loading({
lock: true,
text: '数据正在上传中',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
axios({
method: "post",
url: `${this.url}/transferRelationshipFile?Accumulate=` + accumulate,
headers: {
'Content-type': 'multipart/form-data'
},
data: form
}).then(function (response) {
loading.close()
that.$message({
message: '数据上传完成',
type: 'success'
});
})
});
}
},
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment