80 lines
1.9 KiB
TypeScript
80 lines
1.9 KiB
TypeScript
|
|
import { defineComponent, ref, computed, PropType, toRef, reactive, watch } from 'vue'
|
||
|
|
import { IOperators, ISize, IText } from 'model'
|
||
|
|
|
||
|
|
import { useI18n } from '@/boot/i18n'
|
||
|
|
import { useQuasar } from 'quasar'
|
||
|
|
|
||
|
|
import { tools } from '@store/Modules/tools'
|
||
|
|
|
||
|
|
import { costanti } from '@costanti'
|
||
|
|
|
||
|
|
import { CMySlider } from '@src/components/CMySlider'
|
||
|
|
import { CMyFieldRec } from '@src/components/CMyFieldRec'
|
||
|
|
|
||
|
|
import { shared_consts } from '@/common/shared_vuejs'
|
||
|
|
|
||
|
|
export default defineComponent({
|
||
|
|
name: 'CMyText',
|
||
|
|
emits: ['update:modelValue', 'modifElem', 'saveFieldElem',],
|
||
|
|
components: { CMySlider, CMyFieldRec },
|
||
|
|
props: {
|
||
|
|
modelValue: {
|
||
|
|
type: Object as PropType<IText>,
|
||
|
|
required: true,
|
||
|
|
},
|
||
|
|
label: {
|
||
|
|
type: String,
|
||
|
|
required: true,
|
||
|
|
},
|
||
|
|
disable: {
|
||
|
|
type: Boolean,
|
||
|
|
required: false,
|
||
|
|
default: false,
|
||
|
|
},
|
||
|
|
show_maxlength: {
|
||
|
|
type: Boolean,
|
||
|
|
required: false,
|
||
|
|
default: true,
|
||
|
|
},
|
||
|
|
},
|
||
|
|
setup(props, { emit }) {
|
||
|
|
const $q = useQuasar()
|
||
|
|
const { t } = useI18n()
|
||
|
|
|
||
|
|
const internalModel = reactive({ ...props.modelValue })
|
||
|
|
|
||
|
|
function modifElem() {
|
||
|
|
// console.log('modifElem')
|
||
|
|
emit('update:modelValue', { ...internalModel });
|
||
|
|
emit('modifElem', null);
|
||
|
|
}
|
||
|
|
function update_col() {
|
||
|
|
// console.log('update_col')
|
||
|
|
emit('update:modelValue', { ...internalModel });
|
||
|
|
emit('modifElem', null);
|
||
|
|
}
|
||
|
|
|
||
|
|
function saveFieldElem() {
|
||
|
|
emit('update:modelValue', { ...internalModel });
|
||
|
|
emit('saveFieldElem', null);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Sincronizzare i cambiamenti esterni con internalModel quando props cambiano
|
||
|
|
watch(() => props.modelValue, (newModel: any) => {
|
||
|
|
Object.assign(internalModel, newModel);
|
||
|
|
|
||
|
|
}, { immediate: true });
|
||
|
|
|
||
|
|
return {
|
||
|
|
t,
|
||
|
|
shared_consts,
|
||
|
|
internalModel,
|
||
|
|
modifElem,
|
||
|
|
tools,
|
||
|
|
costanti,
|
||
|
|
saveFieldElem,
|
||
|
|
update_col,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
})
|