Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
custom_form
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2023-04-17 14:21:06 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
dfd07df412cdc7f72e12d1fc447db184378546e7
dfd07df4
1 parent
36f34eec
替换数组交集方法
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
5 deletions
components.d.ts
src/pages/table/index.vue
src/utils/tools.js
components.d.ts
View file @
dfd07df
...
...
@@ -31,7 +31,6 @@ declare module '@vue/runtime-core' {
NutCell
:
typeof
import
(
'@nutui/nutui-taro'
)[
'Cell'
]
NutCheckbox
:
typeof
import
(
'@nutui/nutui-taro'
)[
'Checkbox'
]
NutCheckboxGroup
:
typeof
import
(
'@nutui/nutui-taro'
)[
'CheckboxGroup'
]
NutCol
:
typeof
import
(
'@nutui/nutui-taro'
)[
'Col'
]
NutConfigProvider
:
typeof
import
(
'@nutui/nutui-taro'
)[
'ConfigProvider'
]
NutDatePicker
:
typeof
import
(
'@nutui/nutui-taro'
)[
'DatePicker'
]
NutDialog
:
typeof
import
(
'@nutui/nutui-taro'
)[
'Dialog'
]
...
...
@@ -49,7 +48,6 @@ declare module '@vue/runtime-core' {
NutRadio
:
typeof
import
(
'@nutui/nutui-taro'
)[
'Radio'
]
NutRadioGroup
:
typeof
import
(
'@nutui/nutui-taro'
)[
'RadioGroup'
]
NutRate
:
typeof
import
(
'@nutui/nutui-taro'
)[
'Rate'
]
NutRow
:
typeof
import
(
'@nutui/nutui-taro'
)[
'Row'
]
NutSignature
:
typeof
import
(
'@nutui/nutui-taro'
)[
'Signature'
]
NutSwiper
:
typeof
import
(
'@nutui/nutui-taro'
)[
'Swiper'
]
NutSwiperItem
:
typeof
import
(
'@nutui/nutui-taro'
)[
'SwiperItem'
]
...
...
src/pages/table/index.vue
View file @
dfd07df
<!--
* @Date: 2023-03-24 09:19:27
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-04-17 14:
09:23
* @LastEditTime: 2023-04-17 14:
19:54
* @FilePath: /custom_form/src/pages/table/index.vue
* @Description: 文件描述
-->
...
...
@@ -63,7 +63,7 @@ import { storeToRefs } from 'pinia'
import { mainStore } from '@/stores'
import { queryFormAPI, postVerifyPasswordAPI } from "@/api/form.js";
import { addFormDataAPI } from "@/api/data.js";
import { wxInfo, getUrlParams, deepClone } from "@/utils/tools";
import { wxInfo, getUrlParams, deepClone
, intersection
} from "@/utils/tools";
import { styleColor } from "@/constant.js";
import { sharePage } from '@/composables/useShare.js'
// 初始化WX环境
...
...
@@ -399,7 +399,7 @@ const checkRules = () => {
condition += `${k}${op}`
}
if (typeof postData.value[expr['field_name']] === 'object') { // 表单值为数组(多选)
const k = !!(
_.
intersection(expr['values'], postData.value[expr['field_name']])).length;
const k = !!(intersection(expr['values'], postData.value[expr['field_name']])).length;
condition += `${k}${op}`
}
});
...
...
src/utils/tools.js
View file @
dfd07df
...
...
@@ -150,6 +150,39 @@ const deepClone = (val) => {
}
}
// 获取交集
const
intersection
=
()
=>
{
const
arrays
=
Array
.
prototype
.
slice
.
call
(
arguments
);
// 将参数转换为数组
const
result
=
[];
if
(
arrays
.
length
===
0
)
{
// 如果没有参数,则返回空数组
return
result
;
}
const
firstArray
=
arrays
[
0
];
for
(
let
i
=
0
;
i
<
firstArray
.
length
;
i
++
)
{
const
currentElement
=
firstArray
[
i
];
if
(
result
.
includes
(
currentElement
))
{
// 如果当前元素已经在结果中,则跳过
continue
;
}
let
foundInAllArrays
=
true
;
for
(
let
j
=
1
;
j
<
arrays
.
length
;
j
++
)
{
const
currentArray
=
arrays
[
j
];
if
(
!
currentArray
.
includes
(
currentElement
))
{
// 如果当前元素不在其中一个数组中,则跳过
foundInAllArrays
=
false
;
break
;
}
}
if
(
foundInAllArrays
)
{
// 如果当前元素在所有数组中都存在,则添加到结果中
result
.
push
(
currentElement
);
}
}
return
result
;
}
export
{
formatDate
,
wxInfo
,
...
...
@@ -160,4 +193,5 @@ export {
getUrlParams
,
stringifyQuery
,
deepClone
,
intersection
,
}
...
...
Please
register
or
login
to post a comment