ElecticalFileModal.vue
4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<template>
<a-modal
:title="'批量修改'"
:width="800"
:visible="batchVisible"
:confirmLoading="confirmLoading"
@ok="handleBatchOk"
@cancel="handleBatchCancel"
cancelText="关闭"
wrapClassName="ant-modal-cust-warp"
style="top:5%;height: 85%;overflow-y: hidden">
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="区域电气图纸">
<input id="upfile" type="file" accept="image/*" class="add_upload_file" @change="fileUpload('1')" />
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="使用说明书">
<input id="upfile2" type="file" accept="file/*" class="add_upload_file" @change="fileUpload('2')" />
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="维修与保养手册">
<input id="upfile3" type="file" accept="file/*" class="add_upload_file" @change="fileUpload('3')" />
</a-form-item>
</a-form>
</a-spin>
</a-modal>
</template>
<script>
import { ajaxGetDictItems, editsBatchPurchase, editPurchase } from '../../../api/api'
export default {
name: 'ElecticalFileModal',
data() {
return {
code: '',
workno:'',
uuid:'',
electricalNo:'',
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
model: {},
batchVisible: false,
form: this.$form.createForm(this),
confirmLoading: false,
statusList:[],
status:'',
}
},
created() {
this.loadBaseData();
},
methods: {
handleBatchCancel() {
this.ids = ''
this.batchVisible = false
},
fileUpload(type){
let that = this;
let file = document.getElementById('upfile');
let fileName = file.value;
let files = file.files;
if(fileName == null || fileName==""){
this.$message.error("请选择文件");
}else{
let fileType = fileName.substr(fileName.length-4,fileName.length);
if(fileType == ".jpg" || fileType == ".png"){
if (files[0]) {
let formData = new window.FormData()
formData.append('file', files[0])
formData.append('mod', 5)
formData.append('opt', 2)
formData.append('workno', this.workno)
formData.append('uuid', this.uuid)
formData.append('code', this.code)
formData.append('type', type)
let data = {
mod: 5,
opt: 2,
formData
};
this.$message.info("上传中!")
fetch('http://127.0.0.1:8080/jeecg-boot/sys/upload/mmsEleMinio', {
method: 'POST',
body: formData,
headers: {
// Auth: 'token'
'Access-Control-Allow-Origin': '*',
Authorization: 'Bearer',
},
}).then((res) => {
return res.json()
}).then((res) => {
if (res.code == 0) {
let reader = new FileReader();
reader.readAsDataURL(files[0]);
reader.onload = function (e) {
console.log("aaa:"+this.result)
that.imgs.push({id: res.message, base64: this.result})
console.log(that.imgs)
}
this.$message.success("上传成功!")
} else {
this.$message.error("上传失败!")
}
})
} else {
this.$message.error("请选择要上传的图片");
}
}else{
this.$message.error("上传文件类型错误!");
}
}
},
edit (code,workno,uuid) {
this.code = code
this.workno = workno
this.uuid = uuid
this.form.resetFields();
this.batchVisible = true;
},
}
}
</script>
<style scoped>
</style>