|
@@ -6,7 +6,7 @@ import {stringIsBlank} from "@/utils/blank-utils";
|
|
|
declare type CodeType<T> = keyof T & string | ((item: T) => string);
|
|
|
|
|
|
function cyRefList<T = any>(code: CodeType<T>, errMsg: (item: T) => string = () => '请勿重复添加') {
|
|
|
- const list = ref<T[]>([])
|
|
|
+ const list = ref([]) as Ref<T[]>
|
|
|
const watchFunc: Function[] = []
|
|
|
|
|
|
const codeIsFunction = typeof code === 'function'
|
|
@@ -30,7 +30,6 @@ function cyRefList<T = any>(code: CodeType<T>, errMsg: (item: T) => string = ()
|
|
|
const listProxy = {
|
|
|
push: function (...items: T[]) {
|
|
|
const msgList: string[] = []
|
|
|
-
|
|
|
items.forEach((item: T) => {
|
|
|
let key: string;
|
|
|
if (codeIsFunction) {
|
|
@@ -53,7 +52,6 @@ function cyRefList<T = any>(code: CodeType<T>, errMsg: (item: T) => string = ()
|
|
|
}
|
|
|
sendListening(items).then(r => {
|
|
|
});
|
|
|
- // @ts-ignore
|
|
|
return list.value.push(...items)
|
|
|
},
|
|
|
watchPush: function (cb: (value: T) => void) {
|
|
@@ -90,7 +88,7 @@ function cyRefList<T = any>(code: CodeType<T>, errMsg: (item: T) => string = ()
|
|
|
},
|
|
|
}
|
|
|
|
|
|
- return [list as Ref<T[]>, listProxy]
|
|
|
+ return [list, listProxy]
|
|
|
}
|
|
|
|
|
|
export default cyRefList
|