|
@@ -11,7 +11,7 @@
|
|
|
</BasicModal>
|
|
|
</template>
|
|
|
<script lang="ts" setup>
|
|
|
- import { onMounted, ref, defineEmits, onUnmounted, watch, PropType, nextTick, computed } from 'vue';
|
|
|
+ import { onMounted, ref, defineEmits, onUnmounted, watch, computed } from 'vue';
|
|
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
|
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
|
|
import { FormSchema } from '/@/components/Form';
|
|
@@ -22,10 +22,10 @@
|
|
|
|
|
|
const emit = defineEmits(['close', 'register']);
|
|
|
const props = defineProps({
|
|
|
- formSchema: {
|
|
|
- type: Array as PropType<FormSchema[]>,
|
|
|
- default: () => [],
|
|
|
- },
|
|
|
+ // formSchema: {
|
|
|
+ // type: Array as PropType<FormSchema[]>,
|
|
|
+ // default: () => [],
|
|
|
+ // },
|
|
|
deviceType: {
|
|
|
type: String,
|
|
|
default: '',
|
|
@@ -33,9 +33,9 @@
|
|
|
});
|
|
|
const FormRef = ref();
|
|
|
const tabType = ref('deviceInfo');
|
|
|
- const formSchema = ref<FormSchema[]>([]);
|
|
|
+ const formSchema = ref<Array<FormSchema>>([]);
|
|
|
const formData = ref({});
|
|
|
- const deviceTypeName = ref('');
|
|
|
+ // const props.deviceType ref('');
|
|
|
const deviceType = computed(() => props.deviceType);
|
|
|
|
|
|
// const arrToFormColumns = (tableHeaderColumns = [], devicetype) => {
|
|
@@ -288,14 +288,14 @@
|
|
|
});
|
|
|
|
|
|
const [registerForm, { resetSchema, getFieldsValue, setFieldsValue, resetFields }] = useForm({
|
|
|
- schemas: <FormSchema[]>formSchema.value,
|
|
|
+ schemas: formSchema.value,
|
|
|
showActionButtonGroup: false,
|
|
|
});
|
|
|
|
|
|
function getColumns() {
|
|
|
- let formSchemaArr = getFormSchemaColumns(tabType.value === 'deviceInfo' ? `${deviceTypeName.value}_edit` : `${deviceTypeName.value}_input`) || [];
|
|
|
+ let formSchemaArr = getFormSchemaColumns(tabType.value === 'deviceInfo' ? `${props.deviceType}_edit` : `${props.deviceType}_input`) || [];
|
|
|
if (formSchemaArr && formSchemaArr.length < 1) {
|
|
|
- const arr = deviceTypeName.value.split('_');
|
|
|
+ const arr = props.deviceType.split('_');
|
|
|
formSchemaArr = getFormSchemaColumns(tabType.value === 'deviceInfo' ? arr[0] + '_edit' : arr[0] + '_input') || [];
|
|
|
}
|
|
|
arrToFormColumns(formSchemaArr);
|
|
@@ -303,8 +303,7 @@
|
|
|
|
|
|
watch(
|
|
|
() => props.deviceType,
|
|
|
- (devicetype) => {
|
|
|
- deviceTypeName.value = devicetype;
|
|
|
+ () => {
|
|
|
getColumns();
|
|
|
if (FormRef.value) resetSchema(formSchema.value);
|
|
|
}
|