import { LightningElement, wire, api, track } from 'lwc'; import { ShowToastEvent } from "lightning/platformShowToastEvent"; import { NavigationMixin } from "lightning/navigation"; import { CurrentPageReference } from "lightning/navigation"; //table css import { loadStyle } from "lightning/platformResourceLoader"; import WrappedHeaderTable from "@salesforce/resourceUrl/lexdatatable"; import init from '@salesforce/apex/lexToMcpApprovalController.init'; import save from '@salesforce/apex/lexToMcpApprovalController.save'; import mcpAprroval from '@salesforce/apex/lexToMcpApprovalController.mcpAprroval'; export default class lexToMcpApproval extends LightningElement { recordId; mcpeId=''; isShowNewContactModal = true; IsLoading=true; selectMce = []; @track mceList =[]; selectMceMap = {}; mcpeReson; reson; isMcpeDecide; mceSelects; saveResult ={}; isNotApprove = false; isDecideDisabled = true; @track consumptionRateSolution; solution; @track initResult =[]; //==================服务打包合同的id================ ParamIdStr = ''; // url 参数Id getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i { console.log('init result:'); console.log(result); this.initResult = result; if (result != null && result.length>0) { this.mcpeReson = result[0].mcpeReson; this.reson = result[0].mcpeReson; this.consumptionRateSolution = result[0].consumptionRateSolution; this.solution = result[0].consumptionRateSolution; this.isMcpeDecide = result[0].isMcpeDecide; this.mceSelects = result[0].mceIds; if(result[0].processStatus =='申请中' || result[0].processStatus =='批准'|| result[0].processStatus =='中止') { this.isNotApprove = true; } if(result[0].processStatus =='批准') { this.isDecideDisabled = false; } this.mceSelects = result[0].mceIds; const nowDate = new Date(); for(var i=0;i { console.log("error"); console.log(error); }); } beforeThreeMonth(nowDay,submitDay) { var months; if(nowDay.getDate()>submitDay.getDate()) { months = (nowDay.getFullYear() - submitDay.getFullYear()) * 12 + (nowDay.getMonth() - submitDay.getMonth()) ; } else { months = (nowDay.getFullYear() - submitDay.getFullYear()) * 12 + (nowDay.getMonth() - submitDay.getMonth()) -1; } if(months<3) { return false; } else { return true; } } //取消 async cancle() { window.location = '/'+this.recordId; } async saveMcpGroup() { this.selectMce = []; for(var key in this.selectMceMap) { if(this.selectMceMap[key] != '') { this.selectMce.push(this.selectMceMap[key]); } } console.log('save:mcpeId:'); console.log(this.mcpeId); console.log(this.mcpeReson); if(!this.reson) { alert('请填写申请理由'); return; } if(!this.solution) { alert('请填写消费率改善方案'); return; } if(this.selectMce.length != this.initResult.length) { alert('每个合同必须选择一条报价!'); } else{ if(!this.isMcpeDecide) { this.isMcpeDecide = false; } save({ recordId: this.recordId, mcpeReson:this.reson, mceIds:this.selectMce, mcpeId:this.mcpeId, isDecide:this.isMcpeDecide, consumptionRateSolution:this.solution }).then(returnData=>{ console.log('returnData:'); console.log(returnData); this.saveResult = returnData; if(returnData.result == '1') { this.mcpeId = returnData.mcpeId; alert('组合保存成功!'); window.location = '/'+this.recordId; } else { alert(returnData.result); } }); } } async mcpApproval() { this.selectMce = []; for(var key in this.selectMceMap) { if(this.selectMceMap[key] != '') { this.selectMce.push(this.selectMceMap[key]); } } console.log('save:mcpeId:'); console.log(this.mcpeId); console.log(this.mcpeReson); if(!this.reson) { alert('请填写申请理由'); return; } if(!this.solution) { alert('请填写消费率改善方案'); return; } if(this.selectMce.length != this.initResult.length) { alert('每个合同必须选择一条报价!'); } else{ if(!this.isMcpeDecide) { this.isMcpeDecide = false; } mcpAprroval({ recordId: this.recordId, mcpeReson:this.reson, mceIds:this.selectMce, mcpeId:this.mcpeId, isDecide:this.isMcpeDecide, consumptionRateSolution:this.solution }).then(result=>{ if(result == '1') { alert('提交审批成功!'); // window.location.reload(); // window.close(); window.location = '/'+this.recordId; } else { alert(result); } }); } } toEditMce(event) { window.open('/' + event.target.name,'_blank'); } selectMceEvent(event){ this.selectMceMap[event.target.name] = event.target.value; } changeMceGroupReson(event){ this.reson = event.target.value; } changeMcpeDecide(event){ this.isMcpeDecide =event.target.checked; } changeConsumptionRateSolution(event){ this.solution =event.target.value; } closeContactModal() { this.isShowNewContactModal = false; } }