File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,10 @@ export default defineComponent({
2323 type: String ,
2424 default: null ,
2525 },
26+ type: {
27+ type: String ,
28+ default: null ,
29+ },
2630 collection: {
2731 type: String ,
2832 default: ' ' ,
@@ -54,7 +58,7 @@ export default defineComponent({
5458 },
5559 emits: [' input' ],
5660 setup(props , { emit }) {
57- const computedValue = ref (props .value );
61+ const computedValue = ref < string | number | null > (props .value );
5862 const relations = useCollectionRelations (props .collection );
5963 const values = useDeepValues (
6064 inject <ComputedRef <Record <string , any >>>(' values' )! ,
@@ -87,13 +91,20 @@ export default defineComponent({
8791
8892 function compute() {
8993 try {
90- return props .template .replace (/ {{. *? }}/ g , (match ) => {
94+ const res = props .template .replace (/ {{. *? }}/ g , (match ) => {
9195 const expression = match .slice (2 , - 2 ).trim ();
9296 return parseExpression (expression , values .value );
9397 });
98+ if ([' integer' , ' decimal' , ' bigInteger' ].includes (props .type )) {
99+ return parseInt (res ) || 0 ;
100+ }
101+ if ([' float' ].includes (props .type )) {
102+ return parseFloat (res ) || 0 ;
103+ }
104+ return res ;
94105 } catch (err ) {
95106 errorMsg .value = err .message ?? ' Unknown error' ;
96- return ' ' ;
107+ return null ;
97108 }
98109 }
99110 },
You can’t perform that action at this time.
0 commit comments