This commit is contained in:
qsh
2024-06-26 18:24:45 +08:00
parent f63104591b
commit 848830a21b
9 changed files with 169 additions and 145 deletions

View File

@@ -2,21 +2,16 @@
<div>
<el-form :model="searchForm" ref="searchRef" inline label-width="0">
<el-form-item>
<el-input
v-model="searchForm.schoolName"
placeholder="请输入驾校名称"
<el-cascader
:options="schoolOption"
v-model="searchForm.schPlace"
clearable
style="width: 180px"
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-input
v-model="searchForm.placeName"
placeholder="请输入场地名称"
clearable
style="width: 180px"
@keyup.enter="handleQuery"
filterable
show-all-levels
style="width: 300px"
placeholder="选择驾校/场地"
:props="{ expandTrigger: 'hover', multiple: false, checkStrictly: true }"
@change="handleQuery"
/>
</el-form-item>
<el-form-item>
@@ -69,85 +64,67 @@
</el-form-item>
</el-form>
<el-row :gutter="20">
<el-col :span="6" :offset="0">
<div class="head-container" style="max-height: 700px; overflow-y: auto">
<el-tree
ref="tree"
:data="schoolOption"
accordion
node-key="id"
highlight-current
:default-expanded-keys="selectNodes.map((item) => item.id)"
@node-click="handleNodeClick"
<el-table
:data="tableList"
v-loading="loading"
border
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="50" />
<el-table-column type="index" label="序号" width="60" />
<el-table-column
v-for="col in columns"
:prop="col.props"
:key="col.props"
:label="col.label"
:width="col.width"
show-overflow-tooltip
/>
<el-table-column label="备注" width="260">
<template #default="{ row }">
<div v-dompurify-html="row.remark"></div>
</template>
</el-table-column>
<el-table-column label="状态" width="80">
<template #default="{ row }">
<el-switch
v-model="row.status"
:active-value="0"
:inactive-value="1"
:disabled="!checkPermi(['school:class:update'])"
@change="handleChangeStatus(row)"
/>
</div>
</el-col>
<el-col :span="18" :offset="0">
<el-table
:data="tableList"
v-loading="loading"
border
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="50" />
<el-table-column type="index" label="序号" width="60" />
<el-table-column
v-for="col in columns"
:prop="col.props"
:key="col.props"
:label="col.label"
:width="col.width"
show-overflow-tooltip
/>
<el-table-column label="备注" width="260">
<template #default="{ row }">
<div v-dompurify-html="row.remark"></div>
</template>
</el-table-column>
<el-table-column label="状态" width="80">
<template #default="{ row }">
<el-switch
v-model="row.status"
:active-value="0"
:inactive-value="1"
:disabled="!checkPermi(['school:class:update'])"
@change="handleChangeStatus(row)"
/>
</template>
</el-table-column>
<el-table-column label="操作" width="120px">
<template #default="{ row }">
<el-button
type="primary"
style="padding: 0"
text
v-hasPermi="['school:class:update']"
@click="handleOpenDialog('update', row.typeId)"
>
修改
</el-button>
<el-button
type="danger"
style="padding: 0"
text
v-hasPermi="['school:class:delete']"
@click="handleRemove(row.typeId)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
v-model:limit="searchForm.pageSize"
v-model:page="searchForm.pageNo"
:total="total"
@pagination="getList"
/>
</el-col>
</el-row>
</template>
</el-table-column>
<el-table-column label="操作" width="120px">
<template #default="{ row }">
<el-button
type="primary"
style="padding: 0"
text
v-hasPermi="['school:class:update']"
@click="handleOpenDialog('update', row.typeId)"
>
修改
</el-button>
<el-button
type="danger"
style="padding: 0"
text
v-hasPermi="['school:class:delete']"
@click="handleRemove(row.typeId)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<Pagination
v-model:limit="searchForm.pageSize"
v-model:page="searchForm.pageNo"
:total="total"
@pagination="getList"
/>
<Dialog title="批量修改" v-model="batchStatusDialogShow" width="400px">
<el-form :model="statusForm" ref="statusRef" label-width="80px">
<el-form-item label="选择状态" prop="status">
@@ -186,8 +163,7 @@ const total = ref(0)
const tableList = ref([])
const searchForm = ref({
schoolName: undefined,
placeName: undefined,
schPlace: undefined,
typeName: undefined,
licenseType: undefined,
pageNo: 1,
@@ -195,41 +171,24 @@ const searchForm = ref({
})
const schoolOption = ref([])
const selectNodes = ref([])
// const selectNodes = ref([])
async function getSchoolList() {
try {
const data = await PlaceApi.getPlaceList()
schoolOption.value = data.schoolList.map((item) => ({
id: item.schoolId,
value: item.schoolId,
label: item.schoolName,
level: 1,
children: data.placeList
.filter((place) => item.schoolId === place.schoolId)
.map((place) => ({
id: place.placeId,
label: place.name,
level: 2
value: place.placeId,
label: place.name
}))
}))
} catch {}
}
function handleNodeClick(data, node) {
if (data.level === 1) {
selectNodes.value = [{ id: data.id, name: data.label }]
searchForm.value.schoolName = data.label
} else {
selectNodes.value = [
{ id: node.parent.data.id, name: node.parent.data.label },
{ id: data.id, name: data.label }
]
searchForm.value.schoolName = node.parent.data.label
searchForm.value.placeName = data.label
}
handleQuery()
}
const columns = [
{ props: 'schoolName', label: '驾校', width: '100px' },
{ props: 'placeName', label: '场地' },
@@ -248,7 +207,15 @@ function handleQuery() {
async function getList() {
loading.value = true
try {
const data = await ClassApi.getClassTypePage(searchForm.value)
const params = { ...searchForm.value }
if (params.schPlace && params.schPlace.length) {
params.schoolId = params.schPlace[0]
if (params.schPlace.length == 2) {
params.placeId = params.schPlace[1]
}
}
delete params.schPlace
const data = await ClassApi.getClassTypePage(params)
tableList.value = data.list
total.value = data.total
} finally {
@@ -263,8 +230,7 @@ function handleOpenDialog(type, id = null) {
function handleReset() {
searchForm.value = {
schoolName: undefined,
placeName: undefined,
schPlace: undefined,
typeName: undefined,
licenseType: undefined,
pageNo: 1,