質問編集履歴
1
改修対象のソースについて修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -158,7 +158,7 @@
|
|
158
158
|
|
159
159
|
|
160
160
|
|
161
|
-
```
|
161
|
+
```Vue.js コンポーネント
|
162
162
|
|
163
163
|
<template>
|
164
164
|
|
@@ -166,97 +166,91 @@
|
|
166
166
|
|
167
167
|
<h2>ここで合計金額を表示したい!!</h2>
|
168
168
|
|
169
|
-
<
|
170
|
-
|
171
|
-
<d
|
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
|
-
<label for="journal" class="col-sm-3 col-form-label">Journal</label>
|
230
|
-
|
231
|
-
<input type="text" class="col-sm-9 form-control" id="journal" v-model="cost.journal" />
|
232
|
-
|
233
|
-
</div>
|
234
|
-
|
235
|
-
<button type="submit" class="btn btn-primary">Submit</button>
|
236
|
-
|
237
|
-
</form>
|
238
|
-
|
239
|
-
</div>
|
240
|
-
|
241
|
-
</div>
|
169
|
+
<table class="table table-hover">
|
170
|
+
|
171
|
+
<thead class="thead-light">
|
172
|
+
|
173
|
+
<tr>
|
174
|
+
|
175
|
+
<th scope="col">id</th>
|
176
|
+
|
177
|
+
<th scope="col">account</th>
|
178
|
+
|
179
|
+
<th scope="col">price</th>
|
180
|
+
|
181
|
+
<th scope="col">journal</th>
|
182
|
+
|
183
|
+
<th scope="col">year</th>
|
184
|
+
|
185
|
+
<th scope="col">month</th>
|
186
|
+
|
187
|
+
<th scope="col">day</th>
|
188
|
+
|
189
|
+
<th scope="col">Watch</th>
|
190
|
+
|
191
|
+
</tr>
|
192
|
+
|
193
|
+
</thead>
|
194
|
+
|
195
|
+
<tbody>
|
196
|
+
|
197
|
+
<tr v-for="(cost, index) in costs" :key="index">
|
198
|
+
|
199
|
+
<th scope="row">{{ cost.id }}</th>
|
200
|
+
|
201
|
+
<td>{{ cost.accountName }}</td>
|
202
|
+
|
203
|
+
<td>{{ cost.price }}</td>
|
204
|
+
|
205
|
+
<td>{{ cost.journal }}</td>
|
206
|
+
|
207
|
+
<td>{{ cost.year }}</td>
|
208
|
+
|
209
|
+
<td>{{ cost.month }}</td>
|
210
|
+
|
211
|
+
<td>{{ cost.day }}</td>
|
212
|
+
|
213
|
+
<td>
|
214
|
+
|
215
|
+
<router-link v-bind:to="{name: 'cost.detail', params: { costId: cost.id } }">
|
216
|
+
|
217
|
+
<button class="btn btn-primary">Watch</button>
|
218
|
+
|
219
|
+
</router-link>
|
220
|
+
|
221
|
+
</td>
|
222
|
+
|
223
|
+
</tr>
|
224
|
+
|
225
|
+
</tbody>
|
226
|
+
|
227
|
+
</table>
|
242
228
|
|
243
229
|
</div>
|
244
230
|
|
245
231
|
</template>
|
246
232
|
|
247
|
-
|
248
|
-
|
249
233
|
<script>
|
250
234
|
|
251
235
|
export default {
|
252
236
|
|
237
|
+
props: {
|
238
|
+
|
239
|
+
year: Number,
|
240
|
+
|
241
|
+
month: Number,
|
242
|
+
|
243
|
+
day: Number,
|
244
|
+
|
245
|
+
},
|
246
|
+
|
253
247
|
data: function () {
|
254
248
|
|
255
249
|
return {
|
256
250
|
|
257
|
-
cost:
|
251
|
+
costs: [],
|
258
|
-
|
252
|
+
|
259
|
-
a
|
253
|
+
totalAmount: 0,
|
260
254
|
|
261
255
|
};
|
262
256
|
|
@@ -264,45 +258,51 @@
|
|
264
258
|
|
265
259
|
methods: {
|
266
260
|
|
267
|
-
s
|
261
|
+
getCostData() {
|
262
|
+
|
268
|
-
|
263
|
+
if (this.day === undefined) {
|
264
|
+
|
265
|
+
axios
|
266
|
+
|
269
|
-
|
267
|
+
.get("/api/cost/list/" + this.year + "/" + this.month)
|
268
|
+
|
270
|
-
|
269
|
+
.then((res) => {
|
270
|
+
|
271
|
-
this.
|
271
|
+
this.costs = res.data;
|
272
|
-
|
272
|
+
|
273
|
-
});
|
273
|
+
});
|
274
|
+
|
275
|
+
} else {
|
276
|
+
|
277
|
+
axios
|
278
|
+
|
279
|
+
.get(
|
280
|
+
|
281
|
+
"/api/cost/list/" + this.year + "/" + this.month + "/" + this.day
|
282
|
+
|
283
|
+
)
|
284
|
+
|
285
|
+
.then((res) => {
|
286
|
+
|
287
|
+
this.costs = res.data;
|
288
|
+
|
289
|
+
});
|
290
|
+
|
291
|
+
}
|
292
|
+
|
293
|
+
for (var item in this.costs) {
|
294
|
+
|
295
|
+
totalAmount += this.costs[item]["price"];
|
296
|
+
|
297
|
+
}
|
274
298
|
|
275
299
|
},
|
276
300
|
|
277
|
-
fillDateInfo() {
|
278
|
-
|
279
|
-
var now = new Date();
|
280
|
-
|
281
|
-
this.cost.year = now.getFullYear();
|
282
|
-
|
283
|
-
this.cost.month = now.getMonth() + 1;
|
284
|
-
|
285
|
-
this.cost.day = now.getDate();
|
286
|
-
|
287
|
-
},
|
288
|
-
|
289
|
-
getAccountList() {
|
290
|
-
|
291
|
-
axios.get("/api/account/list").then((res) => {
|
292
|
-
|
293
|
-
this.accounts = res.data;
|
294
|
-
|
295
|
-
});
|
296
|
-
|
297
|
-
},
|
298
|
-
|
299
301
|
},
|
300
302
|
|
301
303
|
mounted() {
|
302
304
|
|
303
|
-
this.get
|
305
|
+
this.getCostData();
|
304
|
-
|
305
|
-
this.fillDateInfo();
|
306
306
|
|
307
307
|
},
|
308
308
|
|
@@ -312,4 +312,6 @@
|
|
312
312
|
|
313
313
|
|
314
314
|
|
315
|
+
|
316
|
+
|
315
317
|
```
|