This commit is contained in:
阿怪 2023-10-31 08:05:20 +08:00
parent 38bb6eb7d8
commit ea2d0b88cd
5 changed files with 586 additions and 40 deletions

View File

@ -2,7 +2,7 @@ ENV = 'development'
VITE_CLI_PORT = 8088 VITE_CLI_PORT = 8088
VITE_SERVER_PORT = 8888 VITE_SERVER_PORT = 8888
VITE_BASE_API = /api VITE_BASE_API = /api
VITE_BASE_PATH = http://36b924d2.r12.cpolar.top VITE_BASE_PATH = http://f968894.r2.cpolar.top
VITE_EDITOR = vscode VITE_EDITOR = vscode
// VITE_EDITOR = webstorm 如果使用webstorm开发且要使用dom定位到代码行功能 请先自定添加 webstorm到环境变量 再将VITE_EDITOR值修改为webstorm // VITE_EDITOR = webstorm 如果使用webstorm开发且要使用dom定位到代码行功能 请先自定添加 webstorm到环境变量 再将VITE_EDITOR值修改为webstorm
// 如果使用docker-compose开发模式设置为下面的地址或本机主机IP // 如果使用docker-compose开发模式设置为下面的地址或本机主机IP

View File

@ -14,6 +14,20 @@ const api = {
method: 'post', method: 'post',
data data
}) })
},
editArticle: data => {
return service({
url: '/article',
method: 'put',
data
})
},
deleteFunc: data => {
return service({
url: '/article',
method: 'delete',
data
})
} }
} }
export default api export default api

32
src/api/hospital.js Normal file
View File

@ -0,0 +1,32 @@
import service from '@/utils/request'
const api = {
getHospitalList: data => {
return service({
url: '/hospital/list',
method: 'get',
params: data
})
},
addHospital: data => {
return service({
url: '/hospital',
method: 'post',
data
})
},
editHospital: data => {
return service({
url: '/article',
method: 'put',
data
})
},
deleteFunc: data => {
return service({
url: '/hospital',
method: 'delete',
data
})
}
}
export default api

View File

