This commit is contained in:
李想 2025-03-12 10:12:54 +08:00
parent 8412ba4bf8
commit 2740fb22b5
2 changed files with 13 additions and 18 deletions

View File

@ -14,21 +14,11 @@
@row-save="handleSave" @row-save="handleSave"
@row-update="handleUpdate" @row-update="handleUpdate"
> >
<template #menu="{ index, row }"> <template #menu-left>
<el-dropdown> <el-button type="primary" @click="handleDownSoilType">导出</el-button>
<el-icon style="padding: 14px 0"><More /></el-icon>
<template #dropdown>
<el-dropdown-menu>
<template v-for="item in actions" :key="item.name">
<el-dropdown-item @click="item.event(row, index)">
<el-button :type="item.type ?? 'primary'" :icon="item.icon" :size="item.size" :disabled="item.disabled" text>
{{ item.name == '查看' ? (row.status == '1' ? '禁用' : '启用') : item.name }}
</el-button>
</el-dropdown-item>
</template> </template>
</el-dropdown-menu> <template #menu="scope">
</template> <custom-table-operate :actions="actions" :data="scope" />
</el-dropdown>
</template> </template>
</avue-crud> </avue-crud>
</CustomCard> </CustomCard>
@ -46,6 +36,7 @@ const {
pageData, pageData,
option, option,
actions, actions,
handleDownSoilType,
handleSizeChange, handleSizeChange,
handleCurrentChange, handleCurrentChange,
handleSearch, handleSearch,

View File

@ -62,8 +62,8 @@ export default function useSoilTypeHook() {
}); });
const actions = ref([ const actions = ref([
{ {
name: '查看', name: ({ row }) => (row.status == '0' ? '启用' : '禁用'),
icon: 'view', icon: 'TurnOff',
event: handleStatusChange, event: handleStatusChange,
}, },
{ {
@ -90,7 +90,7 @@ export default function useSoilTypeHook() {
pageData.value.total = res.data.total; pageData.value.total = res.data.total;
} }
} }
async function handleStatusChange(row, index) { async function handleStatusChange({ row, index }) {
await editSoilType(row, index); await editSoilType(row, index);
} }
function handleCurrentChange(val) { function handleCurrentChange(val) {
@ -153,6 +153,9 @@ export default function useSoilTypeHook() {
pageData.value.pageSize = 10; pageData.value.pageSize = 10;
getList(); getList();
} }
function handleDownSoilType() {
console.log('handleDownSoilType');
}
return { return {
crudRef, crudRef,
condition, condition,
@ -167,5 +170,6 @@ export default function useSoilTypeHook() {
handleSizeChange, handleSizeChange,
handleSave, handleSave,
handleUpdate, handleUpdate,
handleDownSoilType,
}; };
} }