cnhis-design-vue 3.1.12-beta.2 → 3.1.12-beta.3

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.
Files changed (30) hide show
  1. package/es/node_modules/date-fns/esm/differenceInCalendarYears/index.js +33 -0
  2. package/es/node_modules/date-fns/esm/differenceInYears/index.js +43 -0
  3. package/es/packages/form-render/index.d.ts +9 -0
  4. package/es/packages/form-render/src/FormRender.vue.d.ts +10 -1
  5. package/es/packages/form-render/src/FormRender.vue_vue_type_script_setup_true_lang.js +1 -0
  6. package/es/packages/form-render/src/components/renderer/cascader.js +4 -3
  7. package/es/packages/form-render/src/hooks/useAnchor.js +2 -2
  8. package/es/packages/form-render/src/hooks/useBusinessBinding.d.ts +6 -2
  9. package/es/packages/form-render/src/hooks/useBusinessBinding.js +31 -8
  10. package/es/packages/form-render/src/hooks/useFieldListAdaptor.js +17 -6
  11. package/es/packages/form-render/src/hooks/useFormContext.js +3 -2
  12. package/es/packages/form-render/src/hooks/usePresetScope.d.ts +6 -0
  13. package/es/packages/form-render/src/hooks/usePresetScope.js +21 -0
  14. package/es/packages/form-render/src/hooks/useTypeNormalize.js +1 -1
  15. package/es/packages/form-render/src/types/index.d.ts +7 -0
  16. package/es/packages/form-render/src/utils/index.d.ts +2 -0
  17. package/es/packages/form-render/src/utils/index.js +15 -3
  18. package/es/packages/index.css +11 -0
  19. package/es/packages/scale-view/index.d.ts +4 -0
  20. package/es/packages/scale-view/src/ScaleView.vue.d.ts +4 -0
  21. package/es/packages/scale-view/src/ScaleView.vue_vue_type_script_setup_true_lang.js +11 -10
  22. package/es/packages/scale-view/src/components/EvaluateCountdown.vue.d.ts +4 -0
  23. package/es/packages/scale-view/src/components/EvaluateCountdown.vue_vue_type_script_setup_true_lang.js +7 -2
  24. package/es/packages/scale-view/src/components/formitem/r-input.js +0 -2
  25. package/es/packages/scale-view/src/components/formitem/r-select.js +56 -2
  26. package/es/packages/scale-view/src/hooks/scaleview-computed.js +16 -9
  27. package/es/packages/scale-view/src/hooks/scaleview-init.js +8 -2
  28. package/es/packages/scale-view/src/utils/judge-types.js +2 -1
  29. package/es/packages/scale-view/style/index.css +11 -0
  30. package/package.json +1 -1
@@ -0,0 +1,33 @@
1
+ import toDate from '../toDate/index.js';
2
+ import requiredArgs from '../_lib/requiredArgs/index.js';
3
+
4
+ /**
5
+ * @name differenceInCalendarYears
6
+ * @category Year Helpers
7
+ * @summary Get the number of calendar years between the given dates.
8
+ *
9
+ * @description
10
+ * Get the number of calendar years between the given dates.
11
+ *
12
+ * @param {Date|Number} dateLeft - the later date
13
+ * @param {Date|Number} dateRight - the earlier date
14
+ * @returns {Number} the number of calendar years
15
+ * @throws {TypeError} 2 arguments required
16
+ *
17
+ * @example
18
+ * // How many calendar years are between 31 December 2013 and 11 February 2015?
19
+ * const result = differenceInCalendarYears(
20
+ * new Date(2015, 1, 11),
21
+ * new Date(2013, 11, 31)
22
+ * )
23
+ * //=> 2
24
+ */
25
+
26
+ function differenceInCalendarYears(dirtyDateLeft, dirtyDateRight) {
27
+ requiredArgs(2, arguments);
28
+ var dateLeft = toDate(dirtyDateLeft);
29
+ var dateRight = toDate(dirtyDateRight);
30
+ return dateLeft.getFullYear() - dateRight.getFullYear();
31
+ }
32
+
33
+ export { differenceInCalendarYears as default };
@@ -0,0 +1,43 @@
1
+ import toDate from '../toDate/index.js';
2
+ import differenceInCalendarYears from '../differenceInCalendarYears/index.js';
3
+ import compareAsc from '../compareAsc/index.js';
4
+ import requiredArgs from '../_lib/requiredArgs/index.js';
5
+
6
+ /**
7
+ * @name differenceInYears
8
+ * @category Year Helpers
9
+ * @summary Get the number of full years between the given dates.
10
+ *
11
+ * @description
12
+ * Get the number of full years between the given dates.
13
+ *
14
+ * @param {Date|Number} dateLeft - the later date
15
+ * @param {Date|Number} dateRight - the earlier date
16
+ * @returns {Number} the number of full years
17
+ * @throws {TypeError} 2 arguments required
18
+ *
19
+ * @example
20
+ * // How many full years are between 31 December 2013 and 11 February 2015?
21
+ * const result = differenceInYears(new Date(2015, 1, 11), new Date(2013, 11, 31))
22
+ * //=> 1
23
+ */
24
+
25
+ function differenceInYears(dirtyDateLeft, dirtyDateRight) {
26
+ requiredArgs(2, arguments);
27
+ var dateLeft = toDate(dirtyDateLeft);
28
+ var dateRight = toDate(dirtyDateRight);
29
+ var sign = compareAsc(dateLeft, dateRight);
30
+ var difference = Math.abs(differenceInCalendarYears(dateLeft, dateRight)); // Set both dates to a valid leap year for accurate comparison when dealing
31
+ // with leap days
32
+
33
+ dateLeft.setFullYear(1584);
34
+ dateRight.setFullYear(1584); // Math.abs(diff in full years - diff in calendar years) === 1 if last calendar year is not full
35
+ // If so, result must be decreased by 1 in absolute value
36
+
37
+ var isLastYearNotFull = compareAsc(dateLeft, dateRight) === -sign;
38
+ var result = sign * (difference - Number(isLastYearNotFull)); // Prevent negative zero
39
+
40
+ return result === 0 ? 0 : result;
41
+ }
42
+
43
+ export { differenceInYears as default };
@@ -92,6 +92,9 @@ declare const FormRender: SFCWithInstall<import("vue").DefineComponent<{
92
92
  type: import("vue").PropType<Record<string, import("vue").Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions> | import("vue").FunctionalComponent<{}, {}>>>;
93
93
  default: () => {};
94
94
  };
