|
|
@@ -71,9 +71,22 @@
|
|
|
<view class="form-section">
|
|
|
<view class="form-title">在服药物/治疗</view>
|
|
|
<view v-for="(med, idx) in medRows" :key="idx" class="med-row">
|
|
|
- <input class="med-name" type="text" v-model="med.name" placeholder="药物品牌,如 立普妥" />
|
|
|
- <input class="med-time" type="text" v-model="med.time" placeholder="服药时间,如 早饭后一次" />
|
|
|
- <text class="med-del" @click="removeMed(idx)">删除</text>
|
|
|
+ <view class="med-line">
|
|
|
+ <input class="med-name" type="text" v-model="med.name" placeholder="药物品牌,如 立普妥" />
|
|
|
+ <text class="med-del" @click="removeMed(idx)">删除</text>
|
|
|
+ </view>
|
|
|
+ <view class="med-line">
|
|
|
+ <picker mode="date" fields="month" :value="med.startDate || currentMonth" :end="monthEnd" @change="onMedStartChange(idx, $event)">
|
|
|
+ <view class="med-picker">{{ med.startDate ? med.startDate : '选择开始日期' }}</view>
|
|
|
+ </picker>
|
|
|
+ <text class="med-forget" @click="onForgetClick(idx)">记不清</text>
|
|
|
+ </view>
|
|
|
+ <view class="med-line" v-if="med.durationText">
|
|
|
+ <text class="med-duration">已服时长:{{ med.durationText }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="med-line">
|
|
|
+ <input class="med-time" type="text" v-model="med.time" placeholder="服药时间,如 早饭后一次" />
|
|
|
+ </view>
|
|
|
</view>
|
|
|
<text class="add-link" @click="addMed">+ 添加药物/治疗</text>
|
|
|
</view>
|
|
|
@@ -201,7 +214,7 @@ export default {
|
|
|
this.load()
|
|
|
},
|
|
|
methods: {
|
|
|
- getCustomKey: function(i) { return 'c' + i },
|
|
|
+ getSelKey: function(i) { return 's' + i },
|
|
|
load: function() {
|
|
|
var self = this
|
|
|
getHealthStatus().then(function(res) {
|
|
|
@@ -233,8 +246,16 @@ export default {
|
|
|
var arr = JSON.parse(json || '[]')
|
|
|
if (arr instanceof Array) {
|
|
|
arr.forEach(function(item) {
|
|
|
- if (item.name && self.diseaseNames.indexOf(item.name) < 0) {
|
|
|
- self.diseaseNames.push(item.name)
|
|
|
+ if (item.name && self.selectedNames.indexOf(item.name) < 0) {
|
|
|
+ self.selectedDiseases.push({
|
|
|
+ name: item.name,
|
|
|
+ diagnosedAt: item.diagnosedAt || '',
|
|
|
+ custom: false
|
|
|
+ })
|
|
|
+ var gk = self.findGroupKey(item.name)
|
|
|
+ if (gk && self.expandedGroups.indexOf(gk) < 0) {
|
|
|
+ self.expandedGroups.push(gk)
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
@@ -246,35 +267,100 @@ export default {
|
|
|
var arr = JSON.parse(json || '[]')
|
|
|
if (arr instanceof Array) {
|
|
|
arr.forEach(function(item) {
|
|
|
- list.push({ name: item.name || '', time: item.time || '' })
|
|
|
+ list.push({
|
|
|
+ name: item.name || '',
|
|
|
+ startDate: item.startDate || '',
|
|
|
+ durationText: item.durationText || '',
|
|
|
+ time: item.time || ''
|
|
|
+ })
|
|
|
})
|
|
|
}
|
|
|
} catch (e) {}
|
|
|
- if (list.length === 0) list.push({ name: '', time: '' })
|
|
|
+ if (list.length === 0) list.push({ name: '', startDate: '', durationText: '', time: '' })
|
|
|
return list
|
|
|
},
|
|
|
- toggleDisease: function(tag) {
|
|
|
- var idx = this.diseaseNames.indexOf(tag)
|
|
|
- if (idx >= 0) this.diseaseNames.splice(idx, 1)
|
|
|
- else this.diseaseNames.push(tag)
|
|
|
+ toggleGroup: function(key) {
|
|
|
+ var idx = this.expandedGroups.indexOf(key)
|
|
|
+ if (idx >= 0) this.expandedGroups.splice(idx, 1)
|
|
|
+ else this.expandedGroups.push(key)
|
|
|
+ },
|
|
|
+ findGroupKey: function(name) {
|
|
|
+ for (var i = 0; i < this.diseaseGroups.length; i++) {
|
|
|
+ var items = this.diseaseGroups[i].items
|
|
|
+ for (var j = 0; j < items.length; j++) {
|
|
|
+ if (items[j].name === name) return this.diseaseGroups[i].key
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ''
|
|
|
+ },
|
|
|
+ toggleDisease: function(name) {
|
|
|
+ var idx = -1
|
|
|
+ for (var i = 0; i < this.selectedDiseases.length; i++) {
|
|
|
+ if (this.selectedDiseases[i].name === name) { idx = i; break }
|
|
|
+ }
|
|
|
+ if (idx >= 0) {
|
|
|
+ this.selectedDiseases.splice(idx, 1)
|
|
|
+ } else {
|
|
|
+ this.selectedDiseases.push({ name: name, diagnosedAt: '', custom: false })
|
|
|
+ var gk = this.findGroupKey(name)
|
|
|
+ if (gk && this.expandedGroups.indexOf(gk) < 0) {
|
|
|
+ this.expandedGroups.push(gk)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ showRiskTip: function(name) {
|
|
|
+ uni.showModal({
|
|
|
+ title: '菌群报告关联',
|
|
|
+ content: '「' + name + '」与肠道菌群报告相关,勾选后出方案时可结合菌群报告风险值评估。',
|
|
|
+ showCancel: false
|
|
|
+ })
|
|
|
},
|
|
|
addCustomDisease: function() {
|
|
|
var name = (this.diseaseInput || '').trim()
|
|
|
if (!name) return
|
|
|
- if (this.diseaseNames.indexOf(name) < 0) {
|
|
|
- this.diseaseNames.push(name)
|
|
|
- this.customDiseases.push(name)
|
|
|
+ if (this.selectedNames.indexOf(name) < 0) {
|
|
|
+ this.selectedDiseases.push({ name: name, diagnosedAt: '', custom: true })
|
|
|
}
|
|
|
this.diseaseInput = ''
|
|
|
},
|
|
|
- removeCustomDisease: function(idx) {
|
|
|
- var name = this.customDiseases[idx]
|
|
|
- this.customDiseases.splice(idx, 1)
|
|
|
- var i = this.diseaseNames.indexOf(name)
|
|
|
- if (i >= 0) this.diseaseNames.splice(i, 1)
|
|
|
+ removeSelected: function(idx) {
|
|
|
+ this.selectedDiseases.splice(idx, 1)
|
|
|
+ },
|
|
|
+ onDiagChange: function(idx, e) {
|
|
|
+ this.selectedDiseases[idx].diagnosedAt = e.detail.value
|
|
|
},
|
|
|
addMed: function() {
|
|
|
- this.medRows.push({ name: '', time: '' })
|
|
|
+ this.medRows.push({ name: '', startDate: '', durationText: '', time: '' })
|
|
|
+ },
|
|
|
+ onMedStartChange: function(idx, e) {
|
|
|
+ var start = e.detail.value
|
|
|
+ this.medRows[idx].startDate = start
|
|
|
+ this.medRows[idx].durationText = this.calcDuration(start)
|
|
|
+ },
|
|
|
+ onForgetClick: function(idx) {
|
|
|
+ var self = this
|
|
|
+ uni.showModal({
|
|
|
+ title: '记不清开始日期',
|
|
|
+ editable: true,
|
|
|
+ placeholderText: '如:约 3 个月',
|
|
|
+ success: function(res) {
|
|
|
+ if (res.confirm && res.content) {
|
|
|
+ self.medRows[idx].durationText = res.content.trim()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ calcDuration: function(startDate) {
|
|
|
+ if (!startDate) return ''
|
|
|
+ var parts = startDate.split('-')
|
|
|
+ if (parts.length !== 2) return ''
|
|
|
+ var sy = parseInt(parts[0], 10)
|
|
|
+ var sm = parseInt(parts[1], 10)
|
|
|
+ var now = new Date()
|
|
|
+ var months = (now.getFullYear() - sy) * 12 + (now.getMonth() + 1 - sm)
|
|
|
+ if (months < 1) months = 1
|
|
|
+ if (months < 12) return '已服 ' + months + ' 个月'
|
|
|
+ return '已服 ' + Math.floor(months / 12) + ' 年'
|
|
|
},
|
|
|
removeMed: function(idx) {
|
|
|
if (this.medRows.length > 1) this.medRows.splice(idx, 1)
|