{"remainingRequest":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/node_modules/vue-loader/lib/index.js??vue-loader-options!/data/jenkins/workspace/mer.ws.baibaodun.com.cn/src/components/base/uploadFilePicMul.vue?vue&type=script&lang=js","dependencies":[{"path":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/src/components/base/uploadFilePicMul.vue","mtime":1717403463844},{"path":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/node_modules/babel-loader/lib/index.js","mtime":456789000000},{"path":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/data/jenkins/workspace/mer.ws.baibaodun.com.cn/node_modules/vue-loader/lib/index.js","mtime":499162500000}],"contextDependencies":[],"result":["//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\nimport { fileFileApi } from '@/api/systemSetting';\nimport { getToken } from '@/utils/auth';\nexport default {\n  name: 'UploadFile',\n  props: {\n    file: Array,\n    disabled: Boolean,\n  },\n  data() {\n    return {\n      myHeaders: { 'X-Token': getToken() },\n      fileType: ['png', 'jpg'],\n      fileList: [],\n    };\n  },\n\n  watch: {\n    file: {\n      handler(v) {\n        console.log(v);\n        if (Array.isArray(v)) {\n          this.fileList = v;\n        } else {\n          this.fileList = [];\n        }\n      },\n      deep: true,\n    },\n  },\n\n  methods: {\n    //上传文件之前\n    beforeUpload(file) {\n      if (file.type != '' || file.type != null || file.type != undefined) {\n        //截取文件的后缀，判断文件类型\n        const FileExt = file.name.replace(/.+\\./, '').toLowerCase();\n        //计算文件的大小\n        const isLt5M = file.size / 1024 / 1024 < 2; //这里做文件大小限制\n        //如果大于50M\n        if (!isLt5M) {\n          this.$message('上传文件大小不能超过 2MB!');\n          return false;\n        }\n        //如果文件类型不在允许上传的范围内\n        if (this.fileType.includes(FileExt)) {\n          return true;\n        } else {\n          this.$message.error('上传文件格式不正确!');\n          return false;\n        }\n      }\n    },\n    handleRemove(file, fileList) {\n      this.$emit('input', this.fileList);\n\n      this.fileList = fileList;\n    },\n    handleChange(v, fl) {\n      this.fileList = fl;\n    },\n    upload() {\n      console.log(this.fileList);\n\n      this.fileList.forEach((v, index) => {\n        this.handleUploadForm(v, index);\n      });\n    },\n    handleUploadForm(param, ix) {\n      const formData = new FormData();\n      const data = {\n        model: this.$route.path.split('/')[1],\n        pid: 7,\n      };\n      formData.append('multipart', param.raw);\n      const loading = this.$loading({\n        lock: true,\n        text: '上传中，请稍候...',\n        spinner: 'el-icon-loading',\n        background: 'rgba(0, 0, 0, 0.7)',\n      });\n      fileFileApi(formData, data)\n        .then((res) => {\n          console.log(res);\n          loading.close();\n          this.$set(this.fileList[ix], 'status', true);\n          this.$set(this.fileList[ix], 'url','crmebimage'+ res.url.split('crmebimage')[1]);\n\n          this.$message.success('上传成功');\n        })\n        .catch((res) => {\n          this.$message.error('上传失败');\n\n          loading.close();\n        });\n    },\n  },\n};\n",null]}