Browse Source

提交代码

zengyf 2 years ago
parent
commit
10ee4a59dd
2 changed files with 78 additions and 97 deletions
  1. 1 1
      config/index.js
  2. 77 96
      src/views/appoint/components/saleContract/transportPrice.vue

+ 1 - 1
config/index.js

@@ -73,7 +73,7 @@ let proxyTable = {
   // 所有数据的请求域名地址
   '/api/v1': {
     target: 'http://172.16.33.166:80',
-    // target: 'http://localhost:8080',
+    //target: 'http://localhost:8080',
     // target: 'http://192.168.1.104:8080',
     ws: true,
     pathRewrite: {

+ 77 - 96
src/views/appoint/components/saleContract/transportPrice.vue

@@ -10,7 +10,29 @@
         <i class="el-icon-plus"></i>新增
       </el-button>
        <el-button type="primary" @click="exportAllExcel()"><i class="el-icon-download"></i>导出(Excel)</el-button>
-      <el-upload 
+      <el-button type="primary" @click="importOperation()">
+        导入
+      </el-button>
+      <el-dialog
+        :visible.sync="dialogVisible"
+      >
+      <div class="dialog">
+        <div style="width:250px">
+          <span>油价</span>
+          <el-input v-model="importPriceValue" style="width:150px"></el-input>
+        </div>
+        <div style="width:250px">
+          <span>执行日期</span>
+          <el-date-picker
+          v-model="importPriceDate"
+          type="date"
+          value-format="yyyy-MM-dd HH:mm:ss"
+          style="width:150px"
+          >
+          </el-date-picker>
+        </div>
+        <div style="width:200px">
+          <el-upload 
           style="margin-left:10px"
           action=""
           :on-change="importExcel"
@@ -20,6 +42,9 @@
           <el-button  type="primary">
             <i class="el-icon-upload"></i>导入(Excel)</el-button>
       </el-upload>
+        </div>
+      </div>
+      </el-dialog>
       </div>
     
 
@@ -170,10 +195,16 @@ export default {
         requestUrl:
           "/api/v1/ams/getAmsContractTransportPrice1?apiId=109&deleted=1",
       },
-      tableTitle:'汽运单价'
+      tableTitle:'汽运单价',
+      importPriceValue:null,
+      importPriceDate:null,
+      dialogVisible:false
     };
   },
   methods: {
+    importOperation(){
+      this.dialogVisible=true
+    },
     exportAllExcel() {
      if (this.activeName == 'first') {
        this.tableTitle = '正在启用的运输单价'
@@ -473,6 +504,14 @@ export default {
     },
     importExcel(file){
       let that = this;
+      console.log("进入了导入")
+        if(that.importPriceValue==null){
+          that.$message.warning("油价没有值")
+          return
+        }else if(that.importPriceDate==null){
+          that.$message.warning("执行时间没有填")
+          return
+        }
       if (!file) {
         that.$message({
           message: "文件错误!",
@@ -490,7 +529,7 @@ export default {
         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]]
         );
@@ -530,97 +569,6 @@ export default {
         }
         console.log("最新单价列数:" + priceCol);
         console.log("最新单价吨公里:" + tonnageCol);
-        // 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+2; i <= rows.length+1 ; i++){
           let temp={
@@ -632,6 +580,7 @@ export default {
             priceValue:null,
             haulDistance:null,
             priceTonKilometer:null,
+            carrierName:null
           }
           //序号,无序号视为无效数据。
           if(!workbook.Sheets[workbook.SheetNames[0]]["A" + i]){
@@ -660,6 +609,10 @@ export default {
           try{
             temp.haulDistance=workbook.Sheets[workbook.SheetNames[0]]["F" + i].v;
           }catch(error){}
+          //承运商
+          try{
+            temp.carrierName=workbook.Sheets[workbook.SheetNames[0]]["O" + i].v;
+          }catch(error){}
           //单价
           try{
             temp.priceValue=workbook.Sheets[workbook.SheetNames[0]][priceCol + i].v;
@@ -673,11 +626,35 @@ export default {
         }
         //最终数据表格:
         console.log("excelData",excelData);
+        that.importData(excelData)
       }
       reader.readAsBinaryString(file.raw);
-    }
+    },
+    async importData(excelData){
+      const loading = this.$loading({
+        lock: true,
+        text: '正在导入数据',
+        spinner: 'el-icon-loading',
+        background: 'rgba(0, 0, 0, 0.7)'
+      })
+      await this.axios.post("/api/v1/ams/importDataForAmsContractTransportPrice?importPriceValue="+this.importPriceValue
+         +"&importPriceDate="+this.importPriceDate,excelData).then(res=>{
+           console.log(res)
+           if(res.data.code==200){
+             this.$message({
+             message: "导入成功",
+             type: "success"
+           });
+          }
+        })
+        console.log("导入成功")
+        this.dialogVisible=false
+        this.importPriceValue=null
+        this.importPriceDate=null
+        loading.close()
+        this.onclick()
+  }
   },
-
 };
 </script>
 <style lang='scss' scoped>
@@ -701,4 +678,8 @@ export default {
     margin-bottom: 20px;
   }
 }
+.dialog{
+  display: flex;
+  flex-direction: row;
+}
 </style>