diff --git a/src/utils/disposition/defaultButtons.ts b/src/utils/disposition/defaultButtons.ts new file mode 100644 index 000000000..f6f1cbb89 --- /dev/null +++ b/src/utils/disposition/defaultButtons.ts @@ -0,0 +1,204 @@ +// 页面基础按钮样式 +/** + * 如果需要更改配置,格式如:defaultExportBtn({label:'自定义'}) + * @param {*} option + * @returns + */ + +// 新增按钮 +export function defaultAddBtn(option:any) { + return __defaultBtnOption(option,{ + label: '新增', + name: 'add', + hide: false, + type: 'primary', + icon: 'ep:plus', + color: '' + }) +} + +// 导入按钮 +export function defaultImportBtn(option:any) { + return __defaultBtnOption(option,{ + label: '导入', + name: 'import', + hide: false, + type: 'warning', + icon: 'ep:upload', + color: '' + }) +} + +// 导出按钮 +export function defaultExportBtn(option:any) { + return __defaultBtnOption(option,{ + label: '导出', + name: 'export', + hide: false, + type: 'success', + icon: 'ep:download', + color: '' + }) +} + +// 字段设置 +// export function defaultFieldSettingBtn(option:any) { +// // todo:监听已经配置过的字段按钮更改状态特殊显示 +// const routeName = route.name +// let _local = localStorage.getItem('tableColumns_' + this.$store.getters.name.userName + '_' + routeName) +// let _type = '' +// let _num = 0 +// if(_local){ +// JSON.parse(_local).forEach((item: any) => { +// if(item.istrue == true){ +// _num ++ +// } +// }); +// if(_num >= JSON.parse(_local).length){ +// _type = '' +// }else{ +// _type= 'warning' +// } +// } +// return __defaultBtnOption(option,{ +// type: _type, +// plain: true, +// icon: "el-icon-setting", +// label: "字段设置", +// name: "field", +// size: "small", +// float: 'right', +// class: "rowDropNotHideItem" +// }) +// } + +// 刷新按钮 +export function defaultFreshBtn(option:any) { + return __defaultBtnOption(option,{ + label: '刷新', + name: 'refresh', + hide: false, + type: 'primary', + icon: 'ep:refresh', + color: '', + float:'right' + }) +} + +// 重置按钮 +export function defaultResetBtn(option:any) { + return __defaultBtnOption(option,{ + label: '重置', + name: 'reset', + hide: false, + type: 'info', + icon: '', + color: '', + float:'right' + }) +} + +// 筛选按钮 +export function defaultFilterBtn(option:any) { + return __defaultBtnOption(option,{ + label: '筛选', + name: 'filtrate', + hide: false, + type: 'info', + icon: 'Operation', + color: '', + float:'right' + }) +} + +// form表单-保存按钮 +export function formSaveBtn(option:any) { + return __defaultBtnOption(option,{ + label: '保存', + name: 'save', + hide: false, + type: 'primary', + icon: 'ep:select', + color: '' + }) +} + +// form表单-关闭按钮 +export function formCloseBtn(option:any) { + return __defaultBtnOption(option,{ + label: '关闭', + name: 'close', + hide: false, + icon: 'ep:closeBold', + color: '' + }) +} + +// drawer抽屉头部-编辑按钮 +export function drawerEditBtn(option:any) { + return __defaultBtnOption(option,{ + label: '编辑', + name: 'edit', + hide: false, + type: 'warning', + icon: 'ep:editPen', + color: '' + }) +} + +// drawer抽屉头部-删除按钮 +export function drawerDeleteBtn(option:any) { + return __defaultBtnOption(option,{ + label: '删除', + name: 'delete', + hide: false, + type: 'danger', + icon: 'ep:delete', + color: '' + }) +} + +// 主列表-编辑按钮 +export function mainListEditBtn(option:any) { + return __defaultBtnOption(option,{ + label: '编辑', + name: 'edit', + hide: false, + type: 'warning', + color: '', + link: true, // 文本展现按钮 + }) +} + +// 主列表-删除按钮 +export function mainListDeleteBtn(option:any) { + return __defaultBtnOption(option,{ + label: '删除', + name: 'delete', + hide: false, + type: 'danger', + color: '', + link: true, // 文本展现按钮 + }) +} + +// 默认按钮规则 +function __defaultBtnOption(option:any,specific:any){ + return { + type:option && option.type ? option.type : specific.type, + plain:option && option.plain ? option.plain : specific.plain, + icon:option && option.icon ? option.icon : specific.icon, + label:option && option.label ? option.label : specific.label, + name:option && option.name ? option.name : specific.name, + size:option && option.size ? option.size : specific.size, + float:option && option.float ? option.float : (specific.float || null), + url:option && option.url ? option.url : (specific.url || null), + background:option && option.background ? option.background : (specific.background || null), + class:option && option.class ? option.class : specific.class, + color:option && option.color ? option.color : specific.color, + hide:option && option.hide ? option.hide : specific.hide, + link:option && option.link ? option.link : specific.link, + ...option + } +} +