作者 朱兆平

增加尺寸信息批量录入及智能识别

@@ -681,7 +681,7 @@ Handling Information @@ -681,7 +681,7 @@ Handling Information
681 </el-row> 681 </el-row>
682 <el-row style="padding-top: 20px"> 682 <el-row style="padding-top: 20px">
683 <el-col :span="7" style="border-right: 1px solid #a5a5a5"> 683 <el-col :span="7" style="border-right: 1px solid #a5a5a5">
684 - <el-input :disabled="form.cvd.cvd_charge_prepaid=='CC'" v-model="form.ppd.ppd_weight_amount" auto-complete="off" placeholder="计费重量" size="mini"></el-input> 684 + <el-input :disabled="form.cvd.cvd_charge_prepaid=='CC'" v-model="form.ppd.ppd_weight_amount" auto-complete="off" placeholder="毛重" size="mini"></el-input>
685 </el-col> 685 </el-col>
686 <el-col :span="10" style="border-right: 1px solid #a5a5a5;text-align: center"> 686 <el-col :span="10" style="border-right: 1px solid #a5a5a5;text-align: center">
687 <span style="font-size: 12px"> 687 <span style="font-size: 12px">
@@ -689,7 +689,7 @@ Handling Information @@ -689,7 +689,7 @@ Handling Information
689 </span> 689 </span>
690 </el-col> 690 </el-col>
691 <el-col :span="7"> 691 <el-col :span="7">
692 - <el-input :disabled="form.cvd.cvd_charge_prepaid=='PP'" v-model="form.ppd.ppd_weight_amount" auto-complete="off" placeholder="计费重量" size="mini"></el-input> 692 + <el-input :disabled="form.cvd.cvd_charge_prepaid=='PP'" v-model="form.ppd.ppd_weight_amount" auto-complete="off" placeholder="毛重" size="mini"></el-input>
693 </el-col> 693 </el-col>
694 </el-row> 694 </el-row>
695 </el-col> 695 </el-col>
@@ -1844,7 +1844,9 @@ Handling Information @@ -1844,7 +1844,9 @@ Handling Information
1844 </el-tab-pane> 1844 </el-tab-pane>
1845 </el-tabs> 1845 </el-tabs>
1846 <!-- 主单获取尺寸信息--> 1846 <!-- 主单获取尺寸信息-->
1847 - <el-dialog title="尺寸信息" :visible.sync="dialogTableVisible"> 1847 + <el-dialog title="尺寸信息" :visible.sync="dialogTableVisible" width="80%">
  1848 + <el-row :gutter="10">
  1849 + <el-col :span="18">
1848 <el-table :data="gridData" :cell-style="{textAlign:'center'}" show-summary 1850 <el-table :data="gridData" :cell-style="{textAlign:'center'}" show-summary
1849 :summary-method="getSummaries" 1851 :summary-method="getSummaries"
1850 style="border-radius: 10px 10px 0px 0px;line-height: 25px" border 1852 style="border-radius: 10px 10px 0px 0px;line-height: 25px" border
@@ -1893,6 +1895,24 @@ Handling Information @@ -1893,6 +1895,24 @@ Handling Information
1893 <el-button type="primary" size="small" @click="dialogTableVisible = false">取 消</el-button> 1895 <el-button type="primary" size="small" @click="dialogTableVisible = false">取 消</el-button>
1894 <el-button type="success" size="small" @click="addVol()">保 存</el-button> 1896 <el-button type="success" size="small" @click="addVol()">保 存</el-button>
1895 </div> 1897 </div>
  1898 + </el-col>
  1899 + <el-col :span="6">
  1900 + <el-tooltip class="item" effect="dark" content="可以将整体的尺寸信息复制进来,一行一个尺寸信息,系统会自动识别" placement="top-start">
  1901 + <el-input
  1902 + rows="6"
  1903 + resize = "vertical"
  1904 + type="textarea"
  1905 + placeholder="快速尺寸信息录入生成"
  1906 + v-model="dimension_textarea"
  1907 + @change="convertAndCalculateVolume"
  1908 + >
  1909 + </el-input>
  1910 + </el-tooltip>
  1911 +
  1912 + </el-col>
  1913 + </el-row>
  1914 + <el-row>&nbsp; </el-row>
  1915 +
1896 </el-dialog> 1916 </el-dialog>
1897 <!-- 列表区域 获取发货人--> 1917 <!-- 列表区域 获取发货人-->
1898 <el-dialog :visible.sync="dialogVisible" width="70%"> 1918 <el-dialog :visible.sync="dialogVisible" width="70%">
@@ -1929,6 +1949,7 @@ Handling Information @@ -1929,6 +1949,7 @@ Handling Information
1929 hidden: ['a1', 'a2', 'a3', 'a4', 'a5','a6'], 1949 hidden: ['a1', 'a2', 'a3', 'a4', 'a5','a6'],
1930 // 主单 1950 // 主单
1931 activeName: 'first', 1951 activeName: 'first',
  1952 + dimension_textarea: '',
