general-basic-form 1.0.26 → 2.0.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.
- package/README.md +216 -203
- package/dist/index.d.ts +17 -0
- package/dist/index.mjs +266 -0
- package/dist/index.umd.js +1 -0
- package/dist/style.css +1 -0
- package/package.json +48 -32
- package/README.assets/image-20210820173738506.png +0 -0
- package/config/webpack.common.js +0 -98
- package/config/webpack.dev.js +0 -15
- package/config/webpack.prod.js +0 -16
- package/src/GeneralBasicForm.vue +0 -258
- package/src/assets/image-20210820173037871.png +0 -0
- package/src/assets/logo.png +0 -0
- package/src/index.js +0 -12
package/README.md
CHANGED
|
@@ -1,203 +1,216 @@
|
|
|
1
|
-
# GeneralBasicForm
|
|
2
|
-
|
|
3
|
-
一个兼容 Vue2 和 Vue3 的表单组件 <br/>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
1
|
+
# GeneralBasicForm
|
|
2
|
+
|
|
3
|
+
一个兼容 Vue2 和 Vue3 的表单组件 <br/>
|
|
4
|
+
|
|
5
|
+
示例:
|
|
6
|
+
|
|
7
|
+
因为兼容性问题,目前只能使用完整引入
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
import ElementPlus from 'element-plus'
|
|
11
|
+
import 'element-plus/dist/index.css'
|
|
12
|
+
app.use(ElementPlus)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
import GeneralBasicForm from 'general-basic-form'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
<GeneralBasicForm
|
|
20
|
+
:showSearch="showSearch"
|
|
21
|
+
:getList="getList"
|
|
22
|
+
:formItem="formItem"
|
|
23
|
+
:size="size"
|
|
24
|
+
ref="generalBasicForm"
|
|
25
|
+
labelWidth="90px"
|
|
26
|
+
>
|
|
27
|
+
...一些传入插槽的内容
|
|
28
|
+
</GeneralBasicForm>
|
|
29
|
+
|
|
30
|
+

