general-basic-form 1.0.25 → 1.0.27
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 +356 -191
- package/dist/index.d.ts +17 -0
- package/dist/index.js +809 -0
- package/dist/index.umd.cjs +1 -0
- package/dist/style.css +1 -0
- package/package.json +29 -11
- package/public/index.d.ts +17 -0
- package/script/initialization.ts +24 -0
- package/script/link.ts +14 -0
- package/script/linkNode.ts +14 -0
- package/script/unlinkModule.ts +48 -0
- package/script/unlinkNode.ts +38 -0
- package/tsconfig.json +14 -0
- package/vite.config.js +121 -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 -252
- package/src/assets/image-20210820173037871.png +0 -0
- package/src/assets/logo.png +0 -0
- package/src/index.js +0 -12
package/src/GeneralBasicForm.vue
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
* @Author: 陈德立*******419287484@qq.com
|
|
3
|
-
* @Date: 2021-08-20 17:14:53
|
|
4
|
-
* @LastEditTime: 2021-11-23 17:49:55
|
|
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
|
-
formItem: {
|
|
139
|
-
// 定义表单的数据
|
|
140
|
-
type: Array,
|
|
141
|
-
default: [],
|
|
142
|
-
},
|
|
143
|
-
size: {
|
|
144
|
-
// 控制按钮大小
|
|
145
|
-
type: String,
|
|
146
|
-
default: "medium",
|
|
147
|
-
},
|
|
148
|
-
labelWidth: {
|
|
149
|
-
// 表单文字宽度
|
|
150
|
-
type: String,
|
|
151
|
-
default: "90px",
|
|
152
|
-
},
|
|
153
|
-
noUrlParameters: {
|
|
154
|
-
// 不接受和不改变url的参数
|
|
155
|
-
type: Boolean,
|
|
156
|
-
default: () => false,
|
|
157
|
-
},
|
|
158
|
-
formData: {
|
|
159
|
-
// 外部传入的表单数据,用于回填
|
|
160
|
-
type: Object,
|
|
161
|
-
default: () => {},
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
data() {
|
|
165
|
-
return {
|
|
166
|
-
queryParams: {
|
|
167
|
-
...(this.noUrlParameters ? {} : this.$route?.query),
|
|
168
|
-
}, // form表单数据
|
|
169
|
-
selectSetting: {
|
|
170
|
-
placeholder: "请选择",
|
|
171
|
-
clearable: true,
|
|
172
|
-
style: "width: 200px",
|
|
173
|
-
},
|
|
174
|
-
inputSetting: {
|
|
175
|
-
placeholder: "请输入",
|
|
176
|
-
style: "width: 200px",
|
|
177
|
-
clearable: true,
|
|
178
|
-
},
|
|
179
|
-
datePackerSetting: {
|
|
180
|
-
style: "width: 227px",
|
|
181
|
-
"start-placeholder": "开始日期",
|
|
182
|
-
"end-placeholder": "结束日期",
|
|
183
|
-
type: "daterange",
|
|
184
|
-
},
|
|
185
|
-
};
|
|
186
|
-
},
|
|
187
|
-
// setup(props) {
|
|
188
|
-
//设置默认值
|
|
189
|
-
// console.log(props);
|
|
190
|
-
// // const { formItem } = toRefs(props);
|
|
191
|
-
// const { formItem } = props;
|
|
192
|
-
// console.log(formItem);
|
|
193
|
-
// const queryParams = {};
|
|
194
|
-
// formItem.forEach((item) => {
|
|
195
|
-
// queryParams[item.prop] = "";
|
|
196
|
-
// });
|
|
197
|
-
// return {
|
|
198
|
-
// queryParams,
|
|
199
|
-
// };
|
|
200
|
-
// },
|
|
201
|
-
watch: {
|
|
202
|
-
formData(val) {
|
|
203
|
-
this.queryParams = {
|
|
204
|
-
...(this.noUrlParameters ? {} : this.queryParams),
|
|
205
|
-
...val,
|
|
206
|
-
};
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
methods: {
|
|
210
|
-
/** 搜索按钮操作 */
|
|
211
|
-
handleQuery() {
|
|
212
|
-
const params = { page: 1, limit: 10 };
|
|
213
|
-
const searchParams = {
|
|
214
|
-
...this.$route?.query,
|
|
215
|
-
...this.queryParams,
|
|
216
|
-
...params,
|
|
217
|
-
};
|
|
218
|
-
if (!this.noUrlParameters) {
|
|
219
|
-
this.$router.push({
|
|
220
|
-
query: { ...searchParams },
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
this.getList({
|
|
224
|
-
...searchParams,
|
|
225
|
-
});
|
|
226
|
-
},
|
|
227
|
-
/** 重置按钮操作 */
|
|
228
|
-
async resetQuery() {
|
|
229
|
-
this.$refs.queryFormRef.resetFields();
|
|
230
|
-
const params = { page: 1 };
|
|
231
|
-
if (!this.noUrlParameters) {
|
|
232
|
-
await this.$router.push({
|
|
233
|
-
query: { ...params },
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
this.queryParams = {
|
|
237
|
-
...(this.noUrlParameters ? {} : this.$route?.query),
|
|
238
|
-
};
|
|
239
|
-
this.handleQuery();
|
|
240
|
-
},
|
|
241
|
-
currentInputComponent() {
|
|
242
|
-
return "input-archive";
|
|
243
|
-
},
|
|
244
|
-
},
|
|
245
|
-
};
|
|
246
|
-
</script>
|
|
247
|
-
|
|
248
|
-
<style scoped>
|
|
249
|
-
.el-form-item {
|
|
250
|
-
margin-bottom: 2px !important;
|
|
251
|
-
}
|
|
252
|
-
</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
|