transferConfigMqtt.vue 5.11 KB
<template>
  <div class="root">
    <div class="root-form">
      <BasicForm :showSubmitButton="false" @register="register">
        <template #uploadAdd1="{ field }">
          <span style="display: none">{{ field }}</span>
          <UploadDragger
            v-model:fileList="fileList"
            name="file"
            :multiple="true"
            action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
            @change="handleChange"
          >
            <p class="ant-upload-drag-icon">
              <InboxOutlined />
            </p>
            <p class="ant-upload-text">Click or drag file to this area to upload</p>
            <p class="ant-upload-hint">
              Support for a single or bulk upload. Strictly prohibit from uploading company data or
              other band files
            </p>
          </UploadDragger>
        </template>
        <template #uploadAdd2="{ field }">
          <span style="display: none">{{ field }}</span>
          <UploadDragger
            v-model:fileList="fileList"
            name="file"
            :multiple="true"
            action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
            @change="handleChange"
          >
            <p class="ant-upload-drag-icon">
              <InboxOutlined />
            </p>
            <p class="ant-upload-text">Click or drag file to this area to upload</p>
            <p class="ant-upload-hint">
              Support for a single or bulk upload. Strictly prohibit from uploading company data or
              other band files
            </p>
          </UploadDragger>
        </template>
        <template #uploadAdd3="{ field }">
          <span style="display: none">{{ field }}</span>
          <UploadDragger
            v-model:fileList="fileList"
            name="file"
            :multiple="true"
            action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
            @change="handleChange"
          >
            <p class="ant-upload-drag-icon">
              <InboxOutlined />
            </p>
            <p class="ant-upload-text">Click or drag file to this area to upload</p>
            <p class="ant-upload-hint">
              Support for a single or bulk upload. Strictly prohibit from uploading company data or
              other band files
            </p>
          </UploadDragger>
        </template>
      </BasicForm>
    </div>
  </div>
</template>
<script lang="ts">
  import { defineComponent, ref, reactive } from 'vue';
  import { BasicForm, useForm } from '/@/components/Form';
  import { modeMqttForm } from '../config';
  import { InboxOutlined } from '@ant-design/icons-vue';
  import { Alert, Divider, Descriptions, Upload, UploadDragger } from 'ant-design-vue';

  export default defineComponent({
    components: {
      BasicForm,
      [Alert.name]: Alert,
      [Divider.name]: Divider,
      [Descriptions.name]: Descriptions,
      [Descriptions.Item.name]: Descriptions.Item,
      InboxOutlined,
      UploadDragger,
      [Upload.UploadDragger]: Upload.UploadDragger,
    },
    emits: ['next', 'prev', 'register'],
    setup(_, { emit }) {
      const fileList = ref<[]>([]);
      const credentialsV = reactive({
        credentials: {
          type: '',
        },
      });
      const sonValues = reactive({
        configuration: {},
      });
      const [register, { validate, setFieldsValue, resetFields: defineClearFunc }] = useForm({
        labelWidth: 80,
        schemas: modeMqttForm,
        actionColOptions: {
          span: 14,
        },
        resetButtonOptions: {
          text: '上一步',
        },

        resetFunc: customResetFunc,
        submitFunc: customSubmitFunc,
      });
      const setStepTwoFieldsValueFunc = (v, v1) => {
        console.log(v);
        setFieldsValue(v);
        setFieldsValue({
          name: v1,
        });
      };
      const customClearStepTwoValueFunc = async () => {
        defineClearFunc();
      };
      async function customResetFunc() {
        emit('prev');
      }
      async function customSubmitFunc() {
        try {
          const values = await validate();
          emit('next', values);
        } catch (error) {
        } finally {
        }
      }
      const handleChange = () => {};
      const getSonValueFunc = async () => {
        sonValues.configuration = await validate();
        credentialsV.credentials.type = sonValues.configuration.type;
        Object.assign(sonValues.configuration, credentialsV);
        return sonValues;
      };
      return {
        getSonValueFunc,
        register,
        setStepTwoFieldsValueFunc,
        customClearStepTwoValueFunc,
        fileList,
        handleChange,
      };
    },
  });
</script>
<style lang="less" scoped>
  .root {
    width: 47.55vw;
    min-height: 50vh;
    border: 1px solid #bfbfbf;
    display: flex;
    margin-top: 1vh;
    margin-left: 1.5vw;
    border-radius: 8px;
    .root-form {
      width: 45vw;
      margin: 1vh 1vw;
      position: relative;
      :deep .ant-btn {
        position: absolute;
        right: 1vw;
        background-color: #0960bd;
        border-radius: 1px;
        span {
          color: white;
        }
      }
    }
  }
</style>