@hzab/data-model 1.7.4 → 1.7.6
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.
- package/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/src/array-data-model.js +25 -12
- package/src/public-utils.js +15 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/array-data-model.js
CHANGED
|
@@ -2,7 +2,10 @@ import _ from "lodash";
|
|
|
2
2
|
|
|
3
3
|
import { objToFormData, formDataToObj, _$Temp } from "./utils";
|
|
4
4
|
import ArrayUtils, { STATE_CODE } from "./ArrayUtils";
|
|
5
|
-
|
|
5
|
+
const errMsg = {
|
|
6
|
+
404: "未找到对应子项",
|
|
7
|
+
501: "未传入表单id",
|
|
8
|
+
};
|
|
6
9
|
/**
|
|
7
10
|
* ArrayDataModel 本地数据 DataModel
|
|
8
11
|
*/
|
|
@@ -172,11 +175,14 @@ class ArrayDataModel extends ArrayUtils {
|
|
|
172
175
|
if (res === STATE_CODE.SUC) {
|
|
173
176
|
let _res = {};
|
|
174
177
|
if (this.createResMap) {
|
|
175
|
-
_res = this.createResMap();
|
|
178
|
+
_res = this.createResMap(res);
|
|
176
179
|
}
|
|
177
180
|
resolve(_res);
|
|
178
181
|
} else {
|
|
179
|
-
reject(
|
|
182
|
+
reject({
|
|
183
|
+
code: res,
|
|
184
|
+
_message: errMsg[res] || "未知错误",
|
|
185
|
+
});
|
|
180
186
|
}
|
|
181
187
|
});
|
|
182
188
|
}
|
|
@@ -193,11 +199,14 @@ class ArrayDataModel extends ArrayUtils {
|
|
|
193
199
|
if (res === STATE_CODE.SUC) {
|
|
194
200
|
let _res = {};
|
|
195
201
|
if (this.updateResMap) {
|
|
196
|
-
_res = this.updateResMap();
|
|
202
|
+
_res = this.updateResMap(res);
|
|
197
203
|
}
|
|
198
204
|
resolve(_res);
|
|
199
205
|
} else {
|
|
200
|
-
reject(
|
|
206
|
+
reject({
|
|
207
|
+
code: res,
|
|
208
|
+
_message: errMsg[res] || "未知错误",
|
|
209
|
+
});
|
|
201
210
|
}
|
|
202
211
|
});
|
|
203
212
|
}
|
|
@@ -214,11 +223,14 @@ class ArrayDataModel extends ArrayUtils {
|
|
|
214
223
|
if (res === STATE_CODE.SUC) {
|
|
215
224
|
let _res = {};
|
|
216
225
|
if (this.patchResMap) {
|
|
217
|
-
_res = this.patchResMap();
|
|
226
|
+
_res = this.patchResMap(res);
|
|
218
227
|
}
|
|
219
228
|
resolve(_res);
|
|
220
229
|
} else {
|
|
221
|
-
reject(
|
|
230
|
+
reject({
|
|
231
|
+
code: res,
|
|
232
|
+
_message: errMsg[res] || "未知错误",
|
|
233
|
+
});
|
|
222
234
|
}
|
|
223
235
|
});
|
|
224
236
|
}
|
|
@@ -240,16 +252,17 @@ class ArrayDataModel extends ArrayUtils {
|
|
|
240
252
|
const { _idKey } = this;
|
|
241
253
|
const id = config[_idKey] || config.params?.[_idKey] || config.data?.[_idKey] || ctx[_idKey];
|
|
242
254
|
const res = this.delItem(id);
|
|
243
|
-
console.log("res", res);
|
|
244
|
-
|
|
245
255
|
if (res === STATE_CODE.SUC) {
|
|
246
256
|
let _res = {};
|
|
247
257
|
if (this.deleteResMap) {
|
|
248
|
-
_res = this.deleteResMap();
|
|
258
|
+
_res = this.deleteResMap(res);
|
|
249
259
|
}
|
|
250
260
|
resolve(_res);
|
|
251
261
|
} else {
|
|
252
|
-
reject(
|
|
262
|
+
reject({
|
|
263
|
+
code: res,
|
|
264
|
+
_message: errMsg[res] || "未知错误",
|
|
265
|
+
});
|
|
253
266
|
}
|
|
254
267
|
});
|
|
255
268
|
}
|
|
@@ -293,7 +306,7 @@ class ArrayDataModel extends ArrayUtils {
|
|
|
293
306
|
if (sucList.length > 0) {
|
|
294
307
|
let _res = { sucList, failList };
|
|
295
308
|
if (this.multipleDeleteResMap) {
|
|
296
|
-
_res = this.multipleDeleteResMap();
|
|
309
|
+
_res = this.multipleDeleteResMap(_res);
|
|
297
310
|
}
|
|
298
311
|
resolve(_res);
|
|
299
312
|
} else {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取 public 文件路径(自动拼接 hash 数据)
|
|
3
|
+
* @param {*} url 文件路径
|
|
4
|
+
* @param {*} opt
|
|
5
|
+
*/
|
|
6
|
+
export function getPublicUrl(url, opt) {
|
|
7
|
+
if (typeof url !== "string") {
|
|
8
|
+
return url;
|
|
9
|
+
}
|
|
10
|
+
let baseURL = (process.env.WEBPACK_PUBLIC_PATH || ".")?.replace(/^\//, "")?.replace(/\/$/, "");
|
|
11
|
+
return `${(baseURL.startsWith("http") ? "" : window.location.origin)?.replace(/\/$/, "")}/${baseURL}/${url?.replace(
|
|
12
|
+
/^\//,
|
|
13
|
+
"",
|
|
14
|
+
)}`;
|
|
15
|
+
}
|