Commit 3bf889bc authored by 赵啸非's avatar 赵啸非

修改人员学习

parent a42bcdbf
...@@ -10,5 +10,5 @@ VUE_APP_WEBSOCKET_API =127.0.0.1:18222/m ...@@ -10,5 +10,5 @@ VUE_APP_WEBSOCKET_API =127.0.0.1:18222/m
# 门户登录地址 # 门户登录地址
VUE_APP_PORTAL_URL = /portal_home VUE_APP_PORTAL_URL = /portal_home
VUE_APP_PORTAL_PORT = 11089 VUE_APP_PORTAL_PORT = 17300
...@@ -5,4 +5,4 @@ VUE_APP_API_BASE_URL=/basics_api ...@@ -5,4 +5,4 @@ VUE_APP_API_BASE_URL=/basics_api
#图片地址拼接 #图片地址拼接
VUE_APP_PORTAL_URL = /portal_home VUE_APP_PORTAL_URL = /portal_home
VUE_APP_PORTAL_PORT = 11089 VUE_APP_PORTAL_PORT = 17300
...@@ -31,7 +31,7 @@ export default { ...@@ -31,7 +31,7 @@ export default {
this.pageInfo.edit = path + "/edit"; this.pageInfo.edit = path + "/edit";
this.pageInfo.view = path + "/view"; this.pageInfo.view = path + "/view";
}, },
// 默认拉取数据 // 默认拉取数据
getData() { getData() {
this.loading = true; this.loading = true;
...@@ -46,7 +46,9 @@ export default { ...@@ -46,7 +46,9 @@ export default {
res.entity = this.util_toDateStr(res.entity, this.toDate); res.entity = this.util_toDateStr(res.entity, this.toDate);
this.form = Object.assign({}, this.form, res.entity); this.form = Object.assign({}, this.form, res.entity);
this.dict = Object.assign({}, this.dict, res.dict); this.dict = Object.assign({}, this.dict, res.dict);
console.log(this.form)
this.afterRender(res); this.afterRender(res);
}) })
.catch(error => { .catch(error => {
......
...@@ -264,7 +264,7 @@ export default { ...@@ -264,7 +264,7 @@ export default {
// 自定义索引号 // 自定义索引号
handleIndexMethod(index) { handleIndexMethod(index) {
//prePageResult 每页条数 //prePageResult 每页条数
console.log("index:"+index) // console.log("index:"+index)
let size = this.tableData.pageInfo.prePageResult; let size = this.tableData.pageInfo.prePageResult;
let page = this.tableData.pageInfo.currPage; let page = this.tableData.pageInfo.currPage;
let count = parseInt(size) * (parseInt(page) - 1) let count = parseInt(size) * (parseInt(page) - 1)
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<el-link <el-link
:underline="false" :underline="false"
style="font-size: 12px" style="font-size: 12px"
@click="handleDelete(index)" @click="handleDelete(file.url,index)"
type="danger" type="danger"
>删除</el-link >删除</el-link
> >
...@@ -71,7 +71,7 @@ export default { ...@@ -71,7 +71,7 @@ export default {
type: Number, type: Number,
default: 200, default: 200,
}, },
fileNumber: { fileNumber: {
type: Number, type: Number,
default: 1, default: 1,
}, },
...@@ -99,34 +99,55 @@ export default { ...@@ -99,34 +99,55 @@ export default {
}, },
data() { data() {
return { return {
number: 0,
uploadFileUrl: "/study/file/commonupload", // 上传的地址 uploadFileUrl: "/study/file/commonupload", // 上传的地址
uploadList: [],
headers:{}, headers:{},
fileList: [], fileList: [],
}; };
}, },
/* watch: {
value: {
handler(val) {
console.log("value",this.value);
if (val) {
let temp = 1;
// 首先将值转为数组
const list = Array.isArray(val) ? val : this.value.split(',');
// 然后将数组转为对象数组
this.fileList = list.map(item => {
item = { name: item.name, url: item.url};
item.uid = item.uid || new Date().getTime() + temp++;
return item;
});
} else {
this.fileList = [];
return [];
}
},
}
},*/
computed: { computed: {
// 是否显示提示 // 是否显示提示
showTip() { showTip() {
return this.isShowTip && (this.fileType || this.fileSize); return this.isShowTip && (this.fileType || this.fileSize);
}, },
// 列表 // 列表
list() { list() {
let temp = 1; let temp = 1;
if (this.value) { if (this.value) {
console.log("value",this.value)
// 首先将值转为数组 // 首先将值转为数组
const list = Array.isArray(this.value) ? this.value : [this.value]; const list = Array.isArray(this.value) ? this.value : [this.value];
// 然后将数组转为对象数组 // 然后将数组转为对象数组
return list.map((item) => { this.fileList = list.map(item => {
if (typeof item === "string") { item = { name: item.name, url: item.url};
if(this.fileName!=''){
item = { name: this.fileName, url: item };
}else{
item = { name: item, url: item };
}
}
item.uid = item.uid || new Date().getTime() + temp++; item.uid = item.uid || new Date().getTime() + temp++;
return item; return item;
}); });
return this.fileList;
} else { } else {
this.fileList = []; this.fileList = [];
return []; return [];
...@@ -160,11 +181,12 @@ export default { ...@@ -160,11 +181,12 @@ export default {
return false; return false;
} }
} }
this.number++;
return true; return true;
}, },
// 文件个数超出 // 文件个数超出
handleExceed() { handleExceed() {
this.$message.error(`只允许上传单个文件`); this.$message.error(`上传文件数量不能超过 ${this.limit} 个!`);
}, },
// 上传失败 // 上传失败
handleUploadError(err) { handleUploadError(err) {
...@@ -172,19 +194,34 @@ export default { ...@@ -172,19 +194,34 @@ export default {
}, },
// 上传成功回调 // 上传成功回调
handleUploadSuccess(res, file) { handleUploadSuccess(res, file) {
this.$message.success("上传成功"); if (res.code === 1) {
this.$emit("input", res.url); this.uploadList.push({ name: res.fileName, url: res.url });
this.fileName=res.fileName console.log("uploadList:",this.uploadList)
this.$emit("getFileName", res.fileName); if (this.uploadList.length === this.number) {
this.fileList = this.fileList.concat(this.uploadList);
this.uploadList = [];
this.number = 0;
this.$emit("input", this.fileList);
}
} else {
this.$message.error(res.msg);
}
// this.$message.success("上传成功");
// this.$emit("input", res.url);
// this.fileName=res.fileName
// this.$emit("getFileName", res.fileName);
}, },
// 删除文件 // 删除文件
handleDelete(index) { handleDelete(url,index) {
this.fileList.splice(index, 1); //todo 接口请求删除
this.$emit("input", ''); this.value=this.value.filter(item=>item.url!=url)
// this.fileList.splice(index, 1);
this.$emit("input", this.value);
}, },
// 获取文件名称 // 获取文件名称
getFileName(name) { getFileName(name) {
if (name.lastIndexOf("/") > -1) { //console.log("name",name)
if (name&&name.lastIndexOf("/") > -1) {
return name.slice(name.lastIndexOf("/") + 1).toLowerCase(); return name.slice(name.lastIndexOf("/") + 1).toLowerCase();
} else { } else {
return name; return name;
...@@ -192,7 +229,7 @@ export default { ...@@ -192,7 +229,7 @@ export default {
} }
}, },
created() { created() {
this.fileList = this.list; //this.fileList = this.list;
}, },
}; };
</script> </script>
......
<template> <template>
<layout-view> <layout-view>
<el-row justify="center" align="middle" ::span="24"> <el-row justify="center" align="middle" ::span="24">
<el-col :span="24" style="display:flex;justify-content:center;"> <el-col :span="24" style="display:flex;justify-content:center;">
<el-card class="box-card"> <el-card class="box-card">
<el-row> <el-row>
<span class="my-custom-text">{{form.title}}</span> <span class="my-custom-text">{{ form.title }}</span>
<el-button type="primary" style="float: right" @click="$router.go(-1)" size="small">返回</el-button> <el-button type="primary" style="float: right" @click="$router.go(-1)" size="small">返回</el-button>
</el-row> </el-row>
<!-- <el-button type="primary" @click="$router.go(-1)" size="small">返回</el-button>--> <!-- <el-button type="primary" @click="$router.go(-1)" size="small">返回</el-button>-->
<el-divider style="width: 100%"></el-divider> <el-divider style="width: 100%"></el-divider>
<el-descriptions style="text-align: center;width:50%; margin: auto" :column="3" > <el-descriptions style="text-align: center;width:50%; margin: auto" :column="3">
<el-descriptions-item label-width="0" label="公告类型" > <el-descriptions-item label-width="0" label="公告类型">
{{ util_formatters("noticetType", form.noticetType) }} {{ util_formatters("noticetType", form.noticetType) }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="发布时间" label-width="0" > <el-descriptions-item label="发布时间" label-width="0">
{{util_formatterDate(form.createTime)}} {{ util_formatterDate(form.createTime) }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label-width="0" label="发布部门"> <el-descriptions-item label-width="0" label="发布部门">
{{form.deptName}} {{ form.deptName }}
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
<el-divider style="width: 100%"></el-divider> <el-divider style="width: 100%"></el-divider>
<div class="ql-editor" style="" v-html="form.noticeContent"></div> <div class="ql-editor" style="" v-html="form.noticeContent"></div>
<el-divider style="width: 100%"></el-divider> <el-divider style="width: 100%"></el-divider>
<div v-if="isImage">
<img :src="form.filePath" alt="图片描述"> <ul class="attachment-list">
</div> <li v-for="(file, index) in attachmentList" :key="index">
<div v-else-if="isVideo"> <div class="file-preview">
<video id="myVideo" controls> <template v-if="checkImage(file)">
<source :src="form.filePath" type="video/mp4"> <img :src="file.url" alt=""/>
</video> </template>
</div> <template v-else-if="checkVideo(file)">
<video :src="file.url" controls preload="metadata" width="200"></video>
<div v-else> </template>
<el-link type="primary" :href="form.filePath" >{{form.fileName}}</el-link> <template v-else>
</div> <el-link type="primary" :href="file.url">{{ file.fileName }}</el-link>
</el-card> </template>
</el-col> </div>
</el-row> <div class="file-info">
<span class="file-name">{{ file.fileName }}</span>
</layout-view> </div>
<el-divider style="width: 100%"></el-divider>
</li>
</ul>
</el-card>
</el-col>
</el-row>
</layout-view>
</template> </template>
<script> <script>
import view from "@/assets/mixins/view"; import view from "@/assets/mixins/view";
export default {
mixins: [view], export default {
components: { mixins: [view],
}, components: {},
methods: { methods: {
afterRender(data) { beforeRender(data) {
this.checkFileType() const nameArrays =data.entity.fileName.split(';');
}, const pathArrays =data.entity.filePath.split(';');
checkFileType() { for (let i = 0; i < nameArrays.length; i++) {
const extension = this.form.fileName.split('.').pop().toLowerCase(); let obj={fileName: nameArrays[i],url:pathArrays[i]}
if (['jpg', 'jpeg', 'png', 'gif'].indexOf(extension) !== -1) { this.attachmentList.push(obj)
this.isImage = true; }
}else if (['mp4'].indexOf(extension) !== -1) { return data
this.isVideo=true },
} checkImage(file) {
else { const extension = file.fileName.split('.').pop().toLowerCase();
this.isImage = false; if (['jpg', 'jpeg', 'png', 'gif'].indexOf(extension) !== -1) {
} return true;
}, } else {
}, return false;
data() { }
return { },
isImage: false, checkVideo(file) {
isVideo: false, const extension = file.fileName.split('.').pop().toLowerCase();
size:"small", if (['mp4', 'MP4'].indexOf(extension) !== -1) {
column:2, return true
toString:[ } else {
"noticetType", return false;
"noticeStatus", }
"top", },
], },
toArrays: [ data() {
return {
], attachmentList: [],
toDate: [ isImage: false,
isVideo: false,
] size: "small",
} column: 2,
} toString: [
"noticetType",
"noticeStatus",
"top",
],
toArrays: [],
toDate: []
} }
}
}
</script> </script>
<style lang="less"> <style lang="less">
.labelClass{ .labelClass {
width: 200px; width: 200px;
} }
.el-descriptions__body{
.el-descriptions__body {
margin-left: 5px; margin-left: 5px;
margin-right: 5px; margin-right: 5px;
color: #606266; color: #606266;
background-color: #FFF; background-color: #FFF;
} }
.contentClass{
.contentClass {
} }
...@@ -119,7 +139,7 @@ ...@@ -119,7 +139,7 @@
font-weight: bold; font-weight: bold;
} }
.el-divider{ .el-divider {
margin: 18px 0; margin: 18px 0;
background: 0 0; background: 0 0;
border-top: 1px solid #E6EBF5; border-top: 1px solid #E6EBF5;
......
...@@ -133,7 +133,7 @@ ...@@ -133,7 +133,7 @@
<editor v-model="form.studyContent" :min-height="256"/> <editor v-model="form.studyContent" :min-height="256"/>
</Field> </Field>
<Field :span="22" label="项目附件"> <Field :span="22" label="项目附件">
<fileUpload v-model="form.filePath" @getFileName="getProjectFileName" prePath="/file/fileupload"/> <fileUpload v-model="form.filePath" fileNumber="5" prePath="/file/fileupload"/>
</Field> </Field>
</el-row> </el-row>
...@@ -361,10 +361,51 @@ export default { ...@@ -361,10 +361,51 @@ export default {
this.open = false; this.open = false;
}, },
/**获取数据后弹框 */ /**获取数据后弹框 */
beforeRender(data) {
//降filepath转换成数组
if(data.entity.fileName === null || data.entity.fileName === undefined || data.entity.fileName === ''){
data.entity.filePath = []
return data
}
const nameArrays = data.entity.fileName.split(';');
const pathArrays = data.entity.filePath.split(';');
let arrs = []
for (let i = 0; i < nameArrays.length; i++) {
let obj = {name: nameArrays[i], url: pathArrays[i]}
arrs.push(obj)
}
data.entity.filePath = arrs
return data;
},
/**获取数据后弹框 */
afterRender(data) { afterRender(data) {
this.open = true; this.open = true;
}, },
beforeSubmit(data) {
if (Array.isArray(data.filePath)) {
const fileNameArray = data.filePath.map((element, index) => {
if (index === data.filePath.length - 1) {
return element.name;
} else {
return element.name + ";";
}
});
const fileName = fileNameArray.join("")
const filePathArray = data.filePath.map((element, index) => {
if (index === data.filePath.length - 1) {
return element.url;
} else {
return element.url + ";";
}
});
const filePath = filePathArray.join("")
data.filePath = filePath;
data.fileName = fileName;
}
return data;
},
afterSubmit(data) { afterSubmit(data) {
this.open = false; this.open = false;
this.$emit("ok"); this.$emit("ok");
......
...@@ -36,8 +36,26 @@ ...@@ -36,8 +36,26 @@
<div class="ql-editor" v-html="form.studyContent"></div> <div class="ql-editor" v-html="form.studyContent"></div>
<el-divider style="width: 100%"></el-divider> <el-divider style="width: 100%"></el-divider>
<el-link type="primary" :href="form.filePath" >{{form.fileName}}</el-link> <ul class="attachment-list">
<li v-for="(file, index) in attachmentList" :key="index">
<div class="file-preview">
<template v-if="checkImage(file)">
<img :src="file.url" alt=""/>
</template>
<template v-else-if="checkVideo(file)">
<video :src="file.url" controls preload="metadata" width="200"></video>
</template>
<template v-else>
<el-link type="primary" :href="file.url">{{ file.fileName }}</el-link>
</template>
</div>
<div class="file-info">
<span class="file-name">{{ file.fileName }}</span>
</div>
<el-divider style="width: 100%"></el-divider>
</li>
</ul>
</el-card> </el-card>
</el-col> </el-col>
</el-row> </el-row>
...@@ -52,10 +70,38 @@ ...@@ -52,10 +70,38 @@
components: { components: {
}, },
methods: { methods: {
beforeRender(data) {
const nameArrays =data.entity.fileName.split(';');
const pathArrays =data.entity.filePath.split(';');
for (let i = 0; i < nameArrays.length; i++) {
let obj={fileName: nameArrays[i],url:pathArrays[i]}
this.attachmentList.push(obj)
}
return data
},
checkImage(file) {
const extension = file.fileName.split('.').pop().toLowerCase();
if (['jpg', 'jpeg', 'png', 'gif'].indexOf(extension) !== -1) {
return true;
} else {
return false;
}
},
checkVideo(file) {
const extension = file.fileName.split('.').pop().toLowerCase();
if (['mp4', 'MP4'].indexOf(extension) !== -1) {
return true
} else {
return false;
}
},
}, },
data() { data() {
return { return {
attachmentList: [],
isImage: false,
isVideo: false,
size:"small", size:"small",
column:2, column:2,
toString:[ toString:[
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<profiles.server.port>17300</profiles.server.port> <profiles.server.port>17300</profiles.server.port>
<profiles.server.gatewayport>11078</profiles.server.gatewayport> <profiles.server.gatewayport>11078</profiles.server.gatewayport>
<profiles.server.path>/study</profiles.server.path> <profiles.server.path>/study</profiles.server.path>
<profiles.nacos.server-addr>192.168.0.54:8848</profiles.nacos.server-addr> <profiles.nacos.server-addr>192.168.1.104:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group> <profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov-cs</profiles.nacos.namespace> <profiles.nacos.namespace>smart-gov-cs</profiles.nacos.namespace>
<profiles.log.path>/mortals/app/logs</profiles.log.path> <profiles.log.path>/mortals/app/logs</profiles.log.path>
......
...@@ -55,7 +55,7 @@ public class UploadServiceImpl implements UploadService { ...@@ -55,7 +55,7 @@ public class UploadServiceImpl implements UploadService {
log.error("文件上传大小超过限制,当前文件---" + tempFile.getSize() + ",允许大小----------" + type.getMaxSize()); log.error("文件上传大小超过限制,当前文件---" + tempFile.getSize() + ",允许大小----------" + type.getMaxSize());
throw new AppException("文件上传大小超过限制!"); throw new AppException("文件上传大小超过限制!");
} }
if (null != fileName && fileName.length() > 50) { if (null != fileName && fileName.length() > 255) {
throw new AppException("文件名称过长,无法上传!"); throw new AppException("文件名称过长,无法上传!");
} }
......
...@@ -122,5 +122,19 @@ public class UploadController extends BaseController { ...@@ -122,5 +122,19 @@ public class UploadController extends BaseController {
} }
} }
/**
* 通用文件删除
*
* @param fileName 文件名称
*/
@GetMapping("fileupload/{fileName}")
public void fileDel(@PathVariable(value="fileName") String fileName, HttpServletResponse response) {
try {
//uploadService.uploadDownload(fileName, response);
} catch (Exception e) {
log.error("下载文件失败:", e);
}
}
} }
\ No newline at end of file
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