61 lines
2.2 KiB
Vue
61 lines
2.2 KiB
Vue
<template>
|
|
<div>
|
|
<vue-html5-editor :content="content" :auto-height="true" @change="checkdetails" :show-module-name="false"></vue-html5-editor>
|
|
<div class="flex justify-end mt-2">
|
|
<button class="bg-blue-500 text-white active:bg-lightBlue-600 font-bold uppercase text-sm px-6 py-3 rounded shadow hover:shadow-lg outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150" type="button">
|
|
<span v-if="submitStatus === 'PENDING'"><i class="animate-spin fas fa-spinner mr-2"></i>Loading..</span>
|
|
<span v-else @click="updateData">Kemaskini</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data () {
|
|
return {
|
|
content: '',
|
|
submitStatus:''
|
|
}
|
|
},
|
|
created() {
|
|
this.axios.get(this.$hostname + '/api/details/notislelong/' + this.$kodcaw).then(response => {
|
|
this.content = response.data[0].para3;
|
|
});
|
|
},
|
|
methods:{
|
|
checkdetails: function(data){
|
|
this.content = data;
|
|
},
|
|
updateData() {
|
|
// do your submit logic here
|
|
this.submitStatus = 'PENDING'
|
|
let result = this.PostData()
|
|
let pro1 = Promise.resolve(result)
|
|
let self = this
|
|
|
|
pro1.then(function(response) {
|
|
if(response.data == 1)
|
|
{
|
|
setTimeout(() => {
|
|
self.submitStatus = 'OK'
|
|
self.$toast.success('Berjaya dikemaskini!')
|
|
}, 500)
|
|
}else{
|
|
self.$toast.error('Error occured')
|
|
self.submitStatus = 'OK'
|
|
}
|
|
}, function(e) {
|
|
console.error(e); // TypeError: Throwing
|
|
});
|
|
},
|
|
async PostData(){
|
|
let response = await this.axios.put(this.$hostname + '/admin/notislelong/update2/' + this.$kodcaw,
|
|
{
|
|
content: this.content
|
|
});
|
|
return response
|
|
}
|
|
}
|
|
}
|
|
</script> |