chore: install prettier
This commit is contained in:
@@ -4,44 +4,64 @@
|
||||
<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()">Đồng ý</button>
|
||||
<button class="button is-dark ml-5" @click="cancel()">Hủy bỏ</button>
|
||||
<button
|
||||
class="button is-danger"
|
||||
@click="remove()"
|
||||
>
|
||||
Đồng ý
|
||||
</button>
|
||||
<button
|
||||
class="button is-dark ml-5"
|
||||
@click="cancel()"
|
||||
>
|
||||
Hủy bỏ
|
||||
</button>
|
||||
</div>
|
||||
<div class="control" v-if="duration">
|
||||
<CountDown v-bind="{duration: duration}" @close="cancel()"></CountDown>
|
||||
<div
|
||||
class="control"
|
||||
v-if="duration"
|
||||
>
|
||||
<CountDown
|
||||
v-bind="{ duration: duration }"
|
||||
@close="cancel()"
|
||||
></CountDown>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
props: ['content', 'duration', 'vbind', 'setdeleted'],
|
||||
props: ["content", "duration", "vbind", "setdeleted"],
|
||||
methods: {
|
||||
cancel() {
|
||||
this.$emit('close')
|
||||
this.$emit("close");
|
||||
},
|
||||
async remove() {
|
||||
let pagename = this.vbind.pagename
|
||||
let pagedata = this.$store.state[pagename]
|
||||
let name = pagedata.origin_api.name || this.vbind.api
|
||||
let id = this.vbind.row.id
|
||||
let result
|
||||
if(this.setdeleted) {
|
||||
let record = await this.$getdata(name, {id: id}, undefined, true)
|
||||
record.deleted = 1
|
||||
result = await this.$updateapi(name, record)
|
||||
} else result = await this.$deleteapi(name, id)
|
||||
if(result==='error') return this.$dialog('Đã xảy ra lỗi, xóa dữ liệu thất bại', 'Lỗi', 'Error')
|
||||
this.$snackbar('Dữ liệu đã được xoá khỏi hệ thống', 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>
|
||||
let pagename = this.vbind.pagename;
|
||||
let pagedata = this.$store.state[pagename];
|
||||
let name = pagedata.origin_api.name || this.vbind.api;
|
||||
let id = this.vbind.row.id;
|
||||
let result;
|
||||
if (this.setdeleted) {
|
||||
let record = await this.$getdata(name, { id: id }, undefined, true);
|
||||
record.deleted = 1;
|
||||
result = await this.$updateapi(name, record);
|
||||
} else result = await this.$deleteapi(name, id);
|
||||
if (result === "error") return this.$dialog("Đã xảy ra lỗi, xóa dữ liệu thất bại", "Lỗi", "Error");
|
||||
this.$snackbar("Dữ liệu đã được xoá khỏi hệ thống", 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>
|
||||
|
||||
Reference in New Issue
Block a user