@ecan-bi/datav 1.0.64 → 1.0.65

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/dist/index.es.js CHANGED
@@ -3227,47 +3227,68 @@ const _sfc_main$h = defineComponent({
3227
3227
  immediate: true,
3228
3228
  deep: true
3229
3229
  });
3230
- const defaultValue = 0;
3231
- const value = computed(() => {
3230
+ const myValue = computed(() => {
3232
3231
  const data = unref(myData);
3233
- if (data == null)
3232
+ const defaultValue = +props2.variableDefaultValue;
3233
+ if (data == null && !isNaN(defaultValue))
3234
3234
  return defaultValue;
3235
- const values = Object.values(data);
3236
- const value2 = values[0] * 100;
3237
- if (!isNaN(value2)) {
3238
- return props2.decimalFormat ? value2.toFixed(2) : value2;
3235
+ const variables = props2.text.match(/\{.+\}/g) || [];
3236
+ let value;
3237
+ const valueSet = new Set(Object.values(data));
3238
+ for (let i = 0; i < variables.length; i++) {
3239
+ const variable = variables[i];
3240
+ if (valueSet.has(variables[i])) {
3241
+ value = variable;
3242
+ break;
3243
+ }
3244
+ }
3245
+ if (typeof value === "string" && !isNaN(+value)) {
3246
+ value = +value;
3247
+ } else if (!isNaN(defaultValue)) {
3248
+ value = defaultValue;
3249
+ } else {
3250
+ value = 0;
3251
+ }
3252
+ value = value * 100;
3253
+ if (props2.decimalFormat) {
3254
+ value = +value.toFixed(2);
3239
3255
  }
3240
- return 0;
3256
+ return value;
3241
3257
  });
3242
3258
  const text = computed(() => {
3259
+ var _a2;
3243
3260
  let text2 = props2.text;
3261
+ if (text2 === "")
3262
+ return unref(myValue);
3263
+ const defaultValue = props2.variableDefaultValue;
3244
3264
  const data = unref(myData);
3245
3265
  const variables = text2.match(/\{.+\}/g) || [];
3246
- if (text2 === "")
3247
- return unref(value) + "%";
3248
- for (let i = 0; i < (variables == null ? void 0 : variables.length); i++) {
3266
+ for (let i = 0; i < variables.length; i++) {
3249
3267
  const variable = variables[i];
3250
3268
  let statement = variable.slice(1, variable.length - 1);
3251
- const textVariables = statement.match(/[a-zA-Z]\w*/g);
3269
+ const textVariables = statement.match(/.*/g);
3252
3270
  for (let j = 0; j < (textVariables == null ? void 0 : textVariables.length); j++) {
3253
- const textVariable = textVariables[i];
3271
+ const textVariable = (_a2 = textVariables[i]) == null ? void 0 : _a2.trim();
3254
3272
  if (data[textVariable] != null) {
3255
3273
  statement = statement.replace(textVariable, data[textVariable]);
3256
3274
  } else {
3257
- statement = statement.replace(textVariable, props2.variableDefaultValue);
3275
+ statement = statement.replace(textVariable, defaultValue);
3258
3276
  }
3259
3277
  }
3260
3278
  let usedVariable = statement;
3261
3279
  try {
3262
- if (/[+\-*/%]+/g.test(statement)) {
3280
+ if (/\w+[+\-*/%]+\w+/g.test(statement)) {
3263
3281
  const eval2 = eval;
3264
3282
  usedVariable = eval2(statement);
3265
3283
  }
3266
3284
  } catch (e) {
3267
3285
  console.error(e);
3268
3286
  }
3269
- if (props2.decimalFormat) {
3270
- usedVariable = usedVariable == null ? void 0 : usedVariable.toFixed(2);
3287
+ if (typeof usedVariable === "number" || !isNaN(+usedVariable)) {
3288
+ usedVariable = +usedVariable * 100;
3289
+ if (props2.decimalFormat) {
3290
+ usedVariable = usedVariable.toFixed(2);
3291
+ }
3271
3292
  }
3272
3293
  text2 = text2.replace(variable, usedVariable + "");
3273
3294
  }
@@ -3306,7 +3327,7 @@ const _sfc_main$h = defineComponent({
3306
3327
  style: style2,
3307
3328
  myWidth,
3308
3329
  text,
3309
- value,
3330
+ myValue,
3310
3331
  loading,
3311
3332
  click
3312
3333
  };
@@ -3321,7 +3342,7 @@ function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
3321
3342
  }, [
3322
3343
  createVNode(_component_a_progress, {
3323
3344
  class: "progress",
3324
- percent: _ctx.value,
3345
+ percent: _ctx.myValue,
3325
3346
  width: _ctx.myWidth,
3326
3347
  type: _ctx.strokeType,
3327
3348
  strokeColor: _ctx.strokeColor,
@@ -3351,7 +3372,7 @@ function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) {
3351
3372
  }, 8, ["percent", "width", "type", "strokeColor", "strokeLinecap", "trailColor", "strokeWidth", "gapDegree", "onClick"])
3352
3373
  ], 4);
3353
3374
  }
3354
- const Proportion = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h], ["__scopeId", "data-v-5758f39c"]]);
3375
+ const Proportion = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["render", _sfc_render$h], ["__scopeId", "data-v-95ca32ca"]]);
3355
3376
  const EcanProportion = withInstall(Proportion);
3356
3377
  const inputProps = {
3357
3378
  ...props,