bm-admin-ui 1.0.54-alpha → 1.0.55-alpha

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.
@@ -1,5 +1,5 @@
1
1
  import { withInstall } from 'bm-admin-ui/es/utils/with-install';
2
- import { h, nextTick, defineComponent, ref, watch, openBlock, createElementBlock, createVNode, unref, computed, normalizeStyle, Fragment, renderList, normalizeClass, reactive, createBlock, withCtx, createTextVNode, createElementVNode, toDisplayString, createCommentVNode, inject, createStaticVNode, provide, resolveComponent } from 'vue';
2
+ import { h, nextTick, defineComponent, ref, watch, openBlock, createElementBlock, createVNode, unref, computed, normalizeStyle, Fragment, renderList, normalizeClass, reactive, createBlock, withCtx, createTextVNode, createElementVNode, toDisplayString, createCommentVNode, createSlots, inject, createStaticVNode, provide, resolveComponent } from 'vue';
3
3
  import { Input, InputNumber, Select, DatePicker, RangePicker, message, Modal, Layout, LayoutSider, Tree, LayoutContent, Button, Row, Col, Pagination, FormItemRest, Divider, Tabs, TabPane, Cascader } from 'ant-design-vue';
4
4
  import dayjs from 'dayjs';
5
5
  import Picture from 'bm-admin-ui/es/components/upload';
@@ -8,6 +8,7 @@ import { BmTagsDisplay, BmFloatTable } from 'bm-admin-ui/es/components';
8
8
  import { SearchOutlined, CheckCircleFilled, PlusOutlined } from '@ant-design/icons-vue';
9
9
  import { cloneDeep, floor, debounce } from 'lodash-es';
10
10
  import customParseFormat from 'dayjs/plugin/customParseFormat';
11
+ import { isNull } from 'bm-admin-ui/es/utils/isNull';
11
12
 
