@dt-frames/ui 1.0.44 → 1.0.46

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.
@@ -28,8 +28,8 @@
28
28
  "MULTIFY": "Batch",
29
29
  "DELETE_SUCCESS": "Successfully Deleted!",
30
30
  "COLUMN_CONTROL": "Column Control",
31
- "COLUMN_SHOW": "Column Display",
32
- "INDEX": "Serial Number",
31
+ "COLUMN_SHOW": "All",
32
+ "INDEX": "Index",
33
33
  "CHECKBOX": "Checkbox",
34
34
  "FIXED_TO_LEFT": "Fixed to the Left",
35
35
  "FIXED_TO_RIGHT": "Fixed to the Right",
@@ -6,7 +6,7 @@ export declare function useCurd(curdOpt: CrudOptType): {
6
6
  }>;
7
7
  add: () => void;
8
8
  del: ({ row }: Recordable) => void;
9
- dels: (ids: string[], cb: Function) => void;
9
+ dels: (ids?: string[]) => void;
10
10
  update: ({ row }: Recordable) => void;
11
11
  closeModal: () => void;
12
12
  openModal: (data?: {
@@ -3,7 +3,7 @@ import { ComputedRef, VNodeChild } from "vue";
3
3
  import { FormSchema, FormProps } from "../../../forms/src/types/form.type";
4
4
  export declare type CrudOptType = {
5
5
  t?: string;
6
- title?: string | ComputedRef;
6
+ title?: string | ComputedRef | Function;
7
7
  width?: string | number;
8
8
  schemas: FormSchema[];
9
9
  footer?: VNodeChild | JSX.Element | ButtonProps[];
@@ -4,5 +4,5 @@ import { ComputedRef } from 'vue';
4
4
  export declare function useDownload(exportUrl: string, exportName: string | ComputedRef): {
5
5
  download: (excelData: DownloadType & {
6
6
  params: Recordable;
7
- }) => void;
7
+ }, extraData?: any[]) => void;
8
8
  };
@@ -21,7 +21,7 @@ export declare function useSource(opt: SourceType): {
21
21
  total: number;
22
22
  }>;
23
23
  onTableChange: (params: TableParamsType, needSearch?: boolean) => void;
24
- onDownload: (excelData: DownloadType) => void;
24
+ onDownload: (excelData: DownloadType, extraData?: any[]) => void;
25
25
  loading: Ref<boolean>;
26
26
  };
