作业视频信息

This commit is contained in:
wangyan21 2023-11-17 10:41:19 +08:00
parent d2e7f12cae
commit bd26ba2e28

View File

@ -0,0 +1,450 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="农机名称" prop="machineName">
<el-input
v-model="queryParams.machineName"
placeholder="请输入农机名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="农机编码" prop="machineCode">
<el-input
v-model="queryParams.machineCode"
placeholder="请输入农机编码"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="地块" prop="farmland">
<el-input
v-model="queryParams.farmland"
placeholder="请输入地块"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="上传时间" prop="imageTime">
<el-date-picker clearable
v-model="queryParams.imageTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择上传时间">
</el-date-picker>
</el-form-item>
<el-form-item label="地址信息" prop="address">
<el-input
v-model="queryParams.address"
placeholder="请输入地址信息"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['machinery:image:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['machinery:image:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['machinery:image:remove']"
>删除</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="imageList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="农机名称" align="center" prop="machineName" />
<el-table-column label="农机编码" align="center" prop="machineCode" />
<el-table-column label="地块" align="center" prop="farmland" />
<el-table-column label="上传时间" align="center" prop="imageTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.imageTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<!-- <el-table-column label="视频地址" align="center" prop="videoUrl" />-->
<el-table-column label="地址信息" align="center" prop="address" />
<!-- <el-table-column label="作业速度" align="center" prop="speed" />-->
<!-- <el-table-column label="备注" align="center" prop="remark" />-->
<!-- <el-table-column label="数据类型" align="center" prop="dataType" />-->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['machinery:image:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['machinery:image:remove']"
>删除</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-video-camera"
@click="playVideo(scope.row)"
v-hasPermi="['species:video:remove']"
>查看视频</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改作业图片信息对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="农机名称" prop="machineName">
<el-input v-model="form.machineName" placeholder="请输入农机名称" />
</el-form-item>
<el-form-item label="农机编码" prop="machineCode">
<el-input v-model="form.machineCode" placeholder="请输入农机编码" />
</el-form-item>
<el-form-item label="地块" prop="farmland">
<el-input v-model="form.farmland" placeholder="请输入地块" />
</el-form-item>
<el-form-item label="上传时间" prop="imageTime">
<el-date-picker clearable
v-model="form.imageTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择上传时间">
</el-date-picker>
</el-form-item>
<el-form-item label="视频地址" prop="videoUrl">
<el-input v-model="form.videoUrl" placeholder="请输入视频地址" />
</el-form-item>
<el-form-item label="地址信息" prop="address">
<el-input v-model="form.address" placeholder="请输入地址信息" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
<el-form-item label="文件上传">
<el-upload
class="upload-demo"
ref="uploadFile"
action=""
:on-preview="handlePreview"
:on-remove="handleRemoveFiles"
:on-change="handleChangeFiles"
:before-upload="beforeUploadFiles"
:file-list="fileList"
:auto-upload="true"
multiple
>
<el-button size="small" type="primary">上传视频</el-button>
<div slot="tip" class="el-upload__tip">只能上传mp4文件且不超过100M</div>
</el-upload>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listImage, getImage, delImage, addImage, updateImage } from "@/api/machinery/image";
import { getToken } from "@/utils/auth";
import request from "@/utils/request";
export default {
//
name: "JobVideo",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
imageList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
machineName: null,
machineCode: null,
farmland: null,
imageInfo: null,
imageTime: null,
videoUrl: null,
address: null,
speed: null,
dataType: "视频信息"
},
//
form: {},
//
rules: {
},
//
fileInfoList: [],
fileList: [],
//
upload: {
//
headers: { Authorization: "Bearer " + getToken() },
// TODO
url: "/species/video/upload/file",
//
imageUrl: "",
//
data: {
tableName: "",
linkId: "",
workId: "",
},
},
isShow: false,
videoUrl: '',
baseUrl: process.env.VUE_APP_BASE_API,
};
},
created() {
this.getList();
},
methods: {
//
playVideo (row) {
this.isShow = true
// src
let url1 = row.videoUrl;
// this.videoUrl=this.baseUrl+"/profile/upload/2023/10/24/_20231024154211A001.mp4";
this.videoUrl=this.baseUrl+url1;
},
/**
* 关闭视频
*/
closeDialog () {
//
this.isShow = false
this.videoUrl = '' //
},
//
submit() {
this.submitUploadFiles();
},
handlePreview(file, fileList) {
console.log("--->>预览文件", file);
},
beforeUploadFiles: (file, fileList) => {
//
//
return false;
},
// false Promise rejectfunction(file, fileList)
handleRemoveFiles(file, fileList) {
this.fileList = fileList;
},
handleChangeFiles(file, fileList) {
this.fileList = fileList;
this.submitUploadFiles();
},
submitUploadFiles() {
if (this.fileList.length === 0) {
return this.$message.warning("请选取文件后再上传");
}
// FormData:
const formData = new FormData();
// 使FormData.append/
this.fileList.forEach((file) => {
formData.append("files", file.raw);
});
if (this.form.id && this.form.id != "null") {
formData.set("workId", this.form.id);
}
formData.set("dataType", this.form.dataType);
request({
method: "POST",
url: this.upload.url, //
data: formData, //formData
}).then((res) => {
if (res.code == 200) {
this.$message.success("上传成功");
// this.open = false;
// this.getList();
console.log("查看上传结果:",res);
if (res.data) {
this.form.videoUrl = res.data.fileUrl;
}
} else {
this.$message.error("上传失败");
}
//fileList
this.fileList = [];
});
// this.$refs.uploadFile.submit();
},
/** 查询作业图片信息列表 */
getList() {
this.loading = true;
listImage(this.queryParams).then(response => {
this.imageList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
machineName: null,
machineCode: null,
farmland: null,
imageInfo: null,
imageTime: null,
videoUrl: null,
address: null,
speed: null,
remark: null,
dataType: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
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 = "添加作业视频信息";
this.form.dataType = "视频信息";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getImage(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) {
updateImage(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addImage(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 delImage(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('machinery/image/export', {
...this.queryParams
}, `image_${new Date().getTime()}.xlsx`)
}
}
};
</script>