質問編集履歴
2
Javascriptで試した内容を追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,7 +22,15 @@
|
|
22
22
|
|
23
23
|
v-data-table にヘッダ配列とアイテム配列を渡し表示しています。
|
24
24
|
|
25
|
-
|
25
|
+
アイテム配列の[shipment]欄に空欄があった場合にその行の色を変更したいのですが、やり方が分かりません。
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
現状試したことは、items配列に入れているworkers配列に!value.shipmentを条件に行の色を変更する処理を入れてみました。
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
うまく動かず、現状もがいている状態です。
|
26
34
|
|
27
35
|
|
28
36
|
|
@@ -66,6 +74,92 @@
|
|
66
74
|
|
67
75
|
|
68
76
|
|
77
|
+
methods: {
|
78
|
+
|
79
|
+
//CSVをインポートさせる処理
|
80
|
+
|
81
|
+
fileChange: function (e) {
|
82
|
+
|
83
|
+
console.log(e);
|
84
|
+
|
85
|
+
const file = e;
|
86
|
+
|
87
|
+
const reader = new FileReader();
|
88
|
+
|
89
|
+
const workers = [];
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
const loadFunc = () => {
|
94
|
+
|
95
|
+
const lines = reader.result.split("\n");
|
96
|
+
|
97
|
+
lines.forEach((element) => {
|
98
|
+
|
99
|
+
const workerData = element.split(",");
|
100
|
+
|
101
|
+
if (workerData.length != 12) return;
|
102
|
+
|
103
|
+
const worker = {
|
104
|
+
|
105
|
+
TradeTerms: workerData[0],
|
106
|
+
|
107
|
+
ShipmentBy: workerData[1],
|
108
|
+
|
109
|
+
ShipTo: workerData[2],
|
110
|
+
|
111
|
+
PO: workerData[3],
|
112
|
+
|
113
|
+
CommodityDescription: workerData[4],
|
114
|
+
|
115
|
+
Manufacturer: workerData[5],
|
116
|
+
|
117
|
+
QTY: workerData[6],
|
118
|
+
|
119
|
+
Unit: workerData[7],
|
120
|
+
|
121
|
+
UnitPrice: workerData[8],
|
122
|
+
|
123
|
+
TotalPrice: workerData[9],
|
124
|
+
|
125
|
+
RequestETD: workerData[10],
|
126
|
+
|
127
|
+
Remarks: workerData[11],
|
128
|
+
|
129
|
+
};
|
130
|
+
|
131
|
+
workers.push(worker);
|
132
|
+
|
133
|
+
});
|
134
|
+
|
135
|
+
this.workers = workers;
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
//試したやり方(空白の行に対して色を指定)
|
140
|
+
|
141
|
+
this.workers.forEach(function (value, index) {
|
142
|
+
|
143
|
+
if (!value.ShipmentBy) {
|
144
|
+
|
145
|
+
console.log(index);
|
146
|
+
|
147
|
+
this.workers[index].style.color="red"
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
});
|
152
|
+
|
153
|
+
};
|
154
|
+
|
155
|
+
reader.onload = loadFunc;
|
156
|
+
|
157
|
+
reader.readAsBinaryString(file);
|
158
|
+
|
159
|
+
},
|
160
|
+
|
161
|
+
|
162
|
+
|
69
163
|
|
70
164
|
|
71
165
|
```
|
1
内容を簡潔なものに変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
## やりたいこと
|
2
2
|
|
3
|
-
Vuetifyのv-datatable
|
3
|
+
Vuetifyのv-datatable で特定の行の色を変える。
|
4
4
|
|
5
5
|
|
6
6
|
|
@@ -18,19 +18,15 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
-
##
|
21
|
+
## 現状
|
22
22
|
|
23
|
-
|
23
|
+
v-data-table にヘッダ配列とアイテム配列を渡し表示しています。
|
24
24
|
|
25
|
-
|
25
|
+
この表示している内容の中で空欄があった場合にその行の色を変更したいのですが、やり方が分かりません。
|
26
26
|
|
27
27
|
|
28
28
|
|
29
|
-
|
29
|
+
Vue,Vuetifyに知見のある方、アドバイスのほどよろしくお願いします。
|
30
|
-
|
31
|
-
便利なライブラリとかないものか。。。
|
32
|
-
|
33
|
-
|
34
30
|
|
35
31
|
|
36
32
|
|
@@ -38,63 +34,11 @@
|
|
38
34
|
|
39
35
|
|
40
36
|
|
41
|
-
```Javascript
|
37
|
+
```Javascript(一部)
|
42
38
|
|
43
39
|
<template>
|
44
40
|
|
45
|
-
|
41
|
+
|
46
|
-
|
47
|
-
<v-row align="center" justify="left">
|
48
|
-
|
49
|
-
<h1>CSVインポート</h1>
|
50
|
-
|
51
|
-
</v-row>
|
52
|
-
|
53
|
-
<v-row align="Left" style="height: 70px;">
|
54
|
-
|
55
|
-
<v-col>
|
56
|
-
|
57
|
-
<div>
|
58
|
-
|
59
|
-
<Dropdown></Dropdown>
|
60
|
-
|
61
|
-
</div>
|
62
|
-
|
63
|
-
</v-col>
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
<v-col>
|
68
|
-
|
69
|
-
<v-file-input
|
70
|
-
|
71
|
-
@change="fileChange"
|
72
|
-
|
73
|
-
label="CSVファイルを選択してください"
|
74
|
-
|
75
|
-
id="file_input_expense"
|
76
|
-
|
77
|
-
type="file"
|
78
|
-
|
79
|
-
v-validate="required"
|
80
|
-
|
81
|
-
></v-file-input>
|
82
|
-
|
83
|
-
</v-col>
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
<v-col>
|
88
|
-
|
89
|
-
<div align="right">
|
90
|
-
|
91
|
-
<v-btn color="primary" @click="btnClick">登録</v-btn>
|
92
|
-
|
93
|
-
</div>
|
94
|
-
|
95
|
-
</v-col>
|
96
|
-
|
97
|
-
</v-row>
|
98
42
|
|
99
43
|
<v-row align="center" fluid>
|
100
44
|
|
@@ -104,29 +48,7 @@
|
|
104
48
|
|
105
49
|
<template slot="items" slot-scope="props">
|
106
50
|
|
107
|
-
<td class="text-xs-right">{{ props.item.TradeTerms }}</td>
|
108
51
|
|
109
|
-
<td class="text-xs-right">{{ props.item.ShipmentBy }}</td>
|
110
|
-
|
111
|
-
<td class="text-xs-right">{{ props.item.ShipTo }}</td>
|
112
|
-
|
113
|
-
<td class="text-xs-right">{{ props.item.PO }}</td>
|
114
|
-
|
115
|
-
<td class="text-xs-right">{{ props.item.CommodityDescription }}</td>
|
116
|
-
|
117
|
-
<td class="text-xs-right">{{ props.item.Manufacturer }}</td>
|
118
|
-
|
119
|
-
<td class="text-xs-right">{{ props.item.QTY }}</td>
|
120
|
-
|
121
|
-
<td class="text-xs-right">{{ props.item.Unit }}</td>
|
122
|
-
|
123
|
-
<td class="text-xs-right">{{ props.item.UnitPrice }}</td>
|
124
|
-
|
125
|
-
<td class="text-xs-right">{{ props.item.TotalPrice }}</td>
|
126
|
-
|
127
|
-
<td class="text-xs-right">{{ props.item.RequestETD }}</td>
|
128
|
-
|
129
|
-
<td class="text-xs-right">{{ props.item.Remarks }}</td>
|
130
52
|
|
131
53
|
</template>
|
132
54
|
|
@@ -142,268 +64,6 @@
|
|
142
64
|
|
143
65
|
|
144
66
|
|
145
|
-
<script>
|
146
|
-
|
147
|
-
import Dropdown from "@/components/Dropdown.vue";
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
export default {
|
152
|
-
|
153
|
-
components: {
|
154
|
-
|
155
|
-
Dropdown
|
156
|
-
|
157
|
-
},
|
158
|
-
|
159
|
-
data: function() {
|
160
|
-
|
161
|
-
return {
|
162
|
-
|
163
|
-
headers: [
|
164
|
-
|
165
|
-
{
|
166
|
-
|
167
|
-
text: "TradeTerms",
|
168
|
-
|
169
|
-
align: "left",
|
170
|
-
|
171
|
-
sortable: false,
|
172
|
-
|
173
|
-
value: "TradeTerms"
|
174
|
-
|
175
|
-
},
|
176
|
-
|
177
|
-
{
|
178
|
-
|
179
|
-
text: "ShipmentBy",
|
180
|
-
|
181
|
-
align: "left",
|
182
|
-
|
183
|
-
sortable: false,
|
184
|
-
|
185
|
-
value: "ShipmentBy"
|
186
|
-
|
187
|
-
},
|
188
|
-
|
189
|
-
{
|
190
|
-
|
191
|
-
text: "ShipTo",
|
192
|
-
|
193
|
-
align: "left",
|
194
|
-
|
195
|
-
sortable: false,
|
196
|
-
|
197
|
-
value: "ShipTo"
|
198
|
-
|
199
|
-
},
|
200
|
-
|
201
|
-
{
|
202
|
-
|
203
|
-
text: "PO",
|
204
|
-
|
205
|
-
align: "left",
|
206
|
-
|
207
|
-
sortable: false,
|
208
|
-
|
209
|
-
value: "PO"
|
210
|
-
|
211
|
-
},
|
212
|
-
|
213
|
-
{
|
214
|
-
|
215
|
-
text: "CommodityDescription",
|
216
|
-
|
217
|
-
align: "left",
|
218
|
-
|
219
|
-
sortable: false,
|
220
|
-
|
221
|
-
value: "CommodityDescription"
|
222
|
-
|
223
|
-
},
|
224
|
-
|
225
|
-
{
|
226
|
-
|
227
|
-
text: "Manufacturer",
|
228
|
-
|
229
|
-
align: "left",
|
230
|
-
|
231
|
-
sortable: false,
|
232
|
-
|
233
|
-
value: "Manufacturer"
|
234
|
-
|
235
|
-
},
|
236
|
-
|
237
|
-
{
|
238
|
-
|
239
|
-
text: "QTY",
|
240
|
-
|
241
|
-
align: "left",
|
242
|
-
|
243
|
-
sortable: false,
|
244
|
-
|
245
|
-
value: "QTY"
|
246
|
-
|
247
|
-
},
|
248
|
-
|
249
|
-
{
|
250
|
-
|
251
|
-
text: "Unit",
|
252
|
-
|
253
|
-
align: "left",
|
254
|
-
|
255
|
-
sortable: false,
|
256
|
-
|
257
|
-
value: "Unit"
|
258
|
-
|
259
|
-
},
|
260
|
-
|
261
|
-
{
|
262
|
-
|
263
|
-
text: "UnitPrice",
|
264
|
-
|
265
|
-
align: "left",
|
266
|
-
|
267
|
-
sortable: false,
|
268
|
-
|
269
|
-
value: "UnitPrice"
|
270
|
-
|
271
|
-
},
|
272
|
-
|
273
|
-
{
|
274
|
-
|
275
|
-
text: "TotalPrice",
|
276
|
-
|
277
|
-
align: "left",
|
278
|
-
|
279
|
-
sortable: false,
|
280
|
-
|
281
|
-
value: "TotalPrice"
|
282
|
-
|
283
|
-
},
|
284
|
-
|
285
|
-
{
|
286
|
-
|
287
|
-
text: "RequestETD",
|
288
|
-
|
289
|
-
align: "left",
|
290
|
-
|
291
|
-
sortable: false,
|
292
|
-
|
293
|
-
value: "RequestETD"
|
294
|
-
|
295
|
-
},
|
296
|
-
|
297
|
-
{
|
298
|
-
|
299
|
-
text: "Remarks",
|
300
|
-
|
301
|
-
align: "left",
|
302
|
-
|
303
|
-
sortable: false,
|
304
|
-
|
305
|
-
value: "Remarks"
|
306
|
-
|
307
|
-
}
|
308
|
-
|
309
|
-
],
|
310
|
-
|
311
|
-
workers: []
|
312
|
-
|
313
|
-
};
|
314
|
-
|
315
|
-
},
|
316
|
-
|
317
|
-
methods: {
|
318
|
-
|
319
|
-
required: value => !!value || "未入力の項目があります。",
|
320
|
-
|
321
|
-
fileChange: function(e) {
|
322
|
-
|
323
|
-
console.log(e);
|
324
|
-
|
325
|
-
const file = e;
|
326
|
-
|
327
|
-
const reader = new FileReader();
|
328
|
-
|
329
|
-
const workers = [];
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
const loadFunc = () => {
|
334
|
-
|
335
|
-
const lines = reader.result.split("\n");
|
336
|
-
|
337
|
-
lines.forEach(element => {
|
338
|
-
|
339
|
-
const workerData = element.split(",");
|
340
|
-
|
341
|
-
if (workerData.length != 12) return;
|
342
|
-
|
343
|
-
const worker = {
|
344
|
-
|
345
|
-
TradeTerms: workerData[0],
|
346
|
-
|
347
|
-
ShipmentBy: workerData[1],
|
348
|
-
|
349
|
-
ShipTo: workerData[2],
|
350
|
-
|
351
|
-
PO: workerData[3],
|
352
|
-
|
353
|
-
CommodityDescription: workerData[4],
|
354
|
-
|
355
|
-
Manufacturer: workerData[5],
|
356
|
-
|
357
|
-
QTY: workerData[6],
|
358
|
-
|
359
|
-
Unit: workerData[7],
|
360
|
-
|
361
|
-
UnitPrice: workerData[8],
|
362
|
-
|
363
|
-
TotalPrice: workerData[9],
|
364
|
-
|
365
|
-
RequestETD: workerData[10],
|
366
|
-
|
367
|
-
Remarks: workerData[11]
|
368
|
-
|
369
|
-
};
|
370
|
-
|
371
|
-
workers.push(worker);
|
372
|
-
|
373
|
-
});
|
374
|
-
|
375
|
-
this.workers = workers;
|
376
|
-
|
377
|
-
};
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
reader.onload = loadFunc;
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
reader.readAsBinaryString(file);
|
386
|
-
|
387
|
-
},
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
btnClick: function(e) {
|
392
|
-
|
393
|
-
{
|
394
|
-
|
395
|
-
alert(this.workers);
|
396
|
-
|
397
|
-
}
|
398
|
-
|
399
|
-
}
|
400
|
-
|
401
|
-
}
|
402
|
-
|
403
|
-
};
|
404
|
-
|
405
|
-
</script>
|
406
|
-
|
407
67
|
|
408
68
|
|
409
69
|
|