diff --git a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/SysFile.java b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/SysFile.java index 2634e46..bccd2aa 100644 --- a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/SysFile.java +++ b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/domain/SysFile.java @@ -20,6 +20,8 @@ public class SysFile */ private String url; + private int index; + public String getName() { return name; @@ -40,6 +42,14 @@ public class SysFile this.url = url; } + public int getIndex() { + return index; + } + + public void setIndex(int index) { + this.index = index; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/flossom-modules/flossom-file/src/main/java/com/flossom/file/controller/SysFileController.java b/flossom-modules/flossom-file/src/main/java/com/flossom/file/controller/SysFileController.java index 50124c6..5832909 100644 --- a/flossom-modules/flossom-file/src/main/java/com/flossom/file/controller/SysFileController.java +++ b/flossom-modules/flossom-file/src/main/java/com/flossom/file/controller/SysFileController.java @@ -11,6 +11,9 @@ import org.springframework.web.multipart.MultipartFile; import com.flossom.common.core.domain.R; import com.flossom.common.core.utils.file.FileUtils; +import javax.annotation.Nullable; +import java.util.Objects; + /** * 文件请求处理 * @@ -46,4 +49,28 @@ public class SysFileController return R.fail(e.getMessage()); } } + + /** + * 文件上传请求 + */ + @PostMapping("upload/else") + public R upload(MultipartFile file, int index) + { + try + { + // 上传并返回访问地址 + System.out.println("文件上传开始"); + String url = sysFileService.uploadFile(file); + SysFile sysFile = new SysFile(); + sysFile.setName(FileUtils.getName(url)); + sysFile.setUrl(url); + sysFile.setIndex(index); + return R.ok(sysFile); + } + catch (Exception e) + { + log.error("上传文件失败", e); + return R.fail(e.getMessage()); + } + } } diff --git a/flossom-ui/src/views/system/firing/index.vue b/flossom-ui/src/views/system/firing/index.vue index 98cdf5f..07d963b 100644 --- a/flossom-ui/src/views/system/firing/index.vue +++ b/flossom-ui/src/views/system/firing/index.vue @@ -34,20 +34,21 @@ -
+
- +
-
+
请上传登录页背景图片,建议尺寸为375px*471p
+
+ + + + + + + + + + + + + +
@@ -113,6 +133,8 @@ export default { showSearch: true, // 总条数 total: 0, + // 除了video后image类型的数据 + imagesInfo: [], // 登录信息表格数据 infoList: [], // 弹出层标题 @@ -153,6 +175,7 @@ export default { form: {}, // 表单校验 rules: { + } }; }, @@ -163,22 +186,29 @@ export default { /** 查询登录信息列表 */ getList() { this.loading = true; + this.imagesInfo = []; listInfo(this.queryParams).then(response => { this.infoList = response.rows; this.total = response.total; this.loading = false; // 处理逻辑 this.infoList.forEach((item)=>{ - if (item.type == 1) { + if (item.type == 1 && item.fileSuffix == 'video') { // 启动页 this.videoForm = item; this.$refs["video"].load(); this.$refs["video"].play(); - } else { + } else if(item.type == 1 && item.fileSuffix == 'images') { + // 介绍页 + this.imagesInfo.push(item); + }else { // 登录页 this.loginForm = item; } }) + if (this.imagesInfo.length == 0) { + this.imagesInfo.push({"filePath":""}); + } }); }, handleClick(tab, event) { @@ -206,9 +236,10 @@ export default { handleFileUploadProgress(event, file, fileList) { // this.upload.isUploading = true; console.log('上传处理中==>',JSON.stringify(event)) + console.log('上传处理中==>file',JSON.stringify(file)) }, // 文件上传成功处理 - handleFileSuccess(response, file, fileList) { + handleFileSuccess(response, file, fileList, item) { if(response.code == '200') { if (this.activeName == 'startPage') { // 启动页处理 @@ -231,6 +262,9 @@ export default { this.getList(); }); } + } else if(this.activeName == 'middlePage'){ + this.imagesInfo[response.data.index].filePath = response.data.url; + console.log('结果',JSON.stringify(this.imagesInfo)) } else { // 登录页处理 this.loginForm.filePath = response.data.url; @@ -257,6 +291,9 @@ export default { console.log('上传后的结果==>',JSON.stringify(response)) }, + handleAddInfo(){ + this.imagesInfo.push({"filePath":""}); + }, /** 搜索按钮操作 */ handleQuery() { this.queryParams.pageNum = 1; @@ -290,29 +327,32 @@ export default { }); }, /** 提交按钮 */ - submitForm() { - this.$refs["form"].validate(valid => { - if (valid) { - if (this.form.id != null) { - updateInfo(this.form).then(response => { - this.$modal.msgSuccess("修改成功"); - this.open = false; - this.getList(); - }); - } else { - addInfo(this.form).then(response => { - this.$modal.msgSuccess("新增成功"); - this.open = false; - this.getList(); - }); - } - } - }); + submitForm(item) { + this.form = item; + this.form.fileSuffix = 'images'; + this.form.type = 1; + if (this.form.id != null) { + updateInfo(this.form).then(response => { + this.$modal.msgSuccess("修改成功"); + this.open = false; + this.getList(); + }); + } else { + addInfo(this.form).then(response => { + this.$modal.msgSuccess("新增成功"); + this.open = false; + this.getList(); + }); + } }, /** 删除按钮操作 */ handleDelete(row) { + if (!row.id) { + this.$modal.msgError('目前数据状态不允许删除'); + return; + } const ids = row.id || this.ids; - this.$modal.confirm('是否确认删除登录信息编号为"' + ids + '"的数据项?').then(function() { + this.$modal.confirm('是否确认删除登录页信息编号为"' + ids + '"的数据项?').then(function() { return delInfo(ids); }).then(() => { this.getList();