KKbes
2023-06-06 08080a059681cf31f23e0e49b04e1d1e8f7bb465
询价excel导入 lwc重做
4个文件已添加
147 ■■■■■ 已修改文件
force-app/main/default/lwc/lexQuoteExcelImport/lexQuoteExcelImport.css 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexQuoteExcelImport/lexQuoteExcelImport.html 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexQuoteExcelImport/lexQuoteExcelImport.js 99 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexQuoteExcelImport/lexQuoteExcelImport.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexQuoteExcelImport/lexQuoteExcelImport.css
New file
@@ -0,0 +1,6 @@
.textAreaBody {
    --sds-c-textarea-sizing-min-height:120px;
}
td {
    width: 200px; }
table{width:30%;}
force-app/main/default/lwc/lexQuoteExcelImport/lexQuoteExcelImport.html
New file
@@ -0,0 +1,31 @@
<template>
            <table >
                <tr >
                    <td ><u><lable>{Label.ImportText}</lable></u></td>
                    <td colspan="2">&nbsp;</td>
                </tr>
                <tr >
                    <td ><lable >{Label.Tab_Text}</lable></td>
                    <td><lightning-button  onclick={setCB}  label={Label.Paste_IE}   ></lightning-button></td>
                </tr>
                <tr >
                    <td colspan="3"  width="300px">
                        <lightning-textarea
                        id="textarea"
                        class="textAreaBody"
                        name="mandatedNotes"
                        value={mandatedActivityNotes}
                      ></lightning-textarea></td>
                       <td colspan="2">&nbsp;</td>
                </tr>
                    <td width="300px">
                    <lightning-button  variant="brand-outline"  onclick={closeMe}   label={Label.Cancel} ></lightning-button></td>
                    <td width="300px">
                    <lightning-button  variant="brand-outline" label={Label.Registration}   onclick={sendText}></lightning-button></td>
                </tr>
            </table>
</template>
force-app/main/default/lwc/lexQuoteExcelImport/lexQuoteExcelImport.js
New file
@@ -0,0 +1,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 ;
        }
    }
}
force-app/main/default/lwc/lexQuoteExcelImport/lexQuoteExcelImport.js-meta.xml
New file
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lexQuoteExcelImport">
    <apiVersion>51.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
        <target>lightning__RecordAction</target>
    </targets>
</LightningComponentBundle>