1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
import Api from '~/service/Api';
import commonFunctions from '~/mixin/commonFunctions.js';
import moment from 'moment';
export default {
mixins: [commonFunctions],
methods: {
// 点击获取按钮拉取当前key字段下的表单数据
queryFormData (key) {},
// 业务信息=》基本信息=》保函编号-----获取保函编号
queryOwnref () {
let params = this.model.nidgrp.rec;
params.ownref = this.model.nitp.tempOwnref;
if (!this.model.nidgrp.apl.pts.ptainr || !this.model.nidgrp.rec.hndtyp || !this.model.nidgrp.rec.gartyp) {
return
}
let ptainr = this.model.nidgrp.apl.pts.ptainr;
const loading = this.loading();
let trnName = this.root.trnName.toUpperCase()
Api.post(`/business/ref/nid?ptaInr=${ptainr}&trnName=${trnName}`, params).then(res => {
loading.close();
if (res.respCode == SUCCESS) {
this.model.nidgrp.rec.ownref = res.data;
this.model.nitp.tempOwnref = res.data;
} else {
this.$message.error(res.respMsg);
}
}).catch(() => {
loading.close();
});
},
setOtherData(){
if(moment(this.model.nidgrp.rec.opndat).diff(moment(new Date()), 'days')<0){
this.model.nidgrp.rec.opndat = moment(new Date()).format('YYYY-MM-DD');
this.$confirm('保函开立日期不得早于开立当天日期', '提示', {
type: 'warning',
});
}
if(moment(this.model.nidgrp.rec.inudat).diff(moment(this.model.nidgrp.rec.opndat), 'days')<0){
this.$confirm('保函生效日期不得早于保函开立日期', '提示', {
type: 'warning',
});
this.model.nidgrp.rec.inudat = moment(this.model.nidgrp.rec.opndat).add(4, 'day').format('YYYY-MM-DD')
}
},
changeBencnt(){
let list = this.model.ptyList;
if(this.model.nidgrp.ben.pts.extkey){
this.model.nidgrp.bencnt = 1 + list.length;
}else{
this.model.nidgrp.bencnt = list.length;
}
// 已选海关移至其他海关中未添加列
if(this.model.nidgrp.ben.pts.extkey){
if(this.codes.markList) {
this.codes.markList.forEach((item) => {
if(this.model.nidgrp.ben.pts.extkey == item.extkey && this.checkedList.includes(item.extkey)) {
let curIndex = this.checkedList.indexOf(item.extkey)
this.checkedList.splice(curIndex, 1);
}
})
}
this.model.nidgrp.rec.ptyhgq = this.formatCheckedToName()
}
},
formatCheckedToName () {
let nameStr = ''
let nameList = []
if(this.codes.markList) {
this.codes.markList.forEach(item => {
if(this.checkedList.includes(item.extkey)) {
nameList.push(item.extkey);
}
})
}
nameStr = nameList.join('@')
return nameStr
},
formatNameToChecked (ptyhgq) {
this.checkedList = []
if(ptyhgq){
this.checkedList = ptyhgq.split('@');
}
},
// 保函模板转文本
templateToText () {
let gtxinr = this.model.nidgrp.rec.gtxinr
let textTempData = this.model.textTempData
this.formatTxtp(this.model.nidgrp.blk.gtxgidtxt, gtxinr, 'gtx', textTempData, 'nidgrp')
},
changeTxt () {
if(!this.model.nidgrp.blk.modifySet || !this.model.nidgrp.blk.modifySet.includes("gidtxt")){
this.templateToText()
}
},
onBccls1(){
if (this.model.addbcb.bccls1 == 'N') {
this.model.addbcb.expdat = this.model.nidgrp.rec.expdat;
} else if (this.model.addbcb.bccls1 == 'Y') {
this.model.addbcb.preexpdat = this.model.nidgrp.rec.expdat;
}
},
async agreementSigning() {
let data = {
ftynum: this.model.nitp.yptgimod.img[0].ftynum
}
let res = await Api.post('/business/nitopnRule/agreementSigning', data);
if (res.respCode == "AAAAAA") {
if (res.data && res.data.data == "Y") {
this.model.nitp.xyflg = res.data.data;
this.$notify({
title: "成功",
message: "协议盖章成功!",
type: "success",
});
}
else {
this.$notify({
title: '失败',
message: '协议盖章调用失败,错误信息:' + res.data.respMsg,
type: 'error',
});
}
}
else {
this.$notify({
title: '失败',
message: '协议盖章调用失败!',
type: 'error',
});
}
},
async showText() {
let data = this.model.nitp.yptgimod.img;
let res = await Api.post('/business/nitopnRule/getTextResultVo', data);
if (res.respCode == "AAAAAA") {
//res.data 内容为 TextResultVo
if (res.data.data) {
let type, code = res.data;
switch (res.data.extension) {
case "pdf": {
type = "application/pdf"
this.base64ToBlob(code,type)
break;
}
case "html": {
type = "text/html"
this.base64ToBlob(code,type)
break;
}
case "doc": {
type = "application/msword"
this.base64ToBlob(code,type)
break;
}
case "docx": {
type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
this.base64ToBlob(code,type)
break;
}
case "xls": {
type = "application/vnd.ms-excel"
this.base64ToBlob(code,type)
break;
}
case "xlsx": {
type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
this.base64ToBlob(code,type)
break;
}
case "txt": {
type = "text/plain"
this.base64ToBlob(code,type)
break;
}
case "gif": {
type = "image/gif"
this.base64ToBlob(code,type)
break;
}
case "jpeg": {
type = "image/jpeg"
this.base64ToBlob(code,type)
break;
}
case "jpg": {
type = "image/jpeg"
this.base64ToBlob(code,type)
break;
}
case "png": {
type = "image/png"
this.base64ToBlob(code,type)
break;
}
case "bmp": {
type = "image/bmp"
this.base64ToBlob(code,type)
break;
}
case "aac": {
type = "audio/aac"
this.base64ToBlob(code,type)
break;
}
case "abw": {
type = "application/x-abiword"
this.base64ToBlob(code,type)
break;
}
case "arc": {
type = "application/x-freearc"
this.base64ToBlob(code,type)
break;
}
case "avi": {
type = "video/x-msvideo"
this.base64ToBlob(code,type)
break;
}
case "jar": {
type = "application/java-archive"
this.base64ToBlob(code,type)
break;
}
case "js": {
type = "text/javascript"
this.base64ToBlob(code,type)
break;
}
case "json": {
type = "application/json"
this.base64ToBlob(code,type)
break;
}
case "mp3": {
type = "audio/mpeg"
this.base64ToBlob(code,type)
break;
}
case "ppt": {
type = "application/vnd.ms-powerpoint"
this.base64ToBlob(code,type)
break;
}
case "pptx": {
type = "application/vnd.openxmlformats-officedocument.presentationml.presentation"
this.base64ToBlob(code,type)
break;
}
case "rar": {
type = "application/x-rar-compressed"
this.base64ToBlob(code,type)
break;
}
case "svg": {
type = "image/svg+xml"
this.base64ToBlob(code,type)
break;
}
case "tar": {
type = "application/x-tar"
this.base64ToBlob(code,type)
break;
}
case "zip": {
type = "application/zip"
this.base64ToBlob(code,type)
break;
}
case "7z": {
type = "application/x-7z-compressed"
this.base64ToBlob(code,type)
break;
}
default: {
break;
}
}
this.$notify({
title: "成功",
message: "文件下载成功!",
type: "success",
});
}
else {
this.$notify({
title: '失败',
message: '文件下载失败!',
type: 'error',
});
}
}
},
base64ToBlob(code, type) {
if(type == 'application/pdf') {
code.data = code.data.replace(/[\n\r]/g, "")
}
const raw = window.atob(code.data);
const rawLength = raw.length;
const uInt8Array = new Uint8Array(rawLength);
for (let i = 0; i < rawLength; ++i) {
uInt8Array[i] = raw.charCodeAt(i);
}
const blob = new Blob([uInt8Array], { type: type });
// const fileURL = URL.createObjectURL(blob);
// window.open(fileURL)
let fileName = code.filename;
var downloadElement = document.createElement('a');
var href = window.URL.createObjectURL(blob);
downloadElement.href = href;
downloadElement.download = fileName;
document.body.appendChild(downloadElement);
downloadElement.click();
document.body.removeChild(downloadElement);
window.URL.revokeObjectURL(href);
},
},
};