|
|
|
|
@ -1,15 +1,17 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div
|
|
|
|
|
:style="{width:props.dimensions.width*props.ratioWidth+'px',height:props.dimensions.height*props.ratioHeight+'px'}">
|
|
|
|
|
<NodeResizer @resizeEnd="(e) => $emit('resize', e)" color="#fff" v-if="!props.isView && !props.isHideHandle && props.selected"
|
|
|
|
|
<NodeResizer @resizeEnd="(e) => $emit('resize', e)" color="#fff"
|
|
|
|
|
v-if="!props.isView && !props.isHideHandle && props.selected"
|
|
|
|
|
@resize="resize" />
|
|
|
|
|
<div class="custom-node"
|
|
|
|
|
:style="{color:'#fff',width:props.dimensions.width*props.ratioWidth+'px',height:props.dimensions.height*props.ratioHeight+'px',pointerEvents:props.isView?'auto': 'none'}">
|
|
|
|
|
:style="{backgroundColor:props.data.options.backgroundColor,color:'#fff',width:props.dimensions.width*props.ratioWidth+'px',height:props.dimensions.height*props.ratioHeight+'px',pointerEvents:props.isView?'auto': 'none'}">
|
|
|
|
|
<vue-number-roll-plus
|
|
|
|
|
style="display: inline-block;margin-right: 4px;"
|
|
|
|
|
style="display: inline-block; text-align: center;position: relative;top: 50%;transform: translateY(-50%)"
|
|
|
|
|
:number="item"
|
|
|
|
|
:background="props.data.options.backgroundColor"
|
|
|
|
|
:style="{border:props.data.options.isBorder? ` 1px solid ${props.data.options.borderColor}` :''}"
|
|
|
|
|
:height="props.dimensions.height*props.ratioHeight"
|
|
|
|
|
background="#fff0"
|
|
|
|
|
:style="{fontSize:props.data.options.fontSize+'px',color:props.data.options.borderColor,'--number-roll-plus-width':((props.dimensions.width*props.ratioWidth) / props.data.options.numQuantity) - (props.data.options.isBorder? 2:0) +'px',border:props.data.options.isBorder? ` 1px solid ${props.data.options.borderColor}` :''}"
|
|
|
|
|
v-for="(item, index) in list"
|
|
|
|
|
></vue-number-roll-plus>
|
|
|
|
|
</div>
|
|
|
|
|
@ -70,10 +72,21 @@ const emit = defineEmits(['resize']);
|
|
|
|
|
const resize = (e) => {
|
|
|
|
|
emit('resize', e, props.id);
|
|
|
|
|
};
|
|
|
|
|
watch(() => [JSON.parse(JSON.stringify(props.data?.options?.number)), JSON.parse(JSON.stringify(props.inputData?.value || ''))], (obj1, obj2) => {
|
|
|
|
|
const padArray = (arr,x,value=0)=>{
|
|
|
|
|
if (arr.length > x) {
|
|
|
|
|
return arr.slice(-x);
|
|
|
|
|
} else if (arr.length < x) {
|
|
|
|
|
const padding = new Array(x - arr.length).fill(value);
|
|
|
|
|
return [...padding, ...arr];
|
|
|
|
|
} else {
|
|
|
|
|
// 正好 x 位
|
|
|
|
|
return arr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
watch(() => [JSON.parse(JSON.stringify(props.data?.options?.numQuantity)),JSON.parse(JSON.stringify(props.data?.options?.number)), JSON.parse(JSON.stringify(props.inputData?.value || ''))], (obj1, obj2) => {
|
|
|
|
|
if (JSON.stringify(obj1) !== JSON.stringify(obj2)) {
|
|
|
|
|
let value = props.inputData?.value || props.data.options.number || '';
|
|
|
|
|
list.value = value.toString().split('');
|
|
|
|
|
list.value = padArray(value.toString().split(''),props.data.options.numQuantity)
|
|
|
|
|
}
|
|
|
|
|
}, { deep: true, immediate: true });
|
|
|
|
|
</script>
|
|
|
|
|
|