Compare commits

..

No commits in common. "08e97c39a6eb6e245292ea41ac0a456367a31c7e" and "b0ca2d334bc87fa5f02f669ec6bd6c3ff6a95dfa" have entirely different histories.

4 changed files with 0 additions and 788 deletions

View File

@ -1,44 +0,0 @@
import request from '@/utils/request'
// 查询处方列表
export function listPrescription(query) {
return request({
url: '/biosafety/prescription/list',
method: 'get',
params: query
})
}
// 查询处方详细
export function getPrescription(id) {
return request({
url: '/biosafety/prescription/' + id,
method: 'get'
})
}
// 新增处方
export function addPrescription(data) {
return request({
url: '/biosafety/prescription',
method: 'post',
data: data
})
}
// 修改处方
export function updatePrescription(data) {
return request({
url: '/biosafety/prescription',
method: 'put',
data: data
})
}
// 删除处方
export function delPrescription(id) {
return request({
url: '/biosafety/prescription/' + id,
method: 'delete'
})
}

View File

@ -1,44 +0,0 @@
import request from '@/utils/request'
// 查询药品单位列表
export function listUnit(query) {
return request({
url: '/biosafety/unit/list',
method: 'get',
params: query
})
}
// 查询药品单位详细
export function getUnit(id) {
return request({
url: '/biosafety/unit/' + id,
method: 'get'
})
}
// 新增药品单位
export function addUnit(data) {
return request({
url: '/biosafety/unit',
method: 'post',
data: data
})
}
// 修改药品单位
export function updateUnit(data) {
return request({
url: '/biosafety/unit',
method: 'put',
data: data
})
}
// 删除药品单位
export function delUnit(id) {
return request({
url: '/biosafety/unit/' + id,
method: 'delete'
})
}

View File

@ -1,187 +0,0 @@
<template>
<div class="app-container">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd"
v-hasPermi="['biosafety:unit:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate"
v-hasPermi="['biosafety:unit:edit']">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete"
v-hasPermi="['biosafety:unit:remove']">删除</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="unitList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="编号" align="center" prop="id" />
<el-table-column label="单位" align="center" prop="name" />
<el-table-column label="国际单位" align="center" prop="unit" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
v-hasPermi="['biosafety:unit:edit']">修改</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
v-hasPermi="['biosafety:unit:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
@pagination="getList" />
<!-- 添加或修改药品单位对话框 -->
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
<el-form ref="unitRef" :model="form" :rules="rules" label-width="80px">
<el-form-item label="单位" prop="name">
<el-input v-model="form.name" placeholder="请输入单位" />
</el-form-item>
<el-form-item label="国际单位" prop="name">
<el-input v-model="form.unit" placeholder="请输入国际单位" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup name="Unit">
import { listUnit, getUnit, delUnit, addUnit, updateUnit } from "@/api/biosafety/unit"
const { proxy } = getCurrentInstance()
const unitList = ref([])
const open = ref(false)
const loading = ref(true)
const showSearch = ref(true)
const ids = ref([])
const single = ref(true)
const multiple = ref(true)
const total = ref(0)
const title = ref("")
const data = reactive({
form: {},
queryParams: {
pageNum: 1,
pageSize: 10,
},
rules: {
}
})
const { queryParams, form, rules } = toRefs(data)
/** 查询药品单位列表 */
function getList() {
loading.value = true
listUnit(queryParams.value).then(response => {
unitList.value = response.rows
total.value = response.total
loading.value = false
})
}
//
function cancel() {
open.value = false
reset()
}
//
function reset() {
form.value = {
id: null,
name: null
}
proxy.resetForm("unitRef")
}
/** 搜索按钮操作 */
function handleQuery() {
queryParams.value.pageNum = 1
getList()
}
/** 重置按钮操作 */
function resetQuery() {
proxy.resetForm("queryRef")
handleQuery()
}
//
function handleSelectionChange(selection) {
ids.value = selection.map(item => item.id)
single.value = selection.length != 1
multiple.value = !selection.length
}
/** 新增按钮操作 */
function handleAdd() {
reset()
open.value = true
title.value = "添加药品单位"
}
/** 修改按钮操作 */
function handleUpdate(row) {
reset()
const _id = row.id || ids.value
getUnit(_id).then(response => {
form.value = response.data
open.value = true
title.value = "修改药品单位"
})
}
/** 提交按钮 */
function submitForm() {
proxy.$refs["unitRef"].validate(valid => {
if (valid) {
if (form.value.id != null) {
updateUnit(form.value).then(response => {
proxy.$modal.msgSuccess("修改成功")
open.value = false
getList()
})
} else {
addUnit(form.value).then(response => {
proxy.$modal.msgSuccess("新增成功")
open.value = false
getList()
})
}
}
})
}
/** 删除按钮操作 */
function handleDelete(row) {
const _ids = row.id || ids.value
proxy.$modal.confirm('是否确认删除药品单位编号为"' + _ids + '"的数据项?').then(function() {
return delUnit(_ids)
}).then(() => {
getList()
proxy.$modal.msgSuccess("删除成功")
}).catch(() => {})
}
/** 导出按钮操作 */
function handleExport() {
proxy.download('biosafety/unit/export', {
...queryParams.value
}, `unit_${new Date().getTime()}.xlsx`)
}
getList()
</script>

