samedi 3 juillet 2021

Load Checkboxes from computed property in vue js but not able to save the array from v-model in vue js

i need a help regarding checkboxes in vue js laravel. i am working on a project where i need a form having checkboxes of Past History of a patient. we can save multiple Past Histories by click on multiple checkboxes. And also we can load these values from a template already saved in database by click on generatePrescriptionFromPrescription. when i need to save the fresh values of checkboxes they are working but when i click to load from template the checkboxes are not checked. any how i am able to make checked those checkboxes by computed property but after using computed property and loaded the checked checkboxes they are not saving in database

HTML Part is as below

<li v-for="past_history in past_histories">
                    <input type="checkbox" :value="past_history.name" v-model="Checked_Past_Histories.name">
                    
</li>
<div class="form-group">
                <label>Previous Prescription</label>
                <!--<input type="text" class="form-control" placeholder="Search Prescription">-->
                <ul class="list-group custom-height">
                    <li class="list-group-item" v-for="prescription in prescriptions">
                        <span @click="generatePrescriptionFromPrescription(prescription.id)"></span>
                    </li>
                </ul>
</div>

JavaScript Data part is below

data() {
            return {
                past_histories: [],
                past_historyy: [],
                Checked_Past_Histories: {name:[]},
methods: {
    generatePrescriptionFromPrescription: function (prescription_id) {
                this.$confirm({
                    title: 'Generate Prescription!',
                    content: 'Click Ok if you want to generate prescription from this prescription.'
                }).then(() => {
                    axios.get('/vue/prescription-by-id/' + prescription_id).then((response) => {
                        console.log(response.data);
                        this.drugBlocks = response.data.drugs;
                        this.inspection = response.data.inspection;
                        this.past_history_fetched_from_db = response.data.past_history;
                        console.log(this.past_history_fetched_from_db);
                        //this.comorbidities = response.data.co_morbidities;

                    });
                })
            },
beforeMount() {
          
            axios.get('/vue/all-pasthistory').then(response => {
                //console.log(response.data);
                this.past_histories = response.data;
            });
},

}



Aucun commentaire:

Enregistrer un commentaire