@fmdeui/fmui 1.0.161 → 1.0.162

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! fmdeui-fmui v1.0.161 */
1
+ /*! fmdeui-fmui v1.0.162 */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vxe-table'), require('@vxe-ui/plugin-render-element'), require('@vxe-ui/plugin-export-xlsx'), require('vxe-pc-ui'), require('exceljs'), require('@element-plus/icons-vue'), require('vue'), require('element-plus'), require('lodash-es'), require('js-cookie'), require('pinia'), require('vue-router'), require('@vueuse/core'), require('crypto-js'), require('xlsx-js-style'), require('vue-i18n'), require('sortablejs'), require('screenfull'), require('push.js'), require('mitt'), require('@microsoft/signalr'), require('axios')) :
4
4
  typeof define === 'function' && define.amd ? define(['exports', 'vxe-table', '@vxe-ui/plugin-render-element', '@vxe-ui/plugin-export-xlsx', 'vxe-pc-ui', 'exceljs', '@element-plus/icons-vue', 'vue', 'element-plus', 'lodash-es', 'js-cookie', 'pinia', 'vue-router', '@vueuse/core', 'crypto-js', 'xlsx-js-style', 'vue-i18n', 'sortablejs', 'screenfull', 'push.js', 'mitt', '@microsoft/signalr', 'axios'], factory) :
@@ -23069,7 +23069,7 @@
23069
23069
  name: "FSelectTable"
23070
23070
  },
23071
23071
  __name: "index",
