|
@@ -1,13 +1,27 @@
|
|
|
<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>
|
|
|
+ <el-button
|
|
|
+ v-for="(item,index) of showTools"
|
|
|
+ :icon="item.icon"
|
|
|
+ :key="index"
|
|
|
+ size="small"
|
|
|
+ v-hasPermi="[item.audit]"
|
|
|
+ @click="clickBtn(item)">
|
|
|
+ {{ item.name }}
|
|
|
+ </el-button>
|
|
|
<slot name="tool-left" />
|
|
|
</div>
|
|
|
- <slot name="tool-right" />
|
|
|
- <!-- <div class="tool-right">
|
|
|
-
|
|
|
- </div> -->
|
|
|
+
|
|
|
+ <div class="tool-right">
|
|
|
+ <el-tooltip class="item" effect="dark" :content="!openSearch ? '隐藏搜索' : '显示搜索'" placement="top">
|
|
|
+ <el-button :icon="openSearch?'el-icon-search':'el-icon-zoom-out'" size="small" circle v-if="propTools.search" @click="toggleSearch"></el-button>
|
|
|
+ </el-tooltip>
|
|
|
+ <el-tooltip class="item" effect="dark" content="刷新" placement="top">
|
|
|
+ <el-button icon="el-icon-refresh" size="small" circle v-if="propTools.refresh" @click="refresh"></el-button>
|
|
|
+ </el-tooltip>
|
|
|
+ <slot name="tool-right" />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -17,18 +31,27 @@ import { Component, Prop, Vue, Mixins } from 'vue-property-decorator'
|
|
|
// components: { logDrawer }
|
|
|
})
|
|
|
export default class GmTools extends Vue {
|
|
|
+ openSearch:boolean = true
|
|
|
+
|
|
|
@Prop()
|
|
|
propConfig:any
|
|
|
|
|
|
@Prop()
|
|
|
customTools:any;
|
|
|
|
|
|
+ get audit(){
|
|
|
+ return this.propConfig?.audit ? this.propConfig.audit : {}
|
|
|
+ }
|
|
|
+ get propTools(){
|
|
|
+ return this.propConfig?.tools ? this.propConfig.tools : {}
|
|
|
+ }
|
|
|
+
|
|
|
tools:Array<any>=[
|
|
|
- { name: '新增', icon: 'el-icon-plus', clickName: 'onAdd', _class: 'onAdd' },
|
|
|
- { name: '修改', icon: 'el-icon-edit', clickName: 'onUpdate', _class: 'onUpdate' },
|
|
|
- { name: '删除', icon: 'el-icon-delete', clickName: 'onDelete', _class: 'onDelete' },
|
|
|
- { name: '导出', icon: 'el-icon-download', clickName: 'onExport', _class: 'onExport' },
|
|
|
- { name: '刷新', icon: 'el-icon-refresh', clickName: 'onRefresh', _class: 'onRefresh' }
|
|
|
+ { name: '新增', icon: 'el-icon-plus', clickName: 'onAdd', _class: 'add' },
|
|
|
+ { name: '修改', icon: 'el-icon-edit', clickName: 'onUpdate', _class: 'edit' },
|
|
|
+ { name: '删除', icon: 'el-icon-delete', clickName: 'onDelete', _class: 'delete' },
|
|
|
+ { name: '导出', icon: 'el-icon-download', clickName: 'onExport', _class: 'export' },
|
|
|
+ { name: '刷新', icon: 'el-icon-refresh', clickName: 'onRefresh', _class: 'refresh' }
|
|
|
]
|
|
|
showTools:Array<any>=[]
|
|
|
|
|
@@ -45,16 +68,28 @@ export default class GmTools extends Vue {
|
|
|
this.showTools = [];
|
|
|
for(const item of this.tools){
|
|
|
if(data[item._class]){
|
|
|
- this.showTools.push(item)
|
|
|
+ let obj:any = (this as any).$lodash.cloneDeep(item);
|
|
|
+ if(this.audit){
|
|
|
+ obj.audit = this.audit[item._class]
|
|
|
+ }
|
|
|
+ this.showTools.push(obj)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ //自定义工具栏按钮设置
|
|
|
setCustomTools(tools:Array<any>){
|
|
|
for(const item of tools){
|
|
|
this.showTools.push(item)
|
|
|
}
|
|
|
}
|
|
|
+ //点击刷新按钮
|
|
|
+ refresh(){
|
|
|
+ this.$emit('onRefresh')
|
|
|
+ }
|
|
|
+ //点击搜索
|
|
|
+ toggleSearch(){
|
|
|
+ this.$emit('searchHandle')
|
|
|
+ }
|
|
|
|
|
|
clickBtn(item:any){
|
|
|
if(item?.event?.click){
|