修复树形下拉不能默认选中

This commit is contained in:
不做码农 2022-12-16 14:58:01 +08:00
parent a2dd3ee236
commit 2d951c82f6
2 changed files with 16 additions and 13 deletions

View File

@ -34,8 +34,9 @@
:default-expand-all="isExpandAll" :default-expand-all="isExpandAll"
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"> :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
<el-table-column prop="deptName" label="部门名称" width="260"></el-table-column> <el-table-column prop="deptName" label="部门名称" width="260"></el-table-column>
<el-table-column prop="deptId" label="部门id"></el-table-column>
<el-table-column prop="leader" label="负责人" width="100"></el-table-column> <el-table-column prop="leader" label="负责人" width="100"></el-table-column>
<el-table-column prop="orderNum" label="排序" width="200"></el-table-column> <el-table-column prop="orderNum" label="排序"></el-table-column>
<el-table-column label="状态" align="center" prop="status"> <el-table-column label="状态" align="center" prop="status">
<template #default="scope"> <template #default="scope">
<dict-tag :options="statusOptions" :value="scope.row.status" /> <dict-tag :options="statusOptions" :value="scope.row.status" />
@ -46,7 +47,7 @@
<span>{{ parseTime(scope.row.createTime) }}</span> <span>{{ parseTime(scope.row.createTime) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center"> <el-table-column label="操作" align="center" width="200">
<template #default="scope"> <template #default="scope">
<el-button text size="small" icon="edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:dept:update']"> <el-button text size="small" icon="edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:dept:update']">
{{ $t('btn.edit') }} {{ $t('btn.edit') }}
@ -79,7 +80,8 @@
:props="{ value: 'deptId', label: 'deptName', children: 'children' }" :props="{ value: 'deptId', label: 'deptName', children: 'children' }"
value-key="deptId" value-key="deptId"
placeholder="选择上级部门" placeholder="选择上级部门"
check-strictly /> check-strictly
:render-after-expand="false" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :lg="12"> <el-col :lg="12">
@ -147,7 +149,7 @@ const statusOptions = ref([])
// //
const queryParams = reactive({ const queryParams = reactive({
deptName: undefined, deptName: undefined,
status: undefined, status: undefined
}) })
const state = reactive({ const state = reactive({
// //
@ -161,17 +163,17 @@ const state = reactive({
{ {
type: 'email', type: 'email',
message: '请输入正确的邮箱地址', message: '请输入正确的邮箱地址',
trigger: ['blur', 'change'], trigger: ['blur', 'change']
}, }
], ],
phone: [ phone: [
{ {
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
message: '请输入正确的手机号码', message: '请输入正确的手机号码',
trigger: 'blur', trigger: 'blur'
}, }
], ]
}, }
}) })
const formRef = ref() const formRef = ref()
const { form, rules } = toRefs(state) const { form, rules } = toRefs(state)
@ -199,7 +201,7 @@ function reset() {
leader: undefined, leader: undefined,
phone: undefined, phone: undefined,
email: undefined, email: undefined,
status: '0', status: '0'
} }
proxy.resetForm('formRef') proxy.resetForm('formRef')
} }
@ -262,7 +264,7 @@ function handleDelete(row) {
.$confirm('是否确认删除名称为"' + row.deptName + '"的数据项?', '警告', { .$confirm('是否确认删除名称为"' + row.deptName + '"的数据项?', '警告', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning'
}) })
.then(function () { .then(function () {
return delDept(row.deptId) return delDept(row.deptId)

View File

@ -180,7 +180,8 @@
:props="{ value: 'id', label: 'label', children: 'children' }" :props="{ value: 'id', label: 'label', children: 'children' }"
value-key="id" value-key="id"
placeholder="请选择归属部门" placeholder="请选择归属部门"
check-strictly /> check-strictly
:render-after-expand="false" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :lg="12"> <el-col :lg="12">