-
*
+
*
35
40
50
@@ -82,7 +82,7 @@
/>
保存
- *
+ *
35
40
50
@@ -798,7 +798,8 @@ export default {
// 订舱模板 - start
getTemplate(name = '', type) {
BookingTemplate({
- SearchValue: name
+ SearchValue: name,
+ Type: this.enmuType(type)
})
.then((res) => {
if (res.code === 200) {
@@ -1051,6 +1052,8 @@ export default {
return 20
case 'notifypart':
return 30
+ case 'notify':
+ return 30
}
},
handleModelCancel () {
@@ -1060,7 +1063,6 @@ export default {
},
changeCode(num, type) {
- // const newStr = this.senderInfo.replace(/\n|\r/g, '')
const newStr = this.details[type].replace(/\n|\r/g, '')
console.log(newStr)
const indexs = []
@@ -1071,24 +1073,45 @@ export default {
count += 1
}
}
- const splitPosition = this.findId(indexs, num)
- console.log(splitPosition)
- let resStr = ``
- splitPosition.map((split, sindex) => {
- const start = sindex === 0 ? 0 : splitPosition[sindex - 1]
- console.log(sindex, start, newStr.slice(start, split))
- if (sindex === splitPosition.length - 1) {
- console.log('last', newStr.slice(start, split), newStr.slice(split))
- resStr += `${newStr.slice(start, split)}
-${newStr.slice(split)}`
- } else {
- resStr += `${newStr.slice(start, split)}
-`
+ if (indexs.length > 0) {
+ const splitPosition = this.findId(indexs, num)
+ let resStr = ``
+ splitPosition.map((split, sindex) => {
+ const start = sindex === 0 ? 0 : splitPosition[sindex - 1]
+ console.log(sindex, start, newStr.slice(start, split))
+ if (sindex === splitPosition.length - 1) {
+ console.log('last', newStr.slice(start, split), newStr.slice(split))
+ resStr += `${newStr.slice(start, split)}
+ ${newStr.slice(split)}`
+ } else {
+ resStr += `${newStr.slice(start, split)}
+ `
+ }
+ })
+ if (resStr) {
+ this.details[type] = resStr
}
- })
- this.details[type] = resStr
+ } else {
+ var remainder = newStr.length % num; // 对字符串的长度取行的余数
+ var n = (newStr.length - remainder) / num; // 截完一共多少行(如果余数大于1,则共有n+1行
+ let resStr = ''
+ for (var i = 0; i < n; i++) {
+ // resStr += str.slice(i*num,(i+1)*num) + '\n';
+ resStr += `${newStr.slice(i*num,(i+1)*num)}
+ `
+ }
+ if (remainder > 0) {
+ // resStr += str.slice(n*num) + '\n'
+ resStr += `${newStr.slice(n*num)}
+ `
+ }
+ if (resStr) {
+ this.details[type] = resStr
+ }
+ }
},
findId(arr, id) {
+ // [40, 41, 82, 83, 94] 35
const newarr = []
let count = 1
arr.map((item, index) => {
@@ -1105,6 +1128,83 @@ ${newStr.slice(split)}`
})
return newarr
},
+
+ spliceMore1 (type) {
+ const arr = this.details[type].split('\n')
+ const str = arr.splice(5, arr.length - 1).toString()
+ console.log(arr, str)
+ this.$emit('spliceMore', str)
+ const index = this.details[type].indexOf(arr[5])
+ this.details[type] = this.details[type].substring(0, index)
+ debugger
+ },
+
+ spliceMore (field) {
+ const maxStarLine = 5
+ // var strShipper = $("textarea[name='" + field + "']").val();
+ const strShipper = this.details[field]
+ const arr = strShipper.split('\n');
+ if (arr.length > maxStarLine) {
+ var strStar = '*'
+ var str1 = ''
+ var str2 = ''
+ let arrTmp = null
+ // 收货人加几个*,要看发货人是否有*
+ if (field === 'consignee') {
+ // var arrTmp = $("textarea[name='SHIPPER']").val().split('\n')
+ arrTmp = this.details['shipper'].split('\n')
+ if (arrTmp.length > 0 && arrTmp[arrTmp.length - 1].endsWith('*')) {
+ strStar += '*'
+ }
+ }
+
+ // 通知人加几个*,要看发货人和收货人是否有*
+ if (field === 'notifyparty') {
+ // var arrTmp = $("textarea[name='SHIPPER']").val().split('\n')
+ arrTmp = this.details['shipper'].split('\n')
+ if (arrTmp.length > 0 && arrTmp[arrTmp.length - 1].endsWith('*')) {
+ strStar += '*'
+ }
+
+ // arrTmp = $("textarea[name='CONSIGNEE']").val().split('\n')
+ arrTmp = this.details['consignee'].split('\n')
+ if (arrTmp.length > 0 && arrTmp[arrTmp.length - 1].endsWith('*')) {
+ strStar += '*'
+ }
+ }
+
+ for (let idx = 0; idx < arr.length; idx++) {
+ if (idx < maxStarLine) {
+ str1 += arr[idx]
+ if (idx !== maxStarLine - 1) {
+ str1 += '\n'
+ } else {
+ str1 += ' ' + strStar
+ }
+ } else {
+ str2 += arr[idx]
+ if (idx !== arr.length - 1) {
+ str2 += '\n'
+ }
+ }
+ }
+
+ // $("textarea[name='" + field + "']").val(str1);
+ this.details[field] = str1
+ this.$emit('spliceMore', strStar + str2)
+ // var areaDesp = $("textarea[name='DESCRIPTION']")
+ // var valSrc = areaDesp.val()
+ // if (valSrc.length > 0) {
+ // valSrc += '\n'
+ // }
+ // areaDesp.val(valSrc + strStar + str2);
+
+ // console.log("str1:")
+ // console.log(str1)
+ // console.log("str2:")
+ // console.log(str2)
+ }
+ }
},
}