|
|
@@ -27,16 +27,18 @@
|
|
|
<div class="card-body">
|
|
|
<div class="tab-content">
|
|
|
<div class="tab-pane active" id="assetinfo" role="tabpanel" aria-labelledby="assetinfo-tab">
|
|
|
- <!-- <assetinfo asset="{{$asset}}"></assetinfo> -->
|
|
|
+ <asset-info v-if="!assetLoading" :asset="asset"></asset-info>
|
|
|
+ <circle-spinner v-else :color="'#663399'"></circle-spinner>
|
|
|
</div>
|
|
|
<!-- @if($workOrder->asset->group !== null)
|
|
|
<div class="tab-pane" id="group" role="tabpanel" aria-labelledby="group-tab">
|
|
|
Name: {{$workOrder->asset->group->pcgroupname}}
|
|
|
</div>
|
|
|
- @endif
|
|
|
+ @endif -->
|
|
|
<div class="tab-pane" id="credentials" role="tabpanel" aria-labelledby="credentials-tab">
|
|
|
- <credential-list :credential-list="{{$workOrder->asset->credentials->sortByDesc('creddate')->values()}}" :descriptions="{{App\CredDesc::all()}}" :pcid="{{$workOrder->asset->pcid}}"></credential-list>
|
|
|
- </div> -->
|
|
|
+ <credential-list v-if="!credentialsLoading && !credentialDescriptionsLoading" :credentials="credentials" :descriptions="credentialDescriptions" :pcid="asset.pcid"></credential-list>
|
|
|
+ <circle-spinner v-else color="#663399"></circle-spinner>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -62,7 +64,8 @@
|
|
|
<div class='card-body'>
|
|
|
<div class='tab-content'>
|
|
|
<div class="tab-pane active" id="workordersumm" role="tabpanel" aria-labelledby="workordersumm-tab">
|
|
|
- <work-order-info :work-order="workOrder" :stores="stores"></work-order-info>
|
|
|
+ <work-order-info v-if="!woLoading && !storesLoading" :work-order="workOrder" :stores="stores"></work-order-info>
|
|
|
+ <circle-spinner v-else :color="'#663399'"></circle-spinner>
|
|
|
</div>
|
|
|
<div class="tab-pane" id="attachments" role="tabpanel" aria-labelledby="attachments-tab">
|
|
|
TODO 2
|
|
|
@@ -72,12 +75,13 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <!-- <div class="row my-3 no-gutters">
|
|
|
+ <div class="row my-3 no-gutters">
|
|
|
<div class="col-12">
|
|
|
<div class="card">
|
|
|
<div class="card-body">
|
|
|
<h5 class="card-title">Customer Notes</h5>
|
|
|
- <notes :initialnotes='{{ $workOrder->notes->where('notetype', '0')->values() }}' authusername="{{Auth::user()->username}}" :note-type="0" :woid="{{$workOrder->woid}}"></notes>
|
|
|
+ <notes v-if="!workOrderNotesLoading" :notes="publicNotes" :authusername="authUser" :note-type="0" :woid="id"></notes>
|
|
|
+ <circle-spinner v-else color="#663399"></circle-spinner>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -87,49 +91,146 @@
|
|
|
<div class="card">
|
|
|
<div class="card-body">
|
|
|
<h5 class="card-title">Private/Billing Notes</h5>
|
|
|
- <notes :initialnotes='{{ $workOrder->notes->where('notetype', '1')->values() }}' authusername="{{Auth::user()->username}}" :note-type="1" :woid="{{$workOrder->woid}}"></notes>
|
|
|
+ <notes v-if="!workOrderNotesLoading" :notes="privateNotes" :authusername="authUser" :note-type="1" :woid="id"></notes>
|
|
|
+ <circle-spinner v-else color="#663399"></circle-spinner>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- </div> -->
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
import WorkOrderInfo from '../components/WorkOrderInfo.vue'
|
|
|
+import AssetInfo from '../components/AssetInfo.vue'
|
|
|
+import CircleSpinner from '../components/CircleSpinner.vue'
|
|
|
+import CredentialList from '../components/CredentialList.vue'
|
|
|
+import Notes from '../components/Notes.vue'
|
|
|
export default {
|
|
|
components: {
|
|
|
WorkOrderInfo,
|
|
|
+ AssetInfo,
|
|
|
+ CircleSpinner,
|
|
|
+ CredentialList,
|
|
|
+ Notes,
|
|
|
+ },
|
|
|
+ props: {
|
|
|
+ id: {
|
|
|
+ type: String,
|
|
|
+ required: true,
|
|
|
+ }
|
|
|
},
|
|
|
- props: ['id'],
|
|
|
data () {
|
|
|
return {
|
|
|
workOrder: {},
|
|
|
+ asset: {},
|
|
|
stores: {},
|
|
|
+ credentials: {},
|
|
|
+ credentialDescriptions: {},
|
|
|
+ workOrderNotes: [],
|
|
|
+ woLoading: true,
|
|
|
+ assetLoading: true,
|
|
|
+ storesLoading: true,
|
|
|
+ credentialsLoading: true,
|
|
|
+ credentialDescriptionsLoading: true,
|
|
|
+ workOrderNotesLoading: true,
|
|
|
+ authUser: localStorage.getItem('user'),
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ publicNotes: function() {
|
|
|
+ let notes = []
|
|
|
+ notes = this.workOrderNotes.filter(note => note.notetype === 0)
|
|
|
+ return notes
|
|
|
+ },
|
|
|
+ privateNotes: function() {
|
|
|
+ let notes = []
|
|
|
+ notes = this.workOrderNotes.filter(note => note.notetype === 1)
|
|
|
+ return notes
|
|
|
}
|
|
|
},
|
|
|
mounted () {
|
|
|
+ // Get authentication info from current user from local storage
|
|
|
let token = localStorage.getItem('jwt')
|
|
|
let user = localStorage.getItem('user')
|
|
|
|
|
|
+ // Set some axios config options for Content-Type and Authentication.
|
|
|
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
|
|
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
|
|
|
|
|
|
+ // Get WorkOrder from API
|
|
|
axios.get('/api/workorders/'+this.id).then(response => {
|
|
|
this.workOrder = response.data
|
|
|
+ this.woLoading = false
|
|
|
}).catch(error => {
|
|
|
console.log(error)
|
|
|
})
|
|
|
|
|
|
+ // Get list of stores from API
|
|
|
axios.get('/api/stores/').then(response => {
|
|
|
this.stores = response.data
|
|
|
+ this.storesLoading = false
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(error)
|
|
|
+ })
|
|
|
+
|
|
|
+ // Get Asset from API (will most likely be replaced with list of assets
|
|
|
+ // in the future. Current each WO can only have one but that is likely
|
|
|
+ // to change)
|
|
|
+ axios.get(`/api/workorders/${this.id}/asset`).then(response => {
|
|
|
+ this.asset = response.data
|
|
|
+ this.assetLoading = false
|
|
|
+
|
|
|
+ // Get Credentials for this asset. May be relocated to be part of asset
|
|
|
+ // Component when WOs can have more than one asset.
|
|
|
+ axios.get(`/api/assets/${this.asset.pcid}/credentials`).then (response => {
|
|
|
+ this.credentials = response.data
|
|
|
+ this.credentialsLoading = false
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(error)
|
|
|
+ })
|
|
|
+
|
|
|
+ // Get default list of Credential Descriptions. May be relocated along with
|
|
|
+ // the above.
|
|
|
+ axios.get('/api/credentials/descriptions').then(response => {
|
|
|
+ this.credentialDescriptions = response.data
|
|
|
+ this.credentialDescriptionsLoading = false
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(error)
|
|
|
+ })
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(error)
|
|
|
+ })
|
|
|
+
|
|
|
+ axios.get(`/api/workorders/${this.id}/notes`).then(response => {
|
|
|
+ this.workOrderNotes = response.data
|
|
|
+ this.workOrderNotesLoading = false
|
|
|
}).catch(error => {
|
|
|
console.log(error)
|
|
|
})
|
|
|
|
|
|
Echo.channel('work-order.'+this.id)
|
|
|
- .listen('WorkOrderUpdated', (e) => {
|
|
|
- this.workOrder = e.data;
|
|
|
- });
|
|
|
+ .listen('WorkOrderUpdated', (e) => {
|
|
|
+ this.workOrder = e.data;
|
|
|
+ });
|
|
|
+
|
|
|
+ Echo.channel('wonotes.'+this.id)
|
|
|
+ .listen('WorkOrderNoteAdded', (e) => {
|
|
|
+ this.workOrderNotes.push(e.note)
|
|
|
+ })
|
|
|
+ .listen('WorkOrderNoteUpdated', (e) => {
|
|
|
+ let index = this.workOrderNotes.findIndex((note) => {
|
|
|
+ return note.noteid === e.note.noteid
|
|
|
+ })
|
|
|
+ // Note has to be edited this way, or else Vue cannot
|
|
|
+ // see it to recompute the computed values.
|
|
|
+ this.workOrderNotes.splice(index, 1, e.note)
|
|
|
+ })
|
|
|
+ .listen('WorkOrderNoteDeleted', (e) => {
|
|
|
+ let index = this.notes.findIndex((note) => {
|
|
|
+ return note.noteid === e.noteid
|
|
|
+ })
|
|
|
+ this.notes.splice(index, 1)
|
|
|
+ })
|
|
|
},
|
|
|
}
|
|
|
</script>
|