@vunk/form 2.14.6 → 2.14.8

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.
@@ -9,5 +9,9 @@ const KeyConfig = {
9
9
  function getToken() {
10
10
  return localStorage.getItem(KeyConfig.TokenKey) || "";
11
11
  }
12
+ function getTenant() {
13
+ return localStorage.getItem(KeyConfig.TenantKey) || "";
14
+ }
12
15
 
16
+ exports.getTenant = getTenant;
13
17
  exports.getToken = getToken;
@@ -7,5 +7,8 @@ const KeyConfig = {
7
7
  function getToken() {
8
8
  return localStorage.getItem(KeyConfig.TokenKey) || "";
9
9
  }
10
+ function getTenant() {
11
+ return localStorage.getItem(KeyConfig.TenantKey) || "";
12
+ }
10
13
 
11
- export { getToken as g };
14
+ export { getTenant as a, getToken as g };
@@ -54,6 +54,13 @@ const props = {
54
54
  keepLastRow: {
55
55
  type: Boolean,
56
56
  default: true
57
+ },
58
+ /**
59
+ * @description 顶部按钮添加元素的方式是 push 还是 unshift
60
+ */
61
+ buttonAdd: {
62
+ type: String,
63
+ default: "unshift"
57
64
  }
58
65
  };
59
66
  const emits = {
@@ -77,7 +84,13 @@ var _sfc_main$1 = /* @__PURE__ */vue.defineComponent({
77
84
  const formItemBindProps = formItem._VkfFormItemCtx.createBindProps(props);
78
85
  const readonly = composables.useComputedReadonly(props);
79
86
  const addToFirst = () => {
80
- emit("update:modelValue", [cloneDeep.cloneDeep(props.defaultItemValue), ...(props.modelValue ?? [])]);
87
+ const data = props.modelValue ? [...props.modelValue] : [];
88
+ if (props.buttonAdd === "push") {
89
+ data.push(cloneDeep.cloneDeep(props.defaultItemValue));
90
+ } else {
91
+ data.unshift(cloneDeep.cloneDeep(props.defaultItemValue));
92
+ }
93
+ emit("update:modelValue", data);
81
94
  };
82
95
  if (props.modelValue === void 0 && props.defaultModelValue) {
83
96
  emit("update:modelValue", props.defaultModelValue);
@@ -50,6 +50,13 @@ const props = {
50
50
  keepLastRow: {
51
51
  type: Boolean,
52
52
  default: true
53
+ },
54
+ /**
55
+ * @description 顶部按钮添加元素的方式是 push 还是 unshift
56
+ */
57
+ buttonAdd: {
58
+ type: String,
59
+ default: "unshift"
53
60
  }
54
61
  };
55
62
  const emits = {
@@ -73,7 +80,13 @@ var _sfc_main$1 = /* @__PURE__ */defineComponent({
73
80
  const formItemBindProps = _VkfFormItemCtx.createBindProps(props);
74
81
  const readonly = useComputedReadonly(props);
75
82
  const addToFirst = () => {
76
- emit("update:modelValue", [cloneDeep(props.defaultItemValue), ...(props.modelValue ?? [])]);
83
+ const data = props.modelValue ? [...props.modelValue] : [];
84
+ if (props.buttonAdd === "push") {
85
+ data.push(cloneDeep(props.defaultItemValue));
86
+ } else {
87
+ data.unshift(cloneDeep(props.defaultItemValue));
88
+ }
89
+ emit("update:modelValue", data);
77
90
  };
78
91
  if (props.modelValue === void 0 && props.defaultModelValue) {
79
92
  emit("update:modelValue", props.defaultModelValue);
@@ -34,6 +34,13 @@ export declare const props: {
34
34
  type: BooleanConstructor;
35
35
  default: boolean;
36
36
  };
37
+ /**
38
+ * @description 顶部按钮添加元素的方式是 push 还是 unshift
39
+ */
40
+ buttonAdd: {
41
+ type: PropType<"push" | "unshift">;
42
+ default: string;
43
+ };
37
44
  required: {
38
45
  readonly type: PropType<boolean>;
39
46
  readonly required: false;
@@ -36,6 +36,10 @@ declare const _default: import("vue").DefineComponent<{}, {
36
36
  type: BooleanConstructor;
37
37
  default: boolean;
38
38
  };
39
+ buttonAdd: {
40
+ type: import("vue").PropType<"push" | "unshift">;
41
+ default: string;
42
+ };
39
43
  required: {
40
44
  readonly type: import("vue").PropType<boolean>;
41
45
  readonly required: false;
@@ -152,6 +156,10 @@ declare const _default: import("vue").DefineComponent<{}, {
152
156
  type: BooleanConstructor;
153
157
  default: boolean;
154
158
  };
159
+ buttonAdd: {
160
+ type: import("vue").PropType<"push" | "unshift">;
161
+ default: string;
162
+ };
155
163
  required: {
156
164
  readonly type: import("vue").PropType<boolean>;
157
165
  readonly required: false;
@@ -749,6 +757,10 @@ declare const _default: import("vue").DefineComponent<{}, {
749
757
  type: BooleanConstructor;
750
758
  default: boolean;
751
759
  };
760
+ buttonAdd: {
761
+ type: import("vue").PropType<"push" | "unshift">;
762
+ default: string;
763
+ };
752
764
  required: {
753
765
  readonly type: import("vue").PropType<boolean>;
754
766
  readonly required: false;
@@ -862,6 +874,7 @@ declare const _default: import("vue").DefineComponent<{}, {
862
874
  defaultItemValue: any;
863
875
  source: Record<string, any>;
864
876
  keepLastRow: boolean;
877
+ buttonAdd: "push" | "unshift";
865
878
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
866
879
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
867
880
  export default _default;
@@ -25,6 +25,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
25
25
  type: BooleanConstructor;
26
26
  default: boolean;
27
27
  };
28
+ buttonAdd: {
29
+ type: import("vue").PropType<"push" | "unshift">;
30
+ default: string;
31
+ };
28
32
  required: {
29
33
  readonly type: import("vue").PropType<boolean>;
30
34
  readonly required: false;
@@ -141,6 +145,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
141
145
  type: BooleanConstructor;
142
146
  default: boolean;
143
147
  };
148
+ buttonAdd: {
149
+ type: import("vue").PropType<"push" | "unshift">;
150
+ default: string;
151
+ };
144
152
  required: {
145
153
  readonly type: import("vue").PropType<boolean>;
146
154
  readonly required: false;
@@ -738,6 +746,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
738
746
  type: BooleanConstructor;
739
747
  default: boolean;
740
748
  };
749
+ buttonAdd: {
750
+ type: import("vue").PropType<"push" | "unshift">;
751
+ default: string;
752
+ };
741
753
  required: {
742
754
  readonly type: import("vue").PropType<boolean>;
743
755
  readonly required: false;
@@ -851,5 +863,6 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
851
863
  defaultItemValue: any;
852
864
  source: Record<string, any>;
853
865
  keepLastRow: boolean;
866
+ buttonAdd: "push" | "unshift";
854
867
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
855
868
  export default _default;
@@ -18142,6 +18142,10 @@ const verify = async (data) => {
18142
18142
  data,
18143
18143
  setRequestInit(config) {
18144
18144
  setDefaultHeader(config);
18145
+ if (index.getTenant()) {
18146
+ const headers = config.headers;
18147
+ headers.set("Tenant", index.getTenant());
18148
+ }
18145
18149
  return config;
18146
18150
  }
18147
18151
  }).then((res) => {
@@ -18162,7 +18166,7 @@ const upload = async (data, fileServiceType, init) => {
18162
18166
  const xhr = new XMLHttpRequest();
18163
18167
  xhr.upload.onprogress = init?.onprogress || null;
18164
18168
  xhr.open("post", restFetch.baseURL + "/file/chunk/upload");
18165
- xhr.setRequestHeader("Tenant", "default");
18169
+ xhr.setRequestHeader("Tenant", index.getTenant() || "default");
18166
18170
  xhr.setRequestHeader("Application", "platform");
18167
18171
  xhr.setRequestHeader("Token", index.getToken());
18168
18172
  const form = new FormData();
@@ -18210,7 +18214,14 @@ const merge = async (data) => {
18210
18214
  method: "POST",
18211
18215
  url: "/file/chunk/merge",
18212
18216
  data,
18213
- setRequestInit: setDefaultHeader
18217
+ setRequestInit: (config) => {
18218
+ setDefaultHeader(config);
18219
+ if (index.getTenant()) {
18220
+ const headers = config.headers;
18221
+ headers.set("Tenant", index.getTenant());
18222
+ }
18223
+ return config;
18224
+ }
18214
18225
  }).then((res) => {
18215
18226
  if (res.code !== 200) {
18216
18227
  throw new Error(res.message);
@@ -5,7 +5,7 @@ import { createFileChunk, calculateFileHashSample } from '@vunk/form/shared/uplo
5
5
  import { RestFetch } from '@vunk/core/shared/utils-fetch';
6
6
  import '@vunk/core/shared/utils-promise';
7
7
  import { isPlainObject as isPlainObject$1 } from '@vunk/core/shared/utils-object';
8
- import { g as getToken } from '../index2.mjs';
8
+ import { g as getToken, a as getTenant } from '../index2.mjs';
9
9
  import { restFetch as restFetch$1 } from '@skzz/platform/shared/fetch/platform';
10
10
  import { l as success_filled_default, c as circle_close_filled_default, n as upload_filled_default } from '../index.mjs';
11
11
  import { useModelComputed } from '@vunk/core/composables';
@@ -18138,6 +18138,10 @@ const verify = async (data) => {
18138
18138
  data,
18139
18139
  setRequestInit(config) {
18140
18140
  setDefaultHeader(config);
18141
+ if (getTenant()) {
18142
+ const headers = config.headers;
18143
+ headers.set("Tenant", getTenant());
18144
+ }
18141
18145
  return config;
18142
18146
  }
18143
18147
  }).then((res) => {
@@ -18158,7 +18162,7 @@ const upload = async (data, fileServiceType, init) => {
18158
18162
  const xhr = new XMLHttpRequest();
18159
18163
  xhr.upload.onprogress = init?.onprogress || null;
18160
18164
  xhr.open("post", restFetch.baseURL + "/file/chunk/upload");
18161
- xhr.setRequestHeader("Tenant", "default");
18165
+ xhr.setRequestHeader("Tenant", getTenant() || "default");
18162
18166
  xhr.setRequestHeader("Application", "platform");
18163
18167
  xhr.setRequestHeader("Token", getToken());
18164
18168
  const form = new FormData();
@@ -18206,7 +18210,14 @@ const merge = async (data) => {
18206
18210
  method: "POST",
18207
18211
  url: "/file/chunk/merge",
18208
18212
  data,
18209
- setRequestInit: setDefaultHeader
18213
+ setRequestInit: (config) => {
18214
+ setDefaultHeader(config);
18215
+ if (getTenant()) {
18216
+ const headers = config.headers;
18217
+ headers.set("Tenant", getTenant());
18218
+ }
18219
+ return config;
18220
+ }
18210
18221
  }).then((res) => {
18211
18222
  if (res.code !== 200) {
18212
18223
  throw new Error(res.message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vunk/form",
3
- "version": "2.14.6",
3
+ "version": "2.14.8",
4
4
  "description": "",
5
5
  "main": "index.esm.js",
6
6
  "scripts": {