Browse Source

安全生产上传文件

master_tdsql
xzt 1 year ago
parent
commit
bfcfb66469
  1. 114
      src/views/safetyManage/safeProduction/sluice/index.vue

114
src/views/safetyManage/safeProduction/sluice/index.vue

@ -253,7 +253,7 @@
style="width: 100%" style="width: 100%"
v-model="form.processingTime" v-model="form.processingTime"
type="date" type="date"
value-format="yyyy-MM-dd" value-format="yyyy-MM-dd HH:mm:ss"
placeholder="选择处理时间" placeholder="选择处理时间"
> >
</el-date-picker> </el-date-picker>
@ -298,11 +298,31 @@
</el-form-item> </el-form-item>
<el-form-item label="图片" prop="photo"> <el-form-item label="图片" prop="photo">
<el-input <!-- <el-input
v-model="form.photo" v-model="form.photo"
type="textarea" type="textarea"
placeholder="请输入内容" placeholder="请输入内容"
/> /> -->
<el-upload
class="upload-demo"
action="thinking/common/upload"
:headers="headers"
:on-preview="handlePreview"
:on-remove="(file) => handleRemove(file, 'fileList')"
:before-remove="beforeRemove"
multiple
:on-exceed="handleExceed"
:on-success="(_, fileList) => submitUpload(fileList, 'fileList')"
:file-list="fileList"
>
<el-button size="small" type="primary" plain>
<i class="el-icon-upload el-icon--right"></i>
点击上传
</el-button>
<div slot="tip" class="el-upload__tip">
支持jpg/png文件等不超过100M
</div>
</el-upload>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
@ -323,6 +343,8 @@ import {
exportYhxx, exportYhxx,
} from "@/api/yg/yhxx"; } from "@/api/yg/yhxx";
import { listJbxx, getJbxx } from "@/api/yg/jbxx"; import { listJbxx, getJbxx } from "@/api/yg/jbxx";
import { getToken } from "@/utils/auth";
import { getFileStream } from "@/api/system/upload";
export default { export default {
name: "Yhxx", name: "Yhxx",
@ -390,6 +412,11 @@ export default {
// //
rules: {}, rules: {},
isResolve: false, isResolve: false,
//
headers: {
shuili: "water " + getToken(),
},
fileList: [],
}; };
}, },
created() { created() {
@ -403,10 +430,15 @@ export default {
}, },
methods: { methods: {
handleResolve(row) { handleResolve(row) {
this.reset();
this.isResolve = true; this.isResolve = true;
const id = row.id || this.ids; const id = row.id || this.ids;
getYhxx(id).then((response) => { getYhxx(id).then((response) => {
this.form = response.data; this.form = response.data;
if (this.form.photo) {
this.fileList = JSON.parse(this.form.photo);
// console.log(11111, this.fileList);
}
this.open = true; this.open = true;
this.title = "解决水闸隐患信息"; this.title = "解决水闸隐患信息";
}); });
@ -439,6 +471,7 @@ export default {
}, },
// //
reset() { reset() {
this.fileList = [];
this.form = { this.form = {
id: null, id: null,
wagaId: null, wagaId: null,
@ -536,6 +569,10 @@ export default {
const id = row.id || this.ids; const id = row.id || this.ids;
getYhxx(id).then((response) => { getYhxx(id).then((response) => {
this.form = response.data; this.form = response.data;
if (this.form.photo) {
this.fileList = JSON.parse(this.form.photo);
// console.log(11111, this.fileList);
}
this.open = true; this.open = true;
this.title = "修改水闸隐患信息"; this.title = "修改水闸隐患信息";
}); });
@ -544,7 +581,9 @@ export default {
submitForm() { submitForm() {
this.$refs["form"].validate((valid) => { this.$refs["form"].validate((valid) => {
if (valid) { if (valid) {
this.form.photo = JSON.stringify(this.fileList);
if (this.form.id != null) { if (this.form.id != null) {
if (this.isResolve) this.form.status = "1";
updateYhxx(this.form).then((response) => { updateYhxx(this.form).then((response) => {
if (response.code === 200) { if (response.code === 200) {
this.msgSuccess("修改成功"); this.msgSuccess("修改成功");
@ -585,27 +624,54 @@ export default {
this.$message.warning("请选择要删除的数据!!"); this.$message.warning("请选择要删除的数据!!");
} }
}, },
/** 导出按钮操作 */ //
handleExport() { submitUpload(fileList, name) {
const queryParams = this.queryParams; console.log(name, fileList);
let message = "是否确认导出所有的数据项?"; this[name].push({
if (this.ids) { name: fileList.name,
message = "是否确认导出选中的数据项?"; fileName: fileList.response.fileName,
queryParams.ids = this.ids; url: fileList.response.url,
} uid: fileList.uid,
this.$confirm(message, "警告", { });
confirmButtonText: "确定", console.log(name, this[name]);
cancelButtonText: "取消", },
type: "warning", handleRemove(file, name) {
}) // console.log(file, fileList1);
.then(function () { let index = this[name].findIndex((item) => item.uid === file.uid);
return exportYhxx(queryParams); //
}) this[name].splice(index, 1);
.then((response) => { },
this.downloadFile(response, true, response.msg); downloadFile2(info, index) {
// this.download(response.msg); console.log(info);
}) this.handlePreview(info);
.catch(function () {}); },
//
handlePreview(file) {
// console.log(file);
getFileStream({ fileName: file.fileName }).then((res) => {
const blob = new Blob([res], {
// type
// application/xlsx application/zip
type: "application/xlsx",
}); //excel,pdf
const href = URL.createObjectURL(blob); //URLblob
const a = document.createElement("a"); //a
a.style.display = "none";
a.href = href; //
a.download = file.name; //
a.click(); //
URL.revokeObjectURL(a.href); //URL
});
},
handleExceed(files, fileList) {
this.$message.warning(
`当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
files.length + fileList.length
} 个文件`
);
},
beforeRemove(file, fileList) {
return this.$confirm(`确定移除 ${file.name}`);
}, },
}, },
}; };

Loading…
Cancel
Save