|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<div class="tool">
|
|
|
<div class="tool-left">
|
|
|
-
|
|
|
+ <el-button v-for="(item,index) of showTools" :icon="item.icon" :key="index" size="small" @click="clickBtn(item)">{{ item.name }}</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -12,6 +12,9 @@ import { Component, Prop, Vue, Mixins } from 'vue-property-decorator'
|
|
|
// components: { logDrawer }
|
|
|
})
|
|
|
export default class GmTools extends Vue {
|
|
|
+ @Prop()
|
|
|
+ propConfig:any
|
|
|
+
|
|
|
tools:Array<any>=[
|
|
|
{ name: '新增', icon: 'el-icon-plus', clickName: 'onAdd', _class: 'onAdd' },
|
|
|
{ name: '修改', icon: 'el-icon-edit', clickName: 'onUpdate', _class: 'onUpdate' },
|
|
@@ -20,8 +23,27 @@ export default class GmTools extends Vue {
|
|
|
]
|
|
|
showTools:Array<any>=[]
|
|
|
|
|
|
+ created(){
|
|
|
+ if(this.propConfig?.tools){
|
|
|
+ this.setTool(this.propConfig?.tools)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
setTool(data:any){
|
|
|
-
|
|
|
+ this.showTools = [];
|
|
|
+ for(const item of this.tools){
|
|
|
+ if(data[item._class]){
|
|
|
+ this.showTools.push(item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ clickBtn(item:any){
|
|
|
+ if(item?.event?.click){
|
|
|
+ item.event.click()
|
|
|
+ }else{
|
|
|
+ this.$emit(item.clickName)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
@@ -33,5 +55,8 @@ export default class GmTools extends Vue {
|
|
|
display: flex;
|
|
|
justify-content: space-between;
|
|
|
align-items: center;
|
|
|
+ .tool-left{
|
|
|
+ width: 70%;;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|