@archbiz/element-ui 0.0.0-stage → 0.1.0

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.
Files changed (79) hide show
  1. package/dist/element-ui.cjs +12 -0
  2. package/dist/element-ui.js +5522 -0
  3. package/dist/style.css +1 -0
  4. package/package.json +49 -3
  5. package/src/components/ab-checkbox.vue +51 -0
  6. package/src/components/ab-color-picker.vue +39 -0
  7. package/src/components/ab-detail/ab-detail.vue +285 -0
  8. package/src/components/ab-detail/index.js +1 -0
  9. package/src/components/ab-drawer/ab-drawer.vue +50 -0
  10. package/src/components/ab-drawer/index.js +3 -0
  11. package/src/components/ab-icon/ab-icon.vue +90 -0
  12. package/src/components/ab-icon/index.js +1 -0
  13. package/src/components/ab-input-number.vue +49 -0
  14. package/src/components/ab-input-range.vue +90 -0
  15. package/src/components/ab-radio.vue +51 -0
  16. package/src/components/ab-router-link.vue +46 -0
  17. package/src/components/ab-search/ab-search.vue +168 -0
  18. package/src/components/ab-search/index.js +4 -0
  19. package/src/components/ab-select.vue +107 -0
  20. package/src/components/ab-table/ab-table-column.vue +131 -0
  21. package/src/components/ab-table/ab-table-columns.vue +62 -0
  22. package/src/components/ab-table/ab-table-operate.vue +160 -0
  23. package/src/components/ab-table/ab-table.vue +316 -0
  24. package/src/components/ab-table/columns.js +90 -0
  25. package/src/components/ab-table/footer.js +77 -0
  26. package/src/components/ab-table/formatter.js +2 -0
  27. package/src/components/ab-table/index.js +8 -0
  28. package/src/components/ab-table/utils.js +36 -0
  29. package/src/components/ab-time-period.vue +116 -0
  30. package/src/components/ab-time-picker.vue +38 -0
  31. package/src/components/ab-toolbar/ab-toolbar.vue +99 -0
  32. package/src/components/ab-toolbar/index.js +1 -0
  33. package/src/components/ab-tree-select.vue +456 -0
  34. package/src/components/ab-upload-file.vue +277 -0
  35. package/src/components/index.js +27 -0
  36. package/src/core/ab-form.js +25 -0
  37. package/src/core/alias.js +36 -0
  38. package/src/core/config.js +65 -0
  39. package/src/core/form-render.js +260 -0
  40. package/src/core/options.js +25 -0
  41. package/src/hooks/use-cache.js +75 -0
  42. package/src/index.js +39 -0
  43. package/src/makers/datePicker.js +8 -0
  44. package/src/makers/frame.js +23 -0
  45. package/src/makers/index.js +23 -0
  46. package/src/makers/input.js +12 -0
  47. package/src/makers/select.js +8 -0
  48. package/src/makers/slider.js +7 -0
  49. package/src/makers/timePicker.js +8 -0
  50. package/src/makers/tree.js +10 -0
  51. package/src/makers/upload.js +20 -0
  52. package/src/parsers/checkbox.js +5 -0
  53. package/src/parsers/colorPicker.js +29 -0
  54. package/src/parsers/datePicker.js +24 -0
  55. package/src/parsers/frame.js +17 -0
  56. package/src/parsers/hidden.js +11 -0
  57. package/src/parsers/index.js +36 -0
  58. package/src/parsers/input.js +15 -0
  59. package/src/parsers/number.js +29 -0
  60. package/src/parsers/radio.js +5 -0
  61. package/src/parsers/select.js +15 -0
  62. package/src/parsers/slider.js +21 -0
  63. package/src/parsers/switch.js +11 -0
  64. package/src/parsers/text.js +25 -0
  65. package/src/parsers/timePicker.js +12 -0
  66. package/src/parsers/tree.js +37 -0
  67. package/src/parsers/upload.js +35 -0
  68. package/src/plugins/ab-detail.js +7 -0
  69. package/src/plugins/ab-drawer.js +7 -0
  70. package/src/plugins/ab-form.js +14 -0
  71. package/src/plugins/ab-search.js +7 -0
  72. package/src/plugins/ab-table.js +15 -0
  73. package/src/plugins/ab-toolbar.js +7 -0
  74. package/src/rule/defaults.js +187 -0
  75. package/src/rule/formatter.js +218 -0
  76. package/src/style/index.css +356 -0
  77. package/src/utils/formatter.js +188 -0
  78. package/src/utils/router-link.js +59 -0
  79. package/README.md +0 -3
