You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

331 lines
9.9 KiB
Vue

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<div class="app-container">
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="启动页" name="startPage">
<div class="block" style="float: left;margin-left: 3%;margin-top: 3%">
<video
ref="video"
class="play-video"
controls="controls"
autoplay="autoplay"
width="337px"
height="600px"
>
<source :src="videoForm.filePath" type="video/mp4" />
</video>
</div>
<div style="float: left;margin-left: 10%;margin-top: 10%;">
<el-upload
ref="upload"
:limit="1"
accept=".mp4"
:headers="upload.headers"
:action="upload.url"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
<div class="el-upload__tip" slot="tip">请上传视频用于启动页显示比例建议为16: 9</div>
</el-upload>
</div>
</el-tab-pane>
<el-tab-pane label="介绍页" name="middlePage">
<div style="height: 500px;">
<div class="block" style="float: left;margin-left: 3%;margin-top: 3%" >
<el-image :src="loginForm.filePath" style="width: 330px;height: 461px;">
<div slot="placeholder" class="image-slot"><span class="dot"></span>
</div>
</el-image>
</div>
<div style="float: left;margin-left: 10%;margin-top: 10%;">
<el-upload
ref="upload"
:limit="1"
accept=".jpg, .png, .jpeg"
:headers="upload.headers"
:action="upload.url"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
<div class="el-upload__tip" slot="tip">请上传登录页背景图片建议尺寸为375px*471p</div>
</el-upload>
</div>
</div>
</el-tab-pane>
<el-tab-pane label="登录页" name="logoPage">
<div class="block" style="float: left;margin-left: 3%;margin-top: 3%">
<el-image :src="loginForm.filePath" style="width: 330px;height: 461px;">
<div slot="placeholder" class="image-slot"><span class="dot"></span>
</div>
</el-image>
</div>
<div style="float: left;margin-left: 10%;margin-top: 10%;">
<el-upload
ref="upload"
:limit="1"
accept=".jpg, .png, .jpeg"
:headers="upload.headers"
:action="upload.url"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
<div class="el-upload__tip" slot="tip">375px*471p</div>
</el-upload>
</div>
</el-tab-pane>
</el-tabs>
</div>
</template>
<script>
import { listInfo, getInfo, delInfo, addInfo, updateInfo } from "@/api/system/firing";
import {getToken} from "@/utils/auth";
export default {
name: "Info",
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
activeName: 'startPage',
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 登录信息表格数据
infoList: [],
// 弹出层标题
title: "",
videoSrc: 'http://127.0.0.1:9300/statics/2023/12/16/0c49191de1ed8f91b28d9c2b12556154_20231216154804A002.mp4',
// 是否显示弹出层
open: false,
// 用户导入参数
upload: {
// 是否显示弹出层(用户导入)
open: false,
// 弹出层标题(用户导入)
title: "",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的用户数据
updateSupport: 0,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/file/upload"
},
videoForm:{
},
loginForm:{
},
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
filePath: null,
fileSuffix: null,
type: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
}
};
},
created() {
this.getList();
},
methods: {
/** 查询登录信息列表 */
getList() {
this.loading = true;
listInfo(this.queryParams).then(response => {
this.infoList = response.rows;
this.total = response.total;
this.loading = false;
// 处理逻辑
this.infoList.forEach((item)=>{
if (item.type == 1) {
// 启动页
this.videoForm = item;
this.$refs["video"].load();
this.$refs["video"].play();
} else {
// 登录页
this.loginForm = item;
}
})
});
},
handleClick(tab, event) {
console.log(tab, event);
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
filePath: null,
fileSuffix: null,
delFlag: null,
type: null,
createTime: null,
createBy: null
};
this.resetForm("form");
},
// 文件上传中处理
handleFileUploadProgress(event, file, fileList) {
// this.upload.isUploading = true;
console.log('上传处理中==>',JSON.stringify(event))
},
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
if(response.code == '200') {
if (this.activeName == 'startPage') {
// 启动页处理
this.videoForm.filePath = response.data.url;
this.videoForm.fileUrl = response.data.url;
this.videoForm.fileSuffix = 'video';
if (this.videoForm.id != null) {
// 更新操作
updateInfo(this.videoForm).then(response => {
this.$modal.msgSuccess("更新成功");
this.open = false;
this.getList();
});
} else {
// 新增操作
this.videoForm.type = 1;
addInfo(this.videoForm).then(response => {
this.$modal.msgSuccess("保存成功");
this.open = false;
this.getList();
});
}
} else {
// 登录页处理
this.loginForm.filePath = response.data.url;
this.loginForm.fileUrl = response.data.url;
this.videoForm.fileSuffix = 'image';
if (this.loginForm.id != null) {
// 更新操作
updateInfo(this.loginForm).then(response => {
this.$modal.msgSuccess("更新成功");
this.open = false;
this.getList();
});
} else {
// 新增操作
this.loginForm.type = 2;
addInfo(this.loginForm).then(response => {
this.$modal.msgSuccess("保存成功");
this.open = false;
this.getList();
});
}
}
}
console.log('上传后的结果==>',JSON.stringify(response))
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加登录信息";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getInfo(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改登录信息";
});
},
/** 提交按钮 */
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();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除登录信息编号为"' + ids + '"的数据项?').then(function() {
return delInfo(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('system/info/export', {
...this.queryParams
}, `info_${new Date().getTime()}.xlsx`)
}
}
};
</script>