general-basic-form 2.0.2 → 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/dist/index.mjs ADDED
@@ -0,0 +1,281 @@
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({
3
+ components: {
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";
31
+ }
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
+ },
71
+ props: {
72
+ showSearch: {
73
+ // 是否展示所有元素
74
+ type: Boolean,
75
+ default: !0
76
+ },
77
+ formOnly: {
78
+ // 是否只展示表单不展示按钮
79
+ type: Boolean,
80
+ default: !1
81
+ },
82
+ getList: {
83
+ // 查找数据调用的函数
84
+ type: Function,
85
+ default: () => {
86
+ }
87
+ },
88
+ afterReset: {
89
+ // 在重置按钮点击完后但还没重新请求时触发的的函数
90
+ type: Function,
91
+ default: () => {
92
+ }
93
+ },
94
+ formItem: {
95
+ // 定义表单的数据
96
+ type: Array,
97
+ default: []
98
+ },
99
+ size: {
100
+ // 控制按钮大小
101
+ type: String,
102
+ default: "medium"
103
+ },
104
+ labelWidth: {
105
+ // 表单文字宽度
106
+ type: String,
107
+ default: "90px"
108
+ },
109
+ noUrlParameters: {
110
+ // 不接受和不改变url的参数
111
+ type: Boolean,
112
+ default: () => !1
113
+ },
114
+ formData: {
115
+ // 外部传入的表单数据,用于回填
116
+ type: Object,
117
+ default: () => {
118
+ }
119
+ }
120
+ },
121
+ data() {
122
+ var e;
123
+ return {
124
+ queryParams: {
125
+ ...this.noUrlParameters ? {} : (e = this.$route) == null ? void 0 : e.query
126
+ },
127
+ // form表单数据
128
+ selectSetting: {
129
+ placeholder: "请选择",
130
+ clearable: !0,
131
+ style: "width: 200px"
132
+ },
133
+ datePackerSetting: {
134
+ style: "width: 227px",
135
+ "start-placeholder": "开始日期",
136
+ "end-placeholder": "结束日期",
137
+ type: "daterange"
138
+ }
139
+ };
140
+ },
141
+ // setup(props) {
142
+ //设置默认值
143
+ // console.log(props);
144
+ // // const { formItem } = toRefs(props);
145
+ // const { formItem } = props;
146
+ // console.log(formItem);
147
+ // const queryParams = {};
148
+ // formItem.forEach((item) => {
149
+ // queryParams[item.prop] = "";
150
+ // });
151
+ // return {
152
+ // queryParams,
153
+ // };
154
+ // },
155
+ watch: {
156
+ formData(e) {
157
+ this.queryParams = {
158
+ ...this.noUrlParameters ? {} : this.queryParams,
159
+ ...e
160
+ };
161
+ }
162
+ },
163
+ methods: {
164
+ /** 搜索按钮操作 */
165
+ handleQuery() {
166
+ var r;
167
+ const e = { page: 1, limit: 10 }, l = {
168
+ ...(r = this.$route) == null ? void 0 : r.query,
169
+ ...this.queryParams,
170
+ ...e
171
+ };
172
+ this.noUrlParameters || this.$router.push({
173
+ query: { ...l }
174
+ }), this.getList({
175
+ ...l
176
+ });
177
+ },
178
+ /** 重置按钮操作 */
179
+ async resetQuery() {
180
+ var l;
181
+ this.$refs.queryFormRef.resetFields();
182
+ const e = { page: 1 };
183
+ this.noUrlParameters || await this.$router.push({
184
+ query: { ...e }
185
+ }), this.queryParams = {
186
+ ...this.noUrlParameters ? {} : (l = this.$route) == null ? void 0 : l.query
187
+ }, this.afterReset(), this.handleQuery();
188
+ }
189
+ }
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,
195
+ ref: "queryFormRef",
196
+ inline: "",
197
+ "label-position": "left",
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
206
+ }, {
207
+ default: i(() => [
208
+ t.type === "input" ? (n(), _("div", K)) : t.type === "select" ? (n(), s(p, c({
209
+ key: 1,
210
+ filterable: "",
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
220
+ }, null, 8, ["label", "value"]))), 128))
221
+ ]),
222
+ _: 2
223
+ }, 1040, ["modelValue", "onUpdate:modelValue", "size"])) : t.type === "cascader" ? (n(), s(m, c({
224
+ key: 2,
225
+ filterable: "",
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({
231
+ key: 3,
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({
237
+ key: 4,
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)
242
+ ]),
243
+ _: 2
244
+ }, 1032, ["label", "prop", "rules"]))), 128)),
245
+ L(e.$slots, "default"),
246
+ r.formOnly ? d("", !0) : (n(), s(P, { key: 0 }, {
247
+ default: i(() => [
248
+ k(q, {
249
+ type: "primary",
250
+ icon: "el-icon-search",
251
+ size: r.size,
252
+ onClick: h.handleQuery
253
+ }, {
254
+ default: i(() => [
255
+ V("查询")
256
+ ]),
257
+ _: 1
258
+ }, 8, ["size", "onClick"]),
259
+ k(q, {
260
+ icon: "el-icon-refresh",
261
+ size: r.size,
262
+ onClick: h.resetQuery
263
+ }, {
264
+ default: i(() => [
265
+ V("重置")
266
+ ]),
267
+ _: 1
268
+ }, 8, ["size", "onClick"])
269
+ ]),
270
+ _: 1
271
+ }))
272
+ ]),
273
+ _: 3
274
+ }, 16, ["model", "label-width"])), [
275
+ [O, r.showSearch]
276
+ ]);
277
+ }
278
+ const j = /* @__PURE__ */ S(G, [["render", N]]), E = j;
279
+ export {
280
+ E as VGeneralBasicForm
281
+ };
@@ -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 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,8 +1,8 @@
1
1
  {
2
2
  "name": "general-basic-form",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "",
5
- "main": "./src/index.ts",
5
+ "main": "./dist/index.umd.js",
6
6
  "scripts": {
7
7
  "build": "cross-env CURRENT_ENV=prod run-p type-check build-only",
8
8
  "test:e2e": "playwright test",
@@ -42,5 +42,16 @@
42
42
  "element-plus": ">=2.4.2",
43
43
  "vue": ">=3.3.4",
44
44
  "vue-router": ">=4.2.4"
45
- }
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
+ ]
46
57
  }
