dzqm.vue 2.18 KB
<template>
  <div class="from-clues">
    <!-- 表单部分 -->
    <div class="from-clues-header">
      <el-form :model="ruleForm" label-width="80px">
        <el-row>
          <el-col :span="5">
            <el-form-item label="电子签名">
              <el-input v-model="ruleForm.dzqm"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="19" class="btnColRight">
            <el-form-item>
              <el-button type="primary" native-type="submit">查询</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <el-upload
      class="upload-demo"
      action=""
      :limit="1"
      multiple
      :auto-upload="false"
      accept=".jpg, .png"
      :on-change="handleChange"
      :before-upload="beforeUpload"
      :file-list="fileList"
      list-type="picture"
      drag>
      <i class="el-icon-upload"></i>
      <div class="el-upload__text">将图片拖到此处,或<em>点击上传</em></div>
      <div class="el-upload__tip" slot="tip">只能上传jpg/png文件,且不超过5MB</div>
    </el-upload>
    <!-- 表格 -->
  </div>
</template>
<script>
  import { dzqmUpload } from '@/api/dzqm'
  export default {
    name: "dzqm",
    data () {
      return {
        ruleForm: {
          dzqm: ""
        },
        fileList: [], // 已上传文件列表
      }
    },
    methods: {
      beforeUpload (file) {
        // 上传文件之前的钩子,返回false则停止上传
        const isJPGorPNG = file.type === 'image/jpeg' || file.type === 'image/png';
        const isLt2M = file.size / 1024 / 1024 < 5;
        if (!isJPGorPNG) {
          this.$message.error('上传图片只能是 JPG/PNG 格式!');
          return false;
        }
        if (!isLt2M) {
          this.$message.error('上传图片大小不能超过 5MB!');
          return false;
        }
        return true;
      },
      async handleChange (file) {
        var formdata = new FormData();
        formdata.append("file", file.raw);
        dzqmUpload(formdata).then(res => {
          console.log(res);
        })
      }
    }
  };
  </script>
<style scoped lang="scss">
  @import "~@/styles/public.scss";
</style>