general-basic-form 2.0.1 → 2.0.3

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # GeneralBasicForm
2
2
 
3
- 一个兼容 Vue2Vue3 的表单组件 <br/>
3
+ 一个兼容 Vue3React(未来实现) 的表单组件 <br/>
4
4
 
5
5
  示例:
6
6
 
@@ -45,10 +45,11 @@ import GeneralBasicForm from 'general-basic-form'
45
45
  />
46
46
 
47
47
  <style lang="scss" scoped>
48
- :deep {
49
- .el-form-item {
50
- margin-bottom: 22px;
51
- }
48
+ :deep(.el-form-item) {
49
+ margin-bottom: 16px;
50
+ }
51
+ :deep(.el-divider--horizontal) {
52
+ margin: 8px 0px;
52
53
  }
53
54
  </style>
54
55
 
@@ -63,14 +64,29 @@ getList会传出默认的参数,首次请求时会有页数和分页大小,重
63
64
 
64
65
  表单数据校验需要拿到内部表单的ref
65
66
 
66
- this.$refs["generalBasicForm"].$refs["queryFormRef"]
67
- .validate(
68
- async (valid) => {
69
- if (valid) {
70
- console.log(this.$refs["generalBasicForm"]["queryParams"]);
67
+ async getSmscode() {
68
+ const VGeneralBasicFormRef = this.$refs['VGeneralBasicFormRef'] as any
69
+ const state = await new Promise<boolean>((resolve, reject) => {
70
+ VGeneralBasicFormRef.$refs['queryFormRef']?.validateField(
71
+ 'user_phone',
72
+ async (valid: FormValidateCallback | undefined) => {
73
+ if (valid) {
74
+ const { user_phone } = VGeneralBasicFormRef['queryParams']
75
+ const res: any = await SmscodeList({ user_phone })
76
+ if (res) {
77
+ console.log(res)
78
+ resolve(true)
79
+ } else {
80
+ resolve(false)
81
+ }
82
+ } else {
83
+ resolve(false)
84
+ }
71
85
  }
72
- }
73
- );
86
+ )
87
+ })
88
+ return state
89
+ },
74
90
 
75
91
 
76
92
  ![image-20211014191532067](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202110141915657.png)
@@ -83,10 +99,25 @@ getList会传出默认的参数,首次请求时会有页数和分页大小,重
83
99
  formOnly:true // 只展示表单不展示按钮
84
100
  noUrlParameters:true // 不接受和不改变url的参数
85
101
  formItem: [
102
+ {
103
+ label: '',
104
+ prop: 'bsName35',
105
+ type: 'divider',
106
+ dividerSetting: {
107
+ },
108
+ template: {
109
+ default: () => {
110
+ return "123123123";
111
+ },
112
+ },
113
+ },
86
114
  { label: "款式名称",
87
115
  prop: "bsName",
88
116
  type: "input",
89
- placeholder: "请输入图片名称/分类名称/图片标签",
117
+ inputSetting: {
118
+ placeholder: '请输入手机验证码',
119
+ style: 'width: 100%'
120
+ },
90
121
  rules: [
91
122
  {
92
123
  message: "请输入信息"
@@ -101,7 +132,7 @@ getList会传出默认的参数,首次请求时会有页数和分页大小,重
101
132
  return <svg-icon icon-class="baifenbi" />;
102
133
  },
103
134
  },
104
- maxlength: "3000"},
135
+ },
105
136
  {
106
137
  label: "二次工艺",
107
138
  prop: "spName",
@@ -133,6 +164,40 @@ getList会传出默认的参数,首次请求时会有页数和分页大小,重
133
164
  },
134
165
  ],
135
166
  },
167
+ {
168
+ label: '',
169
+ prop: 'bsName2',
170
+ type: 'input-graphic-verification',
171
+ inputSetting: {
172
+ placeholder: '请输入图形验证码',
173
+ style: 'width: 100%'
174
+ },
175
+ rules: [
176
+ {
177
+ message: '请输入图形验证码',
178
+ trigger: 'blur'
179
+ }
180
+ ],
181
+ graphicSrc, // 请求图像的URL
182
+ getGraphic, // 重新请求图像的函数
183
+ key:Math.random(), // 必传,图像更新后必须更新。如果URL会变化也可以用URL代替
184
+ },
185
+ {
186
+ label: '',
187
+ prop: 'bsName3',
188
+ type: 'input-mobile-verification',
189
+ inputSetting: {
190
+ placeholder: '请输入手机验证码',
191
+ style: 'width: 100%'
192
+ },
193
+ rules: [
194
+ {
195
+ message: '请输入手机验证码',
196
+ trigger: 'blur'
197
+ }
198
+ ]
199
+ getSmscode,// 获取验证码的回调函数,获取失败必须返回false,否则计时器不会重新计算
200
+ },
136
201
  {
137
202
  label: "分类",
138
203
  prop: "分类",
@@ -201,9 +266,6 @@ getList会传出默认的参数,首次请求时会有页数和分页大小,重
201
266
  ],
