From 21eb71d35d4d60dc78f1f9766f75adea4abc3f2d Mon Sep 17 00:00:00 2001 From: gaoyunqi Date: Thu, 16 May 2024 17:13:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=98=8E=E7=BB=86=E8=A1=A8=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E9=80=89=E4=BA=BA=E7=BB=84=E4=BB=B6=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E5=B0=86=E6=96=87=E5=AD=97=E9=83=A8=E5=88=86=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E5=88=B0=E7=8B=AC=E7=AB=8B=E5=AD=97=E6=AE=B5=EF=BC=8C=E4=BB=A5?= =?UTF-8?q?=E5=8A=A0=E5=BF=AB=E6=B8=B2=E6=9F=93=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/SelectDepartmentV2.vue | 17 +- .../Form/src/components/SelectUserV2.vue | 836 +++++++++--------- src/utils/event/design.ts | 33 +- src/utils/stringUtil.js | 20 + 4 files changed, 479 insertions(+), 427 deletions(-) create mode 100644 src/utils/stringUtil.js diff --git a/src/components/Form/src/components/SelectDepartmentV2.vue b/src/components/Form/src/components/SelectDepartmentV2.vue index e032349..2c395ea 100644 --- a/src/components/Form/src/components/SelectDepartmentV2.vue +++ b/src/components/Form/src/components/SelectDepartmentV2.vue @@ -34,7 +34,7 @@ const emits = defineEmits(['change', 'changeNames', 'close', 'options-change', 'update:value']); import { getDepartmentTrees } from '/@/api/system/department'; import { CloseOutlined } from '@ant-design/icons-vue'; - import { camelCaseString } from '/@/utils/event/design'; + import { camelCaseString } from '/@/utils/stringUtil'; const visible = ref(false); const departNames = ref(); @@ -76,7 +76,7 @@ (val) => { if (val) { if (props.sepTextField && !valChanged.value) { - departNames.value = props.row[camelCaseString(props.sepTextField, true)]; + departNames.value = props.row[camelCaseString(props.sepTextField)]; } else { getDefaultList(val); } @@ -99,9 +99,14 @@ let nameList = selectedNodes.value.map((item) => item.name); const names = nameList.join(','); departNames.value = names; - if (props.sepTextField) { - props.row[camelCaseString(props.sepTextField, true)] = names; + updateSepTextField(names); + } + + function updateSepTextField(v) { + if (!props.sepTextField || !props.row) { + return; } + props.row[props.sepTextField] = v; } function resetTreeList(list) { @@ -142,9 +147,7 @@ const ids = idList.join(','); emits('update:value', ids); departNames.value = names; - if (props.sepTextField) { - props.row[camelCaseString(props.sepTextField, true)] = names; - } + updateSepTextField(names); } function deleteItem() { diff --git a/src/components/Form/src/components/SelectUserV2.vue b/src/components/Form/src/components/SelectUserV2.vue index a30e4f9..c99723c 100644 --- a/src/components/Form/src/components/SelectUserV2.vue +++ b/src/components/Form/src/components/SelectUserV2.vue @@ -1,423 +1,455 @@ - diff --git a/src/utils/event/design.ts b/src/utils/event/design.ts index 94f1835..2b12e65 100644 --- a/src/utils/event/design.ts +++ b/src/utils/event/design.ts @@ -27,25 +27,22 @@ export function changeToPinyin(label: string, isUpper?: boolean) { /* 如果没有下划线,不需要处理 如果有下划线,用下划线切割,第一个下划线左边的全部小写,后面的首字母大写,首字母后面的全部小写 */ -export function camelCaseString(string: string, skipNoUnderline = false) { - if (!string) return; - if (skipNoUnderline && string.indexOf('_') < 0) { - return string; - } - const stringLower = string.toLowerCase(); - const len = stringLower.length; - let str = ''; - for (let i = 0; i < len; i++) { - const c = stringLower.charAt(i); - if (c === '_') { - if (++i < len) { - str = str.concat(stringLower.charAt(i).toUpperCase()); - } - } else { - str = str.concat(c); +export function camelCaseString(string: string) { + if (!string) return; + const stringLower = string.toLowerCase(); + const len = stringLower.length; + let str = ''; + for (let i = 0; i < len; i++) { + const c = stringLower.charAt(i); + if (c === '_') { + if (++i < len) { + str = str.concat(stringLower.charAt(i).toUpperCase()); + } + } else { + str = str.concat(c); + } } - } - return str; + return str; } export async function apiConfigFunc(apiConfig, isCustomForm = false, formModel?, index?) { diff --git a/src/utils/stringUtil.js b/src/utils/stringUtil.js new file mode 100644 index 0000000..cca30ae --- /dev/null +++ b/src/utils/stringUtil.js @@ -0,0 +1,20 @@ +export function camelCaseString(string) { + if (!string) return; + if (string.indexOf('_') < 0) { + return string; + } + const stringLower = string.toLowerCase(); + const len = stringLower.length; + let str = ''; + for (let i = 0; i < len; i++) { + const c = stringLower.charAt(i); + if (c === '_') { + if (++i < len) { + str = str.concat(stringLower.charAt(i).toUpperCase()); + } + } else { + str = str.concat(c); + } + } + return str; +}