import { LightningElement, track, wire ,api} from 'lwc';
|
import LightningConfirm from 'lightning/confirm';
|
import jquery183minjs from '@salesforce/resourceUrl/jquery183minjs';
|
import PleaseWaitDialog from '@salesforce/resourceUrl/PleaseWaitDialog';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import Selected from '@salesforce/label/c.Selected';
|
import Set_Search from '@salesforce/label/c.Set_Search';
|
import Search_Condition from '@salesforce/label/c.Search_Condition';
|
import Search from '@salesforce/label/c.Search';
|
import Search_Result from '@salesforce/label/c.Search_Result';
|
import { NavigationMixin } from 'lightning/navigation';
|
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
|
import { CurrentPageReference } from 'lightning/navigation';
|
|
import getNeedParm1 from "@salesforce/apex/LexChoiceAssetController.getNeedParm1";
|
import init from "@salesforce/apex/LexChoiceAssetController.init";
|
import searchAss from "@salesforce/apex/LexChoiceAssetController.searchAss";
|
import getData from "@salesforce/apex/LexChoiceAssetController.getData";
|
|
|
|
const columns = [
|
{ label: '选择', fieldName: 'Selected' , minWidth: 20, maxWidth: 20 },
|
{ label: '保有设备名称', fieldName: 'Name' },
|
{ label: '机身编码', fieldName: 'SerialNumber' },
|
{ label: '医院', fieldName: 'HP_Name' },
|
{ label: '科室', fieldName: 'Department_Name' },
|
{ label: '发货日', fieldName: 'Posting_Date' },
|
{ label: '多年保修期至', fieldName: 'Extend_Gurantee_DateTo'},
|
{ label: '最近一期维修合同结束日', fieldName: 'CurrentContract_End_Date'},
|
];
|
export default class lexChoiceAsset extends NavigationMixin(LightningElement) {
|
|
Label = {
|
Set_Search,
|
Search_Condition,
|
Search,
|
Search_Result,
|
Selected
|
}
|
|
|
|
@api recordId;
|
IsLoading=true;
|
data = [];
|
columns = columns;
|
SSPLine;
|
Delivered_Product;
|
Department_Name;
|
HospitalId;
|
WorkLocation;
|
//搜索需要的数据
|
@track inputData1;
|
@track inputData2;
|
@track inputData3;
|
Id;
|
StatusC;
|
Incharge_Staff;
|
Repair_Detail;
|
FaultTime;
|
RepairApplicantName;
|
HPname;
|
DepName;
|
PlannedVisitDay;
|
ActualVisitDateFirst;
|
RepairsReportDate;
|
ReceiverTime;
|
ActualVisitDateSecon;
|
ActualVisitDateThird;
|
ApplicationTime;
|
canRepair;
|
//搜索出的数据 report onclick拼接需要的参数
|
needParm2;
|
|
|
@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;
|
}
|
}
|
}
|
handleRowAction(event) {
|
const action = event.detail.action;
|
const row = event.detail.row;
|
switch (action.name) {
|
case '点击添加':
|
this.handleAdd(row);
|
break;
|
default:
|
break;
|
}
|
}
|
|
handleAdd(row) {
|
// Implement edit logic here
|
console.log('Editing row' + JSON.stringify(row));
|
this.SetProductId(row.setProductidFull);
|
}
|
|
|
|
|
getInput1(event){
|
this.inputData1=event.detail.value;
|
|
}
|
|
getInput2(event){
|
this.inputData2=event.detail.value;
|
|
}
|
getInput3(event){
|
this.inputData3=event.detail.value;
|
|
}
|
|
|
|
connectedCallback(){
|
init({
|
recordId: this.recordId
|
}).then(result => {
|
// console.log(result);
|
if (result != null) {
|
this.IsLoading = false;
|
this.Id = result.Id;
|
this.StatusC = result.StatusC;
|
this.Incharge_Staff = result.OwnerId;
|
this.Repair_Detail = result.Repair_Detail;
|
this.FaultTime = result.FaultTime;
|
this.RepairApplicantName = result.RepairApplicantName;
|
this.HPname = result.HPname;
|
this.DepName = result.DepName;
|
this.RepairsReportDate = result.RepairsReportDate;
|
this.ReceiverTime = result.ReceiverTime;
|
this.PlannedVisitDay = result.PlannedVisitDay;
|
this.ActualVisitDateFirst = result.ActualVisitDateFirst;
|
this.ActualVisitDateSecon = result.ActualVisitDateSecon;
|
this.ActualVisitDateThird = result.ActualVisitDateThird;
|
this.ApplicationTime = result.ApplicationTime;
|
this.ApplyForRepair();
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
}).catch(error => {
|
console.log(error);
|
})
|
this.serContact();
|
|
}
|
async SelectNone(){
|
const inputSearchNo = this.template.querySelector('lightning-input[data-target="SearchNo"]');
|
if (inputSearchNo) {
|
inputSearchNo.value = '';
|
}
|
|
const inputSearchName = this.template.querySelector('lightning-input[data-target="SearchName"]');
|
if (inputSearchName) {
|
inputSearchName.value = '';
|
}
|
const inputSearchSN = this.template.querySelector('lightning-input[data-target="SearchSN"]');
|
console.log('inputSearchSN=='+inputSearchSN);
|
if (inputSearchSN) {
|
inputSearchSN.value = '';
|
}
|
|
this.inputData1='';
|
this.inputData2='';
|
this.inputData3='';
|
var SearchNo = this.inputData1;
|
var SearchName = this.inputData2;
|
var SearchSN = this.inputData3;
|
await getData({SearchName : SearchName , SearchNo : SearchNo , SearchSN : SearchSN}).then(res=>{
|
if(res!=null){
|
this.IsLoading=false;
|
this.data=res;
|
console.log(res);
|
console.log(this.data[0]);
|
}
|
}).catch(error=>{
|
console.log(error);
|
})
|
|
}
|
|
|
|
|
async SelectDone(){
|
var selectedRecords = this.template.querySelector("lightning-datatable").getSelectedRows();
|
console.log('selectedRecords.length=='+selectedRecords.length);
|
if(selectedRecords.length>0){
|
if (selectedRecords.length>1) {
|
const evt = new ShowToastEvent({
|
title : '只能选择一个保有设备',
|
message: '',
|
variant: 'error'
|
});
|
this.dispatchEvent(evt);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
return;
|
}
|
searchAss({
|
recordId: selectedRecords[0].Assetid
|
}).then(result => {
|
// console.log(result);
|
if (result != null) {
|
console.log('result.canRepair=='+result.canRepair);
|
this.IsLoading = false;
|
this.canRepair = result.canRepair;
|
}
|
console.log('this.canRepair=='+this.canRepair);
|
if (this.canRepair == '第三方') {
|
const evt = new ShowToastEvent({
|
title : '非我司修理对象,无法新建修理,如有不明请咨询CIC',
|
message: '',
|
variant: 'error'
|
});
|
this.dispatchEvent(evt);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
return;
|
}
|
if (this.canRepair == '不'||this.canRepair == null) {
|
const evt = new ShowToastEvent({
|
title : '本设备无法新建修理',
|
message: '',
|
variant: 'error'
|
});
|
this.dispatchEvent(evt);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
return;
|
}
|
var status = this.StatusC;
|
if (status != '待处理') {
|
const evt = new ShowToastEvent({
|
title : '修子单的状态不是 待处理 无法申请修理',
|
message: '',
|
variant: 'error'
|
});
|
this.dispatchEvent(evt);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
return;
|
}
|
if (this.Id == null || this.Id == '') {
|
const evt = new ShowToastEvent({
|
title : '报修子单Id 不能为空',
|
message: '',
|
variant: 'error'
|
});
|
this.dispatchEvent(evt);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
return;
|
}
|
this.Delivered_Product = selectedRecords[0].Assetid;
|
this.Department_Name = selectedRecords[0].Accountid;
|
this.HospitalId = selectedRecords[0].Hospital;
|
this.WorkLocation = selectedRecords[0].WorkLocation;
|
this.navigateToNewObjectPage();
|
}).catch(error => {
|
console.log(error);
|
})
|
|
}
|
else{
|
console.log('else');
|
const evt = new ShowToastEvent({
|
title : '请选择一个保有设备',
|
message: '',
|
variant: 'error'
|
});
|
this.dispatchEvent(evt);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
return;
|
}
|
}
|
|
async serContact(){
|
console.log('into serContact')
|
var SearchNo = this.inputData1;
|
var SearchName = this.inputData2;
|
var SearchSN = this.inputData3;
|
|
if(SearchSN == undefined){
|
SearchSN='';
|
}
|
if(SearchName == undefined){
|
SearchName='';
|
}
|
if(SearchNo == undefined){
|
SearchNo = '';
|
}
|
console.log('SearchName='+SearchName);
|
console.log('SearchNo='+SearchNo);
|
console.log('SearchSN='+SearchSN);
|
await getData({SearchName : SearchName , SearchNo : SearchNo , SearchSN : SearchSN}).then(res=>{
|
if(res!=null){
|
this.IsLoading=false;
|
this.data=res;
|
console.log(res);
|
console.log(this.data[0]);
|
}
|
}).catch(error=>{
|
console.log(error);
|
})
|
|
}
|
navigateToNewObjectPage() {
|
// console.log('RepairApplicantName=='+this.RepairApplicantName);
|
// console.log('this.id=='+this.id);
|
const defaultFieldValues =encodeDefaultFieldValues({
|
Delivered_Product__c: this.Delivered_Product,
|
Account__c: this.Department_Name,
|
Hospital__c: this.HospitalId,
|
SalesOfficeCode_selection__c: this.WorkLocation,
|
Incharge_Staff__c:this.Incharge_Staff,
|
Repair_Detail__c:this.Repair_Detail,
|
Failure_Occurrence_Date__c:this.FaultTime,
|
Repair_Source__c:'从报修子单',
|
RepairApplicant__c:this.RepairApplicantName,
|
RepairApplicantHospital__c:this.HPname,
|
RepairApplicantDepartment__c:this.DepName,
|
RepairTime__c:this.RepairsReportDate,
|
ReceiverTime__c:this.ReceiverTime,
|
PlannedVisitDay__c:this.PlannedVisitDay,
|
ActualVisitDateFirst__c:this.ActualVisitDateFirst,
|
ActualVisitDateSecond__c:this.ActualVisitDateSecon,
|
ActualVisitDateThird__c:this.ActualVisitDateThird,
|
SubOrderCreatedDate__c:this.ApplicationTime,
|
Exc_work_location__c:true,
|
RepairSubOrder__c:this.recordId
|
});
|
|
this[NavigationMixin.Navigate]({
|
type: 'standard__objectPage',
|
attributes: {
|
objectApiName: 'Repair__c',
|
actionName: 'new'
|
},
|
state: {
|
nooverride: '1',
|
defaultFieldValues: defaultFieldValues
|
}
|
});
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
|
}
|