93 lines
4.0 KiB
JavaScript
93 lines
4.0 KiB
JavaScript
(async function () {
|
|
|
|
|
|
Vue.component('stitched-item-table', {
|
|
props: ['items'],
|
|
methods: {
|
|
getFormattedDateTime: function (dateTime) {
|
|
if (!!dateTime) {
|
|
return dateTime.split('T')[0] + ' ' + dateTime.split('T')[1];
|
|
}
|
|
return luxon.DateTime.now().toFormat('yyyy-MM-dd HH:mm:ss');
|
|
},
|
|
removeItem: function (index) {
|
|
this.$emit('remove-item', index)
|
|
}
|
|
},
|
|
template: `
|
|
<table class="table table-bordered bg-white col-sm-12">
|
|
<thead>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>Item ID</th>
|
|
<th>Sku</th>
|
|
<th>Created By</th>
|
|
<th>Created At</th>
|
|
<th>Job Card ID</th>
|
|
<th>Barcode</th>
|
|
<th>Status</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr v-for="(item,index) in items">
|
|
<td>
|
|
<input hidden="hidden" v-bind:name="'items[' + index + '].id'" v-bind:value="item.id">
|
|
<input hidden="hidden" v-bind:name="'items[' + index + '].itemId'" v-bind:value="item.itemId">
|
|
<input hidden="hidden" v-bind:name="'items[' + index + '].sku'" v-bind:value="item.sku">
|
|
<input hidden="hidden" v-bind:name="'items[' + index + '].createdBy'" v-bind:value="item.createdBy">
|
|
<input hidden="hidden" v-bind:name="'items[' + index + '].createdAt'" v-bind:value="getFormattedDateTime(item.createdAt)">
|
|
<input hidden="hidden" v-bind:name="'items[' + index + '].jobCardId'" v-bind:value="item.jobCardId">
|
|
<input hidden="hidden" v-bind:name="'items[' + index + '].barcode'" v-bind:value="item.barcode" >
|
|
<input hidden="hidden" v-bind:name="'items[' + index + '].isQa'" v-bind:value="item.isQa">
|
|
<span> {{item.id}} </span>
|
|
</td>
|
|
<td> {{item.itemId}} </td>
|
|
<td> {{item.sku}} </td>
|
|
<td> {{item.createdBy}} </td>
|
|
<td> {{ getFormattedDateTime( item.createdAt) }} </td>
|
|
<td> {{item.jobCardId}}</td>
|
|
<td> {{item.barcode}} </td>
|
|
<td>
|
|
<select class="w-100" required v-bind:name="'items[' + index + '].qaStatus'" v-model="item.qaStatus">
|
|
<option value="APPROVED">APPROVED</option>
|
|
<option value="REJECT">REJECT</option>
|
|
</select><br>
|
|
<textarea class="w-100 mt-1" rows="2" v-model="item.remarks" v-if="item.qaStatus === 'REJECT'" v-bind:name="'items[' + index + '].qaRemarks'"></textarea>
|
|
</td>
|
|
<td>
|
|
<button type="button" title="Remove" class="btn btn-light text-left" v-on:click="removeItem(index)">
|
|
<i class="bi bi-trash"></i>
|
|
</button>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
`
|
|
});
|
|
|
|
|
|
let app = new Vue({
|
|
el: '#qcForm',
|
|
data: {
|
|
items: [],
|
|
},
|
|
methods: {
|
|
onItemSelect: function (id, item) {
|
|
this.items.push(item);
|
|
|
|
},
|
|
removeItem: function (index) {
|
|
this.items.splice(index, 1);
|
|
},
|
|
hasDuplicates: function () {
|
|
const ids = this.items.map(item => item.id);
|
|
const uniqueIds = new Set(ids);
|
|
return ids.length !== uniqueIds.size;
|
|
},
|
|
},
|
|
mounted: function () {
|
|
|
|
}
|
|
})
|
|
})(jQuery); |