View File

@ -1,513 +0,0 @@
<template>
<div class="app-container">
<!-- 搜索表单 -->
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="处方编号" prop="no">
<el-input v-model="queryParams.no" placeholder="请输入处方编号" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="处方名称" prop="name">
<el-input v-model="queryParams.name" placeholder="请输入处方名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="类型" prop="persType">
<el-select v-model="queryParams.persType" placeholder="请选择类型" clearable style="width: 150px">
<el-option v-for="dict in pres_type" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable style="width: 150px">
<el-option v-for="dict in pres_status" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 按钮组 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete">删除</el-button>
</el-col>
<!-- <el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport">导出</el-button>
</el-col> -->
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" />
</el-row>
<!-- 列表 -->
<el-table v-loading="loading" :data="prescriptionList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="处方编号" align="center" prop="no" />
<el-table-column label="处方名称" align="center" prop="name" />
<el-table-column label="类型" align="center" prop="persType">
<template #default="scope">
<dict-tag :options="pres_type" :value="scope.row.persType" />
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="comment" />
<el-table-column label="状态" align="center" prop="status">
<template #default="scope">
<dict-tag :options="pres_status" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="300px">
<template #default="scope">
<el-button link type="primary" icon="View" @click="handleView(scope.row)">详情</el-button>
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)">修改</el-button>
<el-button link :type="scope.row.status ? 'warning' : 'primary'" @click="handleStatus(scope.row)">{{ scope.row.status?"禁用":"启用" }}</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize" @pagination="getList" />
<!-- 弹框详情/修改 -->
<el-dialog :title="title" v-model="open" width="60%" append-to-body s>
<!-- 详情页只读展示 -->
<div v-if="isView" style="padding-bottom:20px ;">
<el-descriptions :column="2" border>
<el-descriptions-item label="处方编号">{{ form.no }}</el-descriptions-item>
<el-descriptions-item label="处方名称">{{ form.name }}</el-descriptions-item>
<el-descriptions-item label="类型">
<dict-tag :options="pres_type" :value="form.persType" />
</el-descriptions-item>
<el-descriptions-item label="状态">
<dict-tag :options="pres_status" :value="form.status" />
</el-descriptions-item>
<el-descriptions-item label="备注" :span="2">
{{ form.comment || '无' }}
</el-descriptions-item>
</el-descriptions>
<el-divider content-position="left">处方详情</el-divider>
<el-table :data="swPresDetailList" stripe border style="width: 100%" max-height="300">
<el-table-column label="序号" type="index" width="60" align="center" />
<el-table-column label="药品" prop="mediId" align="center" :formatter="formatMedicine" />
<el-table-column label="用量" prop="dosage" />
<el-table-column label="使用方法" align="center" prop="usageId" :formatter="formatUsage" />
<el-table-column label="单位" prop="unitId" align="center" :formatter="formatUnit" />
</el-table>
</div>
<!-- 修改页可编辑表单 -->
<div v-else>
<el-form ref="prescriptionRef" :model="form" :rules="rules" label-width="100px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="处方编号" prop="no">
<el-input v-model="form.no" placeholder="请输入处方编号" disabled />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="处方名称" prop="name">
<el-input v-model="form.name" placeholder="请输入处方名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="类型" prop="persType">
<el-select v-model="form.persType" placeholder="请选择类型" style="width: 100%">
<el-option v-for="dict in pres_type" :key="dict.value" :label="dict.label"
:value="parseInt(dict.value)" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="状态" prop="status">
<el-select v-model="form.status" placeholder="请选择状态" style="width: 100%">
<el-option v-for="dict in pres_status" :key="dict.value" :label="dict.label"
:value="parseInt(dict.value)" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="comment">
<el-input type="textarea" :rows="2" v-model="form.comment" placeholder="请输入备注" />
</el-form-item>
</el-col>
</el-row>
<el-divider content-position="left">处方详情</el-divider>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" icon="Plus" @click="handleAddSwPresDetail()">添加</el-button>
</el-col>
</el-row>
<el-table :data="swPresDetailList" :row-class-name="rowSwPresDetailIndex"
@selection-change="handleSwPresDetailSelectionChange" ref="swPresDetail" border stripe>
<el-table-column label="序号" align="center" prop="index" width="60" />
<el-table-column label="药品" prop="mediId">
<template #default="scope">
<el-select v-model="scope.row.mediId" filterable placeholder="请选择药品" style="width: 100%">
<el-option v-for="item in medicines" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</template>
</el-table-column>
<el-table-column label="用量" prop="dosage">
<template #default="scope">
<el-input-number v-model="scope.row.dosage" placeholder="请输入用量" :min="0" :precision="1"
controls-position="right" />
</template>
</el-table-column>
<el-table-column label="单位" prop="unitId">
<template #default="scope">
<el-select v-model="scope.row.unitId" placeholder="请选择单位">
<el-option v-for="item in units" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</template>
</el-table-column>
<el-table-column label="使用方法" prop="usageId">
<template #default="scope">
<el-select v-model="scope.row.usageId" placeholder="请选择使用方法">
<el-option v-for="item in usages" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Delete" @click="deletePresDetail(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form>
</div>
<!-- 底部按钮仅修改页显示 -->
<template #footer v-if="!isView">
<div class="dialog-footer">
<el-button @click="cancel"> </el-button>
<el-button type="primary" @click="submitForm"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup name="Prescription">
import { listPrescription, getPrescription, delPrescription, addPrescription, updatePrescription } from "@/api/biosafety/prescription"
import { getCurrentInstance, ref, reactive, toRefs } from 'vue'
import { listUnit } from "@/api/biosafety/unit"
import { listUsage } from "@/api/biosafety/usage"
import { listMedicine } from "@/api/biosafety/medicine"
const { proxy } = getCurrentInstance()
const { pres_status, pres_type } = proxy.useDict('pres_status', 'pres_type')
const prescriptionList = ref([]) //
const swPresDetailList = ref([]) //
const open = ref(false) //
const loading = ref(true) //
const showSearch = ref(true) //
const ids = ref([]) // id
const checkedSwPresDetail = ref([]) //
const single = ref(true) //
const multiple = ref(true) //
const total = ref(0) //
const title = ref("") //
const isView = ref(false) //
/* 响应式数据form、queryParams、rules */
const data = reactive({
form: {},
queryParams: {
pageNum: 1,
pageSize: 10,
no: null,
name: null,
persType: null,
status: null,
},
rules: {}
})
const { queryParams, form, rules } = toRefs(data)
const units = ref([]) //
const usages = ref([]) // 使
const medicines = ref([]) //
/**
* 获取药品下拉数据源
* 将返回数据转换成 { value, label } 结构 el-option 使用
*/
function getMedicines() {
listMedicine().then(response => {
medicines.value = response.rows.map(item => ({
value: item.id,
label: item.name
}))
})
}
/**
* 获取单位下拉数据源单位字典
* 将返回数据转换成 { value, label } 结构 el-option 使用
*/
function getUnit() {
listUnit().then(response => {
units.value = response.rows.map(item => ({
value: item.id,
label: item.name
}))
})
}
/**
* 获取处方使用方法下拉数据源
* 将返回数据转换成 { value, label } 结构 el-option 使用
*/
function getUsageOptions() {
listUsage().then(response => {
usages.value = response.rows.map(item => ({
value: item.id,
label: item.name
}))
})
}
/**
* 格式化使用方法
* 根据 usageId 查找对应的使用方法名称
*/
function formatUsage(row) {
const usage = usages.value.find(item => item.value === row.usageId)
return usage ? usage.label : '未知'
}
/**
* 格式化药品
* 根据 mediId 查找对应的药品名称
*/
function formatMedicine(row) {
const medicine = medicines.value.find(item => item.value === row.mediId)
return medicine ? medicine.label : '未知'
}
/**
* 格式化单位
* 根据 unitId 查找对应的单位名称
*/
function formatUnit(row) {
const unit = units.value.find(item => item.value === row.unitId)
return unit ? unit.label : '未知'
}
/**
* 查询处方列表
* loading 状态开始时置 true接口返回后更新列表数据与总数loading false
*/
function getList() {
loading.value = true
listPrescription(queryParams.value).then(response => {
prescriptionList.value = response.rows
total.value = response.total
loading.value = false
})
}
/**
* 表单/子表重置
* formswPresDetailList 重置为初始状态并清空校验提示
*/
function reset() {
form.value = {
id: null,
no: null,
name: null,
persType: null,
comment: null,
status: null
}
swPresDetailList.value = []
proxy.resetForm("prescriptionRef")
isView.value = false
}
/**
* 搜索按钮
* 将分页重置到第一页后重新拉取数据
*/
function handleQuery() {
queryParams.value.pageNum = 1
getList()
}
/**
* 重置搜索条件
* 清空 queryRef 表单后重新触发查询
*/
function resetQuery() {
proxy.resetForm("queryRef")
handleQuery()
}
/**
* 主表多选回调
* 更新 ids 数组并设置 single / multiple 按钮禁用状态
*/
function handleSelectionChange(selection) {
ids.value = selection.map(item => item.id)
single.value = selection.length !== 1 //
multiple.value = !selection.length //
}
/**
* 新增按钮
* 重置表单打开弹窗设置标题为添加处方
*/
function handleAdd() {
reset()
form.value.no = `P${Date.now()}` //
open.value = true
title.value = "添加处方"
}
/**
* 查看详情
* 根据 id 拉取单条记录及子表数据弹窗只读展示
*/
function handleView(row) {
reset()
const _id = row.id || ids.value
getPrescription(_id).then(response => {
form.value = response.data
swPresDetailList.value = response.data.swPresDetailList
open.value = true
title.value = "处方详情"
isView.value = true
})
}
/**
* 修改按钮
* 与查看详情共用接口但弹窗可编辑
*/
function handleUpdate(row) {
reset()
const _id = row.id || ids.value
getPrescription(_id).then(response => {
form.value = response.data
swPresDetailList.value = response.data.swPresDetailList
open.value = true
title.value = "修改处方"
isView.value = false
})
}
//
function handleStatus(row) {
const _id = row.id || ids.value
const newStatus = row.status ? 0 : 1 //
proxy.$modal.confirm(`是否确认将 ${row.name} 处方${row.status ? '禁用' : '启用'}`).then(() => {
return updatePrescription({ id: _id, status: newStatus })
}).then(() => {
proxy.$modal.msgSuccess(`处方${row.status ? '禁用' : '启用'}成功`)
getList() //
}).catch(() => {
loading.value = false
})
}
/**
* 提交表单新增/修改
* 先校验再把子表数据合并到 form 最后根据 id 判断是新增还是更新
*/
function submitForm() {
proxy.$refs["prescriptionRef"].validate(valid => {
if (valid) {
form.value.swPresDetailList = swPresDetailList.value
if (form.value.id) {
updatePrescription(form.value).then(() => {
proxy.$modal.msgSuccess("修改成功")
open.value = false
getList()
})
} else {
addPrescription(form.value).then(() => {
proxy.$modal.msgSuccess("新增成功")
open.value = false
getList()
})
}
}
})
}
/**
* 删除按钮单条/批量
* 弹出确认框后调用接口删除成功后刷新列表
*/
function handleDelete(row) {
const _ids = row.id || ids.value
proxy.$modal.confirm(`是否确认删除处方编号为"${_ids}"的数据项?`).then(() => {
return delPrescription(_ids)
}).then(() => {
getList()
proxy.$modal.msgSuccess("删除成功")
})
}
/**
* 子表行序号计算
* 通过 el-table row-class-name 钩子给每一行写入 index 1 开始
*/
function rowSwPresDetailIndex({ row, rowIndex }) {
row.index = rowIndex + 1
}
/**
* 子表添加按钮
* swPresDetailList 追加一条空记录
*/
function handleAddSwPresDetail() {
swPresDetailList.value.push({ mediId: '', dosage: '', unitId: '', usageId: '' })
}
/**
* 子表删除按钮
*
*/
function deletePresDetail(row) {
const index = swPresDetailList.value.findIndex(item => item.index === row.index)
if (index !== -1) {
swPresDetailList.value.splice(index, 1)
}
}
/**
* 子表多选回调
* 记录被选中的行序号数组
*/
function handleSwPresDetailSelectionChange(selection) {
checkedSwPresDetail.value = selection.map(item => item.index)
}
function cancel() {
open.value = false
reset()
}
/**
* 导出按钮
* 调用后端通用导出接口文件名带时间戳
*/
function handleExport() {
proxy.download('biosafety/prescription/export', { ...queryParams.value }, `prescription_${Date.now()}.xlsx`)
}
//
getList()
getUnit() //
getUsageOptions() // 使
getMedicines() //
</script>