202
267
  },
203
268
  ],
204
- //分别支持input输入框,select单选框,date-picker日期选择器,cascader层级选择器 四种组件
205
-
206
- //date-picker可以传入'start-placeholder'和'end-placeholder',其他组件支持placeholder传入
207
269
 
208
270
  //rules为表单校验规则,每个组件都可以传入
209
271
 
@@ -212,5 +274,74 @@ getList会传出默认的参数,首次请求时会有页数和分页大小,重
212
274
  //suffix 输入框尾部内容,只对 type="text" 有效
213
275
  //prepend 输入框前置内容,只对 type="text" 有效
214
276
  //append 输入框后置内容,只对 type="text" 有效
277
+
278
+ //divider支持template:
279
+ //default
280
+ 支持组件:
281
+
282
+ /**
283
+
284
+ \* @description: 输入框
285
+
286
+ */
287
+
288
+ 'input' = 'input',
289
+
290
+ /**
291
+
292
+ \* @description: 输入框/图像验证码
293
+
294
+ */
295
+
296
+ 'input-graphic-verification' = 'input-graphic-verification',
297
+
298
+ /**
299
+
300
+ \* @description: 输入框/手机验证码
301
+
302
+ */
303
+
304
+ 'input-mobile-verification' = 'input-mobile-verification',
305
+
306
+ /**
307
+
308
+ \* @description: 分割线
309
+
310
+ */
311
+
312
+ 'divider' = 'divider',
313
+
314
+ /**
315
+
316
+ \* @description: 选择器
317
+
318
+ */
319
+
320
+ 'select' = 'select',
321
+
322
+ /**
323
+
324
+ \* @description: 级联选择器
325
+
326
+ */
327
+
328
+ 'cascader' = 'cascader',
329
+
330
+ /**
331
+
332
+ \* @description: 日期选择器
333
+
334
+ */
335
+
336
+ 'date-picker' = 'date-picker',
337
+
338
+ /**
339
+
340
+ \* @description: 数字输入框
341
+
342
+ */
343
+
344
+ 'input-number' = 'input-number',
345
+
215
346
  安装:npm i general-basic-form<br/>
