cnhis-design-vue 3.1.14-beta.10 → 3.1.14-beta.11

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.
@@ -287,7 +287,8 @@ var script = /* @__PURE__ */ defineComponent({
287
287
  canvas.value = null;
288
288
  });
289
289
  expose({
290
- select
290
+ select,
291
+ canvas
291
292
  });
292
293
  return (_ctx, _cache) => {
293
294
  return openBlock(), createElementBlock(Fragment, null, [
@@ -38,6 +38,7 @@ function useCenter(canvas, propItems, emits, cumputedX, cumputedY, getXValue, ge
38
38
  const shadowLinesCache = /* @__PURE__ */ new Set();
39
39
  const maiboPoints = /* @__PURE__ */ new Set();
40
40
  const otherPoints = /* @__PURE__ */ new Set();
41
+ const prevLines = /* @__PURE__ */ new Set();
41
42
  onMounted(() => {
42
43
  nextTick(() => {
43
44
  init();
@@ -47,6 +48,7 @@ function useCenter(canvas, propItems, emits, cumputedX, cumputedY, getXValue, ge
47
48
  drawShaDow();
48
49
  maiboPoints.clear();
49
50
  otherPoints.clear();
51
+ prevLines.clear();
50
52
  left.yScaleValue.forEach((scaleValue) => {
51
53
  drawPositionLine(scaleValue);
52
54
  scaleValue.dataList.forEach((item, dataIndex) => {
@@ -94,12 +96,11 @@ function useCenter(canvas, propItems, emits, cumputedX, cumputedY, getXValue, ge
94
96
  y: item.y
95
97
  };
96
98
  }
97
- if (isEffectiveNode(item) && isLimit(item.time)) {
98
- let y = cumputedY(pulseObj.type, pulseObj.list, item.value);
99
- y = y < vitalSignsOriginY.originY ? vitalSignsOriginY.originY : y > vitalSignsOriginY.endY ? vitalSignsOriginY.endY : y;
99
+ const point = getPointer(item, pulseObj);
100
+ if (point == null ? void 0 : point.length) {
100
101
  return {
101
- x: cumputedX(item.time),
102
- y
102
+ x: point[0],
103
+ y: point[1]
103
104
  };
104
105
  }
105
106
  };
@@ -278,24 +279,10 @@ function useCenter(canvas, propItems, emits, cumputedX, cumputedY, getXValue, ge
278
279
  const lineList = [];
279
280
  const otherList = [];
280
281
  item.list.forEach((v, index) => {
281
- const newY = scaleValue.type === "pain" ? painOriginY : vitalSignsOriginY;
282
- let points = null;
283
- if (isEffectiveNode(v)) {
284
- const x = cumputedX(v.time);
285
- const y = cumputedY(scaleValue.type, scaleValue.list, v.value);
286
- if (isLimit(v.time)) {
287
- points = [x, y < newY.originY ? newY.originY : y > newY.endY ? newY.endY : y];
288
- }
289
- }
282
+ var _a;
283
+ const points = getPointer(v, scaleValue);
290
284
  const nextV = item.list[index + 1];
291
- let nextPoint = null;
292
- if (isEffectiveNode(nextV)) {
293
- const nextX = cumputedX(nextV.time);
294
- const nextY = cumputedY(scaleValue.type, scaleValue.list, nextV.value);
295
- if (isLimit(nextV.time)) {
296
- nextPoint = [nextX, nextY < newY.originY ? newY.originY : nextY > newY.endY ? newY.endY : nextY];
297
- }
298
- }
285
+ const nextPoint = getPointer(nextV, scaleValue);
299
286
  let coolLine, coolPoint, noRiseText, arrowGroup, verifiedText;
300
287
  if (points && scaleValue.type === "temperature") {
301
288
  if (v.noRise) {
@@ -357,9 +344,22 @@ function useCenter(canvas, propItems, emits, cumputedX, cumputedY, getXValue, ge
357
344
  }
358
345
  }
359
346
  let point;
360
- const line = points && nextPoint && !v.breakpoint ? drawLine([...points, ...nextPoint], {
361
- ...lineAttr
362
- }) : null;
347
+ let line;
348
+ if (points && nextPoint && !v.breakpoint) {
349
+ line = drawLine([...points, ...nextPoint], {
350
+ ...lineAttr
351
+ });
352
+ } else if (points && !nextPoint && !v.breakpoint && scaleValue.type === "temperature" && dataIndex < scaleValue.dataList.length - 1 && index === item.list.length - 1) {
353
+ const nextV2 = (_a = scaleValue.dataList[dataIndex + 1].list) == null ? void 0 : _a[0];
354
+ const nextLinePoint = getPointer(nextV2, scaleValue);
355
+ line = nextLinePoint ? drawLine([...points, ...nextLinePoint], {
356
+ ...lineAttr
357
+ }) : null;
358
+ nextLinePoint && prevLines.add({
359
+ dataIndex,
360
+ line
361
+ });
362
+ }
363
363
  const previousLine = lineList[index - 1];
364
364
  const pointAttrNew = {
365
365
  origin: {
@@ -390,6 +390,12 @@ function useCenter(canvas, propItems, emits, cumputedX, cumputedY, getXValue, ge
390
390
  } else {
391
391
  if (points) {
392
392
  pointAttrNew.leftLine = null;
393
+ if (scaleValue.type === "temperature" && index === 0) {
394
+ const objLine = [...prevLines].find((v2) => v2.dataIndex === dataIndex - 1);
395
+ if (objLine) {
396
+ pointAttrNew.leftLine = objLine.line;
397
+ }
398
+ }
393
399
  point = drawPoint(type, {
394
400
  left: points[0],
395
401
  top: points[1],
@@ -521,6 +527,16 @@ function useCenter(canvas, propItems, emits, cumputedX, cumputedY, getXValue, ge
521
527
  const getTime = new Date(time).getTime();
522
528
  return getTime >= minMinute && getTime <= maxMinute;
523
529
  }
530
+ function getPointer(v, scaleValue) {
531
+ let points;
532
+ const objOriginY = scaleValue.type === "pain" ? painOriginY : vitalSignsOriginY;
533
+ if (isEffectiveNode(v) && isLimit(v.time)) {
534
+ const x = cumputedX(v.time);
535
+ const y = cumputedY(scaleValue.type, scaleValue.list, v.value);
536
+ points = [x, y < objOriginY.originY ? objOriginY.originY : y > objOriginY.endY ? objOriginY.endY : y];
537
+ }
538
+ return points;
539
+ }
524
540
  function clickMenu({ item, target }) {
525
541
  if (!target) {
526
542
  emits("add", {
@@ -23,6 +23,7 @@ function useCanvasEvent(canvas, propItems, emits) {
23
23
  lockMovementX: true,
24
24
  lockMovementY: true,
25
25
  transparentCorners: false,
26
+ hasControls: false,
26
27
  ...selectionStyle
27
28
  });
28
29
  canvas.value.add(rect);
@@ -37,9 +38,9 @@ function useCanvasEvent(canvas, propItems, emits) {
37
38
  const selections2 = [];
38
39
  selections2.push(drawRect({
39
40
  left: iconsWidth,
40
- top: originY,
41
+ top: originY + 1,
41
42
  width: originX - iconsWidth,
42
- height: endY
43
+ height: endY - originY - 3
43
44
  }, "left"));
44
45
  let topY = 0;
45
46
  topList.forEach((item, index) => {
@@ -48,16 +49,16 @@ function useCanvasEvent(canvas, propItems, emits) {
48
49
  }
49
50
  selections2.push(drawRect({
50
51
  left: iconsWidth,
51
- top: topY,
52
+ top: topY + 1,
52
53
  width: endX - iconsWidth,
53
- height: propItems[`${item.key}Height`]
54
+ height: propItems[`${item.key}Height`] - 1
54
55
  }, item.key));
55
56
  });
56
57
  selections2.push(drawRect({
57
58
  left: originX,
58
- top: originY,
59
+ top: originY + 1,
59
60
  width: endX - originX,
60
- height: endY - originY
61
+ height: endY - originY - 3
61
62
  }, "grid"));
62
63
  canvas.value.renderAll();
63
64
  return selections2;
@@ -67,7 +68,7 @@ function useCanvasEvent(canvas, propItems, emits) {
67
68
  canvas.value.discardActiveObject();
68
69
  canvas.value.renderAll();
69
70
  const obj = selections == null ? void 0 : selections.find((obj2) => obj2.key === key);
70
- obj && obj.bringToFront();
71
+ obj == null ? void 0 : obj.bringToFront();
71
72
  obj && canvas.value.setActiveObject(obj);
72
73
  }
73
74
  return { select };
@@ -17,7 +17,7 @@ export declare const SEARCH_CASCADE: import("vue").DefineComponent<{
17
17
  type: PropType<AnyObject[]>;
18
18
  default: () => never[];
19
19
  };
20
- deep: {
20
+ depth: {
21
21
  type: (NumberConstructor | StringConstructor)[];
22
22
  required: true;
23
23
  };
@@ -34,7 +34,7 @@ export declare const SEARCH_CASCADE: import("vue").DefineComponent<{
34
34
  type: PropType<AnyObject[]>;
35
35
  default: () => never[];
36
36
  };
37
- deep: {
37
+ depth: {
38
38
  type: (NumberConstructor | StringConstructor)[];
39
39
  required: true;
40
40
  };
@@ -1,8 +1,8 @@
1
1
  import { defineComponent, ref, inject, computed, watch, createVNode } from 'vue';
2
2
  import { isField } from '@formily/core';
3
- import { isObject } from 'lodash-es';
3
+ import { isEqual } from 'lodash-es';
4
4
  import { InjectAsyncQueue } from '../../constants/index.js';
5
- import { assignUpdateValue, formRenderLog, traverseDependKey } from '../../utils/index.js';
5
+ import { assignUpdateValue, traverseDependKey } from '../../utils/index.js';
6
6
  import { connect, mapProps } from '@formily/vue';
7
7
  import { NCascader } from 'naive-ui';
8
8
  import { useFormField } from '../../hooks/useFormField.js';
@@ -14,7 +14,7 @@ const script = defineComponent({
14
14
  type: Array,
15
15
  default: () => []
16
16
  },
17
- deep: {
17
+ depth: {
18
18
  type: [Number, String],
19
19
  required: true
20
20
  },
@@ -32,55 +32,41 @@ const script = defineComponent({
32
32
  slots,
33
33
  emit
34
34
  }) {
35
- const _options = ref(null);
35
+ const remoteOptions = ref(null);
36
36
  const asyncQueue = inject(InjectAsyncQueue);
37
37
  const {
38
38
  field,
39
39
  title
40
40
  } = useFormField();
41
41
  async function fetchData(option) {
42
- if (!option && _options.value)
42
+ if (!option && remoteOptions.value)
43
43
  return;
44
- const config = props.urlConfig;
45
- if (!config)
44
+ if (!configFor(props))
46
45
  return;
47
- if (!isObject(config)) {
48
- formRenderLog(`invalid urlConfig (${config}) in CASCADER => ${title.value}`, "warn");
46
+ if (deepFor(option) + 1 >= deepFor(props))
49
47
  return;
50
- }
51
- if (deepFor(option) + 1 >= props.deep)
52
- return;
53
- let data = await asyncQueue.addAsync({
54
- ...createRequestParams(deepFor(option), config, option),
55
- key: title.value
56
- });
57
- if (!Array.isArray(data)) {
58
- data = [];
59
- }
60
- if (!data.length && isObject(option)) {
48
+ const data = await asyncQueue.addAsync(createRequestParams(deepFor(option), configFor(props), title.value, option));
49
+ if (!data.length && option) {
61
50
  option.isLeaf = true;
62
51
  updateValue(null, null, getOptionChain(option));
63
52
  show.value = false;
64
53
  return;
65
54
  }
66
55
  const result = data.map((item) => optionNormalize(item, deepFor(option)));
67
- option ? option.children = result : _options.value = result;
68
- function deepFor(option2) {
69
- var _a;
70
- return (_a = option2 == null ? void 0 : option2.depth) != null ? _a : -1;
71
- }
72
- function createRequestParams(deep, config2, option2) {
56
+ option ? option.children = result : remoteOptions.value = result;
57
+ function createRequestParams(deep, config, key, option2) {
73
58
  const params = {
74
59
  lvlnr: deep + 1 + ""
75
60
  };
76
- if (option2 && config2.dependKey) {
77
- traverseDependKey(config2.dependKey, (dependKey, valueKey2) => {
61
+ if (option2 && config.dependKey) {
62
+ traverseDependKey(config.dependKey, (dependKey, valueKey2) => {
78
63
  params[valueKey2] = option2[dependKey];
79
64
  });
80
65
  }
81
66
  return {
82
67
  params,
83
- ...config2
68
+ ...config,
69
+ key
84
70
  };
85
71
  }
86
72
  function getOptionChain(option2) {
@@ -92,30 +78,39 @@ const script = defineComponent({
92
78
  }
93
79
  return result2;
94
80
  }
95
- function optionNormalize(data2, deep) {
81
+ function optionNormalize(data2, depth) {
96
82
  return {
97
83
  [labelKey.value]: data2[labelKey.value],
98
84
  [valueKey.value]: data2[valueKey.value],
99
- depth: deep + 1,
85
+ depth: depth + 1,
100
86
  parent: option,
101
- isLeaf: deep + 2 >= props.deep
87
+ isLeaf: depth + 2 >= deepFor(props)
102
88
  };
103
89
  }
90
+ function configFor(target) {
91
+ return target.urlConfig;
92
+ }
93
+ function deepFor(target) {
94
+ var _a;
95
+ return (_a = target == null ? void 0 : target.depth) != null ? _a : -1;
96
+ }
104
97
  }
105
- const renderOptions = computed(() => {
106
- return _options.value || props.options || [];
98
+ const parsedOptions = computed(() => {
99
+ return remoteOptions.value || props.options || [];
107
100
  });
108
101
  watch(() => props.value, (n, o) => {
109
102
  var _a, _b;
110
- if (n != null && o == null) {
111
- fetchData();
112
- }
113
- if (isField(field.value) && field.value.visited) {
114
- (_b = (_a = field.value).validate) == null ? void 0 : _b.call(_a);
115
- }
103
+ n != null && o == null && fetchData();
104
+ isField(field.value) && field.value.visited && ((_b = (_a = field.value).validate) == null ? void 0 : _b.call(_a));
116
105
  }, {
117
106
  immediate: true
118
107
  });
108
+ watch(() => props.urlConfig, async (config, oldConfig) => {
109
+ if (isEqual(config, oldConfig))
110
+ return;
111
+ remoteOptions.value = null;
112
+ await fetchData();
113
+ });
119
114
  const labelKey = computed(() => {
120
115
  var _a, _b;
121
116
  return (_b = (_a = props.urlConfig) == null ? void 0 : _a.nameKey) != null ? _b : "text";
@@ -127,13 +122,11 @@ const script = defineComponent({
127
122
  const _value = computed(() => {
128
123
  try {
129
124
  const parsed = Array.isArray(props.value) ? props.value : JSON.parse(props.value || "");
130
- if (Array.isArray(parsed)) {
131
- return parsed.map((option) => option[labelKey.value]).join(" / ");
132
- } else {
133
- return [];
134
- }
125
+ if (!Array.isArray(parsed) || !parsed.length)
126
+ return null;
127
+ return parsed.map((option) => option[labelKey.value]).join(" / ");
135
128
  } catch (e) {
136
- return "";
129
+ return null;
137
130
  }
138
131
  });
139
132
  function updateValue(_, __, options) {
@@ -168,7 +161,7 @@ const script = defineComponent({
168
161
  "remote": true,
169
162
  "labelField": labelKey.value,
170
163
  "valueField": valueKey.value,
171
- "options": renderOptions.value,
164
+ "options": parsedOptions.value,
172
165
  "checkStrategy": "child",
173
166
  "onLoad": fetchData,
174
167
  "onFocus": focusDecorator(props.onFocus),
@@ -1,9 +1,8 @@
1
- import { defineComponent, ref, inject, computed, watch, nextTick, createVNode } from 'vue';
1
+ import { defineComponent, ref, watch, inject, computed, nextTick, createVNode } from 'vue';
2
2
  import { isField } from '@formily/core';
3
- import { cloneDeep } from 'lodash-es';
3
+ import { isEqual, cloneDeep } from 'lodash-es';
4
4
  import { InjectAsyncQueue, InjectionFormItemDepsCollector, InjectionChangeContextCollector } from '../../constants/index.js';
5
- import { assignUpdateValue, formRenderLog, traverseDependKey } from '../../utils/index.js';
6
- import { isObject } from '@vueuse/core';
5
+ import { assignUpdateValue, traverseDependKey } from '../../utils/index.js';
7
6
  import { connect, mapProps } from '@formily/vue';
8
7
  import { NSelect } from 'naive-ui';
9
8
  import { useFormField } from '../../hooks/useFormField.js';
@@ -32,6 +31,7 @@ const script = defineComponent({
32
31
  emit
33
32
  }) {
34
33
  const remoteOptions = ref(null);
34
+ watch(remoteOptions, (o) => console.log("remoteOption", o));
35
35
  const lastSearch = ref("");
36
36
  const asyncQueue = inject(InjectAsyncQueue);
37
37
  const {
@@ -52,10 +52,6 @@ const script = defineComponent({
52
52
  if (!config) {
53
53
  return remoteOptions.value = null;
54
54
  }
55
- if (!isObject(config)) {
56
- formRenderLog(`invalid urlConfig (${config}) in SELECT => ${title.value}`, "warn");
57
- return remoteOptions.value = null;
58
- }
59
55
  try {
60
56
  remoteOptions.value = await asyncQueue.addAsync({
61
57
  ...createParams(config, field.value),
@@ -86,13 +82,16 @@ const script = defineComponent({
86
82
  return filterOption(props.options, lastSearch.value);
87
83
  });
88
84
  const formItemDepsCollector = inject(InjectionFormItemDepsCollector);
89
- watch(() => props.urlConfig, (config) => {
85
+ watch(() => props.urlConfig, (config, oldConfig) => {
86
+ if (isEqual(config, oldConfig))
87
+ return;
90
88
  remoteOptions.value = null;
91
89
  config && formItemDepsCollector.setDeps(fieldKey.value, config.dependKey || [], async () => {
92
90
  remoteOptions.value = null;
93
91
  await nextTick();
94
92
  props.value != null && await fetchData();
95
93
  });
94
+ config && fetchData();
96
95
  }, {
97
96
  immediate: true
98
97
  });
@@ -120,7 +120,7 @@ function useAsyncQueue() {
120
120
  const { data, success } = res;
121
121
  if (!success)
122
122
  throw res;
123
- cb(void 0, data);
123
+ cb(void 0, Array.isArray(data) ? data : []);
124
124
  } catch (e) {
125
125
  cb(new Error(`Request error => ${e}`));
126
126
  removeCache();
@@ -80,7 +80,7 @@ function useFieldListAdaptor(collector, uuid) {
80
80
  const schema = createStandardSchema(item);
81
81
  Object.assign(schema["x-component-props"], {
82
82
  urlConfig: item.urlConfig,
83
- deep: (_a = item.wordbook) == null ? void 0 : _a.level_num,
83
+ depth: (_a = item.wordbook) == null ? void 0 : _a.level_num,
84
84
  options: item.option
85
85
  });
86
86
  return schema;
@@ -1,7 +1,7 @@
1
- import { Func } from '../../../../../es/src/types';
1
+ import { ArrayAble, Func } from '../../../../../es/src/types';
2
2
  export declare class FormItemDepsCollector {
3
3
  private readonly collector;
4
- setDeps(key: string, dependKey: string | string[], callback: Func): void;
4
+ setDeps(key: string, dependKeys: ArrayAble<string> | Record<string, string> | ArrayAble<Record<'paramName' | 'paramValue', string>>, callback: Func): void;
5
5
  trigger(dependKey: string, payload?: any): void;
6
6
  }
7
7
  export declare function useFormItemDeps(): {
@@ -1,16 +1,15 @@
1
1
  import { isFunction } from 'lodash-es';
2
- import { arrayed } from '../../../../packages/form-render/src/utils';
2
+ import { traverseDependKey } from '../../../../packages/form-render/src/utils';
3
3
 
4
4
  class FormItemDepsCollector {
5
5
  constructor() {
6
6
  this.collector = /* @__PURE__ */ new Map();
7
7
  }
8
- setDeps(key, dependKey, callback) {
9
- dependKey = arrayed(dependKey);
10
- dependKey.forEach((dependKey2) => {
11
- const map = this.collector.get(dependKey2) || /* @__PURE__ */ new Map();
8
+ setDeps(key, dependKeys, callback) {
9
+ traverseDependKey(dependKeys, (dependKey) => {
10
+ const map = this.collector.get(dependKey) || /* @__PURE__ */ new Map();
12
11
  map.set(key, callback);
13
- this.collector.set(dependKey2, map);
12
+ this.collector.set(dependKey, map);
14
13
  });
15
14
  }
16
15
  trigger(dependKey, payload) {
package/global.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import * as NaiveUI from 'naive-ui';
2
-
3
- declare module 'naive-ui' {
4
- // @ts-ignore
5
- export const NTree: any;
6
- }
7
-
8
- export {};
1
+ import * as NaiveUI from 'naive-ui';
2
+
3
+ declare module 'naive-ui' {
4
+ // @ts-ignore
5
+ export const NTree: any;
6
+ }
7
+
8
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cnhis-design-vue",
3
3
  "private": false,
4
- "version": "3.1.14-beta.10",
4
+ "version": "3.1.14-beta.11",
5
5
  "license": "ISC",
6
6
  "module": "es/packages/index.js",
7
7
  "main": "es/packages/index.js",