|
@@ -7,8 +7,24 @@
|
|
|
<el-input v-model="fileName" placeholder="待上传" readonly />
|
|
|
</el-col>
|
|
|
<el-col :span="1.5" v-show="!fileUrlid">
|
|
|
- <el-button type="info" plain icon="el-icon-upload2" size="small" @click="uploadAccessory(field)">
|
|
|
- 上传
|
|
|
+ <el-upload
|
|
|
+ class="upload-demo"
|
|
|
+ ref="upload"
|
|
|
+ action="123"
|
|
|
+ :show-file-list="false"
|
|
|
+ :on-change="fileChange"
|
|
|
+ :file-list="fileList"
|
|
|
+ accept=".xlsx, .xls, .doc, .docx, .word, .wordx, .png, .jpg, .gif, .txt"
|
|
|
+ :auto-upload="false"
|
|
|
+ >
|
|
|
+ <el-button type="info" plain icon="el-icon-upload2" size="small">
|
|
|
+ 上传
|
|
|
+ </el-button>
|
|
|
+ </el-upload>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5" v-show="fileUrlid" >
|
|
|
+ <el-button type="success" plain icon="el-icon-download" size="small" @click="exportAccessory">
|
|
|
+ 下载
|
|
|
</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="1.5" v-show="fileUrlid" >
|
|
@@ -24,93 +40,49 @@
|
|
|
</el-row>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
- <!-- 上传对话框 -->
|
|
|
- <el-dialog
|
|
|
- :title="upload.title"
|
|
|
- :visible.sync="upload.open"
|
|
|
- width="400px"
|
|
|
- append-to-body
|
|
|
- >
|
|
|
- <el-upload
|
|
|
- ref="upload"
|
|
|
- :limit="1"
|
|
|
- accept=".xlsx, .xls, .doc, .docx, .word, .wordx, .png, .jpg, .gif, .txt"
|
|
|
- :headers="upload.headers"
|
|
|
- :action="upload.url + '?boId=' + form.id + '&flag=' + upload.flag + '&boType=' + form.boType"
|
|
|
- :disabled="upload.isUploading"
|
|
|
- :on-progress="handleFileUploadProgress"
|
|
|
- :on-success="handleFileSuccess"
|
|
|
- :auto-upload="false"
|
|
|
- drag
|
|
|
- >
|
|
|
- <i class="el-icon-upload"></i>
|
|
|
- <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
|
- </el-upload>
|
|
|
- <div slot="footer" class="dialog-footer">
|
|
|
- <el-button type="primary" @click="submitFileForm">确 定</el-button>
|
|
|
- <el-button @click="upload.open = false">取 消</el-button>
|
|
|
- </div>
|
|
|
- </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import {delAccessory} from "@/api/business/spd/bo/basic";
|
|
|
+import {insertAccessory,delAccessory} from "@/api/business/spd/bo/basic";
|
|
|
import axios from "axios";
|
|
|
-import { getToken } from "@/utils/auth";
|
|
|
|
|
|
export default {
|
|
|
name: "filemanager",
|
|
|
props: ["form","name","fileName","fileUrlid","field"],
|
|
|
data() {
|
|
|
return {
|
|
|
- // 上传参数
|
|
|
- upload: {
|
|
|
- // 是否显示弹出层
|
|
|
- open: false,
|
|
|
- // 弹出层标题
|
|
|
- title: "",
|
|
|
- // 是否禁用上传
|
|
|
- isUploading: false,
|
|
|
- // 上传类型
|
|
|
- flag: "",
|
|
|
- // 设置上传的请求头部
|
|
|
- headers: { Authorization: "Bearer " + getToken() },
|
|
|
- // 上传的地址
|
|
|
- url: process.env.VUE_APP_BASE_API + "/mk/bo/basic/upload",
|
|
|
- },
|
|
|
+ //文件
|
|
|
+ fileList: [],
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
|
},
|
|
|
methods: {
|
|
|
- //上传附件公共方法
|
|
|
- uploadAccessory(f) {
|
|
|
- // this.upload.title = "上传附件";
|
|
|
- this.upload.open = true;
|
|
|
- this.upload.flag = f;
|
|
|
- },
|
|
|
- // 提交上传文件
|
|
|
- submitFileForm() {
|
|
|
- this.$refs.upload.submit();
|
|
|
- },
|
|
|
- // 文件上传中处理
|
|
|
- handleFileUploadProgress(event, file, fileList) {
|
|
|
- this.upload.isUploading = true;
|
|
|
- },
|
|
|
- // 文件上传成功处理
|
|
|
- handleFileSuccess(response, file, fileList) {
|
|
|
- this.upload.open = false;
|
|
|
- this.upload.isUploading = false;
|
|
|
- this.$refs.upload.clearFiles();
|
|
|
- this.$alert(
|
|
|
- "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
|
|
|
- response.msg +
|
|
|
- "</div>",
|
|
|
- "上传结果",
|
|
|
- { dangerouslyUseHTMLString: true }
|
|
|
- );
|
|
|
- this.$emit('reload');
|
|
|
+ fileChange (file, fileList) {
|
|
|
+ if (fileList.length > 0) {
|
|
|
+ this.fileList = [fileList[fileList.length - 1]]
|
|
|
+ console.log('this.fileList',this.fileList);
|
|
|
+ let formData = new FormData();
|
|
|
+ if(this.fileList.length < 1){
|
|
|
+ formData.append('file', null);
|
|
|
+ }else{
|
|
|
+ this.fileList.forEach(el => {
|
|
|
+ formData.append('file', el.raw);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ formData.append("boId",this.form.id);
|
|
|
+ formData.append("flag",this.field);
|
|
|
+ formData.append("boType",this.form.boType);
|
|
|
+ insertAccessory(formData).then(response => {
|
|
|
+ console.log('response',response);
|
|
|
+ if(response.code == 200){
|
|
|
+ this.$emit('reload');
|
|
|
+ }else{
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
//下载附件
|
|
|
exportAccessory() {
|