import { LightningElement, track } from 'lwc';
|
|
|
import GetInspectById from '@salesforce/apex/InspectCheckController.GetInspectById';
|
import { refreshApex } from '@salesforce/apex';
|
import GetIrrelevantReasons from '@salesforce/apex/InspectCheckController.GetIrrelevantReasons';
|
import UpdateInformation from '@salesforce/apex/InspectCheckController.UpdateInformation';
|
|
|
import SaveData from '@salesforce/apex/InspectCheckController.SaveData';
|
|
|
|
import SearchYY from '@salesforce/apex/InspectCheckController.SearchYY';
|
import SearchZLKS from '@salesforce/apex/InspectCheckController.SearchZLKS';
|
import SearchPTKS from '@salesforce/apex/InspectCheckController.SearchPTKS';
|
|
|
import SearchParent from '@salesforce/apex/InspectCheckController.SearchParent';
|
|
import SearchAccountById from '@salesforce/apex/InspectCheckController.SearchAccountById';
|
|
import {ShowToastEvent} from 'lightning/platformShowToastEvent';
|
|
export default class test01 extends LightningElement {
|
|
//提示
|
Tongzhishow=false;
|
SaveShowText="操作成功";
|
Alert(content){
|
this.SaveShowText = content;
|
this.Tongzhishow = true;
|
setTimeout(()=>{
|
this.Tongzhishow = false;
|
this.SaveShowText = "";
|
},3000)
|
}
|
|
IsLoading = false;
|
OnLoading(flag){
|
this.IsLoading = flag;
|
}
|
|
//显示与隐藏
|
isShi = false;
|
isFou = false;
|
isOther = false;
|
|
//End
|
|
|
|
getQueryVariable(variable)
|
{
|
var query = window.location.search.substring(1);
|
var vars = query.split("&");
|
for (var i=0;i<vars.length;i++) {
|
var pair = vars[i].split("=");
|
if(pair[0] == variable){return pair[1];}
|
}
|
return(false);
|
}
|
|
connectedCallback(){
|
var paramId = this.getQueryVariable('id');
|
if (paramId == null || paramId == '') {
|
return ;
|
}
|
|
this.GetInspectByIdFn(paramId);
|
this.GetIrrelevantReasonsFn();
|
|
|
|
}
|
GetInspectByIdFn(Id)
|
{
|
GetInspectById({Id:Id}).then(result=>{
|
var response=JSON.parse(result);
|
if (response!=undefined && response.length == 1) {
|
var tempData = response[0];
|
|
|
this.checkDatas(tempData);
|
|
this.InspectData = tempData;
|
|
|
}
|
|
})
|
}
|
|
checkDatas(tempData)
|
{
|
if (tempData.irrelevantReasonOther__c == undefined || tempData.irrelevantReasonOther__c == '') {
|
tempData.irrelevantReasonOther__c = '';
|
}
|
if (tempData.irrelevantReasons__c == '其他(手动填写)') {
|
this.isOther = true;
|
}
|
if (tempData.IsRelateProject__c == "是") {
|
this.isShi = true;
|
this.isFou = false;
|
this.isOther = false;
|
//加载关联数据
|
// this.yyInit();
|
// this.InitZLKS();
|
// this.InitPTKS();
|
this.InitSearchDatas(tempData);
|
|
}else if(tempData.IsRelateProject__c == "否"){
|
this.isShi = false;
|
this.isFou = true;
|
}
|
}
|
|
InitSearchDatas(tempData){
|
this.OnLoading(true);
|
var temp = 3;
|
if (tempData.Hospital__c != undefined) {
|
SearchAccountById({Id:tempData.Hospital__c}).then(result=>{
|
var datas = JSON.parse(result);
|
this.template.querySelector('[data-parent-id="lookup1"]').setvalue(datas[0].Name);
|
temp--;
|
if (temp <= 0) {
|
this.OnLoading(false);
|
}
|
})
|
|
this.yyId = tempData.Hospital__c;
|
this.InitZLKS();
|
}else {temp --;}
|
if (tempData.department__c != undefined) {
|
SearchAccountById({Id:tempData.department__c}).then(result=>{
|
var datas = JSON.parse(result);
|
this.template.querySelector('[data-parent-id="lookup2"]').setvalue(datas[0].Name);
|
temp--;
|
if (temp <= 0) {
|
this.OnLoading(false);
|
}
|
})
|
this.ZLKSId = tempData.department__c;
|
this.InitPTKS();
|
}else {temp --;}
|
if (tempData.account__c != undefined) {
|
SearchAccountById({Id:tempData.account__c}).then(result=>{
|
var datas = JSON.parse(result);
|
this.template.querySelector('[data-parent-id="lookup3"]').setvalue(datas[0].Name);
|
temp--;
|
if (temp <= 0) {
|
this.OnLoading(false);
|
}
|
})
|
}else {temp --;}
|
|
if (temp <= 0) {
|
this.OnLoading(false);
|
}
|
}
|
GetIrrelevantReasonsFn()
|
{
|
GetIrrelevantReasons().then(result=>{
|
var response=JSON.parse(result);
|
this.IrrelevantReasons = response;
|
})
|
}
|
|
@track InspectData = {}; //数据
|
IrrelevantReasons=[]; //相关性检查
|
|
|
|
RelateOption=[
|
{label:"是",value:"是"},
|
{label:"否",value:"否"},
|
]
|
IsRelateProjectShow = false; //是否输入
|
//是否关联
|
handleRelationFn(event)
|
{
|
// this.IsRelateProjectShow = true;
|
|
var value = event.target.value;
|
this.InspectData.IsRelateProject__c = value;
|
|
if (value == "是") {
|
this.isShi = true;
|
this.isFou = false;
|
this.isOther = false;
|
|
this.InitSearchDatas(this.InspectData);
|
}
|
|
if (value == "否") {
|
this.isShi = false;
|
this.isFou = true;
|
|
if (this.InspectData.irrelevantReasons__c == '其他(手动填写)') {
|
this.isOther = true;
|
}else{
|
this.isOther = false;
|
}
|
}
|
}
|
|
//不相关理由
|
handleIrrelevantFn(event)
|
{
|
var value = event.target.value;
|
this.InspectData.irrelevantReasons__c = value;
|
if (value == "其他(手动填写)") {
|
this.isOther = true;
|
}else{
|
this.isOther = false;
|
}
|
}
|
|
otherData = ""
|
//其他理由
|
handleOtherIrrelevantFn(event)
|
{
|
var value = event.target.value;
|
this.otherData = value;
|
this.InspectData.irrelevantReasonOther__c = this.otherData ;
|
|
}
|
|
|
|
xgxLy ="slds-form-element"; //error = slds-form-element slds-has-error
|
xgxLyFlag = false;
|
|
bxgLy ="slds-form-element"; //error = slds-form-element slds-has-error
|
bxgLyFlag = false;
|
|
qtLy="slds-form-element";
|
qtLyFlag = false;
|
saveFn(){
|
var flag = true;
|
|
if (this.isShi==true) {
|
var id1 = this.template.querySelector('[data-parent-id="lookup1"]').getvalue();
|
var id2 = this.template.querySelector('[data-parent-id="lookup2"]').getvalue();
|
var id3= this.template.querySelector('[data-parent-id="lookup3"]').getvalue();
|
|
if (id1 == undefined || id1 == '') {
|
this.InspectData.Hospital__c == undefined;
|
}
|
if (id2 == undefined || id2 == '') {
|
this.InspectData.department__c == undefined;
|
}
|
if (id3 == undefined || id3 == '') {
|
this.InspectData.account__c == undefined;
|
}
|
}
|
|
|
if (this.InspectData.IsRelateProject__c == undefined || this.InspectData.IsRelateProject__c == "" ) {
|
this.xgxLy = "slds-form-element slds-has-error"
|
this.xgxLyFlag = true;
|
flag = false;
|
}else{
|
this.xgxLy = "slds-form-element"
|
this.xgxLyFlag = false;
|
}
|
|
if (this.InspectData.irrelevantReasons__c == undefined | this.InspectData.irrelevantReasons__c == "" && this.InspectData.IsRelateProject__c != undefined && this.InspectData.IsRelateProject__c == "否") {
|
this.bxgLy = "slds-form-element slds-has-error"
|
this.bxgLyFlag = true;
|
flag = false;
|
}else{
|
this.bxgLy = "slds-form-element"
|
this.bxgLyFlag = false;
|
}
|
if ( this.InspectData.irrelevantReasons__c == '其他(手动填写)' && this.InspectData.irrelevantReasonOther__c == "") {
|
this.qtLy="slds-form-element slds-has-error";
|
this.qtLyFlag = true;
|
flag = false;
|
}else{
|
this.qtLy="slds-form-element";
|
this.qtLyFlag = false;
|
}
|
debugger;
|
|
if (this.InspectData.Hospital__c == undefined && this.InspectData.IsRelateProject__c == "是" ) {
|
this.isErrorShowYY = true;
|
flag = false;
|
}else{
|
this.isErrorShowYY = false;
|
}
|
if (this.InspectData.department__c == undefined && this.InspectData.IsRelateProject__c == "是" ) {
|
this.isErrorShowZLKS = true;
|
flag = false;
|
}else{
|
this.isErrorShowZLKS = false;
|
}
|
|
if (flag) {
|
this.OnLoading(true);
|
debugger;
|
console.warn(this.InspectData);
|
SaveData({JsonData:JSON.stringify(this.InspectData)}).then(()=>{
|
this.OnLoading(false);
|
this.Alert("保存成功");
|
});
|
}
|
}
|
|
clear(flag){
|
if (flag == 0) {
|
this.InspectData.department__c = undefined;
|
this.InspectData.account__c = undefined;
|
this.ZLKSId = '';
|
this.PTKSId = '';
|
this.template.querySelector('[data-parent-id="lookup2"]').setvalue("");
|
this.template.querySelector('[data-parent-id="lookup3"]').setvalue("");
|
this.InitZLKS();
|
this.InitPTKS();
|
}
|
|
if (flag == 1) {
|
this.InspectData.account__c = undefined;
|
this.PTKSId = '';
|
this.template.querySelector('[data-parent-id="lookup3"]').setvalue("");
|
this.InitPTKS();
|
}
|
}
|
//关联医院
|
option = [{lableOne:"Name",lableTwo:"Acc_Record_Type__c"}]
|
searchdata=[];
|
isErrorShowYY=false;
|
onsearchchange(event){
|
var searchContentStr = event.detail.searchContent;
|
SearchYY({content:searchContentStr}).then(response=>{
|
var datas = JSON.parse(response);
|
this.searchdata = datas;
|
if (this.isShi==true) {
|
this.template.querySelector('[data-parent-id="lookup1"]').refreshdata(this.searchdata);
|
}
|
})
|
}
|
yyId = '';
|
selected(event)
|
{
|
var a = this.InspectData;
|
debugger;
|
console.warn(event.detail.selectdata.Id);
|
this.yyId = event.detail.selectdata.Id;
|
this.InitZLKS();
|
|
this.InspectData.Hospital__c = this.yyId;
|
|
this.clear(0);
|
}
|
|
yyInit()
|
{
|
SearchYY({content:undefined}).then(response=>{
|
var datas = JSON.parse(response);
|
this.searchdata = datas;
|
if (this.isShi==true) {
|
this.template.querySelector('[data-parent-id="lookup1"]').refreshdata(this.searchdata);
|
}
|
})
|
}
|
|
//关联医院
|
|
|
|
//关联战略科室
|
optionZLKS = [{lableOne:"Name",lableTwo:"Acc_Record_Type__c"}]
|
searchdataZLKS=[];
|
isErrorShowZLKS = false;
|
onsearchchangeZLKS(event){
|
var searchContentStr = event.detail.searchContent;
|
SearchZLKS({content:searchContentStr,ParentId:this.yyId}).then(response=>{
|
var datas = JSON.parse(response);
|
this.searchdataZLKS = datas;
|
if (this.isShi==true) {
|
this.template.querySelector('[data-parent-id="lookup2"]').refreshdata(this.searchdataZLKS);
|
}
|
})
|
|
}
|
ZLKSId = '';
|
selectedZLKS(event)
|
{
|
console.warn(event.detail.selectdata.Id);
|
this.ZLKSId = event.detail.selectdata.Id;
|
this.template.querySelector('[data-parent-id="lookup3"]').setvalue("");
|
this.InitPTKS();
|
this.InspectData.department__c = this.ZLKSId;
|
this.OnLoading(true);
|
SearchParent({Id:this.ZLKSId }).then(result=>{
|
var data = JSON.parse(result);
|
if (data.yy!=undefined && data.yy.Id!=undefined && data.yy.Name!=undefined) {
|
this. yyId = data.yy.Id;
|
this.template.querySelector('[data-parent-id="lookup1"]').setvalue(data.yy.Name);
|
this.InspectData.Hospital__c = this.yyId;
|
this.InitZLKS();
|
this.OnLoading(false);
|
}
|
})
|
|
this.clear(1);
|
}
|
|
InitZLKS()
|
{
|
SearchZLKS({content:undefined,ParentId:this.yyId}).then(response=>{
|
var datas = JSON.parse(response);
|
this.searchdataZLKS = datas;
|
if (this.isShi==true) {
|
this.template.querySelector('[data-parent-id="lookup2"]').refreshdata(this.searchdataZLKS);
|
}
|
})
|
}
|
|
//关联战略科室
|
|
|
//关联普通科室
|
optionPTKS = [{lableOne:"Name",lableTwo:"Acc_Record_Type__c"}]
|
searchdataPTKS=[];
|
|
onsearchchangePTKS(event){
|
var searchContentStr = event.detail.searchContent;
|
SearchPTKS({content:searchContentStr,ParentId:this.ZLKSId}).then(response=>{
|
var datas = JSON.parse(response);
|
this.searchdataPTKS = datas;
|
if (this.isShi==true) {
|
this.template.querySelector('[data-parent-id="lookup3"]').refreshdata(this.searchdataPTKS);
|
}
|
})
|
}
|
PTKSId = '';
|
selectedPTKS(event)
|
{
|
console.warn(event.detail.selectdata.Id);
|
this.PTKSId = event.detail.selectdata.Id;
|
this.InspectData.account__c = this.PTKSId;
|
this.OnLoading(true);
|
SearchParent({Id:this.PTKSId }).then(result=>{
|
var data = JSON.parse(result);
|
if (data.yy!=undefined && data.yy.Id!=undefined && data.yy.Name!=undefined) {
|
this. yyId = data.yy.Id;
|
this.template.querySelector('[data-parent-id="lookup1"]').setvalue(data.yy.Name);
|
this.InspectData.Hospital__c = this. yyId;
|
this.InitZLKS();
|
}
|
if (data.zlxs!=undefined && data.zlxs.Id!=undefined && data.zlxs.Name!=undefined) {
|
this. ZLKSId = data.zlxs.Id;
|
this.template.querySelector('[data-parent-id="lookup2"]').setvalue(data.zlxs.Name);
|
this.InspectData.department__c = this.ZLKSId;
|
this.InitPTKS();
|
}
|
this.OnLoading(false);
|
})
|
}
|
|
InitPTKS()
|
{
|
SearchPTKS({content:undefined,ParentId:this.ZLKSId}).then(response=>{
|
var datas = JSON.parse(response);
|
this.searchdataPTKS = datas;
|
if (this.isShi==true) {
|
this.template.querySelector('[data-parent-id="lookup3"]').refreshdata(this.searchdataPTKS);
|
}
|
})
|
}
|
|
//关联普通科室
|
|
|
}
|