智能柜开门拒绝授权
This commit is contained in:
1 parent
3a5eae8646
commit
587858fc74
4 files changed
+92
-81
No files matched your search
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, provide, getCurrentInstance, PropType, computed, inject, onMounted } from 'vue'
|
||||
import { ref, watch, provide, getCurrentInstance, computed, inject, onMounted } from 'vue'
|
||||
import { arrayNumberValid, arrayNumberValidByStyleMP, covetUniNumber, linearValid, getUnit, getUid } from "../../libs/tool";
|
||||
import { useTmConfig } from "../../libs/config";
|
||||
import { getDefaultColor, setTextColorLightByDark, getOutlineColorObj, getTextColorObj, getThinColorObj } from "../../libs/colors";
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, provide, onBeforeMount, PropType, computed } from 'vue'
|
||||
import { arrayNumberValid, arrayNumberValidByStyleMP, covetUniNumber, linearValid, getUnit, getUid } from "../../libs/tool";
|
||||
import { useTmConfig } from "../../libs/config";
|
||||
import { getDefaultColor, setTextColorLightByDark, getOutlineColorObj, getTextColorObj, getThinColorObj } from "../../libs/colors";
|
||||
import { ref, watch, provide, onBeforeMount, computed } from "vue"
|
||||
import { arrayNumberValid, arrayNumberValidByStyleMP, covetUniNumber, linearValid, getUnit, getUid } from "../../libs/tool"
|
||||
import { useTmConfig } from "../../libs/config"
|
||||
import { getDefaultColor, setTextColorLightByDark, getOutlineColorObj, getTextColorObj, getThinColorObj } from "../../libs/colors"
|
||||
|
||||
/**
|
||||
* @displayName 折叠面板
|
||||
@@ -14,100 +14,103 @@ import { getDefaultColor, setTextColorLightByDark, getOutlineColorObj, getTextCo
|
||||
| --- | --- | --- | --- |
|
||||
| ☑️| ☑️ | ☑️ | ☑️ | ☑️ | 1.0.0 |
|
||||
*/
|
||||
defineOptions({ name: 'TmCollapse' });
|
||||
defineOptions({ name: "TmCollapse" })
|
||||
|
||||
const { config } = useTmConfig()
|
||||
|
||||
|
||||
const props = defineProps({
|
||||
/**
|
||||
* 当前子项值。可v-model,类型兼容性高,因此不管你提供的是不是数组,最终同步时会被设置成数组
|
||||
*/
|
||||
modelValue: {
|
||||
type: [Array<string | number>, String, Number],
|
||||
default: (): string[] => [] as string[]
|
||||
},
|
||||
/**
|
||||
* 是否允许打开多个。
|
||||
*/
|
||||
multiple: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
/**
|
||||
* 当前子项值。可v-model,类型兼容性高,因此不管你提供的是不是数组,最终同步时会被设置成数组
|
||||
*/
|
||||
modelValue: {
|
||||
type: [Array<string | number>, String, Number],
|
||||
default: (): string[] => [] as string[],
|
||||
},
|
||||
/**
|
||||
* 是否允许打开多个。
|
||||
*/
|
||||
multiple: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits([
|
||||
/**
|
||||
* 变换时触发
|
||||
* @param {String[]} value - 当前打开的值
|
||||
*/
|
||||
'change',
|
||||
'update:modelValue'
|
||||
/**
|
||||
* 变换时触发
|
||||
* @param {String[]} value - 当前打开的值
|
||||
*/
|
||||
"change",
|
||||
"update:modelValue",
|
||||
])
|
||||
|
||||
|
||||
const activeName = ref<Array<string | number>>([])
|
||||
|
||||
onBeforeMount(() => {
|
||||
toggleActivate(props.modelValue)
|
||||
toggleActivate(props.modelValue)
|
||||
})
|
||||
|
||||
provide('tmCollapseDefaultName', computed((): Array<string | number> => activeName.value))
|
||||
provide(
|
||||
"tmCollapseDefaultName",
|
||||
computed((): Array<string | number> => activeName.value),
|
||||
)
|
||||
|
||||
watch(() => props.modelValue, (newValue: Array<string | number> | string | number) => {
|
||||
if(newValue == activeName.value.join('')) return;
|
||||
if(Array.isArray(newValue)){
|
||||
if(newValue.join('') == activeName.value.join('')) return;
|
||||
}
|
||||
toggleActivate(newValue)
|
||||
})
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(newValue: Array<string | number> | string | number) => {
|
||||
if (newValue == activeName.value.join("")) return
|
||||
if (Array.isArray(newValue)) {
|
||||
if (newValue.join("") == activeName.value.join("")) return
|
||||
}
|
||||
toggleActivate(newValue)
|
||||
},
|
||||
)
|
||||
/**
|
||||
* 切换选中
|
||||
*/
|
||||
const toggleActivate = (name: Array<string | number> | string | number, isEmits = false) => {
|
||||
let ar = [] as Array<string | number>
|
||||
if (Array.isArray(name)) {
|
||||
ar = name
|
||||
} else if(name !==''&&name!=undefined&&name!=null) {
|
||||
ar = [name]
|
||||
}
|
||||
|
||||
if (ar.length == 0) {
|
||||
activeName.value = []
|
||||
} else {
|
||||
if (props.multiple) {
|
||||
let diff = activeName.value.filter((item: string | number) => {
|
||||
return ar.indexOf(item) == -1
|
||||
})
|
||||
let diffname = ar.filter((item: string | number) => {
|
||||
return activeName.value.indexOf(item) == -1
|
||||
})
|
||||
activeName.value = [...diff, ...diffname].slice(0)
|
||||
} else {
|
||||
if (activeName.value.indexOf(ar[0]) != -1) {
|
||||
activeName.value = []
|
||||
} else {
|
||||
activeName.value = [ar[0]]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isEmits) {
|
||||
let covervalue:string|number|Array<string|number> = activeName.value.slice(0)
|
||||
emit('update:modelValue', covervalue)
|
||||
emit('change', covervalue)
|
||||
}
|
||||
let ar = [] as Array<string | number>
|
||||
if (Array.isArray(name)) {
|
||||
ar = name
|
||||
} else if (name !== "" && name != undefined && name != null) {
|
||||
ar = [name]
|
||||
}
|
||||
|
||||
if (ar.length == 0) {
|
||||
activeName.value = []
|
||||
} else {
|
||||
if (props.multiple) {
|
||||
let diff = activeName.value.filter((item: string | number) => {
|
||||
return ar.indexOf(item) == -1
|
||||
})
|
||||
let diffname = ar.filter((item: string | number) => {
|
||||
return activeName.value.indexOf(item) == -1
|
||||
})
|
||||
activeName.value = [...diff, ...diffname].slice(0)
|
||||
} else {
|
||||
if (activeName.value.indexOf(ar[0]) != -1) {
|
||||
activeName.value = []
|
||||
} else {
|
||||
activeName.value = [ar[0]]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isEmits) {
|
||||
let covervalue: string | number | Array<string | number> = activeName.value.slice(0)
|
||||
emit("update:modelValue", covervalue)
|
||||
emit("change", covervalue)
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ toggleActivate })
|
||||
|
||||
</script>
|
||||
<template>
|
||||
<view>
|
||||
<!--
|
||||
<view>
|
||||
<!--
|
||||
@slot 默认插槽,可放置tm-collapse-item子节点
|
||||
-->
|
||||
<slot></slot>
|
||||
</view>
|
||||
<slot></slot>
|
||||
</view>
|
||||
</template>
|
||||
<style scoped></style>
|
||||
<style scoped></style>
|
||||
Reference in new issue
Block a user