refactor(cargo-type): 优化按钮布局并修复导出逻辑
- 将功能按钮从自定义紧凑搜索栏迁移至 avue-crud 的 menu-left 插槽,恢复 Avue 原生搜索 - 删除紧凑搜索栏及相关样式和方法,减少冗余代码 - 为按钮补齐 Element Plus 图标,统一界面风格 - 修改导出参数,去除 ids 限制,始终按搜索条件导出数据 - 隐藏 Avue 内置新增按钮,仅保留自定义新增按钮 - 调整 searchShow 配置,启用原生搜索表单功能
This commit is contained in:
@@ -33,7 +33,7 @@ export const getCargoTypeOption = ctx => ({
|
||||
emptyBtnText: '重置',
|
||||
saveBtnText: '提交',
|
||||
updateBtnText: '提交',
|
||||
searchShow: false,
|
||||
searchShow: true,
|
||||
searchIcon: false,
|
||||
searchMenuSpan: 24,
|
||||
searchIndex: 8,
|
||||
|
||||
@@ -1,34 +1,26 @@
|
||||
<template>
|
||||
<basic-container class="cargo-type-page">
|
||||
<!-- 紧凑搜索栏 -->
|
||||
<div class="compact-search">
|
||||
<div class="compact-search__form">
|
||||
<el-select
|
||||
v-model="query.typeLevel"
|
||||
placeholder="选择类型"
|
||||
clearable
|
||||
class="compact-search__select"
|
||||
@change="handleCompactSearch"
|
||||
>
|
||||
<el-option label="一级货物类型" :value="1" />
|
||||
<el-option label="二级货物类型" :value="2" />
|
||||
</el-select>
|
||||
<el-input
|
||||
v-model="query.keyword"
|
||||
placeholder="搜索分类名称"
|
||||
clearable
|
||||
class="compact-search__input"
|
||||
@keyup.enter="handleCompactSearch"
|
||||
@clear="handleCompactSearch"
|
||||
>
|
||||
<template #append>
|
||||
<el-button @click="handleCompactSearch">
|
||||
<el-icon><Search /></el-icon>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
</div>
|
||||
<div class="compact-search__actions">
|
||||
<avue-crud
|
||||
:option="option"
|
||||
:table-loading="loading"
|
||||
:data="data"
|
||||
v-model:page="page"
|
||||
v-model:form="form"
|
||||
ref="crud"
|
||||
:permission="permissionList"
|
||||
:before-open="beforeOpen"
|
||||
@row-save="rowSave"
|
||||
@row-update="rowUpdate"
|
||||
@row-del="rowDel"
|
||||
@search-change="searchChange"
|
||||
@search-reset="searchReset"
|
||||
@selection-change="selectionChange"
|
||||
@current-change="currentChange"
|
||||
@size-change="sizeChange"
|
||||
@refresh-change="refreshChange"
|
||||
@on-load="onLoad"
|
||||
>
|
||||
<template #menu-left>
|
||||
<el-button type="primary" v-if="permission.cargo_type_add" @click="$refs.crud.rowAdd()">
|
||||
<el-icon class="el-icon--left"><Plus /></el-icon>新增
|
||||
</el-button>
|
||||
@@ -56,29 +48,7 @@
|
||||
v-if="permission.cargo_type_delete"
|
||||
@click="handleDelete"
|
||||
><el-icon class="el-icon--left"><Delete /></el-icon>批量删除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<avue-crud
|
||||
:option="option"
|
||||
:table-loading="loading"
|
||||
:data="data"
|
||||
v-model:page="page"
|
||||
v-model="form"
|
||||
ref="crud"
|
||||
:permission="permissionList"
|
||||
:before-open="beforeOpen"
|
||||
@row-save="rowSave"
|
||||
@row-update="rowUpdate"
|
||||
@row-del="rowDel"
|
||||
@search-change="searchChange"
|
||||
@search-reset="searchReset"
|
||||
@selection-change="selectionChange"
|
||||
@current-change="currentChange"
|
||||
@size-change="sizeChange"
|
||||
@refresh-change="refreshChange"
|
||||
@on-load="onLoad"
|
||||
>
|
||||
</template>
|
||||
|
||||
<template #parentCargoName="{ row }">
|
||||
{{ row.typeLevel === 1 ? '/' : row.parentCargoName || '/' }}
|
||||
@@ -176,7 +146,7 @@ import { openImportDialog } from '@/utils/import-excel';
|
||||
import { getToken } from '@/utils/auth';
|
||||
import NProgress from 'nprogress';
|
||||
import 'nprogress/nprogress.css';
|
||||
import { Search, Plus, Upload, Download, Delete } from '@element-plus/icons-vue';
|
||||
import { Plus, Upload, Download, Delete } from '@element-plus/icons-vue';
|
||||
|
||||
// 导入失败明细中,每个错误文本对应的「字段列」与「规则说明」
|
||||
const CARGO_TYPE_FAIL_RULES = [
|
||||
@@ -273,7 +243,7 @@ export const decorateCargoTypeFailDetail = async workbook => {
|
||||
};
|
||||
|
||||
export default {
|
||||
components: { Search, Plus, Upload, Download, Delete },
|
||||
components: { Plus, Upload, Download, Delete },
|
||||
data() {
|
||||
return {
|
||||
form: {},
|
||||
@@ -327,7 +297,7 @@ export default {
|
||||
...mapGetters(['permission']),
|
||||
permissionList() {
|
||||
return {
|
||||
addBtn: this.validData(this.permission.cargo_type_add, false),
|
||||
addBtn: false,
|
||||
};
|
||||
},
|
||||
ids() {
|
||||
@@ -538,17 +508,6 @@ export default {
|
||||
this.syncColumnDisplay();
|
||||
done();
|
||||
},
|
||||
handleCompactSearch() {
|
||||
this.page.currentPage = 1;
|
||||
const params = {};
|
||||
if (this.query.typeLevel != null) {
|
||||
params.typeLevel = this.query.typeLevel;
|
||||
}
|
||||
if (this.query.keyword) {
|
||||
params.cargoName = this.query.keyword;
|
||||
}
|
||||
this.onLoad(this.page, params);
|
||||
},
|
||||
searchReset() {
|
||||
this.query = {};
|
||||
this.page.currentPage = 1;
|
||||
@@ -595,11 +554,7 @@ export default {
|
||||
});
|
||||
},
|
||||
buildExportParams() {
|
||||
const params = { ...this.query };
|
||||
if (this.ids) {
|
||||
params.ids = this.ids;
|
||||
}
|
||||
return params;
|
||||
return { ...this.query };
|
||||
},
|
||||
handleExport() {
|
||||
this.$confirm('是否导出货物类型数据?', '提示', {
|
||||
@@ -657,49 +612,6 @@ export default {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
// 隐藏表格工具栏中的搜索图标按钮
|
||||
:deep(.avue-crud__search-btn) {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
// 紧凑搜索栏
|
||||
.compact-search {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12px 16px;
|
||||
margin-bottom: 8px;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
||||
gap: 16px;
|
||||
|
||||
&__form {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex: 1;
|
||||
gap: 12px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__select {
|
||||
width: 160px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__input {
|
||||
width: 280px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-table) {
|
||||
--el-table-border-color: #eff1f7;
|
||||
--el-table-row-hover-bg-color: #f5f7fa;
|
||||
|
||||
Reference in New Issue
Block a user