lcny-admin-mobile-vue/src/pages/index/insect-monitors.vue

85 lines
2.3 KiB
Vue

<template>
<div>
<SearchForm :schemas="searchFormSchema"></SearchForm>
</div>
</template>
<script>
import SearchForm from '@/components/search-form'
import { http } from '@/api/index.js'
import { formatDataByObject } from '@/utils/index.js'
export default {
components: {
SearchForm,
},
data() {
return {
searchFormSchema: [
{
field: 'base',
label: '基地',
component: 'ApiSelect',
componentProps: ({ formActionType }) => {
return {
api: async () => {
const { data } = await http.get(
'/api/agricultural-device-basic'
)
return data.data
},
onOptionsChange: (options) => {
const { setFieldsValue } = formActionType
if (options.length) {
setFieldsValue({
base: options[0].value,
})
}
},
labelField: 'name',
valueField: 'id',
params: {
device_type: 1,
},
}
},
},
{
field: 'point',
component: 'ApiSelect',
label: '监控点',
componentProps: ({ formModel, formActionType }) => {
return {
placeholder: '监控点',
api: async (e) => {
if (e.agricultural_basic == null) return []
const { data } = await http.get(
`/api/agricultural-device-point/${e.agricultural_basic}`,
{
params: e,
}
)
return formatDataByObject(data.data)
},
onOptionsChange: (options) => {
const { setFieldsValue } = formActionType
if (options.length)
setFieldsValue({
point: options[0].value,
})
},
params: {
device_type: 1,
agricultural_basic: formModel.base,
},
labelField: 'label',
valueField: 'label',
}
},
},
],
}
},
}
</script>