Browse Source

列表头部按钮组件

master
陈薪名 1 year ago
parent
commit
8df1974e43
  1. 3
      src/components/TableHead/index.ts
  2. 122
      src/components/TableHead/src/TableHead.vue
  3. 3
      src/components/XButton/index.ts
  4. 37
      src/components/XButton/src/ButtonBase.vue

3
src/components/TableHead/index.ts

@ -0,0 +1,3 @@
import TableHead from './src/TableHead.vue'
export { TableHead }

122
src/components/TableHead/src/TableHead.vue

@ -0,0 +1,122 @@
<template>
<div class="tableNavBtnsContent" ref="tableNavBtnsContent_Ref">
<div class="searchBox">
<div class="tableNavLeftBtns">
<ButtonBase
:Butttondata="buttonsLeft"
@buttonBaseClick="buttonBaseClick"
/>
</div>
<div class="tableNavRightBtns">
<!-- 快速搜索 -->
<!-- <SearchNormal
ref="quicklySearchDom_Ref"
:vueName="vueName"
:quicklySearchOption="quicklySearchOption"
@searchNormalClick="quicklySearchClick"
@searchNormalClear="quicklySearchClear"
style="margin-right: 15px;"
></SearchNormal> -->
<!-- 右侧按钮 -->
<ButtonBase :Butttondata="buttonsRight" @buttonBaseClick="buttonBaseClick" />
</div>
</div>
<slot></slot>
</div>
</template>
<script setup>
import ButtonBase from '@/components/XButton/src/ButtonBase.vue'
// import SearchNormal from '@/components/SearchNormal/index.vue'
// import * as highSearch from '@/utils/search/highSearch'
// import * as primarySearch from '@/utils/search/primarySearch'
const props = defineProps({
HeadButttondata: {
type: Array,
default: () => {
return []
}
},
// vuename
// vueName:{
// type: String,
// default: ''
// },
// 线--utils/search/quicklySearch.ts
// quicklySearchOption:{
// type: Object,
// default: null
// },
})
const buttonsLeft = ref([])
const buttonsRight = ref([])
const tableNavBtnsContent_Ref = ref()
// const defaultButtons = inject('global').defaultButtons
//
const buttonsLeftOrRight = () => {
// ()
// let _primarySearchOption = primarySearch[props.vueName]
// let _highSearchOption = highSearch[props.vueName]
// if(_primarySearchOption || _highSearchOption){
// buttonsRight.value.push(defaultButtons.defaultFilterBtn())
// }
//
props.HeadButttondata.forEach(item=>{
if(item.float && item.float == 'right'){
buttonsRight.value.push(item)
}else{
buttonsLeft.value.push(item)
}
})
}
buttonsLeftOrRight()
//
const emit = defineEmits([
'buttonBaseClick',
'quicklySearchClick',
'quicklySearchClear'
])
const buttonBaseClick = (val, item) => {
emit('buttonBaseClick', val, item)
}
//
const quicklySearchClick = (val, option) => {
emit('quicklySearchClick', val, option)
}
//
const quicklySearchClear = (val, option) => {
emit('quicklySearchClear', val, option)
}
const quicklySearchDom_Ref = ref()
defineExpose({
tableNavBtnsContent_Ref,
quicklySearchDom_Ref
})
</script>
<style lang="scss" scoped>
.tableNavBtnsContent{
padding-bottom: 10px;
.searchBox{
display: flex;
justify-content: space-between;
}
.tableNavRightBtns{
display: flex;
margin-left: 10px;
.currenButton .el-button {
margin-left: 10px !important;
}
}
}
</style>

3
src/components/XButton/index.ts

@ -1,4 +1,5 @@
import XButton from './src/XButton.vue' import XButton from './src/XButton.vue'
import XTextButton from './src/XTextButton.vue' import XTextButton from './src/XTextButton.vue'
import ButtonBase from './src/ButtonBase.vue'
export { XButton, XTextButton } export { XButton, XTextButton, ButtonBase }

37
src/components/XButton/src/ButtonBase.vue

@ -0,0 +1,37 @@
<template>
<el-button
v-for="(item, index) in Butttondata" :key="index"
v-show="!item.hide"
:type="item.type"
:color="item.color"
:link = "item.link ? item.link : false"
@click="buttonBaseClick(item.name,item,$event)"
>
<Icon :icon="item.icon" class="mr-1px" />
{{ item.label }}
</el-button>
<slot></slot>
</template>
<script setup>
import { Plus } from '@element-plus/icons-vue'
import { clearButtonBlurHandle } from '@/utils/index'
const props = defineProps({
Butttondata: {
type: Array,
default: () => {
return []
}
},
})
//
const emit = defineEmits([
'buttonBaseClick',
])
const buttonBaseClick = (val, item, $event) => {
clearButtonBlurHandle($event)//el-button
emit('buttonBaseClick', val, item, $event)
}
</script>
Loading…
Cancel
Save