42 lines
1.4 KiB
Vue
42 lines
1.4 KiB
Vue
<template>
|
|
<div>
|
|
<p v-html="content"></p>
|
|
<p class="border-bottom mt-4 mb-5"></p>
|
|
<div class="field is-grouped">
|
|
<div class="control is-expanded">
|
|
<button class="button is-danger" @click="remove()">Confirm</button>
|
|
<button class="button is-dark ml-5" @click="cancel()">Cancel</button>
|
|
</div>
|
|
<div class="control" v-if="duration">
|
|
<CountDown v-bind="{duration: duration}"></CountDown>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
export default {
|
|
props: ['content', 'duration', 'vbind'],
|
|
methods: {
|
|
cancel() {
|
|
this.$store.commit('updateStore', {name: 'showmodal', data: undefined})
|
|
},
|
|
async remove() {
|
|
let pagename = this.vbind.pagename
|
|
let pagedata = this.$store.state[pagename]
|
|
let name = pagedata.origin_api.name
|
|
let id = this.vbind.row.id
|
|
let result = await this.$deleteapi(name, id)
|
|
if(result==='error') return
|
|
this.$snackbar('The data has been deleted from the system.', undefined, 'Success')
|
|
let arr = Array.isArray(id)? id : [{id: id}]
|
|
let copy = this.$copy(this.$store.state[pagename].data)
|
|
arr.map(x=>{
|
|
let index = copy.findIndex(v=>v.id===x.id)
|
|
index>=0? this.$delete(copy,index) : false
|
|
})
|
|
this.$store.commit('updateState', {name: pagename, key: 'update', data: {data: copy}})
|
|
this.cancel()
|
|
}
|
|
}
|
|
}
|
|
</script> |