Commit 76a32afb authored by 仇晓婷's avatar 仇晓婷

Merge branch 'product' of http://git.mes123.com/zhouyx/mes-ui into product

parents 317317e0 5e178bdc
+ eslint-plugin-node@11.1.0
added 3 packages from 2 contributors, updated 1 package and moved 1 package in 24.979s
<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>
This diff is collapsed.
......@@ -25,11 +25,8 @@
"gantt-elastic": "^1.0.11",
"gantt-elastic-header": "^0.1.11",
"gojs": "^2.1.19",
"iview-loader": "^1.3.0",
"iview-pro": "file:./iview-pro",
"js-cookie": "^2.2.1",
"less": "^3.10.3",
"less-loader": "^5.0.0",
"lodash": "^4.17.15",
"lodash.chunk": "^4.2.0",
"lowdb": "^1.0.0",
......@@ -69,9 +66,11 @@
"@vue/test-utils": "^1.0.0-beta.28",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "^23.0.1",
"eslint": "^7.7.0",
"eslint-plugin-node": "^11.1.0",
"iview-loader": "^1.3.0",
"less": "^2.7.3",
"less-loader": "^4.1.0",
"less": "^3.12.2",
"less-loader": "^5.0.0",
"lint-staged": "^7.2.0",
"script-loader": "^0.7.2",
"svg-sprite-loader": "^3.8.0",
......
......@@ -5,7 +5,7 @@
<TablePaste hide-table :input-props="inputProps" @on-success="handleSuccess" @on-error="handleError" />
</TabPane>
<TabPane label="预览">
<Table border="true" :columns="columnsImport" :data="excelData" :height="tableHeight" ref="tableExcel" class="tableCommon"></Table>
<Table :border="true" :columns="columnsImport" :data="excelData" :height="tableHeight" ref="tableExcel" class="tableCommon"></Table>
</TabPane>
</Tabs>
......@@ -27,6 +27,8 @@ export default {
rows: 10,
placeholder: "请从Excel复制一段表格数据,粘贴在这里",
},
columnsImport: [],
excelData: []
};
},
......@@ -51,14 +53,6 @@ export default {
};
},
methods: {
load(v) {
Api.get({
id: v,
}).then((r) => {
this.entity = r.result;
this.$emit("on-load");
});
},
handleClose() {
this.$emit("on-close");
},
......@@ -77,10 +71,44 @@ export default {
}
}
},
l(key) {
key = "import_center" + "." + key;
return this.$t(key);
//粘贴excel成功
handleSuccess(tableData) {
//初始化数据
this.excelData = [];
this.columnsImport = [];
//处理colum和data
let tabColum = tableData.columns
let tabData = tableData.data
let arrData = []
tabData.forEach(ele => {
let objData = {}
tabColum.forEach(el => {
objData[el.title] = ele[el.key]
})
arrData.push(objData)
})
//处理title和key一致
tabColum.forEach(el => {
el.key = el.title
})
this.columnsImport = tabColum;
this.columnsImport.unshift({
type: 'index',
width: 80,
align: 'right',
title: '序号'
})
this.excelData = arrData;
this.$emit("on-datalength", this.excelData.length)
},
//粘贴excel失败
handleError(tableData, errorIndex) {
//console.log(tableData, errorIndex);
this.$Message.error("表格数据有误");
},
//粘贴excel相关end
},
watch: {
eid(v) {
......
This diff is collapsed.
......@@ -43,7 +43,7 @@
<Form inline>
<FormItem>
<Tabs :animated="false" :value="0" @on-click="sheetClick">
<TabPane :label="item" v-for="(item,index) in sheetNames"></TabPane>
<TabPane :label="item" v-for="(item,index) in sheetNames" :key="index"></TabPane>
</Tabs>
</FormItem>
</Form>
......
+ eslint@7.7.0
added 51 packages from 29 contributors, removed 3 packages, updated 12 packages and moved 7 packages in 48.231s
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