From ea2d0b88cd8c741e36a76a17b69beae210aa9858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E6=80=AA?= <690927457@qq.com> Date: Tue, 31 Oct 2023 08:05:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BB=E9=99=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- src/api/article.js | 14 ++ src/api/hospital.js | 32 +++ src/view/article/index.vue | 93 ++++--- src/view/hospital/index.vue | 485 ++++++++++++++++++++++++++++++++++++ 5 files changed, 586 insertions(+), 40 deletions(-) create mode 100644 src/api/hospital.js create mode 100644 src/view/hospital/index.vue diff --git a/.env.development b/.env.development index 530fd70..dcd4d8a 100644 --- a/.env.development +++ b/.env.development @@ -2,7 +2,7 @@ ENV = 'development' VITE_CLI_PORT = 8088 VITE_SERVER_PORT = 8888 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 = webstorm 如果使用webstorm开发且要使用dom定位到代码行功能 请先自定添加 webstorm到环境变量 再将VITE_EDITOR值修改为webstorm // 如果使用docker-compose开发模式,设置为下面的地址或本机主机IP diff --git a/src/api/article.js b/src/api/article.js index 6587941..1053bf9 100644 --- a/src/api/article.js +++ b/src/api/article.js @@ -14,6 +14,20 @@ const api = { method: 'post', data }) + }, + editArticle: data => { + return service({ + url: '/article', + method: 'put', + data + }) + }, + deleteFunc: data => { + return service({ + url: '/article', + method: 'delete', + data + }) } } export default api diff --git a/src/api/hospital.js b/src/api/hospital.js new file mode 100644 index 0000000..d2e712f --- /dev/null +++ b/src/api/hospital.js @@ -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 diff --git a/src/view/article/index.vue b/src/view/article/index.vue index 4410328..0f4992d 100644 --- a/src/view/article/index.vue +++ b/src/view/article/index.vue @@ -18,7 +18,7 @@ const path = ref(import.meta.env.VITE_BASE_API) import { useUserStore } from '@/pinia/modules/user' const userStore = useUserStore() // 变量 -const typeList = custom.getExercisesTypeList() +// const typeList = custom.getExercisesTypeList() const queryParams = ref({ page: 1, pageSize: 10, @@ -26,12 +26,12 @@ const queryParams = ref({ // type: '', // subject: '' }) -const subjectParams = ref({ - page: 1, - pageSize: 100, -}) +// const subjectParams = ref({ +// page: 1, +// pageSize: 100, +// }) const tableData = ref([]) -const subjectList = ref([]) +// const subjectList = ref([]) const deleteVisible = ref(false) const question_ids = ref([]) const total = ref(0) @@ -39,11 +39,12 @@ const dialogFormVisible = ref(false) const dialogTitle = ref('') const form = 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 content = ref(null) -const options = ref([]) // 答案选项数组 +// const question_id = ref(0) +// const content = ref(null) +// const options = ref([]) // 答案选项数组 const question_form = ref({ options: [], answer: '', @@ -85,12 +86,12 @@ function openDialog(type) { // let params = {} switch (type) { case 'add': - dialogTitle.value = '新增习题' + dialogTitle.value = '新增文章' form.value = {} break case 'edit': // params.question_id = question_id.value - dialogTitle.value = '编辑习题' + dialogTitle.value = '编辑文章' break } dialogFormVisible.value = true @@ -114,25 +115,25 @@ async function onDelete() { const handleSelectionChange = (val) => { question_ids.value = val } -function editCourseFunc(row) { +function editFunc(row) { form.value = _.cloneDeep(row) - question_id.value = form.value.question_id - content.value = JSON.parse(form.value.question).title - question_form.value = JSON.parse(form.value.question) - if (!question_form.value.options) { - question_form.value.options = [] - } + // question_id.value = form.value.question_id + // content.value = JSON.parse(form.value.question).title + // question_form.value = JSON.parse(form.value.question) + // if (!question_form.value.options) { + // question_form.value.options = [] + // } openDialog('edit') } -function deleteCourseFunc(row) { +function deleteFunc(row) { ElMessageBox.confirm('此操作将永久删除该数据, 是否继续?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }) .then(async() => { - const res = await api.delExercises({ - question_ids: [row.question_id] + const res = await api.deleteFunc({ + id: row.ID }) if (res.code === 0) { ElMessage({ @@ -166,8 +167,8 @@ async function enterDialog() { // 提交 // form.value.teacher_id = 0 // form.value.question = JSON.stringify(question_form.value) let func_name = 'addArticle' - if (form.value.question_id) { // 编辑 - func_name = 'editExercises' + if (form.value.ID) { // 编辑 + func_name = 'editArticle' } const res = await api[func_name](form.value) if (res.code === 0) { @@ -269,7 +270,7 @@ function beforeAvatarUpload(file) { 取消 确定 -