This commit is contained in:
chenbo 2024-01-13 17:56:58 +08:00
parent 32bc7cf18d
commit 2e5aa18bfd
1 changed files with 84 additions and 79 deletions

View File

@ -1,69 +1,76 @@
<template> <template>
<div> <div>
<el-card class="!border-none mb-4" shadow="never"> <el-card class="!border-none mb-4" shadow="never">
<el-form <el-form class="mb-[-16px]" :model="queryParams" inline>
class="mb-[-16px]" <el-form-item label="RFID" prop="rfid">
:model="queryParams" <el-input
inline class="w-[280px]"
> v-model="queryParams.rfid"
<el-form-item label="RFID" prop="rfid"> clearable
<el-input class="w-[280px]" v-model="queryParams.rfid" clearable placeholder="请输入" /> placeholder="请输入"
</el-form-item> />
</el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="resetPage">查询</el-button> <el-button type="primary" @click="resetPage">查询</el-button>
<el-button @click="resetParams">重置</el-button> <el-button @click="resetParams">重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-card> </el-card>
<el-card class="!border-none" v-loading="pager.loading" shadow="never"> <el-card class="!border-none" v-loading="pager.loading" shadow="never">
<el-button v-perms="['rfid.animal_rfid/add']" type="primary" @click="handleAdd"> <el-button v-perms="['rfid.animal_rfid/add']" type="primary" @click="handleAdd">
<template #icon> <template #icon>
<icon name="el-icon-Plus" /> <icon name="el-icon-Plus" />
</template> </template>
新增 新增
</el-button> </el-button>
<el-button <el-button
v-perms="['rfid.animal_rfid/delete']" v-perms="['rfid.animal_rfid/delete']"
:disabled="!selectData.length" :disabled="!selectData.length"
@click="handleDelete(selectData)" @click="handleDelete(selectData)"
> >
删除
</el-button>
<div class="mt-4">
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column label="RFID" prop="rfid" show-overflow-tooltip />
<el-table-column label="所属栏舍" prop="fence_house_id" show-overflow-tooltip />
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<el-button
v-perms="['rfid.animal_rfid/edit']"
type="primary"
link
@click="handleEdit(row)"
>
编辑
</el-button>
<el-button
v-perms="['rfid.animal_rfid/delete']"
type="danger"
link
@click="handleDelete(row.id)"
>
删除 删除
</el-button> </el-button>
</template> <div class="mt-4">
</el-table-column> <el-table :data="pager.lists" @selection-change="handleSelectionChange">
</el-table> <el-table-column type="selection" width="55" />
</div> <el-table-column label="RFID" prop="rfid" show-overflow-tooltip />
<div class="flex mt-4 justify-end"> <el-table-column label="所属栏舍" prop="fence_house_id" show-overflow-tooltip />
<pagination v-model="pager" @change="getLists" />
</div> <el-table-column label="操作" width="120" fixed="right">
</el-card> <template #default="{ row }">
<edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" /> <el-button
</div> v-perms="['rfid.animal_rfid/edit']"
type="primary"
link
@click="handleEdit(row)"
>
编辑
</el-button>
<el-button
v-perms="['rfid.animal_rfid/delete']"
type="danger"
link
@click="handleDelete(row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="flex mt-4 justify-end">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card>
<edit-popup
v-if="showEdit"
ref="editRef"
:dict-data="dictData"
@success="getLists"
@close="showEdit = false"
/>
</div>
</template> </template>
<script lang="ts" setup name="animalRfidLists"> <script lang="ts" setup name="animalRfidLists">
@ -78,10 +85,9 @@ const editRef = shallowRef<InstanceType<typeof EditPopup>>()
// //
const showEdit = ref(false) const showEdit = ref(false)
// //
const queryParams = reactive({ const queryParams = reactive({
rfid: '', rfid: ''
}) })
// //
@ -89,7 +95,7 @@ const selectData = ref<any[]>([])
// //
const handleSelectionChange = (val: any[]) => { const handleSelectionChange = (val: any[]) => {
selectData.value = val.map(({ id }) => id) selectData.value = val.map(({ id }) => id)
} }
// //
@ -97,32 +103,31 @@ const { dictData } = useDictData('')
// //
const { pager, getLists, resetParams, resetPage } = usePaging({ const { pager, getLists, resetParams, resetPage } = usePaging({
fetchFun: apiAnimalRfidLists, fetchFun: apiAnimalRfidLists,
params: queryParams params: queryParams
}) })
// //
const handleAdd = async () => { const handleAdd = async () => {
showEdit.value = true showEdit.value = true
await nextTick() await nextTick()
editRef.value?.open('add') editRef.value?.open('add')
} }
// //
const handleEdit = async (data: any) => { const handleEdit = async (data: any) => {
showEdit.value = true showEdit.value = true
await nextTick() await nextTick()
editRef.value?.open('edit') editRef.value?.open('edit')
editRef.value?.setFormData(data) editRef.value?.setFormData(data)
} }
// //
const handleDelete = async (id: number | any[]) => { const handleDelete = async (id: number | any[]) => {
await feedback.confirm('确定要删除?') await feedback.confirm('确定要删除?')
await apiAnimalRfidDelete({ id }) await apiAnimalRfidDelete({ id })
getLists() getLists()
} }
getLists() getLists()
</script> </script>