12
13
  const fieldRatioMap = {
13
14
  '25%': 6,
@@ -811,6 +812,9 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
811
812
  function handleAdd() {
812
813
  visible.value = true;
813
814
  }
815
+ function getPopupContainer() {
816
+ return document.body;
817
+ }
814
818
  watch(
815
819
  () => props.defaultSelected,
816
820
  (val) => {
@@ -830,9 +834,12 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
830
834
  "onUpdate:list": _cache[0] || (_cache[0] = ($event) => selected.value = $event),
831
835
  "show-empty-btn": false,
832
836
  disabled: __props.disabled,
837
+ "tool-tip-props": {
838
+ getPopupContainer
839
+ },
833
840
  "show-empty": "",
834
841
  onAddClick: handleAdd
835
- }, null, 8, ["list", "disabled"]),
842
+ }, null, 8, ["list", "disabled", "tool-tip-props"]),
836
843
  createVNode(unref(BmStaffsSelector), {
837
844
  select: selected.value,
838
845
  "onUpdate:select": _cache[1] || (_cache[1] = ($event) => selected.value = $event),
@@ -1278,7 +1285,8 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
1278
1285
  "extraConfig",
1279
1286
  "disabled",
1280
1287
  "disabledTable",
1281
- "hidden"
1288
+ "hidden",
1289
+ "formCreateInject"
1282
1290
  ],
1283
1291
  emits: ["change"],
1284
1292
  setup(__props, { emit: emits }) {
@@ -1303,6 +1311,9 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
1303
1311
  const config = computed(() => ({
1304
1312
  columns: [...columns],
1305
1313
  data: [...data],
1314
+ columnConfig: {
1315
+ resizable: true
1316
+ },
1306
1317
  checkboxConfig: {
1307
1318
  trigger: "cell",
1308
1319
  checkMethod() {
@@ -1341,12 +1352,15 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
1341
1352
  return result;
1342
1353
  }, {}) || {}
1343
1354
  );
1355
+ const productInputSlots = reactive([]);
1356
+ const formData = computed(() => props.formCreateInject.api.bind());
1344
1357
  function isShow(key) {
1345
1358
  return props.rule.config.tableAdvancedFeatures.includes(key);
1346
1359
  }
1347
1360
  function initConfig() {
1348
1361
  columns.splice(0, columns.length);
1349
1362
  data.splice(0, data.length);
1363
+ productInputSlots.splice(0, productInputSlots.length);
1350
1364
  const childRules = cloneDeep(props.rule.config.childRules);
1351
1365
  const value = props.rule.value;
1352
1366
  if (deleteFeature.value && !props.hidden) {
@@ -1400,6 +1414,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
1400
1414
  const productName = `\u5546\u54C1${String(++productIndex).padStart(2, "0")}`;
1401
1415
  const field = rule.field;
1402
1416
  const associatedFields = rule.config.associatedFields;
1417
+ productInputSlots.push(rule);
1403
1418
  const columns2 = [
1404
1419
  {
1405
1420
  field,
@@ -1407,19 +1422,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
1407
1422
  headerClassName: rule.effect.required ? "is-required" : "",
1408
1423
  minWidth: "138px",
1409
1424
  slots: {
1410
- default({ row }) {
1411
- return h(Input, {
1412
- value: row[field],
1413
- placeholder: "\u8BF7\u8F93\u5165",
1414
- disabled: rule.disabled,
1415
- "onUpdate:value": (value) => {
1416
- row[field] = value;
1417
- },
1418
- onPressEnter() {
1419
- queryProductInfo(rule, row);
1420
- }
1421
- });
1422
- }
1425
+ default: rule.field
1423
1426
  }
1424
1427
  }
1425
1428
  ];
@@ -1495,9 +1498,9 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
1495
1498
  const field = rule.field;
1496
1499
  const associatedFields = rule?.config?.associatedFields;
1497
1500
  return await props.extraConfig.product.fetch({ productCode: row[field] }).then((data2) => {
1498
- if (data2 && associatedFields.length)
1501
+ if (associatedFields.length)
1499
1502
  associatedFields.forEach((item) => {
1500
- row[field + item.value] = data2[productInfoKeyMap[item.value]];
1503
+ row[field + item.value] = data2 ? data2[productInfoKeyMap[item.value]] : void 0;
1501
1504
  });
1502
1505
  return data2;
1503
1506
  });
@@ -1655,6 +1658,18 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
1655
1658
  return Promise.resolve(rowData);
1656
1659
  }
1657
1660
  }
1661
+ function pruductInputDisabled(shopField) {
1662
+ if (!shopField)
1663
+ return false;
1664
+ return !formData.value[shopField];
1665
+ }
1666
+ function handlePressEnter(rule, row) {
1667
+ queryProductInfo(rule, row).then((data2) => {
1668
+ if (!data2) {
1669
+ row[rule.field] = "";
1670
+ }
1671
+ });
1672
+ }
1658
1673
  watch(
1659
1674
  () => props.rule,
1660
1675
  () => {
@@ -1737,7 +1752,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
1737
1752
  ref_key: "bmFloatTableRef",
1738
1753
  ref: bmFloatTableRef,
1739
1754
  config: unref(config)
1740
- }, {
1755
+ }, createSlots({
1741
1756
  floatHandle: withCtx(({ row, rowIndex }) => [
1742
1757
  unref(copyFeature) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
1743
1758
  createVNode(unref(Button), {
@@ -1765,8 +1780,23 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
1765
1780
  _: 2
1766
1781
  }, 1032, ["disabled", "onClick"])
1767
1782
  ]),
1768
- _: 1
1769
- }, 8, ["config"])
1783
+ _: 2
1784
+ }, [
1785
+ renderList(productInputSlots, (item) => {
1786
+ return {
1787
+ name: item.field,
1788
+ fn: withCtx(({ row }) => [
1789
+ createVNode(unref(Input), {
1790
+ value: row[item.field],
1791
+ "onUpdate:value": ($event) => row[item.field] = $event,
1792
+ placeholder: "\u8BF7\u8F93\u5165",
1793
+ disabled: item.disabled || pruductInputDisabled(item.config?.dataFiltering),
1794
+ onPressEnter: ($event) => handlePressEnter(item, row)
1795
+ }, null, 8, ["value", "onUpdate:value", "disabled", "onPressEnter"])
1796
+ ])
1797
+ };
1798
+ })
1799
+ ]), 1032, ["config"])
1770
1800
  ]),
