el-plus-crud 0.0.100 → 0.0.101

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 CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.101](https://github.com/KDJack/el-plus-crud/compare/v0.0.100...v0.0.101) (2023-11-22)
6
+
5
7
  ### [0.0.100](https://github.com/KDJack/el-plus-crud/compare/v0.0.99...v0.0.100) (2023-11-15)
6
8
 
7
9
  ### [0.0.99](https://github.com/KDJack/el-plus-crud/compare/v0.0.98...v0.0.99) (2023-11-13)
@@ -26,14 +26,14 @@ function ht(s) {
26
26
  case "validCode":
27
27
  case "tag":
28
28
  case "textarea":
29
- return { placeholder: (s == null ? void 0 : s.placeholder) || "请输入" + (s == null ? void 0 : s._label) };
29
+ return { placeholder: (s == null ? void 0 : s.placeholder) || "请输入" + ((s == null ? void 0 : s._label) || "") };
30
30
  case "switch":
31
31
  return {};
32
32
  case "area":
33
33
  case "select":
34
34
  case "category":
35
35
  case "cascader":
36
- return { placeholder: (s == null ? void 0 : s.placeholder) || "请选择" + (s.remote ? s.initLoad !== !1 ? "(默认查10个,其余请输入搜索)" : "或输入进行搜索" : s == null ? void 0 : s._label) };
36
+ return { placeholder: (s == null ? void 0 : s.placeholder) || "请选择" + (s.remote ? s.initLoad !== !1 ? "(默认查10个,其余请输入搜索)" : "或输入进行搜索" : (s == null ? void 0 : s._label) || "") };
37
37
  case "data":
38
38
  case "datetime":
39
39
  case "datas":
@@ -2357,7 +2357,8 @@ const st = /* @__PURE__ */ ze(_a, [["__scopeId", "data-v-a71c4b82"]]), va = /* @
2357
2357
  field: {},
2358
2358
  loading: { type: Boolean },
2359
2359
  desc: {},
2360
- formData: {}
2360
+ formData: {},
2361
+ rowIndex: {}
2361
2362
  },
2362
2363
  setup(s) {
2363
2364
  const t = s;
@@ -2383,7 +2384,7 @@ const st = /* @__PURE__ */ ze(_a, [["__scopeId", "data-v-a71c4b82"]]), va = /* @
2383
2384
  if (!t.desc.format)
2384
2385
  n.value = t.modelValue === "" ? t.desc.default ?? "-" : t.modelValue ?? t.desc.default ?? "-";
2385
2386
  else if (typeof t.desc.format == "function") {
2386
- const r = t.desc.format(t.modelValue, t.formData, t.field);
2387
+ const r = t.desc.format(t.modelValue, t.formData, t.rowIndex);
2387
2388
  n.value = Ze(r) ? await r : r;
2388
2389
  } else
2389
2390
  typeof t.desc.format == "string" ? n.value = l[t.desc.format] ? l[t.desc.format](t.modelValue, t.formData, t.field) : "--" : n.value = t.modelValue || "-";
@@ -2402,7 +2403,7 @@ const st = /* @__PURE__ */ ze(_a, [["__scopeId", "data-v-a71c4b82"]]), va = /* @
2402
2403
  ], 16));
2403
2404
  }
2404
2405
  });
2405
- const ut = /* @__PURE__ */ ze(Oa, [["__scopeId", "data-v-83245562"]]), Sa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: ut }, Symbol.toStringTag, { value: "Module" })), ka = {
2406
+ const ut = /* @__PURE__ */ ze(Oa, [["__scopeId", "data-v-3abef1f1"]]), Sa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: ut }, Symbol.toStringTag, { value: "Module" })), ka = {
2406
2407
  name: "ElPlusFormTextarea",
2407
2408
  inheritAttrs: !1,
2408
2409
  typeName: "textarea",
@@ -3008,7 +3009,7 @@ const $n = ["innerHTML"], Jn = {
3008
3009
  showReset: { type: Boolean, default: !0 },
3009
3010
  resetBtnText: { default: "重置" },
3010
3011
  showLabel: { type: Boolean, default: !0 },
3011
- labelWidth: { default: "" },
3012
+ labelWidth: { default: "auto" },
3012
3013
  disabled: { type: Boolean, default: !1 },
3013
3014
  isDialog: { type: Boolean, default: !1 },
3014
3015
  size: { default: "default" },
@@ -3024,7 +3025,7 @@ const $n = ["innerHTML"], Jn = {
3024
3025
  let j = null;
3025
3026
  const M = J(() => l.size || i.size), g = [..._t, ...((W = i.form) == null ? void 0 : W.comList) || []], b = J(() => ({ display: "flex", flexDirection: l.isTable ? "row" : "column" })), p = J(() => ({
3026
3027
  ...l.formAttrs,
3027
- _labelWidth: l.labelWidth === "auto" ? l.isDialog ? "100px" : "120px" : parseInt(l.labelWidth + "") + "px",
3028
+ _labelWidth: l.isTable ? "auto" : l.labelWidth === "auto" ? l.isDialog ? "100px" : "120px" : parseInt(l.labelWidth + "") + "px",
3028
3029
  // validateOnRuleChange: false,
3029
3030
  disabled: l.disabled || o.value,
3030
3031
  rules: f,
@@ -3723,20 +3724,19 @@ function ru(s) {
3723
3724
  function vt(s, t, e, l, i) {
3724
3725
  const u = [];
3725
3726
  return s && s.length > 0 && tl(s).map((n) => {
3726
- var r;
3727
- switch (n.children && (n.children = vt(n.children, t, e, l, i)), n.type || (n.type = "text"), n.type) {
3727
+ switch (n.children ? (n.headerAlign = n.headerAlign || "center", n.children = vt(n.children, t, e, "center", i)) : n.headerAlign = n.headerAlign || l || "left", n.type || (n.type = "text"), n.type) {
3728
3728
  case "image":
3729
3729
  n.width = n.width || "110px", n.align = n.align || "left", n.headerAlign = n.headerAlign || l || "left";
3730
3730
  break;
3731
3731
  case "btns":
3732
3732
  if (!n.minWidth && n.btns && n.btns.length >= 2) {
3733
- let a = 0;
3734
- n.btns.map((o) => a += typeof o.label == "string" ? o.label.length : 4), n.width = n.width || a * 24 + "px";
3733
+ let r = 0;
3734
+ n.btns.map((a) => r += typeof a.label == "string" ? a.label.length : 4), n.width = n.width || r * 24 + "px";
3735
3735
  }
3736
3736
  n.align = n.align || "left", n.headerAlign = n.headerAlign || l || "left", n.text = !0;
3737
3737
  break;
3738
3738
  }
3739
- n.minWidth = n.minWidth || (n.label !== "操作" ? i : "auto"), n.showOverflowTooltip = n.label !== "操作", Mu(n, t, e), (r = n.children) != null && r.length && (n.headerAlign = n.headerAlign || l || "center"), u.push(n);
3739
+ n.minWidth = n.minWidth || (n.label !== "操作" ? i : "auto"), n.showOverflowTooltip = n.label !== "操作", Mu(n, t, e), u.push(n);
3740
3740
  }), u;
3741
3741
  }
3742
3742
  function Mu(s, t, e) {
@@ -149,7 +149,7 @@ const props = withDefaults(defineProps<IFormProps>(), {
149
149
  // 是否显示标签
150
150
  showLabel: true,
151
151
  // 标签宽度
152
- labelWidth: '',
152
+ labelWidth: 'auto',
153
153
  // 全局禁用表单
154
154
  disabled: false,
155
155
  // 是否为弹窗
@@ -192,7 +192,7 @@ const formLayout = computed(() => ({ display: 'flex', flexDirection: props.isTab
192
192
  const computedFormAttrs = computed(() => {
193
193
  return {
194
194
  ...props.formAttrs,
195
- _labelWidth: props.labelWidth === 'auto' ? (props.isDialog ? '100px' : '120px') : parseInt(props.labelWidth + '') + 'px',
195
+ _labelWidth: props.isTable ? 'auto' : props.labelWidth === 'auto' ? (props.isDialog ? '100px' : '120px') : parseInt(props.labelWidth + '') + 'px',
196
196
  // validateOnRuleChange: false,
197
197
  disabled: props.disabled || innerIsLoading.value,
198
198
  rules: computedRules,
@@ -28,6 +28,7 @@ const props = defineProps<{
28
28
  loading?: boolean
29
29
  desc: { [key: string]: any }
30
30
  formData?: { [key: string]: any }
31
+ rowIndex?: number
31
32
  }>()
32
33
 
33
34
  // 有点击事件时,才inject
@@ -84,7 +85,7 @@ watch(
84
85
  } else {
85
86
  if (typeof props.desc.format === 'function') {
86
87
  // 如果有方法类型的判断,则需要启用动态监测
87
- const result = props.desc.format(props.modelValue, props.formData, props.field)
88
+ const result = props.desc.format(props.modelValue, props.formData, props.rowIndex)
88
89
  formatValue.value = isPromiseLike<any>(result) ? await result : result
89
90
  } else if (typeof props.desc.format === 'string') {
90
91
  formatValue.value = format[props.desc.format] ? format[props.desc.format](props.modelValue, props.formData, props.field) : '--'
@@ -78,14 +78,14 @@ function getPlaceholder(desc: { [key: string]: any }) {
78
78
  case 'validCode':
79
79
  case 'tag':
80
80
  case 'textarea':
81
- return { placeholder: desc?.placeholder || '请输入' + desc?._label }
81
+ return { placeholder: desc?.placeholder || '请输入' + (desc?._label || '') }
82
82
  case 'switch':
83
83
  return {}
84
84
  case 'area':
85
85
  case 'select':
86
86
  case 'category':
87
87
  case 'cascader':
88
- return { placeholder: desc?.placeholder || '请选择' + (desc.remote ? (desc.initLoad !== false ? '(默认查10个,其余请输入搜索)' : '或输入进行搜索') : desc?._label) }
88
+ return { placeholder: desc?.placeholder || '请选择' + (desc.remote ? (desc.initLoad !== false ? '(默认查10个,其余请输入搜索)' : '或输入进行搜索') : desc?._label || '') }
89
89
  case 'data':
90
90
  case 'datetime':
91
91
  case 'datas':
@@ -72,7 +72,12 @@ export function handelListColumn(columnList: Array<IColumnItem> | undefined, def
72
72
  cloneDeep(columnList).map((item: IColumnItem) => {
73
73
  // 如果有子集
74
74
  if (item.children) {
75
- item.children = handelListColumn(item.children, defaultConf, tbName, headerAlign, minWidth)
75
+ // 表头居中
76
+ item.headerAlign = item.headerAlign || 'center'
77
+ item.children = handelListColumn(item.children, defaultConf, tbName, 'center', minWidth)
78
+ } else {
79
+ // 表头居中
80
+ item.headerAlign = item.headerAlign || headerAlign || 'left'
76
81
  }
77
82
 
78
83
  // 处理下一个单元格显示多个数据
@@ -111,11 +116,6 @@ export function handelListColumn(columnList: Array<IColumnItem> | undefined, def
111
116
  // 处理vif
112
117
  handelVIf(item, defaultConf, tbName)
113
118
 
114
- // 表头居中
115
- if (item.children?.length) {
116
- item.headerAlign = item.headerAlign || headerAlign || 'center'
117
- }
118
-
119
119
  tempColumnList.push(item)
120
120
  })
121
121
  }
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "el-plus-crud",
3
- "version": "0.0.100",
3
+ "version": "0.0.101",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "el-plus-crud",
9
- "version": "0.0.100",
9
+ "version": "0.0.101",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@element-plus/icons-vue": "^2.1.0",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "el-plus-crud",
3
3
  "description": "采用Vue3 + TS,封装的element-plus数据驱动表单、列表组件",
4
4
  "author": "K.D.Jack",
5
- "version": "0.0.100",
5
+ "version": "0.0.101",
6
6
  "license": "MIT",
7
7
  "private": false,
8
8
  "main": "dist/el-plus-crud.mjs",