package/script/link.ts DELETED
@@ -1,34 +0,0 @@
1
- /*
2
- * @Author: 陈德立*******419287484@qq.com
3
- * @Date: 2023-11-10 09:39:59
4
- * @LastEditTime: 2023-11-10 10:26:53
5
- * @LastEditors: 陈德立*******419287484@qq.com
6
- * @Github: https://github.com/Alan1034
7
- * @Description: link处理流程
8
- * @FilePath: \GeneralBasicForm\script\link.ts
9
- *
10
- */
11
- import path from "path";
12
- import fs from 'fs'
13
- import chalk from 'chalk'
14
-
15
- const updateMain = () => {
16
- try {
17
- const packageTxt = fs.readFileSync(path.join(__dirname, '../package.json'), 'utf8');
18
- const packageJson = JSON.parse(packageTxt);
19
- const mainDir = "./src/index.ts"
20
- delete packageJson.files
21
- delete packageJson.module
22
- delete packageJson.exports
23
- delete packageJson.types
24
- packageJson.main = mainDir
25
- const versionData = JSON.stringify(packageJson, null, 2);
26
- fs.writeFileSync(path.join(__dirname, '../package.json'), versionData, 'utf8');
27
- console.log(chalk.green.bold('修改入口配置成功!当前入口路径为为:' + mainDir));
28
- } catch (error) {
29
- console.log(chalk.red.bold('修改入口配置出错:', error.toString()));
30
- }
31
-
32
- }
33
-
34
- updateMain()
package/script/unlink.ts DELETED
@@ -1,42 +0,0 @@
1
- /*
2
- * @Author: 陈德立*******419287484@qq.com
3
- * @Date: 2023-11-10 09:39:59
4
- * @LastEditTime: 2023-11-10 10:29:27
5
- * @LastEditors: 陈德立*******419287484@qq.com
6
- * @Github: https://github.com/Alan1034
7
- * @Description: unlink处理流程
8
- * @FilePath: \GeneralBasicForm\script\unlink.ts
9
- *
10
- */
11
- import path from "path";
12
- import fs from 'fs'
13
- import chalk from 'chalk'
14
-
15
- const updateMain = () => {
16
- try {
17
- const packageTxt = fs.readFileSync(path.join(__dirname, '../package.json'), 'utf8');
18
- const packageJson = JSON.parse(packageTxt);
19
- const umdDir = "./dist/index.umd.js"
20
- const esDir = "./dist/index.mjs"
21
- packageJson.main = umdDir
22
- packageJson.module = esDir
23
- packageJson.exports = {
24
- ".": {
25
- "import": esDir,
26
- "require": umdDir
27
- }
28
- }
29
- packageJson.typings = "./dist/index.d.ts"
30
- packageJson.files = [
31
- "/dist"
32
- ]
33
- const versionData = JSON.stringify(packageJson, null, 2);
34
- fs.writeFileSync(path.join(__dirname, '../package.json'), versionData, 'utf8');
35
- console.log(chalk.green.bold('修改入口配置成功!当前入口路径为为:' + umdDir));
36
- } catch (error) {
37
- console.log(chalk.red.bold('修改入口配置出错:', error.toString()));
38
- }
39
-
40
- }
41
-
42
- updateMain()
@@ -1,234 +0,0 @@
1
- <!--
2
- * @Author: 陈德立*******419287484@qq.com
3
- * @Date: 2021-08-20 17:14:53
4
- * @LastEditTime: 2023-11-14 15:18:20
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
- <Input v-if="item.type === 'input'" :item="item" />
31
- <InputGraphicVerification
32
- v-if="item.type === 'input-graphic-verification'"
33
- :item="item"
34
- :key="item.key"
35
- />
36
- <InputMobileVerification
37
- v-if="item.type === 'input-mobile-verification'"
38
- :item="item"
39
- />
40
- <Divider v-if="item.type === 'divider'" :item="item" />
41
- <el-select
42
- filterable
43
- v-else-if="item.type === 'select'"
44
- v-model="queryParams[item.prop]"
45
- :size="size"
46
- v-bind="item.selectSetting || selectSetting"
47
- >
48
- <el-option
49
- v-for="dict in item.option || []"
50
- :key="dict.value"
51
- :label="dict.desc"
52
- :value="dict.value"
53
- />
54
- </el-select>
55
- <el-cascader
56
- filterable
57
- v-else-if="item.type === 'cascader'"
58
- v-model="queryParams[item.prop]"
59
- :size="size"
60
- :options="item.options || []"
61
- v-bind="item.selectSetting || selectSetting"
62
- ></el-cascader>
63
- <el-date-picker
64
- v-else-if="item.type === 'date-picker'"
65
- v-model="queryParams[item.prop]"
66
- :size="size"
67
- v-bind="item.datePackerSetting || datePackerSetting"
68
- ></el-date-picker>
69
- <InputNumber v-if="item.type === 'input-number'" :item="item" />
70
- </el-form-item>
71
- <slot></slot>
72
- <el-form-item v-if="!formOnly">
73
- <el-button
74
- type="primary"
75
- icon="el-icon-search"
76
- :size="size"
77
- @click="handleQuery"
78
- >查询</el-button
79
- >
80
- <el-button icon="el-icon-refresh" :size="size" @click="resetQuery"
81
- >重置</el-button
82
- >
83
- </el-form-item>
84
- </el-form>
85
- </template>
86
-
87
- <script lang="ts">
88
- import { provide, ref, PropType, defineComponent } from "vue";
89
- import type { ItemType } from "./types/basicFrom";
90
- import { useRoute } from "vue-router";
91
- import Input from "./components/VBasic/input";
92
- import InputNumber from "./components/VBasic/input-number";
93
- import InputGraphicVerification from "./components/VBasic/input-graphic-verification";
94
- import InputMobileVerification from "./components/VBasic/input-mobile-verification";
95
- import Divider from "./components/VBasic/divider";
96
-
97
- export default defineComponent({
98
- name: "GeneralBasicForm",
99
- components: {
100
- Input,
101
- InputNumber,
102
- InputGraphicVerification,
103
- InputMobileVerification,
104
- Divider,
105
- },
106
- props: {
107
- showSearch: {
108
- // 是否展示所有元素
109
- type: Boolean,
110
- default: true,
111
- },
112
- formOnly: {
113
- // 是否只展示表单不展示按钮
114
- type: Boolean,
115
- default: false,
116
- },
117
- getList: {
118
- // 查找数据调用的函数
119
- type: Function,
120
- default: () => {},
121
- },
122
- afterReset: {
123
- // 在重置按钮点击完后但还没重新请求时触发的的函数
124
- type: Function,
125
- default: () => {},
126
- },
127
- formItem: {
128
- // 定义表单的数据
129
- type: Array as unknown as PropType<ItemType[]>,
130
- default: [],
131
- },
132
- size: {
133
- // 控制按钮大小
134
- type: String,
135
- default: "medium",
136
- },
137
- labelWidth: {
138
- // 表单文字宽度
139
- type: String,
140
- default: "90px",
141
- },
142
- noUrlParameters: {
143
- // 不接受和不改变url的参数
144
- type: Boolean,
145
- default: () => false,
146
- },
147
- formData: {
148
- // 外部传入的表单数据,用于回填
149
- type: Object,
150
- default: () => {},
151
- },
152
- },
153
- data() {
154
- return {
155
- selectSetting: {
156
- placeholder: "请选择",
157
- clearable: true,
158
- style: "width: 200px",
159
- },
160
- datePackerSetting: {
161
- style: "width: 227px",
162
- "start-placeholder": "开始日期",
163
- "end-placeholder": "结束日期",
164
- type: "daterange",
165
- },
166
- };
167
- },
168
- setup(props) {
169
- const { size, noUrlParameters, getList } = props;
170
- const route = useRoute();
171
- const queryParams = ref({
172
- ...(noUrlParameters ? {} : route?.query),
173
- }); // form表单数据
174
- provide(/* 注入名 */ "queryParams", /* 值 */ queryParams);
175
- provide(/* 注入名 */ "size", /* 值 */ size);
176
- provide(/* 注入名 */ "getList", /* 值 */ getList);
177
- // const { formItem } = toRefs(props);
178
- // const { formItem } = props;
179
- // console.log(formItem);
180
- // const queryParams = {};
181
- // formItem.forEach((item) => {
182
- // queryParams[item.prop] = "";
183
- // });
184
- return {
185
- queryParams,
186
- };
187
- },
188
- watch: {
189
- formData(val) {
190
- this.queryParams = {
191
- ...(this.noUrlParameters ? {} : this.queryParams),
192
- ...val,
193
- };
194
- },
195
- },
196
- methods: {
197
- /** 搜索按钮操作 */
198
- handleQuery() {
199
- const params = { page: 1, limit: 10 };
200
- const searchParams = {
201
- ...this.$route?.query,
202
- ...this.queryParams,
203
- ...params,
204
- };
205
- if (!this.noUrlParameters) {
206
- this.$router.push({
207
- query: { ...searchParams },
208
- });
209
- }
210
- this.getList({
211
- ...searchParams,
212
- });
213
- },
214
- /** 重置按钮操作 */
215
- async resetQuery() {
216
- this.$refs.queryFormRef.resetFields();
217
- const params = { page: 1 };
218
- if (!this.noUrlParameters) {
219
- await this.$router.push({
220
- query: { ...params },
221
- });
222
- }
223
- this.queryParams = {
224
- ...(this.noUrlParameters ? {} : this.$route?.query),
225
- };
226
- this.afterReset();
227
- this.handleQuery();
228
- },
229
- },
230
- });
231
- </script>
232
-
233
- <style scoped>
234
- </style>
Binary file
@@ -1,52 +0,0 @@
1
- <!--
2
- * @Author: 陈德立*******419287484@qq.com
3
- * @Date: 2023-11-09 10:01:20
4
- * @LastEditTime: 2023-11-10 16:51:18
5
- * @LastEditors: 陈德立*******419287484@qq.com
6
- * @Github: https://github.com/Alan1034
7
- * @Description: 分割线
8
- * @FilePath: \deal-front-endd:\work\GeneralBasicForm\src\components\VBasic\divider\index.vue
9
- *
10
- -->
11
-
12
- <template>
13
- <el-divider v-bind="dividerSetting">
14
- <template v-for="(templateEle, name) in item.template" #[name]>
15
- <component
16
- :key="name"
17
- v-if="templateEle"
18
- :is="currentInputComponent()"
19
- :templateEle="templateEle"
20
- />
21
- </template>
22
- </el-divider>
23
- </template>
24
-
25
- <script lang="ts">
26
- import { defineComponent } from "vue";
27
-
28
- export default defineComponent({
29
- components: {
30
- slotArchive: (props) => {
31
- const { templateEle } = props;
32
- return templateEle();
33
- },
34
- },
35
- props: {
36
- item: null, // null就是any
37
- },
38
- setup() {},
39
- data() {
40
- return {
41
- dividerSetting: {
42
- ...this.item.dividerSetting,
43
- },
44
- };
45
- },
46
- methods: {
47
- currentInputComponent() {
48
- return "slot-archive";
49
- },
50
- },
51
- });
52
- </script>
@@ -1,67 +0,0 @@
1
- <template>
2
- <el-input
3
- @keydown.enter="getList"
4
- v-model="queryParams[item.prop]"
5
- :size="size"
6
- v-bind="inputSetting"
7
- >
8
- <template v-for="(templateEle, name) in item.template" #[name]>
9
- <component
10
- :key="name"
11
- v-if="templateEle"
12
- :is="currentInputComponent()"
13
- :templateEle="templateEle"
14
- />
15
- </template>
16
- </el-input>
17
- </template>
18
-
19
- <script lang="ts">
20
- import { defineComponent, inject } from "vue";
21
- import { inputDefaultSetting } from "../../setting";
22
- export default defineComponent({
23
- components: {
24
- InputArchive: (props) => {
25
- const { templateEle } = props;
26
- return templateEle();
27
- },
28
- },
29
- props: {
30
- item: null, // null就是any
31
- },
32
- setup() {
33
- const queryParams = inject("queryParams", {});
34
- const getList = inject("getList");
35
- const size = inject("size");
36
- return { queryParams, getList, size };
37
- },
38
- data() {
39
- return {
40
- inputSetting: {
41
- ...inputDefaultSetting,
42
- ...this.item.inputSetting,
43
- },
44
- };
45
- },
46
- // created() {
47
- // console.log("new", this.item);
48
- // console.log("new", this.inputSetting);
49
- // },
50
- methods: {
51
- currentInputComponent() {
52
- return "input-archive";
53
- },
54
- },
55
- // watch: {
56
- // item(val) {
57
- // console.log("item", val);
58
- // },
59
- // size(val) {
60
- // console.log(val);
61
- // },
62
- // },
63
- });
64
- </script>
65
-
66
- <style>
67
- </style>
@@ -1,56 +0,0 @@
1
- <!--
2
- * @Author: 陈德立*******419287484@qq.com
3
- * @Date: 2023-11-09 10:01:20
4
- * @LastEditTime: 2023-11-15 10:15:28
5
- * @LastEditors: 陈德立*******419287484@qq.com
6
- * @Github: https://github.com/Alan1034
7
- * @Description: 图形验证码组件
8
- * @FilePath: \GeneralBasicForm\src\components\VBasic\input-graphic-verification\index.vue
9
- *
10
- -->
11
-
12
- <script setup lang="ts">
13
- import Input from "../input/index.vue";
14
- import { ref, computed, PropType, toRefs } from "vue";
15
- import type {
16
- BasicFormComponentsProps,
17
- InputGraphicVerification,
18
- } from "../../../types/componentsProps";
19
- const { item } = defineProps<{ item: any }>();
20
- const { graphicSrc = "", getGraphic = () => {} }: InputGraphicVerification =
21
- item;
22
- const loading = ref(false);
23
-
24
- const graphicClick = async () => {
25
- // console.log('click', getGraphic);
26
- if (getGraphic && !loading.value) {
27
- loading.value = true;
28
- await getGraphic();
29
- loading.value = false;
30
- }
31
- };
32
- </script>
33
-
34
- <template>
35
- <div class="input-graphic-verification" v-loading="loading">
36
- <Input :item="item" class="input" />
37
- <img class="graphic" @click="graphicClick" :src="graphicSrc" />
38
- </div>
39
- </template>
40
-
41
- <style lang="less" scoped>
42
- .input-graphic-verification {
43
- display: flex;
44
- gap: 12px;
45
- width: 100%;
46
- .input {
47
- flex: auto;
48
- }
49
- .graphic {
50
- width: 109px;
51
- height: 43px;
52
- object-fit: fill;
53
- flex: none;
54
- }
55
- }
56
- </style>
@@ -1,31 +0,0 @@
1
- <!--
2
- * @Author: 陈德立*******419287484@qq.com
3
- * @Date: 2023-11-09 10:01:20
4
- * @LastEditTime: 2023-11-14 15:35:16
5
- * @LastEditors: 陈德立*******419287484@qq.com
6
- * @Github: https://github.com/Alan1034
7
- * @Description: 手机验证码组件
8
- * @FilePath: \GeneralBasicForm\src\components\VBasic\input-mobile-verification\index.vue
9
- *
10
- -->
11
-
12
- <script setup lang="ts">
13
- import Input from "../input/index.vue";
14
- import { h, watch, onBeforeUpdate, nextTick } from "vue";
15
- import { BasicFormComponentsProps } from "../../../types/componentsProps";
16
- import VerificationButton from "./verification-button.vue";
17
- const { item } = defineProps<{item:any}>();
18
- // 重新赋值一下触发下面的代码,否则响应会在内部进行
19
- const mobileItem = item;
20
- mobileItem.template = {
21
- append: () => {
22
- return h(VerificationButton, {
23
- getSmscode: mobileItem.getSmscode,
24
- });
25
- },
26
- };
27
- </script>
28
-
29
- <template>
30
- <Input :item="mobileItem" class="input"> </Input>
31
- </template>
@@ -1,64 +0,0 @@
1
- <script setup lang="ts">
2
- import { ref, computed, onBeforeUnmount, Ref } from "vue";
3
- import type { InputMobileVerification } from "../../../types/componentsProps";
4
- const { getSmscode } = defineProps<{ getSmscode: Function }>();
5
-
6
- const defaultText = "获取验证码";
7
- const restTime = 60;
8
- const buttonText: Ref<string | number> = ref(defaultText);
9
- const timer = ref(null);
10
- const buttonType = computed(() => buttonText.value === defaultText);
11
- const reset = () => {
12
- if (!timer) {
13
- return;
14
- }
15
- clearInterval(timer.value);
16
- timer.value = null;
17
- buttonText.value = defaultText;
18
- };
19
- const buttonClick = async () => {
20
- if (buttonText.value !== defaultText) {
21
- return;
22
- }
23
- buttonText.value = restTime;
24
- timer.value = setInterval(() => {
25
- if (Number(buttonText.value) <= 0 || !buttonText.value) {
26
- reset();
27
- return;
28
- } else {
29
- buttonText.value = Number(buttonText.value) - 1;
30
- }
31
- }, 1000);
32
- if (!getSmscode) {
33
- return;
34
- } else {
35
- const statue = await getSmscode();
36
- if (statue === false) {
37
- reset();
38
- }
39
- }
40
- };
41
- onBeforeUnmount(() => {
42
- reset();
43
- });
44
- </script>
45
-
46
- <template>
47
- <el-button
48
- class="verifiaction-button"
49
- :style="{
50
- color: buttonType
51
- ? 'var(--color-primary, #409EFF)'
52
- : 'var(--text-color-placeholder, #A8ABB2)',
53
- cursor: buttonType ? 'pointer' : 'default',
54
- }"
55
- @click="buttonClick"
56
- >{{ buttonType ? defaultText : buttonText + "s" }}</el-button
57
- >
58
- </template>
59
-
60
- <style lang="less" scoped>
61
- .verifiaction-button {
62
- width: 109px;
63
- }
64
- </style>
@@ -1,30 +0,0 @@
1
- <!--
2
- * @Author: 陈德立*******419287484@qq.com
3
- * @Date: 2023-11-08 18:03:42
4
- * @LastEditTime: 2023-11-14 15:35:38
5
- * @LastEditors: 陈德立*******419287484@qq.com
6
- * @Github: https://github.com/Alan1034
7
- * @Description:
8
- * @FilePath: \GeneralBasicForm\src\components\VBasic\input-number\index.vue
9
- *
10
- -->
11
- <script setup lang="ts">
12
- import { inputDefaultSetting } from "../../setting";
13
- import { ref, inject } from "vue";
14
- import { BasicFormComponentsProps } from "../../../types/componentsProps";
15
- const { item } = defineProps<{item:any}>();
16
- const queryParams = inject("queryParams", {});
17
- const size = inject("size");
18
- const inputSetting = ref({
19
- ...inputDefaultSetting,
20
- ...item.inputSetting,
21
- });
22
- </script>
23
-
24
- <template>
25
- <el-input-number
26
- v-model="queryParams[item.prop]"
27
- :size="size"
28
- v-bind="inputSetting"
29
- />
30
- </template>
@@ -1,15 +0,0 @@
1
- /*
2
- * @Author: 陈德立*******419287484@qq.com
3
- * @Date: 2023-11-08 18:01:09
4
- * @LastEditTime: 2023-11-08 18:01:25
5
- * @LastEditors: 陈德立*******419287484@qq.com
6
- * @Github: https://github.com/Alan1034
7
- * @Description:
8
- * @FilePath: \GeneralBasicForm\src\components\setting.ts
9
- *
10
- */
11
- export const inputDefaultSetting = {
12
- placeholder: "请输入",
13
- style: "width: 200px",
14
- clearable: true,
15
- }
package/src/index.ts DELETED
@@ -1,15 +0,0 @@
1
- /*
2
- * @Author: 陈德立*******419287484@qq.com
3
- * @Date: 2021-08-20 17:05:30
4
- * @LastEditTime: 2023-11-07 15:05:39
5
- * @LastEditors: 陈德立*******419287484@qq.com
6
- * @Github: https://github.com/Alan1034
7
- * @Description:
8
- * @FilePath: \GeneralBasicForm\src\index.ts
9
- *
10
- */
11
-
12
- import GeneralBasicForm from './GeneralBasicForm.vue';
13
-
14
- export const VGeneralBasicForm = GeneralBasicForm
15
-
@@ -1,48 +0,0 @@
1
- export enum FormType {
2
- /**
3
- * @description: 输入框
4
- * @return {*}
5
- */
6
- 'input' = 'input',
7
- /**
8
- * @description: 输入框/图像验证码
9
- * @return {*}
10
- */
11
- 'input-graphic-verification' = 'input-graphic-verification',
12
- /**
13
- * @description: 输入框/手机验证码
14
- * @return {*}
15
- */
16
- 'input-mobile-verification' = 'input-mobile-verification',
17
- /**
18
- * @description: 分割线
19
- * @return {*}
20
- */
21
- 'divider' = 'divider',
22
- /**
23
- * @description: 选择器
24
- * @return {*}
25
- */
26
- 'select' = 'select',
27
- /**
28
- * @description: 级联选择器
29
- * @return {*}
30
- */
31
- 'cascader' = 'cascader',
32
- /**
33
- * @description: 日期选择器
34
- * @return {*}
35
- */
36
- 'date-picker' = 'date-picker',
37
- /**
38
- * @description: 数字输入框
39
- * @return {*}
40
- */
41
- 'input-number' = 'input-number',
42
- }
43
-
44
- export interface ItemType {
45
- type: FormType;
46
- // 扩展属性
47
- [key: string]: any
48
- };
@@ -1,17 +0,0 @@
1
-
2
- export interface BasicFormComponentsProps {
3
- item: any;
4
- // queryParams: Object | String;
5
- // size:String;
6
- // getList?:Function
7
- }
8
-
9
-
10
- export interface InputGraphicVerification {
11
- graphicSrc?: any
12
- getGraphic?: Function
13
- key: string | number
14
- };
15
- export interface InputMobileVerification {
16
- getSmscode: Function
17
- };
package/tsconfig.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "include": [
3
- "public/index.d.tsex.d.ts",
4
- "src/**/*",
5
- "src/**/*.vue",
6
- "public/*",
7
- ],
8
- "exclude": [],
9
- "compilerOptions": {
10
- "declaration": true,
11
- "allowJs": true,
12
- "composite": true
13
- }
14
- }
package/vite.config.js DELETED
@@ -1,123 +0,0 @@
1
- import legacy from '@vitejs/plugin-legacy'
2
- import { fileURLToPath } from 'url'
3
- import { defineConfig, loadEnv, splitVendorChunkPlugin } from 'vite'
4
- import vue from '@vitejs/plugin-vue'
5
- import vueJsx from '@vitejs/plugin-vue-jsx'
6
- import { ViteImageOptimizer } from 'vite-plugin-image-optimizer';
7
- import path from 'path';
8
- const __filenameNew = fileURLToPath(import.meta.url)
9
- const __dirnameNew = path.dirname(__filenameNew)
10
- const resolve = (dir) => path.resolve(__dirnameNew, dir);
11
- // https://vitejs.dev/config/
12
- export default defineConfig(({ command, mode }) => {
13
- // 根据当前工作目录中的 `mode` 加载 .env 文件
14
- // 设置第三个参数为 '' 来加载所有环境变量,而不管是否有 `VITE_` 前缀。
15
- const env = loadEnv(mode, process.cwd(), '')
16
- // console.log(command)
17
- // console.log(env)
18
- // console.log(env.CURRENT_ENV)
19
- // console.log(env.APP_ENV)
20
- // console.log(env.VUE_APP_BASE_API)
21
- return {
22
- // vite环境变量配置
23
- define: {
24
- "CURRENT_ENV": JSON.stringify(env.CURRENT_ENV),
25
- },
26
- server: {
27
- open: true,
28
- },
29
- resolve: {
30
- alias: {
31
- '@': resolve('src'),//路径化名
32
- },
33
-
34
- extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
35
- },
36
-
37
- plugins: [
38
- /**
39
- * @description: vite自带的文件分割配置
40
- * @return {*}
41
- */
42
- {
43
- ...splitVendorChunkPlugin(),
44
- apply: 'build',
45
- },
46
- /**
47
- * @description: 图片压缩插件
48
- * @return {*}
49
- */
50
- {
51
- ...ViteImageOptimizer({
52
- /* pass your config */
53
- }),
54
- // enforce: 'pre',
55
- apply: 'build',
56
- },
57
- /**
58
- * @description: 兼容旧版本浏览器
59
- * @return {*}
60
- */
61
- {
62
- ...legacy({
63
- targets: ['defaults'],
64
- }),
65
- apply: 'build',
66
- },
67
- vue(),
68
- vueJsx(),
69
- ],
70
- css: {
71
- preprocessorOptions: {
72
- less: {
73
- // 支持内联 JavaScript
74
- javascriptEnabled: true,
75
- },
76
- },
77
- },
78
- /**
79
- * @description: 打包时才调用
80
- * @return {*}
81
- */
82
- build: {
83
- lib: {
84
- // Could also be a dictionary or array of multiple entry points
85
- // 添加打包入口文件夹
86
- entry: resolve(`${__dirnameNew}/src`, 'index.ts'),
87
- // formats: ['es', 'cjs', 'umd', 'iife'],
88
- name: 'Index',
89
- // the proper extensions will be added
90
- // fileName: (format) => `index.${format}.js`,
91
- fileName: "index",
92
- },
93
- rollupOptions: {
94
- // 确保外部化处理那些你不想打包进库的依赖
95
- external: ['vue', 'vue-router', "element-plus"],
96
- output: {
97
- // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
98
- globals: {
99
- vue: 'Vue',
100
- 'vue-router': 'vue-router',
101
- "element-plus": "element-plus",
102
- },
103
- },
104
- },
105
- // minify: 'terser',
106
- //打包环境移除console.log,debugger
107
- // terserOptions: {
108
- // compress: {
109
- // drop_console: true,
110
- // drop_debugger: true,
111
- // },
112
- // },
113
- //打包文件按照类型分文件夹显示(貌似会导致性能下降)
114
- // rollupOptions: {
115
- // output: {
116
- // chunkFileNames: 'js/[name]-chunk-[hash:7].js',
117
- // entryFileNames: 'js/[name]-app-[hash:7].js',
118
- // assetFileNames: '[ext]/[name]-chunk-[hash:7].[ext]',
119
- // },
120
- // },
121
- },
122
- }
123
- })
File without changes