diff --git a/src/views/biosafety/disinfect/index.vue b/src/views/biosafety/disinfect/index.vue index ace824e..66547ac 100644 --- a/src/views/biosafety/disinfect/index.vue +++ b/src/views/biosafety/disinfect/index.vue @@ -1,324 +1,516 @@ +/* ------------------ 下拉数据 ------------------ */ +const barns = ref([]) +const presOptions = ref([]) +const units = ref([]) +const usages = ref([]) +const medicines = ref([]) + +/* 校验规则 */ +const rules = { + sheepfoldIds: [{ required: true, message: '请选择羊舍', trigger: 'change' }], + datetime: [{ required: true, message: '请选择日期', trigger: 'change' }] +} + +/* 处方选择事件 - 新增 */ +function handleSelectPrescription(id) { + if (!id) return + getPrescription(id).then(res => { + usageDetails.value = res.data?.swPresDetailList?.map(i => ({ + mediId: i.mediId, + dosage: i.dosage, + unit: i.unitId, + usageId: i.usageId + })) || [] + }) +} + +/* 处方选择事件 - 修改 */ +function handleSelectPrescriptionEdit(id) { + if (!id) return + getPrescription(id).then(res => { + editDetails.value = res.data?.swPresDetailList?.map(i => ({ + mediId: i.mediId, + dosage: i.dosage, + unit: i.unitId, + usageId: i.usageId + })) || [] + }) +} + +/* 明细添加行 - 新增 */ +function handleAddDetail() { + usageDetails.value.push({ mediId: null, dosage: 0, unit: null, usageId: null, manufacturer: null, batchNumber: null }) +} + +/* 明细添加行 - 修改 */ +function handleAddDetailEdit() { + editDetails.value.push({ mediId: null, dosage: 0, unit: null, usageId: null, manufacturer: null, batchNumber: null }) +} + +/* ------------------ 初始加载 ------------------ */ +onMounted(() => { + getList() + /* 加载本地羊舍 */ + request({ url: '/sheepfold_management/sheepfold_management/list', method: 'get' }).then(res => { + barns.value = res.rows + }) + listPrescription({ status: 1, persType: 1 }).then(res => { + presOptions.value = res.rows.map(item => ({ id: item.id, label: item.name })) + }) + listUnit().then(res => { + units.value = res.rows.map(item => ({ value: item.id, label: item.name })) + }) + listUsage().then(res => { + usages.value = res.rows.map(item => ({ value: item.id, label: item.name })) + }) + listMedicine().then(res => { + medicines.value = res.rows.map(item => ({ value: item.id, label: item.name })) + }) +}) + \ No newline at end of file