From 0f44cb1a0b7b36860e9ce81c1eac9e395d87f0b4 Mon Sep 17 00:00:00 2001 From: buli <137736985@qq.com> Date: 星期一, 05 六月 2023 13:53:18 +0800 Subject: [PATCH] mergecode into lex dtt --- force-app/main/default/lwc/lexConsumable/lexConsumable.js | 622 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 515 insertions(+), 107 deletions(-) diff --git a/force-app/main/default/lwc/lexConsumable/lexConsumable.js b/force-app/main/default/lwc/lexConsumable/lexConsumable.js index c190ba2..1bc8cee 100644 --- a/force-app/main/default/lwc/lexConsumable/lexConsumable.js +++ b/force-app/main/default/lwc/lexConsumable/lexConsumable.js @@ -18,6 +18,10 @@ import searchHospital from '@salesforce/apex/LexSearchHospitalController.searchHospital'; import initContract from '@salesforce/apex/LexSearchContractController.init'; import searchContract from '@salesforce/apex/LexSearchContractController.searchContract'; +import deleteAtt from '@salesforce/apex/LexConsumableController.deleteAtt'; +//table css +import { loadStyle } from "lightning/platformResourceLoader"; +import WrappedHeaderTable from "@salesforce/resourceUrl/lexdatatable"; export default class LexConsumable extends NavigationMixin(LightningElement) { @@ -42,11 +46,14 @@ @track category4Option = []; @track category5Option = []; @track consumableorderdetailsRecordsview = []; - @track consumableorderdetailsRecordForDT = []; + @track currentRecord = [];//鍒嗛〉 + @track selectRows = []; @track attachmentRecoeds = []; @track contactDealer = []; @track proLimitAndDate = []; @track agencyProType; + @track agencyProType1; + @track OSHFLG = false; @track bargainPrice; @track showOrderDate = false; @track showAttUploadDate = false; @@ -67,9 +74,23 @@ @track disabledOfferPriceInputBtn = false; @track showReapplyBtn = false; @track showHospital = false; - @track showSpinner = true; @track showPage = false; @track cansee = false; + @track showSpinner = true; + @track showPopSpinner = false; + stylesLoaded = false; + //鏄惁涓�鐩存樉绀烘彁绀� + @track isNoteStay = true; + //鎺掑簭鐩稿叧 + @track sortDirection = 'asc'; + @track sortedBy; + //鍒嗛〉 + @track currentPage = 1; + @track pageSize = 10; + // @track totalPage = 0; + @track pageSizeOptions = [10, 25, 50, 100]; + @track recordStart = 0; + @track recordEnd = 0; //鎶ラ敊鎻愰啋 // @track hasError = false; @track errorMsgs = []; @@ -94,10 +115,10 @@ @track tempidHp; @track hosCols = [ // {label:'鍖婚櫌鍚嶇О',fieldName:'Name',type:'button',typeAttributes:{label:{fieldName:'Name'},variant:'base'}}, - {label:'',type:'button',typeAttributes:{label:'閫夋嫨'},initialWidth:80,hideDefaultActions: true}, + {label:'',type:'button',typeAttributes:{label:'閫夋嫨'},initialWidth:90,hideDefaultActions: true,wrapText:true}, {label:'鍖婚櫌鍚嶇О',fieldName:'Name',initialWidth:380,wrapText:true,hideDefaultActions: true}, - {label:'鐪佷唤',fieldName:'StateMaster',initialWidth:80,hideDefaultActions: true}, - {label:'鍦板潃',fieldName:'Address__c',hideDefaultActions: true} + {label:'鐪佷唤',fieldName:'StateMaster',initialWidth:80,hideDefaultActions: true,wrapText:true}, + {label:'鍦板潃',fieldName:'Address__c',hideDefaultActions: true,wrapText:true} ]; //鍚堝悓鎼滅储 @track contractLabel; @@ -110,27 +131,27 @@ @track contractName; @track tempidPp; @track conCols = [ - {label:'',type:'button',typeAttributes:{label:'閫夋嫨'},initialWidth:80,hideDefaultActions: true}, + {label:'',type:'button',typeAttributes:{label:'閫夋嫨'},initialWidth:90,hideDefaultActions: true,wrapText:true}, {label:'鍚堝悓鍚嶇О',fieldName:'Name',wrapText:true,hideDefaultActions: true}, - {label:'鐪佷唤',fieldName:'StateMaster',initialWidth:80,hideDefaultActions: true}, - {label:'鐢宠閿�鍞',fieldName:'Sales_Section__c',initialWidth:200,hideDefaultActions: true}, - {label:'鍏佽鎶ヤ环鏈熼棿(寮�濮嬫棩)',fieldName:'Contract_Decide_Start_Date__c',initialWidth:200,hideDefaultActions: true}, - {label:'鍏佽鎶ヤ环鏈熼棿(缁撴潫鏃�)',fieldName:'Contract_Decide_End_Date__c',initialWidth:200,hideDefaultActions: true} + {label:'鐪佷唤',fieldName:'StateMaster',initialWidth:80,hideDefaultActions: true,wrapText:true}, + {label:'鐢宠閿�鍞',fieldName:'Sales_Section__c',initialWidth:160,hideDefaultActions: true,wrapText:true}, + {label:'鍏佽鎶ヤ环鏈熼棿(寮�濮嬫棩)',fieldName:'Contract_Decide_Start_Date__c',initialWidth:175,hideDefaultActions: true,wrapText:true}, + {label:'鍏佽鎶ヤ环鏈熼棿(缁撴潫鏃�)',fieldName:'Contract_Decide_End_Date__c',initialWidth:175,hideDefaultActions: true,wrapText:true} ]; //娑堣�楀搧鏁版嵁col get cols(){ var cols = []; - cols.push({label:'娑堣�楀搧鍚嶇О',fieldName:'prodName',wrapText:true,hideDefaultActions: true}); - cols.push({label:'瑙勬牸',fieldName:'packing_list',hideDefaultActions: true}); - cols.push({label:'CFDA鐘舵��',fieldName:'prodSFDAStatus',hideDefaultActions: true}); - cols.push({label:'娉ㄥ唽璇佺紪鐮佸彿',fieldName:'approbation_No',hideDefaultActions: true}); - cols.push({label:'娉ㄥ唽璇佹晥鏈�',fieldName:'expiration_Date',hideDefaultActions: true}); - cols.push({label:'绗�3鍒嗙被',fieldName:'prodCategory3',hideDefaultActions: true}); - cols.push({label:'绗�4鍒嗙被',fieldName:'prodCategory4',hideDefaultActions: true}); - cols.push({label:'绗�5鍒嗙被',fieldName:'prodCategory5',hideDefaultActions: true}); + cols.push({label:'娑堣�楀搧鍚嶇О',fieldName:'prodName',wrapText:true,hideDefaultActions: true,sortable: true}); + cols.push({label:'瑙勬牸',fieldName:'packing_list',wrapText:true,hideDefaultActions: true,initialWidth:50,cellAttributes: { alignment: "right" }}); + cols.push({label:'CFDA鐘舵��',fieldName:'prodSFDAStatus',wrapText:true,hideDefaultActions: true,initialWidth:97}); + cols.push({label:'娉ㄥ唽璇佺紪鐮佸彿',fieldName:'approbation_No',wrapText:true,hideDefaultActions: true,initialWidth:120}); + cols.push({label:'娉ㄥ唽璇佹晥鏈�',fieldName:'expiration_Date',wrapText:true,hideDefaultActions: true,initialWidth:105}); + cols.push({label:'绗�3鍒嗙被',fieldName:'prodCategory3',wrapText:true,hideDefaultActions: true,initialWidth:78,sortable: true}); + cols.push({label:'绗�4鍒嗙被',fieldName:'prodCategory4',wrapText:true,hideDefaultActions: true,initialWidth:107,sortable: true}); + cols.push({label:'绗�5鍒嗙被',fieldName:'prodCategory5',wrapText:true,hideDefaultActions: true,initialWidth:80,sortable: true}); if(this.cansee){ - cols.push({label:'鏍囧噯鍗曚环',fieldName:'prodIntraTradeList',hideDefaultActions: true}); + cols.push({label:'鏍囧噯鍗曚环',type:'number',typeAttributes:{minimumFractionDigits: 2},fieldName:'prodIntraTradeList',hideDefaultActions: true,initialWidth:80}); } if(this.editAble){ cols.push( @@ -138,16 +159,120 @@ type: "customTableInput",typeAttributes: { recordId: { fieldName: "recordId" }, inputValue: { fieldName: "consumableCount" }, + upperLimit: { fieldName: "upperlimit" }, + lowerLimit: { fieldName: "lowerlimit" }, + allnumber: { fieldName: "allnumber" }, + valueType: 'Number' }, - hideDefaultActions: true}); + hideDefaultActions: true,initialWidth:80}); }else{ - cols.push({label:'閲囪喘鏁伴噺',fieldName:'consumableCount',hideDefaultActions: true}); + cols.push({label:'閲囪喘鏁伴噺',fieldName:'consumableCount',hideDefaultActions: true,initialWidth:80,cellAttributes: { alignment: "right" }}); } - cols.push({label:'鍦ㄥ簱鏁颁笅闄�',fieldName:'lowerlimit',hideDefaultActions: true}); - cols.push({label:'鍦ㄥ簱鏁颁笂闄�',fieldName:'upperlimit',hideDefaultActions: true}); - cols.push({label:'鏈夋晥鏈熷簱瀛�(鐩�)',fieldName:'allnumber',hideDefaultActions: true}); - cols.push({label:'鏈夋晥鏈熷簱瀛�(涓�)',fieldName:'allnumber_piece',hideDefaultActions: true}); - return cols;l + cols.push({label:'鍦ㄥ簱鏁颁笅闄�',fieldName:'lowerlimit',hideDefaultActions: true,initialWidth:100,cellAttributes: { alignment: "right" }}); + cols.push({label:'鍦ㄥ簱鏁颁笂闄�',fieldName:'upperlimit',hideDefaultActions: true,initialWidth:100,cellAttributes: { alignment: "right" }}); + // cols.push({label:'鏈夋晥鏈熷簱瀛�(鐩�)',fieldName:'allnumber',hideDefaultActions: true,initialWidth:105,sortable: true}); + cols.push( + {label:'鏈夋晥鏈熷簱瀛�(鐩�)', + type: "customInventoryColor", + typeAttributes: { + value: { fieldName: "allnumber" }, + upperlimit: { fieldName: "upperlimit" }, + lowerlimit: { fieldName: "lowerlimit" }, + boxPrice: '鐩�' + }, + hideDefaultActions: true,initialWidth:126}); + cols.push({label:'鏈夋晥鏈熷簱瀛�(涓�)',fieldName:'allnumber_piece',hideDefaultActions: true,initialWidth:126,cellAttributes: { alignment: "right" }}); + return cols; + } + + //闄勪欢cols + @track attCols = [ + {label:'鏍囬',fieldName:'attUrl',type:'url',typeAttributes:{label:{fieldName:'fileName'},target: "_blank"},hideDefaultActions: true}, + {label:'鍒涘缓浜�',fieldName:'ownerUrl',type:'url',typeAttributes:{label:{fieldName:'ownerName'},target: "_blank"},hideDefaultActions: true}, + {label:'涓婁紶鏃ユ湡',fieldName:'updateDate',hideDefaultActions: true}, + {label:'',type:'tableCellIcon',typeAttributes:{iconName:'utility:delete',recordId:{fieldName : 'recordId'}},initialWidth:50,hideDefaultActions: true} + ]; + + //鍙栧緱鎵�鏈夎鍕鹃�夌殑浜у搧id + getAllChecked(){ + this.selectRows = []; + for(var i in this.currentRecord){ + if(this.currentRecord[i].check){ + this.selectRows.push(this.currentRecord[i].recordId); + } + } + } + + //鍕鹃�夋搷浣� + checkRows(event){ + this.selectRows = []; + const selectedRows = event.detail.selectedRows; + for(var i in this.consumableorderdetailsRecordsview){ + var count = 0; + for(var j in selectedRows){ + if(this.consumableorderdetailsRecordsview[i].recordId == selectedRows[j].recordId){ + count++ + console.log("checkId:"+selectedRows[j].recordId+'---'+this.consumableorderdetailsRecordsview[i].prodName); + } + } + if(count == 0){ + this.consumableorderdetailsRecordsview[i].check = false; + }else{ + this.consumableorderdetailsRecordsview[i].check = true; + this.selectRows.push(this.consumableorderdetailsRecordsview[i].recordId); + } + } + for(var i in this.selectRows){ + console.log("checkId1:"+this.selectRows[i]); + for(var i in this.currentRecord){ + if(this.currentRecord[i].recordId == this.selectRows[i]){ + console.log("currentRecord:"+this.selectRows[i]); + } + } + } + } + + //閲囪喘鏁伴噺鑾峰彇 + conCountChange(event){ + var recordId = event.detail.data.recordId; + var conCount = event.detail.data.value; + console.log('countChange:'+recordId+'---'+conCount); + for(var i in this.consumableorderdetailsRecordsview){ + if(this.consumableorderdetailsRecordsview[i].recordId == recordId){ + this.consumableorderdetailsRecordsview[i].esd.Consumable_count__c = conCount; + this.consumableorderdetailsRecordsview[i].consumableCount = conCount; + if(conCount != null && conCount !=0 && conCount!=''){ + this.consumableorderdetailsRecordsview[i].check = true; + }else{ + this.consumableorderdetailsRecordsview[i].check = false; + } + } + } + this.getAllChecked(); + for(var i in this.currentRecord){ + if(this.currentRecord[i].recordId == recordId){ + console.log("currentRecord1:"+this.currentRecord[i].esd.Consumable_count__c); + } + } + } + + //閲囪喘鏁伴噺澶辩劍 + conCountBlur(event){ + var conCount = event.detail.data.value; + var allnumber = event.detail.data.allnumber; + var upperLimit = event.detail.data.upperLimit; + var lowerLimit = event.detail.data.lowerLimit; + console.log('limit:'+conCount+'---'+ allnumber+'---'+lowerLimit+'---'+allnumber); + if(upperLimit != null && lowerLimit != null && conCount != null && allnumber != null){ + if(parseInt(allnumber) + parseInt(conCount) > upperLimit){ + // window.alert("璇ヤ骇鍝佽璐暟閲忚秴鍑哄簱瀛樹笂闄愶紒"); + this.showMyToast('璇ヤ骇鍝佽璐暟閲忚秴鍑哄簱瀛樹笂闄愶紒','','error'); + } + if(parseInt(allnumber) + parseInt(conCount) < lowerLimit){ + // window.alert("璇ヤ骇鍝佽璐暟閲忎綆浜庡簱瀛樹笅闄愶紒"); + this.showMyToast('璇ヤ骇鍝佽璐暟閲忎綆浜庡簱瀛樹笅闄愶紒','','error'); + } + } } @wire(CurrentPageReference) @@ -162,11 +287,26 @@ console.log('keyWords:'+this.keyWords); } } + + renderedCallback(){ + if (!this.stylesLoaded) { + Promise.all([loadStyle(this, WrappedHeaderTable)]) + .then(() => { + console.log("Custom styles loaded"); + this.stylesLoaded = true; + }) + .catch((error) => { + console.error("Error loading custom styles"); + }); + } + } + //椤甸潰鍒濆鍖� connectedCallback(){ this.showSpinner = true; initPage({type:this.pageType, esetId:this.esetId, keywordStr:this.keyWords}) .then(result=>{ + this.isNoteStay = result.isNoteStay; if(result.result == 'Success'){ this.editAble = result.editAble; this.edoffersPrice = result.edoffersPrice; @@ -176,13 +316,38 @@ this.category4Option = result.category4Option; this.category5Option = result.category5Option; this.agencyProType = result.agencyProType; + this.agencyProType1 = result.agencyProType1; + this.OSHFLG = result.OSHFLG; this.hospitalName = result.hospitalName; this.contractName = result.contractName; this.contractLabel = '缁忛攢鍟嗘湁鏁堝悎鍚�'; this.consumableorderdetailsRecordsview = result.consumableorderdetailsRecordsview; - // this.consumableorderdetailsRecordForDT = result.consumableorderdetailsRecordsview; - this.getTableData(); + this.currentPage = 1; + this.showCurrentReocrd(); + this.getAllChecked(); this.attachmentRecoeds = result.attachmentRecoeds; + console.log("attSize:"+this.attachmentRecoeds.length); + for(var i in this.attachmentRecoeds){ + this.attachmentRecoeds[i]['recordId'] = this.attachmentRecoeds[i].Concc.Id; + this.attachmentRecoeds[i]['documentId'] = this.attachmentRecoeds[i].Concc.ContentDocumentId; + this.attachmentRecoeds[i]['fileFullName'] = this.attachmentRecoeds[i].Concc.Title; + var contractionName = this.attachmentRecoeds[i].Concc.Title; + // var contractionName = '闀挎枃浠堕暱鏂囦欢闀挎枃浠堕暱鏂囦欢'; + if(contractionName.length > 25){ + contractionName = contractionName.substr(0,21) + "..."; + } + this.attachmentRecoeds[i]['fileName'] = contractionName; + this.attachmentRecoeds[i]['ownerName'] = this.attachmentRecoeds[i].Concc.Owner.Name; + this.attachmentRecoeds[i]['downloadUrl'] = '/sfc/servlet.shepherd/document/download/'+this.attachmentRecoeds[i].Concc.ContentDocumentId+'?operationContext=S1'; + // var date = this.attachmentRecoeds[i].Concc.CreatedDate; + // var year = date.getFullYear(); + // var month = date.getMonth(); + // var day = date.getDay(); + // console.log(year+'-'+month+'-'+day); + this.attachmentRecoeds[i]['updateDate'] = new Date(Date.parse(this.attachmentRecoeds[i].Concc.CreatedDate)).toLocaleString(); + this.attachmentRecoeds[i]['attUrl'] = '/'+this.attachmentRecoeds[i].Concc.Id; + this.attachmentRecoeds[i]['ownerUrl'] = '/'+this.attachmentRecoeds[i].Concc.OwnerId; + } this.errorMsgs = result.errorMsgList; this.warningMsgs = result.warningMsgList; this.userWorkLocation = result.userWorkLocation; @@ -196,6 +361,7 @@ this.contactDealer = result.contactDealer; this.pageType = result.methodType; this.proLimitAndDate = result.proLimitAndDate; + console.log("proLimitAndDate:"+JSON.stringify(this.proLimitAndDate)); this.coc = result.coc; this.cocId = this.coc.Id; if(this.pageType == 'hospitalorder' && this.agencyProType != 'ET'){ @@ -241,50 +407,98 @@ this.showMyToast('鍒濆鍖栭〉闈㈠け璐�',result.errorMsg,'error'); } }) + .catch(error=>{ + this.showSpinner = false; + console.log("error:"+error); + this.showMyToast('鍒濆鍖栭〉闈㈠け璐�',error,'error'); + }) } - getTableData(){ - for(var i in this.consumableorderdetailsRecordForDT){ - if(!this.consumableorderdetailsRecordForDT[i].oldCheck){ - this.consumableorderdetailsRecordForDT[i]["prodName"] = this.consumableorderdetailsRecordForDT[i].Prod.Name__c; - }else{ - this.consumableorderdetailsRecordForDT[i]["prodName"] = this.consumableorderdetailsRecordForDT[i].esd.Consumable_Product__r.Name__c; + //鎺掑簭 + onHandleSort(event){ + //灏嗗凡缁忛�夊ソ浜嗙殑鏀惧埌鍓嶉潰锛屼笉杩涜鎺掑簭 + console.log('sort'); + if(this.editAble){ + const { fieldName: sortedBy, sortDirection } = event.detail; + const cloneData = [...this.currentRecord]; + cloneData.sort(this.sortBy(sortedBy, sortDirection === 'asc' ? 1 : -1)); + let index = 0; + let selectedRows = this.template.querySelector('c-lex-custom-lightning-datatable').getSelectedRows(); + let selectedRowsIds = []; + for(var i in selectedRows){ + selectedRowsIds.push(selectedRows[i].recordId); } - this.consumableorderdetailsRecordForDT[i]["prodSFDAStatus"] = this.consumableorderdetailsRecordForDT[i].Prod.SFDA_Status__c; - this.consumableorderdetailsRecordForDT[i]["prodCategory3"] = this.consumableorderdetailsRecordForDT[i].Prod.Category3__c; - this.consumableorderdetailsRecordForDT[i]["prodCategory4"] = this.consumableorderdetailsRecordForDT[i].Prod.Category4__c; - this.consumableorderdetailsRecordForDT[i]["prodCategory5"] = this.consumableorderdetailsRecordForDT[i].Prod.Category5__c; - this.consumableorderdetailsRecordForDT[i]["prodIntraTradeList"] = this.consumableorderdetailsRecordForDT[i].Prod.Intra_Trade_List_RMB__c; - this.consumableorderdetailsRecordForDT[i]["consumableCount"] = this.consumableorderdetailsRecordForDT[i].esd.Consumable_count__c; + console.log('selectedRowsIds = ' + JSON.stringify(selectedRowsIds)); + for(var i = 0;i < cloneData.length ; i++){ + if(selectedRowsIds.indexOf(cloneData[i].recordId) != -1){ + if(i != 0){ + let temp = cloneData[index]; + cloneData[index] = cloneData[i]; + cloneData[i] = temp; + } + index++; + } + } + this.currentRecord = cloneData; + this.sortDirection = sortDirection; + this.sortedBy = sortedBy; + }else{ + const { fieldName: sortedBy, sortDirection } = event.detail; + const cloneData = [...this.currentRecord]; + cloneData.sort(this.sortBy(sortedBy, sortDirection === 'asc' ? 1 : -1)); + this.currentRecord = cloneData; + this.sortDirection = sortDirection; + this.sortedBy = sortedBy; } - console.log("ProdName1:"+this.consumableorderdetailsRecordForDT[0].prodName); - console.log("ProdName2:"+this.consumableorderdetailsRecordsview[0].prodName); + } + + sortBy(field, reverse, primer) { + const key = primer + ? function (x) { + return primer(x[field]); + } + : function (x) { + return x[field]; + }; + + return function (a, b) { + a = key(a); + b = key(b); + return reverse * ((a > b) - (b > a)); + }; } + //鏄惁鏈夎鍛� get hasWarning(){ + if(this.warningMsgs == null || this.warningMsgs.length == 0){ + return false; + } if(this.warningMsgs.length > 0){ return true; - }else{ - return false; } } + //鏄惁鏈夐敊璇� get hasError(){ + if(this.errorMsgs == null || this.errorMsgs.length == 0){ + return false; + } if(this.errorMsgs.length > 0){ return true; - }else{ - return false; } } + //鐗逛环change浜嬩欢 offerPriceChange(event){ this.coc.Offers_Price__c = event.detail.value; } + //娑堣�楀搧鍚嶇Оchange浜嬩欢 category1Change(event){ this.category1 = event.detail.value; } + //绗笁鍒嗙被change浜嬩欢 category3Change(event){ this.showSpinner = true; this.category3 = event.detail.value; @@ -304,6 +518,7 @@ }) } + //绗洓鍒嗙被change浜嬩欢 category4Change(event){ this.showSpinner = true; this.category4 = event.detail.value; @@ -322,10 +537,12 @@ }) } + //绗簲鍒嗙被change浜嬩欢 category5Change(event){ this.category5 = event.detail.value; } + //鎼滅储浜у搧 searchProduct(event){ this.showSpinner = true; searchConsumableorderdetails({userWorkLocationStr:this.userWorkLocation, @@ -343,11 +560,16 @@ dealerProductIdStr:JSON.stringify(this.dealerProductId), methodTypeStr:this.pageType, editAbleStr:this.editAble, - consumableorderdetailsRecordsviewStr:JSON.stringify(this.consumableorderdetailsRecordsview)}) + consumableorderdetailsRecordsviewStr:JSON.stringify(this.consumableorderdetailsRecordsview), + proLimitAndDateList : this.proLimitAndDate + }) .then(result=>{ if(result.result == 'Success'){ this.consumableorderdetailsRecordsview = result.consumableorderdetailsRecordsview; - this.getTableData(); + this.currentPage = 1; + this.currentRecord = []; + this.showCurrentReocrd(); + this.getAllChecked(); this.showSpinner = false; this.errorMsgs = result.errorMsgList; this.warningMsgs = result.warningMsgList; @@ -369,6 +591,7 @@ }) } + //娓呴櫎鎼滅储鏍� clear(event){ this.category1 = ''; this.category3 = ''; @@ -391,11 +614,15 @@ dealerProductIdStr:JSON.stringify(this.dealerProductId), methodTypeStr:this.pageType, editAbleStr:this.editAble, - consumableorderdetailsRecordsviewStr:JSON.stringify(this.consumableorderdetailsRecordsview) + consumableorderdetailsRecordsviewStr:JSON.stringify(this.consumableorderdetailsRecordsview), + proLimitAndDateList : this.proLimitAndDate }).then(result=>{ if(result.result == 'Success'){ this.consumableorderdetailsRecordsview = result.consumableorderdetailsRecordsview; - this.getTableData(); + this.currentPage = 1; + this.currentRecord = []; + this.showCurrentReocrd(); + this.getAllChecked(); this.showSpinner = false; this.showMyToast('鎼滅储鎴愬姛',result.errorMsg,'success'); }else{ @@ -410,55 +637,33 @@ }) } - attClick1(event){ - var id = event.currentTarget.dataset.name; - console.log('id:'+id); - const config = { - type: 'standard__webPage', - attributes: { - url: '/detail/'+id, - } - }; - this[NavigationMixin.Navigate](config); - } - - attClick2(event){ - var id = event.currentTarget.dataset.name; - var site = window.location.origin; - console.log('id:'+id); - const config = { - type: 'standard__webPage', - attributes: { - url: site+'/consumable/servlet/servlet.FileDownload?file='+id, - } - }; - this[NavigationMixin.Navigate](config); - } - + //閫夋嫨鎵�鏈� checkAll(event){ for(let i=0, len=this.consumableorderdetailsRecordsview.length; i < len ;i++){ this.consumableorderdetailsRecordsview[i].check = event.target.checked; } } + //閫夋嫨 check(event){ let index = event.target.getAttribute("data-index"); this.consumableorderdetailsRecordsview[index].check = event.target.checked; } - consumableCountChange(event){ - let index = event.target.getAttribute("data-index"); - var value = event.target.value; - this.consumableorderdetailsRecordsview[index].esd.Consumable_count__c = value; - if(isNaN(value)){ - value=0.00; - } - if(value != null && value !=0 && value!=''){ - this.consumableorderdetailsRecordsview[index].check = true; - }else{ - this.consumableorderdetailsRecordsview[index].check = false; - } - } + //閲囪喘鏁伴噺change浜嬩欢 + // consumableCountChange(event){ + // let index = event.target.getAttribute("data-index"); + // var value = event.target.value; + // this.consumableorderdetailsRecordsview[index].esd.Consumable_count__c = value; + // if(isNaN(value)){ + // value=0.00; + // } + // if(value != null && value !=0 && value!=''){ + // this.consumableorderdetailsRecordsview[index].check = true; + // }else{ + // this.consumableorderdetailsRecordsview[index].check = false; + // } + // } //淇濆瓨璁㈠崟 saveOrder(event){ @@ -473,7 +678,10 @@ contactDealerStr:JSON.stringify(this.contactDealer), methodTypeStr:this.pageType, eSetIdStr:this.esetId, - hospitalIdStr : this.hospitalId + hospitalIdStr : this.hospitalId, + contractIdStr : this.contractId, + agencyProType1Str : this.agencyProType1, + OSHFLGStr : this.OSHFLG }).then(result=>{ this.showSpinner = false; if(result.result == 'Success'){ @@ -481,7 +689,7 @@ const config = { type: 'standard__webPage', attributes: { - url: '/lexconsumable?ESetid=' + this.esetId + '&type=' + this.pageType + url: '/lexconsumable?ESetid=' + this.esetId + '&type=' + this.pageType } }; this[NavigationMixin.Navigate](config); @@ -503,11 +711,15 @@ accountidStr:this.accountid, consumableorderdetailsRecordsviewStr:JSON.stringify(this.consumableorderdetailsRecordsview), contactDealerStr:JSON.stringify(this.contactDealer), - methodTypeStr:this.pageType + methodTypeStr:this.pageType, + hospitalIdStr:this.hospitalId, + contractIdStr : this.contractId, + agencyProType1Str : this.agencyProType1, + OSHFLGStr : this.OSHFLG }).then(result=>{ this.showSpinner = false; if(result.result == 'Success'){ - this.esetId = result.esetId; + this.esetId = result.eSetId; const config = { type: 'standard__webPage', attributes: { @@ -659,6 +871,7 @@ }) } + //闄勪欢change浜嬩欢 attChange(event){ if(event.target.files.length > 0) { this.filesUploaded = event.target.files; @@ -667,6 +880,7 @@ } } + //鏄惁鏄剧ず闄勪欢绉婚櫎 get attDelBtn(){ if(this.fileName != '' && this.fileName != null && this.fileName != '璇烽�夋嫨涓�涓枃浠朵笂浼�'){ return true; @@ -675,17 +889,20 @@ } } + //鍏抽棴闄勪欢寮圭獥 closePop(){ this.showAttPop = false; this.filesUploaded = []; this.fileName = null; } + //绉婚櫎闄勪欢 removeAtt(){ this.filesUploaded = []; this.fileName = ''; } + //涓婁紶闄勪欢 uploadAtt(event){ if(this.filesUploaded.length > 0) { this.file = this.filesUploaded[0]; @@ -709,13 +926,13 @@ } } + //璋冪敤涓婁紶闄勪欢鍚庡彴鏂规硶 saveToFile() { - // this.showSpinner = true; + this.showPopSpinner = true; filesUpload({pId:this.esetId, fileName: this.file.name, base64Data: encodeURIComponent(this.fileContents)}) .then(result => { - // this.showSpinner = false; + this.showPopSpinner = false; if(result.result == 'Success'){ - // this.showMyToast('涓婁紶鎴愬姛','','success'); this.closePop(); window.location.reload(); }else{ @@ -724,9 +941,47 @@ } }) .catch(error => { - this.showSpinner = false; + this.showPopSpinner = false; this.showMyToast('涓婁紶澶辫触',error,'error'); }); + } + + //鍒犻櫎闄勪欢 + deleteAtt(event){ + this.showSpinner = true; + var recordId = event.target.getAttribute("data-fileid"); + console.log('attid:'+recordId); + deleteAtt({contentVersionId : recordId}) + .then(result=>{ + this.showSpinner = false; + if(result.result == 'Success'){ + window.location.reload(); + }else{ + console.log("Error:"+result.errorMsg); + this.showMyToast('鍒犻櫎澶辫触',result.errorMsg,'error'); + } + }) + .catch(error=>{ + this.showSpinner = false; + console.log("Error:"+error); + this.showMyToast('鍒犻櫎澶辫触',JSON.stringify(error),'error'); + }) + } + + //棰勮闄勪欢 + previweAtt(event){ + var recordId = event.target.getAttribute("data-fileid"); + console.log(recordId); + this[NavigationMixin.Navigate]({ + type:'standard__namedPage', + attributes:{ + pageName:'filePreview' + }, + state:{ + recordIds: recordId, + selectedRecordId: recordId + } + }); } //鎵撳紑鎼滅储寮圭獥锛屽苟鍒濆鍖栧脊绐� @@ -774,6 +1029,7 @@ }) } + //鍖婚櫌鍚嶇Оchange searchNameHosChange(event){ this.searchNameHos = event.detail.value; } @@ -793,6 +1049,14 @@ // this.chooseHospital = hosName; // this.chooseHospitalId = hosid; // } + + changeHos(event){ + this.hospitalName = event.detail.value; + } + + changeCon(event){ + this.contractName = event.detail.value; + } chooseHos(event){ const row = event.detail.row; @@ -831,7 +1095,10 @@ }).then(result=>{ if(result.result == 'Success'){ this.consumableorderdetailsRecordsview = result.consumableorderdetailsRecordsview; - this.getTableData(); + this.currentPage = 1; + this.currentRecord = []; + this.showCurrentReocrd(); + this.getAllChecked(); this.showMyToast('鎼滅储鎴愬姛',result.errorMsg,'success'); }else{ console.log("Error:"+result.errorMsg); @@ -855,7 +1122,7 @@ //鎵撳紑鍚堝悓妫�绱㈠脊绐楀苟鍒濆鍖� showSearchCon(){ - initContract({ctype:this.agencyProType}) + initContract({ctype:this.agencyProType1}) .then(result=>{ if(result.result == 'Success'){ this.showConPop = true; @@ -878,7 +1145,7 @@ //妫�绱㈠悎鍚� searchCon(){ - searchContract({searchName:this.searchNameCon, accountId:this.accountid, ctype:this.agencyProType}) + searchContract({searchName:this.searchNameCon, accountId:this.accountid, ctype:this.agencyProType1,OSHFLGStr : this.OSHFLG}) .then(result=>{ if(result.result == 'Success'){ this.contractList = result.attList; @@ -947,7 +1214,10 @@ }).then(result=>{ if(result.result == 'Success'){ this.consumableorderdetailsRecordsview = result.consumableorderdetailsRecordsview; - this.getTableData(); + this.currentPage = 1; + this.currentRecord = []; + this.showCurrentReocrd(); + this.getAllChecked(); this.showMyToast('鎼滅储鎴愬姛',result.errorMsg,'success'); }else{ console.log("Error:"+result.errorMsg); @@ -969,12 +1239,150 @@ } } - showMyToast(title,message,variant){ - const evt = new ShowToastEvent({ - title : title, - message: message, - variant: variant - }); - this.dispatchEvent(evt); + showMyToast(title, message, variant) { + console.log('show custom message'); + var iconName = ''; + var content = ''; + if(variant == 'success'){ + iconName = 'utility:check'; + }else{ + iconName = 'utility:error'; + } + if(message != ''){ + content = '<h2><strong>'+title+'<strong/></h2><h5>'+message+'</h5>'; + }else{ + content = '<h2><strong>'+title+'<strong/></h2>'; + } + this.template.querySelector('c-common-toast'). + showToast(variant,content,iconName,10000); + // var mode; + // if(this.isNoteStay){ + // mode ='sticky'; + // }else{ + // mode = 'dismissable'; + // } + // const evt = new ShowToastEvent({ + // title: title, + // message: message, + // variant: variant, + // mode: mode + // }); + // this.dispatchEvent(evt); + } + + //鍒嗛〉 + showCurrentReocrd(){ + var startIndex = 0; + var endIndex = 0; + console.log('len:'+this.consumableorderdetailsRecordsview.length); + if(this.consumableorderdetailsRecordsview != null && this.consumableorderdetailsRecordsview.length > 0){ + var currentRecord = []; + var currentCount = 0; + var mu = this.consumableorderdetailsRecordsview.length % this.pageSize; + if(this.currentPage == this.totalPage){ + if(mu != 0){ + currentCount = mu; + }else{ + currentCount = this.pageSize; + } + }else{ + currentCount = this.pageSize; + } + console.log('this.totalPage:'+this.totalPage); + console.log('this.pageSize:'+this.pageSize); + console.log('mu:'+mu); + console.log('currentCount:'+currentCount); + startIndex = (this.currentPage - 1) * this.pageSize; + endIndex = parseInt(startIndex) + parseInt(currentCount) - 1; + console.log('startIndex:'+startIndex); + console.log('endIndex:'+endIndex); + if(this.editAble){ + for(var i in this.currentRecord){ + if(this.currentRecord[i].check){ + currentRecord.push(this.currentRecord[i]); + } + } + } + for(var i = startIndex; i <= endIndex; i++){ + var count = 0; + for(var j in this.currentRecord){ + if(this.consumableorderdetailsRecordsview[i].recordId == this.currentRecord[j].recordId){ + count++; + } + } + if(count == 0){ + currentRecord.push(this.consumableorderdetailsRecordsview[i]); + } + } + this.recordStart = startIndex + 1; + this.recordEnd = endIndex + 1; + this.currentRecord = currentRecord; + }else{ + this.currentPage = 0; + this.currentRecord = []; + } + } + + get prePage(){ + return this.currentPage - 1; + } + + get nextPage(){ + return this.currentPage + 1; + } + + get totalPage(){ + if(this.consumableorderdetailsRecordsview.length % this.pageSize == 0){ + return Math.trunc(this.consumableorderdetailsRecordsview.length / this.pageSize); + }else{ + return Math.trunc(this.consumableorderdetailsRecordsview.length / this.pageSize) + 1; + } + } + + get totalRecords(){ + return this.consumableorderdetailsRecordsview.length; + } + + //绗竴椤� + goFirstPage(){ + this.currentPage = 1; + this.showCurrentReocrd(); + } + + //鏈�鍚庝竴椤� + goLastPage(){ + this.currentPage = this.totalPage; + this.showCurrentReocrd(); + } + + //涓婁竴椤� + prePageClick(){ + this.currentPage = this.currentPage - 1; + this.showCurrentReocrd(); + } + + //涓嬩竴椤� + nextPageClick(){ + this.currentPage = this.currentPage + 1; + this.showCurrentReocrd(); + } + + //page size change + pageSizeChange(event){ + console.log('pagesize:'+event.detail); + this.pageSize = event.detail; + this.currentPage = 1; + this.currentRecord = []; + this.showCurrentReocrd(); + } + + //涓婁竴椤垫寜閽槸鍚isable + get previousButtonDisabled() { + return this.currentPage == 1 || this.currentPage == 0; + } + + //涓嬩竴椤垫寜閽槸鍚isable + get nextButtonDisabled() { + return this.currentPage == this.totalPage; } } \ No newline at end of file -- Gitblit v1.9.1