99 lines
4.7 KiB
JavaScript
99 lines
4.7 KiB
JavaScript
(async function () {
|
|
Vue.prototype.$accounts = window.ctp.accounts;
|
|
|
|
Vue.component('finished-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 type="hidden" v-bind:name="'items[' + index + '].id'" v-bind:value="item.id">
|
|
<input type="hidden" v-bind:name="'items[' + index + '].itemId'" v-bind:value="item.itemId">
|
|
<input type="hidden" v-bind:name="'items[' + index + '].sku'" v-bind:value="item.sku">
|
|
<input type="hidden" v-bind:name="'items[' + index + '].createdBy'" v-bind:value="item.createdBy">
|
|
<input type="hidden" v-bind:name="'items[' + index + '].createdAt'" v-bind:value="getFormattedDateTime(item.createdAt)">
|
|
<input type="hidden" v-bind:name="'items[' + index + '].jobCardId'" v-bind:value="item.jobCardId">
|
|
<input type="hidden" v-bind:name="'items[' + index + '].barcode'" v-bind:value="item.barcode">
|
|
<input type="hidden" v-bind:name="'items[' + index + '].isQa'" v-bind:value="item.isQa">
|
|
<input type="hidden" v-bind:name="'items[' + index + '].stitchedItemId'" v-bind:value="item.stitchedItemId">
|
|
<input type="hidden" v-bind:name="'items[' + index + '].isSegregated'" v-bind:value="item.isSegregated">
|
|
<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>
|
|
<span v-if="!item.qaStatus" class="badge badge-danger">NOT PERFORMED</span>
|
|
<span v-else-if="item.qaStatus === 'APPROVED'" class="font-lg badge badge-success">{{ item.qaStatus }}</span>
|
|
<span v-else-if="item.qaStatus === 'ALTER' || item.qaStatus === 'B GRADE' || item.qaStatus === 'C GRADE' " class="font-lg badge badge-danger">{{ item.qaStatus }}</span>
|
|
<span v-else-if="item.qaStatus === 'WASHED'" class="font-lg badge badge-APPROVED">{{ item.qaStatus }}</span>
|
|
<td>
|
|
<button type="button" class="btn btn-light" v-on:click="removeItem(index)">
|
|
<i class="bi bi-trash"></i>
|
|
</button>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
`
|
|
});
|
|
|
|
let app = new Vue({
|
|
el: '#finishedApp',
|
|
data: {
|
|
items: [],
|
|
QaStatus: 'APPROVED'
|
|
},
|
|
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;
|
|
},
|
|
submitWithQaStatus: function (status) {
|
|
this.QaStatus = status;
|
|
this.$nextTick(() => {
|
|
document.getElementById('finishedApp').submit();
|
|
});
|
|
}
|
|
},
|
|
mounted: function () {
|
|
console.log(this.$accounts);
|
|
}
|
|
});
|
|
})(jQuery);
|