|
@@ -10,6 +10,18 @@
|
|
|
<i class="el-icon-plus"></i>新增
|
|
|
</el-button>
|
|
|
<el-button type="primary" @click="exportData()"><i class="el-icon-download"></i>导出(Excel)</el-button>
|
|
|
+<!-- <el-upload
|
|
|
+ class="upload-excel"
|
|
|
+ action=""
|
|
|
+ :on-change="importExcel"
|
|
|
+ :show-file-list="false"
|
|
|
+ accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
|
|
|
+ :auto-upload="false"
|
|
|
+ >
|
|
|
+ <el-button type="primary">
|
|
|
+ 导入单价表
|
|
|
+ </el-button>
|
|
|
+ </el-upload>-->
|
|
|
</div>
|
|
|
|
|
|
<el-tabs v-model="activeName">
|
|
@@ -23,7 +35,7 @@
|
|
|
<dilTable ref="excelDom" v-bind.sync="option2" :loading="loading" :isKuang="isKuang" @func="func">
|
|
|
</dilTable>
|
|
|
</el-tab-pane>
|
|
|
-
|
|
|
+
|
|
|
</el-tabs>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -66,8 +78,148 @@ export default {
|
|
|
btnclick() {
|
|
|
this.$router.push("/addTransportPrice");
|
|
|
},
|
|
|
+ /*importExcel(file){
|
|
|
+ let that = this;
|
|
|
+ if (!file) {
|
|
|
+ that.$message({
|
|
|
+ message: "文件错误!",
|
|
|
+ type: "warning"
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let excelData =[]
|
|
|
+ var reader=new FileReader();
|
|
|
+ var data=null;
|
|
|
+ var workbook = null;
|
|
|
+ //设置读取操作
|
|
|
+ reader.onload = function (e){
|
|
|
+ console.log(e);
|
|
|
+ data = e.target.result;
|
|
|
+ workbook=XLSX.read(data,{type:'binary'});
|
|
|
+ console.log(workbook)
|
|
|
+ //只取第一个表的数据
|
|
|
+ let rows= XLSX.utils.sheet_to_json(
|
|
|
+ workbook.Sheets[workbook.SheetNames[0]]
|
|
|
+ );
|
|
|
+ console.log(rows)
|
|
|
+ let index=1;
|
|
|
+ // for (index=1;index<rows.length;index++){
|
|
|
+ // if (
|
|
|
+ // typeof workbook.Sheets[workbook.SheetNames[0]]["A"+index] !=
|
|
|
+ // "undefined"
|
|
|
+ // ){
|
|
|
+ // index++;
|
|
|
+ // break
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // console.log("表头行数:" + index);
|
|
|
+ // if(index>=rows.length){
|
|
|
+ // that.$message({
|
|
|
+ // message: "文件错误!",
|
|
|
+ // type: "warning",
|
|
|
+ // });
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ if (
|
|
|
+ typeof workbook.Sheets[workbook.SheetNames[0]]["A" + index] == 'undefined' ||
|
|
|
+ typeof workbook.Sheets[workbook.SheetNames[0]]["B" + index] == 'undefined' ||
|
|
|
+ typeof workbook.Sheets[workbook.SheetNames[0]]["C" + index] == 'undefined' ||
|
|
|
+ typeof workbook.Sheets[workbook.SheetNames[0]]["D" + index] == 'undefined' ||
|
|
|
+ typeof workbook.Sheets[workbook.SheetNames[0]]["E" + index] == 'undefined' ||
|
|
|
+ typeof workbook.Sheets[workbook.SheetNames[0]]["F" + index] == 'undefined' ||
|
|
|
+ typeof workbook.Sheets[workbook.SheetNames[0]]["G" + index] == 'undefined' ||
|
|
|
+ typeof workbook.Sheets[workbook.SheetNames[0]]["H" + index] == 'undefined' ||
|
|
|
+ workbook.Sheets[workbook.SheetNames[0]]["A" + index].v != "序号" ||
|
|
|
+ workbook.Sheets[workbook.SheetNames[0]]["B" + index].v != "省份" ||
|
|
|
+ workbook.Sheets[workbook.SheetNames[0]]["C" + index].v != "市/区" ||
|
|
|
+ workbook.Sheets[workbook.SheetNames[0]]["D" + index].v != "县/镇" ||
|
|
|
+ workbook.Sheets[workbook.SheetNames[0]]["E" + index].v != "卸货地点" ||
|
|
|
+ workbook.Sheets[workbook.SheetNames[0]]["F" + index].v != "参考运距(公里)" ||
|
|
|
+ workbook.Sheets[workbook.SheetNames[0]]["G" + index].v != "运价(元/吨)" ||
|
|
|
+ workbook.Sheets[workbook.SheetNames[0]]["H" + index].v != "吨公里(元/吨.km)"
|
|
|
+ ){
|
|
|
+ if (
|
|
|
+ typeof workbook.Sheets[workbook.SheetNames[0]]["A" + index] == 'undefined' ||
|
|
|
+ workbook.Sheets[workbook.SheetNames[0]]["A" + index].v != "序号"
|
|
|
+ ) {
|
|
|
+ that.$message({
|
|
|
+ message: "表格格式错误:序号错误",
|
|
|
+ type: "warning"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ typeof workbook.Sheets[workbook.SheetNames[0]]["B" + index] == 'undefined' ||
|
|
|
+ workbook.Sheets[workbook.SheetNames[0]]["B" + index].v != "省份"
|
|
|
+ ) {
|
|
|
+ that.$message({
|
|
|
+ message: "表格格式错误:省份错误",
|
|
|
+ type: "warning"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ typeof workbook.Sheets[workbook.SheetNames[0]]["C" + index] == 'undefined' ||
|
|
|
+ workbook.Sheets[workbook.SheetNames[0]]["C" + index].v != "市/区"
|
|
|
+ ) {
|
|
|
+ that.$message({
|
|
|
+ message: "表格格式错误:市/区错误",
|
|
|
+ type: "warning"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ typeof workbook.Sheets[workbook.SheetNames[0]]["D" + index] == 'undefined' ||
|
|
|
+ workbook.Sheets[workbook.SheetNames[0]]["D" + index].v != "县/镇"
|
|
|
+ ) {
|
|
|
+ that.$message({
|
|
|
+ message: "表格格式错误:县/镇错误",
|
|
|
+ type: "warning"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ typeof workbook.Sheets[workbook.SheetNames[0]]["E" + index] == 'undefined' ||
|
|
|
+ workbook.Sheets[workbook.SheetNames[0]]["E" + index].v != "卸货地点"
|
|
|
+ ) {
|
|
|
+ that.$message({
|
|
|
+ message: "表格格式错误:卸货地点错误",
|
|
|
+ type: "warning"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ typeof workbook.Sheets[workbook.SheetNames[0]]["F" + index] == 'undefined' ||
|
|
|
+ workbook.Sheets[workbook.SheetNames[0]]["F" + index].v != "参考运距(公里)"
|
|
|
+ ) {
|
|
|
+ that.$message({
|
|
|
+ message: "表格格式错误:参考运距(公里)错误",
|
|
|
+ type: "warning"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ typeof workbook.Sheets[workbook.SheetNames[0]]["G" + index] == 'undefined' ||
|
|
|
+ workbook.Sheets[workbook.SheetNames[0]]["G" + index].v != "运价(元/吨)"
|
|
|
+ ) {
|
|
|
+ that.$message({
|
|
|
+ message: "表格格式错误:运价(元/吨)错误",
|
|
|
+ type: "warning"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ typeof workbook.Sheets[workbook.SheetNames[0]]["G" + index] == 'undefined' ||
|
|
|
+ workbook.Sheets[workbook.SheetNames[0]]["H" + index].v != "吨公里(元/吨.km)"
|
|
|
+ ) {
|
|
|
+ that.$message({
|
|
|
+ message: "表格格式错误:吨公里(元/吨.km)错误",
|
|
|
+ type: "warning"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //读取表格
|
|
|
+ for (let i = index+1; i <= rows.length+1 ; i++){
|
|
|
+ console.log(workbook.Sheets[workbook.SheetNames[0]]["B" + i].v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ reader.readAsBinaryString(file.raw);
|
|
|
+ }*/
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
};
|
|
|
</script>
|
|
|
<style lang='scss' scoped>
|
|
@@ -80,4 +232,4 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|