diff --git a/src/components/ui/VnLinkPhone.vue b/src/components/ui/VnLinkPhone.vue index 4c045968f..4068498cd 100644 --- a/src/components/ui/VnLinkPhone.vue +++ b/src/components/ui/VnLinkPhone.vue @@ -1,6 +1,7 @@ diff --git a/src/filters/index.js b/src/filters/index.js index ce5c44706..1f7ac77dd 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -12,10 +12,12 @@ import dateRange from './dateRange'; import toHour from './toHour'; import dashOrCurrency from './dashOrCurrency'; import getParamWhere from './getParamWhere'; +import parsePhone from './parsePhone'; import isDialogOpened from './isDialogOpened'; export { isDialogOpened, + parsePhone, toLowerCase, toLowerCamel, toDate, diff --git a/src/filters/parsePhone.js b/src/filters/parsePhone.js new file mode 100644 index 000000000..b2d1ed7b8 --- /dev/null +++ b/src/filters/parsePhone.js @@ -0,0 +1,15 @@ +export default function (phone, prefix = 34) { + if (phone.startsWith('+')) { + console.log('a'); + return `${phone.slice(1)}`; + } + if (phone.startsWith('00')) { + console.log('b'); + return `${phone.slice(2)}`; + } + if (phone.startsWith(prefix) && phone.length === prefix.length + 9) { + console.log('c'); + return `${prefix}${phone.slice(prefix.length)}`; + } + return `${prefix}${phone}`; +}