szld-libs 0.3.81 → 0.3.83

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.
@@ -29,7 +29,7 @@ declare function useUniversalTable(): {
29
29
  formItems: import("szld-libs/lib/components/CreateForm").CreateFormItemProps<import("szld-libs/lib/components/CreateForm").ValueType>[];
30
30
  selList: any[];
31
31
  }>;
32
- handleUniversalDelete: ({ commonRequest, refresh, interfaceType, record, configData, title, okText, cancelText, getTitle, pageID, }: {
32
+ handleUniversalDelete: ({ commonRequest, refresh, interfaceType, record, configData, title, okText, cancelText, getTitle, pageID, deleteItem, }: {
33
33
  commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
34
34
  refresh: () => void;
35
35
  interfaceType?: string | undefined;
@@ -40,7 +40,8 @@ declare function useUniversalTable(): {
40
40
  cancelText?: string | undefined;
41
41
  getTitle?: ((pageID: string, dataID: string, defaultTitle?: string) => string) | undefined;
42
42
  pageID?: string | undefined;
43
- }) => void;
43
+ deleteItem?: Record<string, any> | undefined;
44
+ }) => Promise<void>;
44
45
  handleUniversalSearch: ({ values, currentSelList, currentActive, onSearch, tabItems, }: {
45
46
  values: any;
46
47
  currentSelList: any[];
@@ -205,7 +205,6 @@ function useUniversalTable() {
205
205
  formItemProps: { style: { marginBottom: 10, minWidth: 127 } }
206
206
  });
207
207
  }
208
- ;
209
208
  return { formItems, selList: selListData };
210
209
  } catch (error) {
211
210
  return { formItems: [], selList: [] };
@@ -307,7 +306,7 @@ function useUniversalTable() {
307
306
  return numA - numB;
308
307
  });
309
308
  };
