cnhis-design-vue 3.1.17-beta.6 → 3.1.17-beta.7

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.
@@ -2941,6 +2941,12 @@ declare const BigTable: SFCWithInstall<import("vue").DefineComponent<{
2941
2941
  } | null;
2942
2942
  showOverflow: boolean;
2943
2943
  })[];
2944
+ getRowData: (row: import("../../../es/src/types").AnyObject) => {
2945
+ separateData: Record<string, string>;
2946
+ index: number;
2947
+ rawRow: import("../../../es/src/types").AnyObject;
2948
+ row: import("../../../es/src/types").AnyObject;
2949
+ } | undefined;
2944
2950
  formatterEdit: (params: any, col: any) => any;
2945
2951
  getEditBtn: (row: any, col: any, index: any) => any;
2946
2952
  formatter: (params: any, col: any, _isEdit: any) => any;
@@ -1126,12 +1126,7 @@ declare const _default: import("vue").DefineComponent<{
1126
1126
  textColorGhostHoverWarning: string;
1127
1127
  textColorGhostPressedWarning: string;
1128
1128
  textColorGhostFocusWarning: string;
1129
- textColorGhostDisabledWarning: string; /**
1130
- * 判断是否渲染EditForm
1131
- * @param {*} row
1132
- * @param {*} column
1133
- * @returns
1134
- */
1129
+ textColorGhostDisabledWarning: string;
1135
1130
  borderWarning: string;
1136
1131
  borderHoverWarning: string;
1137
1132
  borderPressedWarning: string;
@@ -1158,7 +1153,14 @@ declare const _default: import("vue").DefineComponent<{
1158
1153
  textColorGhostPressedError: string;
1159
1154
  textColorGhostFocusError: string;
1160
1155
  textColorGhostDisabledError: string;
1161
- borderError: string;
1156
+ borderError: string; /**
1157
+ * 初始化props
1158
+ * @param {*} unionItem
1159
+ * @param {*} row
1160
+ * @param {*} column
1161
+ * @param {*} $rowIndex
1162
+ * @returns
1163
+ */
1162
1164
  borderHoverError: string;
1163
1165
  borderPressedError: string;
1164
1166
  borderFocusError: string;
@@ -1210,6 +1212,10 @@ declare const _default: import("vue").DefineComponent<{
1210
1212
  colorTertiaryPressed: string;
1211
1213
  colorQuaternary: string;
1212
1214
  colorQuaternaryHover: string;
1215
+ /**
1216
+ * 单个form提交成功数据
1217
+ * @param {*} obj formData
1218
+ */
1213
1219
  colorQuaternaryPressed: string;
1214
1220
  color: string;
1215
1221
  colorHover: string;
@@ -2945,6 +2951,12 @@ declare const _default: import("vue").DefineComponent<{
2945
2951
  } | null;
2946
2952
  showOverflow: boolean;
2947
2953
  })[];
2954
+ getRowData: (row: import("../../../src/types").AnyObject) => {
2955
+ separateData: Record<string, string>;
2956
+ index: number;
2957
+ rawRow: import("../../../src/types").AnyObject;
2958
+ row: import("../../../src/types").AnyObject;
2959
+ } | undefined;
2948
2960
  formatterEdit: (params: any, col: any) => any;
2949
2961
  getEditBtn: (row: any, col: any, index: any) => any;
2950
2962
  formatter: (params: any, col: any, _isEdit: any) => any;
@@ -3287,7 +3299,22 @@ declare const _default: import("vue").DefineComponent<{
3287
3299
  errorColor: string;
3288
3300
  errorColorHover: string;
3289
3301
  errorColorPressed: string;
3290
- errorColorSuppl: string;
3302
+ errorColorSuppl: string; /**
3303
+ * 针对 bigTable 的设置列
3304
+ * type: 列的类型
3305
+ * field: 列字段名(注:属性层级越深,渲染性能将直线下降)
3306
+ * title: 列标题(支持开启国际化)
3307
+ * width: 列宽度(如果为空则均匀分配剩余宽度,如果全部列固定了,可能会存在宽屏下不会铺满,可以配合 "%" 或者 "min-width" 布局)
3308
+ * minWidth: 最小列宽度;会自动将剩余空间按比例分配
3309
+ * resizable: 列是否允许拖动列宽调整大小
3310
+ * visible: 列是否显示
3311
+ * fixed: 将列固定在左侧或者右侧(注意:固定列应该放在左右两侧的位置)
3312
+ * align: 列对齐方式
3313
+ * headerAlign: 表头列的对齐方式
3314
+ * footerAlign: 表尾列的对齐方式
3315
+ * formatter: 格式化显示内容 Function({cellValue, row, column})
3316
+ * sortable: 是否允许列排序
3317
+ */
3291
3318
  textColorBase: string;
3292
3319
  textColor1: string;
3293
3320
  textColor2: string;
@@ -19,7 +19,7 @@ import { useBatchEditing } from './hooks/useBatchEditing.js';
19
19
  import { useNestTable } from './hooks/useNestTable.js';
20
20
  import { useAnchor } from './hooks/useAnchor.js';
21
21
  import { useEvent } from './hooks/useEvent.js';
22
- import { useSeparateRow } from './hooks/useSeparateRow.js';
22
+ import { useSeparateRow, useSeparateMap } from './hooks/useSeparateRow.js';
23
23
  import { useFormat } from './hooks/useFormat.js';
24
24
  import { useTableParse } from './hooks/useTableParse.js';
25
25
  import { useEdit, comps } from './hooks/useEdit.js';
@@ -506,7 +506,11 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
506
506
  state.columnLen = currentColumns.filter((item) => item.visible).length;
507
507
  return columns;
508
508
  };
509
+ const {
510
+ getRowData
511
+ } = useSeparateMap();
509
512
  const formatterEdit = (params, col) => {
513
+ var _a, _b;
510
514
  let {
511
515
  row,
512
516
  column,
@@ -526,7 +530,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
526
530
  const propsData = {
527
531
  col,
528
532
  row,
529
- index: $rowIndex,
533
+ index: (_b = (_a = getRowData(row)) == null ? void 0 : _a.index) != null ? _b : $rowIndex,
530
534
  type: formType,
531
535
  ...col.componentProps || {},
532
536
  onFormChange,
@@ -24,32 +24,33 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
24
24
  watch(show, updateShow);
25
25
  const editContent = ref();
26
26
  const { getRowData } = useSeparateMap();
27
- async function updateShow(show2) {
27
+ async function onShow(target) {
28
28
  var _a;
29
- const target = getRowData(props.row);
30
29
  if (!target)
31
30
  return;
32
- if (show2) {
33
- editContent.value = cloneDeep(target.row[props.col.field]);
34
- await new Promise((resolve) => setTimeout(resolve));
35
- (_a = popoverRef.value) == null ? void 0 : _a.syncPosition();
36
- return;
37
- }
38
- const old = target.row[props.col.field];
31
+ editContent.value = cloneDeep(target.row[props.col.field]);
32
+ await new Promise((resolve) => setTimeout(resolve));
33
+ (_a = popoverRef.value) == null ? void 0 : _a.syncPosition();
34
+ return;
35
+ }
36
+ async function onClose(target) {
39
37
  if (!target)
40
38
  return;
39
+ const old = target.row[props.col.field];
41
40
  if (!isObject(editContent.value) && !isArray(editContent.value)) {
42
41
  if (old === editContent.value)
43
42
  return;
44
43
  }
45
- target.rawRow[props.col.field] = editContent.value;
46
44
  emit("formChange", {
47
45
  value: editContent.value,
48
- row: target.row,
46
+ row: props.row,
49
47
  column: props.col,
50
48
  index: target.index
51
49
  });
52
50
  }
51
+ function updateShow(show2) {
52
+ show2 ? onShow(getRowData(props.row)) : onClose(getRowData(props.row));
53
+ }
53
54
  const style = {
54
55
  border: "1px solid #f5f5f5",
55
56
  padding: "4px 0 4px 4px",
@@ -41,7 +41,19 @@ declare const _default: import("vue").DefineComponent<{
41
41
  rawRow: AnyObject;
42
42
  row: AnyObject;
43
43
  } | undefined;
44
- updateShow: (show: boolean) => Promise<void>;
44
+ onShow: (target: {
45
+ separateData: Record<string, string>;
46
+ index: number;
47
+ rawRow: AnyObject;
48
+ row: AnyObject;
49
+ } | undefined) => Promise<void>;
50
+ onClose: (target: {
51
+ separateData: Record<string, string>;
52
+ index: number;
53
+ rawRow: AnyObject;
54
+ row: AnyObject;
55
+ } | undefined) => Promise<void>;
56
+ updateShow: (show: boolean) => void;
45
57
  style: CSSProperties;
46
58
  SlotRender: import("vue").DefineComponent<{
47
59
  renderer: {
@@ -233,7 +233,19 @@ export declare const comps: {
233
233
  rawRow: import("../../../../src/types").AnyObject;
234
234
  row: import("../../../../src/types").AnyObject;
235
235
  } | undefined;
236
- updateShow: (show: boolean) => Promise<void>;
236
+ onShow: (target: {
237
+ separateData: Record<string, string>;
238
+ index: number;
239
+ rawRow: import("../../../../src/types").AnyObject;
240
+ row: import("../../../../src/types").AnyObject;
241
+ } | undefined) => Promise<void>;
242
+ onClose: (target: {
243
+ separateData: Record<string, string>;
244
+ index: number;
245
+ rawRow: import("../../../../src/types").AnyObject;
246
+ row: import("../../../../src/types").AnyObject;
247
+ } | undefined) => Promise<void>;
248
+ updateShow: (show: boolean) => void;
237
249
  style: import("vue").CSSProperties;
238
250
  SlotRender: import("vue").DefineComponent<{
239
251
  renderer: {
@@ -1,5 +1,13 @@
1
+ import { Func } from '../../../../../../es/src/types';
2
+ import { PropType } from 'vue';
1
3
  export declare const INPUT_NUMBER: import("vue").DefineComponent<{
2
- onChange: {};
4
+ value: {
5
+ type: (NumberConstructor | StringConstructor)[];
6
+ };
7
+ onChange: {
8
+ type: PropType<Func<any[], any>>;
9
+ required: true;
10
+ };
3
11
  prefix: {
4
12
  type: StringConstructor;
5
13
  };
@@ -7,7 +15,13 @@ export declare const INPUT_NUMBER: import("vue").DefineComponent<{
7
15
  type: StringConstructor;
8
16
  };
9
17
  }, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
10
- onChange: {};
18
+ value: {
19
+ type: (NumberConstructor | StringConstructor)[];
20
+ };
21
+ onChange: {
22
+ type: PropType<Func<any[], any>>;
23
+ required: true;
24
+ };
11
25
  prefix: {
12
26
  type: StringConstructor;
13
27
  };
@@ -1,12 +1,20 @@
1
- import { defineComponent, createVNode } from 'vue';
2
- import { createInputSlot } from '../../utils/index.js';
1
+ import { defineComponent, watch, computed, createVNode } from 'vue';
2
+ import { isString, isNumber } from 'lodash-es';
3
+ import { useCommonInjection } from '../../../../../packages/form-render/src/hooks/useCommonInjection';
4
+ import { createInputSlot, parseNumberFromMaybeString } from '../../utils/index.js';
3
5
  import { connect, mapProps } from '@formily/vue';
4
6
  import { NInputNumber } from 'naive-ui';
5
7
  import { assignUpdateValue } from '../../utils/schema.js';
6
8
 
7
9
  const script = defineComponent({
8
10
  props: {
9
- onChange: {},
11
+ value: {
12
+ type: [Number, String]
13
+ },
14
+ onChange: {
15
+ type: Function,
16
+ required: true
17
+ },
10
18
  prefix: {
11
19
  type: String
12
20
  },
@@ -16,8 +24,27 @@ const script = defineComponent({
16
24
  },
17
25
  setup(props) {
18
26
  const _slots = createInputSlot(props);
27
+ useCommonInjection().injectValueValidate(() => props.value);
28
+ watch(() => props.value, (value) => {
29
+ if (value == null)
30
+ return;
31
+ if (!isString(value) && !isNumber(value) || Number.isNaN(+value))
32
+ return props.onChange(null);
33
+ props.onChange(+value);
34
+ });
35
+ const valueRef = computed({
36
+ get: () => parseNumberFromMaybeString(props.value),
37
+ set: (v) => {
38
+ var _a;
39
+ return (_a = props.onChange) == null ? void 0 : _a.call(props, v);
40
+ }
41
+ });
19
42
  return () => {
20
- return createVNode(NInputNumber, null, _slots.value);
43
+ return createVNode(NInputNumber, {
44
+ "value": valueRef.value,
45
+ "onUpdate:value": ($event) => valueRef.value = $event,
46
+ "show-button": false
47
+ }, _slots.value);
21
48
  };
22
49
  }
23
50
  });
@@ -7,7 +7,10 @@ function useCommonInjection() {
7
7
  const { field } = useFormField();
8
8
  watch(traverser, () => {
9
9
  var _a, _b;
10
- return isField(field.value) && field.value.visited && ((_b = (_a = field.value).validate) == null ? void 0 : _b.call(_a));
10
+ try {
11
+ isField(field.value) && field.value.visited && ((_b = (_a = field.value).validate) == null ? void 0 : _b.call(_a));
12
+ } catch (e) {
13
+ }
11
14
  });
12
15
  }
13
16
  function injectValueWatchFromEmpty(traverser, trigger) {
@@ -20,9 +20,9 @@ function useFieldListAdaptor(collector) {
20
20
  clearable: item.is_empty === "0",
21
21
  ...item.componentProps || {},
22
22
  onBlur(...args) {
23
- var _a2;
23
+ var _a2, _b;
24
24
  collector.trigger(item.val_key, "blur");
25
- (_a2 = item.componentProps) == null ? void 0 : _a2.onBlur(...args);
25
+ (_b = (_a2 = item.componentProps) == null ? void 0 : _a2.onBlur) == null ? void 0 : _b.call(_a2, ...args);
26
26
  }
27
27
  },
28
28
  "x-display": item.is_show === "0" ? "hidden" : "visible",
@@ -122,8 +122,6 @@ function useFieldListAdaptor(collector) {
122
122
  const { decimal_length, validate } = item;
123
123
  Object.assign(schema["x-component-props"], {
124
124
  precision: decimal_length || (validate == null ? void 0 : validate.decimal_length),
125
- max: validate == null ? void 0 : validate.max_value,
126
- min: validate == null ? void 0 : validate.min_value,
127
125
  prefix: item.prefix,
128
126
  suffix: item.suffix
129
127
  });
@@ -13,6 +13,8 @@ function useFormValidator() {
13
13
  ({ validate }) => ({
14
14
  validator(value) {
15
15
  var _a;
16
+ if (value == null)
17
+ return;
16
18
  if (!isString(value) || !isIdCard(value))
17
19
  return (_a = validate == null ? void 0 : validate.message) != null ? _a : "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u8EAB\u4EFD\u8BC1\u683C\u5F0F";
18
20
  }
@@ -28,20 +30,33 @@ function useFormValidator() {
28
30
  ]
29
31
  ]);
30
32
  const commonValidateConfig = { triggerType: "onBlur" };
33
+ const createDecimalValidator = (decimal, message) => {
34
+ const errorMessage = message != null ? message : `\u5C0F\u6570\u4F4D\u6570\u6700\u591A${decimal}\u4F4D`;
35
+ return {
36
+ validator(value) {
37
+ var _a;
38
+ return ((_a = String(value).split(".")[1]) == null ? void 0 : _a.length) > decimal ? errorMessage : "";
39
+ }
40
+ };
41
+ };
31
42
  function createValidatorSchema(fieldItem) {
32
43
  const rules = [];
33
- const { validate: { vali_obj, max_length, message } = {}, validator } = fieldItem;
44
+ const { validate: { vali_obj, max_length, message, max_value, min_value, decimal_length } = {}, validator } = fieldItem;
34
45
  if (validator) {
35
- const _validator = arrayed(validator);
36
- _validator.forEach((f) => {
46
+ arrayed(validator).forEach((f) => {
37
47
  if (!isFunction(f))
38
48
  return;
39
49
  rules.push({ validator: (value) => f(value, fieldItem) });
40
50
  });
41
51
  }
42
- if (max_length) {
52
+ if (max_length)
43
53
  rules.push({ max: max_length, message });
44
- }
54
+ if (max_value)
55
+ rules.push({ maximum: max_value, message });
56
+ if (min_value)
57
+ rules.push({ minimum: min_value, message });
58
+ if (decimal_length != null)
59
+ rules.push(createDecimalValidator(+decimal_length, message));
45
60
  const ruleCreator = vali_obj && validateMap.get(vali_obj);
46
61
  ruleCreator && rules.push(Object.assign({}, commonValidateConfig, ruleCreator(fieldItem)));
47
62
  return rules;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cnhis-design-vue",
3
3
  "private": false,
4
- "version": "3.1.17-beta.6",
4
+ "version": "3.1.17-beta.7",
5
5
  "license": "ISC",
6
6
  "module": "es/packages/index.js",
7
7
  "main": "es/packages/index.js",
@@ -56,6 +56,7 @@
56
56
  "min-dom": "^3.2.1",
57
57
  "moment": "^2.29.1",
58
58
  "naive-ui": "^2.29.0",
59
+ "ramda": "^0.28.0",
59
60
  "rimraf": "^3.0.2",
60
61
  "spark-md5": "^3.0.2",
61
62
  "tiny-svg": "^2.2.4",
@@ -89,6 +90,7 @@
89
90
  "@types/lodash-es": "^4.17.6",
90
91
  "@types/markdown-it": "^12.2.3",
91
92
  "@types/node": "^17.0.38",
93
+ "@types/ramda": "^0.28.15",
92
94
  "@types/replacestream": "^4.0.1",
93
95
  "@types/sortablejs": "^1.13.0",
94
96
  "@types/vue-router": "^2.0.0",