1932 form:{ 1953 form:{
1933 acc:[], 1954 acc:[],
1934 agt:{ 1955 agt:{
@@ -2239,11 +2260,11 @@ Handling Information @@ -2239,11 +2260,11 @@ Handling Information
2239 const value = Number(curr) 2260 const value = Number(curr)
2240 if (!isNaN(value)) { 2261 if (!isNaN(value)) {
2241 // 保存了两位小数点 2262 // 保存了两位小数点
2242 - return Math.round((prev + curr) * 1000) / 1000; 2263 + return Math.round((prev + curr) * 100) / 100;
2243 2264
2244 } else { 2265 } else {
2245 // 保存了两位小数点 2266 // 保存了两位小数点
2246 - return Math.round(prev * 1000) / 1000; 2267 + return Math.round(prev * 100) / 100;
2247 } 2268 }
2248 }, 0) 2269 }, 0)
2249 sums[index] += ''; 2270 sums[index] += '';
@@ -2689,6 +2710,76 @@ Handling Information @@ -2689,6 +2710,76 @@ Handling Information
2689 }) 2710 })
2690 // console.log("获取分单的方法执行了") 2711 // console.log("获取分单的方法执行了")
2691 }, 2712 },
  2713 + //批量尺寸信息识别
  2714 + convertAndCalculateVolume() {
  2715 + let _this= this;
  2716 + this.$confirm('是否需要根据录入的尺寸信息生成详细的尺寸计算数据表,此操作会往表里面添加新的尺寸数据', '提示', {
  2717 + confirmButtonText: '确定',
  2718 + cancelButtonText: '取消',
  2719 + type: 'warning'
  2720 + }).then(() => {
  2721 + let text = this.dimension_textarea.trim().replaceAll("*","x");
  2722 + text = text.replaceAll("CM","");
  2723 + text = text.replaceAll("cm","");
  2724 + text = text.replaceAll("X","x");
  2725 + text = text.replaceAll("-","x");
  2726 + //去掉空白字符
  2727 + text = text.replaceAll("/\s/g","");
  2728 + const lines = text.split('\n');
  2729 + let output = '';
  2730 + let totalVolume = 0;
  2731 +
  2732 + for (const line of lines) {
  2733 + //正则校验每行格式
  2734 + const regex = /^([\d\.]+)x([\d\.]+)x([\d\.]+)x([\d\.]+)$/;
  2735 + let l = line.replace(/\s/g, "");
  2736 + if (regex.test(l)) {
  2737 + let dim_form = {
  2738 + long:"",
  2739 + wide:"",
  2740 + height:"",
  2741 + pic:"",
  2742 + vol:"",
  2743 + weight:""
  2744 + };
  2745 +
  2746 + const dimensions = l.trim().split('x');
  2747 + dim_form.long = Number(dimensions[0]);
  2748 + dim_form.wide = Number(dimensions[1]);
  2749 + dim_form.height = Number(dimensions[2]);
  2750 + dim_form.pic = Number(dimensions[3]);
  2751 +
  2752 + dim_form.vol = dim_form.long * dim_form.wide * dim_form.height * dim_form.pic / 1000000;
  2753 +
  2754 + _this.gridData.push(dim_form)
  2755 + totalVolume += dim_form.vol;
  2756 +
  2757 + const formattedDimensions = `${dim_form.long}-${dim_form.wide}-${dim_form.height }/${dim_form.pic}`;
  2758 +
  2759 + output += formattedDimensions + '\n';
  2760 + } else {
  2761 + this.$message({
  2762 + type: 'error',
  2763 + message: '行:'+ line +'尺寸格式错误! 录入信息支持 数字和Xx*- '
  2764 + });
  2765 + return ;
  2766 + }
  2767 + }
  2768 + if (totalVolume>0){
  2769 + totalVolume = Math.floor(totalVolume * 100) / 100;
  2770 + }
  2771 +
  2772 + return {
  2773 + converted: output.trim(),
  2774 + totalVolume: totalVolume
  2775 + };
  2776 + }).catch(() => {
  2777 + this.$message({
  2778 + type: 'info',
  2779 + message: '已取消'
  2780 + });
  2781 + });
  2782 + },
2692 cancleBtn(){ 2783 cancleBtn(){
2693 Object.assign(this.$data, this.$options.data()); 2784 Object.assign(this.$data, this.$options.data());
2694 } 2785 }