Commit c04868b7 authored by renjintao's avatar renjintao

模板相关&&op

parent a2c243e4
<template>
<Tooltip trigger="hover" v-if="title" :content="title" placement="top-end">
<a class="op" :class="css" @click="handler">
<slot>
<Tooltip trigger="hover" v-if="title" :content="title" placement="top-end">
<a class="op" :class="css" @click="handler">
<slot>
<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>
</a>
</Tooltip>
<a class="op" v-else :class="css" @click="handler">
<slot>
<a class="op" v-else :class="css" @click="handler">
<slot>
<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>
</a>
</template>
<script>
export default {
name: 'op',
name: "op",
props: {
icon:{
type:String
icon: {
type: String
},
oprate: {
type: String
},
type: {
type:String,
default:"text"
type: String,
default: "text"
},
title:{
type:String
title: {
type: String
},
msg:{
type:String,
default:"确认要删除吗?"
msg: {
type: String,
default: "确认要删除吗?"
}
},
data(){
data() {
return {
text:"",
css:"detail"
}
text: "",
css: "detail"
};
},
created(){
var oprates={
detail:"查看",
edit:"编辑",
add:"添加",
delete:"删除"
created() {
var oprates = {
detail: "查看",
edit: "编辑",
add: "添加",
delete: "删除"
};
if(oprates[this.oprate]){
this.text=oprates[this.oprate]
this.css=this.oprate;
}else if(this.oprate){
this.css=this.oprate;
}else if(this.type=='icon'){
this.css='icon'
if (oprates[this.oprate]) {
this.text = oprates[this.oprate];
this.css = this.oprate;
} else if (this.oprate) {
this.css = this.oprate;
} else if (this.type == "icon") {
this.css = "icon";
}
},
methods:{
handler(){
if(this.oprate=="delete"){
methods: {
handler() {
if (this.oprate == "delete") {
this.$Modal.confirm({
title: '确认',
content: '<p>'+this.msg+'</p>',
onOk: () => {
this.$emit("click",event)
}
});
}else{
this.$emit("click",event)
title: "确认",
content: "<p>" + this.msg + "</p>",
onOk: () => {
this.$emit("click", event);
}
});
} else {
this.$emit("click", event);
}
}
}
}
};
</script>
<style lang="less">
a.op{
a.op {
display: inline;
margin: 0 3px;
}
</style>
\ No newline at end of file
......@@ -116,7 +116,8 @@ export default {
this.$emit("on-close");
},
addData(obj) {
this.data.splice(0, 0,obj);
//this.data.splice(0, 0,obj);
this.data.push(obj)
},
cancel() {
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