Commit ae2643b6 authored by renjintao's avatar renjintao

PROCESS

parent bc31834f
<template>
<div>
<div>
<Input v-model="newName" placeholder="请选择上传文件" disabled>
<Button v-if="view" icon="md-download" slot="prepend" @click="downFile(newName)"> </Button>
<Button type="primary" icon="ios-cloud-upload-outline" slot="append" @click="handler">上传</Button>
<Button v-if="view" icon="md-download" slot="prepend" @click="downFile(newName)"> </Button>
<Button type="primary" icon="ios-cloud-upload-outline" slot="append" @click="handler">上传</Button>
</Input>
<Upload
v-model="name"
:action="postUrl"
:on-success="uploadSuccess"
:on-error="uploadError"
:on-remove="removeFile"
:format="formatList"
:max-size="maxSize"
:on-exceeded-size="onExceededSize"
:on-format-error="onFormatError"
:show-upload-list="false"
:files="files"
:on-progress="onProgress"
>
<Button v-show="1==2" type="primary" ref="upload">上传</Button>
<Upload v-model="name" :action="postUrl" :on-success="uploadSuccess" :on-error="uploadError" :on-remove="removeFile" :format="formatList" :max-size="maxSize" :on-exceeded-size="onExceededSize" :on-format-error="onFormatError" :show-upload-list="false" :files="files" :on-progress="onProgress">
<Button v-show="1==2" type="primary" ref="upload">上传</Button>
</Upload>
<Progress :percent="per" :stroke-width="5" v-show="vshowPro" />
</div>
</div>
</template>
<script>
import util from "@/libs/util";
export default {
name: "inputExcel",
model: {
prop: "value",
event: "on-change"
},
data() {
return {
file: null,
name: this.value,
downUrl: fileUrlDown,
fileUrlPath: "",
nameList: [],
postUrl:
fileUrl +
"/upload/?token=Bearer " +
util.cookies.get("token") +
"&" +
this.parms,
formatList: ["xlsx", "xls"],
newName: "",
newPath: "",
per: 0,
vshowPro: false
};
},
created() {},
props: {
value: [String, Number, Array, Object],
maxSize: {
type: Number,
default: 10240
name: "inputExcel",
model: {
prop: "value",
event: "on-change"
},
files: {
type: Boolean,
default: false
data() {
return {
file: null,
name: this.value,
downUrl: fileUrlDown,
fileUrlPath: "",
nameList: [],
postUrl: fileUrl +
"/upload/?token=Bearer " +
util.cookies.get("token") +
"&" +
this.parms,
formatList: ["xlsx", "xls", "jpg", "gif", "png", "pdf", "docx", "doc", "txt", "rar", "zip"],
newName: "",
newPath: "",
per: 0,
vshowPro: false
};
},
parms: {
type: String,
default: ""
},
showButton: {
type: Boolean,
default: true
}
},
methods: {
onProgress(event, file, fileList) {
this.per = 0;
this.vshowPro = true;
},
handler() {
this.$refs.upload.$el.click();
},
// change(event) {
// this.$emit('on-change', event.target.value)
// },
//上传成功文件
uploadSuccess(response, file, fileList) {
this.per = 60;
this.vshowPro = true;
const hbaseFileList = [];
const filesList = [];
if (file.response.status == 0) {
let objImag = {};
objImag.fileName = file.response.data.fileName;
objImag.filePath = file.response.data.downloadPath;
filesList.push(objImag);
this.newName = file.response.data.fileName;
this.newPath = file.response.data.downloadPath;
this.$emit("on-change", JSON.stringify(filesList));
this.per = 100;
setTimeout(() => {
this.per = 0;
this.vshowPro = false;
}, 2000);
} else {
this.$Message.error("上传失败,请重新上传!");
}
},
//上传文件失败
uploadError(response, file, fileList) {
this.$Message.error("上传失败,请重新上传!");
},
//文件大小验证返回
onExceededSize(file, fileList) {
if (Object.keys(file).length == 0) {
this.$Message.error(
"上传文件不能大于" + this.maxSize + "k,请重新上传!"
);
}
created() {},
props: {
value: [String, Number, Array, Object],
maxSize: {
type: Number,
default: 10240
},
files: {
type: Boolean,
default: false
},
parms: {
type: String,
default: ""
},
showButton: {
type: Boolean,
default: true
}
},
//文件格式验证
onFormatError(file, fileList) {
if (Object.keys(file).length == 0) {
this.$Message.error("上传文件格式不正确,请重新上传!");
}
methods: {
onProgress(event, file, fileList) {
this.per = 0;
this.vshowPro = true;
},
handler() {
this.$refs.upload.$el.click();
},
// change(event) {
// this.$emit('on-change', event.target.value)
// },
//上传成功文件
uploadSuccess(response, file, fileList) {
this.per = 60;
this.vshowPro = true;
const hbaseFileList = [];
const filesList = [];
if (file.response.status == 0) {
let objImag = {};
objImag.fileName = file.response.data.fileName;
objImag.filePath = file.response.data.downloadPath;
filesList.push(objImag);
this.newName = file.response.data.fileName;
this.newPath = file.response.data.downloadPath;
this.$emit("on-change", JSON.stringify(filesList));
this.per = 100;
setTimeout(() => {
this.per = 0;
this.vshowPro = false;
}, 2000);
} else {
this.$Message.error("上传失败,请重新上传!");
}
},
//上传文件失败
uploadError(response, file, fileList) {
this.$Message.error("上传失败,请重新上传!");
},
//文件大小验证返回
onExceededSize(file, fileList) {
if (Object.keys(file).length == 0) {
this.$Message.error(
"上传文件不能大于" + this.maxSize + "k,请重新上传!"
);
}
},
//文件格式验证
onFormatError(file, fileList) {
if (Object.keys(file).length == 0) {
this.$Message.error("上传文件格式不正确,请重新上传!");
}
},
//删除上传
removeFile(file, fileList) {},
formatL() {
if (this.files) {
this.formatList = [
"pdf",
"docx",
"doc",
"xls",
"xlsx",
"txt",
"png",
"jpg",
"gif",
"zip",
"rar"
];
}
return this.formatList;
},
downFile(path) {
let truePath = path.trim();
if (truePath.length > 2) {
if (
truePath.substring(0, 7).toLowerCase() == "http://" ||
truePath.substring(0, 8).toLowerCase() == "https://"
) {
window.open(truePath, "_blank");
} else {
this.fileUrlPath = this.downUrl + path;
window.open(this.fileUrlPath, "_blank");
}
}
}
},
//删除上传
removeFile(file, fileList) {},
formatL() {
if (this.files) {
this.formatList = [
"pdf",
"docx",
"doc",
"xls",
"xlsx",
"txt",
"png",
"jpg",
"gif",
"zip",
"rar"
];
}
return this.formatList;
mounted() {
this.formatL();
},
downFile(path) {
let truePath = path.trim();
if (truePath.length > 2) {
if (
truePath.substring(0, 7).toLowerCase() == "http://" ||
truePath.substring(0, 8).toLowerCase() == "https://"
) {
window.open(truePath, "_blank");
} else {
this.fileUrlPath = this.downUrl + path;
window.open(this.fileUrlPath, "_blank");
computed: {
nativeInputValue() {
return this.value === null || this.value === undefined ? "" : this.value;
},
view() {
return true
}
}
}
},
mounted() {
this.formatL();
},
computed: {
nativeInputValue() {
return this.value === null || this.value === undefined ? "" : this.value;
},
view(){
return true
}
},
watch: {
value(v) {
this.name = v;
watch: {
value(v) {
this.name = v;
}
}
}
};
</script>
<style lang="less">
</style>
\ No newline at end of file
</style>
......@@ -9,9 +9,11 @@
<FormItem>
<dictionary code="import.im.page" style="width:160px" @on-change="pageChange" v-model="pageType"></dictionary>
</FormItem>
<!--
<FormItem>
<div class="tip mr20">{{listLength}}条数据</div>
</FormItem>
-->
<FormItem>
<Button type="primary" @click="openInfoModal" :disabled="btnIm">导入</Button>
</FormItem>
......@@ -37,12 +39,12 @@
</a>
</FormItem>
<FormItem>
<RadioGroup v-model="excelType" type="button" @on-change="changeExcel">
<RadioGroup v-model="excelType" type="button" @on-change="changeExcel" size="small">
<Radio label="0">
<Icon type="md-list" />列表
<Icon type="ios-list-box-outline" />
</Radio>
<Radio label="1">
<Icon type="md-clipboard" />Excel
<Icon type="ios-copy" />
</Radio>
</RadioGroup>
</FormItem>
......@@ -400,6 +402,11 @@ export default {
var tempCos = Object.keys(this.openDatas[val].dataTable[0]); //获取列表标题
this.columnsImport = [];
var headersNow = [];
headersNow.push({
type: 'index',
width: 60,
align: 'center'
})
tempCos.forEach((el) => {
let headObj = {};
headObj.title = el;
......@@ -532,6 +539,11 @@ export default {
var lines = csv.split("\n"); //第一行标题
var headers = lines[0].split(",");
var headersNow = [];
headersNow.push({
type: 'index',
width: 60,
align: 'center'
})
headers.forEach((elHead) => {
let headObj = {};
headObj.title = elHead;
......@@ -539,7 +551,6 @@ export default {
headersNow.push(headObj);
});
this.columnsImport = headersNow;
var result = [];
for (var i = 1; i < lines.length - 1; i++) {
var obj = {};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment