This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
}"
|
||||
:readonly="readonly"
|
||||
:disabled="disabled"
|
||||
:clearable="!readonly && canClear"
|
||||
:label="label"
|
||||
:rules="rules"
|
||||
:error-messages="errorMessages"
|
||||
@@ -20,11 +19,16 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
/* Xeslint-disable //@click:append-outer="appendOuter"*/
|
||||
/* Xeslint-disable //@click:append-outer="appendOuter" */
|
||||
//https://dm4t2.github.io/vue-currency-input/guide/#introduction :value="formattedValue"
|
||||
//https://codesandbox.io/s/vue-template-kd7d1?fontsize=14&module=%2Fsrc%2FApp.vue
|
||||
//https://github.com/dm4t2/vue-currency-input
|
||||
//https://github.com/dm4t2/vue-currency-input/releases
|
||||
|
||||
//NOTE: when get sick of this not working, can look into this: https://github.com/phiny1/v-currency-field
|
||||
//which is purported to be exactly what I'm trying to do here with a v-text-field but better I guess??
|
||||
//or look at the source for ideas?
|
||||
|
||||
import { setValue, parseCurrency } from "vue-currency-input";
|
||||
export default {
|
||||
data() {
|
||||
@@ -41,8 +45,7 @@ export default {
|
||||
readonly: { type: Boolean, default: false },
|
||||
disabled: { type: Boolean, default: false },
|
||||
errorMessages: { type: Array, default: null },
|
||||
appendOuterIcon: { type: String, default: null },
|
||||
canClear: { type: Boolean, default: true }
|
||||
appendOuterIcon: { type: String, default: null }
|
||||
},
|
||||
computed: {
|
||||
currencyValue() {
|
||||
@@ -60,21 +63,12 @@ export default {
|
||||
return;
|
||||
}
|
||||
let val = this.$refs.textField.$refs.input.value;
|
||||
// //_value contains the actual underlying numeric value without text
|
||||
// //value contains the entered text
|
||||
// if (this.$refs.textField.$refs.input._value == this.value) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
let parsedValue = parseCurrency(val, {
|
||||
currency: this.currencyName,
|
||||
locale: this.languageName
|
||||
});
|
||||
|
||||
// //this.value on init is a very long string of digits / decimal places triggering a variance once rounded
|
||||
// let parsedOldValue = parseCurrency(this.value.toString(), {
|
||||
// currency: this.currencyName,
|
||||
// locale: this.languageName
|
||||
// });
|
||||
if (parsedValue != this.value) {
|
||||
this.$emit("input", parsedValue);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
<v-menu offset-y>
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<div class="text-h6">
|
||||
<v-icon large color="primary" class="mr-2">$ayiHammer</v-icon>
|
||||
<v-icon large color="primary" class="mr-2"
|
||||
>$ayiTruckMonster</v-icon
|
||||
>
|
||||
{{ $ay.t("WorkOrderItemTravelList") }}
|
||||
<v-btn v-if="!parentDeleted" large icon v-bind="attrs" v-on="on">
|
||||
<v-icon small color="primary">$ayiEllipsisV</v-icon>
|
||||
|
||||
@@ -791,6 +791,10 @@ async function saveItems(vm) {
|
||||
z => (z.workorderItemId = vm.obj.items[i].id)
|
||||
);
|
||||
|
||||
vm.obj.items[i].travels.forEach(
|
||||
z => (z.workorderItemId = vm.obj.items[i].id)
|
||||
);
|
||||
|
||||
//todo: other grandchildren
|
||||
}
|
||||
}
|
||||
@@ -808,6 +812,9 @@ async function saveItems(vm) {
|
||||
if (!vm.saveResult.fatal) {
|
||||
await saveLabors(vm, i);
|
||||
}
|
||||
if (!vm.saveResult.fatal) {
|
||||
await saveTravels(vm, i);
|
||||
}
|
||||
//todo: other grandchildren
|
||||
//------
|
||||
}
|
||||
@@ -992,6 +999,65 @@ async function deleteLabors(vm, woItemIndex) {
|
||||
return;
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
// TRAVEL
|
||||
//
|
||||
async function saveTravels(vm, woItemIndex) {
|
||||
//DELETE FLAGGED ITEMS FIRST
|
||||
await deleteTravels(vm, woItemIndex);
|
||||
if (vm.saveResult.fatal) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let i = 0; i < vm.obj.items[woItemIndex].travels.length; i++) {
|
||||
let o = vm.obj.items[woItemIndex].travels[i];
|
||||
if (o.isDirty) {
|
||||
const res = await window.$gz.api.upsert(
|
||||
`${API_BASE_URL}items/travels`,
|
||||
o
|
||||
);
|
||||
if (res.error) {
|
||||
handleSaveError(vm, {
|
||||
error: res.error,
|
||||
itemUid: vm.obj.items[woItemIndex].uid,
|
||||
childKey: "travels",
|
||||
childUid: o.uid
|
||||
});
|
||||
} else {
|
||||
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
|
||||
vm.obj.items[woItemIndex].travels.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
async function deleteTravels(vm, woItemIndex) {
|
||||
//walk the array backwards as items may be spliced out
|
||||
for (var i = vm.obj.items[woItemIndex].travels.length - 1; i >= 0; i--) {
|
||||
const d = vm.obj.items[woItemIndex].travels[i];
|
||||
if (!d.deleted) {
|
||||
continue;
|
||||
}
|
||||
let res = await window.$gz.api.remove(
|
||||
`${API_BASE_URL}items/travels/${d.id}`
|
||||
);
|
||||
if (res.error) {
|
||||
handleSaveError(vm, {
|
||||
error: res.error,
|
||||
itemUid: vm.obj.items[woItemIndex].uid,
|
||||
childKey: "travels",
|
||||
childUid: d.uid
|
||||
});
|
||||
} else {
|
||||
vm.obj.items[woItemIndex].travels.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//----
|
||||
return;
|
||||
}
|
||||
|
||||
//todo: other grandchildren
|
||||
|
||||
//######################################### UTILITY METHODS ###########################################
|
||||
|
||||
Reference in New Issue
Block a user