216
- install: npm i general-basic-form
347
+ install: npm i general-basic-form
package/dist/index.mjs CHANGED
@@ -1,17 +1,73 @@
1
- import { resolveComponent as u, withDirectives as x, openBlock as a, createBlock as s, mergeProps as c, withCtx as p, createElementBlock as g, Fragment as P, renderList as m, withKeys as B, createSlots as C, resolveDynamicComponent as F, createCommentVNode as i, renderSlot as I, createVNode as k, createTextVNode as V, vShow as Q } from "vue";
2
- const D = (r, n) => {
3
- const t = r.__vccOpts || r;
4
- for (const [h, l] of n)
5
- t[h] = l;
6
- return t;
7
- }, G = {
8
- name: "GeneralBasicForm",
1
+ import { defineComponent as v, resolveComponent as u, openBlock as n, createBlock as s, mergeProps as c, withKeys as C, createSlots as F, renderList as g, withCtx as i, resolveDynamicComponent as B, createCommentVNode as d, withDirectives as I, createElementBlock as _, Fragment as z, renderSlot as L, createVNode as k, createTextVNode as V, vShow as O } from "vue";
2
+ const Q = v({
9
3
  components: {
10
- InputArchive: (r) => {
11
- const { templateEle: n } = r;
12
- return n();
4
+ InputArchive: (e) => {
5
+ const { templateEle: l } = e;
6
+ return l();
7
+ }
8
+ },
9
+ props: {
10
+ item: null,
11
+ // null就是any
12
+ queryParams: { type: [Object, String], required: !0 },
13
+ getList: { type: Function, required: !0 },
14
+ size: { type: String, required: !0 }
15
+ },
16
+ data() {
17
+ return {
18
+ inputSetting: {
19
+ placeholder: "请输入",
20
+ style: "width: 200px",
21
+ clearable: !0
22
+ }
23
+ };
24
+ },
25
+ created() {
26
+ console.log("new");
27
+ },
28
+ methods: {
29
+ currentInputComponent() {
30
+ return "input-archive";
13
31
  }
14
32
  },
33
+ watch: {
34
+ item(e) {
35
+ console.log(e);
36
+ },
37
+ size(e) {
38
+ console.log(e);
39
+ }
40
+ }
41
+ }), S = (e, l) => {
42
+ const r = e.__vccOpts || e;
43
+ for (const [y, o] of l)
44
+ r[y] = o;
45
+ return r;
46
+ };
47
+ function D(e, l, r, y, o, h) {
48
+ const f = u("el-input");
49
+ return n(), s(f, c({
50
+ onKeydown: C(e.getList, ["enter"]),
51
+ modelValue: e.queryParams[e.item.prop],
52
+ "onUpdate:modelValue": l[0] || (l[0] = (p) => e.queryParams[e.item.prop] = p),
53
+ size: e.size
54
+ }, e.item.inputSetting || e.inputSetting), F({ _: 2 }, [
55
+ g(e.item.template, (p, m) => ({
56
+ name: m,
57
+ fn: i(() => [
58
+ p ? (n(), s(B(e.currentInputComponent()), {
59
+ key: m,
60
+ templateEle: p
61
+ }, null, 8, ["templateEle"])) : d("", !0)
62
+ ])
63
+ }))
64
+ ]), 1040, ["onKeydown", "modelValue", "size"]);
65
+ }
66
+ const R = /* @__PURE__ */ S(Q, [["render", D]]), G = {
67
+ name: "GeneralBasicForm",
68
+ components: {
69
+ Input: R
70
+ },
15
71
  props: {
16
72
  showSearch: {
17
73
  // 是否展示所有元素
@@ -63,10 +119,10 @@ const D = (r, n) => {
63
119
  }
64
120
  },
65
121
  data() {
66
- var r;
122
+ var e;
67
123
  return {
68
124
  queryParams: {
69
- ...this.noUrlParameters ? {} : (r = this.$route) == null ? void 0 : r.query
125
+ ...this.noUrlParameters ? {} : (e = this.$route) == null ? void 0 : e.query
70
126
  },
71
127
  // form表单数据
72
128
  selectSetting: {
@@ -74,11 +130,6 @@ const D = (r, n) => {
74
130
  clearable: !0,
75
131
  style: "width: 200px"
76
132
  },
77
- inputSetting: {
78
- placeholder: "请输入",
79
- style: "width: 200px",
80
- clearable: !0
81
- },
82
133
  datePackerSetting: {
83
134
  style: "width: 227px",
84
135
  "start-placeholder": "开始日期",
@@ -102,151 +153,115 @@ const D = (r, n) => {
102
153
  // };
103
154
  // },
104
155
  watch: {
105
- formData(r) {
156
+ formData(e) {
106
157
  this.queryParams = {
107
158
  ...this.noUrlParameters ? {} : this.queryParams,
108
- ...r
159
+ ...e
109
160
  };
110
161
  }
111
162
  },
112
163
  methods: {
113
164
  /** 搜索按钮操作 */
114
165
  handleQuery() {
115
- var t;
116
- const r = { page: 1, limit: 10 }, n = {
117
- ...(t = this.$route) == null ? void 0 : t.query,
166
+ var r;
167
+ const e = { page: 1, limit: 10 }, l = {
168
+ ...(r = this.$route) == null ? void 0 : r.query,
118
169
  ...this.queryParams,
119
- ...r
170
+ ...e
120
171
  };
121
172
  this.noUrlParameters || this.$router.push({
122
- query: { ...n }
173
+ query: { ...l }
123
174
  }), this.getList({
124
- ...n
175
+ ...l
125
176
  });
126
177
  },
127
178
  /** 重置按钮操作 */
128
179
  async resetQuery() {
129
- var n;
180
+ var l;
130
181
  this.$refs.queryFormRef.resetFields();
131
- const r = { page: 1 };
182
+ const e = { page: 1 };
132
183
  this.noUrlParameters || await this.$router.push({
133
- query: { ...r }
184
+ query: { ...e }
134
185
  }), this.queryParams = {
135
- ...this.noUrlParameters ? {} : (n = this.$route) == null ? void 0 : n.query
186
+ ...this.noUrlParameters ? {} : (l = this.$route) == null ? void 0 : l.query
136
187
  }, this.afterReset(), this.handleQuery();
137
- },
138
- currentInputComponent() {
139
- return "input-archive";
140
188
  }
141
189
  }
142
- };
143
- function L(r, n, t, h, l, d) {
144
- const q = u("el-input"), z = u("el-option"), b = u("el-select"), S = u("el-cascader"), v = u("el-date-picker"), U = u("el-input-number"), y = u("el-form-item"), _ = u("el-button"), w = u("el-form");
145
- return x((a(), s(w, c({
146
- model: l.queryParams,
190
+ }, K = { key: 0 };
191
+ function N(e, l, r, y, o, h) {
192
+ const f = u("el-option"), p = u("el-select"), m = u("el-cascader"), b = u("el-date-picker"), w = u("el-input-number"), P = u("el-form-item"), q = u("el-button"), U = u("el-form");
193
+ return I((n(), s(U, c({
194
+ model: o.queryParams,
147
195
  ref: "queryFormRef",
148
196
  inline: "",
149
197
  "label-position": "left",
150
- "label-width": t.labelWidth
151
- }, r.$attrs), {
152
- default: p(() => [
153
- (a(!0), g(P, null, m(t.formItem, (e) => (a(), s(y, {
154
- label: e.label,
155
- prop: e.prop,
156
- key: e.prop,
157
- rules: e.rules
198
+ "label-width": r.labelWidth
199
+ }, e.$attrs), {
200
+ default: i(() => [
201
+ (n(!0), _(z, null, g(r.formItem, (t) => (n(), s(P, {
202
+ label: t.label,
203
+ prop: t.prop,
204
+ key: t.prop,
205
+ rules: t.rules
158
206
  }, {
159
- default: p(() => [
160
- e.type === "input" ? (a(), s(q, c({
161
- key: 0,
162
- onKeydown: B(t.getList, ["enter"]),
163
- modelValue: l.queryParams[e.prop],
164
- "onUpdate:modelValue": (o) => l.queryParams[e.prop] = o,
165
- size: t.size
166
- }, l.inputSetting, {
167
- placeholder: e.placeholder || l.inputSetting.placeholder,
168
- maxlength: e.maxlength
169
- }), C({ _: 2 }, [
170
- m(e.template, (o, f) => ({
171
- name: f,
172
- fn: p(() => [
173
- o ? (a(), s(F(d.currentInputComponent()), {
174
- key: f,
175
- templateEle: o
176
- }, null, 8, ["templateEle"])) : i("", !0)
177
- ])
178
- }))
179
- ]), 1040, ["onKeydown", "modelValue", "onUpdate:modelValue", "size", "placeholder", "maxlength"])) : e.type === "select" ? (a(), s(b, c({
207
+ default: i(() => [
208
+ t.type === "input" ? (n(), _("div", K)) : t.type === "select" ? (n(), s(p, c({
180
209
  key: 1,
181
210
  filterable: "",
182
- modelValue: l.queryParams[e.prop],
183
- "onUpdate:modelValue": (o) => l.queryParams[e.prop] = o,
184
- size: t.size
185
- }, l.selectSetting, {
186
- multiple: e.multiple,
187
- placeholder: e.placeholder || l.selectSetting.placeholder
188
- }), {
189
- default: p(() => [
190
- (a(!0), g(P, null, m(e.option || [], (o) => (a(), s(z, {
191
- key: o.value,
192
- label: o.desc,
193
- value: o.value
211
+ modelValue: o.queryParams[t.prop],
212
+ "onUpdate:modelValue": (a) => o.queryParams[t.prop] = a,
213
+ size: r.size
214
+ }, t.selectSetting || o.selectSetting), {
215
+ default: i(() => [
216
+ (n(!0), _(z, null, g(t.option || [], (a) => (n(), s(f, {
217
+ key: a.value,
218
+ label: a.desc,
219
+ value: a.value
194
220
  }, null, 8, ["label", "value"]))), 128))
195
221
  ]),
196
222
  _: 2
197
- }, 1040, ["modelValue", "onUpdate:modelValue", "size", "multiple", "placeholder"])) : e.type === "cascader" ? (a(), s(S, c({
223
+ }, 1040, ["modelValue", "onUpdate:modelValue", "size"])) : t.type === "cascader" ? (n(), s(m, c({
198
224
  key: 2,
199
225
  filterable: "",
200
- modelValue: l.queryParams[e.prop],
201
- "onUpdate:modelValue": (o) => l.queryParams[e.prop] = o,
202
- size: t.size
203
- }, l.selectSetting, {
204
- options: e.options || [],
205
- placeholder: e.placeholder || l.selectSetting.placeholder
206
- }), null, 16, ["modelValue", "onUpdate:modelValue", "size", "options", "placeholder"])) : e.type === "date-picker" ? (a(), s(v, c({
226
+ modelValue: o.queryParams[t.prop],
227
+ "onUpdate:modelValue": (a) => o.queryParams[t.prop] = a,
228
+ size: r.size,
229
+ options: t.options || []
230
+ }, t.selectSetting || o.selectSetting), null, 16, ["modelValue", "onUpdate:modelValue", "size", "options"])) : t.type === "date-picker" ? (n(), s(b, c({
207
231
  key: 3,
208
- modelValue: l.queryParams[e.prop],
209
- "onUpdate:modelValue": (o) => l.queryParams[e.prop] = o,
210
- size: t.size
211
- }, l.datePackerSetting, {
212
- "start-placeholder": e["start-placeholder"] || l.datePackerSetting["start-placeholder"],
213
- "end-placeholder": e["end-placeholder"] || l.datePackerSetting["end-placeholder"],
214
- "value-format": e["value-format"]
215
- }), null, 16, ["modelValue", "onUpdate:modelValue", "size", "start-placeholder", "end-placeholder", "value-format"])) : i("", !0),
216
- e.type === "input-number" ? (a(), s(U, c({
232
+ modelValue: o.queryParams[t.prop],
233
+ "onUpdate:modelValue": (a) => o.queryParams[t.prop] = a,
234
+ size: r.size
235
+ }, t.datePackerSetting || o.datePackerSetting), null, 16, ["modelValue", "onUpdate:modelValue", "size"])) : d("", !0),
236
+ t.type === "input-number" ? (n(), s(w, c({
217
237
  key: 4,
218
- modelValue: l.queryParams[e.prop],
219
- "onUpdate:modelValue": (o) => l.queryParams[e.prop] = o,
220
- size: t.size
221
- }, l.inputSetting, {
222
- min: e.min,
223
- max: e.max,
224
- "controls-position": e["controls-position"],
225
- "step-strictly": e["step-strictly"]
226
- }), null, 16, ["modelValue", "onUpdate:modelValue", "size", "min", "max", "controls-position", "step-strictly"])) : i("", !0)
238
+ modelValue: o.queryParams[t.prop],
239
+ "onUpdate:modelValue": (a) => o.queryParams[t.prop] = a,
240
+ size: r.size
241
+ }, t.inputSetting || e.inputSetting), null, 16, ["modelValue", "onUpdate:modelValue", "size"])) : d("", !0)
227
242
  ]),
228
243
  _: 2
229
244
  }, 1032, ["label", "prop", "rules"]))), 128)),
230
- I(r.$slots, "default", {}, void 0, !0),
231
- t.formOnly ? i("", !0) : (a(), s(y, { key: 0 }, {
232
- default: p(() => [
233
- k(_, {
245
+ L(e.$slots, "default"),
246
+ r.formOnly ? d("", !0) : (n(), s(P, { key: 0 }, {
247
+ default: i(() => [
248
+ k(q, {
234
249
  type: "primary",
235
250
  icon: "el-icon-search",
236
- size: t.size,
237
- onClick: d.handleQuery
251
+ size: r.size,
252
+ onClick: h.handleQuery
238
253
  }, {
239
- default: p(() => [
254
+ default: i(() => [
240
255
  V("查询")
241
256
  ]),
242
257
  _: 1
243
258
  }, 8, ["size", "onClick"]),
244
- k(_, {
259
+ k(q, {
245
260
  icon: "el-icon-refresh",
246
- size: t.size,
247
- onClick: d.resetQuery
261
+ size: r.size,
262
+ onClick: h.resetQuery
248
263
  }, {
249
- default: p(() => [
264
+ default: i(() => [
250
265
  V("重置")
251
266
  ]),
252
267
  _: 1
@@ -257,10 +272,10 @@ function L(r, n, t, h, l, d) {
257
272
  ]),
258
273
  _: 3
259
274
  }, 16, ["model", "label-width"])), [
260
- [Q, t.showSearch]
275
+ [O, r.showSearch]
261
276
  ]);
262
277
  }
263
- const O = /* @__PURE__ */ D(G, [["render", L], ["__scopeId", "data-v-279f95d9"]]), E = O;
278
+ const j = /* @__PURE__ */ S(G, [["render", N]]), E = j;
264
279
  export {
265
280
  E as VGeneralBasicForm
266
281
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(s,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(s=typeof globalThis<"u"?globalThis:s||self,e(s.Index={},s.Vue))})(this,function(s,e){"use strict";const q="",u=(r,a)=>{const l=r.__vccOpts||r;for(const[p,o]of a)l[p]=o;return l},h={name:"GeneralBasicForm",components:{InputArchive:r=>{const{templateEle:a}=r;return a()}},props:{showSearch:{type:Boolean,default:!0},formOnly:{type:Boolean,default:!1},getList:{type:Function,default:()=>{}},afterReset:{type:Function,default:()=>{}},formItem:{type:Array,default:[]},size:{type:String,default:"medium"},labelWidth:{type:String,default:"90px"},noUrlParameters:{type:Boolean,default:()=>!1},formData:{type:Object,default:()=>{}}},data(){var r;return{queryParams:{...this.noUrlParameters?{}:(r=this.$route)==null?void 0:r.query},selectSetting:{placeholder:"请选择",clearable:!0,style:"width: 200px"},inputSetting:{placeholder:"请输入",style:"width: 200px",clearable:!0},datePackerSetting:{style:"width: 227px","start-placeholder":"开始日期","end-placeholder":"结束日期",type:"daterange"}}},watch:{formData(r){this.queryParams={...this.noUrlParameters?{}:this.queryParams,...r}}},methods:{handleQuery(){var l;const r={page:1,limit:10},a={...(l=this.$route)==null?void 0:l.query,...this.queryParams,...r};this.noUrlParameters||this.$router.push({query:{...a}}),this.getList({...a})},async resetQuery(){var a;this.$refs.queryFormRef.resetFields();const r={page:1};this.noUrlParameters||await this.$router.push({query:{...r}}),this.queryParams={...this.noUrlParameters?{}:(a=this.$route)==null?void 0:a.query},this.afterReset(),this.handleQuery()},currentInputComponent(){return"input-archive"}}};function y(r,a,l,p,o,c){const _=e.resolveComponent("el-input"),k=e.resolveComponent("el-option"),g=e.resolveComponent("el-select"),P=e.resolveComponent("el-cascader"),B=e.resolveComponent("el-date-picker"),V=e.resolveComponent("el-input-number"),i=e.resolveComponent("el-form-item"),d=e.resolveComponent("el-button"),C=e.resolveComponent("el-form");return e.withDirectives((e.openBlock(),e.createBlock(C,e.mergeProps({model:o.queryParams,ref:"queryFormRef",inline:"","label-position":"left","label-width":l.labelWidth},r.$attrs),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.formItem,t=>(e.openBlock(),e.createBlock(i,{label:t.label,prop:t.prop,key:t.prop,rules:t.rules},{default:e.withCtx(()=>[t.type==="input"?(e.openBlock(),e.createBlock(_,e.mergeProps({key:0,onKeydown:e.withKeys(l.getList,["enter"]),modelValue:o.queryParams[t.prop],"onUpdate:modelValue":n=>o.queryParams[t.prop]=n,size:l.size},o.inputSetting,{placeholder:t.placeholder||o.inputSetting.placeholder,maxlength:t.maxlength}),e.createSlots({_:2},[e.renderList(t.template,(n,m)=>({name:m,fn:e.withCtx(()=>[n?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(c.currentInputComponent()),{key:m,templateEle:n},null,8,["templateEle"])):e.createCommentVNode("",!0)])}))]),1040,["onKeydown","modelValue","onUpdate:modelValue","size","placeholder","maxlength"])):t.type==="select"?(e.openBlock(),e.createBlock(g,e.mergeProps({key:1,filterable:"",modelValue:o.queryParams[t.prop],"onUpdate:modelValue":n=>o.queryParams[t.prop]=n,size:l.size},o.selectSetting,{multiple:t.multiple,placeholder:t.placeholder||o.selectSetting.placeholder}),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.option||[],n=>(e.openBlock(),e.createBlock(k,{key:n.value,label:n.desc,value:n.value},null,8,["label","value"]))),128))]),_:2},1040,["modelValue","onUpdate:modelValue","size","multiple","placeholder"])):t.type==="cascader"?(e.openBlock(),e.createBlock(P,e.mergeProps({key:2,filterable:"",modelValue:o.queryParams[t.prop],"onUpdate:modelValue":n=>o.queryParams[t.prop]=n,size:l.size},o.selectSetting,{options:t.options||[],placeholder:t.placeholder||o.selectSetting.placeholder}),null,16,["modelValue","onUpdate:modelValue","size","options","placeholder"])):t.type==="date-picker"?(e.openBlock(),e.createBlock(B,e.mergeProps({key:3,modelValue:o.queryParams[t.prop],"onUpdate:modelValue":n=>o.queryParams[t.prop]=n,size:l.size},o.datePackerSetting,{"start-placeholder":t["start-placeholder"]||o.datePackerSetting["start-placeholder"],"end-placeholder":t["end-placeholder"]||o.datePackerSetting["end-placeholder"],"value-format":t["value-format"]}),null,16,["modelValue","onUpdate:modelValue","size","start-placeholder","end-placeholder","value-format"])):e.createCommentVNode("",!0),t.type==="input-number"?(e.openBlock(),e.createBlock(V,e.mergeProps({key:4,modelValue:o.queryParams[t.prop],"onUpdate:modelValue":n=>o.queryParams[t.prop]=n,size:l.size},o.inputSetting,{min:t.min,max:t.max,"controls-position":t["controls-position"],"step-strictly":t["step-strictly"]}),null,16,["modelValue","onUpdate:modelValue","size","min","max","controls-position","step-strictly"])):e.createCommentVNode("",!0)]),_:2},1032,["label","prop","rules"]))),128)),e.renderSlot(r.$slots,"default",{},void 0,!0),l.formOnly?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(i,{key:0},{default:e.withCtx(()=>[e.createVNode(d,{type:"primary",icon:"el-icon-search",size:l.size,onClick:c.handleQuery},{default:e.withCtx(()=>[e.createTextVNode("查询")]),_:1},8,["size","onClick"]),e.createVNode(d,{icon:"el-icon-refresh",size:l.size,onClick:c.resetQuery},{default:e.withCtx(()=>[e.createTextVNode("重置")]),_:1},8,["size","onClick"])]),_:1}))]),_:3},16,["model","label-width"])),[[e.vShow,l.showSearch]])}const f=u(h,[["render",y],["__scopeId","data-v-279f95d9"]]);s.VGeneralBasicForm=f,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
1
+ (function(s,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(s=typeof globalThis<"u"?globalThis:s||self,e(s.Index={},s.Vue))})(this,function(s,e){"use strict";const h=e.defineComponent({components:{InputArchive:t=>{const{templateEle:l}=t;return l()}},props:{item:null,queryParams:{type:[Object,String],required:!0},getList:{type:Function,required:!0},size:{type:String,required:!0}},data(){return{inputSetting:{placeholder:"请输入",style:"width: 200px",clearable:!0}}},created(){console.log("new")},methods:{currentInputComponent(){return"input-archive"}},watch:{item(t){console.log(t)},size(t){console.log(t)}}}),u=(t,l)=>{const r=t.__vccOpts||t;for(const[p,n]of l)r[p]=n;return r};function k(t,l,r,p,n,m){const d=e.resolveComponent("el-input");return e.openBlock(),e.createBlock(d,e.mergeProps({onKeydown:e.withKeys(t.getList,["enter"]),modelValue:t.queryParams[t.item.prop],"onUpdate:modelValue":l[0]||(l[0]=i=>t.queryParams[t.item.prop]=i),size:t.size},t.item.inputSetting||t.inputSetting),e.createSlots({_:2},[e.renderList(t.item.template,(i,c)=>({name:c,fn:e.withCtx(()=>[i?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.currentInputComponent()),{key:c,templateEle:i},null,8,["templateEle"])):e.createCommentVNode("",!0)])}))]),1040,["onKeydown","modelValue","size"])}const _={name:"GeneralBasicForm",components:{Input:u(h,[["render",k]])},props:{showSearch:{type:Boolean,default:!0},formOnly:{type:Boolean,default:!1},getList:{type:Function,default:()=>{}},afterReset:{type:Function,default:()=>{}},formItem:{type:Array,default:[]},size:{type:String,default:"medium"},labelWidth:{type:String,default:"90px"},noUrlParameters:{type:Boolean,default:()=>!1},formData:{type:Object,default:()=>{}}},data(){var t;return{queryParams:{...this.noUrlParameters?{}:(t=this.$route)==null?void 0:t.query},selectSetting:{placeholder:"请选择",clearable:!0,style:"width: 200px"},datePackerSetting:{style:"width: 227px","start-placeholder":"开始日期","end-placeholder":"结束日期",type:"daterange"}}},watch:{formData(t){this.queryParams={...this.noUrlParameters?{}:this.queryParams,...t}}},methods:{handleQuery(){var r;const t={page:1,limit:10},l={...(r=this.$route)==null?void 0:r.query,...this.queryParams,...t};this.noUrlParameters||this.$router.push({query:{...l}}),this.getList({...l})},async resetQuery(){var l;this.$refs.queryFormRef.resetFields();const t={page:1};this.noUrlParameters||await this.$router.push({query:{...t}}),this.queryParams={...this.noUrlParameters?{}:(l=this.$route)==null?void 0:l.query},this.afterReset(),this.handleQuery()}}},g={key:0};function B(t,l,r,p,n,m){const d=e.resolveComponent("el-option"),i=e.resolveComponent("el-select"),c=e.resolveComponent("el-cascader"),V=e.resolveComponent("el-date-picker"),q=e.resolveComponent("el-input-number"),y=e.resolveComponent("el-form-item"),f=e.resolveComponent("el-button"),C=e.resolveComponent("el-form");return e.withDirectives((e.openBlock(),e.createBlock(C,e.mergeProps({model:n.queryParams,ref:"queryFormRef",inline:"","label-position":"left","label-width":r.labelWidth},t.$attrs),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.formItem,o=>(e.openBlock(),e.createBlock(y,{label:o.label,prop:o.prop,key:o.prop,rules:o.rules},{default:e.withCtx(()=>[o.type==="input"?(e.openBlock(),e.createElementBlock("div",g)):o.type==="select"?(e.openBlock(),e.createBlock(i,e.mergeProps({key:1,filterable:"",modelValue:n.queryParams[o.prop],"onUpdate:modelValue":a=>n.queryParams[o.prop]=a,size:r.size},o.selectSetting||n.selectSetting),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.option||[],a=>(e.openBlock(),e.createBlock(d,{key:a.value,label:a.desc,value:a.value},null,8,["label","value"]))),128))]),_:2},1040,["modelValue","onUpdate:modelValue","size"])):o.type==="cascader"?(e.openBlock(),e.createBlock(c,e.mergeProps({key:2,filterable:"",modelValue:n.queryParams[o.prop],"onUpdate:modelValue":a=>n.queryParams[o.prop]=a,size:r.size,options:o.options||[]},o.selectSetting||n.selectSetting),null,16,["modelValue","onUpdate:modelValue","size","options"])):o.type==="date-picker"?(e.openBlock(),e.createBlock(V,e.mergeProps({key:3,modelValue:n.queryParams[o.prop],"onUpdate:modelValue":a=>n.queryParams[o.prop]=a,size:r.size},o.datePackerSetting||n.datePackerSetting),null,16,["modelValue","onUpdate:modelValue","size"])):e.createCommentVNode("",!0),o.type==="input-number"?(e.openBlock(),e.createBlock(q,e.mergeProps({key:4,modelValue:n.queryParams[o.prop],"onUpdate:modelValue":a=>n.queryParams[o.prop]=a,size:r.size},o.inputSetting||t.inputSetting),null,16,["modelValue","onUpdate:modelValue","size"])):e.createCommentVNode("",!0)]),_:2},1032,["label","prop","rules"]))),128)),e.renderSlot(t.$slots,"default"),r.formOnly?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(y,{key:0},{default:e.withCtx(()=>[e.createVNode(f,{type:"primary",icon:"el-icon-search",size:r.size,onClick:m.handleQuery},{default:e.withCtx(()=>[e.createTextVNode("查询")]),_:1},8,["size","onClick"]),e.createVNode(f,{icon:"el-icon-refresh",size:r.size,onClick:m.resetQuery},{default:e.withCtx(()=>[e.createTextVNode("重置")]),_:1},8,["size","onClick"])]),_:1}))]),_:3},16,["model","label-width"])),[[e.vShow,r.showSearch]])}const P=u(_,[["render",B]]);s.VGeneralBasicForm=P,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,48 +1,57 @@
1
- {
2
- "name": "general-basic-form",
3
- "version": "2.0.1",
4
- "description": "",
5
- "files": [
6
- "/dist"
7
- ],
8
- "main": "./dist/index.umd.js",
9
- "module": "./dist/index.mjs",
10
- "exports": {
11
- ".": {
12
- "import": "./dist/index.mjs",
13
- "require": "./dist/index.umd.js"
14
- }
15
- },
16
- "types": "./dist/index.d.ts",
17
- "scripts": {
18
- "build": "cross-env CURRENT_ENV=prod run-p type-check build-only",
19
- "test:e2e": "playwright test",
20
- "build-only": "vite build",
21
- "type-check": "tsc --noEmit -p tsconfig.json --composite false"
22
- },
23
- "keywords": [
24
- "general-basic-form",
25
- "form",
26
- "vue",
27
- "vue2",
28
- "vue3",
29
- "element-plus"
30
- ],
31
- "author": "chendeli419287484@qq.com",
32
- "license": "ISC",
33
- "repository": {
34
- "type": "git",
35
- "url": "git+https://github.com/Alan1034/GeneralBasicForm.git"
36
- },
37
- "devDependencies": {
38
- "@playwright/test": "^1.36.1",
39
- "@types/node": "^20.8.10",
40
- "@vitejs/plugin-legacy": "^4.1.1",
41
- "@vitejs/plugin-vue": "^4.2.3",
42
- "@vitejs/plugin-vue-jsx": "^3.0.1",
43
- "cross-env": "^7.0.3",
44
- "npm-run-all": "^4.1.5",
45
- "typescript": "^5.2.2",
46
- "vite-plugin-image-optimizer": "^1.1.6"
47
- }
48
- }
1
+ {
2
+ "name": "general-basic-form",
3
+ "version": "2.0.3",
4
+ "description": "",
5
+ "main": "./dist/index.umd.js",
6
+ "scripts": {
7
+ "build": "cross-env CURRENT_ENV=prod run-p type-check build-only",
8
+ "test:e2e": "playwright test",
9
+ "build-only": "vite build",
10
+ "type-check": "tsc --noEmit -p tsconfig.json --composite false",
11
+ "link": "tsx script/link.ts && yarn link",
12
+ "unlink": "tsx script/unlink.ts && yarn unlink"
13
+ },
14
+ "keywords": [
15
+ "general-basic-form",
16
+ "form",
17
+ "vue",
18
+ "vue2",
19
+ "vue3",
20
+ "element-plus"
21
+ ],
22
+ "author": "chendeli419287484@qq.com",
23
+ "license": "ISC",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/Alan1034/GeneralBasicForm.git"
27
+ },
28
+ "devDependencies": {
29
+ "@playwright/test": "^1.36.1",
30
+ "@types/node": "^20.8.10",
31
+ "@vitejs/plugin-legacy": "^4.1.1",
32
+ "@vitejs/plugin-vue": "^4.2.3",
33
+ "@vitejs/plugin-vue-jsx": "^3.0.1",
34
+ "cross-env": "^7.0.3",
35
+ "chalk": "^2.4.2",
36
+ "npm-run-all": "^4.1.5",
37
+ "tsx": "^4.0.0",
38
+ "typescript": "^5.2.2",
39
+ "vite-plugin-image-optimizer": "^1.1.6"
40
+ },
41
+ "peerDependencies": {
42
+ "element-plus": ">=2.4.2",
43
+ "vue": ">=3.3.4",
44
+ "vue-router": ">=4.2.4"
45
+ },
46
+ "module": "./dist/index.mjs",
47
+ "exports": {
48
+ ".": {
49
+ "import": "./dist/index.mjs",
50
+ "require": "./dist/index.umd.js"
51
+ }
52
+ },
53
+ "typings": "./dist/index.d.ts",
54
+ "files": [
55
+ "/dist"
56
+ ]
57
+ }
package/dist/style.css DELETED
@@ -1 +0,0 @@
1
- .el-form-item[data-v-279f95d9]{margin-bottom:2px!important}