1771
1801
  _: 1
1772
1802
  })
@@ -1971,7 +2001,8 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
1971
2001
  return void 0;
1972
2002
  }
1973
2003
  function handleTableDataChange(value) {
1974
- getAcitvePane().tableData = value;
2004
+ const activePane2 = getAcitvePane();
2005
+ activePane2.tableData = value;
1975
2006
  }
1976
2007
  function emitChange() {
1977
2008
  emits("change", {
@@ -1982,7 +2013,8 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
1982
2013
  tempIdSelected: pane.tempSelected.templateCode || pane.tempIdSelected,
1983
2014
  templateName: pane.tempSelected?.templateName || pane.templateName,
1984
2015
  tableData: pane.tableData,
1985
- uploadList: pane.uploadList
2016
+ uploadList: pane.uploadList,
2017
+ tableRequiredFields: pane.tableRule?.config?.childRules?.filter((rule) => rule.effect?.required).map((rule) => rule.field)
1986
2018
  }))
1987
2019
  });
1988
2020
  }
@@ -2320,6 +2352,30 @@ var materialTemp = {
2320
2352
  inject.self.value = value;
2321
2353
  },
2322
2354
  },
2355
+ validate: [
2356
+ {
2357
+ validator(rule, value) {
2358
+ if (isNull(value)) {
2359
+ return Promise.reject();
2360
+ }
2361
+ const panes = value.panes;
2362
+ for (const pane of panes) {
2363
+ if (!pane.tempIdSelected) {
2364
+ return Promise.reject();
2365
+ }
2366
+ if (pane.tableRequiredFields) {
2367
+ for (const field of pane.tableRequiredFields) {
2368
+ if (pane.tableData.some((row) => isNull(row[field]))) {
2369
+ return Promise.reject();
2370
+ }
2371
+ }
2372
+ }
2373
+ }
2374
+ return Promise.resolve();
2375
+ },
2376
+ message: '请检查必填项',
2377
+ },
2378
+ ],
2323
2379
  },
2324
2380
  ],
2325
2381
  class: 'bm-fc-module-widget',
@@ -2337,7 +2393,8 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
2337
2393
  "required",
2338
2394
  "extraConfig",
2339
2395
  "defalutValue",
2340
- "disabled"
2396
+ "disabled",
2397
+ "formCreateInject"
2341
2398
  ],
2342
2399
  emits: ["change"],
2343
2400
  setup(__props, { emit: emits }) {
@@ -2352,8 +2409,9 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
2352
2409
  \u5546\u54C1\u5355\u4F4D: "unit"
2353
2410
  };
2354
2411
  const unitMap = ["\u652F", "\u74F6", "\u5957", "\u7EC4", "\u7BB1", "\u4E2A", "\u5F20"];
