|
@@ -63,13 +63,15 @@ const CtFormRef = ref()
|
|
|
const dictItemsObj = reactive({})
|
|
|
|
|
|
// 学校下拉列表
|
|
|
-const getSchoolListData = async (name, init = '') => {
|
|
|
+const getSchoolListData = async (name) => {
|
|
|
const item = formItems.value.options.find(e => e.key === 'schoolId')
|
|
|
if (!item) return
|
|
|
item[item.itemTextName] = name
|
|
|
- if (!init) item.value = null
|
|
|
- const data = await schoolSearchByName({ name })
|
|
|
- item.items = data
|
|
|
+ if (name === null || name === '') { item.items = [] }
|
|
|
+ else {
|
|
|
+ const data = await schoolSearchByName({ name })
|
|
|
+ item.items = data
|
|
|
+ }
|
|
|
}
|
|
|
const debouncedCallbackSchool = debounce(newValue => {
|
|
|
if (!newValue) return
|
|
@@ -77,13 +79,18 @@ const debouncedCallbackSchool = debounce(newValue => {
|
|
|
}, 500)
|
|
|
|
|
|
// 专业下拉列表
|
|
|
-const getMajorListData = async (name, init = '') => {
|
|
|
- if (name === '') return // 此接口不支持传空值
|
|
|
+const getMajorListData = async (name) => {
|
|
|
+ if (name === '') { // 此接口不支持传空值
|
|
|
+ item.items = []
|
|
|
+ return
|
|
|
+ }
|
|
|
const item = formItems.value.options.find(e => e.key === 'majorId')
|
|
|
item[item.itemTextName] = name
|
|
|
- if (!init) item.value = null
|
|
|
- const data = await schoolMajorByName({ name })
|
|
|
- item.items = data
|
|
|
+ if (name === null || name === '') { item.items = [] }
|
|
|
+ else {
|
|
|
+ const data = await schoolMajorByName({ name })
|
|
|
+ item.items = data
|
|
|
+ }
|
|
|
}
|
|
|
const debouncedCallbackMajor = debounce(newValue => {
|
|
|
getMajorListData(newValue)
|
|
@@ -219,7 +226,11 @@ const handle = (item) => {
|
|
|
})
|
|
|
} else { // 新增
|
|
|
editId.value = null
|
|
|
- formItems.value.options.forEach(e => e.value = e.default || null)
|
|
|
+ formItems.value.options.forEach(e => {
|
|
|
+ e.value = e.default || null
|
|
|
+ if (e.key === 'schoolId') e.items = []
|
|
|
+ if (e.key === 'majorId') e.items = []
|
|
|
+ })
|
|
|
}
|
|
|
nextTick(() => {
|
|
|
isEdit.value = true
|