cut-to-pack-service/src/main/resources/static/js/finishing/finished-item-segregation-f...

109 lines
5.2 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>Account</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">
<input hidden="hidden" v-bind:name="'items[' + index + '].stitchedItemId'" v-bind:value="item.stitchedItemId">
<input hidden="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>
<select class="w-100" required v-bind:name="'items[' + index + '].qaStatus'" v-model="item.qaStatus">
<option value="WASHED">WASHED</option>
<option value="ALTER">ALTER</option>
<option value="APPROVED">APPROVED</option>
</select><br>
<!-- <textarea class="w-100 mt-1" rows="2" v-model="item.qaRemarks" -->
<!-- v-if="item.accountId === '0'" -->
<!-- v-bind:name="'items[' + index + '].qaRemarks'"></textarea> -->
</td>
<td>
<select class="w-100" required v-bind:name="'items[' + index + '].accountId'"
v-model="item.accountId"
v-bind:disabled="item.qaStatus !== 'APPROVED'"
v-bind:required="item.qaStatus === 'APPROVED'">
<option v-for="(option,index) in $accounts"
v-bind:value="option.id">{{option.title}}</option>
</select>
</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 : '#finishedApp',
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 () {
console.log( this.$accounts )
}
})
})(jQuery)