316 lines
8.8 KiB
JavaScript
316 lines
8.8 KiB
JavaScript
import Toast from '@vant/weapp/toast/toast';
|
||
import { API } from './../../../utils/network/api'
|
||
const api = new API()
|
||
const app = getApp()
|
||
Page({
|
||
data: {
|
||
navbarData: {
|
||
showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
|
||
title: '在线开方', //导航栏 中间的标题
|
||
},
|
||
height: app.globalData.height,
|
||
zhenduan_popshow: false,
|
||
drugs_popshow: false,
|
||
note_popshow: false,
|
||
disease_class_name: "",
|
||
zhenduan_search_list: [],
|
||
zhenduan_list: [],
|
||
note_columns: ['杭州', '宁波', '温州', '嘉兴', '湖州'],
|
||
drugs_box_item_list:[],
|
||
drug_content_show: false,
|
||
search_drug_list_empty: true,
|
||
search_drug_list: [],
|
||
select_drug_name: "",
|
||
select_drug_id: "",
|
||
save_durg_product_id: "",
|
||
save_durg_prescription_product_num: "",
|
||
save_durg_single_unit: "",
|
||
save_durg_single_use: "",
|
||
save_durg_packaging_unit: "",
|
||
save_durg_frequency_use: "",
|
||
save_durg_available_days: "",
|
||
order_inquiry_id: "",
|
||
doctor_advice: "",
|
||
doctors_advice_focus: false,
|
||
case_detail: {}
|
||
},
|
||
onDoctorsAdviceFocus(){
|
||
this.setData({
|
||
doctors_advice_focus: true
|
||
})
|
||
},
|
||
onLoad(options){
|
||
let order_inquiry_id = options.order_inquiry_id;
|
||
//获取患者问诊病例
|
||
api.getDoctorInquiryCase({order_inquiry_id: order_inquiry_id}).then(response => {
|
||
console.log(response);
|
||
this.setData({
|
||
case_detail: response.data
|
||
})
|
||
}).catch(errors => {console.error(errors);})
|
||
this.setData({
|
||
order_inquiry_id: order_inquiry_id
|
||
})
|
||
},
|
||
select_drug(e){
|
||
this.setData({
|
||
drug_content_show: true,
|
||
select_drug_name: e.currentTarget.dataset.product_name,
|
||
select_drug_id: e.currentTarget.dataset.product_id,
|
||
save_durg_product_id: e.currentTarget.dataset.product_id
|
||
});
|
||
},
|
||
showPopup() {
|
||
this.setData({ drugs_popshow: true });
|
||
},
|
||
|
||
onClose() {
|
||
var _this = this;
|
||
this.setData({
|
||
drugs_popshow: false,
|
||
});
|
||
|
||
setTimeout(function(){
|
||
_this.setData({
|
||
drug_content_show: false,
|
||
search_value: ""
|
||
});
|
||
},1000)
|
||
},
|
||
|
||
showNotePopup() {
|
||
this.setData({ note_popshow: true });
|
||
},
|
||
|
||
onCloseNote() {
|
||
this.setData({ note_popshow: false });
|
||
},
|
||
|
||
onConfirmNote(event) {
|
||
const { picker, value, index } = event.detail;
|
||
Toast(`当前值:${value}, 当前索引:${index}`);
|
||
this.setData({ note_popshow: false });
|
||
},
|
||
|
||
onCancelNote(event) {
|
||
const { picker, value, index } = event.detail;
|
||
Toast(`当前值:${value}, 当前索引:${index}`);
|
||
this.setData({ note_popshow: false });
|
||
},
|
||
|
||
onChangeNote(event) {
|
||
const { picker, value, index } = event.detail;
|
||
Toast(`当前值:${value}, 当前索引:${index}`);
|
||
},
|
||
|
||
saveDrugs(){
|
||
console.log("saveDrugs");
|
||
|
||
let product_id = this.data.save_durg_product_id;
|
||
this.delDrugBox(product_id);
|
||
|
||
let save_durg = {};
|
||
save_durg.select_drug_name = this.data.select_drug_name;
|
||
save_durg.product_id = this.data.save_durg_product_id;
|
||
save_durg.prescription_product_num = this.data.save_durg_prescription_product_num;
|
||
save_durg.single_unit = this.data.save_durg_single_unit;
|
||
save_durg.single_use = this.data.save_durg_single_use;
|
||
save_durg.packaging_unit = this.data.save_durg_packaging_unit;
|
||
save_durg.frequency_use = this.data.save_durg_frequency_use;
|
||
save_durg.available_days = this.data.save_durg_available_days;
|
||
let list = this.data.drugs_box_item_list;
|
||
list.push(save_durg);
|
||
this.setData({
|
||
drugs_box_item_list: list,
|
||
drugs_popshow: false,
|
||
select_drug_name: "",
|
||
drug_content_show: false,
|
||
search_drug_list: [],
|
||
save_durg_product_id: "",
|
||
save_durg_prescription_product_num: "",
|
||
save_durg_single_unit: "",
|
||
save_durg_single_use: "",
|
||
save_durg_packaging_unit: "",
|
||
save_durg_frequency_use: "",
|
||
save_durg_available_days: ""
|
||
})
|
||
|
||
},
|
||
showZhenDuan(){
|
||
this.setData({
|
||
zhenduan_popshow: true
|
||
})
|
||
},
|
||
onZhenDuanChange(e){
|
||
console.log(e)
|
||
let name = e.detail;
|
||
this.setData({
|
||
zhenduan_search_list: []
|
||
})
|
||
if(name){
|
||
this.search();
|
||
}
|
||
},
|
||
search(){
|
||
//搜索诊断
|
||
let params = {};
|
||
params.disease_class_name = this.data.disease_class_name;
|
||
api.getBasicDiseaseSearch(params).then(response => {
|
||
console.log(response);
|
||
this.setData({
|
||
zhenduan_search_list: response.data
|
||
})
|
||
}).catch(errors => {
|
||
console.error(errors);
|
||
})
|
||
},
|
||
searchDrug(){
|
||
//搜索药品
|
||
let params = {};
|
||
params.product_keyword = this.data.select_drug_name;
|
||
api.getBasicProductSearch(params).then(response => {
|
||
console.log(response);
|
||
if(response.data.length > 0){
|
||
this.setData({
|
||
search_drug_list_empty: false,
|
||
search_drug_list: response.data,
|
||
})
|
||
}
|
||
}).catch(errors => {
|
||
console.error(errors);
|
||
})
|
||
},
|
||
onDrugChange(e){
|
||
console.log(e.detail);
|
||
let name = e.detail;
|
||
this.setData({
|
||
search_drug_list_empty: true,
|
||
search_drug_list: []
|
||
})
|
||
if(name){
|
||
this.searchDrug();
|
||
}
|
||
},
|
||
onZhenduanClose(){
|
||
this.setData({
|
||
zhenduan_popshow: false
|
||
})
|
||
},
|
||
addZhenDuan(e){
|
||
let disease_class_name = e.currentTarget.dataset.disease_class_name;
|
||
let disease_class_id = e.currentTarget.dataset.disease_class_id;
|
||
console.log("disease_class_name: ", disease_class_name);
|
||
console.log("disease_class_id: ", disease_class_id);
|
||
|
||
let disease_obj = {};
|
||
disease_obj.disease_class_name = disease_class_name;
|
||
disease_obj.disease_class_id = disease_class_id;
|
||
let list = this.data.zhenduan_list;
|
||
let find_index = list.findIndex(item => {
|
||
return item.disease_class_id == disease_class_id
|
||
});
|
||
if(find_index == -1){
|
||
list.push(disease_obj);
|
||
}
|
||
this.setData({
|
||
zhenduan_list: list,
|
||
zhenduan_popshow: false
|
||
})
|
||
},
|
||
delZhenDuan(e){
|
||
let disease_class_id = e.currentTarget.dataset.disease_class_id;
|
||
console.log("disease_class_id: ", disease_class_id);
|
||
let list = this.data.zhenduan_list;
|
||
let find_index = list.findIndex(item => {
|
||
return item.disease_class_id == disease_class_id
|
||
});
|
||
console.log("find_idex: ", find_index)
|
||
list.splice(find_index, 1);
|
||
this.setData({
|
||
zhenduan_list: list
|
||
})
|
||
},
|
||
go(e){
|
||
let url = e.currentTarget.dataset.url;
|
||
console.log(url);
|
||
app.go(url);
|
||
},
|
||
editDrug(e){
|
||
let product_id = e.currentTarget.dataset.product_id;
|
||
console.log(product_id);
|
||
let list = this.data.drugs_box_item_list;
|
||
let drug = list.find(item => {
|
||
return item.product_id == product_id;
|
||
})
|
||
console.log(drug);
|
||
this.setData({
|
||
drugs_popshow: true,
|
||
select_drug_name: drug.select_drug_name,
|
||
drug_content_show: true,
|
||
save_durg_product_id: drug.product_id,
|
||
save_durg_prescription_product_num: drug.prescription_product_num,
|
||
save_durg_single_unit: drug.single_unit,
|
||
save_durg_single_use: drug.single_use,
|
||
save_durg_packaging_unit: drug.packaging_unit,
|
||
save_durg_frequency_use: drug.frequency_use,
|
||
save_durg_available_days: drug.available_days
|
||
})
|
||
},
|
||
delDrug(e){
|
||
let product_id = e.currentTarget.dataset.product_id;
|
||
console.log(product_id);
|
||
this.delDrugBox(product_id);
|
||
},
|
||
delDrugBox(product_id){
|
||
let list = this.data.drugs_box_item_list;
|
||
let drug_index = list.findIndex(item => {
|
||
return item.product_id == product_id;
|
||
})
|
||
console.log(drug_index);
|
||
if(drug_index > -1){
|
||
list.splice(drug_index, 1);
|
||
this.setData({
|
||
drugs_box_item_list: list
|
||
})
|
||
}
|
||
},
|
||
getAdvice(e){
|
||
console.log(e.detail.value)
|
||
this.setData({
|
||
doctor_advice: e.detail.value
|
||
})
|
||
},
|
||
postDoctorPrescription(){//新增处方
|
||
console.log("postDoctorPrescription postDoctorPrescription");
|
||
let params = {};
|
||
params.order_inquiry_id = this.data.order_inquiry_id;
|
||
params.doctor_advice = this.data.doctor_advice;
|
||
let prescription_icd = [];
|
||
this.data.zhenduan_list.forEach(item => {
|
||
prescription_icd.push(item.disease_class_id);
|
||
})
|
||
params.prescription_icd = prescription_icd;
|
||
params.prescription_product = this.data.drugs_box_item_list;
|
||
|
||
console.log(params);
|
||
|
||
api.postDoctorPrescription(params).then(response => {
|
||
console.log(response);
|
||
|
||
}).catch(errors => {console.error(errors);})
|
||
},
|
||
putDoctorPrescription(){//修改处方
|
||
let params = {};
|
||
api.putDoctorPrescription(params).then(response => {
|
||
console.log(response);
|
||
|
||
}).catch(errors => {console.error(errors);})
|
||
},
|
||
getDoctorPrescriptionInfo(){//获取处方详情
|
||
let params = {};
|
||
api.getDoctorPrescriptionInfo(params).then(response => {
|
||
console.log(response);
|
||
|
||
}).catch(errors => {console.error(errors);})
|
||
}
|
||
}) |