Listen to textarea, replace with data from a spreadsheet and print in another textarea, in Vue.js

Asked

Viewed 49 times

0

You have a Function in the trampo system that takes the text typed in the View (textarea and input), reads from where you have {}, which refer to the column of the spreadsheet that was uploaded in the View, replaces the information being referred between keys by the spreadsheet cells and prints a notification, via the @click event, of the final message with the replacements of the spreadsheet data. I hope I explained it correctly. I need this message to be automatically printed in another textarea that is listening to what was typed in the other fields with the substitutions. Or at least, use this page view.

VUE

visualizeMensagem: function () {

                let assuntoFinal = (this.assunto ? this.assunto + '
' : ''), codigo = new RegExp('smsurl.com.br/[a-zA-Z0-9]+', 'g'); if (SMSDigital['tipoCliente'] == SMSDigital.tipoClienteEnum.smsmkt) assuntoFinal = this.assunto + ':
'; let total, mensagem = (assuntoFinal + this.mensagem + (this.assinatura ? '
' + this.assinatura : '')).replace(/\r\n|\r|\n/g, '
').replace(/{reenvio}/ig, '1'), maioresValores = this.maioresValores(); for (let i in maioresValores) { mensagem = mensagem.replace(new RegExp(`{${i}}`, 'gi'), maioresValores[i]); mensagem = mensagem.replace(new RegExp(`{primeiro.${i}}`, 'gi'), (maioresValores[i] || '').split(' ')[0]); } let resultado = codigo.exec(mensagem); if (resultado) mensagem = mensagem.replace(resultado[0], resultado[0] + Envio.paraCodigo(maioresValores['celular'])); total = mensagem.replace(/
/g, ' ')/*.replace(/\%/g, '%25')*/.length; if (SMSDigital['tipoCliente'] == SMSDigital.tipoClienteEnum.smsmkt) total = total - 2; SMSDigital.notifiqueHTML(`${mensagem}

${total} caracteres que serão enviados em ${Envio.totalCreditosCobrados(total - 1, this.flash)} mensagen(s)`); }

HTML


                            Assunto
                            
                                                               

                            
                            Mensagem
                             

                            Assinatura
                            

                        
 Visualize Mensagem

 {{assunto}}
{{ mensagem }}
{{assinatura}}

notificação do texto com as sustituicões

  • You can use a computed Property https://vuejs.org/v2/guide/computed.html

  • Dude, I right!!! I used the computed and funfou!!!! vlw my friend! thank you very much!!!!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.