@ -18,7 +18,7 @@ const path = ref(import.meta.env.VITE_BASE_API)
import { useUserStore } from '@/pinia/modules/user' import { useUserStore } from '@/pinia/modules/user'
const userStore = useUserStore() const userStore = useUserStore()
// //
const typeList = custom.getExercisesTypeList() // const typeList = custom.getExercisesTypeList()
const queryParams = ref({ const queryParams = ref({
page: 1, page: 1,
pageSize: 10, pageSize: 10,
@ -26,12 +26,12 @@ const queryParams = ref({
// type: '', // type: '',
// subject: '' // subject: ''
}) })
const subjectParams = ref({ // const subjectParams = ref({
page: 1, // page: 1,
pageSize: 100, // pageSize: 100,
}) // })
const tableData = ref([]) const tableData = ref([])
const subjectList = ref([]) // const subjectList = ref([])
const deleteVisible = ref(false) const deleteVisible = ref(false)
const question_ids = ref([]) const question_ids = ref([])
const total = ref(0) const total = ref(0)
@ -39,11 +39,12 @@ const dialogFormVisible = ref(false)
const dialogTitle = ref('') const dialogTitle = ref('')
const form = ref({}) const form = ref({})
const rules = ref({ const rules = ref({
name: [{ required: true, message: '请输入课程名称', trigger: 'blur' }] title: [{ required: true, message: '请输入标题', trigger: 'blur' }],
content: [{ required: true, message: '请输入内容', trigger: 'blur' }]
}) })
const question_id = ref(0) // const question_id = ref(0)
const content = ref(null) // const content = ref(null)
const options = ref([]) // // const options = ref([]) //
const question_form = ref({ const question_form = ref({
options: [], options: [],
answer: '', answer: '',
@ -85,12 +86,12 @@ function openDialog(type) {
// let params = {} // let params = {}
switch (type) { switch (type) {
case 'add': case 'add':
dialogTitle.value = '新增习题' dialogTitle.value = '新增文章'
form.value = {} form.value = {}
break break
case 'edit': case 'edit':
// params.question_id = question_id.value // params.question_id = question_id.value
dialogTitle.value = '编辑习题' dialogTitle.value = '编辑文章'
break break
} }
dialogFormVisible.value = true dialogFormVisible.value = true
@ -114,25 +115,25 @@ async function onDelete() {
const handleSelectionChange = (val) => { const handleSelectionChange = (val) => {
question_ids.value = val question_ids.value = val
} }
function editCourseFunc(row) { function editFunc(row) {
form.value = _.cloneDeep(row) form.value = _.cloneDeep(row)
question_id.value = form.value.question_id // question_id.value = form.value.question_id
content.value = JSON.parse(form.value.question).title // content.value = JSON.parse(form.value.question).title
question_form.value = JSON.parse(form.value.question) // question_form.value = JSON.parse(form.value.question)
if (!question_form.value.options) { // if (!question_form.value.options) {
question_form.value.options = [] // question_form.value.options = []
} // }
openDialog('edit') openDialog('edit')
} }
function deleteCourseFunc(row) { function deleteFunc(row) {
ElMessageBox.confirm('此操作将永久删除该数据, 是否继续?', '提示', { ElMessageBox.confirm('此操作将永久删除该数据, 是否继续?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}) })
.then(async() => { .then(async() => {
const res = await api.delExercises({ const res = await api.deleteFunc({
question_ids: [row.question_id] id: row.ID
}) })
if (res.code === 0) { if (res.code === 0) {
ElMessage({ ElMessage({
@ -166,8 +167,8 @@ async function enterDialog() { // 提交
// form.value.teacher_id = 0 // form.value.teacher_id = 0
// form.value.question = JSON.stringify(question_form.value) // form.value.question = JSON.stringify(question_form.value)
let func_name = 'addArticle' let func_name = 'addArticle'
if (form.value.question_id) { // if (form.value.ID) { //
func_name = 'editExercises' func_name = 'editArticle'
} }
const res = await api[func_name](form.value) const res = await api[func_name](form.value)
if (res.code === 0) { if (res.code === 0) {
@ -269,7 +270,7 @@ function beforeAvatarUpload(file) {
<el-button size="small" type="primary" link @click="deleteVisible = false">取消</el-button> <el-button size="small" type="primary" link @click="deleteVisible = false">取消</el-button>
<el-button size="small" type="primary" @click="onDelete">确定</el-button> <el-button size="small" type="primary" @click="onDelete">确定</el-button>
</div> </div>
<template #reference> <!-- <template #reference>
<el-button <el-button
icon="delete" icon="delete"
size="small" size="small"
@ -278,26 +279,29 @@ function beforeAvatarUpload(file) {
style="margin-left: 10px;" style="margin-left: 10px;"
@click="deleteVisible = true" @click="deleteVisible = true"
>删除</el-button> >删除</el-button>
</template> </template> -->
</el-popover> </el-popover>
</div> </div>
<!-- 数据列表--> <!-- 数据列表-->
<el-table :data="tableData" @selection-change="handleSelectionChange"> <el-table :data="tableData" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" /> <!-- <el-table-column type="selection" width="55" /> -->
<el-table-column align="left" label="ID" min-width="60" prop="question_id" sortable="custom" /> <el-table-column align="left" label="ID" min-width="60" prop="ID" sortable="custom" />
<el-table-column align="left" label="" min-width="150" prop="name"> <el-table-column align="left" label="题" min-width="150" prop="title">
<template #default="scope"> <!-- <template #default="scope">
{{ custom.getExercisesTypeName(scope.row.type) }} {{ custom.getExercisesTypeName(scope.row.type) }}
</template> </template> -->
</el-table-column> </el-table-column>
<el-table-column align="left" label="科目" min-width="150" prop="subject" /> <el-table-column align="left" label="内容" min-width="150" prop="subject">
<el-table-column align="left" label="题目" min-width="150">
<template #default="scope"> <template #default="scope">
<!-- {{getExercisesName(scope.row)}}--> <div class="show-content text-ellipsis-1" v-html="scope.row.content"></div>
<!-- <div v-html="getExercisesName(scope.row)" /> -->
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="left" label="分值" prop="score" /> <el-table-column align="left" label="封面图" min-width="150">
<template #default="scope">
<img class="lbt-thumb" :src="scope.row.cover_img" alt="">
</template>
</el-table-column>
<el-table-column align="left" label="阅读量" prop="reading_num" />
<!-- <el-table-column align="left" label="创建者" min-width="150" prop="teacher_id" /> --> <!-- <el-table-column align="left" label="创建者" min-width="150" prop="teacher_id" /> -->
<el-table-column align="left" label="创建时间" min-width="150"> <el-table-column align="left" label="创建时间" min-width="150">
<template #default="scope"> <template #default="scope">
@ -311,14 +315,14 @@ function beforeAvatarUpload(file) {
size="small" size="small"
type="primary" type="primary"
link link
@click="editCourseFunc(scope.row)" @click="editFunc(scope.row)"
>编辑</el-button> >编辑</el-button>
<el-button <el-button
icon="delete" icon="delete"
size="small" size="small"
type="danger" type="danger"
link link
@click="deleteCourseFunc(scope.row)" @click="deleteFunc(scope.row)"
>删除</el-button> >删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -414,7 +418,14 @@ function beforeAvatarUpload(file) {
align-items: center; align-items: center;
margin-bottom: 10px; margin-bottom: 10px;
} }
.text-ellipsis-1{ /*超出部分省略号 单行*/
overflow:hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 1;
display: -webkit-box;
-webkit-box-orient: vertical;
/* min-height: 38rpx; */
}
.button-box { .button-box {
padding: 10px 20px; padding: 10px 20px;
@ -426,4 +437,8 @@ function beforeAvatarUpload(file) {
.warning { .warning {
color: #dc143c; color: #dc143c;
} }
.lbt-thumb{
width: 100px;
height: 50px;
}
</style> </style>

485
src/view/hospital/index.vue Normal file
View File

@ -0,0 +1,485 @@
<script setup>
//
import api from '@/api/hospital'
// import capi from '@/api/course'
import custom from '@/utils/custom'
import { formatDate } from '@/utils/format'
import _ from 'lodash'
// import { toSQLLine } from '@/utils/stringFun'
// import WarningBar from '@/components/warningBar/warningBar.vue'
import ckEditor from '@/components/richText/ckEditor5.vue'
import { ref, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useRouter, useRoute } from 'vue-router'
const router = useRouter()
const route = useRoute()
const path = ref(import.meta.env.VITE_BASE_API)
import { useUserStore } from '@/pinia/modules/user'
const userStore = useUserStore()
//
const typeList = custom.getExercisesTypeList()
const queryParams = ref({
page: 1,
pageSize: 10,
// name: '',
// type: '',
// subject: ''
})
// const subjectParams = ref({
// page: 1,
// pageSize: 100,
// })
const tableData = ref([])
// const subjectList = ref([])
const deleteVisible = ref(false)
const question_ids = ref([])
const total = ref(0)
const dialogFormVisible = ref(false)
const dialogTitle = ref('')
const form = ref({})
const rules = ref({
name: [{ required: true, message: '请输入标题', trigger: 'blur' }],
addr: [{ required: true, message: '请输入地址', trigger: 'blur' }],
phone: [{ required: true, message: '请输入电话', trigger: 'blur' }],
})
// const question_id = ref(0)
// const content = ref(null)
// const options = ref([]) //
const question_form = ref({
options: [],
answer: '',
title: ''
})
const note_list = ref([
// {
// content: '',
// notes_time: ''
// }
])
const time_options = ref([
'手术前',
'手术中',
'手术后'
])
const todo_list = ref([])
//
onMounted(() => {
getHospitalList()
// getSubject()
})
//
async function getHospitalList() {
const res = await api.getHospitalList(queryParams.value)
if (res.code === 0) {
tableData.value = res.data.list
// console.log(tableData.value)
total.value = res.data.total
}
}
// async function getSubject() { //
// const res = await capi.getSubjectList(subjectParams.value)
// if (res.code === 0) {
// subjectList.value = custom.getStdSubject(res.data.records)
// }
// }
function onSubmit() {
getHospitalList()
}
const onReset = () => {
queryParams.value = {
page: 1,
pageSize: 10,
name: '',
// status: '',
// subject: ''
}
}
function openDialog(type) {
// let params = {}
switch (type) {
case 'add':
dialogTitle.value = '新增医院'
form.value = {}
break
case 'edit':
// params.question_id = question_id.value
dialogTitle.value = '编辑医院信息'
break
}
dialogFormVisible.value = true
// router.push({name:'addCourse',params})
}
async function onDelete() {
const ids = question_ids.value.map(item => item.question_id)
const res = await api.delExercises({ question_ids: ids })
if (res.code === 0) {
ElMessage({
type: 'success',
message: res.msg
})
deleteVisible.value = false
getHospitalList()
}
}
const handleSelectionChange = (val) => {
question_ids.value = val
}
function editFunc(row) {
form.value = _.cloneDeep(row)
console.log(form.value)
todo_list.value = form.value.todos
note_list.value = form.value.notes
openDialog('edit')
}
function deleteFunc(row) {
ElMessageBox.confirm('此操作将永久删除该数据, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(async() => {
const res = await api.deleteFunc({
id: row.ID
})
if (res.code === 0) {
ElMessage({
type: 'success',
message: '删除成功!'
})
getHospitalList()
}
}, () => {
})
}
function handleCurrentChange(val) {
queryParams.value.page = val
getHospitalList()
}
function handleSizeChange(val) {
queryParams.value.pageSize = val
getHospitalList()
}
function closeDialog() {
dialogFormVisible.value = false
// question_form.value = {
// options: [],
// answer: '',
// title: ''
// }
todo_list.value = []
note_list.value = []
form.value = {}
}
async function enterDialog() { //
// form.value.score = parseInt(form.value.score)
// form.value.teacher_id = 0
// form.value.question = JSON.stringify(question_form.value)
let func_name = 'addHospital'
if (form.value.ID) { //
func_name = 'editHospital'
}
form.value.todos = todo_list.value
form.value.notes = note_list.value
const res = await api[func_name](form.value)
if (res.code === 0) {
ElMessage({
type: 'success',
message: res.msg
})
// if (tableData.value.length === ids.length && page.value > 1) {
// page.value--
// }
// deleteVisible.value = false
closeDialog()
getHospitalList()
}
}
function addRowFunc(type) {
// {
// content: '',
// notes_time: ''
// }
if (type === 1) {
note_list.value.push({
content: '',
notes_time: ''
})
} else {
todo_list.value.push({
content: ''
})
}
}
function del_ro_func(i, type) {
if (type === 1) {
note_list.value.splice(i, 1)
} else {
todo_list.value.splice(i, 1)
}
}
</script>
<template>
<div>
<!-- 搜索框-->
<div class="gva-search-box">
<el-form ref="searchForm" :inline="true" :model="queryParams">
<el-form-item label="医院名称">
<el-input v-model="queryParams.name" placeholder="根据医院名称进行查询" />
</el-form-item>
<!-- <el-form-item label="课程分类">
<el-select v-model="queryParams.subject" clearable placeholder="请选择">
<el-option v-for="item in subjectList" :key="item.id" :label="item.name" :value="item.name" />
</el-select>
</el-form-item>
<el-form-item label="题型">
<el-select v-model="queryParams.type" clearable placeholder="请选择">
<el-option v-for="item in typeList" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item> -->
<el-form-item>
<el-button size="small" type="primary" icon="search" @click="onSubmit">查询</el-button>
<el-button size="small" icon="refresh" @click="onReset">重置</el-button>
</el-form-item>
</el-form>
</div>
<!-- 表格数据-->
<div class="gva-table-box">
<!-- 批量操作-->
<div class="gva-btn-list">
<el-button size="small" type="primary" icon="plus" @click="openDialog('add')">新增</el-button>
<el-popover v-model="deleteVisible" placement="top" width="160">
<p>确定要删除吗</p>
<div style="text-align: right; margin-top: 8px;">
<el-button size="small" type="primary" link @click="deleteVisible = false">取消</el-button>
<el-button size="small" type="primary" @click="onDelete">确定</el-button>
</div>
<!-- <template #reference>
<el-button
icon="delete"
size="small"
type="danger"
:disabled="!question_ids.length"
style="margin-left: 10px;"
@click="deleteVisible = true"
>删除</el-button>
</template> -->
</el-popover>
</div>
<!-- 数据列表-->
<el-table :data="tableData" @selection-change="handleSelectionChange">
<!-- <el-table-column type="selection" width="55" /> -->
<el-table-column align="left" label="ID" min-width="60" prop="ID" sortable="custom" />
<el-table-column align="left" label="医院名称" min-width="150" prop="name">
<!-- <template #default="scope">
{{ custom.getExercisesTypeName(scope.row.type) }}
</template> -->
</el-table-column>
<el-table-column align="left" label="医院地址" min-width="150">
<template #default="scope">
<div class="show-content text-ellipsis-1">{{scope.row.addr }}</div>
</template>
</el-table-column>
<el-table-column align="center" label="注意事项" min-width="150">
<template #default="scope">
<div>{{scope.row.notes.length}}</div>
</template>
</el-table-column>
<el-table-column align="center" label="须知事项" min-width="150">
<template #default="scope">
<div>{{ scope.row.todos.length }}</div>
</template>
</el-table-column>
<el-table-column align="left" label="联系电话" min-width="150" prop="phone" />
<!-- <el-table-column align="left" label="创建者" min-width="150" prop="teacher_id" /> -->
<el-table-column align="left" label="创建时间" min-width="200">
<template #default="scope">
{{ formatDate(scope.row.CreatedAt) }}
</template>
</el-table-column>
<el-table-column align="left" fixed="right" label="操作" width="200">
<template #default="scope">
<el-button
icon="edit"
size="small"
type="primary"
link
@click="editFunc(scope.row)"
>编辑</el-button>
<el-button
icon="delete"
size="small"
type="danger"
link
@click="deleteFunc(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="gva-pagination">
<el-pagination
:current-page="queryParams.page"
:page-size="queryParams.pageSize"
:page-sizes="[10, 30, 50, 100]"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
/>
</div>
</div>
<el-dialog v-model="dialogFormVisible" :before-close="closeDialog" :title="dialogTitle">
<el-form ref="apiForm" :model="form" :rules="rules" label-width="80px">
<el-form-item required label="医院名称" prop="name">
<el-input v-model="form.name" />
</el-form-item>
<el-form-item required label="医院地址" prop="addr">
<el-input v-model="form.addr" />
</el-form-item>
<el-form-item required label="联系电话" prop="phone">
<el-input v-model="form.phone" />
</el-form-item>
<el-form-item label="注意事项" prop="notes">
<div class="item-card-box" style="flex:1">
<div v-for="(item, i) in note_list" :key="i" class="item-card">
<div class="del-row-btn" @click="del_ro_func(i,1)">
<el-icon><Close /></el-icon>
</div>
<div class="ic-left">{{ i + 1 }} . </div>
<div class="ic-right">
<div class="ic-right-row">
<div class="icr-left">注意事项</div>
<div class="icr-right">
<el-input autosize type="textarea" v-model="item.content" />
</div>
</div>
<div class="ic-right-row">
<div class="icr-left">注意时间</div>
<div class="icr-right">
<el-select v-model="item.notes_time" class="m-2" placeholder="选择注意时间" size="large">
<el-option
v-for="(item2, i) in time_options"
:key="i"
:label="item2"
:value="item2"
/>
</el-select>
</div>
</div>
</div>
</div>
<div class="add-row-btn" style="text-align: center;cursor: pointer;" @click="addRowFunc(1)">
<el-icon><Plus /></el-icon>
</div>
</div>
</el-form-item>
<el-form-item label="须知事项" prop="notes">
<div class="item-card-box" style="flex:1">
<div v-for="(item, i) in todo_list" :key="i" class="item-card">
<div class="del-row-btn" @click="del_ro_func(i,2)">
<el-icon><Close /></el-icon>
</div>
<div class="ic-left">{{ i + 1 }} . </div>
<div class="ic-right">
<div class="ic-right-row">
<div class="icr-left">须知事项</div>
<div class="icr-right">
<el-input autosize type="textarea" v-model="item.content" />
</div>
</div>
</div>
</div>
<div class="add-row-btn" style="text-align: center;cursor: pointer;" @click="addRowFunc(2)">
<el-icon><Plus /></el-icon>
</div>
</div>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button size="small" @click="closeDialog"> </el-button>
<el-button size="small" type="primary" @click="enterDialog"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<style scoped lang="scss">
.add-row-btn:hover{
background-color: rgb(244, 244, 244);
}
.item-card{
display: flex;
flex: 1;
padding: 10px;
border: 1px solid #dcdfe6;
border-radius: 10px;
margin-bottom: 10px;
position: relative;
// padding-right: 30px;
.del-row-btn{
position: absolute;
cursor: pointer;
width: 18px;
height: 18px;
background: #cecece;
color: white;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
right: -7px;
top: -7px;
z-index: 10;
}
.ic-left{
padding-right: 10px;
}
.ic-right{
flex: 1;
.ic-right-row{
display: flex;
align-items: center;
padding-bottom: 10px;
.ic-right-row:last-child{
padding-bottom: 0px;
}
.icr-left{
margin-right: 10px;
}
.icr-right{
flex: 1;
}
}
}
}
.option-item {
display: flex;
align-items: center;
margin-bottom: 10px;
}
.text-ellipsis-1{ /*超出部分省略号 单行*/
overflow:hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 1;
display: -webkit-box;
-webkit-box-orient: vertical;
/* min-height: 38rpx; */
}
.button-box {
padding: 10px 20px;
.el-button {
float: right;
}
}
.warning {
color: #dc143c;
}
.lbt-thumb{
width: 100px;
height: 50px;
}
</style>