100 lines
1.9 KiB
Vue
100 lines
1.9 KiB
Vue
<template>
|
|
<v-row class="search-box" align="center" no-gutters>
|
|
<v-col v-if="label" :cols="labelCols">
|
|
<label for="" class="search-box-label">
|
|
<v-icon x-small color="primary" class="mr-1">mdi-record-circle</v-icon>
|
|
{{ label }}
|
|
</label>
|
|
</v-col>
|
|
<v-col :cols="label ? textCols : ''">
|
|
<v-text-field
|
|
v-model="textValue"
|
|
class="v-input__custom"
|
|
:disabled="disabled"
|
|
outlined
|
|
:hide-details="true"
|
|
@keyup="modifyValue"
|
|
></v-text-field>
|
|
</v-col>
|
|
</v-row>
|
|
</template>
|
|
|
|
<script>
|
|
import { mapState, mapMutations } from 'vuex';
|
|
import Utility from '~/plugins/utility';
|
|
export default {
|
|
props: {
|
|
parentPrgmId: {
|
|
type: String,
|
|
require: true,
|
|
},
|
|
diffModel: {
|
|
type: String,
|
|
require: false,
|
|
},
|
|
label: {
|
|
type: String,
|
|
require: true,
|
|
},
|
|
valueNm: {
|
|
type: String,
|
|
require: true,
|
|
},
|
|
disabled: {
|
|
type: Boolean,
|
|
require: false,
|
|
default: false,
|
|
},
|
|
labelCols: {
|
|
type: Number,
|
|
require: false,
|
|
default: 4,
|
|
},
|
|
textCols: {
|
|
type: Number,
|
|
require: false,
|
|
default: 7,
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
textValue: null,
|
|
};
|
|
},
|
|
computed: {
|
|
...mapState({
|
|
searchParam: state => state.pageData,
|
|
menuData: 'menuData',
|
|
}),
|
|
getValue() {
|
|
return this.searchParam[this.parentPrgmId][this.valueNm];
|
|
},
|
|
},
|
|
watch: {
|
|
getValue() {
|
|
this.textValue = this.validateNumber(this.getValue);
|
|
},
|
|
},
|
|
created() {},
|
|
methods: {
|
|
...mapMutations({ setPageData: 'setPageData' }),
|
|
modifyValue(e) {
|
|
let val = e.target.value.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
this.textValue = this.validateNumber(val);
|
|
if (!this.diffModel) {
|
|
this.setPageData({ [this.valueNm]: val });
|
|
}
|
|
},
|
|
validateNumber(value) {
|
|
let returnVal = String(value).replaceAll(',', '');
|
|
returnVal = Utility.setFormatInt(returnVal);
|
|
if (returnVal == 'NaN') returnVal = null;
|
|
|
|
return returnVal;
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style></style>
|