|
@ -9,7 +9,7 @@ |
|
|
<view v-if="colItem.type === 1"> |
|
|
<view v-if="colItem.type === 1"> |
|
|
<u-radio-group v-model="colItem.value" class="flex items-center"> |
|
|
<u-radio-group v-model="colItem.value" class="flex items-center"> |
|
|
<u-radio |
|
|
<u-radio |
|
|
@change="change($event, index, itemIndex, colItem.type)" |
|
|
@change="change(radioIndex, index, itemIndex, colItem.type)" |
|
|
v-for="(radioItem, radioIndex) in colItem.radioList" |
|
|
v-for="(radioItem, radioIndex) in colItem.radioList" |
|
|
:key="radioIndex" |
|
|
:key="radioIndex" |
|
|
:name="radioItem" |
|
|
:name="radioItem" |
|
@ -20,7 +20,13 @@ |
|
|
</view> |
|
|
</view> |
|
|
<!-- 数字输入框 --> |
|
|
<!-- 数字输入框 --> |
|
|
<view v-if="colItem.type === 3" class="pr-7"> |
|
|
<view v-if="colItem.type === 3" class="pr-7"> |
|
|
<u-input v-model="colItem.value" type="number" :clearable="false" input-align="right" /> |
|
|
<u-input |
|
|
|
|
|
v-model="colItem.value" |
|
|
|
|
|
type="number" |
|
|
|
|
|
:clearable="false" |
|
|
|
|
|
input-align="right" |
|
|
|
|
|
@blur="change(colItem.value, index, itemIndex, colItem.type)" |
|
|
|
|
|
/> |
|
|
</view> |
|
|
</view> |
|
|
<!-- 数字输入框+单选 --> |
|
|
<!-- 数字输入框+单选 --> |
|
|
<view v-if="colItem.type === 4" class="flex flex-nowrap items-center"> |
|
|
<view v-if="colItem.type === 4" class="flex flex-nowrap items-center"> |
|
@ -32,8 +38,9 @@ |
|
|
type="number" |
|
|
type="number" |
|
|
input-align="center" |
|
|
input-align="center" |
|
|
@focus="cancelChecked(index, itemIndex)" |
|
|
@focus="cancelChecked(index, itemIndex)" |
|
|
|
|
|
@blur="change(colItem.value, index, itemIndex, colItem.type)" |
|
|
/> |
|
|
/> |
|
|
<u-checkbox-group @change="change($event, index, itemIndex, colItem.type)"> |
|
|
<u-checkbox-group @change="change($event, index, itemIndex, 99)"> |
|
|
<u-checkbox v-model="colItem.checked" shape="circle">未服用</u-checkbox> |
|
|
<u-checkbox v-model="colItem.checked" shape="circle">未服用</u-checkbox> |
|
|
</u-checkbox-group> |
|
|
</u-checkbox-group> |
|
|
</view> |
|
|
</view> |
|
@ -41,10 +48,14 @@ |
|
|
</template> |
|
|
</template> |
|
|
<view class="w-full h-2 bg-gray-100" v-if="index !== medicineInfo.length - 1"></view> |
|
|
<view class="w-full h-2 bg-gray-100" v-if="index !== medicineInfo.length - 1"></view> |
|
|
</view> |
|
|
</view> |
|
|
|
|
|
<view class="p-4"> |
|
|
|
|
|
<u-button type="primary" v-if="show" @click="addMedicine">添加</u-button> |
|
|
|
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
|
|
|
import { mapGetters } from 'vuex'; |
|
|
import { medicineInfo } from '@/config/yyInfo'; |
|
|
import { medicineInfo } from '@/config/yyInfo'; |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
@ -59,16 +70,96 @@ export default { |
|
|
}, |
|
|
}, |
|
|
bodyStyle: { paddingLeft: '1rem' }, |
|
|
bodyStyle: { paddingLeft: '1rem' }, |
|
|
medicineInfo, |
|
|
medicineInfo, |
|
|
|
|
|
show: true, |
|
|
|
|
|
params: {}, |
|
|
}; |
|
|
}; |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
computed: mapGetters('project', ['projectId']), |
|
|
|
|
|
|
|
|
|
|
|
mounted() { |
|
|
|
|
|
this.queryMedicine(); |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
methods: { |
|
|
methods: { |
|
|
cancelChecked(index, itemIndex) { |
|
|
cancelChecked(index, itemIndex) { |
|
|
this.medicineInfo[index].date[itemIndex].checked = false; |
|
|
this.medicineInfo[index].date[itemIndex].checked = false; |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
change(e, index, itemIndex, type) { |
|
|
change(e, index, itemIndex, type) { |
|
|
console.log('e, index, itemIndex, type: ', e, index, itemIndex, type); |
|
|
let item = this.medicineInfo[index].date[itemIndex]; |
|
|
this.medicineInfo[index].date[itemIndex].value = e; |
|
|
if (type === 99) { |
|
|
|
|
|
item.checked = true; |
|
|
|
|
|
item.value = null; |
|
|
|
|
|
this.params[item.label] = '未服用'; |
|
|
|
|
|
} else { |
|
|
|
|
|
item.value = e; |
|
|
|
|
|
this.params[item.label] = item.value; |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 查询药物使用 |
|
|
|
|
|
* @param { String } projectId 项目id |
|
|
|
|
|
*/ |
|
|
|
|
|
async queryMedicine() { |
|
|
|
|
|
try { |
|
|
|
|
|
const params = { projectId: this.projectId }; |
|
|
|
|
|
const data = await this.$u.api.queryMedicine(params); |
|
|
|
|
|
if (!data || !data.id) { |
|
|
|
|
|
this.show = true; |
|
|
|
|
|
} else { |
|
|
|
|
|
this.show = false; |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('error: ', error); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 添加药物使用 |
|
|
|
|
|
* @param { Object } params |
|
|
|
|
|
*/ |
|
|
|
|
|
async addMedicine() { |
|
|
|
|
|
try { |
|
|
|
|
|
const params = this.params; |
|
|
|
|
|
if (!this.validationRequired(params)) return; |
|
|
|
|
|
params.projectId = this.projectId; |
|
|
|
|
|
await this.$u.api.addMedicine(params); |
|
|
|
|
|
this.$emit('showToast', 'success', '药物使用添加成功'); |
|
|
|
|
|
this.show = false; |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('error: ', error); |
|
|
|
|
|
this.$emit('showToast', 'error', '药物使用添加失败'); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 验证必填项 |
|
|
|
|
|
validationRequired() { |
|
|
|
|
|
let isComplete = true; |
|
|
|
|
|
for (let i = 0; i < this.medicineInfo.length; i++) { |
|
|
|
|
|
const info = this.medicineInfo[i]; |
|
|
|
|
|
for (let j = 0; j < info.date.length; j++) { |
|
|
|
|
|
const item = info.date[j]; |
|
|
|
|
|
if (item.type !== 4) { |
|
|
|
|
|
if (!item.value) { |
|
|
|
|
|
this.$t.ui.showToast(`请填写${item.name}`); |
|
|
|
|
|
isComplete = false; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
if (!item.value && !item.checked) { |
|
|
|
|
|
this.$t.ui.showToast(`请填写${item.name}`); |
|
|
|
|
|
isComplete = false; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (!isComplete) { |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (isComplete) return true; |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}; |
|
|
}; |
|
|