| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import { last } from 'lodash';
- import { ref } from 'vue';
- import { useRoute } from 'vue-router';
- import { getGoafSelectOption } from '../monitor.api';
- import { useMineDepartmentStore } from '/@/store/modules/mine';
- import { historicalFormSchema, searchFormSchema } from '../monitor.data';
- import { FormSchema } from '/@/components/Form';
- export function useInitForm() {
- const mineStore = useMineDepartmentStore();
- const route = useRoute();
- const id = last(route.fullPath.split('/'));
- // 采空区选择器
- const goafId = ref('');
- const goafOptions = ref<any[]>([]);
- function initGoafOptions() {
- getGoafSelectOption({ mineCode: mineStore.getMineCode }).then(({ options, defaultValue }) => {
- goafOptions.value = options;
- goafId.value = defaultValue;
- });
- }
- initGoafOptions();
- const realtimeSchemas: FormSchema[] = [
- {
- field: 'mineCodeList',
- label: '煤矿名称',
- component: 'MineCascader',
- colProps: { span: 6 },
- componentProps: {
- resetOnDestroy: true,
- rootId: id,
- },
- },
- ...searchFormSchema,
- ];
- const historySchemas: FormSchema[] = [
- {
- field: 'mineCodeList',
- label: '煤矿名称',
- component: 'MineCascader',
- colProps: { span: 6 },
- required: true,
- componentProps: {
- resetOnDestroy: true,
- rootId: id,
- onChange() {
- initGoafOptions();
- },
- },
- },
- ...historicalFormSchema,
- ];
- return {
- historySchemas,
- realtimeSchemas,
- goafOptions,
- goafId,
- initGoafOptions,
- };
- }
|