310
- const handleUniversalDelete = ({
309
+ const handleUniversalDelete = async ({
311
310
  commonRequest,
312
311
  refresh,
313
312
  interfaceType = "YLFWLRInstanceDelete",
@@ -317,41 +316,59 @@ function useUniversalTable() {
317
316
  okText,
318
317
  cancelText,
319
318
  getTitle,
320
- pageID
319
+ pageID,
320
+ deleteItem
321
321
  }) => {
322
- const mustAttrid = (configData == null ? void 0 : configData["must-attrid"]) || [];
323
- const obj = {};
324
- for (const [key, value] of Object.entries(record)) {
325
- if (mustAttrid.includes(key)) {
326
- obj[key] = value;
327
- }
328
- }
329
- const params = {
330
- instanceid: record == null ? void 0 : record.instanceid,
331
- asid: record == null ? void 0 : record.asid,
332
- ...obj
333
- };
334
- modal.confirm({
335
- title: title || "",
336
- icon: null,
337
- okType: "danger",
338
- okText: okText || "",
339
- cancelText: cancelText || "",
340
- onOk: () => {
341
- return new Promise(async (resolve, reject) => {
342
- const res = await commonRequest(interfaceType, params);
343
- const msg = getTitle && getTitle(pageID || "", res == null ? void 0 : res["msg-code"], res == null ? void 0 : res.msg) || "删除失败";
344
- if ((res == null ? void 0 : res.ReturnValue) === 1) {
345
- message.success(msg);
346
- refresh();
347
- resolve(res);
348
- } else {
349
- message.error(msg || "删除失败");
350
- reject(res);
351
- }
322
+ var _a, _b;
323
+ try {
324
+ let mustAttrid = (configData == null ? void 0 : configData["must-attrid"]) || [];
325
+ const sourceNumber = (deleteItem == null ? void 0 : deleteItem["source-number"]) || "";
326
+ if (!(mustAttrid == null ? void 0 : mustAttrid.length) && sourceNumber) {
327
+ const res = await commonRequest("YLKHDSelPCParam", {
328
+ "source-number": Number(sourceNumber)
352
329
  });
330
+ if (res && res.ReturnValue === 1 && res.data) {
331
+ mustAttrid = ((_b = (_a = res.data) == null ? void 0 : _a["sourceNumber"]) == null ? void 0 : _b["must-attrid"]) || [];
332
+ }
353
333
  }
354
- });
334
+ if (!(mustAttrid == null ? void 0 : mustAttrid.length)) {
335
+ message.error("请先配置must-attrid");
336
+ return;
337
+ }
338
+ const obj = {};
339
+ for (const [key, value] of Object.entries(record)) {
340
+ if (mustAttrid.includes(key)) {
341
+ obj[key] = value;
342
+ }
343
+ }
344
+ const params = {
345
+ instanceid: record == null ? void 0 : record.instanceid,
346
+ asid: record == null ? void 0 : record.asid,
347
+ ...obj
348
+ };
349
+ modal.confirm({
350
+ title: title || (deleteItem == null ? void 0 : deleteItem["title"]) || "",
351
+ icon: null,
352
+ okType: "danger",
353
+ okText: okText || "",
354
+ cancelText: cancelText || "",
355
+ onOk: () => {
356
+ return new Promise(async (resolve, reject) => {
357
+ const res = await commonRequest(interfaceType, params);
358
+ const msg = getTitle && getTitle(pageID || "", res == null ? void 0 : res["msg-code"], res == null ? void 0 : res.msg) || "删除失败";
359
+ if ((res == null ? void 0 : res.ReturnValue) === 1) {
360
+ message.success(msg);
361
+ refresh();
362
+ resolve(res);
363
+ } else {
364
+ message.error(msg || "删除失败");
365
+ reject(res);
366
+ }
367
+ });
368
+ }
369
+ });
370
+ } catch (error) {
371
+ }
355
372
  };
356
373
  const handleUniversalSearch = ({
357
374
  values,
@@ -29,7 +29,7 @@ declare function useUniversalTable(): {
29
29
  formItems: import("szld-libs/lib/components/CreateForm").CreateFormItemProps<import("szld-libs/lib/components/CreateForm").ValueType>[];
30
30
  selList: any[];
31
31
  }>;
32
- handleUniversalDelete: ({ commonRequest, refresh, interfaceType, record, configData, title, okText, cancelText, getTitle, pageID, }: {
32
+ handleUniversalDelete: ({ commonRequest, refresh, interfaceType, record, configData, title, okText, cancelText, getTitle, pageID, deleteItem, }: {
33
33
  commonRequest: (InterfaceType: string, data?: any) => Promise<AxiosResponse<any, any>>;
34
34
  refresh: () => void;
35
35
  interfaceType?: string | undefined;
@@ -40,7 +40,8 @@ declare function useUniversalTable(): {
40
40
  cancelText?: string | undefined;
41
41
  getTitle?: ((pageID: string, dataID: string, defaultTitle?: string) => string) | undefined;
42
42
  pageID?: string | undefined;
43
- }) => void;
43
+ deleteItem?: Record<string, any> | undefined;
44
+ }) => Promise<void>;
44
45
  handleUniversalSearch: ({ values, currentSelList, currentActive, onSearch, tabItems, }: {
45
46
  values: any;
46
47
  currentSelList: any[];
@@ -206,7 +206,6 @@ function useUniversalTable() {
206
206
  formItemProps: { style: { marginBottom: 10, minWidth: 127 } }
207
207
  });
208
208
  }
209
- ;
210
209
  return { formItems, selList: selListData };
211
210
  } catch (error) {
212
211
  return { formItems: [], selList: [] };
@@ -308,7 +307,7 @@ function useUniversalTable() {
308
307
  return numA - numB;
309
308
  });
310
309
  };
311
- const handleUniversalDelete = ({
310
+ const handleUniversalDelete = async ({
312
311
  commonRequest,
313
312
  refresh,
314
313
  interfaceType = "YLFWLRInstanceDelete",
@@ -318,41 +317,59 @@ function useUniversalTable() {
318
317
  okText,
319
318
  cancelText,
320
319
  getTitle,
321
- pageID
320
+ pageID,
321
+ deleteItem
322
322
  }) => {
323
- const mustAttrid = (configData == null ? void 0 : configData["must-attrid"]) || [];
324
- const obj = {};
325
- for (const [key, value] of Object.entries(record)) {
326
- if (mustAttrid.includes(key)) {
327
- obj[key] = value;
328
- }
329
- }
330
- const params = {
331
- instanceid: record == null ? void 0 : record.instanceid,
332
- asid: record == null ? void 0 : record.asid,
333
- ...obj
334
- };
335
- modal.confirm({
336
- title: title || "",
337
- icon: null,
338
- okType: "danger",
339
- okText: okText || "",
340
- cancelText: cancelText || "",
341
- onOk: () => {
342
- return new Promise(async (resolve, reject) => {
343
- const res = await commonRequest(interfaceType, params);
344
- const msg = getTitle && getTitle(pageID || "", res == null ? void 0 : res["msg-code"], res == null ? void 0 : res.msg) || "删除失败";
345
- if ((res == null ? void 0 : res.ReturnValue) === 1) {
346
- message.success(msg);
347
- refresh();
348
- resolve(res);
349
- } else {
350
- message.error(msg || "删除失败");
351
- reject(res);
352
- }
323
+ var _a, _b;
324
+ try {
325
+ let mustAttrid = (configData == null ? void 0 : configData["must-attrid"]) || [];
326
+ const sourceNumber = (deleteItem == null ? void 0 : deleteItem["source-number"]) || "";
327
+ if (!(mustAttrid == null ? void 0 : mustAttrid.length) && sourceNumber) {
328
+ const res = await commonRequest("YLKHDSelPCParam", {
329
+ "source-number": Number(sourceNumber)
353
330
  });
331
+ if (res && res.ReturnValue === 1 && res.data) {
332
+ mustAttrid = ((_b = (_a = res.data) == null ? void 0 : _a["sourceNumber"]) == null ? void 0 : _b["must-attrid"]) || [];
333
+ }
354
334
  }
355
- });
335
+ if (!(mustAttrid == null ? void 0 : mustAttrid.length)) {
336
+ message.error("请先配置must-attrid");
337
+ return;
338
+ }
339
+ const obj = {};
340
+ for (const [key, value] of Object.entries(record)) {
341
+ if (mustAttrid.includes(key)) {
342
+ obj[key] = value;
343
+ }
344
+ }
345
+ const params = {
346
+ instanceid: record == null ? void 0 : record.instanceid,
347
+ asid: record == null ? void 0 : record.asid,
348
+ ...obj
349
+ };
350
+ modal.confirm({
351
+ title: title || (deleteItem == null ? void 0 : deleteItem["title"]) || "",
352
+ icon: null,
353
+ okType: "danger",
354
+ okText: okText || "",
355
+ cancelText: cancelText || "",
356
+ onOk: () => {
357
+ return new Promise(async (resolve, reject) => {
358
+ const res = await commonRequest(interfaceType, params);
359
+ const msg = getTitle && getTitle(pageID || "", res == null ? void 0 : res["msg-code"], res == null ? void 0 : res.msg) || "删除失败";
360
+ if ((res == null ? void 0 : res.ReturnValue) === 1) {
361
+ message.success(msg);
362
+ refresh();
363
+ resolve(res);
364
+ } else {
365
+ message.error(msg || "删除失败");
366
+ reject(res);
367
+ }
368
+ });
369
+ }
370
+ });
371
+ } catch (error) {
372
+ }
356
373
  };
357
374
  const handleUniversalSearch = ({
358
375
  values,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "szld-libs",
3
3
  "private": false,
4
- "version": "0.3.81",
4
+ "version": "0.3.83",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",