@@ -0,0 +1,90 @@
1
+ <template>
2
+ <div class="ab-input-range">
3
+ <span v-if="prefix" class="range-prefix">{{ prefix }}</span>
4
+ <template v-if="isReadonly">
5
+ <!-- <span class="ab-input-range__val">{{ range[0] }}</span>
6
+ <span class="range-splitter"> ~ </span>
7
+ <span class="ab-input-range__val">{{ range[1] }}</span> -->
8
+ {{ range[0] }} ~ {{ range[1] }}
9
+ </template>
10
+ <template v-else>
11
+ <el-input
12
+ :value="range[0] === null ? '' : range[0]"
13
+ :size="currentSize"
14
+ placeholder="最小"
15
+ :clearable="clearable"
16
+ class="ab-input-range__val"
17
+ @input="updateRange(0, $event)"
18
+ @change="emitChange(0, $event)"
19
+ />
20
+ <span class="range-splitter"> ~ </span>
21
+ <el-input
22
+ :value="range[1] === null ? '' : range[1]"
23
+ :size="currentSize"
24
+ placeholder="最大"
25
+ :clearable="clearable"
26
+ class="ab-input-range__val"
27
+ @input="updateRange(1, $event)"
28
+ @change="emitChange(1, $event)"
29
+ />
30
+ </template>
31
+ <span v-if="suffix" class="range-suffix">{{ suffix }}</span>
32
+ </div>
33
+ </template>
34
+
35
+ <script>
36
+ export default {
37
+ name: "AbInputRange",
38
+ props: {
39
+ abFormInject: { type: Object, default: undefined },
40
+ value: { type: Array, default: () => [] },
41
+ prefix: { type: [String, Number], default: undefined },
42
+ suffix: { type: [String, Number], default: undefined },
43
+ clearable: { type: Boolean, default: true },
44
+ readonly: Boolean,
45
+ },
46
+ computed: {
47
+ range() {
48
+ const value = Array.isArray(this.value) ? this.value : [];
49
+ return [value[0] === undefined ? null : value[0], value[1] === undefined ? null : value[1]];
50
+ },
51
+ isReadonly() {
52
+ return this.readonly === true || Boolean(this.abFormInject && this.abFormInject.readonly === true);
53
+ },
54
+ currentSize() {
55
+ return (this.$ELEMENT && this.$ELEMENT.size) || "default";
56
+ },
57
+ },
58
+ methods: {
59
+ rangeWithValue(index, value) {
60
+ const next = [...this.range];
61
+ next[index] = value === "" ? null : value;
62
+ return next;
63
+ },
64
+ updateRange(index, value) {
65
+ this.$emit("input", this.rangeWithValue(index, value));
66
+ },
67
+ emitChange(index, value) {
68
+ this.$emit("change", this.rangeWithValue(index, value));
69
+ },
70
+ },
71
+ };
72
+ </script>
73
+
74
+ <style>
75
+ .ab-input-range {
76
+ display: flex;
77
+ align-items: center;
78
+ width: 100%;
79
+ }
80
+ .ab-input-range .range-splitter,
81
+ .ab-input-range .range-prefix,
82
+ .ab-input-range .range-suffix {
83
+ margin: 0 10px;
84
+ font-weight: 300;
85
+ white-space: nowrap;
86
+ }
87
+ .ab-input-range .ab-input-range__val {
88
+ flex: 1;
89
+ }
90
+ </style>
@@ -0,0 +1,51 @@
1
+ <template>
2
+ <el-radio-group v-bind="$attrs" :value="value" @input="handleInput" ref="el">
3
+ <template v-for="(option, index) in optionsList">
4
+ <el-radio-button
5
+ v-if="type === 'button'"
6
+ :key="`button-${index}-${option.value}`"
7
+ v-bind="optionProps(option)"
8
+ :label="option.value"
9
+ >
10
+ {{ option.label ?? option.value ?? "" }}
11
+ </el-radio-button>
12
+ <el-radio
13
+ v-else
14
+ :key="`radio-${index}-${option.value}`"
15
+ v-bind="optionProps(option)"
16
+ :label="option.value"
17
+ >
18
+ {{ option.label ?? option.value ?? "" }}
19
+ </el-radio>
20
+ </template>
21
+ <slot />
22
+ </el-radio-group>
23
+ </template>
24
+
25
+ <script>
26
+ export default {
27
+ name: "AbRadio",
28
+ inheritAttrs: false,
29
+ props: {
30
+ abFormInject: { type: Object, default: undefined },
31
+ value: { type: [String, Number, Boolean], default: undefined },
32
+ options: Array,
33
+ type: String,
34
+ },
35
+ computed: {
36
+ optionsList() {
37
+ const items = this.options || (this.abFormInject && this.abFormInject.options) || [];
38
+ return Array.isArray(items) ? items : [];
39
+ },
40
+ },
41
+ methods: {
42
+ optionProps(option) {
43
+ const { value, label, ...rest } = option || {};
44
+ return rest;
45
+ },
46
+ handleInput(value) {
47
+ this.$emit("input", value);
48
+ },
49
+ },
50
+ };
51
+ </script>
@@ -0,0 +1,46 @@
1
+ <template>
2
+ <span class="ab-router-link">
3
+ <ab-icon icon="ep:link" :size="16" :color="primaryColor" />
4
+ <router-link v-if="to" :to="to" class="ab-router-link__anchor">
5
+ <slot />
6
+ </router-link>
7
+ <slot v-else />
8
+ </span>
9
+ </template>
10
+
11
+ <script>
12
+ import { resolveRouterLink } from "../utils/router-link.js";
13
+
14
+ export default {
15
+ name: "AbRouterLink",
16
+ props: {
17
+ link: { type: [String, Function, Object], default: undefined },
18
+ value: { default: undefined },
19
+ row: { type: Object, default: () => ({}) },
20
+ },
21
+ computed: {
22
+ to() {
23
+ return resolveRouterLink(this.link, this.value, this.row);
24
+ },
25
+ primaryColor() {
26
+ const rootStyles = getComputedStyle(document.documentElement);
27
+ return rootStyles?.getPropertyValue("--el-color-primary").trim() || "#1890ff";
28
+ },
29
+ },
30
+ };
31
+ </script>
32
+
33
+ <style scoped>
34
+ .ab-router-link {
35
+ display: inline-flex;
36
+ align-items: center;
37
+ gap: 4px;
38
+ }
39
+ .ab-router-link__anchor {
40
+ color: var(--el-color-primary);
41
+ text-decoration: none;
42
+ }
43
+ .ab-router-link__anchor:hover {
44
+ text-decoration: underline;
45
+ }
46
+ </style>
@@ -0,0 +1,168 @@
1
+ <template>
2
+ <div :class="['ab-search', compactMode ? 'compact' : '']">
3
+ <ab-form ref="visibleForm" :rule="visibleRule" :option="formOption" @change="handleFormChange" />
4
+
5
+ <transition class="ab-search__expanded" mode="out-in" appear>
6
+ <div v-show="expanded">
7
+ <ab-form ref="hiddenForm" :rule="hiddenRule" :option="formOption" @change="handleFormChange" />
8
+ </div>
9
+ </transition>
10
+ </div>
11
+ </template>
12
+
13
+ <script>
14
+ import { useCache } from "../../hooks/use-cache.js";
15
+
16
+ export default {
17
+ name: "AbSearch",
18
+ props: {
19
+ rule: {
20
+ type: Array,
21
+ default: () => [],
22
+ },
23
+ value: {
24
+ type: Object,
25
+ default: () => ({}),
26
+ },
27
+ option: {
28
+ type: Object,
29
+ default: () => ({}),
30
+ },
31
+ compactMode: {
32
+ type: Boolean,
33
+ default: false,
34
+ },
35
+ },
36
+ data() {
37
+ return {
38
+ expanded: false,
39
+ opr: this.createOperatesRule(),
40
+ };
41
+ },
42
+ computed: {
43
+ formOption() {
44
+ const { getCurrentSize } = useCache();
45
+ const size = getCurrentSize();
46
+ return {
47
+ ...this.option,
48
+ formData: this.value,
49
+ form: { ...(this.option && this.option.form), size },
50
+ };
51
+ },
52
+ visibleRule() {
53
+ return [...this.rule.filter((item) => !this.isHidden(item)), this.opr];
54
+ },
55
+ hiddenRule() {
56
+ return this.rule.filter((item) => this.isHidden(item)).map((item) => ({ ...this.getRule(item), hidden: false }));
57
+ },
58
+ },
59
+ watch: {
60
+ value: {
61
+ handler(next) {
62
+ this.syncValue(next);
63
+ },
64
+ deep: true,
65
+ },
66
+ },
67
+ mounted() {
68
+ this.syncValue(this.value);
69
+ },
70
+ methods: {
71
+ createOperatesRule() {
72
+ return {
73
+ type: "formItem",
74
+ native: true,
75
+ class: "ab-form-item ab-search__operates",
76
+ children: [
77
+ {
78
+ type: "ElButton",
79
+ native: true,
80
+ children: ["搜索"],
81
+ props: { type: "primary", icon: "el-icon-search" },
82
+ on: { click: () => this.handleSearch() },
83
+ },
84
+ {
85
+ type: "ElButton",
86
+ native: true,
87
+ children: ["重置"],
88
+ props: { icon: "el-icon-refresh" },
89
+ on: { click: () => this.handleReset() },
90
+ },
91
+ {
92
+ type: "ElButton",
93
+ native: true,
94
+ children: ["展开"],
95
+ props: { type: "text", icon: "el-icon-arrow-down" },
96
+ on: { click: () => this.toggleExpand() },
97
+ },
98
+ ],
99
+ };
100
+ },
101
+ updateOperatesRule() {
102
+ const btn = this.opr.children[2];
103
+ btn.children = [this.expanded ? "收起" : "展开"];
104
+ btn.props.icon = this.expanded ? "el-icon-arrow-up" : "el-icon-arrow-down";
105
+ },
106
+ getRule(item) {
107
+ return item && typeof item.getRule === "function" ? item.getRule() : item;
108
+ },
109
+ isHidden(item) {
110
+ const rule = this.getRule(item);
111
+ return !!(rule && rule.hidden);
112
+ },
113
+ forms() {
114
+ return [this.$refs.visibleForm, this.$refs.hiddenForm];
115
+ },
116
+ collectFormData() {
117
+ const data = { ...this.value };
118
+ this.forms().forEach((form) => {
119
+ const fapi = form && form.$f;
120
+ if (fapi) Object.assign(data, fapi.formData());
121
+ });
122
+ return data;
123
+ },
124
+ syncValue(value) {
125
+ this.forms().forEach((form) => {
126
+ const fapi = form && form.$f;
127
+ if (!fapi) return;
128
+ Object.keys(value || {}).forEach((field) => fapi.setValue(field, value[field]));
129
+ });
130
+ },
131
+ handleFormChange() {
132
+ this.$emit("input", this.collectFormData());
133
+ },
134
+ toggleExpand() {
135
+ this.expanded = !this.expanded;
136
+ this.updateOperatesRule();
137
+ },
138
+ handleSearch() {
139
+ const data = this.collectFormData();
140
+ this.$emit("input", data);
141
+ this.$emit("search", data);
142
+ },
143
+ handleReset() {
144
+ this.forms().forEach((form) => {
145
+ const fapi = form && form.$f;
146
+ if (fapi) fapi.resetFields();
147
+ });
148
+ this.$emit("input", {});
149
+ this.$emit("reset", {});
150
+ },
151
+ },
152
+ };
153
+ </script>
154
+
155
+ <style scoped>
156
+ .ab-search-expand-enter-active {
157
+ transition: all 300ms ease-in-out;
158
+ }
159
+ .ab-search-expand-leave-active {
160
+ transition: all 200ms ease-out;
161
+ }
162
+ .ab-search-expand-enter,
163
+ .ab-search-expand-leave-active {
164
+ transform: translate3D(0, 0, 0);
165
+ height: 0;
166
+ opacity: 0;
167
+ }
168
+ </style>
@@ -0,0 +1,4 @@
1
+ import abSearch from "./ab-search.vue";
2
+
3
+ export { abSearch };
4
+ export default abSearch;
@@ -0,0 +1,107 @@
1
+ <template>
2
+ <el-select
3
+ v-bind="$attrs"
4
+ :value="value"
5
+ :size="currentSize"
6
+ @input="handleInput"
7
+ @change="handleChange"
8
+ ref="el"
9
+ >
10
+ <template v-for="(item, index) in options">
11
+ <el-option-group
12
+ v-if="hasGroup(item)"
13
+ :key="`group-${index}-${item.label}`"
14
+ :label="item.label"
15
+ >
16
+ <el-option
17
+ v-for="(option, optIndex) in trueArray(item.options)"
18
+ :key="`group-${index}-${optIndex}-${option.value}`"
19
+ v-bind="option"
20
+ />
21
+ </el-option-group>
22
+ <template v-else>
23
+ <el-option
24
+ v-if="showValue"
25
+ :key="`${index}-${item.value}`"
26
+ :label="item.label"
27
+ :value="item.value"
28
+ :class="item.class"
29
+ >
30
+ <span class="p-option__left">{{ item.label }}</span>
31
+ <span class="p-option__right">{{ item.value }}</span>
32
+ </el-option>
33
+ <el-option
34
+ v-else-if="showKey || showCode"
35
+ :key="`${index}-${item.value}`"
36
+ :label="item.label"
37
+ :value="item.value"
38
+ :class="item.class"
39
+ >
40
+ <span class="p-option__left">{{ item.label }}</span>
41
+ <span v-if="showKey" class="p-option__right">{{ item.key }}</span>
42
+ <span v-if="showCode" class="p-option__right">{{ item.code }}</span>
43
+ </el-option>
44
+ <el-option
45
+ v-else
46
+ :key="`${index}-${item.value}`"
47
+ :label="item.label"
48
+ :value="item.value"
49
+ />
50
+ </template>
51
+ </template>
52
+ <slot />
53
+ </el-select>
54
+ </template>
55
+
56
+ <script>
57
+ export default {
58
+ name: "AbSelect",
59
+ inheritAttrs: false,
60
+ props: {
61
+ abFormInject: {
62
+ type: Object,
63
+ default: undefined,
64
+ },
65
+ value: {
66
+ type: [Array, String, Number, Boolean, Object],
67
+ default: undefined,
68
+ },
69
+ type: String,
70
+ showValue: Boolean,
71
+ showKey: {
72
+ type: Boolean,
73
+ default: true,
74
+ },
75
+ showCode: {
76
+ type: Boolean,
77
+ default: true,
78
+ },
79
+ },
80
+ computed: {
81
+ options() {
82
+ const value = this.abFormInject && this.abFormInject.options;
83
+ return Array.isArray(value) ? value : [];
84
+ },
85
+ currentSize() {
86
+ return (this.$ELEMENT && this.$ELEMENT.size) || "default";
87
+ },
88
+ },
89
+ mounted() {
90
+ this.$emit("fc.el", this.$refs.el);
91
+ },
92
+ methods: {
93
+ hasGroup(item) {
94
+ return Boolean(item) && typeof item === "object" && Object.prototype.hasOwnProperty.call(item, "options");
95
+ },
96
+ trueArray(value) {
97
+ return Array.isArray(value) ? value : [];
98
+ },
99
+ handleInput(value) {
100
+ this.$emit("input", value);
101
+ },
102
+ handleChange(value) {
103
+ this.$emit("change", value);
104
+ },
105
+ },
106
+ };
107
+ </script>
@@ -0,0 +1,131 @@
1
+ <script>
2
+ import { resolveRuleFormatter } from "../../rule/formatter.js";
3
+ import { AbTableEnum } from "./utils.js";
4
+ import { loadRuleOptions } from "../../core/options.js";
5
+
6
+ export default {
7
+ name: "AbTableColumn",
8
+ props: {
9
+ rule: { type: Object, required: true },
10
+ idField: String,
11
+ idFieldTable: String,
12
+ permiPrefix: String,
13
+ sortable: Boolean,
14
+ deleteHandler: Function,
15
+ readonly: Boolean,
16
+ },
17
+ data() {
18
+ return { loadedOptions: undefined };
19
+ },
20
+ created() {
21
+ loadRuleOptions(this.rule, (options) => {
22
+ this.loadedOptions = options;
23
+ });
24
+ },
25
+ computed: {
26
+ effectiveRule() {
27
+ return this.loadedOptions ? { ...this.rule, options: this.loadedOptions } : this.rule;
28
+ },
29
+ isVisible() {
30
+ return !this.rule.hidden;
31
+ },
32
+ ruleSortable() {
33
+ return (
34
+ this.sortable !== false &&
35
+ this.rule.sortable !== false &&
36
+ this.rule.sortFieldTable !== false &&
37
+ (this.rule.sortable === true || this.rule.sortFieldTable !== undefined || !!this.idFieldTable)
38
+ );
39
+ },
40
+ ruleParams() {
41
+ return {
42
+ ...(this.rule.params || {}),
43
+ sortField: this.rule.sortField ?? this.rule.params?.sortField,
44
+ sortFieldTable: typeof this.rule.sortFieldTable === "string" ? this.rule.sortFieldTable : this.rule.params?.sortFieldTable ?? this.idFieldTable ?? "",
45
+ };
46
+ },
47
+ formatter() {
48
+ return resolveRuleFormatter(this.effectiveRule).formatter;
49
+ },
50
+ },
51
+ methods: {
52
+ changeHandler({ cellValue, row, column }) {
53
+ if (typeof this.rule?.on?.change === "function") this.rule.on.change({ cellValue, row, column });
54
+ },
55
+ formattedValue(scope) {
56
+ const cellValue = scope.row ? scope.row[this.rule.field] : undefined;
57
+ if (this.formatter) return this.formatter({ cellValue, column: scope.column, row: scope.row });
58
+ return cellValue === undefined || cellValue === null ? "" : cellValue;
59
+ },
60
+ renderCell(h, scope) {
61
+ const field = this.rule.field;
62
+ const cellValue = scope.row ? scope.row[field] : undefined;
63
+ const nodes = [];
64
+ if (this.rule.type === "ElRow" && field === AbTableEnum.OPERATE) {
65
+ nodes.push(
66
+ h("ab-table-operate", {
67
+ props: {
68
+ idField: this.idField,
69
+ idFieldTable: this.idFieldTable,
70
+ permiPrefix: this.permiPrefix,
71
+ rule: this.rule,
72
+ modelValue: scope.row,
73
+ deleteHandler: this.deleteHandler,
74
+ readonly: this.readonly,
75
+ link: true,
76
+ },
77
+ on: { refresh: () => this.$emit("refresh") },
78
+ })
79
+ );
80
+ } else if (this.rule.cellRender && this.rule.type === "switch") {
81
+ nodes.push(
82
+ h("el-switch", {
83
+ props: { ...(this.rule.props || {}), value: cellValue },
84
+ on: {
85
+ change: (value) => {
86
+ scope.row[field] = value;
87
+ this.changeHandler({ cellValue: value, row: scope.row, column: scope.column });
88
+ },
89
+ },
90
+ })
91
+ );
92
+ } else if (this.rule.cellRender) {
93
+ nodes.push(this.rule.type || "");
94
+ } else if (this.rule.link) {
95
+ nodes.push(h("ab-router-link", { props: { link: this.rule.link, value: cellValue, row: scope.row } }, [String(this.formattedValue(scope) ?? "")]));
96
+ } else {
97
+ nodes.push(String(this.formattedValue(scope) ?? ""));
98
+ }
99
+ if (this.rule.cellArrow) {
100
+ const decreasing = Number(cellValue) < 0;
101
+ // nodes.push(h('i', { class: decreasing ? 'el-icon-bottom danger' : 'el-icon-top success' }));
102
+ nodes.push(
103
+ h("ab-icon", {
104
+ props: {
105
+ icon: decreasing ? "streamline:graph-arrow-decrease" : "streamline:graph-arrow-increase",
106
+ },
107
+ class: decreasing ? "danger" : "success",
108
+ })
109
+ );
110
+ }
111
+ return nodes;
112
+ },
113
+ },
114
+ render(h) {
115
+ if (!this.rule.field) return h("span");
116
+ const props = {
117
+ title: this.rule.title,
118
+ field: this.rule.field,
119
+ sortable: this.ruleSortable,
120
+ params: this.ruleParams,
121
+ width: this.rule.width || "auto",
122
+ minWidth: this.rule.minWidth,
123
+ align: this.rule.align,
124
+ fixed: this.rule.fixed,
125
+ visible: this.isVisible,
126
+ className: this.rule.cellArrow ? "items-center" : "",
127
+ };
128
+ return h("vxe-column", { props, scopedSlots: { default: (scope) => this.renderCell(h, scope) } });
129
+ },
130
+ };
131
+ </script>
@@ -0,0 +1,62 @@
1
+ <script>
2
+ import { AbTableEnum } from './utils.js';
3
+
4
+ export default {
5
+ name: 'AbTableColumns',
6
+ props: {
7
+ rule: { type: Object, required: true },
8
+ idx: { type: [Number, String], default: 0 },
9
+ idField: String,
10
+ idFieldTable: String,
11
+ permiPrefix: String,
12
+ sortable: Boolean,
13
+ deleteHandler: Function,
14
+ readonly: Boolean
15
+ },
16
+ computed: {
17
+ isGroup() {
18
+ const rule = this.rule || {};
19
+ return !!rule.children?.length && (rule.field ? rule.field !== AbTableEnum.OPERATE : !rule.type && !!rule.title);
20
+ }
21
+ },
22
+ methods: {
23
+ childProps(rule, idx) {
24
+ return {
25
+ rule,
26
+ idx,
27
+ idField: this.idField,
28
+ idFieldTable: this.idFieldTable,
29
+ permiPrefix: this.permiPrefix,
30
+ sortable: this.sortable,
31
+ deleteHandler: this.deleteHandler,
32
+ readonly: this.readonly
33
+ };
34
+ }
35
+ },
36
+ render(h) {
37
+ if (this.isGroup) {
38
+ return h(
39
+ 'vxe-colgroup',
40
+ {
41
+ props: {
42
+ field: this.rule.field,
43
+ title: this.rule.title,
44
+ headerAlign: this.rule.groupAlign || this.rule.align || 'center'
45
+ }
46
+ },
47
+ (this.rule.children || []).map((child, index) =>
48
+ h('ab-table-columns', {
49
+ props: this.childProps(child, index),
50
+ on: { refresh: () => this.$emit('refresh') },
51
+ key: child.field || `${this.idx}_${index}`
52
+ })
53
+ )
54
+ );
55
+ }
56
+ return h('ab-table-column', {
57
+ props: this.childProps(this.rule, this.idx),
58
+ on: { refresh: () => this.$emit('refresh') }
59
+ });
60
+ }
61
+ };
62
+ </script>