Commit ae2643b6 authored by renjintao's avatar renjintao

PROCESS

parent bc31834f
<template> <template>
<div> <div>
<Input v-model="newName" placeholder="请选择上传文件" disabled> <Input v-model="newName" placeholder="请选择上传文件" disabled>
<Button v-if="view" icon="md-download" slot="prepend" @click="downFile(newName)"> </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> <Button type="primary" icon="ios-cloud-upload-outline" slot="append" @click="handler">上传</Button>
</Input> </Input>
<Upload <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">
v-model="name" <Button v-show="1==2" type="primary" ref="upload">上传</Button>
: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> </Upload>
<Progress :percent="per" :stroke-width="5" v-show="vshowPro" /> <Progress :percent="per" :stroke-width="5" v-show="vshowPro" />
</div> </div>
</template> </template>
<script> <script>
import util from "@/libs/util"; import util from "@/libs/util";
export default { export default {
name: "inputExcel", name: "inputExcel",
model: { model: {
prop: "value", prop: "value",
event: "on-change" 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
}, },
files: { data() {
type: Boolean, return {
default: false 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: { created() {},
type: String, props: {
default: "" value: [String, Number, Array, Object],
}, maxSize: {
showButton: { type: Number,
type: Boolean, default: 10240
default: true },
} files: {
}, type: Boolean,
methods: { default: false
onProgress(event, file, fileList) { },
this.per = 0; parms: {
this.vshowPro = true; type: String,
}, default: ""
handler() { },
this.$refs.upload.$el.click(); showButton: {
}, type: Boolean,
// change(event) { default: true
// 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,请重新上传!"
);
}
}, },
//文件格式验证 methods: {
onFormatError(file, fileList) { onProgress(event, file, fileList) {
if (Object.keys(file).length == 0) { this.per = 0;
this.$Message.error("上传文件格式不正确,请重新上传!"); 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");
}
}
}
}, },
//删除上传 mounted() {
removeFile(file, fileList) {}, this.formatL();
formatL() {
if (this.files) {
this.formatList = [
"pdf",
"docx",
"doc",
"xls",
"xlsx",
"txt",
"png",
"jpg",
"gif",
"zip",
"rar"
];
}
return this.formatList;
}, },
downFile(path) { computed: {
let truePath = path.trim(); nativeInputValue() {
if (truePath.length > 2) { return this.value === null || this.value === undefined ? "" : this.value;
if ( },
truePath.substring(0, 7).toLowerCase() == "http://" || view() {
truePath.substring(0, 8).toLowerCase() == "https://" return true
) {
window.open(truePath, "_blank");
} else {
this.fileUrlPath = this.downUrl + path;
window.open(this.fileUrlPath, "_blank");
} }
}
}
},
mounted() {
this.formatL();
},
computed: {
nativeInputValue() {
return this.value === null || this.value === undefined ? "" : this.value;
}, },
view(){ watch: {
return true value(v) {
} this.name = v;
}, }
watch: {
value(v) {
this.name = v;
} }
}
}; };
</script> </script>
<style lang="less"> <style lang="less">
</style> </style>
\ No newline at end of file
...@@ -9,9 +9,11 @@ ...@@ -9,9 +9,11 @@
<FormItem> <FormItem>
<dictionary code="import.im.page" style="width:160px" @on-change="pageChange" v-model="pageType"></dictionary> <dictionary code="import.im.page" style="width:160px" @on-change="pageChange" v-model="pageType"></dictionary>
</FormItem> </FormItem>
<!--
<FormItem> <FormItem>
<div class="tip mr20">{{listLength}}条数据</div> <div class="tip mr20">{{listLength}}条数据</div>
</FormItem> </FormItem>
-->
<FormItem> <FormItem>
<Button type="primary" @click="openInfoModal" :disabled="btnIm">导入</Button> <Button type="primary" @click="openInfoModal" :disabled="btnIm">导入</Button>
</FormItem> </FormItem>
...@@ -37,12 +39,12 @@ ...@@ -37,12 +39,12 @@
</a> </a>
</FormItem> </FormItem>
<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"> <Radio label="0">
<Icon type="md-list" />列表 <Icon type="ios-list-box-outline" />
</Radio> </Radio>
<Radio label="1"> <Radio label="1">
<Icon type="md-clipboard" />Excel <Icon type="ios-copy" />
</Radio> </Radio>
</RadioGroup> </RadioGroup>
</FormItem> </FormItem>
...@@ -400,6 +402,11 @@ export default { ...@@ -400,6 +402,11 @@ export default {
var tempCos = Object.keys(this.openDatas[val].dataTable[0]); //获取列表标题 var tempCos = Object.keys(this.openDatas[val].dataTable[0]); //获取列表标题
this.columnsImport = []; this.columnsImport = [];
var headersNow = []; var headersNow = [];
headersNow.push({
type: 'index',
width: 60,
align: 'center'
})
tempCos.forEach((el) => { tempCos.forEach((el) => {
let headObj = {}; let headObj = {};
headObj.title = el; headObj.title = el;
...@@ -532,6 +539,11 @@ export default { ...@@ -532,6 +539,11 @@ export default {
var lines = csv.split("\n"); //第一行标题 var lines = csv.split("\n"); //第一行标题
var headers = lines[0].split(","); var headers = lines[0].split(",");
var headersNow = []; var headersNow = [];
headersNow.push({
type: 'index',
width: 60,
align: 'center'
})
headers.forEach((elHead) => { headers.forEach((elHead) => {
let headObj = {}; let headObj = {};
headObj.title = elHead; headObj.title = elHead;
...@@ -539,7 +551,6 @@ export default { ...@@ -539,7 +551,6 @@ export default {
headersNow.push(headObj); headersNow.push(headObj);
}); });
this.columnsImport = headersNow; this.columnsImport = headersNow;
var result = []; var result = [];
for (var i = 1; i < lines.length - 1; i++) { for (var i = 1; i < lines.length - 1; i++) {
var obj = {}; 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