fix:机组系统子系统下拉框空则全部适配 #89

Merged
xiaojinfei merged 1 commits from dev-xjf into master 3 weeks ago
  1. 42
      src/views/warn/alarm/alarm.data.ts
  2. 4
      src/views/warn/alarm/index.vue

42
src/views/warn/alarm/alarm.data.ts

@ -14,14 +14,16 @@ export const searchFormSchema: FormSchema[] = [
label: '机组', label: '机组',
field: 'unit', field: 'unit',
component: 'Select', component: 'Select',
defaultValue: optionList.units[0].id || null, // defaultValue: optionList.units[0].id || null,
colProps: { span: 5 }, defaultValue: null,
colProps: { span: 4 },
componentProps: ({ schema, tableAction, formActionType, formModel }) => { componentProps: ({ schema, tableAction, formActionType, formModel }) => {
return { return {
// xxxx props // xxxx props
allowClear: false, allowClear: false,
placeholder: '请选择机组', placeholder: '全部机组',
options: optionList.units.map(unit => ({ value: unit.id, label: unit.name })), options: optionList.units.map(unit => ({ value: unit.id, label: unit.name })),
onChange: async (e: any) => { onChange: async (e: any) => {
// const { reload } = tableAction // const { reload } = tableAction
@ -32,8 +34,13 @@ export const searchFormSchema: FormSchema[] = [
unitId: e, unitId: e,
typeId: formModel.type, typeId: formModel.type,
} }
//如果typeId是空,则不设置system'Options
if (!param.typeId) {
systemOptions.value = []
return
}
systemOptions.value = await subSystemListApi(param) systemOptions.value = await subSystemListApi(param)
formModel.system = systemOptions.value[0].id // formModel.system = systemOptions.value[0].id
}, },
} }
}, },
@ -42,12 +49,14 @@ export const searchFormSchema: FormSchema[] = [
label: '系统', label: '系统',
field: 'type', field: 'type',
component: 'Select', component: 'Select',
defaultValue: optionList.types[0].id || null, // defaultValue: optionList.types[0].id || null,
colProps: { span: 5 }, defaultValue: null,
colProps: { span: 4 },
componentProps: ({ formModel }) => { componentProps: ({ formModel }) => {
return { return {
allowClear: false, allowClear: false,
placeholder: '请选择系统', placeholder: '全部系统',
options: optionList.types.map(type => ({ value: type.id, label: type.name })), options: optionList.types.map(type => ({ value: type.id, label: type.name })),
onChange: async (e: any) => { onChange: async (e: any) => {
// const { reload } = tableAction // const { reload } = tableAction
@ -58,6 +67,11 @@ export const searchFormSchema: FormSchema[] = [
unitId: formModel.unit, unitId: formModel.unit,
typeId: e, typeId: e,
} }
//如果typeId是空,则不设置system'Options
if (!param.typeId) {
systemOptions.value = []
return
}
systemOptions.value = await subSystemListApi(param) systemOptions.value = await subSystemListApi(param)
}, },
} }
@ -67,12 +81,13 @@ export const searchFormSchema: FormSchema[] = [
label: '子系统', label: '子系统',
field: 'system', field: 'system',
component: 'Select', component: 'Select',
defaultValue: systemOptions.value[0].id || null, // defaultValue: systemOptions.value[0].id || null,
colProps: { span: 5 }, defaultValue: null,
colProps: { span: 4 },
componentProps: () => { componentProps: () => {
return { return {
allowClear: false, allowClear: false,
placeholder: '请选择子系统', placeholder: '全部子系统',
options: systemOptions.value.map(system => ({ value: system.id, label: system.name })), options: systemOptions.value.map(system => ({ value: system.id, label: system.name })),
} }
}, },
@ -82,10 +97,11 @@ export const searchFormSchema: FormSchema[] = [
label: '模型实例名称', label: '模型实例名称',
field: 'mpName', field: 'mpName',
component: 'Input', component: 'Input',
labelWidth: 120, labelWidth: 100,
defaultValue: '', defaultValue: '',
colProps: { span: 6 }, colProps: { span: 5 },
} },
] ]
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [

4
src/views/warn/alarm/index.vue

@ -79,8 +79,8 @@ async function handleTrend(record: Recordable) {
} }
onMounted(async () => { onMounted(async () => {
const { setFieldsValue } = getForm() // const { setFieldsValue } = getForm()
await setFieldsValue({ system: null }) // await setFieldsValue({ system: null })
}) })
</script> </script>

Loading…
Cancel
Save