You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
2.3 KiB
94 lines
2.3 KiB
2 years ago
|
<template>
|
||
|
<el-dialog v-loading="loading" @close="hiddenView">
|
||
|
<flexbox class="content">
|
||
|
<div class="book">
|
||
|
<el-input type="text" v-model="paster" @paste.native="pasteMe" />
|
||
|
<el-table :data="tableData">
|
||
|
<el-table-column
|
||
|
prop="name"
|
||
|
label="说明:只支持从Excel上粘贴复制,不支持手输!"
|
||
|
width="120"
|
||
|
>
|
||
|
</el-table-column>
|
||
|
</el-table>
|
||
|
</div>
|
||
|
</flexbox>
|
||
|
<div slot="footer" class="dialog-footer">
|
||
|
<el-button type="primary" @click="submiteBillNo()">确定录入</el-button>
|
||
|
</div>
|
||
|
</el-dialog>
|
||
|
</template>
|
||
|
|
||
|
|
||
|
|
||
|
<script>
|
||
|
export default {
|
||
|
props: {
|
||
|
typeName: {
|
||
|
type: String,
|
||
|
default: "",
|
||
|
},
|
||
|
},
|
||
|
data() {
|
||
|
return {
|
||
|
loading: false,
|
||
|
paster: "",
|
||
|
pasterValue: "",
|
||
|
tableData: [
|
||
|
{
|
||
|
name: "单据号",
|
||
|
},
|
||
|
],
|
||
|
};
|
||
|
},
|
||
|
methods: {
|
||
|
submiteBillNo() {
|
||
|
var getbillNo = this.pasterValue.substring(
|
||
|
0,
|
||
|
this.pasterValue.length - 1
|
||
|
);
|
||
|
this.$emit("savebillNo", { biilNo: getbillNo, billName: this.typeName });
|
||
|
this.hiddenView();
|
||
|
},
|
||
|
hiddenView() {
|
||
|
this.$emit("close");
|
||
|
},
|
||
|
pasteMe(e) {
|
||
|
let source = e.clipboardData.getData("Text");
|
||
|
// 首先对源头进行解析
|
||
|
let rows = source.split("\r\n"); // 拆成很多行
|
||
|
this.pasterValue = "";
|
||
|
for (let i = 0; i < rows.length; i++) {
|
||
|
if (rows[i] != "") {
|
||
|
// 如果某一行不是空,再按列拆分
|
||
|
let columns = rows[i].split("\t"); // 已经按列划分
|
||
|
// console.log(columns);
|
||
|
let dataone = {}; // 声明一行数组
|
||
|
for (let j = 0; j < columns.length; j++) {
|
||
|
// 读取tableData里的第j对应的key值
|
||
|
let keys = Object.keys(this.tableData[j]); // key的名
|
||
|
dataone[keys[j]] = columns[j];
|
||
|
this.pasterValue += columns[j] + ",";
|
||
|
}
|
||
|
this.tableData.push(dataone);
|
||
|
console.log(this.tableData);
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
},
|
||
|
};
|
||
|
</script>
|
||
|
<style lang="scss" scoped>
|
||
|
.book {
|
||
|
width: 50%;
|
||
|
height: 400px;
|
||
|
border: 1px solid red;
|
||
|
margin: 0 auto;
|
||
|
margin-top: 50px;
|
||
|
overflow-y: scroll;
|
||
|
}
|
||
|
.el-input__inner {
|
||
|
height: 100px !important;
|
||
|
}
|
||
|
</style>
|