tenghui-ui 1.5.2 → 1.5.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/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "tenghui-ui",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "vue 2x, tenghui-ui",
5
5
  "files": [
6
6
  "dist",
7
+ "packages",
7
8
  "types"
8
9
  ],
9
10
  "main": "./dist/tenghui-ui.umd.js",
@@ -0,0 +1,11 @@
1
+ import Vue from 'vue';
2
+ import ComTemplate from './src/index.vue';
3
+
4
+ type SFCWithInstall<T> = T & { install(app: typeof Vue): void }; // vue 安装
5
+
6
+ // 安装
7
+ ComTemplate.install = (app: typeof Vue) => {
8
+ app.component(ComTemplate.name, ComTemplate);
9
+ };
10
+ const InComTemplate: SFCWithInstall<typeof ComTemplate> = ComTemplate; // 增加类型
11
+ export default InComTemplate;
@@ -0,0 +1,21 @@
1
+ <template>
2
+ <div class="ui-template">
3
+ <h1>{{msg}}</h1>
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ export default {
9
+ name: "ComTemplate",
10
+ data() {
11
+ return {
12
+ msg: '测试组件'
13
+ }
14
+ },
15
+ methods: {
16
+ }
17
+ }
18
+ </script>
19
+
20
+ <style scoped>
21
+ </style>
@@ -0,0 +1,11 @@
1
+ import Vue from 'vue';
2
+ import ComComponent from './src/index.vue';
3
+
4
+ type SFCWithInstall<T> = T & { install(app: typeof Vue): void }; // vue 安装
5
+
6
+ // 安装
7
+ ComComponent.install = (app: typeof Vue) => {
8
+ app.component(ComComponent.name, ComComponent);
9
+ };
10
+ const InComComponent: SFCWithInstall<typeof ComComponent> = ComComponent; // 增加类型
11
+ export default InComComponent;
@@ -0,0 +1,117 @@
1
+ <template>
2
+ <el-dialog
3
+ append-to-body
4
+ :top="top"
5
+ :title="title"
6
+ :visible="visible"
7
+ :width="width"
8
+ :close-on-click-modal="closeOnClickModal"
9
+ :before-close="beforeClose"
10
+ @close="handleClose">
11
+ <slot></slot>
12
+ <template v-slot:footer>
13
+ <slot name="footer">
14
+ <el-button v-if="showBtn" size="small" @click="$emit('update:visible', false)">取消</el-button>
15
+ <el-button v-if="showBtn" size="small" type="primary" @click="handleConfirm">确定</el-button>
16
+ </slot>
17
+ </template>
18
+ </el-dialog>
19
+ </template>
20
+ <script>
21
+ export default {
22
+ name: 'ComDialog',
23
+ props: {
24
+ visible: {
25
+ type: Boolean,
26
+ default: false
27
+ },
28
+ title: {
29
+ type: String,
30
+ default: '标题'
31
+ },
32
+ width: {
33
+ type: String,
34
+ default: '600px'
35
+ },
36
+ top: {
37
+ type: String,
38
+ default: '50px'
39
+ },
40
+ closeOnClickModal: {
41
+ type: Boolean,
42
+ default: false
43
+ },
44
+ beforeClose: {
45
+ type: Function,
46
+ default(done) {
47
+ done();
48
+ }
49
+ },
50
+ showBtn: {
51
+ type: Boolean,
52
+ default: true
53
+ }
54
+ },
55
+ data() {
56
+ return {
57
+ show: false
58
+ }
59
+ },
60
+ methods: {
61
+ handleClose() {
62
+ this.$emit('close');
63
+ this.$emit('update:visible', false);
64
+ },
65
+
66
+ handleConfirm() {
67
+ this.$emit('confirm');
68
+ }
69
+ }
70
+ }
71
+ </script>
72
+ <style lang="less" scoped>
73
+ /deep/ .el-dialog__header {
74
+ border-bottom: 1px solid #ededed;
75
+
76
+ .el-dialog__title {
77
+ font-size: 16px;
78
+ }
79
+ }
80
+
81
+ /deep/ .el-dialog__footer {
82
+ border-top: 1px solid #ededed;
83
+ }
84
+
85
+ /deep/ .el-dialog__body {
86
+
87
+ .el-form {
88
+ .el-select {
89
+ width: 240px;
90
+ }
91
+
92
+ .el-input {
93
+ width: 240px;
94
+ }
95
+
96
+ .el-input-number {
97
+ width: 240px;
98
+
99
+ .el-input__inner {
100
+ text-align: left;
101
+ }
102
+ }
103
+
104
+ .ui-item__main {
105
+ width: 100%;
106
+ }
107
+
108
+ .el-form-item__label {
109
+ font-size: 12px;
110
+ }
111
+
112
+ .el-input--small .el-input__icon {
113
+ height: 32px;
114
+ }
115
+ }
116
+ }
117
+ </style>
@@ -0,0 +1,11 @@
1
+ import Vue from 'vue';
2
+ import ComComponent from './src/index.vue';
3
+
4
+ type SFCWithInstall<T> = T & { install(app: typeof Vue): void }; // vue 安装
5
+
6
+ // 安装
7
+ ComComponent.install = (app: typeof Vue) => {
8
+ app.component(ComComponent.name, ComComponent);
9
+ };
10
+ const InComComponent: SFCWithInstall<typeof ComComponent> = ComComponent; // 增加类型
11
+ export default InComComponent;
@@ -0,0 +1,54 @@
1
+ const datePickerCommonAttrs = {
2
+ 'range-separator': '至',
3
+ 'start-placeholder': '开始时间',
4
+ 'end-placeholder': '结束时间',
5
+ };
6
+ const datetimerangeDefaultAttrs = {
7
+ ...datePickerCommonAttrs,
8
+ type: 'datetimerange',
9
+ 'default-time': ['00:00:00', '23:59:59'],
10
+ 'value-format': 'yyyy-MM-dd HH:mm:ss',
11
+ format: 'yyyy-MM-dd HH:mm:ss',
12
+ };
13
+ const daterangeDefaultAttrs = {
14
+ ...datePickerCommonAttrs,
15
+ type: 'daterange',
16
+ 'value-format': 'yyyy-MM-dd',
17
+ format: 'yyyy-MM-dd',
18
+ };
19
+ const datetimeDefaultAttrs = {
20
+ type: 'datetime',
21
+ 'default-time': '00:00:00',
22
+ format: 'yyyy-MM-dd HH:mm:ss',
23
+ };
24
+ const dateDefaultAttrs = {
25
+ type: 'date',
26
+ format: 'yyyy-MM-dd',
27
+ };
28
+ export const defaultAttrsMap = {
29
+ input: {
30
+ size: 'small',
31
+ },
32
+ select: {
33
+ size: 'small',
34
+ clearable: true,
35
+ placeholder: '请选择',
36
+ },
37
+ textarea: {
38
+ placeholder: '请输入',
39
+ size: 'small',
40
+ rows: 4,
41
+ },
42
+ 'input-number': {
43
+ 'controls-position': 'right',
44
+ size: 'small',
45
+ },
46
+ cascader: {
47
+ size: 'small',
48
+ clearable: true,
49
+ },
50
+ daterange: daterangeDefaultAttrs,
51
+ datetimerange: datetimerangeDefaultAttrs,
52
+ datetime: datetimeDefaultAttrs,
53
+ date: dateDefaultAttrs
54
+ };
@@ -0,0 +1,384 @@
1
+ <template>
2
+ <div class="ui-form__item" :class="`ui-form__item--${type}`">
3
+ <div>
4
+ <slot name="label">
5
+ <div class="ui-item__label" v-if="label">
6
+ <span>{{ label }}</span>
7
+ </div>
8
+ </slot>
9
+ </div>
10
+ <div class="ui-item__main" :class="inlineLabel ? 'inline_form' : ''">
11
+ <template v-if="type === 'input'">
12
+ <span v-if="inlineLabel" class="inline_label" :style="{ width: labelWidth }">{{ inlineLabel }}</span>
13
+
14
+ <el-input
15
+ :class="{ inline_content: inlineLabel }"
16
+ :ref="type"
17
+ v-model="modelForm"
18
+ v-bind="setDefaultAttrs(polyfillAttrs($attrs))"
19
+ v-on="$listeners"
20
+ >
21
+ <template v-for="(item, key) in getComponentSlots($slots)" v-slot:[key]>
22
+ <slot :name="key"></slot>
23
+ </template>
24
+ </el-input>
25
+ </template>
26
+ <template v-else-if="type === 'select'">
27
+ <span v-if="inlineLabel" class="inline_label" :style="{ width: labelWidth }">{{ inlineLabel }}</span>
28
+ <el-select
29
+ :class="{ inline_content: inlineLabel }"
30
+ :ref="type"
31
+ :multiple="multiple"
32
+ :collapseTags="collapseTags"
33
+ :filterable="filterable"
34
+ :remote="remote"
35
+ :reserve-keyword="reserveKeyword"
36
+ :remote-method="remoteMethod"
37
+ v-model="modelForm"
38
+ v-bind="setDefaultAttrs(polyfillAttrs($attrs))"
39
+ v-on="$listeners"
40
+ >
41
+ <el-option
42
+ v-for="item in selectOption"
43
+ :key="item.value"
44
+ :value="item.value.toString()"
45
+ :label="item.label"
46
+ ></el-option>
47
+
48
+ <template v-for="(item, key) in getComponentSlots($slots)" v-slot:[key]>
49
+ <slot :name="key"></slot>
50
+ </template>
51
+ </el-select>
52
+ </template>
53
+ <template v-else-if="type === 'textarea'">
54
+ <span v-if="inlineLabel" class="inline_label" :style="{ width: labelWidth }">{{ inlineLabel }}</span>
55
+ <el-input
56
+ :class="{ inline_content: inlineLabel }"
57
+ :ref="type"
58
+ v-model="modelForm"
59
+ type="textarea"
60
+ v-on="$listeners"
61
+ v-bind="setDefaultAttrs(polyfillAttrs($attrs))"
62
+ ></el-input>
63
+ </template>
64
+ <template v-else-if="type === 'input-number'">
65
+ <span v-if="inlineLabel" class="inline_label" :style="{ width: labelWidth }">{{ inlineLabel }}</span>
66
+ <el-input-number
67
+ :class="{ inline_content: inlineLabel }"
68
+ :ref="type"
69
+ v-model="modelForm"
70
+ v-bind="setDefaultAttrs($attrs)"
71
+ v-on="$listeners"
72
+ ></el-input-number>
73
+ </template>
74
+ <template v-else-if="type === 'cascader'">
75
+ <span v-if="inlineLabel" class="inline_label" :style="{ width: labelWidth }">{{ inlineLabel }}</span>
76
+ <el-cascader
77
+ :class="{ inline_content: inlineLabel }"
78
+ :ref="type"
79
+ v-model="modelForm"
80
+ :options="options"
81
+ :props="props"
82
+ :filterable="filterable"
83
+ :collapseTags="collapseTags"
84
+ v-bind="setDefaultAttrs($attrs)"
85
+ v-on="$listeners"
86
+ ></el-cascader>
87
+ </template>
88
+ <template v-else-if="type === 'daterange'">
89
+ <span v-if="inlineLabel" class="inline_label" :style="{ width: labelWidth }">{{ inlineLabel }}</span>
90
+ <el-date-picker
91
+ :class="{ inline_content: inlineLabel }"
92
+ :ref="type"
93
+ v-model="modelForm"
94
+ v-bind="setDefaultAttrs($attrs)"
95
+ v-on="$listeners"
96
+ >
97
+ </el-date-picker>
98
+ </template>
99
+ <template v-else-if="type === 'datetimerange'">
100
+ <span v-if="inlineLabel" class="inline_label" :style="{ width: labelWidth }">{{ inlineLabel }}</span>
101
+ <el-date-picker
102
+ :class="{ inline_content: inlineLabel }"
103
+ :ref="type"
104
+ v-model="modelForm"
105
+ v-bind="setDefaultAttrs($attrs)"
106
+ v-on="$listeners"
107
+ >
108
+ </el-date-picker>
109
+ </template>
110
+ <template v-else-if="type === 'datetime'">
111
+ <span v-if="inlineLabel" class="inline_label" :style="{ width: labelWidth }">{{ inlineLabel }}</span>
112
+ <el-date-picker
113
+ :class="{ inline_content: inlineLabel }"
114
+ :ref="type"
115
+ v-model="modelForm"
116
+ v-bind="setDefaultAttrs($attrs)"
117
+ v-on="$listeners"
118
+ >
119
+ </el-date-picker>
120
+ </template>
121
+ <template v-else-if="type === 'date'">
122
+ <span v-if="inlineLabel" class="inline_label" :style="{ width: labelWidth }">{{ inlineLabel }}</span>
123
+ <el-date-picker
124
+ :class="{ inline_content: inlineLabel }"
125
+ :ref="type"
126
+ v-model="modelForm"
127
+ v-bind="setDefaultAttrs($attrs)"
128
+ v-on="$listeners"
129
+ >
130
+ </el-date-picker>
131
+ </template>
132
+ <template v-else-if="type === 'inputrange'">
133
+ <span v-if="inlineLabel" class="inline_label" :style="{ width: labelWidth }">{{ inlineLabel }}</span>
134
+ <div class="ui-input__range" :class="{ inline_content: inlineLabel }">
135
+ <el-input style="width: 50%" v-model="modelForm[0]"></el-input>
136
+ <span style="color: #dcdfe6">-</span>
137
+ <el-input style="width: 50%" v-model="modelForm[1]"></el-input>
138
+ </div>
139
+ </template>
140
+ </div>
141
+ </div>
142
+ </template>
143
+ <script>
144
+ import { defaultAttrsMap } from './defaultAttrsConfig';
145
+
146
+ export default {
147
+ name: 'ComFormItem',
148
+ model: {
149
+ prop: 'model',
150
+ event: 'changes',
151
+ },
152
+ props: {
153
+ model: undefined,
154
+
155
+ // 组件类型
156
+ type: {
157
+ type: String,
158
+ default: 'input',
159
+ },
160
+
161
+ // item name
162
+ label: {
163
+ type: String,
164
+ default: '',
165
+ },
166
+
167
+ // 使用属性透传代替了此props,但原来的使用方式一样有效果
168
+ // readonly: {
169
+ // type: Boolean,
170
+ // default: false,
171
+ // },
172
+
173
+ // 选项
174
+ options: {
175
+ type: [Object, Array],
176
+ default() {
177
+ return { 1: '选项一', 2: '选项二' };
178
+ },
179
+ },
180
+
181
+ // 选项映射
182
+ props: {
183
+ type: Object,
184
+ default() {
185
+ return { value: 'value', label: 'label' };
186
+ },
187
+ },
188
+ // 加载条
189
+ loading: {
190
+ type: Boolean,
191
+ default: false,
192
+ },
193
+
194
+ multiple: {
195
+ type: Boolean,
196
+ default: false,
197
+ },
198
+
199
+ collapseTags: {
200
+ type: Boolean,
201
+ default: true,
202
+ },
203
+
204
+ filterable: {
205
+ type: Boolean,
206
+ default: true,
207
+ },
208
+
209
+ remote: {
210
+ type: Boolean,
211
+ default: false,
212
+ },
213
+
214
+ reserveKeyword: {
215
+ type: Boolean,
216
+ default: false,
217
+ },
218
+
219
+ remoteMethod: {
220
+ type: Function,
221
+ default() {},
222
+ },
223
+
224
+ // 行内显示标签
225
+ inlineLabel: {
226
+ type: String,
227
+ default: '',
228
+ },
229
+ // 行内标签宽度
230
+ labelWidth: {
231
+ type: String,
232
+ default: '120px',
233
+ },
234
+ },
235
+ data() {
236
+ return {
237
+ modelForm: this.model,
238
+ };
239
+ },
240
+ computed: {
241
+ selectOption() {
242
+ let tempArr = [];
243
+ if (Array.isArray(this.options) && this.options.length && this.options[0][this.props.label] === undefined) {
244
+ const { label, value } = this.props;
245
+ tempArr = this.options.map((item, index) => {
246
+ const obj = {
247
+ label: item,
248
+ value: index,
249
+ };
250
+ return {
251
+ label: obj[label],
252
+ value: obj[value],
253
+ };
254
+ });
255
+ } else if (!Array.isArray(this.options)) {
256
+ tempArr = Object.entries(this.options).map(([value, label]) => {
257
+ return {
258
+ label,
259
+ value,
260
+ };
261
+ });
262
+ } else {
263
+ let options = [];
264
+ options.push(...this.options);
265
+ tempArr = options.map((item) => {
266
+ return {
267
+ label: item[this.props.label],
268
+ value: item[this.props.value],
269
+ };
270
+ });
271
+ }
272
+ return tempArr;
273
+ },
274
+ },
275
+ methods: {
276
+ // 获取需要透传到element组件的插槽
277
+ getComponentSlots(slots) {
278
+ const excludeSlots = ['label'];
279
+ const slots_ = {};
280
+
281
+ Object.entries(slots).forEach(([key, value]) => {
282
+ if (!excludeSlots.includes(key)) {
283
+ slots_[key] = value;
284
+ }
285
+ });
286
+ return slots_;
287
+ },
288
+
289
+ // 获取当前element组件实例
290
+ getCurrentInstance() {
291
+ return this.$refs[this.type];
292
+ },
293
+
294
+ // 因使用属性透传而删除了以前定义的一些props,这里做一下兼容,让以前的使用方式不改变
295
+ polyfillAttrs(attrs) {
296
+ return {
297
+ ...attrs,
298
+ disabled: attrs.readonly || attrs.disabled,
299
+ };
300
+ },
301
+
302
+ // 获取配置项
303
+ getformItemConfig() {
304
+ if (!this.$UICONFIG) return {};
305
+ const { formItemConfig } = this.$UICONFIG;
306
+ return formItemConfig || {};
307
+ },
308
+
309
+ // 设置elemenet组件默认属性
310
+ setDefaultAttrs(attrs) {
311
+ const { type } = this;
312
+ const formItemConfig = this.getformItemConfig();
313
+ const defaultAttrs = formItemConfig[type] || defaultAttrsMap[type] || {};
314
+ return {
315
+ ...defaultAttrs,
316
+ ...attrs,
317
+ };
318
+ },
319
+ },
320
+ watch: {
321
+ modelForm(val) {
322
+ this.$emit('changes', val);
323
+ },
324
+ model(val) {
325
+ this.modelForm = val;
326
+ },
327
+ },
328
+ };
329
+ </script>
330
+ <style lang="less" scoped>
331
+ .ui-form__item {
332
+ display: flex;
333
+ align-items: center;
334
+ margin-right: 15px;
335
+ }
336
+
337
+ .ui-item__label {
338
+ margin-right: 10px;
339
+ font-size: 12px;
340
+ width: 70px;
341
+ text-align: right;
342
+ }
343
+ // 使用远程搜索时箭头图标高亮显示
344
+ ::v-deep.el-select {
345
+ .el-select__caret:first-child::before {
346
+ content: '\e6e1';
347
+ }
348
+ .is-focus {
349
+ .el-select__caret:first-child {
350
+ transform: rotateZ(0deg);
351
+ }
352
+ }
353
+ }
354
+
355
+ .ui-input__range {
356
+ max-width: 240px;
357
+ display: flex;
358
+
359
+ & > span {
360
+ line-height: 28px;
361
+ }
362
+ }
363
+
364
+ .el-date-editor {
365
+ width: 100% !important;
366
+ }
367
+
368
+ .inline_form {
369
+ display: flex;
370
+ margin-bottom: 10px;
371
+ }
372
+
373
+ .inline_label {
374
+ display: inline-block;
375
+ height: 32px;
376
+ line-height: 32px;
377
+ font-size: 12px;
378
+ text-align: right;
379
+ padding-right: 10px;
380
+ }
381
+ .inline_content {
382
+ flex: 1;
383
+ }
384
+ </style>
@@ -0,0 +1,11 @@
1
+ import Vue from 'vue';
2
+ import ComComponent from './src/index.vue';
3
+
4
+ type SFCWithInstall<T> = T & { install(app: typeof Vue): void }; // vue 安装
5
+
6
+ // 安装
7
+ ComComponent.install = (app: typeof Vue) => {
8
+ app.component(ComComponent.name, ComComponent);
9
+ };
10
+ const InComComponent: SFCWithInstall<typeof ComComponent> = ComComponent; // 增加类型
11
+ export default InComComponent;