@archbiz/element-ui 0.0.0-stage → 0.1.1

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 +11 -0
  2. package/dist/element-ui.js +5518 -0
  3. package/dist/style.css +1 -0
  4. package/package.json +50 -4
  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 +102 -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 +256 -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,277 @@
1
+ <template>
2
+ <div class="ab-upload-file">
3
+ <el-upload
4
+ v-if="!currentDisabled"
5
+ action=""
6
+ :show-file-list="false"
7
+ :drag="drag"
8
+ :multiple="currentLimit > 1"
9
+ :accept="accept"
10
+ :before-upload="beforeUpload"
11
+ :http-request="uploadRequest"
12
+ >
13
+ <el-button type="primary" size="small">选择文件</el-button>
14
+ <div v-if="isShowTip" slot="tip" class="ab-upload-file__tip">
15
+ 支持 {{ fileTypes.join("/") }},单个不超过 {{ fileSize }} MB
16
+ </div>
17
+ </el-upload>
18
+
19
+ <ul class="ab-upload-file__list">
20
+ <li v-for="file in files" :key="file.uid" class="ab-upload-file__item">
21
+ <span class="ab-upload-file__name">{{ file.name }}</span>
22
+ <span v-if="file.status === 'uploading'" class="ab-upload-file__tip">上传中...</span>
23
+ <span v-if="file.error" class="ab-upload-file__error">{{ file.error }}</span>
24
+ <el-button v-if="file.url && preEnabled" type="text" @click="preview(file)">预览</el-button>
25
+ <el-link v-if="file.url && dowEnabled" :href="file.url" target="_blank" download>下载</el-link>
26
+ <el-button
27
+ v-if="!currentDisabled && delEnabled && file.status !== 'uploading'"
28
+ type="text"
29
+ @click="removeFile(file)"
30
+ >
31
+ 删除
32
+ </el-button>
33
+ </li>
34
+ </ul>
35
+ </div>
36
+ </template>
37
+
38
+ <script>
39
+ const IMAGE_TYPES = ["png", "jpg", "jpeg", "gif", "webp", "bmp", "svg"];
40
+ const DEFAULT_TYPES = ["doc", "xls", "txt", "pdf"];
41
+
42
+ function fileNameFromUrl(url) {
43
+ const name = String(url).split(/[?#]/, 1)[0].split("/").pop() || url;
44
+ try {
45
+ return decodeURIComponent(name);
46
+ } catch (error) {
47
+ if (error instanceof URIError) return name;
48
+ throw error;
49
+ }
50
+ }
51
+
52
+ function getBusinessId(value) {
53
+ if (typeof value === "number" && Number.isFinite(value)) return value;
54
+ if (typeof value === "string" && value.trim() && value !== "new") return value;
55
+ return undefined;
56
+ }
57
+
58
+ export default {
59
+ name: "AbUploadFile",
60
+ props: {
61
+ value: { type: Array, default: () => [] },
62
+ apis: { type: Object, default: undefined },
63
+ abFormInject: { type: Object, default: undefined },
64
+ idFieldTable: { type: String, default: undefined },
65
+ businessCode: { type: String, default: undefined },
66
+ uploadType: { type: String, default: undefined },
67
+ maxLength: { type: [Number, String], default: undefined },
68
+ fileType: { type: Array, default: undefined },
69
+ fileSize: { type: Number, default: 5 },
70
+ limit: { type: Number, default: undefined },
71
+ drag: Boolean,
72
+ isShowTip: { type: Boolean, default: true },
73
+ readonly: Boolean,
74
+ disabled: Boolean,
75
+ delEnabled: { type: Boolean, default: true },
76
+ preEnabled: { type: Boolean, default: true },
77
+ dowEnabled: { type: Boolean, default: true },
78
+ coverEnabled: Boolean,
79
+ autoCover: Boolean,
80
+ },
81
+ data() {
82
+ return {
83
+ uid: 0,
84
+ files: [],
85
+ };
86
+ },
87
+ computed: {
88
+ currentDisabled() {
89
+ return this.disabled || this.readonly || Boolean(this.abFormInject && this.abFormInject.readonly === true);
90
+ },
91
+ currentLimit() {
92
+ if (this.limit != null) return Number(this.limit);
93
+ if (this.maxLength != null) return Number(this.maxLength);
94
+ return 5;
95
+ },
96
+ fileTypes() {
97
+ if (Array.isArray(this.fileType) && this.fileType.length) return this.fileType;
98
+ return this.uploadType === "image" ? IMAGE_TYPES : DEFAULT_TYPES;
99
+ },
100
+ accept() {
101
+ return this.fileTypes.map((type) => `.${String(type).replace(/^\./, "")}`).join(",");
102
+ },
103
+ apisClient() {
104
+ return this.apis || this.$abUploadApis;
105
+ },
106
+ },
107
+ watch: {
108
+ value: {
109
+ handler(next) {
110
+ this.syncFromValue(next);
111
+ },
112
+ immediate: true,
113
+ deep: true,
114
+ },
115
+ },
116
+ methods: {
117
+ syncFromValue(value) {
118
+ const urls = Array.isArray(value) ? value : [];
119
+ const available = [...this.files];
120
+ const next = urls.map((url) => {
121
+ const index = available.findIndex((file) => file.url === url);
122
+ if (index > -1) return available.splice(index, 1)[0];
123
+ return {
124
+ uid: ++this.uid,
125
+ name: fileNameFromUrl(url),
126
+ url,
127
+ id: undefined,
128
+ fileId: undefined,
129
+ size: undefined,
130
+ error: undefined,
131
+ status: "linked",
132
+ };
133
+ });
134
+ this.files = [
135
+ ...next,
136
+ ...this.files.filter((file) => file.status === "uploading" || file.status === "failed"),
137
+ ];
138
+ },
139
+ publish() {
140
+ this.$emit(
141
+ "input",
142
+ this.files.filter((file) => file.url).map((file) => file.url)
143
+ );
144
+ },
145
+ beforeUpload(file) {
146
+ const uploading = this.files.filter((item) => item.status === "uploading" || item.status === "linked").length;
147
+ if (uploading >= this.currentLimit) {
148
+ this.$message.error(`最多上传 ${this.currentLimit} 个文件`);
149
+ return false;
150
+ }
151
+ const name = file.name || "";
152
+ const extension = name.includes(".") ? name.slice(name.lastIndexOf(".") + 1).toLowerCase() : "";
153
+ if (
154
+ this.fileTypes.length &&
155
+ !this.fileTypes.some((type) => String(type).toLowerCase().replace(/^\./, "") === extension)
156
+ ) {
157
+ this.$message.error(`仅支持 ${this.fileTypes.join("/")} 格式`);
158
+ return false;
159
+ }
160
+ if (file.size > this.fileSize * 1024 * 1024) {
161
+ this.$message.error(`文件大小不能超过 ${this.fileSize} MB`);
162
+ return false;
163
+ }
164
+ return true;
165
+ },
166
+ uploadRequest(options) {
167
+ const client = this.apisClient;
168
+ if (!client || typeof client.upload !== "function") {
169
+ const error = new Error("未配置上传接口");
170
+ this.$message.error(error.message);
171
+ this.$emit("error", error);
172
+ return Promise.reject(error);
173
+ }
174
+ const file = {
175
+ uid: ++this.uid,
176
+ name: options.file && options.file.name,
177
+ url: undefined,
178
+ id: undefined,
179
+ fileId: undefined,
180
+ size: undefined,
181
+ error: undefined,
182
+ status: "uploading",
183
+ };
184
+ this.files.push(file);
185
+ return Promise.resolve()
186
+ .then(() => client.upload({ file: options.file }))
187
+ .then((response) => {
188
+ const data = response && response.data ? response.data : response;
189
+ if (!data || data.id == null || typeof data.url !== "string" || !data.url) {
190
+ throw new TypeError("上传接口需返回 id、name、url");
191
+ }
192
+ this.$set(file, "id", data.id);
193
+ this.$set(file, "fileId", data.id);
194
+ this.$set(file, "url", data.url);
195
+ this.$set(file, "name", data.name || (options.file && options.file.name) || data.url);
196
+ this.$set(file, "size", data.size);
197
+ this.$set(file, "status", "linked");
198
+ this.publish();
199
+ return response;
200
+ })
201
+ .catch((error) => {
202
+ this.$set(file, "status", "failed");
203
+ this.$set(file, "error", this.errorMessage(error));
204
+ this.$emit("error", error);
205
+ throw error;
206
+ });
207
+ },
208
+ handleUploadError(error) {
209
+ this.$emit("error", error);
210
+ },
211
+ removeFile(file) { const client = this.apisClient;
212
+ const businessId = this.businessId();
213
+ const done = () => {
214
+ this.files = this.files.filter((item) => item.uid !== file.uid);
215
+ this.publish();
216
+ };
217
+ if (client && typeof client.remove === "function" && file.fileId != null && businessId !== undefined) {
218
+ Promise.resolve(
219
+ client.remove({
220
+ ...this.businessParams(businessId),
221
+ fileId: file.fileId,
222
+ })
223
+ )
224
+ .then(done)
225
+ .catch((error) => {
226
+ this.$message.error(this.errorMessage(error));
227
+ this.$emit("error", error);
228
+ });
229
+ return;
230
+ }
231
+ done();
232
+ },
233
+ preview(file) {
234
+ const name = file.name || "";
235
+ const extension = name.includes(".") ? name.slice(name.lastIndexOf(".") + 1).toLowerCase() : "";
236
+ this.$emit("preview", { url: file.url, name, extension, fileId: file.fileId });
237
+ },
238
+ businessId() {
239
+ const inject = this.abFormInject;
240
+ const value = inject && inject.formValue && inject.idField ? inject.formValue[inject.idField] : undefined;
241
+ return getBusinessId(value);
242
+ },
243
+ businessParams(id) {
244
+ return {
245
+ businessType: this.idFieldTable || (this.abFormInject && this.abFormInject.idFieldTable),
246
+ businessCode: this.businessCode,
247
+ businessId: id,
248
+ };
249
+ },
250
+ errorMessage(error) {
251
+ return error instanceof Error ? error.message : String(error);
252
+ },
253
+ },
254
+ };
255
+ </script>
256
+
257
+ <style scoped>
258
+ .ab-upload-file__list {
259
+ margin: 0;
260
+ padding: 0;
261
+ list-style: none;
262
+ }
263
+ .ab-upload-file__item {
264
+ display: flex;
265
+ align-items: center;
266
+ gap: 8px;
267
+ flex-wrap: wrap;
268
+ }
269
+ .ab-upload-file__tip {
270
+ font-size: 12px;
271
+ color: #909399;
272
+ }
273
+ .ab-upload-file__error {
274
+ font-size: 12px;
275
+ color: #f56c6c;
276
+ }
277
+ </style>
@@ -0,0 +1,27 @@
1
+ import abSelect from "./ab-select.vue";
2
+ import abRadio from "./ab-radio.vue";
3
+ import abCheckbox from "./ab-checkbox.vue";
4
+ import abIcon from "./ab-icon/ab-icon.vue";
5
+ import abTreeSelect from "./ab-tree-select.vue";
6
+ import abInputNumber from "./ab-input-number.vue";
7
+ import abInputRange from "./ab-input-range.vue";
8
+ import abTimePeriod from "./ab-time-period.vue";
9
+ import abTimePicker from "./ab-time-picker.vue";
10
+ import abColorPicker from "./ab-color-picker.vue";
11
+ import abUploadFile from "./ab-upload-file.vue";
12
+ import abRouterLink from "./ab-router-link.vue";
13
+
14
+ export default [
15
+ abSelect,
16
+ abRadio,
17
+ abCheckbox,
18
+ abIcon,
19
+ abTreeSelect,
20
+ abInputNumber,
21
+ abInputRange,
22
+ abTimePeriod,
23
+ abTimePicker,
24
+ abColorPicker,
25
+ abUploadFile,
26
+ abRouterLink,
27
+ ];
@@ -0,0 +1,25 @@
1
+ import createAbForm, { VNode } from "@archbiz/core-v2";
2
+ import components from "../components/index.js";
3
+ import parsers from "../parsers/index.js";
4
+ import getConfig from "./config.js";
5
+ import alias from "./alias.js";
6
+ import formRender from "./form-render.js";
7
+ import makers from "../makers/index.js";
8
+ import { applyRuleDefaults } from "../rule/defaults.js";
9
+
10
+ export default function abForm() {
11
+ VNode.use(alias);
12
+
13
+ const { AbForm } = createAbForm({
14
+ ui: process.env.UI,
15
+ version: `${process.env.VERSION}`,
16
+ formRender,
17
+ components,
18
+ parsers,
19
+ makers,
20
+ getConfig,
21
+ mergeRule: (rule) => applyRuleDefaults(rule),
22
+ });
23
+
24
+ return AbForm;
25
+ }
@@ -0,0 +1,36 @@
1
+ const PRE = 'el';
2
+
3
+ export default {
4
+ input: `${PRE}-input`,
5
+ password: `${PRE}-input`,
6
+ textarea: `${PRE}-input`,
7
+ text: 'span',
8
+ hidden: 'span',
9
+ divider: `${PRE}-divider`,
10
+ number: `${PRE}-input-number`,
11
+ inputNumber: `${PRE}-input-number`,
12
+ inputCurrency: 'ab-input-number',
13
+ inputPercent: 'ab-input-number',
14
+ select: 'ab-select',
15
+ radio: 'ab-radio',
16
+ checkbox: 'ab-checkbox',
17
+ switch: `${PRE}-switch`,
18
+ datePicker: `${PRE}-date-picker`,
19
+ timePicker: 'ab-time-picker',
20
+ slider: `${PRE}-slider`,
21
+ rate: `${PRE}-rate`,
22
+ colorPicker: 'ab-color-picker',
23
+ cascader: `${PRE}-cascader`,
24
+ treeSelect: 'ab-tree-select',
25
+ inputRange: 'ab-input-range',
26
+ timePeriod: 'ab-time-period',
27
+ uploadFile: 'ab-upload-file',
28
+ upload: 'ab-upload-file',
29
+ form: `${PRE}-form`,
30
+ formItem: `${PRE}-form-item`,
31
+ ElButton: `${PRE}-button`,
32
+ button: `${PRE}-button`,
33
+ icon: 'ab-icon',
34
+ row: `${PRE}-row`,
35
+ col: `${PRE}-col`
36
+ };
@@ -0,0 +1,65 @@
1
+ export default function getConfig() {
2
+ return {
3
+ form: {
4
+ inline: true,
5
+ labelPosition: "right",
6
+ labelSuffix: undefined,
7
+ hideRequiredAsterisk: false,
8
+ labelWidth: "120px",
9
+ fieldWidth: "238px",
10
+ showMessage: true,
11
+ inlineMessage: false,
12
+ statusIcon: false,
13
+ validateOnRuleChange: true,
14
+ disabled: false,
15
+ size: undefined,
16
+ },
17
+ row: {
18
+ gutter: 0,
19
+ type: undefined,
20
+ align: undefined,
21
+ justify: undefined,
22
+ tag: "div",
23
+ },
24
+ info: {
25
+ type: "popover",
26
+ trigger: "hover",
27
+ placement: "top-start",
28
+ icon: "el-icon-warning",
29
+ },
30
+ submitBtn: {
31
+ type: "primary",
32
+ size: "medium",
33
+ plain: false,
34
+ round: false,
35
+ circle: false,
36
+ loading: false,
37
+ disabled: false,
38
+ icon: "el-icon-upload",
39
+ width: "100%",
40
+ autofocus: false,
41
+ nativeType: "button",
42
+ innerText: "提交",
43
+ show: false,
44
+ col: undefined,
45
+ click: undefined,
46
+ },
47
+ resetBtn: {
48
+ type: "default",
49
+ size: "medium",
50
+ plain: false,
51
+ round: false,
52
+ circle: false,
53
+ loading: false,
54
+ disabled: false,
55
+ icon: "el-icon-refresh",
56
+ width: "100%",
57
+ autofocus: false,
58
+ nativeType: "button",
59
+ innerText: "重置",
60
+ show: false,
61
+ col: undefined,
62
+ click: undefined,
63
+ },
64
+ };
65
+ }
@@ -0,0 +1,256 @@
1
+ import { isFunction, preventDefault, toString, isString, isType } from "@archbiz/utils";
2
+ import { BaseForm } from "@archbiz/core-v2";
3
+ import "../style/index.css";
4
+ import { resolveRuleFormatter } from "../rule/formatter.js";
5
+ import { isRouterLinkConfig } from "../utils/router-link.js";
6
+ import AbRouterLink from "../components/ab-router-link.vue";
7
+
8
+ const upperCaseReg = /[A-Z]/;
9
+
10
+ const injectTypes = new Set(["select", "treeselect", "radio", "checkbox", "inputrange", "timeperiod", "tree", "upload", "uploadfile", "frame"]);
11
+
12
+ const readonlyTextTypes = new Set([
13
+ "input",
14
+ "password",
15
+ "textarea",
16
+ "number",
17
+ "inputnumber",
18
+ "inputcurrency",
19
+ "inputpercent",
20
+ "select",
21
+ "radio",
22
+ "checkbox",
23
+ "switch",
24
+ "datepicker",
25
+ "timepicker",
26
+ "slider",
27
+ "rate",
28
+ "cascader",
29
+ "treeselect",
30
+ "text",
31
+ ]);
32
+
33
+ export function isAttr(name, value) {
34
+ return !upperCaseReg.test(name) && (isString(value) || isType(value, "Number"));
35
+ }
36
+
37
+ function isTooltip(info) {
38
+ return info.type === "tooltip";
39
+ }
40
+
41
+ export default class Form extends BaseForm {
42
+ get injectTypes() {
43
+ return injectTypes;
44
+ }
45
+
46
+ readonlyRender(parser) {
47
+ if (!this.$handle.vm || !this.$handle.vm.readonly) return;
48
+ if (!parser.isDef || parser.rule.component) return;
49
+ if (!readonlyTextTypes.has(parser.type)) return;
50
+
51
+ const rule = parser.rule;
52
+ const value = this.$handle.getFormData(parser);
53
+ const row = this.$handle.formData || {};
54
+ const formatter = resolveRuleFormatter({ ...rule, props: rule.props || {} }).formatter;
55
+ const displayValue = typeof formatter === "function" ? formatter({ cellValue: value, column: rule, row }) : value;
56
+ const content = String(displayValue ?? "");
57
+ const link = rule.link;
58
+
59
+ if (isRouterLinkConfig(link)) {
60
+ return this.vNode.make(AbRouterLink, { props: { link, value, row } }, [content]);
61
+ }
62
+ return this.vNode.make("span", { domProps: { textContent: content } });
63
+ }
64
+
65
+ inputVData(parser) {
66
+ const props = parser.rule.props || {};
67
+ parser.vData.attrs({ ...props });
68
+ if (!props.size && this.options.form.size) parser.vData.props("size", this.options.form.size);
69
+ }
70
+
71
+ validate(call) {
72
+ this.getFormRef().validate((valid) => {
73
+ call && call(valid);
74
+ });
75
+ }
76
+
77
+ validateField(field, call) {
78
+ this.getFormRef().validateField(field, call);
79
+ }
80
+
81
+ resetField(parser) {
82
+ this.vm.$refs[parser.formItemRefName].resetField();
83
+ }
84
+
85
+ clearValidateState(parser) {
86
+ const fItem = this.vm.$refs[parser.formItemRefName];
87
+ if (fItem) {
88
+ fItem.validateMessage = "";
89
+ fItem.validateState = "";
90
+ }
91
+ }
92
+
93
+ beforeRender() {
94
+ this.propsData = this.vData
95
+ .props(this.options.form)
96
+ .props({
97
+ model: this.$handle.formData,
98
+ rules: this.$handle.validate,
99
+ key: "form" + this.unique,
100
+ })
101
+ .ref(this.refName)
102
+ .nativeOn({ submit: preventDefault })
103
+ .class(this.options.form.className)
104
+ .class("form-create", true)
105
+ .class("ab-form", true)
106
+ .key(this.unique)
107
+ .get();
108
+ }
109
+
110
+ render(vn) {
111
+ if (vn.length > 0) vn.push(this.makeFormBtn());
112
+
113
+ return this.vNode.form(this.propsData, [this.options.row === false ? vn : this.makeRow(vn)]);
114
+ }
115
+
116
+ makeRow(vn) {
117
+ const _class = {},
118
+ row = this.options.row || {};
119
+
120
+ if (row.class) _class[row.class] = true;
121
+ return this.vNode.row({ props: row || {}, key: "fr" + this.unique, class: _class }, vn);
122
+ }
123
+
124
+ container(child, parser) {
125
+ return this.makeFormItem(parser, child);
126
+ }
127
+
128
+ makeFormItem(parser, child) {
129
+ let fItemUnique = `fItem${parser.key}${this.unique}`,
130
+ { rule, field, formItemRefName } = parser,
131
+ col = this.getGetCol(parser),
132
+ labelWidth = !col.labelWidth && !rule.title ? 0 : col.labelWidth,
133
+ fieldWidth = parser.isDef ? this.options.form && this.options.form.fieldWidth : "",
134
+ { inline, col: _col } = this.propsData.props,
135
+ propsData = this.vData
136
+ .props({
137
+ prop: field,
138
+ // label: rule.title,
139
+ // labelFor: unique,
140
+ rules: rule.validate,
141
+ labelWidth: toString(labelWidth),
142
+ required: rule.props.required,
143
+ })
144
+ .key(fItemUnique)
145
+ .ref(formItemRefName)
146
+ .class(rule.className)
147
+ .style(fieldWidth ? { "--ab-field-width": toString(fieldWidth) } : undefined)
148
+ .get(),
149
+ node = this.vNode.formItem(propsData, [child, this.makeFormPop(parser, fItemUnique)]);
150
+ return inline === true || _col === false ? node : this.makeCol(col, parser, fItemUnique, [node]);
151
+ }
152
+
153
+ makeFormPop({ rule }, unique) {
154
+ if (rule.title) {
155
+ const titleProp = isString(rule.title) ? { title: rule.title } : rule.title;
156
+ const info = this.options.info || {},
157
+ svn = [titleProp.title || ""];
158
+ if (rule.info) {
159
+ svn.push(
160
+ this.vNode.make(
161
+ isTooltip(info) ? "el-tooltip" : "el-popover",
162
+ {
163
+ props: { ...info, content: rule.info },
164
+ key: `pop${unique}`,
165
+ },
166
+ [
167
+ this.vNode.icon({
168
+ class: [info.icon || "el-icon-warning"],
169
+ slot: isTooltip(info) ? "default" : "reference",
170
+ }),
171
+ ]
172
+ )
173
+ );
174
+ }
175
+ return this.vNode.make("span", { ...titleProp, slot: "label" }, svn);
176
+ }
177
+ }
178
+
179
+ makeCol(col, parser, fItemUnique, VNodeFn) {
180
+ if (col.span === undefined) col.span = 24;
181
+ const cls = {};
182
+ if (col.class) cls[col.class] = true;
183
+ return this.vNode.col(
184
+ {
185
+ props: col,
186
+ class: cls,
187
+ key: `${fItemUnique}col1`,
188
+ },
189
+ VNodeFn
190
+ );
191
+ }
192
+
193
+ makeFormBtn() {
194
+ let btn = [],
195
+ submitBtnShow = false !== this.vm.buttonProps && false !== this.vm.buttonProps.show,
196
+ resetBtnShow = false !== this.vm.resetProps && false !== this.vm.resetProps.show;
197
+ if (submitBtnShow) btn.push(this.makeSubmitBtn(resetBtnShow ? 19 : 24));
198
+ if (resetBtnShow) btn.push(this.makeResetBtn(4));
199
+
200
+ return this.propsData.props.inline === true
201
+ ? btn
202
+ : btn.length
203
+ ? this.vNode.col(
204
+ {
205
+ props: { span: 24 },
206
+ key: `${this.unique}col2`,
207
+ },
208
+ btn
209
+ )
210
+ : [];
211
+ }
212
+
213
+ makeResetBtn(span) {
214
+ const resetBtn = this.vm.resetProps,
215
+ props = resetBtn.col || { span: span, push: 1 };
216
+
217
+ return this.vNode.col({ props: props, key: `${this.unique}col3` }, [
218
+ this.vNode.button(
219
+ {
220
+ key: `frsbtn${this.unique}`,
221
+ props: resetBtn,
222
+ on: {
223
+ click: () => {
224
+ const fApi = this.$handle.fCreateApi;
225
+ isFunction(resetBtn.click) ? resetBtn.click(fApi) : fApi.resetFields();
226
+ },
227
+ },
228
+ style: { width: resetBtn.width },
229
+ },
230
+ [resetBtn.innerText]
231
+ ),
232
+ ]);
233
+ }
234
+
235
+ makeSubmitBtn(span) {
236
+ const submitBtn = this.vm.buttonProps,
237
+ props = submitBtn.col || { span: span };
238
+
239
+ return this.vNode.col({ props: props, key: `${this.unique}col4` }, [
240
+ this.vNode.button(
241
+ {
242
+ key: `fbtn${this.unique}`,
243
+ props: submitBtn,
244
+ on: {
245
+ click: () => {
246
+ const fApi = this.$handle.fCreateApi;
247
+ isFunction(submitBtn.click) ? submitBtn.click(fApi) : fApi.submit();
248
+ },
249
+ },
250
+ style: { width: submitBtn.width },
251
+ },
252
+ [submitBtn.innerText]
253
+ ),
254
+ ]);
255
+ }
256
+ }