Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
188 views
in Technique[技术] by (71.8m points)

javascript - Pass parameters via GET to return filter

I want to return a data query via GET to return me values according to what is selected in the v-model. I would like to know how to get the v-model values from the input and make the request to get by parameter

My filter (the components are already returning object as your id according to what I select)

  <div class="row gutter-sm">
    <div class="col-md-12">
       <q-card class="full-width bg-white q-pa-md q-card-flex">
            <div class="col-md-2">            
              <situacao-select multiple v-model="situacao" :stackLabel="'Situa??o OS'" style="height:50px;" :clearable="true" />            
            </div>
            <div class="col-md-2">
              <input-holder label="Help Desk" style="height:50px;">
                  <pessoa-funcao-select :funcao="'Help Desk'" :clearable="true" />
              </input-holder>
            </div>
            <div class="col-md-2">
              <input-holder label="Supervisor" style="height:50px;">
                  <pessoa-funcao-select :funcao="'Supervisor'" :clearable="true" />
              </input-holder>
            </div>
                <div class="col-auto">
                    <q-btn
                      color="primary"
                      style="margin-left: auto; margin-right: auto;"
                      @click="search = false"
                    >FILTER</q-btn>
                </div>                                        
            </div>                   
       </q-card>

Request the API (I know it is wrong, I would like to know how to request with the parameter according to what the GET requests)

     mounted() {
        this.refresh()
 },
 methods: {
      refresh () {
         this.$axios.get()
         
          this.$axios.get("/Operacional/GetRelatorio").then(res => { 
            this.prazos = res.data
            this.$refs.chart1.updateSeries([{
                name: 'NO PRAZO',
                data: [this.prazos.noPrazo, this.prazos.emDia, this.prazos.atrasadas]
             }])
          })
          this.$axios.get("/Operacional/GetAprovadas").then(res => {
            this.os = res.data
          })
          this.$axios.get("/Operacional/GetPendenciasOS").then(res => {
            this.os = res.data
            this.$refs.chart4.updateSeries([{
                name: 'EM DIA',
                data: [ this.os.emdiaPendencia, this.os.emdiaSPendencia],
              },{
                name: 'ATRASADAS',
                data: [ this.os.atrasadasPendencia, this.os.atrasadasSPendencia],
                }
             ])
          })

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is how you get that value you selected, let's say you want to use 'situacao'. and pass that value to your backend via GET parameters:

refresh () {
         this.$axios.get()
    
         var selectedSituacao = this.situacao;
         var url = "/Operacional/GetRelatorio?ID=" + selectedSituacao;

         this.$axios.get(url).then(res => { .... })

         // or you could do this:
         var axiosParams = {
             params: {
                ID: selectedSituacao
             }
         }
         this.$axios.get("/Operacional/GetRelatorio", axiosParams).then(res => { .... })

edit: Updated url get parameter situacao to ID as requested.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...