2024-04-28 16:20:45 +08:00
|
|
|
<template>
|
2024-05-14 11:45:46 +08:00
|
|
|
<div>
|
2024-05-28 11:46:28 +08:00
|
|
|
<el-form :model="searchForm" label-width="0" inline>
|
2024-05-14 11:45:46 +08:00
|
|
|
<el-form-item>
|
|
|
|
|
<el-input
|
2024-05-28 11:46:28 +08:00
|
|
|
v-model="searchForm.schoolName"
|
2024-05-14 11:45:46 +08:00
|
|
|
class="!w-240px"
|
|
|
|
|
placeholder="请输入驾校名称"
|
|
|
|
|
@keyup.enter="handleQuery"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
2024-05-28 11:46:28 +08:00
|
|
|
<el-button @click="handleQuery" v-hasPermi="['school:school:search']"> 搜索 </el-button>
|
|
|
|
|
<el-button @click="resetQuery" v-hasPermi="['school:school:reset']"> 重置 </el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
plain
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="openForm('create')"
|
|
|
|
|
v-hasPermi="['school:school:add']"
|
|
|
|
|
>
|
|
|
|
|
新增
|
|
|
|
|
</el-button>
|
2024-05-14 11:45:46 +08:00
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<!-- 列表 -->
|
|
|
|
|
<el-table v-loading="loading" :data="tableList">
|
2024-05-28 11:46:28 +08:00
|
|
|
<el-table-column label="驾校名称" prop="schoolName" />
|
|
|
|
|
<el-table-column label="负责人" prop="leader" />
|
|
|
|
|
<el-table-column label="联系方式" prop="phone" />
|
2024-05-14 11:45:46 +08:00
|
|
|
<el-table-column label="状态">
|
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
<el-switch
|
|
|
|
|
v-model="row.status"
|
2024-05-28 11:46:28 +08:00
|
|
|
:active-value="0"
|
|
|
|
|
:inactive-value="1"
|
|
|
|
|
:disabled="checkPermi(['school:school:update'])"
|
2024-05-14 11:45:46 +08:00
|
|
|
@change="changeStatus(row)"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column label="创建时间" prop="" />
|
|
|
|
|
<el-table-column fixed="right" label="操作" width="150">
|
|
|
|
|
<template #default="{ row }">
|
2024-05-28 11:46:28 +08:00
|
|
|
<el-button
|
|
|
|
|
link
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="openForm(update, row)"
|
|
|
|
|
v-hasPermi="['school:school:update']"
|
|
|
|
|
>
|
|
|
|
|
修改
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
link
|
|
|
|
|
type="danger"
|
|
|
|
|
@click="handleDelete(row.id)"
|
|
|
|
|
v-hasPermi="['school:school:delete']"
|
|
|
|
|
>
|
|
|
|
|
删除
|
|
|
|
|
</el-button>
|
2024-05-14 11:45:46 +08:00
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
<!-- 分页 -->
|
|
|
|
|
<Pagination
|
|
|
|
|
v-model:limit="searchForm.pageSize"
|
2024-05-28 11:46:28 +08:00
|
|
|
v-model:page="searchForm.pageNo"
|
2024-05-14 11:45:46 +08:00
|
|
|
:total="total"
|
|
|
|
|
@pagination="getList"
|
|
|
|
|
/>
|
|
|
|
|
<DialogSchool ref="schoolDialog" @success="handleQuery" />
|
|
|
|
|
</div>
|
2024-04-28 16:20:45 +08:00
|
|
|
</template>
|
|
|
|
|
|
2024-05-28 11:46:28 +08:00
|
|
|
<script setup schoolName="School">
|
2024-05-14 11:45:46 +08:00
|
|
|
import DialogSchool from './Comp/DialogSchool.vue'
|
2024-05-28 11:46:28 +08:00
|
|
|
import * as api from '@/api/school/sch'
|
|
|
|
|
import { checkPermi } from '@/utils/permission'
|
|
|
|
|
|
2024-05-14 11:45:46 +08:00
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
|
|
|
|
|
|
|
const searchForm = ref({
|
2024-05-28 11:46:28 +08:00
|
|
|
schoolName: '',
|
|
|
|
|
pageNo: 1,
|
2024-05-14 11:45:46 +08:00
|
|
|
pageSize: 20
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
const total = ref(0)
|
|
|
|
|
|
|
|
|
|
const tableList = ref([])
|
|
|
|
|
const schoolDialog = ref()
|
|
|
|
|
|
|
|
|
|
function resetQuery() {
|
|
|
|
|
searchForm.value = {
|
2024-05-28 11:46:28 +08:00
|
|
|
schoolName: '',
|
2024-05-14 11:45:46 +08:00
|
|
|
pageSize: 20,
|
2024-05-28 11:46:28 +08:00
|
|
|
pageNo: 1
|
2024-05-14 11:45:46 +08:00
|
|
|
}
|
|
|
|
|
getList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleQuery() {
|
2024-05-28 11:46:28 +08:00
|
|
|
searchForm.value.pageNo = 1
|
2024-05-14 11:45:46 +08:00
|
|
|
getList()
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-28 11:46:28 +08:00
|
|
|
async function getList() {
|
|
|
|
|
loading.value = true
|
|
|
|
|
try {
|
|
|
|
|
const data = await api.getSchoolPage(searchForm.value)
|
|
|
|
|
tableList.value = data.list
|
|
|
|
|
total.value = data.total
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
2024-05-14 11:45:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function openForm(type, row = null) {
|
|
|
|
|
schoolDialog.value.open(type, row)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function handleDelete(row) {
|
|
|
|
|
try {
|
|
|
|
|
// 删除的二次确认
|
|
|
|
|
await message.delConfirm()
|
|
|
|
|
// 发起删除
|
2024-05-28 11:46:28 +08:00
|
|
|
await api.deleteSchool(row.id)
|
2024-05-14 11:45:46 +08:00
|
|
|
message.success(t('common.delSuccess'))
|
|
|
|
|
// 刷新列表
|
|
|
|
|
await getList()
|
|
|
|
|
} catch {}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-28 11:46:28 +08:00
|
|
|
async function changeStatus(row) {
|
|
|
|
|
try {
|
|
|
|
|
// 修改状态的二次确认
|
|
|
|
|
const text = row.status === CommonStatusEnum.ENABLE ? '启用' : '停用'
|
|
|
|
|
await message.confirm('确认要"' + text + '""' + row.schoolName + '"驾校吗?')
|
|
|
|
|
// 发起修改状态
|
|
|
|
|
await api.updateSchoolStatus(row.id, row.status)
|
|
|
|
|
// 刷新列表
|
|
|
|
|
await getList()
|
|
|
|
|
} catch {
|
|
|
|
|
// 取消后,进行恢复按钮
|
|
|
|
|
row.status =
|
|
|
|
|
row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE : CommonStatusEnum.ENABLE
|
|
|
|
|
}
|
2024-05-14 11:45:46 +08:00
|
|
|
}
|
2024-05-28 11:46:28 +08:00
|
|
|
|
|
|
|
|
/** 初始化 **/
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
await getList()
|
|
|
|
|
})
|
2024-05-14 11:45:46 +08:00
|
|
|
</script>
|
2024-04-28 16:20:45 +08:00
|
|
|
|
|
|
|
|
<style lang="scss" scoped></style>
|