|
|
31
|
+
|
|
32
|
+
在单纯作为表单的时候可以这样使用:
|
|
33
|
+
|
|
34
|
+
<GeneralBasicForm
|
|
35
|
+
formOnly
|
|
36
|
+
:formItem="formItem"
|
|
37
|
+
size="small"
|
|
38
|
+
ref="generalBasicForm"
|
|
39
|
+
:labelWidth="formLabelWidth"
|
|
40
|
+
:formData: {
|
|
41
|
+
// 外部传入的表单数据,用于回填
|
|
42
|
+
}
|
|
43
|
+
noUrlParameters
|
|
44
|
+
:afterReset="afterReset"
|
|
45
|
+
/>
|
|
46
|
+
|
|
47
|
+
<style lang="scss" scoped>
|
|
48
|
+
:deep {
|
|
49
|
+
.el-form-item {
|
|
50
|
+
margin-bottom: 22px;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
</style>
|
|
54
|
+
|
|
55
|
+
getList会传出默认的参数,首次请求时会有页数和分页大小,重置后会传出默认页数1
|
|
56
|
+
|
|
57
|
+
async getList(
|
|
58
|
+
params = {
|
|
59
|
+
page: Number(this.$route.query.page) || 1,
|
|
60
|
+
limit: Number(this.$route.query.limit) || 10,
|
|
61
|
+
}
|
|
62
|
+
) {}
|
|
63
|
+
|
|
64
|
+
表单数据校验需要拿到内部表单的ref
|
|
65
|
+
|
|
66
|
+
this.$refs["generalBasicForm"].$refs["queryFormRef"]
|
|
67
|
+
.validate(
|
|
68
|
+
async (valid) => {
|
|
69
|
+
if (valid) {
|
|
70
|
+
console.log(this.$refs["generalBasicForm"]["queryParams"]);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+

|
|
77
|
+
|
|
78
|
+
数据示例:
|
|
79
|
+
|
|
80
|
+
showSearch: true, // 显示搜索条件
|
|
81
|
+
getList(); // 请求数据的函数
|
|
82
|
+
afterReset(); // 在重置按钮点击完后但还没重新请求时触发的的函数
|
|
83
|
+
formOnly:true // 只展示表单不展示按钮
|
|
84
|
+
noUrlParameters:true // 不接受和不改变url的参数
|
|
85
|
+
formItem: [
|
|
86
|
+
{ label: "款式名称",
|
|
87
|
+
prop: "bsName",
|
|
88
|
+
type: "input",
|
|
89
|
+
placeholder: "请输入图片名称/分类名称/图片标签",
|
|
90
|
+
rules: [
|
|
91
|
+
{
|
|
92
|
+
message: "请输入信息"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
pattern: /^\w+[\,\,\-\w' '#]+$/,
|
|
96
|
+
message: "请输入正确的Invoice单号"
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
template: {
|
|
100
|
+
suffix: () => {
|
|
101
|
+
return <svg-icon icon-class="baifenbi" />;
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
maxlength: "3000"},
|
|
105
|
+
{
|
|
106
|
+
label: "二次工艺",
|
|
107
|
+
prop: "spName",
|
|
108
|
+
type: "select",
|
|
109
|
+
multiple:true, //多选
|
|
110
|
+
option: [
|
|
111
|
+
{ value: "3", desc: "满印" },
|
|
112
|
+
{ value: "1", desc: "区域印花" },
|
|
113
|
+
{ value: "2", desc: "绣花" },
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
label: "创建时间",
|
|
118
|
+
prop: "create_time",
|
|
119
|
+
type: "date-picker",
|
|
120
|
+
"value-format": "yyyyMMdd"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
label: "二次工艺成本价格(人民币分)",
|
|
124
|
+
prop: "spCost",
|
|
125
|
+
type: "input-number",
|
|
126
|
+
"controls-position": "right",
|
|
127
|
+
min: 0,
|
|
128
|
+
rules: [
|
|
129
|
+
{
|
|
130
|
+
required: true,
|
|
131
|
+
message: "请输入二次工艺成本价格",
|
|
132
|
+
trigger: "blur",
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
label: "分类",
|
|
138
|
+
prop: "分类",
|
|
139
|
+
type: "cascader",
|
|
140
|
+
options: [
|
|
141
|
+
{
|
|
142
|
+
value: "zhinan",
|
|
143
|
+
label: "指南",
|
|
144
|
+
children: [
|
|
145
|
+
{
|
|
146
|
+
value: "shejiyuanze",
|
|
147
|
+
label: "设计原则",
|
|
148
|
+
children: [
|
|
149
|
+
{
|
|
150
|
+
value: "yizhi",
|
|
151
|
+
label: "一致",
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
value: "fankui",
|
|
155
|
+
label: "反馈",
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
value: "xiaolv",
|
|
159
|
+
label: "效率",
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
value: "kekong",
|
|
163
|
+
label: "可控",
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
value: "daohang",
|
|
169
|
+
label: "导航",
|
|
170
|
+
children: [
|
|
171
|
+
{
|
|
172
|
+
value: "cexiangdaohang",
|
|
173
|
+
label: "侧向导航",
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
value: "dingbudaohang",
|
|
177
|
+
label: "顶部导航",
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
value: "ziyuan",
|
|
185
|
+
label: "资源",
|
|
186
|
+
children: [
|
|
187
|
+
{
|
|
188
|
+
value: "axure",
|
|
189
|
+
label: "Axure Components",
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
value: "sketch",
|
|
193
|
+
label: "Sketch Templates",
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
value: "jiaohu",
|
|
197
|
+
label: "组件交互文档",
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
},
|
|
203
|
+
],
|
|
204
|
+
//分别支持input输入框,select单选框,date-picker日期选择器,cascader层级选择器 四种组件
|
|
205
|
+
|
|
206
|
+
//date-picker可以传入'start-placeholder'和'end-placeholder',其他组件支持placeholder传入
|
|
207
|
+
|
|
208
|
+
//rules为表单校验规则,每个组件都可以传入
|
|
209
|
+
|
|
210
|
+
//input支持template,支持以下几个属性:
|
|
211
|
+
//prefix 输入框头部内容,只对 type="text"(默认) 有效
|
|
212
|
+
//suffix 输入框尾部内容,只对 type="text" 有效
|
|
213
|
+
//prepend 输入框前置内容,只对 type="text" 有效
|
|
214
|
+
//append 输入框后置内容,只对 type="text" 有效
|
|
215
|
+
安装:npm i general-basic-form<br/>
|
|
216
|
+
install: npm i general-basic-form
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: 陈德立*******419287484@qq.com
|
|
3
|
+
* @Date: 2023-11-07 17:55:59
|
|
4
|
+
* @LastEditTime: 2023-11-08 10:24:14
|
|
5
|
+
* @LastEditors: 陈德立*******419287484@qq.com
|
|
6
|
+
* @Github: https://github.com/Alan1034
|
|
7
|
+
* @Description:
|
|
8
|
+
* @FilePath: \GeneralBasicForm\public\index.d.ts
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
/// <reference types="vite/client" />
|
|
12
|
+
declare module "*.vue" {
|
|
13
|
+
import { DefineComponent } from "vue"
|
|
14
|
+
const component: DefineComponent<{}, {}, any>
|
|
15
|
+
export default component
|
|
16
|
+
}
|
|
17
|
+
declare module "general-basic-form";
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
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",
|
|
9
|
+
components: {
|
|
10
|
+
InputArchive: (r) => {
|
|
11
|
+
const { templateEle: n } = r;
|
|
12
|
+
return n();
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
props: {
|
|
16
|
+
showSearch: {
|
|
17
|
+
// 是否展示所有元素
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: !0
|
|
20
|
+
},
|
|
21
|
+
formOnly: {
|
|
22
|
+
// 是否只展示表单不展示按钮
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: !1
|
|
25
|
+
},
|
|
26
|
+
getList: {
|
|
27
|
+
// 查找数据调用的函数
|
|
28
|
+
type: Function,
|
|
29
|
+
default: () => {
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
afterReset: {
|
|
33
|
+
// 在重置按钮点击完后但还没重新请求时触发的的函数
|
|
34
|
+
type: Function,
|
|
35
|
+
default: () => {
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
formItem: {
|
|
39
|
+
// 定义表单的数据
|
|
40
|
+
type: Array,
|
|
41
|
+
default: []
|
|
42
|
+
},
|
|
43
|
+
size: {
|
|
44
|
+
// 控制按钮大小
|
|
45
|
+
type: String,
|
|
46
|
+
default: "medium"
|
|
47
|
+
},
|
|
48
|
+
labelWidth: {
|
|
49
|
+
// 表单文字宽度
|
|
50
|
+
type: String,
|
|
51
|
+
default: "90px"
|
|
52
|
+
},
|
|
53
|
+
noUrlParameters: {
|
|
54
|
+
// 不接受和不改变url的参数
|
|
55
|
+
type: Boolean,
|
|
56
|
+
default: () => !1
|
|
57
|
+
},
|
|
58
|
+
formData: {
|
|
59
|
+
// 外部传入的表单数据,用于回填
|
|
60
|
+
type: Object,
|
|
61
|
+
default: () => {
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
data() {
|
|
66
|
+
var r;
|
|
67
|
+
return {
|
|
68
|
+
queryParams: {
|
|
69
|
+
...this.noUrlParameters ? {} : (r = this.$route) == null ? void 0 : r.query
|
|
70
|
+
},
|
|
71
|
+
// form表单数据
|
|
72
|
+
selectSetting: {
|
|
73
|
+
placeholder: "请选择",
|
|
74
|
+
clearable: !0,
|
|
75
|
+
style: "width: 200px"
|
|
76
|
+
},
|
|
77
|
+
inputSetting: {
|
|
78
|
+
placeholder: "请输入",
|
|
79
|
+
style: "width: 200px",
|
|
80
|
+
clearable: !0
|
|
81
|
+
},
|
|
82
|
+
datePackerSetting: {
|
|
83
|
+
style: "width: 227px",
|
|
84
|
+
"start-placeholder": "开始日期",
|
|
85
|
+
"end-placeholder": "结束日期",
|
|
86
|
+
type: "daterange"
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
// setup(props) {
|
|
91
|
+
//设置默认值
|
|
92
|
+
// console.log(props);
|
|
93
|
+
// // const { formItem } = toRefs(props);
|
|
94
|
+
// const { formItem } = props;
|
|
95
|
+
// console.log(formItem);
|
|
96
|
+
// const queryParams = {};
|
|
97
|
+
// formItem.forEach((item) => {
|
|
98
|
+
// queryParams[item.prop] = "";
|
|
99
|
+
// });
|
|
100
|
+
// return {
|
|
101
|
+
// queryParams,
|
|
102
|
+
// };
|
|
103
|
+
// },
|
|
104
|
+
watch: {
|
|
105
|
+
formData(r) {
|
|
106
|
+
this.queryParams = {
|
|
107
|
+
...this.noUrlParameters ? {} : this.queryParams,
|
|
108
|
+
...r
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
methods: {
|
|
113
|
+
/** 搜索按钮操作 */
|
|
114
|
+
handleQuery() {
|
|
115
|
+
var t;
|
|
116
|
+
const r = { page: 1, limit: 10 }, n = {
|
|
117
|
+
...(t = this.$route) == null ? void 0 : t.query,
|
|
118
|
+
...this.queryParams,
|
|
119
|
+
...r
|
|
120
|
+
};
|
|
121
|
+
this.noUrlParameters || this.$router.push({
|
|
122
|
+
query: { ...n }
|
|
123
|
+
}), this.getList({
|
|
124
|
+
...n
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
/** 重置按钮操作 */
|
|
128
|
+
async resetQuery() {
|
|
129
|
+
var n;
|
|
130
|
+
this.$refs.queryFormRef.resetFields();
|
|
131
|
+
const r = { page: 1 };
|
|
132
|
+
this.noUrlParameters || await this.$router.push({
|
|
133
|
+
query: { ...r }
|
|
134
|
+
}), this.queryParams = {
|
|
135
|
+
...this.noUrlParameters ? {} : (n = this.$route) == null ? void 0 : n.query
|
|
136
|
+
}, this.afterReset(), this.handleQuery();
|
|
137
|
+
},
|
|
138
|
+
currentInputComponent() {
|
|
139
|
+
return "input-archive";
|
|
140
|
+
}
|
|
141
|
+
}
|
|
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,
|
|
147
|
+
ref: "queryFormRef",
|
|
148
|
+
inline: "",
|
|
149
|
+
"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
|
|
158
|
+
}, {
|
|
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({
|
|
180
|
+
key: 1,
|
|
181
|
+
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
|
|
194
|
+
}, null, 8, ["label", "value"]))), 128))
|
|
195
|
+
]),
|
|
196
|
+
_: 2
|
|
197
|
+
}, 1040, ["modelValue", "onUpdate:modelValue", "size", "multiple", "placeholder"])) : e.type === "cascader" ? (a(), s(S, c({
|
|
198
|
+
key: 2,
|
|
199
|
+
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({
|
|
207
|
+
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({
|
|
217
|
+
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)
|
|
227
|
+
]),
|
|
228
|
+
_: 2
|
|
229
|
+
}, 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(_, {
|
|
234
|
+
type: "primary",
|
|
235
|
+
icon: "el-icon-search",
|
|
236
|
+
size: t.size,
|
|
237
|
+
onClick: d.handleQuery
|
|
238
|
+
}, {
|
|
239
|
+
default: p(() => [
|
|
240
|
+
V("查询")
|
|
241
|
+
]),
|
|
242
|
+
_: 1
|
|
243
|
+
}, 8, ["size", "onClick"]),
|
|
244
|
+
k(_, {
|
|
245
|
+
icon: "el-icon-refresh",
|
|
246
|
+
size: t.size,
|
|
247
|
+
onClick: d.resetQuery
|
|
248
|
+
}, {
|
|
249
|
+
default: p(() => [
|
|
250
|
+
V("重置")
|
|
251
|
+
]),
|
|
252
|
+
_: 1
|
|
253
|
+
}, 8, ["size", "onClick"])
|
|
254
|
+
]),
|
|
255
|
+
_: 1
|
|
256
|
+
}))
|
|
257
|
+
]),
|
|
258
|
+
_: 3
|
|
259
|
+
}, 16, ["model", "label-width"])), [
|
|
260
|
+
[Q, t.showSearch]
|
|
261
|
+
]);
|
|
262
|
+
}
|
|
263
|
+
const O = /* @__PURE__ */ D(G, [["render", L], ["__scopeId", "data-v-279f95d9"]]), E = O;
|
|
264
|
+
export {
|
|
265
|
+
E as VGeneralBasicForm
|
|
266
|
+
};
|
|
@@ -0,0 +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"})});
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.el-form-item[data-v-279f95d9]{margin-bottom:2px!important}
|
package/package.json
CHANGED
|
@@ -1,32 +1,48 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "general-basic-form",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
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
|
+
}
|
|
Binary file
|
package/config/webpack.common.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
const path = require("path");
|
|
2
|
-
const webpack = require("webpack");
|
|
3
|
-
const { VueLoaderPlugin } = require('vue-loader')
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
entry: "./src/index.js",
|
|
7
|
-
module: {
|
|
8
|
-
rules: [
|
|
9
|
-
{
|
|
10
|
-
test: /\.js$/,
|
|
11
|
-
exclude: file => (
|
|
12
|
-
/node_modules/.test(file) &&
|
|
13
|
-
!/\.vue\.js/.test(file)
|
|
14
|
-
),
|
|
15
|
-
use: [
|
|
16
|
-
// "thread-loader",// 多线程编译,可能会导致报错
|
|
17
|
-
{
|
|
18
|
-
loader: 'babel-loader',
|
|
19
|
-
options: {
|
|
20
|
-
presets: ['@babel/preset-env']
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
],
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
test: /\.css$/,
|
|
28
|
-
use: ['vue-style-loader', 'css-loader']
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
test: /\.less$/,
|
|
32
|
-
use: ['vue-style-loader', 'css-loader', 'less-loader']
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
test: /\.scss$/,
|
|
36
|
-
use: [
|
|
37
|
-
'vue-style-loader',
|
|
38
|
-
'css-loader',
|
|
39
|
-
'sass-loader'
|
|
40
|
-
]
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
test: /\.(eot|svg|ttf|woff|woff2)$/,
|
|
44
|
-
use: {
|
|
45
|
-
loader: 'file-loader',
|
|
46
|
-
options: {
|
|
47
|
-
outputPath: 'fonts/',
|
|
48
|
-
esModule: false
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
test: /\.(png|jpg|gif)$/,
|
|
54
|
-
use: {
|
|
55
|
-
loader: 'file-loader',
|
|
56
|
-
options: {
|
|
57
|
-
outputPath: 'assets/',
|
|
58
|
-
esModule: false
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
test: /\.vue$/,
|
|
64
|
-
loader: 'vue-loader',
|
|
65
|
-
options: {
|
|
66
|
-
use: [
|
|
67
|
-
// "thread-loader",// 多线程编译,可能会导致报错
|
|
68
|
-
{
|
|
69
|
-
loader: 'babel-loader',
|
|
70
|
-
options: {
|
|
71
|
-
presets: ['@babel/preset-env']
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
],
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
]
|
|
78
|
-
},
|
|
79
|
-
resolve: {
|
|
80
|
-
extensions: ['\*', '.js', '.jsx', '.vue'],// 能够使用户在引入模块时不带扩展
|
|
81
|
-
alias: {
|
|
82
|
-
"@": path.resolve(__dirname, '../src'),
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
output: {
|
|
86
|
-
path: path.resolve(__dirname, "../dist/"),
|
|
87
|
-
publicPath: "/",
|
|
88
|
-
filename: "bundle.js"
|
|
89
|
-
},
|
|
90
|
-
//why:https://github.com/vuejs/vue-next/tree/master/packages/vue#bundler-build-feature-flags
|
|
91
|
-
plugins: [
|
|
92
|
-
new webpack.HotModuleReplacementPlugin(),
|
|
93
|
-
new VueLoaderPlugin(),
|
|
94
|
-
new webpack.DefinePlugin({
|
|
95
|
-
"__VUE_OPTIONS_API__": true,
|
|
96
|
-
"__VUE_PROD_DEVTOOLS__": false,
|
|
97
|
-
})]
|
|
98
|
-
};
|
package/config/webpack.dev.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const path = require("path");
|
|
2
|
-
const { merge } = require('webpack-merge');
|
|
3
|
-
const common = require('./webpack.common.js');
|
|
4
|
-
|
|
5
|
-
module.exports = merge(common, {
|
|
6
|
-
mode: 'development',
|
|
7
|
-
devtool: 'inline-source-map',
|
|
8
|
-
devServer: {
|
|
9
|
-
contentBase: path.join(__dirname, "dist"),
|
|
10
|
-
port: 3000,
|
|
11
|
-
hot: true,
|
|
12
|
-
open: true, //自动打开浏览器
|
|
13
|
-
// host: '0.0.0.0',//开启项目本地服务
|
|
14
|
-
},
|
|
15
|
-
});
|
package/config/webpack.prod.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const { merge } = require('webpack-merge');
|
|
2
|
-
const common = require('./webpack.common.js');
|
|
3
|
-
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
|
|
4
|
-
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
5
|
-
|
|
6
|
-
module.exports = merge(common, {
|
|
7
|
-
mode: 'production',
|
|
8
|
-
plugins: [
|
|
9
|
-
new UglifyJsPlugin({
|
|
10
|
-
uglifyOptions: {
|
|
11
|
-
comments: "some", //去掉部分注释
|
|
12
|
-
}
|
|
13
|
-
}),
|
|
14
|
-
new CleanWebpackPlugin(),// 构筑前清理dist文件夹
|
|
15
|
-
]
|
|
16
|
-
});
|
package/src/GeneralBasicForm.vue
DELETED
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
* @Author: 陈德立*******419287484@qq.com
|
|
3
|
-
* @Date: 2021-08-20 17:14:53
|
|
4
|
-
* @LastEditTime: 2021-11-30 17:27:27
|
|
5
|
-
* @LastEditors: 陈德立*******419287484@qq.com
|
|
6
|
-
* @Github: https://github.com/Alan1034
|
|
7
|
-
* @Description:
|
|
8
|
-
* @FilePath: \GeneralBasicForm\src\GeneralBasicForm.vue
|
|
9
|
-
*
|
|
10
|
-
-->
|
|
11
|
-
/** 通用基本表单。用在表单页面搜索栏 */
|
|
12
|
-
|
|
13
|
-
<template>
|
|
14
|
-
<el-form
|
|
15
|
-
:model="queryParams"
|
|
16
|
-
ref="queryFormRef"
|
|
17
|
-
v-show="showSearch"
|
|
18
|
-
inline
|
|
19
|
-
label-position="left"
|
|
20
|
-
:label-width="labelWidth"
|
|
21
|
-
v-bind="$attrs"
|
|
22
|
-
>
|
|
23
|
-
<el-form-item
|
|
24
|
-
v-for="item in formItem"
|
|
25
|
-
:label="item.label"
|
|
26
|
-
:prop="item.prop"
|
|
27
|
-
:key="item.prop"
|
|
28
|
-
:rules="item.rules"
|
|
29
|
-
>
|
|
30
|
-
<el-input
|
|
31
|
-
v-if="item.type === 'input'"
|
|
32
|
-
@keydown.enter="getList"
|
|
33
|
-
v-model="queryParams[item.prop]"
|
|
34
|
-
:size="size"
|
|
35
|
-
v-bind="inputSetting"
|
|
36
|
-
:placeholder="item.placeholder || inputSetting.placeholder"
|
|
37
|
-
:maxlength="item.maxlength"
|
|
38
|
-
>
|
|
39
|
-
<template v-for="(templateEle, name) in item.template" #[name]>
|
|
40
|
-
<component
|
|
41
|
-
:key="name"
|
|
42
|
-
v-if="templateEle"
|
|
43
|
-
:is="currentInputComponent()"
|
|
44
|
-
:templateEle="templateEle"
|
|
45
|
-
/>
|
|
46
|
-
</template>
|
|
47
|
-
</el-input>
|
|
48
|
-
<el-select
|
|
49
|
-
filterable
|
|
50
|
-
v-else-if="item.type === 'select'"
|
|
51
|
-
v-model="queryParams[item.prop]"
|
|
52
|
-
:size="size"
|
|
53
|
-
v-bind="selectSetting"
|
|
54
|
-
:multiple="item.multiple"
|
|
55
|
-
:placeholder="item.placeholder || selectSetting.placeholder"
|
|
56
|
-
>
|
|
57
|
-
<el-option
|
|
58
|
-
v-for="dict in item.option || []"
|
|
59
|
-
:key="dict.value"
|
|
60
|
-
:label="dict.desc"
|
|
61
|
-
:value="dict.value"
|
|
62
|
-
/>
|
|
63
|
-
</el-select>
|
|
64
|
-
<el-cascader
|
|
65
|
-
filterable
|
|
66
|
-
v-else-if="item.type === 'cascader'"
|
|
67
|
-
v-model="queryParams[item.prop]"
|
|
68
|
-
:size="size"
|
|
69
|
-
v-bind="selectSetting"
|
|
70
|
-
:options="item.options || []"
|
|
71
|
-
:placeholder="item.placeholder || selectSetting.placeholder"
|
|
72
|
-
></el-cascader>
|
|
73
|
-
<el-date-picker
|
|
74
|
-
v-else-if="item.type === 'date-picker'"
|
|
75
|
-
v-model="queryParams[item.prop]"
|
|
76
|
-
:size="size"
|
|
77
|
-
v-bind="datePackerSetting"
|
|
78
|
-
:start-placeholder="
|
|
79
|
-
item['start-placeholder'] || datePackerSetting['start-placeholder']
|
|
80
|
-
"
|
|
81
|
-
:end-placeholder="
|
|
82
|
-
item['end-placeholder'] || datePackerSetting['end-placeholder']
|
|
83
|
-
"
|
|
84
|
-
:value-format="item['value-format']"
|
|
85
|
-
></el-date-picker>
|
|
86
|
-
<el-input-number
|
|
87
|
-
v-if="item.type === 'input-number'"
|
|
88
|
-
v-model="queryParams[item.prop]"
|
|
89
|
-
:size="size"
|
|
90
|
-
v-bind="inputSetting"
|
|
91
|
-
:min="item.min"
|
|
92
|
-
:max="item.max"
|
|
93
|
-
:controls-position="item['controls-position']"
|
|
94
|
-
:step-strictly="item['step-strictly']"
|
|
95
|
-
/>
|
|
96
|
-
</el-form-item>
|
|
97
|
-
<slot></slot>
|
|
98
|
-
<el-form-item v-if="!formOnly">
|
|
99
|
-
<el-button
|
|
100
|
-
type="primary"
|
|
101
|
-
icon="el-icon-search"
|
|
102
|
-
:size="size"
|
|
103
|
-
@click="handleQuery"
|
|
104
|
-
>查询</el-button
|
|
105
|
-
>
|
|
106
|
-
<el-button icon="el-icon-refresh" :size="size" @click="resetQuery"
|
|
107
|
-
>重置</el-button
|
|
108
|
-
>
|
|
109
|
-
</el-form-item>
|
|
110
|
-
</el-form>
|
|
111
|
-
</template>
|
|
112
|
-
|
|
113
|
-
<script>
|
|
114
|
-
export default {
|
|
115
|
-
name: "GeneralBasicForm",
|
|
116
|
-
components: {
|
|
117
|
-
InputArchive: (props) => {
|
|
118
|
-
const { templateEle } = props;
|
|
119
|
-
return templateEle();
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
props: {
|
|
123
|
-
showSearch: {
|
|
124
|
-
// 是否展示所有元素
|
|
125
|
-
type: Boolean,
|
|
126
|
-
default: true,
|
|
127
|
-
},
|
|
128
|
-
formOnly: {
|
|
129
|
-
// 是否只展示表单不展示按钮
|
|
130
|
-
type: Boolean,
|
|
131
|
-
default: false,
|
|
132
|
-
},
|
|
133
|
-
getList: {
|
|
134
|
-
// 查找数据调用的函数
|
|
135
|
-
type: Function,
|
|
136
|
-
default: () => {},
|
|
137
|
-
},
|
|
138
|
-
afterReset: {
|
|
139
|
-
// 在重置按钮点击完后但还没重新请求时触发的的函数
|
|
140
|
-
type: Function,
|
|
141
|
-
default: () => {},
|
|
142
|
-
},
|
|
143
|
-
formItem: {
|
|
144
|
-
// 定义表单的数据
|
|
145
|
-
type: Array,
|
|
146
|
-
default: [],
|
|
147
|
-
},
|
|
148
|
-
size: {
|
|
149
|
-
// 控制按钮大小
|
|
150
|
-
type: String,
|
|
151
|
-
default: "medium",
|
|
152
|
-
},
|
|
153
|
-
labelWidth: {
|
|
154
|
-
// 表单文字宽度
|
|
155
|
-
type: String,
|
|
156
|
-
default: "90px",
|
|
157
|
-
},
|
|
158
|
-
noUrlParameters: {
|
|
159
|
-
// 不接受和不改变url的参数
|
|
160
|
-
type: Boolean,
|
|
161
|
-
default: () => false,
|
|
162
|
-
},
|
|
163
|
-
formData: {
|
|
164
|
-
// 外部传入的表单数据,用于回填
|
|
165
|
-
type: Object,
|
|
166
|
-
default: () => {},
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
data() {
|
|
170
|
-
return {
|
|
171
|
-
queryParams: {
|
|
172
|
-
...(this.noUrlParameters ? {} : this.$route?.query),
|
|
173
|
-
}, // form表单数据
|
|
174
|
-
selectSetting: {
|
|
175
|
-
placeholder: "请选择",
|
|
176
|
-
clearable: true,
|
|
177
|
-
style: "width: 200px",
|
|
178
|
-
},
|
|
179
|
-
inputSetting: {
|
|
180
|
-
placeholder: "请输入",
|
|
181
|
-
style: "width: 200px",
|
|
182
|
-
clearable: true,
|
|
183
|
-
},
|
|
184
|
-
datePackerSetting: {
|
|
185
|
-
style: "width: 227px",
|
|
186
|
-
"start-placeholder": "开始日期",
|
|
187
|
-
"end-placeholder": "结束日期",
|
|
188
|
-
type: "daterange",
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
},
|
|
192
|
-
// setup(props) {
|
|
193
|
-
//设置默认值
|
|
194
|
-
// console.log(props);
|
|
195
|
-
// // const { formItem } = toRefs(props);
|
|
196
|
-
// const { formItem } = props;
|
|
197
|
-
// console.log(formItem);
|
|
198
|
-
// const queryParams = {};
|
|
199
|
-
// formItem.forEach((item) => {
|
|
200
|
-
// queryParams[item.prop] = "";
|
|
201
|
-
// });
|
|
202
|
-
// return {
|
|
203
|
-
// queryParams,
|
|
204
|
-
// };
|
|
205
|
-
// },
|
|
206
|
-
watch: {
|
|
207
|
-
formData(val) {
|
|
208
|
-
this.queryParams = {
|
|
209
|
-
...(this.noUrlParameters ? {} : this.queryParams),
|
|
210
|
-
...val,
|
|
211
|
-
};
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
methods: {
|
|
215
|
-
/** 搜索按钮操作 */
|
|
216
|
-
handleQuery() {
|
|
217
|
-
const params = { page: 1, limit: 10 };
|
|
218
|
-
const searchParams = {
|
|
219
|
-
...this.$route?.query,
|
|
220
|
-
...this.queryParams,
|
|
221
|
-
...params,
|
|
222
|
-
};
|
|
223
|
-
if (!this.noUrlParameters) {
|
|
224
|
-
this.$router.push({
|
|
225
|
-
query: { ...searchParams },
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
this.getList({
|
|
229
|
-
...searchParams,
|
|
230
|
-
});
|
|
231
|
-
},
|
|
232
|
-
/** 重置按钮操作 */
|
|
233
|
-
async resetQuery() {
|
|
234
|
-
this.$refs.queryFormRef.resetFields();
|
|
235
|
-
const params = { page: 1 };
|
|
236
|
-
if (!this.noUrlParameters) {
|
|
237
|
-
await this.$router.push({
|
|
238
|
-
query: { ...params },
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
this.queryParams = {
|
|
242
|
-
...(this.noUrlParameters ? {} : this.$route?.query),
|
|
243
|
-
};
|
|
244
|
-
this.afterReset();
|
|
245
|
-
this.handleQuery();
|
|
246
|
-
},
|
|
247
|
-
currentInputComponent() {
|
|
248
|
-
return "input-archive";
|
|
249
|
-
},
|
|
250
|
-
},
|
|
251
|
-
};
|
|
252
|
-
</script>
|
|
253
|
-
|
|
254
|
-
<style scoped>
|
|
255
|
-
.el-form-item {
|
|
256
|
-
margin-bottom: 2px !important;
|
|
257
|
-
}
|
|
258
|
-
</style>
|
|
Binary file
|
package/src/assets/logo.png
DELETED
|
Binary file
|
package/src/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: 陈德立*******419287484@qq.com
|
|
3
|
-
* @Date: 2021-08-20 17:05:30
|
|
4
|
-
* @LastEditTime: 2021-08-20 17:15:27
|
|
5
|
-
* @LastEditors: 陈德立*******419287484@qq.com
|
|
6
|
-
* @Github: https://github.com/Alan1034
|
|
7
|
-
* @Description:
|
|
8
|
-
* @FilePath: \GeneralBasicForm\src\index.js
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
import GeneralBasicForm from './GeneralBasicForm.vue';
|
|
12
|
-
export default GeneralBasicForm
|