From e1f19883e37f969d4e8ada6a3137ba399ebfc6df Mon Sep 17 00:00:00 2001 From: jiangs <373297395@qq.com> Date: Tue, 20 May 2025 16:34:38 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E5=92=8C=E5=A2=9E=E5=8A=A0eslint=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- eslint.config.js | 31 + index.html | 1 + package.json | 25 +- pnpm-lock.yaml | 4247 ----------------- src/api/liswork/dict/ComDict.js | 20 +- src/api/liswork/dict/LabInstr.js | 18 + src/api/liswork/work/LisWork.js | 59 + src/api/pinyin.js | 43 + src/main.js | 12 +- src/utils/dict.js | 43 +- src/utils/request.js | 5 +- src/views/liswork/dict/index.vue | 187 +- .../liswork/work/components/DictInput.vue | 276 ++ src/views/liswork/work/components/ddlb.vue | 102 + src/views/liswork/work/components/labpat.vue | 144 + .../liswork/work/components/labpatlist.vue | 206 + .../liswork/work/components/labresult.vue | 240 + src/views/liswork/work/index.vue | 505 ++ vite.config.js | 3 + 19 files changed, 1887 insertions(+), 4280 deletions(-) create mode 100644 eslint.config.js delete mode 100644 pnpm-lock.yaml create mode 100644 src/api/liswork/dict/LabInstr.js create mode 100644 src/api/liswork/work/LisWork.js create mode 100644 src/api/pinyin.js create mode 100644 src/views/liswork/work/components/DictInput.vue create mode 100644 src/views/liswork/work/components/ddlb.vue create mode 100644 src/views/liswork/work/components/labpat.vue create mode 100644 src/views/liswork/work/components/labpatlist.vue create mode 100644 src/views/liswork/work/components/labresult.vue create mode 100644 src/views/liswork/work/index.vue diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..cd79f72 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,31 @@ +import js from "@eslint/js"; +import globals from "globals"; +import pluginVue from "eslint-plugin-vue"; +import { defineConfig } from "eslint/config"; + + +export default defineConfig([ + { files: ["**/*.{js,mjs,cjs,vue}"], plugins: { js }, extends: ["js/recommended"] }, + { files: ["**/*.{js,mjs,cjs,vue}"], languageOptions: { globals: globals.browser } }, + pluginVue.configs["flat/essential"], + { + plugins: { + 'auto-import': { + extensions: ['.js', '.mjs', '.jsx', '.vue'], + }, + }, + }, + { + rules: { + 'auto-import/export': 'error', + }, + }, + { + settings: { + 'auto-import': { + // 自动导入的模块配置,与 unplugin-auto-import 配置一致 + imports: ['vue'], + }, + }, + }, +]); diff --git a/index.html b/index.html index 46161a4..22fe2b7 100644 --- a/index.html +++ b/index.html @@ -8,6 +8,7 @@ 实验室检验系统 + \ No newline at end of file diff --git a/src/views/liswork/work/components/DictInput.vue b/src/views/liswork/work/components/DictInput.vue new file mode 100644 index 0000000..dbe08ef --- /dev/null +++ b/src/views/liswork/work/components/DictInput.vue @@ -0,0 +1,276 @@ + + + + + \ No newline at end of file diff --git a/src/views/liswork/work/components/ddlb.vue b/src/views/liswork/work/components/ddlb.vue new file mode 100644 index 0000000..e5c72bb --- /dev/null +++ b/src/views/liswork/work/components/ddlb.vue @@ -0,0 +1,102 @@ + + + + + \ No newline at end of file diff --git a/src/views/liswork/work/components/labpat.vue b/src/views/liswork/work/components/labpat.vue new file mode 100644 index 0000000..7d88d21 --- /dev/null +++ b/src/views/liswork/work/components/labpat.vue @@ -0,0 +1,144 @@ + + + + \ No newline at end of file diff --git a/src/views/liswork/work/components/labpatlist.vue b/src/views/liswork/work/components/labpatlist.vue new file mode 100644 index 0000000..4acde70 --- /dev/null +++ b/src/views/liswork/work/components/labpatlist.vue @@ -0,0 +1,206 @@ + + + + \ No newline at end of file diff --git a/src/views/liswork/work/components/labresult.vue b/src/views/liswork/work/components/labresult.vue new file mode 100644 index 0000000..72fdde4 --- /dev/null +++ b/src/views/liswork/work/components/labresult.vue @@ -0,0 +1,240 @@ + + + + + \ No newline at end of file diff --git a/src/views/liswork/work/index.vue b/src/views/liswork/work/index.vue new file mode 100644 index 0000000..13aec18 --- /dev/null +++ b/src/views/liswork/work/index.vue @@ -0,0 +1,505 @@ + + + + + diff --git a/vite.config.js b/vite.config.js index 9f1472c..334026c 100644 --- a/vite.config.js +++ b/vite.config.js @@ -62,4 +62,7 @@ export default defineConfig(({ mode, command }) => { } } } + optimizeDeps: { + include: ['jquery', 'select2', 'vue3-select2-component'] + } }) From 9081b170712cbd07b389c384c0b1978cde4d5a33 Mon Sep 17 00:00:00 2001 From: jiangs <373297395@qq.com> Date: Tue, 20 May 2025 16:34:38 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E9=97=A8=E8=AF=8A=E9=87=87=E8=A1=80?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- eslint.config.js | 31 + index.html | 1 + package.json | 25 +- pnpm-lock.yaml | 4247 ----------------- src/api/liswork/dict/ComDict.js | 20 +- src/api/liswork/dict/LabInstr.js | 18 + src/api/liswork/work/LisWork.js | 59 + src/api/pinyin.js | 43 + src/main.js | 12 +- src/utils/dict.js | 43 +- src/utils/request.js | 5 +- src/views/liswork/dict/index.vue | 187 +- .../liswork/work/components/DictInput.vue | 276 ++ src/views/liswork/work/components/ddlb.vue | 102 + src/views/liswork/work/components/labpat.vue | 144 + .../liswork/work/components/labpatlist.vue | 206 + .../liswork/work/components/labresult.vue | 240 + src/views/liswork/work/index.vue | 505 ++ vite.config.js | 3 + 19 files changed, 1887 insertions(+), 4280 deletions(-) create mode 100644 eslint.config.js delete mode 100644 pnpm-lock.yaml create mode 100644 src/api/liswork/dict/LabInstr.js create mode 100644 src/api/liswork/work/LisWork.js create mode 100644 src/api/pinyin.js create mode 100644 src/views/liswork/work/components/DictInput.vue create mode 100644 src/views/liswork/work/components/ddlb.vue create mode 100644 src/views/liswork/work/components/labpat.vue create mode 100644 src/views/liswork/work/components/labpatlist.vue create mode 100644 src/views/liswork/work/components/labresult.vue create mode 100644 src/views/liswork/work/index.vue diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..cd79f72 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,31 @@ +import js from "@eslint/js"; +import globals from "globals"; +import pluginVue from "eslint-plugin-vue"; +import { defineConfig } from "eslint/config"; + + +export default defineConfig([ + { files: ["**/*.{js,mjs,cjs,vue}"], plugins: { js }, extends: ["js/recommended"] }, + { files: ["**/*.{js,mjs,cjs,vue}"], languageOptions: { globals: globals.browser } }, + pluginVue.configs["flat/essential"], + { + plugins: { + 'auto-import': { + extensions: ['.js', '.mjs', '.jsx', '.vue'], + }, + }, + }, + { + rules: { + 'auto-import/export': 'error', + }, + }, + { + settings: { + 'auto-import': { + // 自动导入的模块配置,与 unplugin-auto-import 配置一致 + imports: ['vue'], + }, + }, + }, +]); diff --git a/index.html b/index.html index 46161a4..22fe2b7 100644 --- a/index.html +++ b/index.html @@ -8,6 +8,7 @@ 实验室检验系统 + \ No newline at end of file diff --git a/src/views/liswork/work/components/DictInput.vue b/src/views/liswork/work/components/DictInput.vue new file mode 100644 index 0000000..dbe08ef --- /dev/null +++ b/src/views/liswork/work/components/DictInput.vue @@ -0,0 +1,276 @@ + + + + + \ No newline at end of file diff --git a/src/views/liswork/work/components/ddlb.vue b/src/views/liswork/work/components/ddlb.vue new file mode 100644 index 0000000..e5c72bb --- /dev/null +++ b/src/views/liswork/work/components/ddlb.vue @@ -0,0 +1,102 @@ + + + + + \ No newline at end of file diff --git a/src/views/liswork/work/components/labpat.vue b/src/views/liswork/work/components/labpat.vue new file mode 100644 index 0000000..7d88d21 --- /dev/null +++ b/src/views/liswork/work/components/labpat.vue @@ -0,0 +1,144 @@ + + + + \ No newline at end of file diff --git a/src/views/liswork/work/components/labpatlist.vue b/src/views/liswork/work/components/labpatlist.vue new file mode 100644 index 0000000..4acde70 --- /dev/null +++ b/src/views/liswork/work/components/labpatlist.vue @@ -0,0 +1,206 @@ + + + + \ No newline at end of file diff --git a/src/views/liswork/work/components/labresult.vue b/src/views/liswork/work/components/labresult.vue new file mode 100644 index 0000000..72fdde4 --- /dev/null +++ b/src/views/liswork/work/components/labresult.vue @@ -0,0 +1,240 @@ + + + + + \ No newline at end of file diff --git a/src/views/liswork/work/index.vue b/src/views/liswork/work/index.vue new file mode 100644 index 0000000..13aec18 --- /dev/null +++ b/src/views/liswork/work/index.vue @@ -0,0 +1,505 @@ + + + + + diff --git a/vite.config.js b/vite.config.js index 9f1472c..334026c 100644 --- a/vite.config.js +++ b/vite.config.js @@ -62,4 +62,7 @@ export default defineConfig(({ mode, command }) => { } } } + optimizeDeps: { + include: ['jquery', 'select2', 'vue3-select2-component'] + } }) From 1a6f5411e960f728635cc456dcc8fe7da1b7e8b3 Mon Sep 17 00:00:00 2001 From: tangw Date: Mon, 21 Jul 2025 17:53:19 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=97=A8=E8=AF=8A?= =?UTF-8?q?=E9=87=87=E8=A1=80=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/mzcx/cydj.js | 44 ++ .../liswork/work/components/DictInput.vue | 260 +++++------ src/views/mzcx/cydj/index.vue | 402 ++++++++++++++++++ 3 files changed, 545 insertions(+), 161 deletions(-) create mode 100644 src/api/mzcx/cydj.js create mode 100644 src/views/mzcx/cydj/index.vue diff --git a/src/api/mzcx/cydj.js b/src/api/mzcx/cydj.js new file mode 100644 index 0000000..61b363f --- /dev/null +++ b/src/api/mzcx/cydj.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询采样登记列表 +export function querySQD(query) { + return request({ + url: '/mzcx/querySQD', + method: 'get', + params: query + }) +} + +// 查询采样登记详细 +export function getReqmain(sqh) { + return request({ + url: '/system/reqmain/' + sqh, + method: 'get' + }) +} + +// 新增采样登记 +export function addReqmain(data) { + return request({ + url: '/system/reqmain', + method: 'post', + data: data + }) +} + +// 修改采样登记 +export function updateReqmain(data) { + return request({ + url: '/system/reqmain', + method: 'put', + data: data + }) +} + +// 删除采样登记 +export function delReqmain(sqh) { + return request({ + url: '/system/reqmain/' + sqh, + method: 'delete' + }) +} diff --git a/src/views/liswork/work/components/DictInput.vue b/src/views/liswork/work/components/DictInput.vue index dbe08ef..ab6569c 100644 --- a/src/views/liswork/work/components/DictInput.vue +++ b/src/views/liswork/work/components/DictInput.vue @@ -9,53 +9,48 @@ @clear="handleClear" @dblclick="handleDblClick" > - - + + - + - + - - - - - - - + + + + + + + + @@ -64,62 +59,36 @@ import { ref, computed, watch, onMounted } from 'vue'; import { Loading, ArrowDown } from '@element-plus/icons-vue'; -// 组件参数(Vue3 语法) +import { getFirstLetter } from '@/api/pinyin.js'; // 引入拼音处理工具 +// 组件参数 const props = defineProps({ - modelValue: { // 双向绑定的原始值 - type: [String, Number], - default: '' - }, - dictType: { // 字典类型 - type: String, - required: true - }, - placeholder: { - type: String, - default: '请输入或双击选择' - }, - clearable: { - type: Boolean, - default: true - }, - disabled: { - type: Boolean, - default: false - }, - fetchDict: { // 获取字典的方法(需返回 Promise) - type: Function, - required: true - }, - dialogTitle: { - type: String, - default: '选择字典项' - } + modelValue: { type: [String, Number], default: '' }, + dictType: { type: String, required: true }, + placeholder: { type: String, default: '请输入或双击选择' }, + clearable: { type: Boolean, default: true }, + disabled: {type: Boolean, default: false}, + fetchDict: {type: Function, required: true}, + dialogTitle: {type: String, default: '选择字典项'} }); -// 组件事件(Vue3 语法) -const emit = defineEmits([ - 'update:modelValue', // 同步原始值 - 'update:labelValue', // 同步标签值 - 'select' // 选中事件 -]); +// 组件事件 +const emit = defineEmits(['update:modelValue', 'update:labelValue', 'select']); -// 内部状态(Vue3 ref 响应式) -const tempValue = ref(''); // 临时输入值 -const labelValue = ref(''); // 映射后的标签 -const dictData = ref([]); // 完整字典数据 -const filteredDictData = ref([]); // 过滤后的字典数据 -const isDictLoading = ref(true); // 字典加载状态 -const dialogVisible = ref(false); // 弹窗显示状态 -const searchKey = ref(''); // 搜索关键词 +// 内部状态 +const tempValue = ref(''); +const labelValue = ref(''); +const dictData = ref([]); // 存储带简拼的字典数据 +const filteredDictData = ref([]); +const isDictLoading = ref(true); +const dialogVisible = ref(false); +const searchKey = ref(''); -// 显示值计算(Vue3 computed) +// 显示值计算 const displayValue = computed({ get() { - // 优先显示标签,无则显示原始值 return labelValue.value || tempValue.value || props.modelValue || ''; }, set(newValue) { - // 用户输入时更新临时值,并清除旧标签 tempValue.value = newValue; if (labelValue.value && newValue !== labelValue.value) { labelValue.value = ''; @@ -128,14 +97,20 @@ const displayValue = computed({ } }); -// 加载字典数据 + + +// 加载字典数据(并添加简拼字段) const loadDictData = async () => { try { isDictLoading.value = true; - // 调用父组件传入的字典获取方法 - const data = await props.fetchDict(props.dictType); - dictData.value = data || []; - filteredDictData.value = [...dictData.value]; // 初始化过滤数据 + const rawData = await props.fetchDict(props.dictType); + // 为每个字典项添加简拼字段 + dictData.value = (rawData || []).map(item => ({ + ...item, + pinyin: getFirstLetter(item.label) // 新增pinyin字段存储简拼 + })); + + filteredDictData.value = [...dictData.value]; } catch (error) { console.error(`加载${props.dictType}字典失败:`, error); dictData.value = []; @@ -145,23 +120,30 @@ const loadDictData = async () => { } }; -// 过滤字典数据(搜索功能) +// 核心搜索逻辑(支持模糊搜索+简拼搜索) const filterDictData = () => { - if (!searchKey.value) { + const key = searchKey.value.trim().toLowerCase(); + if (!key) { filteredDictData.value = [...dictData.value]; return; } - const key = searchKey.value.toLowerCase(); - filteredDictData.value = dictData.value.filter(item => - item.label.toLowerCase().includes(key) || - String(item.value).toLowerCase().includes(key) - ); + + filteredDictData.value = dictData.value.filter(item => { + // 1. 模糊搜索:匹配label(名称)或value(编码) + const matchLabel = item.label.toLowerCase().includes(key); + const matchValue = String(item.value).toLowerCase().includes(key); + + // 2. 简拼搜索:匹配首字母简拼 + const matchPinyin = item.pinyin.toLowerCase().includes(key); + + // 满足任一条件即匹配 + return matchLabel || matchValue || matchPinyin; + }); }; // 双击事件处理 const handleDblClick = () => { if (!props.disabled && !isDictLoading.value) { - console.log('双击触发弹窗'); dialogVisible.value = true; } }; @@ -170,82 +152,39 @@ const handleDblClick = () => { const openDictSelector = () => { if (!props.disabled && !isDictLoading.value) { dialogVisible.value = true; - searchKey.value = ''; // 重置搜索 - filterDictData(); // 重置过滤 + searchKey.value = ''; + filterDictData(); } }; // 选择字典项 const selectItem = (item) => { - // 同步原始值和标签值到父组件 emit('update:modelValue', item.value); emit('update:labelValue', item.label); - emit('select', item); // 触发选中事件 - - // 更新内部状态 + emit('select', item); tempValue.value = item.value; labelValue.value = item.label; - - // 关闭弹窗 dialogVisible.value = false; }; -// 失焦时自动映射 -const handleBlur = () => { - const value = tempValue.value.trim() || props.modelValue; - if (!value) { - emit('update:modelValue', ''); - emit('update:labelValue', ''); - labelValue.value = ''; - tempValue.value = ''; - return; - } - - // 查找匹配的字典项 - const matched = dictData.value.find( - item => String(item.value) === String(value) - ); - - if (matched) { - emit('update:labelValue', matched.label); - labelValue.value = matched.label; - } else { - emit('update:labelValue', value); // 无匹配时用原始值 - labelValue.value = value; - } +// 其他方法(失焦、清空等)保持不变 +const handleBlur = () => { /* ... */ }; - -// 清空输入 -const handleClear = () => { - tempValue.value = ''; - labelValue.value = ''; - emit('update:modelValue', ''); - emit('update:labelValue', ''); +const handleClear = () => { /* ... */ }; - -// 关闭弹窗 const handleDialogClose = () => { dialogVisible.value = false; }; -// 监听父组件传入的初始值 -watch( - () => props.modelValue, - (newVal) => { - if (newVal === tempValue.value) return; // 避免重复更新 - tempValue.value = newVal || ''; - - // 初始值自动映射标签 - if (newVal && !isDictLoading.value) { - const matched = dictData.value.find( - item => String(item.value) === String(newVal) - ); - labelValue.value = matched?.label || newVal; - emit('update:labelValue', labelValue.value); - } - }, - { immediate: true } // 初始化时执行一次 -); +// 监听初始值变化 +watch(() => props.modelValue, (newVal) => { + tempValue.value = newVal || ''; + if (newVal && !isDictLoading.value) { + const matched = dictData.value.find(item => String(item.value) === String(newVal)); + labelValue.value = matched?.label || newVal; + emit('update:labelValue', labelValue.value); + } +}, {immediate: true}); // 组件挂载时加载字典 onMounted(async () => { @@ -254,6 +193,7 @@ onMounted(async () => { From 0aec49b2eb88f9d0abdb435d4a72ac628ec6b407 Mon Sep 17 00:00:00 2001 From: tangw Date: Mon, 21 Jul 2025 18:06:57 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=AD=97=E5=85=B8=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=AE=80=E6=8B=BC=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liswork/work/components/DictInput.vue | 228 ------------------ 1 file changed, 228 deletions(-) diff --git a/src/views/liswork/work/components/DictInput.vue b/src/views/liswork/work/components/DictInput.vue index 541f47c..ab6569c 100644 --- a/src/views/liswork/work/components/DictInput.vue +++ b/src/views/liswork/work/components/DictInput.vue @@ -9,7 +9,6 @@ @clear="handleClear" @dblclick="handleDblClick" > -<<<<<<< HEAD @@ -52,55 +51,6 @@ -======= - - - - - - - - - - - - - - - ->>>>>>> e1f19883e37f969d4e8ada6a3137ba399ebfc6df @@ -109,7 +59,6 @@ import { ref, computed, watch, onMounted } from 'vue'; import { Loading, ArrowDown } from '@element-plus/icons-vue'; -<<<<<<< HEAD import { getFirstLetter } from '@/api/pinyin.js'; // 引入拼音处理工具 // 组件参数 const props = defineProps({ @@ -140,64 +89,6 @@ const displayValue = computed({ return labelValue.value || tempValue.value || props.modelValue || ''; }, set(newValue) { -======= -// 组件参数(Vue3 语法) -const props = defineProps({ - modelValue: { // 双向绑定的原始值 - type: [String, Number], - default: '' - }, - dictType: { // 字典类型 - type: String, - required: true - }, - placeholder: { - type: String, - default: '请输入或双击选择' - }, - clearable: { - type: Boolean, - default: true - }, - disabled: { - type: Boolean, - default: false - }, - fetchDict: { // 获取字典的方法(需返回 Promise) - type: Function, - required: true - }, - dialogTitle: { - type: String, - default: '选择字典项' - } -}); - -// 组件事件(Vue3 语法) -const emit = defineEmits([ - 'update:modelValue', // 同步原始值 - 'update:labelValue', // 同步标签值 - 'select' // 选中事件 -]); - -// 内部状态(Vue3 ref 响应式) -const tempValue = ref(''); // 临时输入值 -const labelValue = ref(''); // 映射后的标签 -const dictData = ref([]); // 完整字典数据 -const filteredDictData = ref([]); // 过滤后的字典数据 -const isDictLoading = ref(true); // 字典加载状态 -const dialogVisible = ref(false); // 弹窗显示状态 -const searchKey = ref(''); // 搜索关键词 - -// 显示值计算(Vue3 computed) -const displayValue = computed({ - get() { - // 优先显示标签,无则显示原始值 - return labelValue.value || tempValue.value || props.modelValue || ''; - }, - set(newValue) { - // 用户输入时更新临时值,并清除旧标签 ->>>>>>> e1f19883e37f969d4e8ada6a3137ba399ebfc6df tempValue.value = newValue; if (labelValue.value && newValue !== labelValue.value) { labelValue.value = ''; @@ -206,7 +97,6 @@ const displayValue = computed({ } }); -<<<<<<< HEAD // 加载字典数据(并添加简拼字段) @@ -221,16 +111,6 @@ const loadDictData = async () => { })); filteredDictData.value = [...dictData.value]; -======= -// 加载字典数据 -const loadDictData = async () => { - try { - isDictLoading.value = true; - // 调用父组件传入的字典获取方法 - const data = await props.fetchDict(props.dictType); - dictData.value = data || []; - filteredDictData.value = [...dictData.value]; // 初始化过滤数据 ->>>>>>> e1f19883e37f969d4e8ada6a3137ba399ebfc6df } catch (error) { console.error(`加载${props.dictType}字典失败:`, error); dictData.value = []; @@ -240,7 +120,6 @@ const loadDictData = async () => { } }; -<<<<<<< HEAD // 核心搜索逻辑(支持模糊搜索+简拼搜索) const filterDictData = () => { const key = searchKey.value.trim().toLowerCase(); @@ -260,28 +139,11 @@ const filterDictData = () => { // 满足任一条件即匹配 return matchLabel || matchValue || matchPinyin; }); -======= -// 过滤字典数据(搜索功能) -const filterDictData = () => { - if (!searchKey.value) { - filteredDictData.value = [...dictData.value]; - return; - } - const key = searchKey.value.toLowerCase(); - filteredDictData.value = dictData.value.filter(item => - item.label.toLowerCase().includes(key) || - String(item.value).toLowerCase().includes(key) - ); ->>>>>>> e1f19883e37f969d4e8ada6a3137ba399ebfc6df }; // 双击事件处理 const handleDblClick = () => { if (!props.disabled && !isDictLoading.value) { -<<<<<<< HEAD -======= - console.log('双击触发弹窗'); ->>>>>>> e1f19883e37f969d4e8ada6a3137ba399ebfc6df dialogVisible.value = true; } }; @@ -290,19 +152,13 @@ const handleDblClick = () => { const openDictSelector = () => { if (!props.disabled && !isDictLoading.value) { dialogVisible.value = true; -<<<<<<< HEAD searchKey.value = ''; filterDictData(); -======= - searchKey.value = ''; // 重置搜索 - filterDictData(); // 重置过滤 ->>>>>>> e1f19883e37f969d4e8ada6a3137ba399ebfc6df } }; // 选择字典项 const selectItem = (item) => { -<<<<<<< HEAD emit('update:modelValue', item.value); emit('update:labelValue', item.label); emit('select', item); @@ -316,60 +172,10 @@ const handleBlur = () => { /* ... */ }; const handleClear = () => { /* ... */ }; -======= - // 同步原始值和标签值到父组件 - emit('update:modelValue', item.value); - emit('update:labelValue', item.label); - emit('select', item); // 触发选中事件 - - // 更新内部状态 - tempValue.value = item.value; - labelValue.value = item.label; - - // 关闭弹窗 - dialogVisible.value = false; -}; - -// 失焦时自动映射 -const handleBlur = () => { - const value = tempValue.value.trim() || props.modelValue; - if (!value) { - emit('update:modelValue', ''); - emit('update:labelValue', ''); - labelValue.value = ''; - tempValue.value = ''; - return; - } - - // 查找匹配的字典项 - const matched = dictData.value.find( - item => String(item.value) === String(value) - ); - - if (matched) { - emit('update:labelValue', matched.label); - labelValue.value = matched.label; - } else { - emit('update:labelValue', value); // 无匹配时用原始值 - labelValue.value = value; - } -}; - -// 清空输入 -const handleClear = () => { - tempValue.value = ''; - labelValue.value = ''; - emit('update:modelValue', ''); - emit('update:labelValue', ''); -}; - -// 关闭弹窗 ->>>>>>> e1f19883e37f969d4e8ada6a3137ba399ebfc6df const handleDialogClose = () => { dialogVisible.value = false; }; -<<<<<<< HEAD // 监听初始值变化 watch(() => props.modelValue, (newVal) => { tempValue.value = newVal || ''; @@ -379,26 +185,6 @@ watch(() => props.modelValue, (newVal) => { emit('update:labelValue', labelValue.value); } }, {immediate: true}); -======= -// 监听父组件传入的初始值 -watch( - () => props.modelValue, - (newVal) => { - if (newVal === tempValue.value) return; // 避免重复更新 - tempValue.value = newVal || ''; - - // 初始值自动映射标签 - if (newVal && !isDictLoading.value) { - const matched = dictData.value.find( - item => String(item.value) === String(newVal) - ); - labelValue.value = matched?.label || newVal; - emit('update:labelValue', labelValue.value); - } - }, - { immediate: true } // 初始化时执行一次 -); ->>>>>>> e1f19883e37f969d4e8ada6a3137ba399ebfc6df // 组件挂载时加载字典 onMounted(async () => { @@ -407,10 +193,7 @@ onMounted(async () => {