Bläddra i källkod

报表数据处理

wangzhuo 1 år sedan
förälder
incheckning
287ba514fe
1 ändrade filer med 180 tillägg och 33 borttagningar
  1. 180 33
      src/views/iosBasicData/SeafreightExportF/bills/assembly/reports.vue

+ 180 - 33
src/views/iosBasicData/SeafreightExportF/bills/assembly/reports.vue

@@ -1,5 +1,6 @@
 <template>
   <basic-container>
+    <el-checkbox v-model="isPrintTheBoxNumber">打印箱号</el-checkbox>
     <avue-crud :option="option"
                :table-loading="loading"
                :data="data"
@@ -55,7 +56,7 @@
         <el-link type="primary" style="font-size: 12px" icon="el-icon-view" :underline="false" @click="addedData(1, scope)">查看详情&nbsp;&nbsp;</el-link>
         <el-link type="primary" style="font-size: 12px" icon="el-icon-edit" :underline="false" :disabled="disabled" @click="addedData(2, scope)">编 辑&nbsp;&nbsp;</el-link>
         <el-link type="primary" style="font-size: 12px" icon="el-icon-delete" :underline="false" :disabled="disabled" @click="rowDel(scope.row)">删 除</el-link>
-        <el-link type="primary" @click="handleReportPreview(scope.row.url)">预览报表</el-link>
+        <el-link type="primary" :disabled="scope.row.status == 1" @click="handleReportPreview(scope.row.url)">预览报表</el-link>
       </template>
     </avue-crud>
     <reportContainer ref="reportContainer"></reportContainer>
