7 changed files with 407 additions and 9 deletions
@ -0,0 +1,56 @@ |
|||||
|
//基础列表字段
|
||||
|
export const tempOtherUnit = [ |
||||
|
{ |
||||
|
label: '其他字段', |
||||
|
options: [ |
||||
|
{ |
||||
|
label: '多选', |
||||
|
type: 'selection' |
||||
|
}, |
||||
|
{ |
||||
|
label: '序号', |
||||
|
type: 'index', |
||||
|
width: '70px' |
||||
|
}, |
||||
|
{ |
||||
|
label: '操作', |
||||
|
prop: '__control' |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
] |
||||
|
//新增与批量删除按钮
|
||||
|
export const controlBtnList = [ |
||||
|
{ |
||||
|
label: '新增', |
||||
|
key: 'add', |
||||
|
type: 'primary', |
||||
|
size: 'small', |
||||
|
icon: 'plus' |
||||
|
}, |
||||
|
{ |
||||
|
label: '导出', |
||||
|
key: 'import', |
||||
|
type: 'primary', |
||||
|
size: 'small', |
||||
|
icon: 'plus' |
||||
|
}, |
||||
|
{ |
||||
|
label: '批量删除', |
||||
|
key: 'del', |
||||
|
type: 'danger', |
||||
|
size: 'small', |
||||
|
icon: 'delete' |
||||
|
} |
||||
|
] |
||||
|
//编辑删除按钮
|
||||
|
export const operateBtnList = [ |
||||
|
{ |
||||
|
label: '编辑', |
||||
|
key: 'edit' |
||||
|
}, |
||||
|
{ |
||||
|
label: '删除', |
||||
|
key: 'del' |
||||
|
} |
||||
|
] |
||||
@ -0,0 +1,64 @@ |
|||||
|
<!-- Created by weiXin:337547038 --> |
||||
|
<template> |
||||
|
<div class="main-tools"> |
||||
|
<slot></slot> |
||||
|
<el-button |
||||
|
link |
||||
|
type="primary" |
||||
|
@click="btnClick(item.icon)" |
||||
|
v-for="item in btnList" |
||||
|
:key="item.icon" |
||||
|
> |
||||
|
<i v-if="item.iconFont==''" :class="['icon-' + item.icon]" ></i><i v-if="item.iconFont!=''" :class="['fa ' + item.iconFont]" ></i>{{ item.label }} |
||||
|
</el-button> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script lang="ts" setup> |
||||
|
import { computed } from 'vue' |
||||
|
|
||||
|
const props = withDefaults( |
||||
|
defineProps<{ |
||||
|
showKey?: string[] // showKey,hideKey设置其中一个即可,showKey优先 |
||||
|
hideKey?: string[] // 设置了showKey时,hideKey无效 |
||||
|
}>(), |
||||
|
{ |
||||
|
showKey: () => { |
||||
|
return [] |
||||
|
}, |
||||
|
hideKey: () => { |
||||
|
return [] |
||||
|
} |
||||
|
} |
||||
|
) |
||||
|
const emits = defineEmits<{ |
||||
|
(e: 'click', value: string): void |
||||
|
}>() |
||||
|
|
||||
|
const btnList = computed(() => { |
||||
|
const list = [ |
||||
|
{ icon: 'del',iconFont:"", label: '清空', key: 1 }, |
||||
|
{ icon: 'eye',iconFont:"", label: '预览', key: 2 }, |
||||
|
{ icon: 'json',iconFont:"", label: '生成脚本预览', key: 3 }, |
||||
|
// { icon: 'vue', label: '导出vue文件', key: 4 }, |
||||
|
{ icon: 'save',iconFont:"fa-save", label: '保存', key: 5 }, |
||||
|
] |
||||
|
if (props.showKey?.length) { |
||||
|
// 按照指定的key显示 |
||||
|
return list.filter((item: any) => { |
||||
|
return props.showKey.includes(item.key) |
||||
|
}) |
||||
|
} else if (props.hideKey?.length) { |
||||
|
// 按照指定的key隐藏 |
||||
|
return list.filter((item: any) => { |
||||
|
return !props.hideKey.includes(item.key) |
||||
|
}) |
||||
|
} else { |
||||
|
return list // 否则显示全部 |
||||
|
} |
||||
|
}) |
||||
|
const btnClick = (type: string) => { |
||||
|
emits('click', type) |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
Loading…
Reference in new issue