ShipDetailsList.vue
6.5 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
<template>
<a-modal
:width="modalWidth"
:style="modalStyle"
:visible="visible"
:maskClosable="false"
@cancel="handleCancel">
<template slot="footer">
<a-button @click="handleCancel">确认收货</a-button>
<a-button @click="handleCancel">关闭</a-button>
</template>
<div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
<i class="anticon anticon-info-circle ant-alert-icon"></i>已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
<a style="margin-left: 24px" @click="onClearSelected">清空</a>
</div>
<a-table
ref="table"
rowKey="id"
size="middle"
:columns="columns"
:loading="loading"
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: selectChanges}"
:dataSource="dataSource"
:pagination="false">
</a-table>
<div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
上传收货信息图片:
</div>
<div class="add_upload_imgBox float_left">
<div class="add_upload_imgDiv float_left" v-for="(item, index) in imgs" :key="item.id + index">
<img :src="item.base64" />
<p class="add_upload_close" @click="handleDeleteImage(item.id)">
<img class="add_upload_close " src="~@/assets/delete.png" />
</p>
</div>
<div class="add_upload float_left">
<button class="add_upload_button">
<img class="add_upload_icon" src="~@/assets/add.png" />
<input id="upfile" type="file" accept="image/*" class="add_upload_file" @change="fileUpload" />
</button>
</div>
</div>
</a-modal>
</template>
<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import {queryDetailList} from "../../../api/api";
export default {
name: 'ShipDetailsList',
mixins:[JeecgListMixin, mixinDevice],
components: {
},
data () {
return {
description: '用来存储需要抓取的plm节点管理页面',
statusList: [],
modalWidth: '90%',
modalStyle: { 'top': '8px'},
ids:'',
imgs:[],
visible:false,
// 表头
columns: [
{
title: '#',
dataIndex: '',
key:'rowIndex',
width:60,
align:"center",
customRender:function (t,r,index) {
return parseInt(index)+1;
}
},
{
title:'名称',
align:"center",
dataIndex: 'name'
},
{
title:'编码',
align:"center",
dataIndex: 'no',
},
{
title:'数量',
align:"center",
dataIndex: 'num',
}
],
dictOptions:{},
superFieldList:[],
}
},
created() {
},
methods: {
edit (headId) {
this.visible=true
this.queryDetailsList(headId)
},
handleCancel(){
this.visible = false
this.dataSource=[];
},
queryDetailsList(headId){
let params = {
'headid': headId
}
queryDetailList(params).then((res) => {
if (res.success) {
this.dataSource = res.result
}
})
},
selectChanges(selectedRowKeys, selectionRows) {
this.selectedRowKeys = selectedRowKeys;
this.selectionRows = selectionRows;
var array='';
this.selectionRows.forEach(function (row) {
array += row.id + ",";
});
this.ids=array;
},
fileUpload(){
let that = this;
let file = document.getElementById('upfile');
let fileName = file.value;
let files = file.files;
console.log(files[0])
if(fileName == null || fileName==""){
alert("请选择文件");
}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)
let data = {
mod: 5,
opt: 2,
formData
};
fetch('/upload', {
method: 'POST',
body: formData,
headers: {
// Auth: 'token'
'Access-Control-Allow-Origin': '*',
Authorization: 'Bearer ',
},
}).then((res) => {
return res.json()
}).then((res) => {
console.log(res)
if (res.sta == 0) {
// 上传代码返回结果之后
// console.log(res.data)
} else {
console.log(res.msg)
}
})
let reader = new FileReader();
reader.readAsDataURL(files[0]);
reader.onload = function (e) {
let timestamp = (new Date()).valueOf();
that.imgs.push({id: timestamp, base64: this.result})
console.log(that.imgs)
}
} else {
alert("请选择要上传的图片");
}
}else{
alert("上传文件类型错误!");
}
}
},
handleDeleteImage(id) {
let that = this;
deleteImage()
function deleteImage() {
for(let i = 0; i < that.imgs.length; i+=1) {
if(that.imgs[i].id === id) {
that.imgs.splice(i, 1);
break;
}
}
}
},
}
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
<style scoped>
.float_left {
display: inline-block;
/*float: left;*/
margin-bottom: 0.4rem;
}
.add_upload .add_upload_button {
position: relative;
width: 4.5rem;
height: 4.5rem;
border: none;
background: rgb(236,236,236);
}
.add_upload .add_upload_icon {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
.add_upload .add_upload_file {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
opacity: 0;
font-size: 0;
}
.add_upload_imgBox .add_upload_imgDiv {
position: relative;
width: 4.5rem;
height: 4.5rem;
margin: 0 .0rem .0rem 0;
margin-left: 0.4rem;
}
.add_upload_imgBox .add_upload_imgDiv img {
width: 100%;
height: 100%;
}
.add_upload_imgBox .add_upload_close {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.add_upload_imgBox .add_upload_close img {
width: 100%;
height: 100%;
margin-top: 0.5rem;
}
</style>