@fangzhongya/fang-ui 0.1.16 → 0.1.18

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.
@@ -53,11 +53,50 @@ function getFormRule(obj) {
53
53
  }
54
54
  }
55
55
  }
56
+ function setComputed(obj, v) {
57
+ if (obj.computed) {
58
+ if (obj.default) {
59
+ const value = obj.default;
60
+ if (obj.computed instanceof Array) {
61
+ obj.computed.forEach((k, i) => {
62
+ if (value instanceof Array) {
63
+ v[k] = value[i];
64
+ } else {
65
+ v[k] = value ? value[k] : void 0;
66
+ }
67
+ });
68
+ } else if (obj.computed.set) {
69
+ obj.computed.set(value, v, obj);
70
+ }
71
+ } else {
72
+ if (obj.prop) {
73
+ const r = v[obj.prop];
74
+ if (obj.computed instanceof Array) {
75
+ v[obj.prop] = obj.computed.map((k) => {
76
+ return v[k];
77
+ });
78
+ } else if (obj.computed.get) {
79
+ v[obj.prop] = obj.computed.get(r, v, obj);
80
+ }
81
+ obj.default = v[obj.prop];
82
+ } else {
83
+ if (obj.computed instanceof Array) {
84
+ obj.default = obj.computed.map((k) => {
85
+ return v[k];
86
+ });
87
+ } else if (obj.computed.get) {
88
+ obj.default = obj.computed.get(void 0, v, obj);
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
56
94
  function setFormDefaultValue(obj, value) {
57
95
  let v = util.getChildrenData(obj, value, true) ?? {};
58
96
  if (obj.orig) {
59
97
  v = value;
60
98
  }
99
+ setComputed(obj, v);
61
100
  const prop = obj.prop;
62
101
  if (prop) {
63
102
  if (obj.pars) {
@@ -51,11 +51,50 @@ function getFormRule(obj) {
51
51
  }
52
52
  }
53
53
  }
54
+ function setComputed(obj, v) {
55
+ if (obj.computed) {
56
+ if (obj.default) {
57
+ const value = obj.default;
58
+ if (obj.computed instanceof Array) {
59
+ obj.computed.forEach((k, i) => {
60
+ if (value instanceof Array) {
61
+ v[k] = value[i];
62
+ } else {
63
+ v[k] = value ? value[k] : void 0;
64
+ }
65
+ });
66
+ } else if (obj.computed.set) {
67
+ obj.computed.set(value, v, obj);
68
+ }
69
+ } else {
70
+ if (obj.prop) {
71
+ const r = v[obj.prop];
72
+ if (obj.computed instanceof Array) {
73
+ v[obj.prop] = obj.computed.map((k) => {
74
+ return v[k];
75
+ });
76
+ } else if (obj.computed.get) {
77
+ v[obj.prop] = obj.computed.get(r, v, obj);
78
+ }
79
+ obj.default = v[obj.prop];
80
+ } else {
81
+ if (obj.computed instanceof Array) {
82
+ obj.default = obj.computed.map((k) => {
83
+ return v[k];
84
+ });
85
+ } else if (obj.computed.get) {
86
+ obj.default = obj.computed.get(void 0, v, obj);
87
+ }
88
+ }
89
+ }
90
+ }
91
+ }
54
92
  function setFormDefaultValue(obj, value) {
55
93
  let v = getChildrenData(obj, value, true) ?? {};
56
94
  if (obj.orig) {
57
95
  v = value;
58
96
  }
97
+ setComputed(obj, v);
59
98
  const prop = obj.prop;
60
99
  if (prop) {
61
100
  if (obj.pars) {
@@ -1,7 +1,7 @@
1
- /**
2
- * @config cover=true
3
- */
4
- @use 'element-plus/theme-chalk/src/base.scss' as *;
5
- // @use '../../date-picker-panel/style/index2.scss' as *;
6
- @use 'element-plus/theme-chalk/src/popper.scss' as *;
7
- @use 'element-plus/theme-chalk/src/date-picker.scss' as *;
1
+ /**
2
+ * @config cover=true
3
+ */
4
+ @use 'element-plus/theme-chalk/src/base.scss' as *;
5
+ // @use '../../date-picker-panel/style/index2.scss' as *;
6
+ @use 'element-plus/theme-chalk/src/popper.scss' as *;
7
+ @use 'element-plus/theme-chalk/src/date-picker.scss' as *;
@@ -95,6 +95,20 @@ function setUp(props, emit, cs, refForm, getLocale) {
95
95
  }
96
96
  return setObjStyle.setObjStyle(vst, obj);
97
97
  }
98
+ function setReset() {
99
+ const setListValue = (arr, listobj) => {
100
+ arr == null ? void 0 : arr.forEach((obj) => {
101
+ if (listobj) {
102
+ obj.father = obj.father ?? listobj;
103
+ }
104
+ if (obj.children) {
105
+ setListValue(obj.children, obj);
106
+ }
107
+ use.setFormDefaultValue(obj, dataForm.value);
108
+ });
109
+ };
110
+ setListValue(props.list);
111
+ }
98
112
  function getRules() {
99
113
  const rules = {};
100
114
  const setListValue = (arr, listobj) => {
@@ -106,9 +120,7 @@ function setUp(props, emit, cs, refForm, getLocale) {
106
120
  if (obj.children) {
107
121
  setListValue(obj.children, obj);
108
122
  }
109
- if (obj.prop) {
110
- use.setFormDefaultValue(obj, dataForm.value);
111
- }
123
+ use.setFormDefaultValue(obj, dataForm.value);
112
124
  let trigger = 1;
113
125
  if (typeof obj.compon == "string") {
114
126
  if (Changes.includes(lineToLargeHump.lineToLargeHump(obj.compon))) {
@@ -199,6 +211,7 @@ function setUp(props, emit, cs, refForm, getLocale) {
199
211
  function resetFields() {
200
212
  var _a;
201
213
  (_a = refForm.value) == null ? void 0 : _a.resetFields();
214
+ setReset();
202
215
  }
203
216
  function validateField(...arr) {
204
217
  var _a;
@@ -93,6 +93,20 @@ function setUp(props, emit, cs, refForm, getLocale) {
93
93
  }
94
94
  return setObjStyle(vst, obj);
95
95
  }
96
+ function setReset() {
97
+ const setListValue = (arr, listobj) => {
98
+ arr == null ? void 0 : arr.forEach((obj) => {
99
+ if (listobj) {
100
+ obj.father = obj.father ?? listobj;
101
+ }
102
+ if (obj.children) {
103
+ setListValue(obj.children, obj);
104
+ }
105
+ setFormDefaultValue(obj, dataForm.value);
106
+ });
107
+ };
108
+ setListValue(props.list);
109
+ }
96
110
  function getRules() {
97
111
  const rules = {};
98
112
  const setListValue = (arr, listobj) => {
@@ -104,9 +118,7 @@ function setUp(props, emit, cs, refForm, getLocale) {
104
118
  if (obj.children) {
105
119
  setListValue(obj.children, obj);
106
120
  }
107
- if (obj.prop) {
108
- setFormDefaultValue(obj, dataForm.value);
109
- }
121
+ setFormDefaultValue(obj, dataForm.value);
110
122
  let trigger = 1;
111
123
  if (typeof obj.compon == "string") {
112
124
  if (Changes.includes(lineToLargeHump(obj.compon))) {
@@ -197,6 +209,7 @@ function setUp(props, emit, cs, refForm, getLocale) {
197
209
  function resetFields() {
198
210
  var _a;
199
211
  (_a = refForm.value) == null ? void 0 : _a.resetFields();
212
+ setReset();
200
213
  }
201
214
  function validateField(...arr) {
202
215
  var _a;
@@ -5,6 +5,7 @@ const data = require("./data.cjs");
5
5
  require("../../../utils/index.cjs");
6
6
  const index = require("../../../hooks/cssname/index.cjs");
7
7
  const use = require("../../common/use.cjs");
8
+ const isEqual = require("@fangzhongya/utils/basic/object/isEqual");
8
9
  const index$1 = require("../../../hooks/props-default/index.cjs");
9
10
  const data$1 = require("../../forms/src/data.cjs");
10
11
  const objValue = require("@fangzhongya/utils/basic/object/objValue");
@@ -20,7 +21,6 @@ const _sfc_main = vue.defineComponent({
20
21
  const prs = index$1.usePropsDefault(data.name, p, data.dataProps);
21
22
  index$1.viewProps(prs, data.name);
22
23
  const props = prs.listobj;
23
- console.log("props", props);
24
24
  const compons = vue.inject(data$1.provides.compons, {});
25
25
  const formvalue = vue.computed(() => {
26
26
  const o = {};
@@ -59,13 +59,24 @@ const _sfc_main = vue.defineComponent({
59
59
  r = z;
60
60
  }
61
61
  if (props.computed) {
62
+ let c;
62
63
  if (props.computed instanceof Array) {
63
- r = props.computed.map((k) => {
64
+ c = props.computed.map((k) => {
64
65
  return v[k];
65
66
  });
66
67
  } else if (props.computed.get) {
67
- r = props.computed.get(r, v, props);
68
+ c = props.computed.get(r, v, props);
68
69
  }
70
+ if (prop) {
71
+ if (!isEqual.isEqual(c, r)) {
72
+ if (props.pars) {
73
+ objValue.setObjValue(v, prop, c);
74
+ } else {
75
+ v[prop] = c;
76
+ }
77
+ }
78
+ }
79
+ r = c;
69
80
  }
70
81
  return r;
71
82
  },
@@ -3,6 +3,7 @@ import { name, dataProps, dataEmits, dataExpose } from "./data.js";
3
3
  import "../../../utils/index.js";
4
4
  import { useCssName } from "../../../hooks/cssname/index.js";
5
5
  import { getOnObjs } from "../../common/use.js";
6
+ import { isEqual } from "@fangzhongya/utils/basic/object/isEqual";
6
7
  import { usePropsDefault, viewProps, getProps } from "../../../hooks/props-default/index.js";
7
8
  import { provides } from "../../forms/src/data.js";
8
9
  import { setObjValue, getObjValue } from "@fangzhongya/utils/basic/object/objValue";
@@ -18,7 +19,6 @@ const _sfc_main = defineComponent({
18
19
  const prs = usePropsDefault(name, p, dataProps);
19
20
  viewProps(prs, name);
20
21
  const props = prs.listobj;
21
- console.log("props", props);
22
22
  const compons = inject(provides.compons, {});
23
23
  const formvalue = computed(() => {
24
24
  const o = {};
@@ -57,13 +57,24 @@ const _sfc_main = defineComponent({
57
57
  r = z;
58
58
  }
59
59
  if (props.computed) {
60
+ let c;
60
61
  if (props.computed instanceof Array) {
61
- r = props.computed.map((k) => {
62
+ c = props.computed.map((k) => {
62
63
  return v[k];
63
64
  });
64
65
  } else if (props.computed.get) {
65
- r = props.computed.get(r, v, props);
66
+ c = props.computed.get(r, v, props);
66
67
  }
68
+ if (prop) {
69
+ if (!isEqual(c, r)) {
70
+ if (props.pars) {
71
+ setObjValue(v, prop, c);
72
+ } else {
73
+ v[prop] = c;
74
+ }
75
+ }
76
+ }
77
+ r = c;
67
78
  }
68
79
  return r;
69
80
  },
@@ -117,4 +117,5 @@
117
117
  @use './tables/style/index2.scss' as *;
118
118
  @use './tablesp/style/index2.scss' as *;
119
119
  @use './tabless/style/index2.scss' as *;
120
- @use './tablesv/style/index2.scss' as *;
120
+ @use './tablesv/style/index2.scss' as *;
121
+ @use './tablesvp/style/index2.scss' as *;
@@ -9,6 +9,9 @@ const util = require("../../../utils/util.cjs");
9
9
  const objValue = require("@fangzhongya/utils/basic/object/objValue");
10
10
  const dataProps = {
11
11
  ...urls.props,
12
+ isValue: {
13
+ type: Boolean
14
+ },
12
15
  // 总表格的配置
13
16
  configs: {
14
17
  type: Object
@@ -478,7 +481,7 @@ const useInit = (props2, emit, refTable, getLocale, isEl) => {
478
481
  function getFrontPaginatValue(obj) {
479
482
  var _a2;
480
483
  if (paginat.is && paginat.front) {
481
- const list = obj.value;
484
+ const list = obj.value || [];
482
485
  const total = list.length;
483
486
  const c = paginat.current;
484
487
  const z = paginat.pageSize;
@@ -495,6 +498,39 @@ const useInit = (props2, emit, refTable, getLocale, isEl) => {
495
498
  obj.value = value;
496
499
  }
497
500
  }
501
+ function setData(dlist, total) {
502
+ var _a2;
503
+ if (dlist instanceof Array === false) {
504
+ dlist = [dlist];
505
+ }
506
+ if (((_a2 = tableConfig.value.paginat) == null ? void 0 : _a2.is) && dlist.length > paginat.pageSize) {
507
+ dlist = dlist.slice(0, paginat.pageSize);
508
+ }
509
+ if (paginat.current != 1 && paginat.scroll) {
510
+ data.list.push(...dlist);
511
+ } else {
512
+ data.list = defaultSort(dlist);
513
+ }
514
+ data.total = total || dlist.length;
515
+ toggleCrossPage();
516
+ }
517
+ function setValue() {
518
+ if (props2.isValue) {
519
+ vue.watch(
520
+ () => props2.value,
521
+ () => {
522
+ const obj = {
523
+ value: props2.value
524
+ };
525
+ getFrontPaginatValue(obj);
526
+ setData(obj.value);
527
+ },
528
+ {
529
+ immediate: true
530
+ }
531
+ );
532
+ }
533
+ }
498
534
  function getData(p = {}, callback) {
499
535
  var _a2, _b2;
500
536
  loading.value = true;
@@ -522,22 +558,9 @@ const useInit = (props2, emit, refTable, getLocale, isEl) => {
522
558
  ...p
523
559
  })
524
560
  ).then((list) => {
525
- var _a3;
526
561
  Object.assign(data, paginat);
527
562
  let dlist = (list == null ? void 0 : list.list) || [];
528
- if (dlist instanceof Array === false) {
529
- dlist = [dlist];
530
- }
531
- if (((_a3 = tableConfig.value.paginat) == null ? void 0 : _a3.is) && dlist.length > paginat.pageSize) {
532
- dlist = dlist.slice(0, paginat.pageSize);
533
- }
534
- if (paginat.current != 1 && paginat.scroll) {
535
- data.list.push(...dlist);
536
- } else {
537
- data.list = defaultSort(dlist);
538
- }
539
- data.total = (list == null ? void 0 : list.total) || dlist.length;
540
- toggleCrossPage();
563
+ setData(dlist, list == null ? void 0 : list.total);
541
564
  loading.value = false;
542
565
  if (callback) {
543
566
  callback(data);
@@ -614,6 +637,7 @@ const useInit = (props2, emit, refTable, getLocale, isEl) => {
614
637
  onChange: onScroll
615
638
  };
616
639
  });
640
+ setValue();
617
641
  return {
618
642
  height,
619
643
  tableConfig,
@@ -1,6 +1,9 @@
1
1
  import { Ref, Component, ExtractPropTypes, ComputedRef } from 'vue';
2
2
  import { Translator } from '../../types/locale';
3
3
  export declare const dataProps: {
4
+ isValue: {
5
+ type: BooleanConstructor;
6
+ };
4
7
  configs: {
5
8
  type: () => Config;
6
9
  };
@@ -7,6 +7,9 @@ import { executionMethod } from "../../../utils/util.js";
7
7
  import { setObjValue, getObjValue } from "@fangzhongya/utils/basic/object/objValue";
8
8
  const dataProps = {
9
9
  ...props,
10
+ isValue: {
11
+ type: Boolean
12
+ },
10
13
  // 总表格的配置
11
14
  configs: {
12
15
  type: Object
@@ -476,7 +479,7 @@ const useInit = (props2, emit, refTable, getLocale, isEl) => {
476
479
  function getFrontPaginatValue(obj) {
477
480
  var _a2;
478
481
  if (paginat.is && paginat.front) {
479
- const list = obj.value;
482
+ const list = obj.value || [];
480
483
  const total = list.length;
481
484
  const c = paginat.current;
482
485
  const z = paginat.pageSize;
@@ -493,6 +496,39 @@ const useInit = (props2, emit, refTable, getLocale, isEl) => {
493
496
  obj.value = value;
494
497
  }
495
498
  }
499
+ function setData(dlist, total) {
500
+ var _a2;
501
+ if (dlist instanceof Array === false) {
502
+ dlist = [dlist];
503
+ }
504
+ if (((_a2 = tableConfig.value.paginat) == null ? void 0 : _a2.is) && dlist.length > paginat.pageSize) {
505
+ dlist = dlist.slice(0, paginat.pageSize);
506
+ }
507
+ if (paginat.current != 1 && paginat.scroll) {
508
+ data.list.push(...dlist);
509
+ } else {
510
+ data.list = defaultSort(dlist);
511
+ }
512
+ data.total = total || dlist.length;
513
+ toggleCrossPage();
514
+ }
515
+ function setValue() {
516
+ if (props2.isValue) {
517
+ watch(
518
+ () => props2.value,
519
+ () => {
520
+ const obj = {
521
+ value: props2.value
522
+ };
523
+ getFrontPaginatValue(obj);
524
+ setData(obj.value);
525
+ },
526
+ {
527
+ immediate: true
528
+ }
529
+ );
530
+ }
531
+ }
496
532
  function getData(p = {}, callback) {
497
533
  var _a2, _b2;
498
534
  loading.value = true;
@@ -520,22 +556,9 @@ const useInit = (props2, emit, refTable, getLocale, isEl) => {
520
556
  ...p
521
557
  })
522
558
  ).then((list) => {
523
- var _a3;
524
559
  Object.assign(data, paginat);
525
560
  let dlist = (list == null ? void 0 : list.list) || [];
526
- if (dlist instanceof Array === false) {
527
- dlist = [dlist];
528
- }
529
- if (((_a3 = tableConfig.value.paginat) == null ? void 0 : _a3.is) && dlist.length > paginat.pageSize) {
530
- dlist = dlist.slice(0, paginat.pageSize);
531
- }
532
- if (paginat.current != 1 && paginat.scroll) {
533
- data.list.push(...dlist);
534
- } else {
535
- data.list = defaultSort(dlist);
536
- }
537
- data.total = (list == null ? void 0 : list.total) || dlist.length;
538
- toggleCrossPage();
561
+ setData(dlist, list == null ? void 0 : list.total);
539
562
  loading.value = false;
540
563
  if (callback) {
541
564
  callback(data);
@@ -612,6 +635,7 @@ const useInit = (props2, emit, refTable, getLocale, isEl) => {
612
635
  onChange: onScroll
613
636
  };
614
637
  });
638
+ setValue();
615
639
  return {
616
640
  height,
617
641
  tableConfig,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "prefix": "fang-ui",
3
3
  "info": {},
4
- "lastModified": 1762745359297,
4
+ "lastModified": 1762769052882,
5
5
  "icons": {
6
6
  "bar": {
7
7
  "body": " <path fill=\"currentColor\" d=\"M128 544h768a32 32 0 1 0 0-64H128a32 32 0 0 0 0 64z\" ></path> "
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fangzhongya/fang-ui",
3
3
  "private": false,
4
- "version": "0.1.16",
4
+ "version": "0.1.18",
5
5
  "type": "module",
6
6
  "description ": "fang-ui",
7
7
  "keywords": [
@@ -24,7 +24,7 @@
24
24
  "fangui": "bin/fang-ui.js"
25
25
  },
26
26
  "dependencies": {
27
- "@fangzhongya/utils": "0.0.45"
27
+ "@fangzhongya/utils": "0.0.46"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@fangzhongya/create": "0.2.41",
@@ -48,15 +48,15 @@
48
48
  "vue": "^3.5.24",
49
49
  "vue-tsc": "^3.1.3",
50
50
  "vuedraggable": "4.1.0",
51
- "vxe-table": "4.17.12",
52
- "@fang-ui/icons": "0.0.1-0",
51
+ "vxe-table": "4.17.13",
52
+ "@fang-ui/hooks": "0.0.1-0",
53
53
  "@fang-ui/components": "0.0.1-0",
54
- "@fang-ui/directives": "0.0.1-0",
55
54
  "@fang-ui/locale": "0.0.1-0",
56
- "@fang-ui/hooks": "0.0.1-0",
57
- "@fang-ui/types": "0.0.1-0",
55
+ "@fang-ui/icons": "0.0.1-0",
58
56
  "@fang-ui/utils": "0.0.1-0",
59
- "@fang-ui/theme": "0.0.1-0"
57
+ "@fang-ui/directives": "0.0.1-0",
58
+ "@fang-ui/theme": "0.0.1-0",
59
+ "@fang-ui/types": "0.0.1-0"
60
60
  },
61
61
  "main": "./dist/index.cjs",
62
62
  "module": "./dist/index.js",