23072
- props: {
23072
+ props: /* @__PURE__ */ vue.mergeModels({
23073
23073
  modelValue: { default: void 0 },
23074
23074
  inputValue: { default: void 0 },
23075
23075
  defaultSelectVal: { default: () => [] },
@@ -23122,9 +23122,21 @@
23122
23122
  isExpanded: { type: Boolean, default: false },
23123
23123
  multipleDisableDelete: { type: Boolean, default: true },
23124
23124
  tableLoading: { type: Boolean, default: false },
23125
- loadingTxt: { default: "" }
23126
- },
23127
- emits: ["page-change", "selectionChange", "radioChange", "update:inputValue", "input-focus", "input-blur", "input-clear", "input-click"],
23125
+ loadingTxt: { default: "" },
23126
+ apiService: { default: void 0 },
23127
+ apiAction: { default: "" },
23128
+ queryParams: { default: () => ({}) },
23129
+ responseFormatter: { type: Function, default: (res) => ({
23130
+ data: res.result.items || [],
23131
+ total: res.result.total || 0
23132
+ }) }
23133
+ }, {
23134
+ "id": { default: 0, required: false },
23135
+ "idModifiers": {},
23136
+ "name": { default: "", required: false },
23137
+ "nameModifiers": {}
23138
+ }),
23139
+ emits: /* @__PURE__ */ vue.mergeModels(["page-change", "selectionChange", "radioChange", "update:inputValue", "input-focus", "input-blur", "input-clear", "input-click"], ["update:id", "update:name"]),
23128
23140
  setup(__props, { expose: __expose, emit: __emit }) {
23129
23141
  const { t } = useLocale();
23130
23142
  const {
@@ -23135,6 +23147,8 @@
23135
23147
  saveDATA,
23136
23148
  getItemHeightFromCache
23137
23149
  } = useVirtualized();
23150
+ const modeValueId = vue.useModel(__props, "id");
23151
+ const modeValueName = vue.useModel(__props, "name");
23138
23152
  const props = __props;
23139
23153
  const vClickOutside = ClickOutside;
23140
23154
  const emits = __emit;
@@ -23146,8 +23160,24 @@
23146
23160
  const isVisible = vue.ref(false);
23147
23161
  const radioVal = vue.ref("");
23148
23162
  const isShowFirstRadio = vue.ref(props.isShowFirstColumn);
23149
- const selectDefaultLabel = vue.ref(props.modelValue);
23163
+ const selectDefaultLabel = vue.ref(modeValueName.value);
23150
23164
  const scrollTopNum = vue.ref(0);
23165
+ const pagination = vue.reactive({
23166
+ currentPage: props.table.currentPage,
23167
+ pageSize: props.table.pageSize,
23168
+ total: props.table.total
23169
+ });
23170
+ vue.watch(
23171
+ () => props.table,
23172
+ (newVal) => {
23173
+ if (!props.apiService) {
23174
+ pagination.currentPage = newVal.currentPage;
23175
+ pagination.pageSize = newVal.pageSize;
23176
+ pagination.total = newVal.total;
23177
+ }
23178
+ },
23179
+ { deep: true }
23180
+ );
23151
23181
  let selectInputVal = vue.computed({
23152
23182
  get() {
23153
23183
  return props.inputValue;
@@ -23238,20 +23268,55 @@
23238
23268
  );
23239
23269
  vue.onMounted(() => {
23240
23270
  var _a;
23241
- if (state.defaultSelectValue && state.defaultSelectValue.length > 0 && isDefaultSelectVal.value) {
23242
- defaultSelect(state.defaultSelectValue);
23243
- }
23244
- if (props.selfExpanded) {
23245
- selectRef.value.expanded = true;
23246
- }
23247
- if (props.useVirtual) {
23248
- saveDATA.value = props.table.data;
23249
- isShowFirstRadio.value = false;
23250
- getDom(props);
23251
- (_a = scrollContainerEl.value) == null ? void 0 : _a.addEventListener("scroll", handleScroll);
23271
+ if (props.apiService) {
23272
+ fetchTableData();
23273
+ } else {
23274
+ if (state.defaultSelectValue && state.defaultSelectValue.length > 0 && isDefaultSelectVal.value) {
23275
+ defaultSelect(state.defaultSelectValue);
23276
+ }
23277
+ if (props.selfExpanded) {
23278
+ selectRef.value.expanded = true;
23279
+ }
23280
+ if (props.useVirtual) {
23281
+ saveDATA.value = props.table.data;
23282
+ isShowFirstRadio.value = false;
23283
+ getDom(props);
23284
+ (_a = scrollContainerEl.value) == null ? void 0 : _a.addEventListener("scroll", handleScroll);
23285
+ }
23286
+ if (props.radioSelectValLabel) findLabel();
23252
23287
  }
23253
- if (props.radioSelectValLabel) findLabel();
23254
23288
  });
23289
+ const internalLoading = vue.ref(false);
23290
+ const internalQueryParams = vue.reactive({ ...props.queryParams });
23291
+ const fetchTableData = async (isResetPage = false) => {
23292
+ if (!props.apiService) return;
23293
+ internalLoading.value = true;
23294
+ try {
23295
+ if (isResetPage) {
23296
+ pagination.currentPage = 1;
23297
+ }
23298
+ const requestParams = {
23299
+ currentPage: pagination.currentPage,
23300
+ pageSize: pagination.pageSize,
23301
+ ...internalQueryParams
23302
+ };
23303
+ const res = await useBaseApi(props.apiService).post(requestParams, props.apiAction);
23304
+ const formatted = props.responseFormatter(res);
23305
+ pagination.total = formatted.total;
23306
+ state.tableData = formatted.data;
23307
+ if (props.useVirtual) {
23308
+ saveDATA.value = formatted.data;
23309
+ updateRenderData(scrollTopNum.value);
23310
+ }
23311
+ if (state.defaultSelectValue && state.defaultSelectValue.length > 0 && isDefaultSelectVal.value) {
23312
+ defaultSelect(state.defaultSelectValue);
23313
+ }
23314
+ } catch (error) {
23315
+ console.error("FSelectTable API request failed:", error);
23316
+ } finally {
23317
+ internalLoading.value = false;
23318
+ }
23319
+ };
23255
23320
  const updateRenderData = (scrollTop) => {
23256
23321
  let startIndex = 0;
23257
23322
  let offsetHeight = 0;
@@ -23299,6 +23364,11 @@
23299
23364
  } else {
23300
23365
  if (fQueryConditionRef.value && props.isShowQuery && props.isClearQuery && !selectRef.value.expanded && !props.selfExpanded) {
23301
23366
  (_a = fQueryConditionRef.value) == null ? void 0 : _a.resetData();
23367
+ if (props.apiService) {
23368
+ Object.keys(internalQueryParams).forEach((key) => delete internalQueryParams[key]);
23369
+ Object.assign(internalQueryParams, props.queryParams);
23370
+ fetchTableData(true);
23371
+ }
23302
23372
  }
23303
23373
  findLabel();
23304
23374
  filterMethodHandle("");
@@ -23376,6 +23446,10 @@
23376
23446
  });
23377
23447
  };
23378
23448
  const handlesCurrentChange = (val) => {
23449
+ if (props.apiService) {
23450
+ fetchTableData();
23451
+ return;
23452
+ }
23379
23453
  if (props.multiple) {
23380
23454
  if (!props.reserveSelection) {
23381
23455
  clear();
@@ -23400,12 +23474,15 @@
23400
23474
  setTimeout(() => {
23401
23475
  var _a, _b;
23402
23476
  state.defaultValue = multipleList.map((item) => item[props.keywords.label]);
23477
+ state.ids = multipleList.map((item) => item[props.keywords.value]);
23403
23478
  multipleList.forEach((row) => {
23404
23479
  selectTable.value.toggleRowSelection(row, true);
23405
23480
  });
23406
23481
  (_b = (_a = selectRef.value) == null ? void 0 : _a.selected) == null ? void 0 : _b.forEach((item) => {
23407
23482
  item.currentLabel = item.value;
23408
23483
  });
23484
+ modeValueId.value = state.ids;
23485
+ modeValueName.value = state.defaultValue;
23409
23486
  }, 0);
23410
23487
  } else {
23411
23488
  setTimeout(() => {
@@ -23414,6 +23491,8 @@
23414
23491
  radioVal.value = state.tableData.indexOf(row) + 1;
23415
23492
  state.defaultValue = row;
23416
23493
  selectDefaultLabel.value = row[props.keywords.label];
23494
+ modeValueId.value = row[props.keywords.value];
23495
+ modeValueName.value = row[props.keywords.label];
23417
23496
  if (!props.defaultValIsOpenRadioChange) {
23418
23497
  emits("radioChange", row, row[props.keywords.value]);
23419
23498
  }
@@ -23430,6 +23509,10 @@
23430
23509
  state.defaultSelectValue = [];
23431
23510
  }
23432
23511
  emits("selectionChange", val, state.ids);
23512
+ if (props.multiple) {
23513
+ modeValueId.value = state.ids;
23514
+ modeValueName.value = state.defaultValue;
23515
+ }
23433
23516
  };
23434
23517
  const getRowClassName = ({ row }) => {
23435
23518
  if (!props.multiple && JSON.stringify(row) === JSON.stringify(state.defaultValue)) {
@@ -23554,6 +23637,8 @@
23554
23637
  radioVal.value = index;
23555
23638
  state.defaultValue = row;
23556
23639
  emits("radioChange", row, row[props.keywords.value]);
23640
+ modeValueId.value = row[props.keywords.value];
23641
+ modeValueName.value = row[props.keywords.label];
23557
23642
  };
23558
23643
  const rowClick = async (row) => {
23559
23644
  var _a;
@@ -23586,6 +23671,8 @@
23586
23671
  isDefaultSelectVal.value = true;
23587
23672
  state.defaultSelectValue = [];
23588
23673
  state.defaultValue = props.multiple ? [] : null;
23674
+ modeValueId.value = props.multiple ? [] : 0;
23675
+ modeValueName.value = props.multiple ? [] : "";
23589
23676
  };
23590
23677
  if (!selectTable.value) {
23591
23678
  console.warn("selectTable.value is not initialized");
@@ -23669,7 +23756,7 @@
23669
23756
  ref_key: "selectRef",
23670
23757
  ref: selectRef,
23671
23758
  "model-value": __props.multiple ? state.defaultValue : selectDefaultLabel.value,
23672
- "popper-class": "t-select-table",
23759
+ "popper-class": "f-select-table",
23673
23760
  style: { width: __props.selectWidth ? `${__props.selectWidth}px` : "100%" },
23674
23761
  "value-key": __props.keywords.value,
23675
23762
  "filter-method": __props.filterMethod || filterMethodHandle,
@@ -23849,18 +23936,18 @@
23849
23936
  }, 16, ["data", "class"]),
23850
23937
  __props.isShowPagination ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4$8, [
23851
23938
  vue.createVNode(_component_el_pagination, vue.mergeProps({
23852
- "current-page": __props.table.currentPage,
23853
- "onUpdate:currentPage": _cache[6] || (_cache[6] = ($event) => __props.table.currentPage = $event),
23854
- "page-size": __props.table.pageSize,
23855
- "onUpdate:pageSize": _cache[7] || (_cache[7] = ($event) => __props.table.pageSize = $event),
23939
+ "current-page": pagination.currentPage,
23940
+ "onUpdate:currentPage": _cache[6] || (_cache[6] = ($event) => pagination.currentPage = $event),
23941
+ "page-size": pagination.pageSize,
23942
+ "onUpdate:pageSize": _cache[7] || (_cache[7] = ($event) => pagination.pageSize = $event),
23856
23943
  onCurrentChange: handlesCurrentChange,
23857
23944
  layout: "total, prev, pager, next, jumper",
23858
23945
  "pager-count": __props.table["pager-count"] || 5,
23859
- total: __props.table.total
23946
+ total: pagination.total
23860
23947
  }, { background: true, size: __props.paginationSize || "small", ..._ctx.$attrs }), null, 16, ["current-page", "page-size", "pager-count", "total"])
23861
23948
  ])) : vue.createCommentVNode("v-if", true)
23862
23949
  ], 8, _hoisted_2$p)), [
23863
- [_directive_loading, __props.tableLoading]
23950
+ [_directive_loading, __props.tableLoading || internalLoading.value]
23864
23951
  ]),
23865
23952
  vue.renderSlot(_ctx.$slots, "footer")
23866
23953
  ],