黄千龙
2023-04-13 2d0c3e982b4dbd9192a6d717488653a54afebcb2
QIS按钮(发送QIS到SPO,OCSM服务本部收到实物)
8个文件已添加
2个文件已修改
444 ■■■■■ 已修改文件
force-app/main/default/classes/QISReportController.cls 101 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexOSHSubmit/lexOSHSubmit.js 43 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexRCRecieved/lexRCRecieved.css 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexRCRecieved/lexRCRecieved.html 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexRCRecieved/lexRCRecieved.js 103 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexRCRecieved/lexRCRecieved.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexSendQIS/lexSendQIS.css 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexSendQIS/lexSendQIS.html 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexSendQIS/lexSendQIS.js 121 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexSendQIS/lexSendQIS.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/QISReportController.cls
@@ -413,15 +413,114 @@
        }
         return re;
    }
    //发送QIS到SPO
    @AuraEnabled
    public static InitData initForlexSendQISButton (String recordId){
        InitData res = new initData();
        ID myUserID = UserInfo.getUserId();
        User userinfo = [SELECT id,Profile.name FROM User WHERE Id = :myUserID LIMIT 1];
        try{
            QIS_Report__c report = [SELECT  id ,RecordTypeId,IsSendQIS__c FROM QIS_Report__c WHERE Id = :recordId LIMIT 1];
            RecordType rec = [SELECT id,name FROM RecordType where  Id = :report.RecordTypeId];
            res.Id = report.Id;
            res.qisRecordTypeId = report.RecordTypeId;
            res.qisRecordName = rec.name;
            res.profileName = userinfo.Profile.name;
            res.IsSendQIS = report.IsSendQIS__c;
            System.debug(LoggingLevel.INFO, '*** res: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
    @AuraEnabled
    public static String updateQisForSendQIS (String recordId){
        String re = '成功';
        QIS_Report__c report = [SELECT Id,Name,IsSendQIS__c FROM QIS_Report__c WHERE Id = :recordId LIMIT 1];
        if(report == null ){
            return '没有QIS:' + recordId + '的数据。';
        }
        Savepoint sp = Database.setSavepoint();
        try{
                QIS_Report__c rac  = new QIS_Report__c();
                rac.id = recordId;
                rac.IsSendQIS__c = true;
                update rac;
        }catch(Exception e){
            Database.rollback(sp);
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            re = e.getMessage();
        }
         return re;
    }
    // OCSM服务本部收到实物
    @AuraEnabled
    public static InitData initForlexRCRecievedButton (String recordId){
        InitData res = new initData();
        ID myUserID = UserInfo.getUserId();
        User userinfo = [SELECT id,Profile.name FROM User WHERE Id = :myUserID LIMIT 1];
        try{
            QIS_Report__c report = [SELECT  id ,isAE_Profile__c,QIS_Status__c,isPAE_Profile__c,is_CNBuy__c FROM QIS_Report__c WHERE Id = :recordId LIMIT 1];
            res.Id = report.Id;
            res.isAEProfile = report.isAE_Profile__c;
            res.isPAEProfile = report.isPAE_Profile__c;
            res.QIStatus = report.QIS_Status__c;
            res.isCNBuy = report.is_CNBuy__c;
            System.debug(LoggingLevel.INFO, '*** res: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
    @AuraEnabled
    public static String updateQisForRCRecieved (String recordId){
        String re = '成功';
        ID myUserID = UserInfo.getUserId();
        User userinfo = [SELECT id,Alias,BuchangApprovalManagerSales__c,JingliApprovalManager__c, BuchangApprovalManager__c, ZongjianApprovalManager__c FROM User WHERE Id = :myUserID LIMIT 1];
        try{
                QIS_Report__c rac  = new QIS_Report__c();
                rac.id = recordId;
                rac.QIS_Status__c = 'RC检测中';
                rac.OCM_RC_RecievedDate__c = Date.today();
                rac.RC__c = myUserID;
                rac.RC_Receive_staff__c = userinfo.Alias;
                if (userinfo != null  && userinfo.BuchangApprovalManagerSales__c!= null) {
                    rac.RC_Manager__c = userinfo.BuchangApprovalManagerSales__c;
                } else {
                    rac.RC_Manager__c = myUserID;
                }
                update rac;
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            re = e.getMessage();
        }
         return re;
    }
    public class InitData{
        @AuraEnabled
        public String Id;
        @AuraEnabled
        public String qISSCReport;
        @AuraEnabled
        public String name;
        @AuraEnabled
        public String qISSCId;
        @AuraEnabled
        public String ownerId;
        @AuraEnabled
        public String qisRecordTypeId;
        @AuraEnabled
        public String qisRecordName;
        @AuraEnabled
        public String nextaction;
        @AuraEnabled
        public String qISMarketCategory;
        @AuraEnabled
        public String profileName;
        @AuraEnabled
@@ -455,6 +554,8 @@
        @AuraEnabled
        public Date qISInstallDate;
        @AuraEnabled
        public Date oSHInspectionDate;
        @AuraEnabled
        public Date cdsdate;
        @AuraEnabled
        public Date awaredate;
force-app/main/default/lwc/lexOSHSubmit/lexOSHSubmit.js
@@ -2,6 +2,7 @@
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import { NavigationMixin } from 'lightning/navigation';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import init  from '@salesforce/apex/QISReportController.initForOSHSubmitButton';
import updateQis  from '@salesforce/apex/QISReportController.updateQis1';
import UserInfo_Owner from '@salesforce/apex/TaskFeedbackController.UserInfo_Owner';
@@ -44,27 +45,59 @@
            console.log('this.OSHstaff='+this.OSHstaff);
            console.log('this.OSHstaffEmail='+this.OSHstaffEmail);
             if (this.qisStatus=='OSH检测申请' && this.qisStatus=='完毕') {
                 alert('需要先点击[OSH检查受理]');
                const evt = new ShowToastEvent({
                            title : '需要先点击[OSH检查受理]',
                            message: '',
                            variant: 'error'
                        });
                        this.dispatchEvent(evt);
                        this.dispatchEvent(new CloseActionScreenEvent());
                 return;
             }
             if (this.qisStatus!='OSH检测中') {
                 alert('已经提交审批');
                const evt = new ShowToastEvent({
                            title : '已经提交审批',
                            message: '',
                            variant: 'error'
                        });
                        this.dispatchEvent(evt);
                        this.dispatchEvent(new CloseActionScreenEvent());
                 return;
             }
             if (!confirm("一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?")) {
                return;
            }
            if (this.OSHstaff==null||this.OSHstaffEmail==null) {
                alert("OSH担当必须填写");
                const evt = new ShowToastEvent({
                            title : 'OSH担当必须填写',
                            message: '',
                            variant: 'error'
                        });
                        this.dispatchEvent(evt);
                        this.dispatchEvent(new CloseActionScreenEvent());
                return;
            }
            try{
                this.updateQisSubmit();
            }catch(err){
                if(err.faultstring !=undefined && err.faultstring.indexOf('INVALID_SESSION_ID') != -1) {
                    alert('当前网页已登出,请您重新登录后刷新该网页!');
                    const evt = new ShowToastEvent({
                            title : '当前网页已登出,请您重新登录后刷新该网页!',
                            message: '',
                            variant: 'error'
                        });
                        this.dispatchEvent(evt);
                        this.dispatchEvent(new CloseActionScreenEvent());
                        return;
                } else {
                    alert(err.faultstring);
                    const evt = new ShowToastEvent({
                            title : err.faultstring,
                            message: '',
                            variant: 'error'
                        });
                        this.dispatchEvent(evt);
                        this.dispatchEvent(new CloseActionScreenEvent());
                        return;
                }
                return;
            }
force-app/main/default/lwc/lexRCRecieved/lexRCRecieved.css
New file
@@ -0,0 +1,22 @@
.outerBorderCss{
    border: 1px solid #D4D4D4;
    border-radius : 5px;
    border-top : 3px solid #565959;
}
.borderCss{
    border: 1px solid #D4D4D4;
    border-radius : 5px;
    margin-bottom : 7px;
    border-top : 3px solid #565959;
}
.headerDorderCss{
    border-top: 1px solid #565959;
    border-bottom: 1px solid #D4D4D4;
    padding:3px;
}
.centerCss{
    text-align: center;
}
.centerCss .left{
    margin-left: 100px;
}/* sample css file */
force-app/main/default/lwc/lexRCRecieved/lexRCRecieved.html
New file
@@ -0,0 +1,5 @@
<template>
    <div class="sisToOPDHolder" if:true={IsLoading}>
        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
    </div>
</template>
force-app/main/default/lwc/lexRCRecieved/lexRCRecieved.js
New file
@@ -0,0 +1,103 @@
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import { NavigationMixin } from 'lightning/navigation';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { updateRecord } from 'lightning/uiRecordApi';
import init  from '@salesforce/apex/QISReportController.initForlexRCRecievedButton';
import updateQis  from '@salesforce/apex/QISReportController.updateQisForRCRecieved';
export default class lexRCRecieved extends LightningElement {
    @api recordId;
    err;
    IsLoading = true;
    qisReportId;
    qisStatus;
    isAEProfile;
    isPAEProfile;
    isCNBuy;
     @wire(CurrentPageReference)
     getStateParameters(currentPageReference) {
             console.log(111);
             console.log(currentPageReference);
         if (currentPageReference) {
           const urlValue = currentPageReference.state.recordId;
           if (urlValue) {
             let str = `${urlValue}`;
             console.log("str");
             console.log(str);
             this.recordId = str;
           }
         }
     }
     connectedCallback () {
        init({
            recordId: this.recordId
        }).then(result => {
            this.IsLoading = false;
            this.qisReportId = result.Id;
            this.qisStatus = result.qIStatus;
            this.isAEProfile = result.isAEProfile;
            this.isPAEProfile = result.isPAEProfile;
            this.isCNBuy = result.isCNBuy;
            console.log('this.qisStatus='+this.qisStatus);
             if (this.qisStatus!='RC检测申请') {
                const evt = new ShowToastEvent({
                        title : 'OCM服务本部已经收到实物',
                        message: '',
                        variant: 'error'
                    });
                this.dispatchEvent(evt);
                this.dispatchEvent(new CloseActionScreenEvent());
                return;
             }else{
                 if (this.isAEProfile == null || this.isPAEProfile == null || this.isCNBuy != 'true') {
                     const evt = new ShowToastEvent({
                        title : '安全信息未判定,请联系质量法规部',
                        message: '',
                        variant: 'error'
                    });
                    this.dispatchEvent(evt);
                    this.dispatchEvent(new CloseActionScreenEvent());
                    return;
                 }else{
                     this.updateQisSubmit();
                 }
             }
        }).catch(error => {
            console.log('error='+error);
        }).finally(() => {
        });
    }
    updateRecordView(recordId) {
        updateRecord({fields: { Id: recordId }});
    }
    updateQisSubmit(){
            updateQis({
                 recordId: this.recordId
                }).then(result =>{
                    console.log('result'+result);
                    this.err = result;
                    if (result!='成功') {
                        const evt = new ShowToastEvent({
                            title : '更新失败',
                            message: this.err,
                            variant: 'error'
                        });
                        this.dispatchEvent(evt);
                    }
                this.dispatchEvent(new CloseActionScreenEvent());
                this.updateRecordView(this.recordId);
                }).catch(error => {
                            console.log('error='+error);
                }).finally(() => {
                });
    }
}
force-app/main/default/lwc/lexRCRecieved/lexRCRecieved.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="lexRCRecieved">
   <apiVersion>54.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
        <target>lightning__RecordAction</target>
    </targets>
</LightningComponentBundle>
force-app/main/default/lwc/lexSendQIS/lexSendQIS.css
New file
@@ -0,0 +1,22 @@
.outerBorderCss{
    border: 1px solid #D4D4D4;
    border-radius : 5px;
    border-top : 3px solid #565959;
}
.borderCss{
    border: 1px solid #D4D4D4;
    border-radius : 5px;
    margin-bottom : 7px;
    border-top : 3px solid #565959;
}
.headerDorderCss{
    border-top: 1px solid #565959;
    border-bottom: 1px solid #D4D4D4;
    padding:3px;
}
.centerCss{
    text-align: center;
}
.centerCss .left{
    margin-left: 100px;
}/* sample css file */
force-app/main/default/lwc/lexSendQIS/lexSendQIS.html
New file
@@ -0,0 +1,5 @@
<template>
   <div class="sisToOPDHolder" if:true={IsLoading}>
        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
    </div>
</template>
force-app/main/default/lwc/lexSendQIS/lexSendQIS.js
New file
@@ -0,0 +1,121 @@
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import { NavigationMixin } from 'lightning/navigation';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import init  from '@salesforce/apex/QISReportController.initForlexSendQISButton';
import sendSPO  from '@salesforce/apex/QISReportController.updateQisForSendQIS';
import UserInfo_Owner from '@salesforce/apex/TaskFeedbackController.UserInfo_Owner';
import { updateRecord } from 'lightning/uiRecordApi';
export default class lexSendQIS extends LightningElement {
    @api recordId;
    str;
    err;
    IsLoading = true;
    qisReportId;
    qisRecordTypeId;
    qisRecordName;
    ProfileName;
    IsSendQIS;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
        if (currentPageReference) {
            const urlValue = currentPageReference.state.recordId;
            if (urlValue) {
                let str = `${urlValue}`;
                this.recordId = str;
            }
        }
    }
    connectedCallback() {
        console.log(this.recordId);
        init({
            recordId: this.recordId
        }).then(result => {
            console.log(result);
                this.IsLoading = false;
                this.qisRecordTypeId = result.qisRecordTypeId;
                this.qisReportId = result.Id;
                this.qisRecordName = result.qisRecordName;
                this.ProfileName = result.profileName;
                this.IsSendQIS = result.isSendQIS;
                if (this.qisRecordName == '2.OCSM') {
                    const evt = new ShowToastEvent({
                            title : '不能提交到SPO',
                            message: '记录类型为'+this.qisRecordName,
                            variant: 'error'
                        });
                        this.dispatchEvent(evt);
                        this.dispatchEvent(new CloseActionScreenEvent());
                        return;
                }
                if (!(this.ProfileName == '系统管理员' || this.ProfileName == '2F4_技术推进部' || this.ProfileName == '2F1_服务窗口')) {
                    const evt = new ShowToastEvent({
                            title : '没有权限提交,请联系系统管理员',
                            message: '',
                            variant: 'error'
                        });
                        this.dispatchEvent(evt);
                        this.dispatchEvent(new CloseActionScreenEvent());
                        return;
                }
                if (this.IsSendQIS) {
                    const evt = new ShowToastEvent({
                            title : '已提交到SPO,请不要重复提交',
                            message: '',
                            variant: 'error'
                        });
                        this.dispatchEvent(evt);
                        this.dispatchEvent(new CloseActionScreenEvent());
                        return;
                }
                this.send2SPO();
        }).catch(error => {
            console.log(error.getMessage());
        }).finally(() => {
        });
    }
    updateRecordView(recordId) {
        updateRecord({fields: { Id: recordId }});
    }
    send2SPO(){
            sendSPO({
                 recordId: this.recordId
                }).then(result =>{
                    console.log('result'+result);
                     this.err = result;
                    if (result!='成功') {
                        const evt = new ShowToastEvent({
                            title : '更新失败',
                            message: this.err,
                            variant: 'error'
                        });
                        this.dispatchEvent(evt);
                        this.dispatchEvent(new CloseActionScreenEvent());
                        return;
                    }else{
                        const evt = new ShowToastEvent({
                            title : '提交成功!请在SPO系统中完成退换货申请',
                            message: '',
                            variant: 'success'
                        });
                        this.dispatchEvent(evt);
                        this.dispatchEvent(new CloseActionScreenEvent());
                        this.updateRecordView(this.recordId);
                        window.location.replace("https://olympus.sharepoint.cn/sites/GSPWF/SitePages/HomePage.aspx");
                    }
                }).catch(error => {
            console.log('error='+error);
        }).finally(() => {
        });
    }
}
force-app/main/default/lwc/lexSendQIS/lexSendQIS.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="lexSendQIS">
   <apiVersion>54.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
        <target>lightning__RecordAction</target>
    </targets>
</LightningComponentBundle>