From 91cb465962ee0ef0d6613ad56931a14520a107db Mon Sep 17 00:00:00 2001
From: qk123 <18211963828@163.com>
Date: Tue, 30 Dec 2025 14:26:14 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8C=BB=E7=94=9F=E5=B8=B8=E7=94=A8=E8=AF=AD?=
=?UTF-8?q?=E7=BB=B4=E6=8A=A4->=E5=90=8D=E7=A7=B0=E5=AD=97=E6=95=B0?=
=?UTF-8?q?=E9=99=90=E5=88=B6=E3=80=81=E5=89=8D=E7=AB=AF=E5=90=8D=E7=A7=B0?=
=?UTF-8?q?=E5=94=AF=E4=B8=80=E6=80=A7=E6=A0=A1=E9=AA=8C=E7=AD=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../views/doctorstation/doctorphrase/api.js | 4 +-
.../doctorstation/doctorphrase/index.vue | 94 ++++++++++++++-----
2 files changed, 72 insertions(+), 26 deletions(-)
diff --git a/openhis-ui-vue3/src/views/doctorstation/doctorphrase/api.js b/openhis-ui-vue3/src/views/doctorstation/doctorphrase/api.js
index 40dd150c..353baa4b 100644
--- a/openhis-ui-vue3/src/views/doctorstation/doctorphrase/api.js
+++ b/openhis-ui-vue3/src/views/doctorstation/doctorphrase/api.js
@@ -13,11 +13,11 @@ export function getDoctorPhraseList() {
/**
* 搜索医生常用语
*/
-export function searchDoctorPhraseList(phraseName, phraseType, phraseCategory) {
+export function searchDoctorPhraseList(phraseName, phraseType) {
return request({
url: '/Doctor-phrase/search',
method: 'get',
- params: { phraseName, phraseType, phraseCategory }
+ params: { phraseName, phraseType }
})
}
diff --git a/openhis-ui-vue3/src/views/doctorstation/doctorphrase/index.vue b/openhis-ui-vue3/src/views/doctorstation/doctorphrase/index.vue
index 225dfc15..cffb0a57 100644
--- a/openhis-ui-vue3/src/views/doctorstation/doctorphrase/index.vue
+++ b/openhis-ui-vue3/src/views/doctorstation/doctorphrase/index.vue
@@ -3,9 +3,9 @@
@@ -36,7 +37,9 @@
{{ scope.row.phraseName }}
@@ -137,7 +140,7 @@
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
- :page-sizes="[10, 20, 50, 100]"
+ :page-sizes="[15, 30, 50]"
:page-size="pageSize"
layout="total, prev, pager, next, jumper, sizes"
:total="total"
@@ -153,7 +156,7 @@
>
-
+
import { ref, onMounted } from 'vue'
-import { Search, Plus, Check, Close } from '@element-plus/icons-vue'
+import { Search, Plus, Check, Close, Refresh } from '@element-plus/icons-vue'
import { getDoctorPhraseList, searchDoctorPhraseList, addDoctorPhrase, deleteDoctorPhrase, updateDoctorPhrase } from './api'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useDict } from '@/utils/dict'
// 搜索条件
-const searchScope = ref('个人')
-const searchKeyword = ref('')
+ const searchScope = ref(null) // null表示未选择,数字类型:1=个人,2=科室,3=全院
+ const searchKeyword = ref('')
// 表格数据
const tableData = ref([])
// 分页
const currentPage = ref(1)
-const pageSize = ref(10)
+const pageSize = ref(15)
const total = ref(0)
// 新增模态框相关
@@ -276,6 +279,33 @@ const getScopeName = (scope) => {
return scopeMap[scope] || '未知范围'
}
+// 名称唯一性校验函数
+const validatePhraseName = (phraseName, excludeId = null) => {
+ if (!phraseName || !phraseName.trim()) {
+ return { valid: false, message: '请输入常用语名称' }
+ }
+
+ // 检查字数限制
+ if (phraseName.trim().length > 50) {
+ return { valid: false, message: '常用语名称不能超过50字' }
+ }
+
+ // 检查名称是否已存在
+ const existingPhrase = allData.value.find(item => {
+ // 排除自身(更新时)
+ if (excludeId && item.id === excludeId) {
+ return false
+ }
+ return item.phraseName === phraseName.trim()
+ })
+
+ if (existingPhrase) {
+ return { valid: false, message: '常用语名称已存在,请输入不同的名称' }
+ }
+
+ return { valid: true, message: '' }
+}
+
// 所有数据(用于客户端分页)
const allData = ref([])
@@ -302,6 +332,16 @@ const fetchDoctorPhraseList = async () => {
}
}
+// 重置功能
+const handleReset = () => {
+ // 重置搜索条件
+ searchScope.value = null
+ searchKeyword.value = ''
+
+ // 重新加载所有数据
+ fetchDoctorPhraseList()
+}
+
// 客户端分页处理
const applyPagination = () => {
const start = (currentPage.value - 1) * pageSize.value
@@ -323,21 +363,13 @@ const handleCurrentChange = (val) => {
// 搜索功能
const handleSearch = async () => {
try {
- // 根据搜索范围确定phraseType
- // 这里需要根据实际业务逻辑映射,暂时使用默认值
- const phraseType = 1
+ // searchScope可能是null(未选择)、1=个人,2=科室,3=全院
+ const searchScopeValue = searchScope.value
+ const phraseType = searchScopeValue === null ? undefined : searchScopeValue
- // 如果需要使用searchScope进行搜索,需要将字符串转换为对应的数字
- const scopeMap = {
- '个人': 1,
- '科室': 2,
- '全院': 3
- }
- const searchScopeValue = scopeMap[searchScope.value] || 1
-
- // 调用搜索接口
- // 注意:根据后端API要求,这里的参数顺序可能需要调整
- const response = await searchDoctorPhraseList(searchKeyword.value, searchScopeValue, phraseType)
+ // 调用搜索接口:phraseName, phraseType
+ // 如果phraseType为undefined,则后端不会按范围过滤,查询所有数据
+ const response = await searchDoctorPhraseList(searchKeyword.value, phraseType)
// 处理后端返回的数据结构:data.data
if (response.code === 200 && response.data && response.data.data) {
@@ -378,6 +410,13 @@ const handleAdd = async () => {
// 验证表单
await addFormRef.value.validate()
+ // 名称唯一性校验
+ const nameValidation = validatePhraseName(addForm.value.phraseName)
+ if (!nameValidation.valid) {
+ ElMessage.error(nameValidation.message)
+ return
+ }
+
// 添加数据库要求的必填默认字段
const formData = {
...addForm.value,
@@ -484,6 +523,13 @@ const handleSave = async () => {
return
}
+ // 名称唯一性校验(排除当前记录)
+ const nameValidation = validatePhraseName(editForm.value.phraseName, editingId.value)
+ if (!nameValidation.valid) {
+ ElMessage.error(nameValidation.message)
+ return
+ }
+
// 准备更新数据
const updateData = {
...editForm.value,