27
27
  curd: {
@@ -38,6 +38,6 @@ export declare function useSource(opt: SourceType): {
38
38
  onDeletes: (ids: any) => void;
39
39
  onUpdate: (model: Recordable) => Promise<unknown>;
40
40
  onTableChange: (params: TableParamsType, needSearch?: boolean) => void;
41
- onDownload: (excelData: DownloadType) => void;
41
+ onDownload: (excelData: DownloadType, extraData?: any[]) => void;
42
42
  onSearch: (model?: Recordable) => void;
43
43
  };
@@ -21,6 +21,7 @@ export declare type ApiObjType = {
21
21
  export declare type SourceType = {
22
22
  baseUrl?: string;
23
23
  exportName?: string | ComputedRef;
24
+ clearKeys?: Function;
24
25
  api: ApiObjType;
25
26
  };
26
27
  export declare type BaseDataType = {
package/es/index.js CHANGED
@@ -5136,7 +5136,6 @@ function useDataSource(propsRef, {
5136
5136
  }, false);
5137
5137
  function updateTableDataRecord(rowKey, record) {
5138
5138
  const row = findTableDataRecord(rowKey);
5139
- console.log(row, record);
5140
5139
  if (row) {
5141
5140
  for (const field in record) {
5142
5141
  row[field] = record[field];
@@ -5270,7 +5269,7 @@ var _sfc_main$I = defineComponent({
5270
5269
  },
5271
5270
  setup(props) {
5272
5271
  let renderText = ref();
5273
- watch(() => props.record, (v) => {
5272
+ watch(() => [props.record, props.column], (v) => {
5274
5273
  if (v)
5275
5274
  renderCell();
5276
5275
  }, {
@@ -5545,7 +5544,7 @@ function handleIndexColumn(propsRef, getPaginationRef, columns) {
5545
5544
  const isFixedLeft = columns.some((item) => item.fixed === "left");
5546
5545
  columns.unshift({
5547
5546
  flag: INDEX_FLAG,
5548
- width: unref(getIsZH) ? 50 : 60,
5547
+ width: unref(getIsZH) ? 50 : 70,
5549
5548
  title: t("NUMBER"),
5550
5549
  align: "center",
5551
5550
  customRender: ({ index: index2 }) => {
@@ -5683,7 +5682,6 @@ function useColumns(propsRef, getPaginationRef, tableElRef) {
5683
5682
  return columns;
5684
5683
  }
5685
5684
  function setColumns(columnList = []) {
5686
- console.log(columnList);
5687
5685
  const columns = cloneDeep(columnList);
5688
5686
  if (!isArray$1(columns))
5689
5687
  return;
@@ -5887,7 +5885,6 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
5887
5885
  setColumns(columns);
5888
5886
  }
5889
5887
  function setColumns(columns) {
5890
- console.log(columns, "===");
5891
5888
  table.setColumns(columns);
5892
5889
  const data = unref(plainSortOptions).map((col) => {
5893
5890
  const visable = columns.findIndex((c) => c === col.value || typeof c !== "string" && c.dataIndex === col.value) !== -1;
@@ -6844,7 +6841,7 @@ function useFetch(api, baseUrl = "") {
6844
6841
  };
6845
6842
  }
6846
6843
  function useDownload(exportUrl, exportName) {
6847
- function download(excelData) {
6844
+ function download(excelData, extraData = []) {
6848
6845
  const { params: searchDTO, type, columns } = excelData;
6849
6846
  switch (type) {
6850
6847
  case "all":
@@ -6857,7 +6854,7 @@ function useDownload(exportUrl, exportName) {
6857
6854
  break;
6858
6855
  case "current":
6859
6856
  case "select":
6860
- handleDownloadPage(excelData, unref(exportName));
6857
+ handleDownloadPage(excelData, unref(exportName), extraData);
6861
6858
  break;
6862
6859
  }
6863
6860
  }
@@ -6883,7 +6880,7 @@ function useDownload(exportUrl, exportName) {
6883
6880
  return column;
6884
6881
  });
6885
6882
  }
6886
- function handleDownloadPage({ columns = [], rows = [] }, exportName2 = "") {
6883
+ function handleDownloadPage({ columns = [], rows = [] }, exportName2 = "", extraData = []) {
6887
6884
  const titles = columns.map((it) => it.title);
6888
6885
  const content = rows.reduce((total, it) => {
6889
6886
  const rowData = columns.map((column) => {
@@ -6913,7 +6910,7 @@ function useDownload(exportUrl, exportName) {
6913
6910
  total.push(rowData);
6914
6911
  return total;
6915
6912
  }, []);
6916
- export2Excel([titles].concat(content), exportName2);
6913
+ export2Excel([extraData, titles].concat(content), exportName2);
6917
6914
  }
6918
6915
  function export2Excel(data = [], exportName2 = "") {
6919
6916
  const worksheet = xlsx.utils.aoa_to_sheet(data);
@@ -6937,7 +6934,8 @@ function useSource(opt) {
6937
6934
  onSearch: ref(false),
6938
6935
  onReset: ref(false)
6939
6936
  };
6940
- const { baseUrl = "", api = {}, exportName = "" } = opt;
6937
+ const { baseUrl = "", api = {}, exportName = "", clearKeys = () => {
6938
+ } } = opt;
6941
6939
  const { add, deletes, update, queryById, queryPage } = api;
6942
6940
  const { message } = useMessage();
6943
6941
  const apiFul = {};
@@ -6973,12 +6971,14 @@ function useSource(opt) {
6973
6971
  baseData.entityDTO = { ...model };
6974
6972
  baseData.pageDTO.pageNo = 0;
6975
6973
  loading.onSearch.value = true;
6974
+ clearKeys();
6976
6975
  search();
6977
6976
  }
6978
6977
  function onReset(model) {
6979
6978
  baseData.entityDTO = { ...model };
6980
6979
  baseData.pageDTO.pageNo = 0;
6981
6980
  loading.onReset.value = true;
6981
+ clearKeys();
6982
6982
  search();
6983
6983
  }
6984
6984
  function onTableChange(params, needSearch = true) {
@@ -7023,15 +7023,17 @@ function useSource(opt) {
7023
7023
  });
7024
7024
  }
7025
7025
  function onAdd(model) {
7026
- if (!add)
7026
+ if (!add || loading.onAdd.value)
7027
7027
  return;
7028
7028
  const { fetch } = useFetch(add, baseUrl);
7029
+ loading.onAdd.value = true;
7029
7030
  let httpFetch = fetch(model, false);
7030
7031
  httpFetch.then((rsp) => {
7031
7032
  if ((rsp == null ? void 0 : rsp.code) === 0) {
7032
7033
  message.success(t("ADD_SUCCESS"));
7033
7034
  search();
7034
7035
  }
7036
+ loading.onAdd.value = false;
7035
7037
  });
7036
7038
  return httpFetch;
7037
7039
  }
@@ -7042,8 +7044,9 @@ function useSource(opt) {
7042
7044
  return await fetch({ id });
7043
7045
  }
7044
7046
  function onUpdate(model) {
7045
- if (!update)
7047
+ if (!update || loading.onUpdate.value)
7046
7048
  return;
7049
+ loading.onUpdate.value = true;
7047
7050
  const { fetch } = useFetch(update, baseUrl);
7048
7051
  let httpFetch = fetch(model, false);
7049
7052
  httpFetch.then((rsp) => {
@@ -7051,26 +7054,31 @@ function useSource(opt) {
7051
7054
  message.success(t("UPDATE_SUCCESS"));
7052
7055
  search();
7053
7056
  }
7057
+ loading.onUpdate.value = false;
7054
7058
  });
7055
7059
  return httpFetch;
7056
7060
  }
7057
7061
  function onDeletes(ids) {
7058
- if (!deletes)
7062
+ if (!deletes || loading.onDeletes.value)
7059
7063
  return;
7064
+ loading.onDeletes.value = true;
7060
7065
  const { fetch } = useFetch(deletes, baseUrl);
7061
7066
  fetch(toRaw(ids), false).then((rsp) => {
7062
7067
  if ((rsp == null ? void 0 : rsp.code) === 0) {
7063
7068
  message.success(`${ids.length > 1 ? t("MULTIFY") : ""} ${t("DELETE_SUCCESS")}`);
7069
+ if (ids.length > 1)
7070
+ clearKeys();
7064
7071
  search();
7065
7072
  }
7073
+ loading.onDeletes.value = false;
7066
7074
  });
7067
7075
  }
7068
7076
  const { download } = useDownload(apiFul.export, exportName);
7069
- function onDownload(excelData) {
7077
+ function onDownload(excelData, extraData = []) {
7070
7078
  download({
7071
7079
  ...excelData,
7072
7080
  params: baseData
7073
- });
7081
+ }, extraData);
7074
7082
  }
7075
7083
  const form = {
7076
7084
  onSearch,
@@ -7216,7 +7224,7 @@ function useCurd(curdOpt) {
7216
7224
  t
7217
7225
  } = useI18n("UI");
7218
7226
  const actType = ref(null);
7219
- const title = computed(() => unref(actType) + unref(curdOpt.title));
7227
+ const title = computed(() => isFunction(curdOpt.title) ? curdOpt.title() : unref(actType) + unref(curdOpt.title));
7220
7228
  const DtCurdModal = () => {
7221
7229
  return h(createVNode("div", {
7222
7230
  "class": "curdModal"
@@ -7267,7 +7275,7 @@ function useCurd(curdOpt) {
7267
7275
  nextTick(() => dispatchResize());
7268
7276
  });
7269
7277
  }
7270
- function dels(ids = [], cb) {
7278
+ function dels(ids = []) {
7271
7279
  if (!ids.length) {
7272
7280
  message.error(t("EMPTY"));
7273
7281
  return;
@@ -7282,7 +7290,6 @@ function useCurd(curdOpt) {
7282
7290
  iconType: "warning",
7283
7291
  onOk() {
7284
7292
  curd.onDeletes(ids);
7285
- cb();
7286
7293
  }
7287
7294
  });
7288
7295
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dt-frames/ui",
3
- "version": "1.0.44",
3
+ "version": "1.0.46",
4
4
  "keywords": [
5
5
  "ui",
6
6
  "dt-ui"