|
@@ -1,19 +1,19 @@
|
|
|
<template>
|
|
|
<!-- 添加车皮装车实绩 -->
|
|
|
<div class="addWagonLoad">
|
|
|
- <page-title>新增</page-title>
|
|
|
+ <page-title>返回</page-title>
|
|
|
<div class="cp">
|
|
|
<span >车皮号:</span>
|
|
|
<el-upload style="margin: 8px;"
|
|
|
class="upload-excel"
|
|
|
action=""
|
|
|
- :on-change="importfile"
|
|
|
+ :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>
|
|
|
- <span >当前车皮号数量:{{list.length}}</span>
|
|
|
+ <span >当前导入数量:{{tableData.length}}</span>
|
|
|
<!-- <el-input
|
|
|
placeholder="请输入内容"
|
|
|
v-model="input"
|
|
@@ -22,15 +22,83 @@
|
|
|
>
|
|
|
</el-input> -->
|
|
|
</div>
|
|
|
- <div class="cpList">
|
|
|
+ <!-- <div class="cpList">
|
|
|
<div class="list">
|
|
|
<div class="cpList1" v-for="(item, i) in list" :key="i">
|
|
|
{{ item }}
|
|
|
<i class="el-icon-close itu" @click="onclick(i)"></i>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ </div> -->
|
|
|
+ <div class="table item">
|
|
|
+ <el-table
|
|
|
+ stripe
|
|
|
+ :data="tableData"
|
|
|
+ style="width: 100%">
|
|
|
+ <el-table-column
|
|
|
+ type="index"
|
|
|
+ width="50"
|
|
|
+ prop="number"
|
|
|
+ label="序号"
|
|
|
+ align="center"
|
|
|
+ fixed="left"
|
|
|
+ :resizable="false">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ prop="materialName"
|
|
|
+ label="物资"
|
|
|
+ width="180px">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ prop="supplierName"
|
|
|
+ label="发货单位"
|
|
|
+ width="180px">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ prop="wagonNo"
|
|
|
+ label="车号"
|
|
|
+ width="180px">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ prop="sendDate"
|
|
|
+ label="发货日期"
|
|
|
+ width="180px">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ prop="sendStation"
|
|
|
+ label="火车发站"
|
|
|
+ width="180px">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ width="180px"
|
|
|
+ prop="arrivalStation"
|
|
|
+ label="火车到站">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ width="180px"
|
|
|
+ prop="weight"
|
|
|
+ label="标重">
|
|
|
+ </el-table-column>
|
|
|
+ <!-- <el-table-column
|
|
|
+ align="center"
|
|
|
+ width="100px"
|
|
|
+ fixed="right"
|
|
|
+ label="操作">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
|
|
|
+ <el-button type="text" size="small">编辑</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column> -->
|
|
|
+ </el-table>
|
|
|
</div>
|
|
|
- <div class="matching item">
|
|
|
+ <!-- <div class="matching item">
|
|
|
<span class="text">是否知道采购订单号:</span>
|
|
|
<el-switch
|
|
|
v-model="matching"
|
|
@@ -54,9 +122,9 @@
|
|
|
<span class="text">卸货点:</span>
|
|
|
<el-input v-model="unloadPointName" disabled> </el-input>
|
|
|
<el-button type="primary" @click="ondrawer(3)">浏览</el-button>
|
|
|
- </div>
|
|
|
+ </div> -->
|
|
|
<div class="fromOther">
|
|
|
- <el-form :inline="true" class="demo-form-inline" label-width="80px" style="margin-left:500px;">
|
|
|
+ <!-- <el-form :inline="true" class="demo-form-inline" label-width="80px" style="margin-left:500px;">
|
|
|
<el-form-item label="发站:">
|
|
|
<el-autocomplete
|
|
|
class="inline-input"
|
|
@@ -71,8 +139,8 @@
|
|
|
</template>
|
|
|
</el-autocomplete>
|
|
|
</el-form-item>
|
|
|
- </el-form>
|
|
|
- <el-form :inline="true" class="demo-form-inline" label-width="80px" style="margin-left:500px;">
|
|
|
+ </el-form> -->
|
|
|
+ <el-form :inline="true" class="demo-form-inline" label-width="80px" style="margin-left:500px;margin-top:30px">
|
|
|
<el-form-item label="到站:">
|
|
|
<el-autocomplete
|
|
|
class="inline-input"
|
|
@@ -185,7 +253,14 @@ export default {
|
|
|
supplierId: null,
|
|
|
//物资id
|
|
|
materialId: null,
|
|
|
+ //表格数据
|
|
|
+ tableData:[],
|
|
|
unloadPointName:null,
|
|
|
+ //物资集合和供应商映射,相当于本地缓存,减少请求次数
|
|
|
+ materialMap:new Map(),
|
|
|
+ supplierMap:new Map(),
|
|
|
+ materials:[],
|
|
|
+ suppliers:[],
|
|
|
unloadPointId:null,
|
|
|
//是否需要打开模态窗口
|
|
|
drawer: false,
|
|
@@ -225,6 +300,9 @@ export default {
|
|
|
arrivalStationId: 1,
|
|
|
};
|
|
|
},
|
|
|
+ mounted(){
|
|
|
+ this.form1.resultLoadingDate=new Date();
|
|
|
+ },
|
|
|
methods: {
|
|
|
currentRadioChange1(selection) {
|
|
|
this.input = null;
|
|
@@ -423,38 +501,16 @@ export default {
|
|
|
},
|
|
|
// 确定
|
|
|
makeSure() {
|
|
|
- let state = 0;
|
|
|
- if (
|
|
|
- this.list.length > 0 &&
|
|
|
- this.sendStationId &&
|
|
|
- this.toTheStationId &&
|
|
|
- this.form1.resultLoadingDate
|
|
|
- ) {
|
|
|
- state = 1;
|
|
|
- } else {
|
|
|
- if (this.list.length == 0) {
|
|
|
+ let that=this;
|
|
|
+ if (this.tableData.length <= 0 || !this.toTheStationId || this.form1.resultLoadingDate){
|
|
|
+ if (this.tableData.length <= 0) {
|
|
|
this.$message({
|
|
|
type: "warning",
|
|
|
- message: "请输入车皮号!",
|
|
|
+ message: "请导入数据!",
|
|
|
});
|
|
|
} else {
|
|
|
- if (this.sendStationId) {
|
|
|
if (this.toTheStationId) {
|
|
|
if (this.form1.resultLoadingDate) {
|
|
|
- if (this.supplierId) {
|
|
|
- if (this.materialId) {
|
|
|
- } else {
|
|
|
- this.$message({
|
|
|
- type: "warning",
|
|
|
- message: "请选择物资",
|
|
|
- });
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.$message({
|
|
|
- type: "warning",
|
|
|
- message: "请选择发货单位",
|
|
|
- });
|
|
|
- }
|
|
|
} else {
|
|
|
this.$message({
|
|
|
type: "warning",
|
|
@@ -467,60 +523,42 @@ export default {
|
|
|
message: "请选择到站!",
|
|
|
});
|
|
|
}
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //绑定通用字段
|
|
|
+ this.tableData.forEach((row)=>{
|
|
|
+ row.resultType=3;//装车类型为国产矿
|
|
|
+ row.arrivalStationId=that.form1.arrivalStationId;//到站id,默认老区轨道衡
|
|
|
+ row.resultLoadingDate=sjTime(that.form1.resultLoadingDate);//装车日期
|
|
|
+ row.resultRemarks=that.form1.resultRemarks;//备注
|
|
|
+ })
|
|
|
+ console.log(that.tableData);
|
|
|
+ //请求添加
|
|
|
+ this.axios
|
|
|
+ .post("/api/v1/tms/addDomesticLoadResult", that.tableData)
|
|
|
+ .then((res) => {
|
|
|
+ console.log(res);
|
|
|
+ if (res.data.code == "200") {
|
|
|
this.$message({
|
|
|
- type: "warning",
|
|
|
- message: "请选择发站!",
|
|
|
+ type: "success",
|
|
|
+ message: "新增成功",
|
|
|
});
|
|
|
+ this.$router.push("/wagonLoadMine");
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- if (state == 1) {
|
|
|
- let map = {
|
|
|
- wagonNoList: this.list,
|
|
|
- sendStationId: this.sendStationId,
|
|
|
- arrivalStationId: this.toTheStationId,
|
|
|
- resultLoadingDate: sjTime(this.form1.resultLoadingDate),
|
|
|
- resultRemarks: this.form1.resultRemarks,
|
|
|
- resultType: 3,
|
|
|
- sendUnitId: this.supplierId,
|
|
|
- materialId: this.materialId,
|
|
|
- };
|
|
|
- if (this.matching) {
|
|
|
- map = {
|
|
|
- wagonNoList: this.list,
|
|
|
- sendStationId: this.sendStationId,
|
|
|
- arrivalStationId: this.toTheStationId,
|
|
|
- resultLoadingDate: sjTime(this.form1.resultLoadingDate),
|
|
|
- resultRemarks: this.form1.resultRemarks,
|
|
|
- resultType: 3,
|
|
|
- sendUnitId: this.supplierId,
|
|
|
- materialId: this.materialId,
|
|
|
- purchaseOrderRailPlanId: this.purchaseOrderId,
|
|
|
- };
|
|
|
- }
|
|
|
- this.axios
|
|
|
- .post("/api/v1/tms/addDomesticLoadResult", map)
|
|
|
- .then((res) => {
|
|
|
- console.log(res);
|
|
|
- if (res.data.code == "200") {
|
|
|
- this.$message({
|
|
|
- type: "success",
|
|
|
- message: "新增成功",
|
|
|
- });
|
|
|
- this.$router.push("/wagonLoadMine");
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ });
|
|
|
+
|
|
|
},
|
|
|
cancel() {
|
|
|
this.$router.push("/wagonLoadMine");
|
|
|
},
|
|
|
- // excel表上传
|
|
|
- importfile(file) {//导入文件
|
|
|
+ // 导入excel
|
|
|
+ importExcel(file) {
|
|
|
let that=this;
|
|
|
if (!file) {
|
|
|
- alert('文件错误,请重新选择');
|
|
|
+ that.$message({
|
|
|
+ message: "文件错误!",
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
return
|
|
|
}
|
|
|
var reader = new FileReader();
|
|
@@ -533,60 +571,45 @@ export default {
|
|
|
workbook= XLSX.read(data, {
|
|
|
type: 'binary'
|
|
|
});
|
|
|
- console.log(workbook.SheetNames.length);
|
|
|
+ console.log(workbook);
|
|
|
//读取表格
|
|
|
let rows= XLSX.utils.sheet_to_json(workbook.Sheets[workbook.SheetNames[0]]);//只取第一页
|
|
|
console.log(rows);
|
|
|
- //绑定品名和发货单位
|
|
|
+ //清空
|
|
|
if(rows.length>0){
|
|
|
- that.list=[];
|
|
|
- that.materialName=rows[0]['品 名'];
|
|
|
- that.supplierName=rows[0]['发货单位'];
|
|
|
- that.setIdForName();
|
|
|
+ that.tableData=[];
|
|
|
+ if((typeof rows[0]['车号'])=='undefined'){
|
|
|
+ that.$message({
|
|
|
+ message: "导入Excel格式错误!",
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
- //绑定车号
|
|
|
+ //绑定数据
|
|
|
rows.forEach((row,index) => {
|
|
|
let carNumber=row['车号'];
|
|
|
- if((typeof carNumber)!="undefined" && carNumber.length > 6)
|
|
|
- that.list.push(carNumber);
|
|
|
- else
|
|
|
- console.log(carNumber+"不符合格式");
|
|
|
- });
|
|
|
- };
|
|
|
- reader.readAsBinaryString(file.raw); //以二进制方式读取
|
|
|
- },
|
|
|
- //导入的时候为品名和发货单位绑定id
|
|
|
- setIdForName(){
|
|
|
- let that=this;
|
|
|
- //绑定品名id
|
|
|
- that.axios.post("/api/v1/uc/queryAPOMaterialByLike?apiId=244&startNum=050&index=" +
|
|
|
- that.materialName).then((res)=>{
|
|
|
- console.log(res.data.data);
|
|
|
- if(res.data.code == "200" && res.data.data &&res.data.data.list.length > 0 ) {
|
|
|
- that.materialId=res.data.data.list[0].materialId;
|
|
|
- that.materialName=res.data.data.list[0].materialName;
|
|
|
- }else{
|
|
|
- that.materialId=null;
|
|
|
- that.materialName=null;
|
|
|
- this.$message.error("绑定品名失败,请手动选择!");
|
|
|
+ if((typeof carNumber)!="undefined" && carNumber.length > 6){
|
|
|
+ //表格数据
|
|
|
+ let temp={
|
|
|
+ number:row['序号'],
|
|
|
+ materialName:row['品 名'],
|
|
|
+ supplierName:row['发货单位'],
|
|
|
+ sendDate:row['发货日期'],
|
|
|
+ sendStation:row['发站'],
|
|
|
+ arrivalStation:row['到站'],
|
|
|
+ wagonNo:row['车号'],
|
|
|
+ weight:row['标重']
|
|
|
+ }
|
|
|
+ that.tableData.push(temp);
|
|
|
}
|
|
|
-
|
|
|
- });
|
|
|
- //绑定发货单位id
|
|
|
- that.axios.post("/api/v1/uc/getSupplierMesByMaterialId?apiId=247&index=" +
|
|
|
- that.supplierName).then((res)=>{
|
|
|
- console.log(res.data.data);
|
|
|
- if(res.data.code == "200" && res.data.data &&res.data.data.list.length > 0 ) {
|
|
|
- that.supplierId=res.data.data.list[0].supplierId;
|
|
|
- that.supplierName=res.data.data.list[0].supplierName;
|
|
|
- }else{
|
|
|
- that.supplierId=null;
|
|
|
- that.supplierName=null;
|
|
|
- this.$message.error("绑定发货单位失败,请手动选择!");
|
|
|
+ else{
|
|
|
+ console.log("车号"+carNumber+"不是7位数!");
|
|
|
}
|
|
|
- });
|
|
|
+ });
|
|
|
+ };
|
|
|
+ reader.readAsBinaryString(file.raw); //以二进制方式读取
|
|
|
}
|
|
|
-
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
@@ -752,11 +775,13 @@ export default {
|
|
|
.button_box {
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
|
- padding-top: 30px;
|
|
|
+ margin-top: 30px;
|
|
|
+ margin-bottom: 30px;
|
|
|
}
|
|
|
.fromOther .el-input__inner{
|
|
|
width: 250px;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
</style>
|
|
|
|