|
@@ -0,0 +1,127 @@
|
|
|
+<template>
|
|
|
+ <BasicModal
|
|
|
+ v-bind="$attrs"
|
|
|
+ @register="register"
|
|
|
+ :title="t('routes.devices.browserDevice')"
|
|
|
+ @ok="submitModal"
|
|
|
+ @visible-change="handleVisibleChange"
|
|
|
+ >
|
|
|
+ <div class="pt-3px pr-3px">
|
|
|
+ <BasicForm @register="registerForm">
|
|
|
+ <template #userName="{ model, field }">
|
|
|
+ {{ model[field] }}
|
|
|
+ </template>
|
|
|
+ <template #name="{ model, field }">
|
|
|
+ {{ model[field] }}
|
|
|
+ </template>
|
|
|
+ </BasicForm>
|
|
|
+ </div>
|
|
|
+ </BasicModal>
|
|
|
+</template>
|
|
|
+<script lang="ts">
|
|
|
+ import { defineComponent, ref } from 'vue';
|
|
|
+ import { BasicModal, useModalInner } from '/@/components/Modal';
|
|
|
+ import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
|
|
|
+ // import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
+ // import { AddDevice, checkDevice } from '/@/api/corporation/modal';
|
|
|
+ import { useI18n } from '/@/hooks/web/useI18n';
|
|
|
+ export default defineComponent({
|
|
|
+ components: { BasicModal, BasicForm },
|
|
|
+ props: {
|
|
|
+ userData: { type: Object },
|
|
|
+ },
|
|
|
+ emits: ['register'],
|
|
|
+ setup() {
|
|
|
+ // const modelRef = ref({});
|
|
|
+ const num = ref(0);
|
|
|
+ const { t } = useI18n();
|
|
|
+ // const { createMessage } = useMessage();
|
|
|
+ // const { success, error } = createMessage;
|
|
|
+
|
|
|
+ const [register] = useModalInner((data) => {
|
|
|
+ data && onDataReceive(data);
|
|
|
+ });
|
|
|
+
|
|
|
+ // const handlevalidator = async (_, value) => {
|
|
|
+ // console.log('handlevalidator', value);
|
|
|
+ // if (!value) {
|
|
|
+ // return Promise.resolve();
|
|
|
+ // }
|
|
|
+ // try {
|
|
|
+ // let res = await checkDevice({
|
|
|
+ // childName: value,
|
|
|
+ // });
|
|
|
+ // if (res.message) {
|
|
|
+ // return Promise.reject(res.message);
|
|
|
+ // } else {
|
|
|
+ // return Promise.resolve();
|
|
|
+ // }
|
|
|
+ // } catch (err) {
|
|
|
+ // return Promise.reject(err);
|
|
|
+ // }
|
|
|
+ // };
|
|
|
+ const schemas: FormSchema[] = [
|
|
|
+ {
|
|
|
+ field: 'userName',
|
|
|
+ label: t('routes.corporation.enterpriseName'),
|
|
|
+ slot: 'userName',
|
|
|
+ component: 'Input',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'name',
|
|
|
+ label: t('routes.corporation.enterpriseId'),
|
|
|
+ slot: 'name',
|
|
|
+ component: 'Input',
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ // let schemasList = []
|
|
|
+ const [
|
|
|
+ registerForm,
|
|
|
+ {
|
|
|
+ setFieldsValue,
|
|
|
+ resetFields,
|
|
|
+ // getFieldsValue,
|
|
|
+ // validateFields,
|
|
|
+ // appendSchemaByField,
|
|
|
+ // removeSchemaByFiled,
|
|
|
+ },
|
|
|
+ ] = useForm({
|
|
|
+ labelWidth: 120,
|
|
|
+ schemas,
|
|
|
+ showActionButtonGroup: false,
|
|
|
+ actionColOptions: {
|
|
|
+ span: 24,
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ function onDataReceive(data) {
|
|
|
+ // 方式1;
|
|
|
+ resetFields();
|
|
|
+ setFieldsValue({
|
|
|
+ ...data.record,
|
|
|
+ });
|
|
|
+ console.log('data', data);
|
|
|
+ // // 方式2
|
|
|
+ // modelRef.value = { ...data.record };
|
|
|
+ }
|
|
|
+
|
|
|
+ async function submitModal() {}
|
|
|
+
|
|
|
+ function handleVisibleChange() {
|
|
|
+ // v && props.userData && nextTick(() => onDataReceive(props.userData));
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ register,
|
|
|
+ submitModal,
|
|
|
+ schemas,
|
|
|
+ registerForm,
|
|
|
+ // numOnChange,
|
|
|
+ // modelRef,
|
|
|
+ handleVisibleChange,
|
|
|
+ num,
|
|
|
+ // errorMsg: error,
|
|
|
+ t,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ });
|
|
|
+</script>
|