From 2ad1bf19381ae7ef5700f5fe9f8776223f979ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E6=80=AA?= <690927457@qq.com> Date: Wed, 1 Nov 2023 00:35:17 +0800 Subject: [PATCH] =?UTF-8?q?2023.11.1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- src/api/hospital.js | 2 +- src/view/hospital/index.vue | 50 +++++++++++++++++++------------------ 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/.env.development b/.env.development index dcd4d8a..54d28e8 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://f968894.r2.cpolar.top +VITE_BASE_PATH = http://410fed99.r6.cpolar.top VITE_EDITOR = vscode // VITE_EDITOR = webstorm 如果使用webstorm开发且要使用dom定位到代码行功能 请先自定添加 webstorm到环境变量 再将VITE_EDITOR值修改为webstorm // 如果使用docker-compose开发模式,设置为下面的地址或本机主机IP diff --git a/src/api/hospital.js b/src/api/hospital.js index d2e712f..7c9dc81 100644 --- a/src/api/hospital.js +++ b/src/api/hospital.js @@ -16,7 +16,7 @@ const api = { }, editHospital: data => { return service({ - url: '/article', + url: '/hospital', method: 'put', data }) diff --git a/src/view/hospital/index.vue b/src/view/hospital/index.vue index 589f19a..f34d6b8 100644 --- a/src/view/hospital/index.vue +++ b/src/view/hospital/index.vue @@ -51,6 +51,7 @@ const question_form = ref({ answer: '', title: '' }) +const apiForm = ref(null) const note_list = ref([ // { // content: '', @@ -96,18 +97,19 @@ const onReset = () => { } } function openDialog(type) { + dialogFormVisible.value = true // let params = {} switch (type) { case 'add': dialogTitle.value = '新增医院' - form.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() { @@ -172,28 +174,28 @@ function closeDialog() { 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() - } + await apiForm.value.validate(async(valid, fields) => { + if (valid) { + console.log('submit!') + 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 + }) + getHospitalList() + closeDialog() + } + } else { + // console.log('error submit!', fields) + } + }) } function addRowFunc(type) { // {