95
+ businessFilter: {
96
+ type: import("vue").PropType<import("./src/types").FormBusinessFilter>;
97
+ };
95
98
  scope: {
96
99
  type: import("vue").PropType<import("../../../es/src/types").AnyObject>;
97
100
  default: () => {};
@@ -194,6 +197,9 @@ declare const FormRender: SFCWithInstall<import("vue").DefineComponent<{
194
197
  type: import("vue").PropType<Record<string, import("vue").Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions> | import("vue").FunctionalComponent<{}, {}>>>;
195
198
  default: () => {};
196
199
  };
200
+ businessFilter: {
201
+ type: import("vue").PropType<import("./src/types").FormBusinessFilter>;
202
+ };
197
203
  scope: {
198
204
  type: import("vue").PropType<import("../../../es/src/types").AnyObject>;
199
205
  default: () => {};
@@ -1383,6 +1389,9 @@ declare const FormRender: SFCWithInstall<import("vue").DefineComponent<{
1383
1389
  type: import("vue").PropType<Record<string, import("vue").Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions> | import("vue").FunctionalComponent<{}, {}>>>;
1384
1390
  default: () => {};
1385
1391
  };
1392
+ businessFilter: {
1393
+ type: import("vue").PropType<import("./src/types").FormBusinessFilter>;
1394
+ };
1386
1395
  scope: {
1387
1396
  type: import("vue").PropType<import("../../../es/src/types").AnyObject>;
1388
1397
  default: () => {};
@@ -1,7 +1,7 @@
1
1
  /// <reference types="lodash" />
2
2
  import { AnyObject } from '../../../../es/src/types';
3
3
  import { Component, FunctionalComponent, PropType } from 'vue';
4
- import { FieldItem, FieldVisitor } from './types';
4
+ import { FieldItem, FieldVisitor, FormBusinessFilter } from './types';
5
5
  declare const _default: import("vue").DefineComponent<{
6
6
  fieldList: {
7
7
  type: PropType<FieldItem[]>;
@@ -92,6 +92,9 @@ declare const _default: import("vue").DefineComponent<{
92
92
  type: PropType<Record<string, Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions> | FunctionalComponent<{}, {}>>>;
93
93
  default: () => {};
94
94
  };
95
+ businessFilter: {
96
+ type: PropType<FormBusinessFilter>;
97
+ };
95
98
  scope: {
96
99
  type: PropType<AnyObject>;
97
100
  default: () => {};
@@ -194,6 +197,9 @@ declare const _default: import("vue").DefineComponent<{
194
197
  type: PropType<Record<string, Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions> | FunctionalComponent<{}, {}>>>;
195
198
  default: () => {};
196
199
  };
200
+ businessFilter: {
201
+ type: PropType<FormBusinessFilter>;
202
+ };
197
203
  scope: {
198
204
  type: PropType<AnyObject>;
199
205
  default: () => {};
@@ -1383,6 +1389,9 @@ declare const _default: import("vue").DefineComponent<{
1383
1389
  type: PropType<Record<string, Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions> | FunctionalComponent<{}, {}>>>;
1384
1390
  default: () => {};
1385
1391
  };
1392
+ businessFilter: {
1393
+ type: PropType<FormBusinessFilter>;
1394
+ };
1386
1395
  scope: {
1387
1396
  type: PropType<AnyObject>;
1388
1397
  default: () => {};
@@ -29,6 +29,7 @@ var script = /* @__PURE__ */ defineComponent({
29
29
  type: Object,
30
30
  default: () => ({})
31
31
  },
32
+ businessFilter: { type: Function },
32
33
  scope: { type: Object, default: () => ({}) },
33
34
  consumer: { type: Boolean, default: false },
34
35
  uuid: { type: String }
@@ -57,7 +57,7 @@ const script = defineComponent({
57
57
  }
58
58
  arrayed(config.dependKey).forEach((key) => {
59
59
  if (isString(key)) {
60
- params[key] = option[config.valueKey];
60
+ params[key] = option[valueKey.value];
61
61
  } else if (isObject(key)) {
62
62
  params[key.paramName] = option[key.paramValue];
63
63
  }
@@ -80,12 +80,13 @@ const script = defineComponent({
80
80
  currentOption = currentOption.parent;
81
81
  }
82
82
  updateValue(null, null, result2);
83
+ show.value = false;
83
84
  return;
84
85
  }
85
86
  const result = data.reduce((res, d) => {
86
87
  res.push({
87
- [config.nameKey]: d[config.nameKey],
88
- [config.valueKey]: d[config.valueKey],
88
+ [labelKey.value]: d[labelKey.value],
89
+ [valueKey.value]: d[valueKey.value],
89
90
  depth: parentDepth + 1,
90
91
  parent: option,
91
92
  isLeaf: parentDepth + 2 >= props.deep
@@ -57,9 +57,9 @@ function useAnchor(props, collector) {
57
57
  }) || anchorIdList.value[anchorIdList.value.length - 1];
58
58
  __currentAnchor.value = (_a = result == null ? void 0 : result.name) != null ? _a : "";
59
59
  }, 300);
60
- watch(anchorIdList, (anchorIdList2) => {
60
+ watch(anchorIdList, (_anchorIdList) => {
61
61
  var _a, _b;
62
- __currentAnchor.value = (_b = (_a = anchorIdList2[0]) == null ? void 0 : _a.name) != null ? _b : "";
62
+ __currentAnchor.value = (_b = (_a = _anchorIdList[0]) == null ? void 0 : _a.name) != null ? _b : "";
63
63
  }, { deep: true, immediate: true });
64
64
  const currentAnchor = computed({
65
65
  get() {
@@ -1,15 +1,19 @@
1
1
  import { Form } from '@formily/core';
2
+ import { FormBusinessFilter } from '../../../../../es/packages/form-render';
2
3
  import { FIELD_BUSINESS_TYPE } from '../constants';
3
4
  export declare class BusinessCollector {
4
5
  private readonly typeCollector;
5
6
  private readonly fieldNameCollector;
7
+ private readonly valueFilter;
8
+ constructor(valueFilter?: FormBusinessFilter);
6
9
  collect(type: FIELD_BUSINESS_TYPE, fieldName: string): void;
7
10
  getField(type: FIELD_BUSINESS_TYPE): string[];
8
11
  getType(fieldName: string): FIELD_BUSINESS_TYPE | undefined;
9
- handlerIdCardType(formModel: Form, value: unknown): void;
12
+ private handlerIdCardType;
13
+ private handlerBirthdayType;
10
14
  handlerMap: Map<FIELD_BUSINESS_TYPE, (formModel: Form, value: unknown) => void>;
11
15
  trigger(formModel: Form, fieldName: string, value: unknown): void;
12
16
  }
13
17
  export declare function useBusinessBinding(): {
14
- create: () => BusinessCollector;
18
+ create: (valueFilter?: FormBusinessFilter) => BusinessCollector;
15
19
  };
@@ -1,14 +1,16 @@
1
1
  import { isString } from '@vueuse/core';
2
2
  import { FIELD_BUSINESS_TYPE } from '../constants/index.js';
3
- import { isIdCard, parseIdCard } from '../utils/index.js';
3
+ import { isIdCard, parseIdCard, parseBirthday } from '../utils/index.js';
4
4
 
5
5
  class BusinessCollector {
6
- constructor() {
6
+ constructor(valueFilter = ({ value }) => value) {
7
7
  this.typeCollector = /* @__PURE__ */ new Map();
8
8
  this.fieldNameCollector = /* @__PURE__ */ new Map();
9
9
  this.handlerMap = /* @__PURE__ */ new Map([
10
- [FIELD_BUSINESS_TYPE.ID_CARD, this.handlerIdCardType.bind(this)]
10
+ [FIELD_BUSINESS_TYPE.ID_CARD, this.handlerIdCardType.bind(this)],
11
+ [FIELD_BUSINESS_TYPE.BIRTHDAY, this.handlerBirthdayType.bind(this)]
11
12
  ]);
13
+ this.valueFilter = valueFilter;
12
14
  }
13
15
  collect(type, fieldName) {
14
16
  const set = this.typeCollector.get(type) || /* @__PURE__ */ new Set();
@@ -29,19 +31,40 @@ class BusinessCollector {
29
31
  const ageFields = this.getField(FIELD_BUSINESS_TYPE.AGE);
30
32
  ageFields.forEach((field) => {
31
33
  formModel.setFieldState(field, (state) => {
32
- state.value = info.age;
34
+ state.value = this.valueFilter({
35
+ fieldKey: field,
36
+ value: info.age,
37
+ context: info,
38
+ type: FIELD_BUSINESS_TYPE.AGE
39
+ });
33
40
  });
34
41
  });
35
42
  const sexFields = this.getField(FIELD_BUSINESS_TYPE.SEX);
36
43
  sexFields.forEach((field) => {
37
44
  formModel.setFieldState(field, (state) => {
38
- state.value = info.sex;
45
+ state.value = this.valueFilter({ fieldKey: field, value: info.sex, type: FIELD_BUSINESS_TYPE.SEX });
39
46
  });
40
47
  });
41
48
  const birthdayFields = this.getField(FIELD_BUSINESS_TYPE.BIRTHDAY);
42
49
  birthdayFields.forEach((field) => {
43
50
  formModel.setFieldState(field, (state) => {
44
- state.value = info.birthday;
51
+ state.value = this.valueFilter({ fieldKey: field, value: info.birthday, type: FIELD_BUSINESS_TYPE.BIRTHDAY });
52
+ });
53
+ });
54
+ }
55
+ handlerBirthdayType(formModel, value) {
56
+ if (!isString(value))
57
+ return;
58
+ const ageFields = this.getField(FIELD_BUSINESS_TYPE.AGE);
59
+ ageFields.forEach((field) => {
60
+ const context = parseBirthday(value);
61
+ formModel.setFieldState(field, (state) => {
62
+ state.value = this.valueFilter({
63
+ fieldKey: field,
64
+ value: context.year,
65
+ context,
66
+ type: FIELD_BUSINESS_TYPE.AGE
67
+ });
45
68
  });
46
69
  });
47
70
  }
@@ -53,8 +76,8 @@ class BusinessCollector {
53
76
  }
54
77
  }
55
78
  function useBusinessBinding() {
56
- function create() {
57
- return new BusinessCollector();
79
+ function create(valueFilter) {
80
+ return new BusinessCollector(valueFilter);
58
81
  }
59
82
  return { create };
60
83
  }
@@ -1,4 +1,4 @@
1
- import { pick } from 'lodash-es';
1
+ import { isArray, pick } from 'lodash-es';
2
2
  import { arrayed, transformDateFormat } from '../utils/index.js';
3
3
  import { useFormValidator, useTypeNormalize } from '../../../../packages/form-render';
4
4
  import { isObject } from '@vueuse/core';
@@ -17,7 +17,11 @@ function useFieldListAdaptor(collector, uuid) {
17
17
  id: `${uuid}-${item.val_key}`
18
18
  },
19
19
  "x-component": item.html_type,
20
- "x-component-props": { placeholder: item.placeholder, clearable: item.is_empty === "1" },
20
+ "x-component-props": {
21
+ placeholder: item.placeholder,
22
+ clearable: item.is_empty === "1",
23
+ ...item.componentProps || {}
24
+ },
21
25
  "x-display": item.is_show === "0" ? "hidden" : "visible",
22
26
  "x-pattern": item.is_edit === "0" ? "disabled" : "editable"
23
27
  };
@@ -169,6 +173,7 @@ function useFieldListAdaptor(collector, uuid) {
169
173
  }));
170
174
  return {
171
175
  type: "void",
176
+ name: fieldList.map((f) => f.val_key).join("-"),
172
177
  title: item.alias || item.name,
173
178
  "x-component": "INPUT_GROUP",
174
179
  "x-component-props": { span: item.elem_width },
@@ -184,16 +189,22 @@ function useFieldListAdaptor(collector, uuid) {
184
189
  const obj_type = (_a = cur.validate) == null ? void 0 : _a.obj_type;
185
190
  obj_type && collector.collect(obj_type, cur.val_key);
186
191
  if (cur.html_type === "LINEBAR") {
187
- fin[cur.val_key] = createLinebarSchema(cur);
188
- prevLinebar = fin[cur.val_key].properties = {};
192
+ fin[createFieldName(cur)] = createLinebarSchema(cur);
193
+ prevLinebar = fin[createFieldName(cur)].properties = {};
189
194
  } else if (prevLinebar) {
190
- prevLinebar[cur.val_key] = createWidgetSchema(cur);
195
+ prevLinebar[createFieldName(cur)] = createWidgetSchema(cur);
191
196
  } else {
192
197
  prevLinebar = null;
193
- fin[cur.val_key] = createWidgetSchema(cur);
198
+ fin[createFieldName(cur)] = createWidgetSchema(cur);
194
199
  }
195
200
  return fin;
196
201
  }, {});
202
+ function createFieldName(fieldItem) {
203
+ if (isArray(fieldItem.suffixConfig)) {
204
+ return [fieldItem.val_key, fieldItem.suffixConfig.map((f) => f.val_key)].join("-");
205
+ }
206
+ return fieldItem.val_key;
207
+ }
197
208
  }
198
209
  return { schemaAdaptor };
199
210
  }
@@ -2,6 +2,7 @@ import { provide } from 'vue';
2
2
  import { createSchemaField } from '@formily/vue';
3
3
  import { useAsyncQueue, useBusinessBinding, useChangeContext, useFormItemDeps } from '../../../../packages/form-render';
4
4
  import * as components from '../../../../packages/form-render/src/components/renderer';
5
+ import { usePresetScope } from '../../../../packages/form-render/src/hooks/usePresetScope';
5
6
  import { injectOrProvide, uuidGenerator } from '../../../../packages/form-render/src/utils';
6
7
  import { InjectAsyncQueue, InjectionSchemaField, InjectionBusinessCollector, InjectionChangeContextCollector, InjectionFormItemDepsCollector, InjectionFormUUID } from '../../../../packages/form-render/src/constants';
7
8
 
@@ -12,9 +13,9 @@ function useFormContext(props) {
12
13
  ...components,
13
14
  ...props.components
14
15
  },
15
- scope: props.scope
16
+ scope: Object.assign({}, usePresetScope(), props.scope)
16
17
  }).SchemaField);
17
- const businessCollector = useBusinessBinding().create();
18
+ const businessCollector = useBusinessBinding().create(props.businessFilter);
18
19
  provide(InjectionBusinessCollector, businessCollector);
19
20
  const changeContextCollector = useChangeContext().create();
20
21
  provide(InjectionChangeContextCollector, changeContextCollector);
@@ -0,0 +1,6 @@
1
+ export declare function usePresetScope(): {
2
+ isIdCard(value: unknown): boolean;
3
+ isMobile(value: unknown): boolean;
4
+ isEmail(value: unknown): boolean;
5
+ isNumber(value: unknown): boolean;
6
+ };
@@ -0,0 +1,21 @@
1
+ import { isString } from 'lodash-es';
2
+ import { isIdCard, isMobile } from '../../../../packages/form-render/src/utils';
3
+
4
+ function usePresetScope() {
5
+ return {
6
+ isIdCard(value) {
7
+ return isString(value) && isIdCard(value);
8
+ },
9
+ isMobile(value) {
10
+ return isString(value) && isMobile(value);
11
+ },
12
+ isEmail(value) {
13
+ return isString(value) && /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(value);
14
+ },
15
+ isNumber(value) {
16
+ return isString(value) && /\d+/.test(value);
17
+ }
18
+ };
19
+ }
20
+
21
+ export { usePresetScope };
@@ -1,6 +1,6 @@
1
1
  function useTypeNormalize() {
2
2
  function normalizeAgeField(item) {
3
- item.html_type = "INPUT";
3
+ item.html_type = "INPUT_NUMBER";
4
4
  item.suffixConfig = [
5
5
  {
6
6
  val_key: item.val_key_unit,
@@ -1,5 +1,6 @@
1
1
  import { AnyObject } from '../../../../../es/src/types';
2
2
  import { DataField, Field } from '@formily/core';
3
+ import { FIELD_BUSINESS_TYPE } from '../../../../../es/packages/form-render/src/constants';
3
4
  import { FieldItem } from '../types';
4
5
  import { AsyncQueue } from '../hooks';
5
6
  export * from './fieldItem';
@@ -35,3 +36,9 @@ export declare type FormChangePayload = {
35
36
  fieldInstance: DataField;
36
37
  context: FormChangeContext;
37
38
  };
39
+ export declare type FormBusinessFilter = (payload: {
40
+ fieldKey: string;
41
+ value: unknown;
42
+ type: FIELD_BUSINESS_TYPE;
43
+ context?: any;
44
+ }) => unknown;
@@ -10,6 +10,8 @@ export declare function assignUpdateValue(props: AnyObject, field: GeneralField)
10
10
  };
11
11
  export declare function transformDateFormat(format: string): "date" | "datetime";
12
12
  export declare function isIdCard(idCardNo: string): boolean;
13
+ export declare function isMobile(mobile: string): boolean;
14
+ export declare function parseBirthday(birthday: string): Record<string, any>;
13
15
  export declare function parseIdCard(idCardNo: string): IdCardParseInfo;
14
16
  export declare function injectOrProvide<T>(key: InjectionKey<T>, creator: () => T): T;
15
17
  export declare function generateUrlParams(field: GeneralField, dependKeys?: string | string[]): AnyObject;
@@ -3,6 +3,7 @@ import { FIELD_SEX_VALUE } from '../constants/index.js';
3
3
  import { isField } from '@formily/core';
4
4
  import differenceInDays from '../../../../node_modules/date-fns/esm/differenceInDays/index.js';
5
5
  import differenceInMonths from '../../../../node_modules/date-fns/esm/differenceInMonths/index.js';
6
+ import differenceInYears from '../../../../node_modules/date-fns/esm/differenceInYears/index.js';
6
7
  import '../../../../node_modules/date-fns/esm/parse/_lib/parsers/index.js';
7
8
  import { inject, provide } from 'vue';
8
9
 
@@ -31,6 +32,18 @@ function transformDateFormat(format) {
31
32
  function isIdCard(idCardNo) {
32
33
  return /^\d{6}(((19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2]\d|3[0-1])\d{3}(\d|x|X))|(\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2]\d|3[0-1])\d{3}))$/.test(idCardNo);
33
34
  }
35
+ function isMobile(mobile) {
36
+ return /^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/.test(mobile);
37
+ }
38
+ function parseBirthday(birthday) {
39
+ const result = {};
40
+ const d = new Date();
41
+ const birthDate = new Date(birthday);
42
+ result.day = differenceInDays(d, birthDate);
43
+ result.month = differenceInMonths(d, birthDate);
44
+ result.year = differenceInYears(d, birthDate);
45
+ return result;
46
+ }
34
47
  function parseIdCard(idCardNo) {
35
48
  const parseInner = (certificateNo, idxSexStart, birthYearSpan) => {
36
49
  const res = {};
@@ -42,9 +55,8 @@ function parseIdCard(idCardNo) {
42
55
  res.birthday = year + "-" + month + "-" + day;
43
56
  const d = new Date();
44
57
  const monthFloor = d.getMonth() + 1 < parseInt(month, 10) || d.getMonth() + 1 == parseInt(month, 10) && d.getDate() < parseInt(day, 10) ? 1 : 0;
58
+ Object.assign(res, parseBirthday(res.birthday));
45
59
  res.age = res.year = d.getFullYear() - parseInt(year, 10) - monthFloor;
46
- res.day = differenceInDays(d, new Date(res.birthday));
47
- res.month = differenceInMonths(d, new Date(res.birthday));
48
60
  return res;
49
61
  };
50
62
  return parseInner(idCardNo, idCardNo.length == 15 ? 14 : 16, idCardNo.length == 15 ? 2 : 4);
@@ -84,4 +96,4 @@ function uuidGenerator() {
84
96
  });
85
97
  }
86
98
 
87
- export { arrayed, assignUpdateValue, formRenderLog, generateUrlParams, injectOrProvide, isIdCard, parseIdCard, transformDateFormat, traverseSchema, uuidGenerator };
99
+ export { arrayed, assignUpdateValue, formRenderLog, generateUrlParams, injectOrProvide, isIdCard, isMobile, parseBirthday, parseIdCard, transformDateFormat, traverseSchema, uuidGenerator };
@@ -1669,6 +1669,7 @@ body > .vxe-table--tooltip-wrapper {
1669
1669
  cursor: pointer;
1670
1670
  }
1671
1671
  .c-scale .linebar-div {
1672
+ width: 100%;
1672
1673
  text-align: center;
1673
1674
  margin-top: 24px;
1674
1675
  }
@@ -1687,6 +1688,12 @@ body > .vxe-table--tooltip-wrapper {
1687
1688
  .main {
1688
1689
  box-sizing: border-box;
1689
1690
  }
1691
+ .main .n-form-item.n-form-item--top-labelled .n-form-item-label {
1692
+ display: block;
1693
+ }
1694
+ .main .n-form-item .n-form-item-blank {
1695
+ display: block;
1696
+ }
1690
1697
  .main .scale-label-required {
1691
1698
  font-weight: 700;
1692
1699
  }
@@ -1694,6 +1701,9 @@ body > .vxe-table--tooltip-wrapper {
1694
1701
  color: #e02828;
1695
1702
  font-weight: 700;
1696
1703
  }
1704
+ .main .score-i {
1705
+ word-break: keep-all;
1706
+ }
1697
1707
  .main .evalute-label {
1698
1708
  display: inline-block;
1699
1709
  height: 20px;
@@ -2113,6 +2123,7 @@ body > .vxe-table--tooltip-wrapper {
2113
2123
  .c-scale-collection.prompt-message .prompt-message-content {
2114
2124
  line-height: 16px;
2115
2125
  font-size: 14px;
2126
+ word-break: break-all;
2116
2127
  }
2117
2128
  .c-time-range {
2118
2129
  display: flex;
@@ -503,6 +503,10 @@ declare const CScaleView: SFCWithInstall<import("vue").DefineComponent<{
503
503
  init: () => void;
504
504
  checkType: (val: any) => string;
505
505
  diffAnswered: (form: any) => void;
506
+ getCountdownObj: () => {
507
+ setAnswered: number;
508
+ totalLen: number;
509
+ };
506
510
  SvgIcon: import("vue").DefineComponent<{
507
511
  iconClass: {
508
512
  type: StringConstructor;
@@ -503,6 +503,10 @@ declare const _default: import("vue").DefineComponent<{
503
503
  init: () => void;
504
504
  checkType: (val: any) => string;
505
505
  diffAnswered: (form: any) => void;
506
+ getCountdownObj: () => {
507
+ setAnswered: number;
508
+ totalLen: number;
509
+ };
506
510
  SvgIcon: import("vue").DefineComponent<{
507
511
  iconClass: {
508
512
  type: StringConstructor;
@@ -140,7 +140,7 @@ var script = /* @__PURE__ */ defineComponent({
140
140
  return;
141
141
  }
142
142
  let key = "getSubjectAnswer";
143
- const fn = ((_a = state.scaleApiConfig) == null ? void 0 : _a[key]) || null;
143
+ const fn = ((_a = props.scaleApiConfig) == null ? void 0 : _a[key]) || null;
144
144
  if (!fn || typeof fn !== "function") {
145
145
  message.error(`${key} Is not a function`);
146
146
  return;
@@ -228,6 +228,7 @@ var script = /* @__PURE__ */ defineComponent({
228
228
  };
229
229
  };
230
230
  const onSubmit = () => {
231
+ var _a;
231
232
  let hasEvaluate = state.formArray.find((item) => isEvaluation(item.type));
232
233
  if (!hasEvaluate) {
233
234
  confirmSubmit("\u786E\u8BA4\u8981\u63D0\u4EA4\u5417\uFF1F");
@@ -242,15 +243,15 @@ var script = /* @__PURE__ */ defineComponent({
242
243
  emit("submitNoRequest");
243
244
  return;
244
245
  }
245
- if (!(state == null ? void 0 : state.showEvaluateCountdown)) {
246
- confirmSubmit("\u786E\u8BA4\u8981\u7ED3\u675F\u6D4B\u8BC4\u5417\uFF1F");
247
- return;
248
- }
249
- let message2 = "\u786E\u8BA4\u8981\u63D0\u524D\u7ED3\u675F\u6D4B\u8BC4\u5417\uFF1F";
250
- let setAnswered = countdownDom == null ? void 0 : countdownDom.setAnswered;
251
- let totalLen = countdownDom == null ? void 0 : countdownDom.totalLen;
252
- if (setAnswered < totalLen) {
253
- message2 = "\u5B58\u5728\u672A\u89E3\u7B54\u7684\u9898\u76EE\uFF0C\u786E\u5B9A\u8981\u63D0\u524D\u7ED3\u675F\u5417\uFF1F";
246
+ let message2 = "\u786E\u5B9A\u8981\u63D0\u524D\u7ED3\u675F\u6D4B\u8BC4\u5417\uFF1F";
247
+ if (showEvaluateCoundownPage.value && ((_a = countdownDom.value) == null ? void 0 : _a.getCountdownObj)) {
248
+ const evaCountdownObj = countdownDom.value.getCountdownObj();
249
+ const { setAnswered, totalLen } = evaCountdownObj;
250
+ if (setAnswered < totalLen) {
251
+ message2 = "\u5B58\u5728\u672A\u4F5C\u7B54\u7684\u9898\u76EE\uFF0C\u786E\u5B9A\u8981\u63D0\u524D\u7ED3\u675F\u6D4B\u8BC4\u5417\uFF1F";
252
+ } else {
253
+ !(state == null ? void 0 : state.showEvaluateCountdown) && (message2 = "\u786E\u8BA4\u8981\u7ED3\u675F\u6D4B\u8BC4\u5417\uFF1F");
254
+ }
254
255
  }
255
256
  confirmSubmit(message2);
256
257
  };
@@ -71,6 +71,10 @@ declare const _default: import("vue").DefineComponent<{
71
71
  init: () => void;
72
72
  checkType: (val: any) => string;
73
73
  diffAnswered: (form: any) => void;
74
+ getCountdownObj: () => {
75
+ setAnswered: number;
76
+ totalLen: number;
77
+ };
74
78
  SvgIcon: import("vue").DefineComponent<{
75
79
  iconClass: {
76
80
  type: StringConstructor;
@@ -75,9 +75,14 @@ var script = /* @__PURE__ */ defineComponent({
75
75
  console.log(val, "\u89E6\u53D1\u4FEE\u6539\u5566\u5566\u5566");
76
76
  diffAnswered(val);
77
77
  }, { immediate: true, deep: true });
78
+ const getCountdownObj = () => {
79
+ return {
80
+ setAnswered: state.setAnswered,
81
+ totalLen: evaluateState.totalLen
82
+ };
83
+ };
78
84
  expose({
79
- setAnswered: state.setAnswered,
80
- totalLen: evaluateState.totalLen
85
+ getCountdownObj
81
86
  });
82
87
  return (_ctx, _cache) => {
83
88
  return openBlock(), createElementBlock("div", {
@@ -53,8 +53,6 @@ var RInput = defineComponent({
53
53
  };
54
54
  const inputValue = ref(props.form[props.item.val_key]);
55
55
  watch(() => props.form[props.item.val_key], (val) => {
56
- if (!val)
57
- return;
58
56
  inputValue.value = val;
59
57
  }, {
60
58
  immediate: true
@@ -59,6 +59,58 @@ var scriptSelect = defineComponent({
59
59
  var _a, _b;
60
60
  return !!((_b = (_a = props.item) == null ? void 0 : _a.setting) == null ? void 0 : _b.isMultiple);
61
61
  });
62
+ const isDynamic2Static = computed(() => {
63
+ let {
64
+ targetSource = {},
65
+ options = [],
66
+ optionType
67
+ } = props.item || {};
68
+ if (targetSource.target_id && (options.length || optionType == 3))
69
+ return true;
70
+ return false;
71
+ });
72
+ const columnKey = computed(() => {
73
+ var _a;
74
+ let {
75
+ target_id,
76
+ values
77
+ } = ((_a = props.item) == null ? void 0 : _a.targetSource) || {};
78
+ if (!target_id || !values)
79
+ return "value";
80
+ if (isDynamic2Static.value)
81
+ return values || "value";
82
+ return values;
83
+ });
84
+ const labelKey = computed(() => {
85
+ var _a;
86
+ let {
87
+ target_id,
88
+ showField
89
+ } = ((_a = props.item) == null ? void 0 : _a.targetSource) || {};
90
+ if (!target_id || !showField)
91
+ return "label";
92
+ if (isDynamic2Static.value)
93
+ return showField || "label";
94
+ return showField;
95
+ });
96
+ const handleDynamic2StaticOptions = (options) => {
97
+ if (!options || !options.length)
98
+ return [];
99
+ return options.map((item) => {
100
+ if ("cascadeData" in item) {
101
+ Object.assign(item, {
102
+ ...item.cascadeData
103
+ });
104
+ }
105
+ if (!(columnKey.value in item)) {
106
+ item[columnKey.value] = item.value || item.label;
107
+ }
108
+ if (!(labelKey.value in item)) {
109
+ item[labelKey.value] = item.label;
110
+ }
111
+ return item;
112
+ });
113
+ };
62
114
  const initSelectOptions = async () => {
63
115
  const {
64
116
  targetSource,
@@ -69,8 +121,8 @@ var scriptSelect = defineComponent({
69
121
  state.showField = "label";
70
122
  if (!(targetSource == null ? void 0 : targetSource.target_id))
71
123
  return;
72
- if (options.length || optionType == 3) {
73
- state.curOptions = options;
124
+ if (isDynamic2Static.value) {
125
+ state.curOptions = handleDynamic2StaticOptions(options);
74
126
  return;
75
127
  }
76
128
  try {
@@ -134,6 +186,8 @@ var scriptSelect = defineComponent({
134
186
  "onUpdate:value": [($event) => props.form[props.item.val_key] = $event, handleSelectChange],
135
187
  "filterable": true,
136
188
  "placeholder": "\u8BF7\u9009\u62E9",
189
+ "value-field": columnKey.value,
190
+ "label-field": labelKey.value,
137
191
  "multiple": isMultiple.value,
138
192
  "disabled": props.isLock,
139
193
  "loading": state.fetching,
@@ -58,7 +58,7 @@ const ScaleViewComputed = (props, state, config) => {
58
58
  if (!isEvaluation(type))
59
59
  return tempTile;
60
60
  let score = handleEvaluationScore(item);
61
- return `${tempTile}&nbsp;<span style="color:#2d7aff;">${score}</span>`;
61
+ return `${tempTile}&nbsp;<span style="color:#2d7aff;" class="score-i">${score}</span>`;
62
62
  });
63
63
  const hasScore = computed(() => {
64
64
  let { config: config2 } = state;
@@ -91,7 +91,9 @@ const ScaleViewComputed = (props, state, config) => {
91
91
  return state.paramsEvaluate && Object.keys(state.paramsEvaluate).length;
92
92
  });
93
93
  const hasDefault = computed(() => {
94
- let hash = window.location.hash;
94
+ let hash = window.location.search;
95
+ if (!hash)
96
+ return;
95
97
  let defaultVariable = ["evaname", "evadesc", "evast", "evadur", "evaan"];
96
98
  let hasDefaultItem = defaultVariable.find((item) => hash.includes(item));
97
99
  return state.paramsEvaluate || hasDefaultItem;
@@ -118,7 +120,12 @@ const ScaleViewComputed = (props, state, config) => {
118
120
  const showAnswerParse = computed(() => (item) => {
119
121
  var _a;
120
122
  let { evaluateAnswer, checkAnswerMode, evaluateStartTime, evaluateTime } = ((_a = state.config) == null ? void 0 : _a.evaluateResultSetting) || {};
121
- let arr = ["EVALUATE_RADIO_BLOCK", "EVALUATE_CHECKBOX_BLOCK", "EVALUATE_SELECT", "EVALUATE_INPUT"];
123
+ let arr = [
124
+ "EVALUATE_RADIO_BLOCK",
125
+ "EVALUATE_CHECKBOX_BLOCK",
126
+ "EVALUATE_SELECT",
127
+ "EVALUATE_INPUT"
128
+ ];
122
129
  let maxScore = (item == null ? void 0 : item.scoreConfigs) || 0;
123
130
  let isShow = evaluateAnswer && state.isFinished && arr.includes(item.type) && maxScore;
124
131
  if (!evaluateStartTime || !evaluateTime || checkAnswerMode && checkAnswerMode == 1) {
@@ -172,12 +179,12 @@ const ScaleViewComputed = (props, state, config) => {
172
179
  };
173
180
  });
174
181
  const comProsMap = {
175
- RSelectCom: selectProps.value,
176
- RCascaderCom: cascaderProps.value,
177
- RUploadCom: uploadProps.value,
178
- RMapCom: mapProps.value,
179
- RVodChunkUploadCom: vodChunkUploadProps.value,
180
- CSelectLabelCom: selectLabelProps.value
182
+ "RSelectCom": selectProps.value,
183
+ "RCascaderCom": cascaderProps.value,
184
+ "RUploadCom": uploadProps.value,
185
+ "RMapCom": mapProps.value,
186
+ "RVodChunkUploadCom": vodChunkUploadProps.value,
187
+ "CSelectLabelCom": selectLabelProps.value
181
188
  };
182
189
  const propsConfig = computed(() => (item, index) => {
183
190
  var _a;
@@ -10,7 +10,12 @@ import { useDialog } from 'naive-ui';
10
10
  const ScaleViewInit = (props, state, emit, config) => {
11
11
  const dialog = useDialog();
12
12
  const { setNoData } = useNoData();
13
- const { hasEvaluateResultSetting, hasparamsEvaluate, hasDefault, formKey } = ScaleViewComputed(props, state, config);
13
+ const {
14
+ hasEvaluateResultSetting,
15
+ hasparamsEvaluate,
16
+ hasDefault,
17
+ formKey
18
+ } = ScaleViewComputed(props, state, config);
14
19
  const { formatRules } = ScaleViewValidate(props, state, config);
15
20
  const { nextLogicEvent } = useEvent(props, state);
16
21
  const setEvaluateStartTime = (evaluateResultSetting) => {
@@ -189,6 +194,7 @@ const ScaleViewInit = (props, state, emit, config) => {
189
194
  item.relationLogic = relationLogicObj;
190
195
  };
191
196
  const handleFrontAddress = (list) => {
197
+ var _a, _b;
192
198
  if (!list || !list.length)
193
199
  return;
194
200
  let matchItem = list.find((item) => item.type === "FRONT_ADDRESS");
@@ -201,7 +207,7 @@ const ScaleViewInit = (props, state, emit, config) => {
201
207
  if (!setting || !Object.keys(setting).length)
202
208
  return;
203
209
  let query = handleQueryParams();
204
- if ((query == null ? void 0 : query.redirect) == 1)
210
+ if ((query == null ? void 0 : query.redirect) == 1 || ((_a = props.params) == null ? void 0 : _a.redirect) == 1 || query.isEdit == 3 || ((_b = props.params) == null ? void 0 : _b.isEdit) == 3)
205
211
  return;
206
212
  let { frontAddress } = setting;
207
213
  if (frontAddress) {
@@ -12,9 +12,10 @@ const isEvaluation = (e) => {
12
12
  };
13
13
  const handleQueryParams = () => {
14
14
  let params = {};
15
- let hash = window.location.hash.split("?")[1];
15
+ let hash = window.location.search.split("?")[1];
16
16
  if (!hash)
17
17
  return {};
18
+ hash = hash.replace(/\+/g, "%20");
18
19
  for (let [key, value] of new URLSearchParams(hash).entries()) {
19
20
  params[key] = decodeURIComponent(value);
20
21
  }
@@ -166,6 +166,7 @@
166
166
  cursor: pointer;
167
167
  }
168
168
  .c-scale .linebar-div {
169
+ width: 100%;
169
170
  text-align: center;
170
171
  margin-top: 24px;
171
172
  }
@@ -184,6 +185,12 @@
184
185
  .main {
185
186
  box-sizing: border-box;
186
187
  }
188
+ .main .n-form-item.n-form-item--top-labelled .n-form-item-label {
189
+ display: block;
190
+ }
191
+ .main .n-form-item .n-form-item-blank {
192
+ display: block;
193
+ }
187
194
  .main .scale-label-required {
188
195
  font-weight: 700;
189
196
  }
@@ -191,6 +198,9 @@
191
198
  color: #e02828;
192
199
  font-weight: 700;
193
200
  }
201
+ .main .score-i {
202
+ word-break: keep-all;
203
+ }
194
204
  .main .evalute-label {
195
205
  display: inline-block;
196
206
  height: 20px;
@@ -610,6 +620,7 @@
610
620
  .c-scale-collection.prompt-message .prompt-message-content {
611
621
  line-height: 16px;
612
622
  font-size: 14px;
623
+ word-break: break-all;
613
624
  }
614
625
  .c-time-range {
615
626
  display: flex;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cnhis-design-vue",
3
3
  "private": false,
4
- "version": "3.1.12-beta.2",
4
+ "version": "3.1.12-beta.3",
5
5
  "license": "ISC",
6
6
  "module": "es/packages/index.js",
7
7
  "main": "es/packages/index.js",