2412
+ const formData = computed(() => props.formCreateInject.api.bind());
2355
2413
  async function fetch(value) {
2356
- productInfo.value = await props.extraConfig.fetch({
2414
+ productInfo.value = await props.extraConfig.product.fetch({
2357
2415
  productCode: value,
2358
2416
  filterByShopcode: props.dataFiltering
2359
2417
  }) || {};
@@ -2369,6 +2427,9 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
2369
2427
  function emitChange(value) {
2370
2428
  emits("change", value);
2371
2429
  }
2430
+ function inputDisbale(shopField) {
2431
+ return shopField && !formData.value[shopField];
2432
+ }
2372
2433
  watch(
2373
2434
  () => props.defalutValue,
2374
2435
  (val) => {
@@ -2401,7 +2462,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
2401
2462
  createVNode(unref(Input), {
2402
2463
  placeholder: "\u8BF7\u8F93\u5165",
2403
2464
  value: __props.defalutValue,
2404
- disabled: __props.disabled,
2465
+ disabled: __props.disabled || inputDisbale(__props.dataFiltering),
2405
2466
  onPressEnter: handleBlur
2406
2467
  }, null, 8, ["value", "disabled"])
2407
2468
  ]),
@@ -2435,7 +2496,8 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
2435
2496
  getValue(field.value) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2436
2497
  field.value === "\u5546\u54C1\u56FE\u7247" ? (openBlock(), createElementBlock("img", {
2437
2498
  key: 0,
2438
- src: getValue(field.value)
2499
+ class: "bm-fc-form-item__img",
2500
+ src: __props.extraConfig.common.previewImg(getValue(field.value))
2439
2501
  }, null, 8, _hoisted_2$2)) : field.value === "\u5546\u54C1\u5355\u4F4D" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
2440
2502
  createTextVNode(toDisplayString(unitMap[getValue(field.value)]), 1)
2441
2503
  ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 2 }, [
@@ -2476,7 +2538,7 @@ var product = {
2476
2538
  required: data.effect.required,
2477
2539
  associatedFields: data.config.associatedFields,
2478
2540
  dataFiltering: data.config.dataFiltering,
2479
- extraConfig: extraConfig.product,
2541
+ extraConfig: extraConfig,
2480
2542
  defalutValue: data.value,
2481
2543
  },
2482
2544
  inject: true,
@@ -2490,7 +2552,7 @@ var product = {
2490
2552
  },
2491
2553
  };
2492
2554
  },
2493
- rowRule(data) {
2555
+ rowRule(data, extraConfig) {
2494
2556
  return {
2495
2557
  type: 'ProductInfo',
2496
2558
  component: ProductInfo,
@@ -2503,6 +2565,7 @@ var product = {
2503
2565
  associatedFields: data.config.associatedFields,
2504
2566
  dataFiltering: data.config.dataFiltering,
2505
2567
  defalutValue: data.value,
2568
+ extraConfig: extraConfig,
2506
2569
  },
2507
2570
  inject: true,
2508
2571
  on: {
@@ -3030,6 +3093,20 @@ var department = {
3030
3093
  },
3031
3094
  };
3032
3095
 
3096
+ function validator(rule, value) {
3097
+ var _a;
3098
+ const childRules = ((_a = rule.config) === null || _a === void 0 ? void 0 : _a.childRules) || [];
3099
+ const requiredRules = childRules.filter((rule) => { var _a; return (_a = rule === null || rule === void 0 ? void 0 : rule.effect) === null || _a === void 0 ? void 0 : _a.required; });
3100
+ if (requiredRules.length && isNull(value)) {
3101
+ return Promise.reject();
3102
+ }
3103
+ for (const rule of requiredRules) {
3104
+ if (value.some((item) => isNull(item[rule.field]))) {
3105
+ return Promise.reject();
3106
+ }
3107
+ }
3108
+ return Promise.resolve();
3109
+ }
3033
3110
  var table = {
3034
3111
  name: 'table',
3035
3112
  rule(data, extraConfig) {
@@ -3044,9 +3121,19 @@ var table = {
3044
3121
  inject: true,
3045
3122
  on: {
3046
3123
  change(inject, value) {
3047
- inject.self.value = value;
3124
+ const rule = inject.self;
3125
+ rule.value = value;
3126
+ inject.api.emit('table-change', inject.api.bind());
3048
3127
  },
3049
3128
  },
3129
+ validate: [
3130
+ {
3131
+ validator(rule, value) {
3132
+ return validator(data, value);
3133
+ },
3134
+ message: '请检查必填项',
3135
+ },
3136
+ ],
3050
3137
  };
3051
3138
  },
3052
3139
  rowRule(data, extraConfig) {
@@ -3062,8 +3149,17 @@ var table = {
3062
3149
  on: {
3063
3150
  change(inject, value) {
3064
3151
  inject.self.value = value;
3152
+ inject.api.emit('table-change', inject.api.bind());
3065
3153
  },
3066
3154
  },
3155
+ validate: [
3156
+ {
3157
+ validator(rule, value) {
3158
+ return validator(data, value);
3159
+ },
3160
+ message: '请检查必填项',
3161
+ },
3162
+ ],
3067
3163
  col: {
3068
3164
  span: 24,
3069
3165
  },
@@ -3384,7 +3480,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
3384
3480
  "model-value": __props.value,
3385
3481
  option,
3386
3482
  rule: rule.value,
3387
- "onUpdate:modelValue": handleValue
3483
+ "onUpdate:modelValue": handleValue,
3484
+ onTableChange: handleValue
3388
3485
  }, null, 8, ["api", "model-value", "rule"])
3389
3486
  ], 64);
3390
3487
  };
@@ -1354,6 +1354,7 @@ var date = {
1354
1354
  props: {
1355
1355
  placeholder: '请选择',
1356
1356
  format: 'YYYY-MM',
1357
+ valueFormat: 'YYYY-MM',
1357
1358
  },
1358
1359
  config: {
1359
1360
  propsFields: Object.values(fieldsMap$b),
@@ -1404,6 +1405,12 @@ var date = {
1404
1405
  },
1405
1406
  ],
1406
1407
  value: rule.props.format,
1408
+ inject: true,
1409
+ on: {
1410
+ change({ api, self }, format) {
1411
+ api.emit('props.valueFormat', format.value);
1412
+ },
1413
+ },
1407
1414
  },
1408
1415
  {
1409
1416
  type: 'input',
@@ -917,6 +917,7 @@ declare const BmStaffsSelector: import("bm-admin-ui/es/utils/with-install").SFCW
917
917
  }> | null | undefined)[]>;
918
918
  isFulfill: import("vue").Ref<boolean>;
919
919
  changeTreeCheck: (checkedKeys: any) => void;
920
+ departmentSelect: import("vue").Ref<never[]>;
920
921
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:selected" | "fetchList")[], "update:selected" | "fetchList", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
921
922
  limit: {
922
923
  type: NumberConstructor;
@@ -156,7 +156,9 @@ const _sfc_main$3 = defineComponent({
156
156
  },
157
157
  { deep: true }
158
158
  );
159
+ const departmentSelect = ref([]);
159
160
  function changeTreeCheck(checkedKeys) {
161
+ departmentSelect.value = checkedKeys;
160
162
  let flatMap = selectState.dataMap;
161
163
  let curlistKeys = selectState.curlistKeys;
162
164
  let hadselected = new Set(selectState.multipDepartment);
@@ -181,6 +183,7 @@ const _sfc_main$3 = defineComponent({
181
183
  }
182
184
  return {
183
185
  changeTreeCheck,
186
+ departmentSelect,
184
187
  ...toRefs(state),
185
188
  ...toRefs(selectState),
186
189
  list,
@@ -261,7 +264,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
261
264
  }), 128))
262
265
  ], 64)) : _ctx.isTree ? (openBlock(), createBlock(_component_ATree, {
263
266
  key: 1,
264
- "checked-keys": _ctx.multipDepartment,
267
+ "checked-keys": _ctx.departmentSelect,
265
268
  checkable: "",
266
269
  "tree-data": _ctx.list,
267
270
  onCheck: _ctx.changeTreeCheck
@@ -35,6 +35,7 @@ declare const _default: import("vue").DefineComponent<{
35
35
  }> | null | undefined)[]>;
36
36
  isFulfill: import("vue").Ref<boolean>;
37
37
  changeTreeCheck: (checkedKeys: any) => void;
38
+ departmentSelect: import("vue").Ref<never[]>;
38
39
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:selected" | "fetchList")[], "update:selected" | "fetchList", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
39
40
  limit: {
40
41
  type: NumberConstructor;
@@ -917,6 +917,7 @@ declare const _default: import("vue").DefineComponent<{
917
917
  }> | null | undefined)[]>;
918
918
  isFulfill: import("vue").Ref<boolean>;
919
919
  changeTreeCheck: (checkedKeys: any) => void;
920
+ departmentSelect: import("vue").Ref<never[]>;
920
921
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:selected" | "fetchList")[], "update:selected" | "fetchList", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
921
922
  limit: {
922
923
  type: NumberConstructor;
@@ -0,0 +1 @@
1
+ export declare function isNull(value: any): boolean;
@@ -0,0 +1,5 @@
1
+ export function isNull(value) {
2
+ return (!value ||
3
+ (Array.isArray(value) && !value.length) ||
4
+ (value.constructor === Object && !Object.keys(value).length));
5
+ }