@@ -86,6 +87,7 @@
     data() {
       return {
         userList: [],
+        isPrintTheBoxNumber: false,
         bbDisabled: false,
         form: {},
         formReport: {},
@@ -417,8 +419,101 @@
             if (this.id) {
               billsDetail(this.id).then(res => {
                 var data = res.data.data
-                // data.extraLongTips = '** TO BE CONTINUED ON ATTACHED LIST **'
-                // data.extraLongText = 'extraLongText'
+                data.pageOne = 'Page : 1 of 1'
+                // 处理超长数据
+                if (data.hshipperDetails) {
+                  var consignerIndex2 = data.hshipperDetails.indexOf( '\n' )
+                  for (let i = 0; i < 4; i++) {
+                    consignerIndex2 = data.hshipperDetails.indexOf( '\n', consignerIndex2 + 1 );
+                  }
+                  if (consignerIndex2 != -1) {
+                    var hshipperDetails = data.hshipperDetails.substring(consignerIndex2 + 2, data.hshipperDetails.length)
+                    data.hshipperDetails = data.hshipperDetails.substring(0, consignerIndex2) + ' *'
+                    data.commodityDescr += '\n*' + hshipperDetails
+                  }
+                }
+
+                if (data.hconsigneeDetails) {
+                  var consigneeIndex2 = data.hconsigneeDetails.indexOf( '\n' )
+                  for (let i = 0; i < 3; i++) {
+                    consigneeIndex2 = data.hconsigneeDetails.indexOf( '\n', consigneeIndex2 + 1 );
+                  }
+                  if (consigneeIndex2 != -1) {
+                    var hconsigneeDetails = data.hconsigneeDetails.substring(consigneeIndex2 + 2, data.hconsigneeDetails.length)
+                    data.hconsigneeDetails = data.hconsigneeDetails.substring(0, consigneeIndex2) + ' **'
+                    data.commodityDescr += '\n**' + hconsigneeDetails
+                  }
+                }
+
+                if (data.hnotifyDetails) {
+                  var notifierIndex2 = data.hnotifyDetails.indexOf( '\n' )
+                  for (let i = 0; i < 3; i++) {
+                    notifierIndex2 = data.hnotifyDetails.indexOf( '\n', notifierIndex2 + 1 );
+                  }
+                  if (notifierIndex2 != -1) {
+                    var hnotifyDetails = data.hnotifyDetails.substring(notifierIndex2 + 2, data.hnotifyDetails.length)
+                    data.hnotifyDetails = data.hnotifyDetails.substring(0, notifierIndex2) + ' ***'
+                    data.commodityDescr += '\n***' + hnotifyDetails
+                  }
+                }
+
+                // 处理箱号
+                if (this.isPrintTheBoxNumber) {
+                  data.commodityDescr += '\n.\n.\n'
+                }
+
+                // PLACE & DATE OF ISSUE
+                data.placeAndDateOfIssue = ''
+                if (data.issueAt) {
+                  data.placeAndDateOfIssue += data.issueAt
+                }
+                if (data.issueDate) {
+                  let date = new Date(data.issueDate.replace(/-/g,'/'));
+                  let yyyy = date.getFullYear();
+                  let mmmm = date.toDateString().split(" ")[1]
+                  let dd = date.getDate()
+                  data.placeAndDateOfIssue += ', ' + dd + '-' + mmmm + '-' + yyyy
+                }
+
+                // Total number of containers or packages received by the Carriers
+                if (data.preContainersList) {
+                  let boxMap = new Map();
+                  for (let boxQuantity of data.preContainersList) {
+                    if (boxMap.get(boxQuantity.cntrTypeCode)) {
+                      let v = boxMap.get(boxQuantity.cntrTypeCode)
+                      boxMap.set(boxQuantity.cntrTypeCode, v + boxQuantity.quantity)
+                    } else {
+                      boxMap.set(boxQuantity.cntrTypeCode, boxQuantity.quantity)
+                    }
+                  }
+                  let boxs = ''
+                  boxMap.forEach(function (value, key, map) {
+                    boxs += value + 'x' + key + ', '
+                  })
+                  boxs = boxs.substring(0, boxs.length - 2)
+
+                  data.boxQuantity = boxs + ' CONTAINER(S) ONLY'
+                }
+
+                // Number of original B/Ls
+                if (data.numberOfObl) {
+                  data.numberOfObl += ' (' + data.numberOfOblDigit + ')'
+                }
+
+                if (data.commodityDescr) {
+                  var descriptionIndex2 = data.commodityDescr.indexOf( '\n' )
+                  for (let i = 0; i < 19; i++) {
+                    descriptionIndex2 = data.commodityDescr.indexOf( '\n', descriptionIndex2 + 1 );
+                  }
+                  if (descriptionIndex2 != -1) {
+                    data.pageOne = 'Page : 1 of 2'
+                    data.pageTwo = 'Page : 2 of 2'
+                    var extraLongText = data.commodityDescr.substring(descriptionIndex2 + 2, data.commodityDescr.length)
+                    data.commodityDescr = data.commodityDescr.substring(0, descriptionIndex2)
+                    data.extraLongTips = '** TO BE CONTINUED ON ATTACHED LIST **'
+                    data.extraLongText = extraLongText
+                  }
+                }
                 var dataSet = new Stimulsoft.System.Data.DataSet(
                   'reportData'
                 )
@@ -495,49 +590,101 @@
               // var aaa = data.hshipperDetails.split('\n')
               // console.log(aaa)
 
+              data.pageOne = 'Page : 1 of 1'
               // 处理超长数据
-              var consignerIndex2 = data.hshipperDetails.indexOf( '\n' )
-              for (let i = 0; i < 4; i++) {
-                consignerIndex2 = data.hshipperDetails.indexOf( '\n', consignerIndex2 + 1 );
+              if (data.hshipperDetails) {
+                var consignerIndex2 = data.hshipperDetails.indexOf( '\n' )
+                for (let i = 0; i < 4; i++) {
+                  consignerIndex2 = data.hshipperDetails.indexOf( '\n', consignerIndex2 + 1 );
+                }
+                if (consignerIndex2 != -1) {
+                  var hshipperDetails = data.hshipperDetails.substring(consignerIndex2 + 2, data.hshipperDetails.length)
+                  data.hshipperDetails = data.hshipperDetails.substring(0, consignerIndex2) + ' *'
+                  data.commodityDescr += '\n*' + hshipperDetails
+                }
               }
-              if (consignerIndex2 != -1) {
-                var hshipperDetails = data.hshipperDetails.substring(consignerIndex2, data.hshipperDetails.length)
-                data.hshipperDetails = data.hshipperDetails.substring(0, consignerIndex2) + ' *'
-                data.commodityDescr += '\n*' + hshipperDetails
+
+              if (data.hconsigneeDetails) {
+                var consigneeIndex2 = data.hconsigneeDetails.indexOf( '\n' )
+                for (let i = 0; i < 3; i++) {
+                  consigneeIndex2 = data.hconsigneeDetails.indexOf( '\n', consigneeIndex2 + 1 );
+                }
+                if (consigneeIndex2 != -1) {
+                  var hconsigneeDetails = data.hconsigneeDetails.substring(consigneeIndex2 + 2, data.hconsigneeDetails.length)
+                  data.hconsigneeDetails = data.hconsigneeDetails.substring(0, consigneeIndex2) + ' **'
+                  data.commodityDescr += '\n**' + hconsigneeDetails
+                }
               }
 
-              var consigneeIndex2 = data.hconsigneeDetails.indexOf( '\n' )
-              for (let i = 0; i < 3; i++) {
-                consigneeIndex2 = data.hconsigneeDetails.indexOf( '\n', consigneeIndex2 + 1 );
+              if (data.hnotifyDetails) {
+                var notifierIndex2 = data.hnotifyDetails.indexOf( '\n' )
+                for (let i = 0; i < 3; i++) {
+                  notifierIndex2 = data.hnotifyDetails.indexOf( '\n', notifierIndex2 + 1 );
+                }
+                if (notifierIndex2 != -1) {
+                  var hnotifyDetails = data.hnotifyDetails.substring(notifierIndex2 + 2, data.hnotifyDetails.length)
+                  data.hnotifyDetails = data.hnotifyDetails.substring(0, notifierIndex2) + ' ***'
+                  data.commodityDescr += '\n***' + hnotifyDetails
+                }
               }
-              if (consigneeIndex2 != -1) {
-                var hconsigneeDetails = data.hconsigneeDetails.substring(consignerIndex2, data.hconsigneeDetails.length)
-                data.hconsigneeDetails = data.hconsigneeDetails.substring(0, consigneeIndex2) + ' **'
-                data.commodityDescr += '\n**' + hconsigneeDetails
+
+              // 处理箱号
+              if (this.isPrintTheBoxNumber) {
+                data.commodityDescr += '\n.\n.\n'
               }
 
-              var notifierIndex2 = data.hnotifyDetails.indexOf( '\n' )
-              for (let i = 0; i < 3; i++) {
-                notifierIndex2 = data.hnotifyDetails.indexOf( '\n', notifierIndex2 + 1 );
+              // PLACE & DATE OF ISSUE
+              data.placeAndDateOfIssue = ''
+              if (data.issueAt) {
+                data.placeAndDateOfIssue += data.issueAt
               }
-              if (notifierIndex2 != -1) {
-                var hnotifyDetails = data.hnotifyDetails.substring(consignerIndex2, data.hnotifyDetails.length)
-                data.hnotifyDetails = data.hnotifyDetails.substring(0, notifierIndex2) + ' ***'
-                data.commodityDescr += '\n***' + hnotifyDetails
+              if (data.issueDate) {
+                let date = new Date(data.issueDate.replace(/-/g,'/'));
+                let yyyy = date.getFullYear();
+                let mmmm = date.toDateString().split(" ")[1]
+                let dd = date.getDate()
+                data.placeAndDateOfIssue += ', ' + dd + '-' + mmmm + '-' + yyyy
               }
 
-              var descriptionIndex2 = data.commodityDescr.indexOf( '\n' )
-              for (let i = 0; i < 19; i++) {
-                descriptionIndex2 = data.commodityDescr.indexOf( '\n', descriptionIndex2 + 1 );
-              }
-              if (descriptionIndex2 != -1) {
-                var extraLongText = data.commodityDescr.substring(consignerIndex2, data.commodityDescr.length)
-                data.commodityDescr = data.commodityDescr.substring(0, descriptionIndex2)
-                data.extraLongTips = '** TO BE CONTINUED ON ATTACHED LIST **'
-                data.extraLongText = extraLongText
+              // Total number of containers or packages received by the Carriers
+              if (data.preContainersList) {
+                let boxMap = new Map();
+                for (let boxQuantity of data.preContainersList) {
+                  if (boxMap.get(boxQuantity.cntrTypeCode)) {
+                    let v = boxMap.get(boxQuantity.cntrTypeCode)
+                    boxMap.set(boxQuantity.cntrTypeCode, v + boxQuantity.quantity)
+                  } else {
+                    boxMap.set(boxQuantity.cntrTypeCode, boxQuantity.quantity)
+                  }
+                }
+                let boxs = ''
+                boxMap.forEach(function (value, key, map) {
+                  boxs += value + 'x' + key + ', '
+                })
+                boxs = boxs.substring(0, boxs.length - 2)
+
+                data.boxQuantity = boxs + ' CONTAINER(S) ONLY'
               }
 
+              // Number of original B/Ls
+              if (data.numberOfObl) {
+                data.numberOfObl += ' (' + data.numberOfOblDigit + ')'
+              }
 
+              if (data.commodityDescr) {
+                var descriptionIndex2 = data.commodityDescr.indexOf( '\n' )
+                for (let i = 0; i < 19; i++) {
+                  descriptionIndex2 = data.commodityDescr.indexOf( '\n', descriptionIndex2 + 1 );
+                }
+                if (descriptionIndex2 != -1) {
+                  data.pageOne = 'Page : 1 of 2'
+                  data.pageTwo = 'Page : 2 of 2'
+                  var extraLongText = data.commodityDescr.substring(descriptionIndex2 + 2, data.commodityDescr.length)
+                  data.commodityDescr = data.commodityDescr.substring(0, descriptionIndex2)
+                  data.extraLongTips = '** TO BE CONTINUED ON ATTACHED LIST **'
+                  data.extraLongText = extraLongText
+                }
+              }
 
               // console.log(data.hshipperDetails, 'hshipperDetails2')