This commit is contained in:
饶秋霖 2024-12-07 18:28:32 +08:00
parent 49edf73cc4
commit cf4552f814
2 changed files with 313 additions and 0 deletions

44
api/system/doctor.js Normal file
View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询医生列表
export function listDoctor(query) {
return request({
url: '/system/doctor/list',
method: 'get',
params: query
})
}
// 查询医生详细
export function getDoctor(id) {
return request({
url: '/system/doctor/' + id,
method: 'get'
})
}
// 新增医生
export function addDoctor(data) {
return request({
url: '/system/doctor',
method: 'post',
data: data
})
}
// 修改医生
export function updateDoctor(data) {
return request({
url: '/system/doctor',
method: 'put',
data: data
})
}
// 删除医生
export function delDoctor(id) {
return request({
url: '/system/doctor/' + id,
method: 'delete'
})
}

View File

@ -0,0 +1,269 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="医生" prop="doctor">
<el-input
v-model="queryParams.doctor"
placeholder="请输入医生"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="评价" prop="expert">
<el-input
v-model="queryParams.expert"
placeholder="请输入评价"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="费用" prop="cost">
<el-input
v-model="queryParams.cost"
placeholder="请输入费用"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="图片" prop="picture">
<el-input
v-model="queryParams.picture"
placeholder="请输入图片"
clearable
@keyup.enter="handleQuery"
/>
</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"
v-hasPermi="['system:doctor:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="Edit"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:doctor:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="Delete"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:doctor:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="Download"
@click="handleExport"
v-hasPermi="['system:doctor:export']"
>导出</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="doctorList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="id" align="center" prop="id" />
<el-table-column label="医生" align="center" prop="doctor" />
<el-table-column label="评价" align="center" prop="expert" />
<el-table-column label="费用" align="center" prop="cost" />
<el-table-column label="图片" align="center" prop="picture" />
<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="['system:doctor:edit']">修改</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:doctor: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="doctorRef" :model="form" :rules="rules" label-width="80px">
<el-form-item label="医生" prop="doctor">
<el-input v-model="form.doctor" placeholder="请输入医生" />
</el-form-item>
<el-form-item label="评价" prop="expert">
<el-input v-model="form.expert" placeholder="请输入评价" />
</el-form-item>
<el-form-item label="费用" prop="cost">
<el-input v-model="form.cost" placeholder="请输入费用" />
</el-form-item>
<el-form-item label="图片" prop="picture">
<el-input v-model="form.picture" 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="Doctor">
import { listDoctor, getDoctor, delDoctor, addDoctor, updateDoctor } from "@/api/system/doctor";
const { proxy } = getCurrentInstance();
const doctorList = 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,
doctor: null,
expert: null,
cost: null,
picture: null
},
rules: {
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询医生列表 */
function getList() {
loading.value = true;
listDoctor(queryParams.value).then(response => {
doctorList.value = response.rows;
total.value = response.total;
loading.value = false;
});
}
//
function cancel() {
open.value = false;
reset();
}
//
function reset() {
form.value = {
id: null,
doctor: null,
expert: null,
cost: null,
picture: null
};
proxy.resetForm("doctorRef");
}
/** 搜索按钮操作 */
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
getDoctor(_id).then(response => {
form.value = response.data;
open.value = true;
title.value = "修改医生";
});
}
/** 提交按钮 */
function submitForm() {
proxy.$refs["doctorRef"].validate(valid => {
if (valid) {
if (form.value.id != null) {
updateDoctor(form.value).then(response => {
proxy.$modal.msgSuccess("修改成功");
open.value = false;
getList();
});
} else {
addDoctor(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 delDoctor(_ids);
}).then(() => {
getList();
proxy.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
/** 导出按钮操作 */
function handleExport() {
proxy.download('system/doctor/export', {
...queryParams.value
}, `doctor_${new Date().getTime()}.xlsx`)
}
getList();
</script>