Browse Source

promise

master
pengjun 5 months ago
parent
commit
601e7632aa
  1. 170
      src/components/patientRegister/PatientRegisterEdit.vue

170
src/components/patientRegister/PatientRegisterEdit.vue

@ -899,7 +899,7 @@ export default {
};
},
async created() {
created() {
//
let userPriv = window.sessionStorage.getItem('userPriv')
if (userPriv) this.pagePriv.privs = deepCopy(getPagePriv(this.pagePriv.routeUrlorPageName))
@ -929,7 +929,7 @@ export default {
this.formInit = deepCopy(this.form)
//
await this.dictInit()
this.dictInit()
},
//
@ -982,17 +982,16 @@ export default {
btnTest() {
// console.log('form', this.form)
},
//
async dictInit() {
try {
dictInit() {
let sysParmId = "patient_register_occ_check_id"
let sysParm = await postapi('/api/app/SysParmValue/GetSysParmValueBySysParmId', { sysParmId })
if (sysParm.code > -1) {
this.patient_register_occ_check_id = sysParm.data
}
} catch (error) {
console.log('sysParmId:patient_register_occ_check_id', error)
}
postapi('/api/app/SysParmValue/GetSysParmValueBySysParmId', { sysParmId })
.then(res => {
if (res.code > -1) this.patient_register_occ_check_id = res.data
})
//
getapi("/api/app/sex").then((res) => {
@ -1203,7 +1202,8 @@ export default {
},
// form
async initFormData(patientRegisterId) {
initFormData(patientRegisterId) {
return new Promise((resolve, reject) => {
this.peisid = window.sessionStorage.getItem('peisid');
let customerOrgId, customerOrgName, customerOrgParentId
if (this.patientRegister.query.customerOrgId) {
@ -1224,22 +1224,29 @@ export default {
this.form.customerOrgId = customerOrgId //
this.form.customerOrgParentId = customerOrgParentId //
this.form.customerOrgName = customerOrgName
this.handleFormData()
this.completeFlag = '0'
this.handleFormData().then(() => {
resolve()
})
} else {
// let res = await getapi(`/api/app/patient-register/${patientRegisterId}`)
postapi('/api/app/patientregister/getinfoorpatient', { patientRegisterId }).then(res => {
postapi('/api/app/patientregister/getinfoorpatient', { patientRegisterId })
.then(res => {
if (res.code > -1) {
// this.form = res.data checkbox
this.form = Object.assign({}, this.form, res.data)
this.completeFlag = this.form.completeFlag
this.handleFormData()
this.handleFormData().then(() => resolve())
}
})
.catch(() => resolve())
}
})
},
handleFormData() {
return new Promise((resolve, reject) => {
//
this.changeMedicalTypeId(this.form.medicalTypeId)
if (this.form.isPatientOccupationalDisease == 'Y') {
@ -1258,8 +1265,14 @@ export default {
// /
this.changeCustomerOrgId(this.form.customerOrgId)
.then(() => {
//
this.dataTransOpts.refresh.register_check_asbitem.OnlyRefreshAsbitem++
})
.finally(() => {
resolve()
})
})
},
@ -1279,37 +1292,27 @@ export default {
}
},
//
async changeCustomerOrgId(v) {
//
changeCustomerOrgId(v) {
// reslove
return new Promise((resolve, reject) => {
console.log('changeCustomerOrgId', v, this.form.customerOrgParentId)
let customerOrgId = "", customerOrgParentId = ""
if (Array.isArray(v) && v.length > 0) {
customerOrgId = v[v.length - 1]
customerOrgParentId = v[0]
} else {
customerOrgId = v // ID
customerOrgParentId = await this.getParentCustomerOrgId(customerOrgId)
// let pids = getTreePids(this.patientRegister.customerOrgTreeAll, "treeChildren", "parentId", "id", customerOrgId)
// if (Array.isArray(pids) && pids.length > 0) {
// if (pids.length == 1) {
// customerOrgParentId = customerOrgId
// } else {
// customerOrgParentId = pids[1]
// }
// }
}
// if (!this.preCustomerOrgId)
this.preCustomerOrgId = customerOrgId
if (customerOrgParentId) {
if (customerOrgParentId == this.dict.personOrgId) {
//
this.form.customerOrgRegisterId = "00000000-0000-0000-0000-000000000001"
} else {
//
this.getParentCustomerOrgId(v)
.then(res => {
if (res) {
customerOrgParentId = res
// "00000000-0000-0000-0000-000000000001"
this.getCustomerOrgRegisterList(customerOrgParentId)
}
.then(() => {
// / ID
if (customerOrgParentId != this.form.customerOrgParentId) {
this.form.customerOrgGroupId = null
@ -1319,6 +1322,7 @@ export default {
e.isBelongGroupPackage = 'N'
});
//
if (customerOrgParentId == this.dict.personOrgId) {
this.patientRegister.customerOrgGroup = []
}
@ -1329,28 +1333,53 @@ export default {
this.changeCustomerOrgGroupId()
}
}
return resolve(customerOrgParentId)
})
} else {
resolve(customerOrgParentId)
}
})
.catch(() => {
resolve(customerOrgParentId)
})
})
},
// ID
async getParentCustomerOrgId(customerOrgId) {
getParentCustomerOrgId(v) {
return new Promise((resolve, reject) => {
let customerOrgParentId = null
if (!customerOrgId) return customerOrgParentId
if (Array.isArray(v) && v.length > 1) {
customerOrgParentId = v[0]
return resolve(customerOrgParentId)
} else {
let customerOrgId = v
if (Array.isArray(v) && v.length == 1) customerOrgId = v[0]
if (!customerOrgId) return resolve(customerOrgParentId)
if (typeof customerOrgId == 'string') {
try {
let res = await getapi(`/api/app/customer-org/parent/${customerOrgId}`)
if (res.code != -1) customerOrgParentId = res.data
} catch (error) {
// console.log('ID', error)
}
getapi(`/api/app/customer-org/parent/${customerOrgId}`)
.then(res => {
if (res.code > -1) customerOrgParentId = res.data
})
.finally(() => {
return resolve(customerOrgParentId)
})
} else if (customerOrgId.length > 0) {
customerOrgParentId = customerOrgId[0]
return resolve(customerOrgParentId)
}
}
return customerOrgParentId
})
},
//
// "00000000-0000-0000-0000-000000000001"
getCustomerOrgRegisterList(customerOrgParentId) {
return new Promise((resolve, reject) => {
if (customerOrgParentId == this.dict.personOrgId) {
//
this.form.customerOrgRegisterId = "00000000-0000-0000-0000-000000000001"
return resolve()
} else {
//
getapi(`/api/app/customerorgregister/getlistincustomerorgid?CustomerOrgId=${customerOrgParentId}`)
.then(res => {
@ -1366,11 +1395,20 @@ export default {
}
// /api/app/customerorggroup/getlistinfilter?CustomerOrgRegisterId=${this.form.customerOrgRegisterId}
this.patientRegister.customerOrgGroup = []
if (this.form.customerOrgRegisterId && this.form.customerOrgRegisterId != '00000000-0000-0000-0000-000000000001') return postapi('/api/app/CustomerOrgGroup/GetListForPatentRegisterByFilter', { customerOrgRegisterId: this.form.customerOrgRegisterId }) //
if (this.form.customerOrgRegisterId && this.form.customerOrgRegisterId != '00000000-0000-0000-0000-000000000001') {
//
postapi('/api/app/CustomerOrgGroup/GetListForPatentRegisterByFilter', { customerOrgRegisterId: this.form.customerOrgRegisterId })
.then(res2 => {
if (res2 && res2.code != -1) {
this.patientRegister.customerOrgGroup = res2.data;
}
}).then(res => {
if (res && res.code != -1) {
this.patientRegister.customerOrgGroup = res.data;
})
} return
}
})
.finally(() => {
resolve()
})
}
})
},
@ -1904,7 +1942,7 @@ export default {
});
this.form.poisonIds = poisonIds
resolve('')
}else{
} else {
reject(res.message)
}
})
@ -2837,7 +2875,7 @@ export default {
},
// --寿
async close_dialogWin_WebBookingMzak() {
close_dialogWin_WebBookingMzak() {
// console.log('this.dataTransOpts.tableS.appoint_patient_register',this.dataTransOpts.tableS.appoint_patient_register)
// console.log('this.dataTransOpts.tableM.appoint_register_asbitem',this.dataTransOpts.tableM.appoint_register_asbitem)
//
@ -2849,13 +2887,16 @@ export default {
this.patientRegister.query.customerOrgId = appoint_patient_register.customerOrgId
this.patientRegister.query.CustomerOrgParentId = appoint_patient_register.customerOrgId
this.form.customerOrgId = [appoint_patient_register.customerOrgId] //
let customerOrgParentId = await this.getParentCustomerOrgId(appoint_patient_register.customerOrgId)
this.form.customerOrgParentId = customerOrgParentId
await this.initFormData(this.dataTransOpts.tableS.patient_register.id)
this.form.customerOrgName = customerOrgParentId
let customerOrgParentId = ''
this.getParentCustomerOrgId(appoint_patient_register.customerOrgId)
.then(res => {
customerOrgParentId = res
this.form.customerOrgParentId = customerOrgParentId
return this.initFormData(this.dataTransOpts.tableS.patient_register.id)
})
.then(() => {
// this.form.customerOrgName = customerOrgParentId
// "appointPatientRegisterId": "string",
// "personId": "string",
// "personName": "string",
@ -2891,8 +2932,8 @@ export default {
// 寿
// personnelTypeId --> positionName
// dict.personnelType" :key="item.id" :label="item.displayName"
let lfind = arrayExistObj(this.dict.personnelType,'displayName',appoint_patient_register.positionName)
if(lfind > -1) this.form.personnelTypeId = this.dict.personnelType[lfind].id
let lfind = arrayExistObj(this.dict.personnelType, 'displayName', appoint_patient_register.positionName)
if (lfind > -1) this.form.personnelTypeId = this.dict.personnelType[lfind].id
console.log('this.form', JSON.stringify(this.form))
@ -2926,12 +2967,7 @@ export default {
if (this.form.customerOrgGroupId) this.changeCustomerOrgGroupId()
this.changeIdNo() //
//
setTimeout(() => {
this.form.customerOrgGroupId = appoint_patient_register.customerOrgGroupId
}, 500);
})
},

Loading…
Cancel
Save