fix: 新功能开发完善。

This commit is contained in:
tianyongbao
2024-10-28 13:09:06 +08:00
parent df34762355
commit 66c776c753
48 changed files with 5845 additions and 1633 deletions

View File

@@ -26,10 +26,11 @@
inputAlign="right" border="none"></u--input>
<u-icon slot="right" name="arrow-down"></u-icon>
</u-form-item>
<u-form-item label="药名称" prop="name" required >
<u--input v-model="form.name" placeholder="请填写用药名称"
inputAlign="right" border="none"></u--input>
</u-form-item>
<u-form-item label="药名称" prop="medicalName" required @click="handleMedical">
<u--input v-model="form.medicalName" disabled disabledColor="#ffffff" placeholder="请选择药品名称"
inputAlign="right" border="none"></u--input>
<u-icon slot="right" name="arrow-down"></u-icon>
</u-form-item>
<u-form-item label="药品来源" prop="resourceName" required @click="handleResource">
<u--input v-model="form.resourceName" disabled disabledColor="#ffffff" placeholder="请选择药品来源"
inputAlign="right" border="none"></u--input>
@@ -48,7 +49,11 @@
<u--input v-model="form.dosage" placeholder="请填写用药剂量"
inputAlign="right" border="none"></u--input>
</u-form-item>
<u-form-item label="用药单位" prop="unitName" required @click="handleUnit">
<u--input v-model="form.unitName" disabled disabledColor="#ffffff" placeholder="请选择用药单位"
inputAlign="right" border="none"></u--input>
<u-icon slot="right" name="arrow-down"></u-icon>
</u-form-item>
<u-form-item label="备注" prop="remark" labelPosition="top">
<u--textarea v-model="form.remark" placeholder="请填写备注" border="none" autoHeight inputAlign="right" count
maxlength="2000" style="padding:18rpx 0;"></u--textarea>
@@ -72,6 +77,10 @@
@confirm="handleMarTypeConfirm"></u-picker>
<u-picker itemHeight="88" :show="showHealthRecord" :columns="healthRecordList" keyName="name" @cancel="handHealthRecordCancel"
@confirm="handHealthRecordConfirm"></u-picker>
<u-picker itemHeight="88" :show="showMedical" :columns="medicalList" keyName="shortNameBrandPackaging" @cancel="handleMedicalCancel"
@confirm="handleMedicalConfirm"></u-picker>
<u-picker itemHeight="88" :show="showUnit" :columns="unitList" keyName="dictLabel" @cancel="handleUnitCancel"
@confirm="handleUnitConfirm"></u-picker>
<u-datetime-picker
:show="datePickShow"
mode="datetime"
@@ -87,6 +96,7 @@
import { getMarRecord, addMarRecord, updateMarRecord } from '@/api/health/marRecord'
import { listPerson, getPerson } from '@/api/health/person'
import { listHealthRecord } from '@/api/health/healthRecord'
import { listMedicineBasic, getMedicineBasic } from '@/api/health/medicineBasic'
const { proxy } = getCurrentInstance()
import { getDicts } from '@/api/system/dict/data.js'
import dayjs from 'dayjs'
@@ -95,18 +105,27 @@ import {onLoad,onReady} from "@dcloudio/uni-app";
import {reactive ,toRefs,ref,computed ,getCurrentInstance }from "vue";
const datePickShow = ref(false)
const showPerson = ref(false)
const flag = ref('add')
const showHealthRecord = ref(false)
const title = ref("用药记录")
const healthRecordList = ref([])
const personList = ref([])
const medicalList = ref([])
const showMedical = ref(false)
const marTypeList = ref([])
const showMarType = ref(false)
const resourceList = ref([])
const showResource = ref(false)
const placeList = ref([])
const showPlace = ref(false)
const unitList = ref([])
const showUnit = ref(false)
const data = reactive({
form: {
id: null,
@@ -137,33 +156,57 @@ queryHealthRecordParams: {
personId:null,
pageSize: 1000
},
queryMedicineParams: {
pageNum: 1,
treatmentType: null,
pageSize: 1000
},
rules: {
healthRecordName: [{ required: true, message: '健康档案不能为空', trigger:['change', 'blur'] }],
personName: [{ required: true, message: '人员不能为空', trigger: ['change', 'blur'] }],
name: [{ required: true, message: '药名称不能为空', trigger: ['change', 'blur'] }],
type: [{ required: true, message: '用药类型不能为空', trigger: ['change', 'blur'] }],
medicalName: [{ required: true, message: '药名称不能为空', trigger: ['change', 'blur'] }],
marTypeName: [{ required: true, message: '用药类型不能为空', trigger: ['change', 'blur'] }],
resource: [{ required: true, message: '药品来源不能为空', trigger: ['change', 'blur'] }],
place: [{ required: true, message: '用药地点不能为空', trigger: ['change', 'blur'] }],
dosage: [{ type: 'number', required: true, message: '用药剂量不能为空', trigger: ['change', 'blur'] }],
dosingTime: [{ required: true, message: '用药时间不能为空', trigger: ['change', 'blur'] }]
}
})
const { form, queryPersonParams, queryHealthRecordParams, rules} = toRefs(data)
const { form, queryPersonParams, queryHealthRecordParams,queryMedicineParams, rules} = toRefs(data)
onLoad((option) => {
form.value.id = option.id
if(form.value.id!=null){
flag.value = option.flag
if(flag.value==null){
if(form.value.id!=null){
title.value="用药记录-修改"
}else{
title.value="用药记录-新增"
}
}else{
title.value="用药记录-复制"
}
getData()
})
onReady(() => {
form.value.dosingTime = dayjs(new Date().getTime()).format("YYYY-MM-DD HH:mm:ss")
})
function dictStr(val, arr) {
let str = ''
arr.map(item => {
if (item.dictValue === val) {
str = item.dictLabel
}
})
return str
}
function getData() {
listMedicineBasic(queryMedicineParams.value).then((response) => {
medicalList.value = [response.rows]
})
listPerson(queryPersonParams.value).then((response) => {
personList.value = [response.rows]
if(response.rows.length>0){
@@ -182,6 +225,10 @@ function getData() {
// 类型
getDicts('mar_type').then(res => {
marTypeList.value =[res.data]
})
// 类型
getDicts('medical_unit').then(res => {
unitList.value =[res.data]
})
// 类型
getDicts('mar_resource').then(res => {
@@ -197,31 +244,26 @@ function getData() {
if(form.value.id!=null){
getMarRecord(form.value.id).then(res => {
form.value = res.data
form.value.medicalName=form.value.name
getDicts('mar_place').then(result => {
form.value.placeName=dictStr(form.value.place, result.data)
})
// 药品来源
getDicts('mar_resource').then(result => {
form.value.resourceName=dictStr(form.value.resource, result.data)
})
// 药品来源
getDicts('medical_unit').then(result => {
form.value.unitName=dictStr(form.value.unit, result.data)
})
// 用药类型
getDicts('mar_type').then(result => {
getDicts('mar_type').then(result => {
form.value.marTypeName=dictStr(form.value.type, result.data)
})
})
}
}
function dictStr(val, arr) {
let str = ''
arr.map(item => {
if (item.dictValue === val) {
str = item.dictLabel
}
})
return str
}
function handlePerson() {
if (personList.value[0].length === 0) {
proxy.$refs['uToast'].show({
@@ -239,6 +281,10 @@ function handlePersonConfirm(e) {
queryHealthRecordParams.value.personId=e.value[0].id
listHealthRecord(queryHealthRecordParams.value).then((response) => {
healthRecordList.value = [response.rows]
if(response.rows.length>0){
form.value.healthRecordName= response.rows[0].name
form.value.healthRecordId = response.rows[0].id
}
showPerson.value = false
})
@@ -246,6 +292,34 @@ function handlePersonConfirm(e) {
function handlePersonCancel() {
showPerson.value = false
}
function handleMedical() {
if (medicalList.value[0].length === 0) {
proxy.$refs['uToast'].show({
message: '药品为空 ', type: 'warning'
})
} else {
showMedical.value = true
}
}
function handleMedicalConfirm(e) {
form.value.medicalName = e.value[0].shortNameBrandPackaging
form.value.name = e.value[0].shortNameBrandPackaging
form.value.medicineId = e.value[0].id
getMedicineBasic(e.value[0].id).then((response) => {
form.value.unit = response.data.unit
// 药品来源
getDicts('medical_unit').then(result => {
form.value.unitName=dictStr( response.data.unit, result.data)
})
form.value.contentUnit = response.data.contentUnit
})
showMedical.value = false
}
function handleMedicalCancel() {
showMedical.value = false
}
function handHealthRecord() {
if (healthRecordList.value[0].length === 0) {
proxy.$refs['uToast'].show({
@@ -282,6 +356,24 @@ function handleResource() {
showResource.value = false
}
function handleUnit() {
if (unitList.value[0].length === 0) {
proxy.$refs['uToast'].show({
message: '用药单位为空 ', type: 'warning'
})
} else {
showUnit.value = true
}
}
function handleUnitConfirm(e) {
form.value.unitName = e.value[0].dictLabel
form.value.unit = e.value[0].dictValue
showUnit.value = false
}
function handleUnitCancel() {
showUnit.value = false
}
function handlePlace() {
if (placeList.value[0].length === 0) {
proxy.$refs['uToast'].show({
@@ -312,6 +404,15 @@ function handleResource() {
function handleMarTypeConfirm(e) {
form.value.marTypeName = e.value[0].dictLabel
form.value.type = e.value[0].dictValue
queryMedicineParams.value.treatmentType = e.value[0].dictValue
form.value.medicalName = ""
form.value.name = ""
form.value.medicineId = null
listMedicineBasic(queryMedicineParams.value).then((response) => {
medicalList.value = [response.rows]
})
showMarType.value = false
}
function handleMarTypeCancel() {
@@ -329,13 +430,25 @@ function datePickConfirm(e) {
function submit() {
proxy.$refs['uForm'].validate().then(() => {
if (form.value.id != null) {
updateMarRecord(form.value).then(res => {
if(flag.value==null){
updateMarRecord(form.value).then(res => {
proxy.$refs['uToast'].show({
message: '修改成功', complete() {
uni.navigateTo({ url: `/pages/health/marRecord/list` })
}
})
})
}else {
form.value.id == null
addMarRecord(form.value).then(res => {
proxy.$refs['uToast'].show({
message: '新增成功', complete() {
uni.navigateTo({ url: `/pages/health/marRecord/list` })
}
})
})
}
}else {
addMarRecord(form.value).then(res => {
proxy.$refs['uToast'].show({