Commit c04868b7 authored by renjintao's avatar renjintao

模板相关&&op

parent a2c243e4
<template> <template>
<Tooltip trigger="hover" v-if="title" :content="title" placement="top-end"> <Tooltip trigger="hover" v-if="title" :content="title" placement="top-end">
<a class="op" :class="css" @click="handler"> <a class="op" :class="css" @click="handler">
<slot> <slot>
<Icon v-if="type=='icon'" :type="icon" /> <Icon v-if="type=='icon'" :type="icon" />
<span v-else="type=='text'" v-text="text"></span> <span v-else="type=='text'" v-text="text"></span>
</slot> </slot>
</a> </a>
</Tooltip> </Tooltip>
<a class="op" v-else :class="css" @click="handler"> <a class="op" v-else :class="css" @click="handler">
<slot> <slot>
<Icon v-if="type=='icon'" :type="icon" /> <Icon v-if="type=='icon'" :type="icon" />
<span v-else="type=='text'" v-text="text"></span> <span v-else="type=='text'" v-text="text"></span>
</slot> </slot>
</a> </a>
</template> </template>
<script> <script>
export default { export default {
name: 'op', name: "op",
props: { props: {
icon:{ icon: {
type:String type: String
}, },
oprate: { oprate: {
type: String type: String
}, },
type: { type: {
type:String, type: String,
default:"text" default: "text"
}, },
title:{ title: {
type:String type: String
}, },
msg:{ msg: {
type:String, type: String,
default:"确认要删除吗?" default: "确认要删除吗?"
} }
}, },
data(){ data() {
return { return {
text:"", text: "",
css:"detail" css: "detail"
} };
}, },
created(){ created() {
var oprates={ var oprates = {
detail:"查看", detail: "查看",
edit:"编辑", edit: "编辑",
add:"添加", add: "添加",
delete:"删除" delete: "删除"
}; };
if(oprates[this.oprate]){ if (oprates[this.oprate]) {
this.text=oprates[this.oprate] this.text = oprates[this.oprate];
this.css=this.oprate; this.css = this.oprate;
}else if(this.oprate){ } else if (this.oprate) {
this.css=this.oprate; this.css = this.oprate;
}else if(this.type=='icon'){ } else if (this.type == "icon") {
this.css='icon' this.css = "icon";
} }
}, },
methods:{ methods: {
handler(){ handler() {
if(this.oprate=="delete"){ if (this.oprate == "delete") {
this.$Modal.confirm({ this.$Modal.confirm({
title: '确认', title: "确认",
content: '<p>'+this.msg+'</p>', content: "<p>" + this.msg + "</p>",
onOk: () => { onOk: () => {
this.$emit("click",event) this.$emit("click", event);
} }
}); });
}else{ } else {
this.$emit("click",event) this.$emit("click", event);
} }
} }
} }
} };
</script> </script>
<style lang="less"> <style lang="less">
a.op{ a.op {
display: inline; display: inline;
margin: 0 3px; margin: 0 3px;
} }
</style> </style>
\ No newline at end of file
...@@ -116,7 +116,8 @@ export default { ...@@ -116,7 +116,8 @@ export default {
this.$emit("on-close"); this.$emit("on-close");
}, },
addData(obj) { addData(obj) {
this.data.splice(0, 0,obj); //this.data.splice(0, 0,obj);
this.data.push(obj)
}, },
cancel() { cancel() {
this.add = null; this.add = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment