PC Number defaults to serial number (editable)
On a new PC, the PC Number (assetnumber) auto-fills from the serial number as it is typed, but stops auto-filling once the user edits it manually. Edit mode never auto-overwrites. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,9 @@
|
|||||||
type="text"
|
type="text"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
required
|
required
|
||||||
|
@input="onPcNumberInput"
|
||||||
/>
|
/>
|
||||||
|
<small class="form-hint">Defaults to the serial number; editable</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -266,7 +268,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, computed } from 'vue'
|
import { ref, onMounted, computed, watch } from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import { computersApi, assetsApi, vendorsApi, locationsApi, modelsApi, operatingsystemsApi } from '../../api'
|
import { computersApi, assetsApi, vendorsApi, locationsApi, modelsApi, operatingsystemsApi } from '../../api'
|
||||||
import ShopFloorMap from '../../components/ShopFloorMap.vue'
|
import ShopFloorMap from '../../components/ShopFloorMap.vue'
|
||||||
@@ -281,6 +283,13 @@ const router = useRouter()
|
|||||||
|
|
||||||
const isEdit = computed(() => !!route.params.id)
|
const isEdit = computed(() => !!route.params.id)
|
||||||
|
|
||||||
|
// PC Number (assetnumber) defaults to the serial number while the user hasn't
|
||||||
|
// typed their own. Editable; only auto-fills on a new PC.
|
||||||
|
const manualPcNumber = ref(false)
|
||||||
|
function onPcNumberInput() {
|
||||||
|
manualPcNumber.value = true
|
||||||
|
}
|
||||||
|
|
||||||
const loading = ref(true)
|
const loading = ref(true)
|
||||||
const saving = ref(false)
|
const saving = ref(false)
|
||||||
const error = ref('')
|
const error = ref('')
|
||||||
@@ -314,6 +323,13 @@ const models = ref([])
|
|||||||
const locations = ref([])
|
const locations = ref([])
|
||||||
const operatingsystems = ref([])
|
const operatingsystems = ref([])
|
||||||
|
|
||||||
|
// Default PC Number to serial while the user hasn't typed their own (new PC only)
|
||||||
|
watch(() => form.value.serialnumber, (serial) => {
|
||||||
|
if (!isEdit.value && !manualPcNumber.value && serial) {
|
||||||
|
form.value.machinenumber = serial
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Filter models by selected vendor and PC type
|
// Filter models by selected vendor and PC type
|
||||||
const filteredModels = computed(() => {
|
const filteredModels = computed(() => {
|
||||||
// filter by vendor only (PC type now maps to computertypeid, a different id
|
// filter by vendor only (PC type now maps to computertypeid, a different id
|
||||||
|
|||||||
Reference in New Issue
Block a user