KKbes
2023-08-07 492f744d9d84289e27b2ddac9a9b4a2137fd11d6
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
import { LightningElement, track, wire ,api} from 'lwc';
 
 
 
 
import ImportText from '@salesforce/label/c.ImportText';
import Tab_Text from '@salesforce/label/c.Tab_Text';
import Paste_IE  from '@salesforce/label/c.Paste_IE';
import Cancel  from '@salesforce/label/c.Cancel';
import Registration  from '@salesforce/label/c.Registration';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
 
 
 const event3 = new ShowToastEvent({
            title: '粘贴失败',
            message:
                '粘贴失败,请联系管理人员',
        });
 
 
 
export default class lexQuoteExcelImport extends LightningElement {
 
 
    @api recordId;
    mandatedActivityNotes;
 
   
 
 
 
        Label = {
        ImportText,
        Tab_Text,
        Paste_IE,
        Cancel,
        Registration
    };
 
 
 
 
    async closeMe(event){
        console.log('closeMe');
        top.window.close();
    }
 
 
    async sendText(event) {
        console.log('sendText');
        console.log(this);
        this.mandatedActivityNotes = this.template.querySelector("lightning-textarea").value;
        console.log(this.mandatedActivityNotes);
        // top.window.opener.excelImport(str);
        //上一个页面的方法,得找到这个页面的入口
        top.window.opener.excelImportGateway(this.mandatedActivityNotes);
        top.window.close();
    }
 
 
 
    async setCB(event) {
        console.log('setCB');
        var userAgent = navigator.userAgent;
        console.log('navigator');
        var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1;
        console.log('isIE='+isIE);
        var isEdge = userAgent.indexOf("Edge") > -1 && !isIE;
        console.log('isEdge='+isEdge);
        var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1;
        console.log('isIE11'+isIE11);
        var txt;
        if (isIE|| isIE11 ){
            console.log('1');
             txt = window.clipboardData.getData("text");
             console.log(txt);
             console.log('2');
             this.mandatedActivityNotes=txt;
             // document.forms['{!$Component.mainForm}']['{!$Component.mainForm.page1.exceltext}'].value = txt;
        }
        else{
                var testA;
                await navigator.clipboard.readText().then(function(text){
                    console.log('readText');
                    console.log(text);
                    testA= text;
                    // this.mandatedActivityNotes = text;
                    // document.getElementById("textarea").innerHTML = text;
                    // this.mandatedActivityNotes = acText;
                    console.log('hhh');
                 }).catch(error => {
                console.log("error");
                this.dispatchEvent(event3);
                });
                this.mandatedActivityNotes = testA ;
        }
    }
 
}