adtec-core-package 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -18,12 +18,53 @@
|
|
|
18
18
|
font-size: 14px;
|
|
19
19
|
font-weight: bold;
|
|
20
20
|
"
|
|
21
|
-
|
|
21
|
+
>1</span
|
|
22
22
|
>
|
|
23
|
-
<el-text style="margin-left: 16px">共 {{
|
|
23
|
+
<el-text style="margin-left: 16px">共 {{ computedModel }} 条</el-text>
|
|
24
24
|
</el-flex>
|
|
25
25
|
</template>
|
|
26
26
|
<script setup lang="ts">
|
|
27
|
-
|
|
27
|
+
import { computed } from 'vue'
|
|
28
|
+
|
|
29
|
+
const props=defineProps({
|
|
30
|
+
/**
|
|
31
|
+
* @type string
|
|
32
|
+
* @default ''
|
|
33
|
+
* @description 提示文字
|
|
34
|
+
*/
|
|
35
|
+
children: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: 'children',
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
const model = defineModel()
|
|
41
|
+
const computedModel = computed(() => {
|
|
42
|
+
let total
|
|
43
|
+
if (typeof model.value === 'number') {
|
|
44
|
+
total = model.value
|
|
45
|
+
} else if (typeof model.value === 'string') {
|
|
46
|
+
total = model.value
|
|
47
|
+
} else if (Array.isArray(model.value)) {
|
|
48
|
+
let t=0
|
|
49
|
+
model.value.forEach(item=>{
|
|
50
|
+
if(item[props.children]){
|
|
51
|
+
t+=getTotal(item[props.children])
|
|
52
|
+
}
|
|
53
|
+
t++
|
|
54
|
+
})
|
|
55
|
+
total=t
|
|
56
|
+
}
|
|
57
|
+
return total
|
|
58
|
+
})
|
|
59
|
+
const getTotal = (arr:any[]) => {
|
|
60
|
+
let t=0
|
|
61
|
+
arr.forEach(item => {
|
|
62
|
+
if (item[props.children]) {
|
|
63
|
+
t+=getTotal(item[props.children])
|
|
64
|
+
}
|
|
65
|
+
t++
|
|
66
|
+
})
|
|
67
|
+
return t;
|
|
68
|
+
}
|
|
28
69
|
</script>
|
|
29
70
|
<style scoped lang="scss"></style>
|