@@ -86,7 +86,7 @@ export default {
8686
8787<script lang="ts" setup>
8888import { getCurrentInstance , onBeforeMount , ref , watch , computed , onMounted , nextTick } from ' vue'
89- import { deepClone , defaultDisplayFormat , getType , isArray , isDef } from ' ../common/util'
89+ import { deepClone , defaultDisplayFormat , getType , isArray , isDef , isFunction } from ' ../common/util'
9090import { useCell } from ' ../composables/useCell'
9191import { type ColumnItem , formatArray } from ' ../wd-picker-view/types'
9292import { FORM_KEY , type FormItemRule } from ' ../wd-form/types'
@@ -112,14 +112,16 @@ const resetColumns = ref<Array<string | number | ColumnItem | Array<string | num
112112const isPicking = ref <boolean >(false ) // 判断pickview是否还在滑动中
113113const hasConfirmed = ref <boolean >(false ) // 判断用户是否点击了确认按钮
114114
115+ const emit = defineEmits ([' confirm' , ' open' , ' cancel' , ' update:modelValue' ])
116+
115117const isLoading = computed (() => {
116118 return props .loading || innerLoading .value
117119})
118120
119121watch (
120122 () => props .displayFormat ,
121123 (fn ) => {
122- if (fn && getType (fn ) !== ' function ' ) {
124+ if (fn && ! isFunction (fn )) {
123125 console .error (' The type of displayFormat must be Function' )
124126 }
125127 if (pickerViewWd .value && pickerViewWd .value .selectedIndex && pickerViewWd .value .selectedIndex .length !== 0 ) {
@@ -186,7 +188,7 @@ watch(
186188watch (
187189 () => props .columnChange ,
188190 (newValue ) => {
189- if (newValue && getType (newValue ) !== ' function ' ) {
191+ if (newValue && ! isFunction (newValue )) {
190192 console .error (' The type of columnChange must be Function' )
191193 }
192194 },
@@ -223,8 +225,6 @@ const isRequired = computed(() => {
223225
224226const { proxy } = getCurrentInstance () as any
225227
226- const emit = defineEmits ([' confirm' , ' open' , ' cancel' , ' update:modelValue' ])
227-
228228onMounted (() => {
229229 isDef (props .modelValue ) && props .modelValue !== ' ' && setShowValue (getSelects (props .modelValue )! )
230230 if (isDef (props .modelValue ) && props .modelValue !== ' ' && pickerViewWd .value && pickerViewWd .value .getSelects ) {
@@ -257,7 +257,7 @@ function getSelects(value: string | number | Array<string | number | Array<any>>
257257 * 2.根据formatColumns的长度截取Array<String>,保证下面的遍历不溢出
258258 * 3.根据每列的key值找到选项中value为此key的下标并记录
259259 */
260- value = value instanceof Array ? value : [value ]
260+ value = isArray ( value ) ? value : [value ]
261261 value = value .slice (0 , formatColumns .length )
262262
263263 if (value .length === 0 ) {
@@ -319,7 +319,7 @@ function onConfirm() {
319319 }
320320
321321 const { beforeConfirm } = props
322- if (beforeConfirm && getType (beforeConfirm ) === ' function ' ) {
322+ if (beforeConfirm && isFunction (beforeConfirm )) {
323323 beforeConfirm (
324324 pickerValue .value ,
325325 (isPass : boolean ) => {
@@ -363,7 +363,7 @@ function pickerViewChange({ value }: any) {
363363 */
364364function setShowValue(items : ColumnItem | ColumnItem []) {
365365 // 避免值为空时调用自定义展示函数
366- if ((items instanceof Array && ! items .length ) || ! items ) return
366+ if ((isArray ( items ) && ! items .length ) || ! items ) return
367367
368368 const { valueKey, labelKey } = props
369369 showValue .value = (props .displayFormat || defaultDisplayFormat )(items , { valueKey , labelKey })
0 commit comments