NurseStationApp/pages/disease/disease.vue

93 lines
2.2 KiB
Vue
Raw Normal View History

2022-10-17 11:21:23 +08:00
<template>
<view class="app">
<view class="items">
2022-10-18 08:54:14 +08:00
<view class="item"
2022-11-11 17:23:23 +08:00
:style="disease.find(e => e.diseaseName == item.diseaseName)?'background-color: #4C7BC9;color: #ffffff;':''"
2022-10-18 08:54:14 +08:00
v-for='(item,index) in diseaselist' :key="index" @tap='choicedisease(item)'>
2022-10-17 11:21:23 +08:00
{{item.diseaseName}}
</view>
<view class="other">
<span>其他:</span>
2022-11-11 17:23:23 +08:00
<u-input type="text" placeholder='请填写' v-model="diseaseother.diseaseName" />
2022-10-17 11:21:23 +08:00
</view>
2022-10-18 08:54:14 +08:00
<view class="btn" @tap='goinformation'>
2022-10-17 11:21:23 +08:00
提交
</view>
</view>
</view>
</template>
<script>
import {
getDiseaseInfo
} from '@/api/disease/index.js'
export default {
data() {
return {
2022-10-18 08:54:14 +08:00
diseaselist: [], //疾病列表
2022-11-11 14:19:07 +08:00
disease: [],
2022-11-11 17:23:23 +08:00
diseaseother: {
diseaseName: '',
},
2022-10-17 11:21:23 +08:00
};
},
methods: {
2022-10-18 08:54:14 +08:00
//选择疾病
choicedisease(item) {
2022-11-11 17:23:23 +08:00
if (this.disease.findIndex(e => e.diseaseName == item.diseaseName) == -1) {
2022-10-18 08:54:14 +08:00
this.disease.push(item)
} else {
2022-11-11 17:23:23 +08:00
this.disease = this.disease.filter(e => e.diseaseName != item.diseaseName)
2022-10-18 08:54:14 +08:00
}
2022-11-11 17:23:23 +08:00
// if (this.disease.length > 1) {
// this.disease = this.disease.filter(e => e.id != 9999)
// }
2022-10-18 08:54:14 +08:00
},
//获取疾病列表
2022-10-17 11:21:23 +08:00
diseaseinfo() {
2022-11-11 17:23:23 +08:00
try {
const value = uni.getStorageSync('patientId');
if (value) {
getDiseaseInfo(value).then(res => {
this.diseaselist = res.data;
// this.diseaselist.unshift({
// id: 9999,
// diseaseName: '无'
// })
})
}
} catch (e) {}
2022-10-17 11:21:23 +08:00
},
2022-10-18 08:54:14 +08:00
//跳转回信息完善页面
goinformation() {
2022-11-11 17:23:23 +08:00
if (this.diseaseother.diseaseName != '' || this.diseaseother.diseaseName) {
this.disease.push(this.diseaseother)
}
2022-11-23 16:41:09 +08:00
this.diseaselist.forEach(e => {
if (this.diseaseother.diseaseName == e.diseaseName) {
this.disease = this.disease.filter(el => el.diseaseName != e.diseaseName)
this.disease.push(e)
}
})
2022-10-18 08:54:14 +08:00
uni.$emit('disease', {
disease: JSON.stringify(this.disease)
})
uni.navigateBack({
delta: 1
});
}
},
2022-11-11 17:23:23 +08:00
onShow() { //开局方法
2022-10-18 08:54:14 +08:00
this.diseaseinfo()
2022-11-11 17:23:23 +08:00
},
onLoad(options) { //传参接受
2022-10-18 08:54:14 +08:00
this.disease = JSON.parse(options.diseaseInfoList)
2022-11-11 17:23:23 +08:00
console.log(this.disease)
2022-10-18 08:54:14 +08:00
},
2022-10-17 11:21:23 +08:00
}
</script>
<style lang="scss">
2022-11-11 17:23:23 +08:00
@import './disease.scss';
2022-10-17 11:21:23 +08:00
</style>