2023-03-21 12:05:24 +00:00
|
|
|
<script>
|
|
|
|
import { ObjectUtils } from 'primevue/utils';
|
|
|
|
|
|
|
|
export default {
|
2023-03-31 21:51:41 +00:00
|
|
|
name: 'BaseComponent',
|
2023-03-21 12:05:24 +00:00
|
|
|
props: {
|
|
|
|
pt: {
|
|
|
|
type: Object,
|
2023-04-26 08:57:02 +00:00
|
|
|
default: undefined
|
2023-03-21 12:05:24 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2023-04-03 00:12:25 +00:00
|
|
|
getPTItem(obj = {}, key = '') {
|
|
|
|
const fKey = ObjectUtils.convertToFlatCase(key);
|
|
|
|
|
|
|
|
return obj[Object.keys(obj).find((k) => ObjectUtils.convertToFlatCase(k) === fKey) || ''];
|
|
|
|
},
|
2023-04-25 11:36:01 +00:00
|
|
|
getPTValue(obj = {}, key = '', params = {}) {
|
|
|
|
const self = ObjectUtils.getItemValue(this.getPTItem(obj, key), params);
|
|
|
|
const globalComponentPT = this.getPTItem(this.$primevue.config.pt, this.$.type.name);
|
|
|
|
const global = ObjectUtils.getItemValue(this.getPTItem(globalComponentPT, key), params);
|
|
|
|
|
|
|
|
return { ...global, ...self };
|
|
|
|
},
|
2023-03-21 12:05:24 +00:00
|
|
|
ptm(key = '', params = {}) {
|
2023-04-25 11:36:01 +00:00
|
|
|
return this.getPTValue(this.pt, key, { props: this.$props, state: this.$data, ...params });
|
2023-03-22 12:11:03 +00:00
|
|
|
},
|
|
|
|
ptmo(obj = {}, key = '', params = {}) {
|
2023-04-25 11:36:01 +00:00
|
|
|
return this.getPTValue(obj, key, params);
|
2023-03-21 12:05:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|