ylwl-cpscoms 1.1.0 → 1.3.0

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.
Files changed (40) hide show
  1. package/es/SlForm/index.vue.js +1 -1
  2. package/es/SlForm/index.vue3.js +1 -1
  3. package/package.json +7 -4
  4. package/src/DtTable/DtTable/347/273/204/344/273/266/344/275/277/347/224/250/346/226/207/346/241/243.md +0 -819
  5. package/src/DtTable/index.vue +0 -779
  6. package/src/SlAlert/SlAlert.stories.js +0 -108
  7. package/src/SlAlert/index.vue +0 -55
  8. package/src/SlAlert/remark.md +0 -16
  9. package/src/SlDescriptions/SlDescriptions.stories.js +0 -119
  10. package/src/SlDescriptions/index.vue +0 -60
  11. package/src/SlDescriptions/renderOptions.vue +0 -27
  12. package/src/SlDialog/README-PLUS.md +0 -74
  13. package/src/SlDialog/README.md +0 -114
  14. package/src/SlDialog/dialogPlus.js +0 -160
  15. package/src/SlDialog/index.js +0 -170
  16. package/src/SlDrawer/SlDrawer.stories.js +0 -154
  17. package/src/SlDrawer/index.js +0 -62
  18. package/src/SlForm/SlForm.stories.js +0 -120
  19. package/src/SlForm/index.vue +0 -506
  20. package/src/SlForm/mixinRender.js +0 -228
  21. package/src/SlForm/otherItem/titleItem.vue +0 -31
  22. package/src/SlForm/remark.md +0 -607
  23. package/src/SlGuide/SlGuide.stories.js +0 -100
  24. package/src/SlGuide/index.vue +0 -166
  25. package/src/SlGuide/remark.md +0 -90
  26. package/src/SlMessageBox/index.js +0 -35
  27. package/src/SlPage/README.md +0 -515
  28. package/src/SlPage/SlPage.stories.js +0 -125
  29. package/src/SlPage/index.vue +0 -303
  30. package/src/SlPage/remark.md +0 -283
  31. package/src/SlTable/SlTable.stories.js +0 -118
  32. package/src/SlTable/components/colSetting.vue +0 -86
  33. package/src/SlTable/index.vue +0 -541
  34. package/src/SlTitle/SlTitle.stories.js +0 -98
  35. package/src/SlTitle/index.vue +0 -49
  36. package/src/global.css +0 -5
  37. package/src/index.js +0 -49
  38. package/src/store/index.js +0 -20
  39. package/src/utils/index.js +0 -47
  40. package/src/utils/tableConfig.js +0 -33
@@ -1,506 +0,0 @@
1
- <script>
2
- import { typeOf, hasKey, filterKey, transformName } from '@/components/global/utils'
3
- import EL from 'element-ui'
4
- import mixinRender from './mixinRender'
5
-
6
- export default {
7
- name: 'SlForm',
8
- mixins: [mixinRender],
9
- props: {
10
- value: { type: Object, default: () => ({}) },
11
- itemWidth: { type: String, default: '' },
12
- data: { type: Array, default: () => [] },
13
- showlabel: { type: Boolean, default: true },
14
- drawer: { type: Boolean, default: false }, // 开启抽屉模式
15
- formProps: { type: Object, default: () => ({ inline: true }) },
16
- formItemProps: { type: Object, default: () => ({}) },
17
- pipe: { type: Object, default: () => ({}) }, // 动态管道
18
- freeData: { type: Object, default: () => ({}) }, // 游离的数据(将会合并到form一起返回)
19
- initItem: { type: Function, default: () => {} } // 初始化item的值
20
- },
21
- data() {
22
- const state = this.formateState()
23
- return {
24
- ...state,
25
- isDrawerOpen: true,
26
- boxHeight: 'auto',
27
- firstitemHeight: '0',
28
- selectOptions: {}, // 实时渲染的selectOptions
29
- selectAllOptions: {}, // 初始化好的Select的Options
30
- aggGameId: '123456'
31
- }
32
- },
33
- mounted() {
34
- // console.log('mounted', this.form)
35
- this.$emit('input', this.form)
36
- this.initFirstHieght()
37
- },
38
- methods: {
39
- // 重置
40
- reset() {
41
- const { form, transfer } = JSON.parse(
42
- JSON.stringify(this.catchInitValueData)
43
- )
44
- this.form = form
45
- this.transfer = transfer
46
- this.$emit('input', this.form)
47
- },
48
- initFirstHieght() {
49
- const { offsetHeight = 0 } = (this.$refs.firstItem || {}).$el || {}
50
- this.firstitemHeight = offsetHeight + 20 + 'px'
51
- },
52
- formateState() {
53
- const { data, freeData } = this.$props
54
- const form = { ...freeData }
55
- const transfer = {}
56
- const initData = data.reduce((pre, item) => {
57
- // debugger
58
- if (hasKey(item, ['model', 'type'])) {
59
- !item.props && (item.props = {})
60
- item = this.initItem(item) || item
61
- const { callback, model, value } = item
62
- const dispersed = typeOf(callback, 'function') // 是否离散键(拆分model键)
63
-
64
- const target = dispersed ? transfer : form //
65
- const valueSource = target[model] !== undefined ? target[model] : this.$props.value[model] !== undefined ? this.$props.value[model] : value !== undefined ? value : ''
66
- if (dispersed) {
67
- const res = callback(valueSource || '') || {}
68
- Object.keys(res).forEach((key) => {
69
- res[key] === undefined && (res[key] = '')
70
- // console.log(!hasKey(form, [key]), "form[key],", form, key, [key])
71
- !hasKey(form, [key]) && (form[key] = res[key] || '')
72
- })
73
- }
74
- // console.log(valueSource, "valueSource", !hasKey(target, [model]))
75
- !hasKey(target, [model]) && (target[model] = valueSource)
76
- pre.push(item)
77
- // if (item.show === undefined || item.show === null) pre.push(item)
78
- // else if (typeOf(item.show, 'function') && item.show()) pre.push(item)
79
- // else if (typeOf(item.show, 'boolean') && item.show) pre.push(item)
80
- }
81
- return pre
82
- }, [])
83
-
84
- // console.log(initData, "initData")
85
- setTimeout(() => {
86
- // 初始化后再watch
87
- initData.forEach((...p) => this.watchValue(...p))
88
- })
89
- // const aaa = {
90
- // form,
91
- // transfer,
92
- // initData,
93
- // catchInitValueData: {
94
- // form: JSON.parse(JSON.stringify(form)),
95
- // transfer: JSON.parse(JSON.stringify(transfer))
96
- // }
97
- // }
98
- // console.log(aaa, "zxckxzcnxzkjc")
99
- return {
100
- form,
101
- transfer,
102
- initData,
103
- catchInitValueData: {
104
- form: JSON.parse(JSON.stringify(form)),
105
- transfer: JSON.parse(JSON.stringify(transfer))
106
- }
107
- }
108
- },
109
- // 联动变化监听
110
- watchValue(item, i, ary) {
111
- const { callback, model, linkSet } = item
112
- if (typeOf(linkSet, 'function')) {
113
- const dispersed = typeOf(callback, 'function')
114
- const target = dispersed ? this.transfer : this.form
115
- const targetstr = dispersed ? 'transfer' : 'form'
116
- const watchCallback = async function(val) {
117
- let getInfo = (await linkSet(val || '')) || {}
118
- if (!Array.isArray(getInfo)) {
119
- getInfo = [getInfo]
120
- }
121
- getInfo.forEach((setItem) => {
122
-
123
- this.$set(this.selectOptions, setItem.model, setItem.options || [])
124
- let nextItem = {}
125
- const tindex = ary.findIndex((item1) => {
126
- const flag = item1.model === setItem.model
127
- flag && (nextItem = item1)
128
- return flag
129
- })
130
- console.log('watchCallback', setItem, nextItem, ary, tindex, '----', this.initData)
131
- const nextTarget = typeOf(nextItem.callback, 'function')
132
- ? this.transfer
133
- : this.form
134
- hasKey(setItem, 'value') &&
135
- (nextTarget[setItem.model] = setItem.value)
136
- tindex !== -1 && this.$set(
137
- ary,
138
- tindex,
139
- Object.assign(ary[tindex], setItem)
140
- )
141
- console.log('watchCallback22222', this.initData, ary)
142
- // this.initData = ary.filter((item) => {
143
- // console.log('watchCallback44444', item)
144
- // if ((item.show === undefined || item.show === null) || (typeOf(item.show, 'function') && item.show()) || (typeOf(item.show, 'boolean') && item.show)) {
145
- // nextTarget[setItem.model] = ''
146
- // return true
147
- // }
148
- // return false
149
- // })
150
- console.log('watchCallback333333', this.initData)
151
- })
152
-
153
- }
154
- this.$watch(`${targetstr}.${model}`, watchCallback)
155
- watchCallback.call(this, target[model]) // 首次进行绑定执行
156
- }
157
- },
158
- fomateValue(item, value = item.value) {
159
- const { callback } = item
160
- console.log('fomateValue', typeOf(callback, 'function'), this.form)
161
- if (typeOf(callback, 'function')) {
162
- this.transfer[item.model] = value
163
- const res = callback(value || '') || {}
164
- // console.log(res, 'res')
165
- Object.keys(res).forEach((key) => {
166
- res[key] === undefined && (res[key] = '')
167
- })
168
- Object.assign(this.form, res)
169
- console.log(this.form, 'this.form')
170
- } else {
171
- if (item.type === 'input') {
172
- this.form[item.model] = value.replace(/^[ \t]+|[ \t]+$/g, '');
173
- } else {
174
- this.form[item.model] = value
175
- }
176
- }
177
- },
178
- validate() {
179
- return this.$refs.form.validate()
180
- },
181
- // 提交表单
182
- submit() {
183
- return new Promise((res, rej) => {
184
- this.$refs.form.validate((isOk, msg) => {
185
- if (isOk) {
186
- res(this.form)
187
- } else {
188
- rej(msg)
189
- }
190
- })
191
- })
192
- },
193
-
194
- setItemValue(item) {
195
- const target = item.callback ? this.transfer : this.form
196
- target[item.model] = item.value
197
- },
198
- initCommonProps(item, filters = [], privateProps = {}, privateAttrs = {}) {
199
- const target = item.callback ? this.transfer : this.form
200
- // console.log('initCommonProps', item, target, this.value, item.callback ? '1' : '2', this.form)
201
- // this.form[item.model] = ''
202
- // console.log(this.form, 'this.form111', filterKey(item.props, filters), privateProps)
203
- const { itemWidth, showlabel } = this.$props
204
- return {
205
- style: `width:${showlabel ? '100%' : item.width || itemWidth};${
206
- item.style
207
- }`,
208
- props: Object.assign(
209
- {
210
- value: this.form[item.model],
211
- clearable: true,
212
- filterable: true,
213
- placeholder: showlabel ? '请输入' + item.label : item.label
214
- },
215
- filterKey(item.props, filters),
216
- privateProps
217
- ),
218
- attrs: { placeholder: showlabel ? '请输入' + item.label : item.label, ...privateAttrs },
219
- on: {
220
- input: (value) => {
221
- this.fomateValue(item, value)
222
- }
223
- }
224
- }
225
- },
226
- initOptions(item) {
227
- if (item.asycnOptions && typeOf(item.asycnOptions, 'function')) {
228
- // console.log(item.asycnOptions, 'it-----em')
229
- item.asycnOptions().then(result => {
230
- // console.log(result, "result")
231
- this.$set(this.selectOptions, item.model, result || [])
232
- })
233
- } else {
234
- this.$set(this.selectOptions, item.model, item.options || [])
235
- }
236
- }
237
- },
238
- created() {
239
- this.initData.forEach((item) => {
240
- if (['select', 'checkbox', 'radio'].includes(item.type)) {
241
- this.initOptions(item)
242
- }
243
- })
244
- },
245
-
246
- render(ce) {
247
- const { showlabel, itemWidth, drawer } = this.$props
248
- // console.log('render', this.initData)
249
- const updateInitData = this.initData.filter((item) => {
250
- if ((item.show === undefined || item.show === null) || (typeOf(item.show, 'function') && item.show()) || (typeOf(item.show, 'boolean') && item.show)) {
251
- return true
252
- }
253
- return false
254
- })
255
- const formItems = updateInitData.map((item, ii) => {
256
- const { label, model, rules, type, width, labelTips } = item
257
- if (type === 'title') {
258
- return this.renderTitle(ce, item)
259
- }
260
- // console.log(item, "itexxxxxxm", this)
261
- if (type === 'slot' && item.slotName && this.$slots[item.slotName]) {
262
- return ce('div', {
263
- class: 'yl-form-slot-container',
264
- style: item.style || ''
265
- }, this.$slots[item.slotName])
266
- }
267
-
268
- const itemBody = [this[`render${transformName(type)}`](ce, item)]
269
- const itemClass = `yl-form-item ${showlabel ? '' : 'yl-form-fullitem'} ${
270
- item.className || ''
271
- }`
272
- // if (!showlabel) {
273
- // itemBody.unshift(ce('div', { class: 'yl-i-lebel' }, label))
274
- // itemClass += 'yl-form-item-grid'
275
- // }
276
- if (
277
- item.rules &&
278
- item.rules.find(({ required }) => required) &&
279
- !showlabel
280
- ) {
281
- itemBody.unshift(ce('span', { class: 'yl-r-icon' }, '*'))
282
- }
283
- const itemSet = {
284
- class: itemClass,
285
- style: `width:${width || itemWidth};${item.style}`,
286
- props: Object.assign(
287
- { label: showlabel ? label : '', prop: model, rules },
288
- this.formItemProps
289
- ),
290
- scopedSlots: {
291
- label: () =>
292
- ce(
293
- 'span',
294
- { style: 'label-container' },
295
- [
296
- labelTips ? ce(
297
- 'el-tooltip',
298
- {
299
- props: {
300
- content: labelTips,
301
- placement: 'top'
302
- }
303
- },
304
- [
305
- ce(
306
- 'i',
307
- { class: 'el-icon-info' },
308
- []
309
- )
310
- ]
311
- ) : '',
312
- ce(
313
- 'span',
314
- { class: 'item-label', domProps: { title: label }, style: 'margin-left: 5px;' },
315
- label + ':'
316
- )
317
- ]
318
- )
319
- }
320
- }
321
- ii === 0 && (itemSet.ref = 'firstItem')
322
- const ft = ce(EL.FormItem, itemSet, itemBody)
323
- return ft
324
- })
325
- // console.log(this, "this.$scopedSlots.default")
326
- if (this.$slots.default || drawer) {
327
- const element = []
328
- // this.$slots.default &&
329
- // element.push(this.$slots.default(this.form))
330
- drawer && element.push(this.renderDrawer(ce))
331
- formItems.push(
332
- ce(
333
- 'div',
334
- {
335
- class: `yl-form-drawericon ${
336
- this.isDrawerOpen ? '' : 'yl-form-drawericon-float'
337
- }`
338
- },
339
- this.$slots.default
340
- )
341
- )
342
- }
343
- // console.log(this.formProps, "this.formProps")
344
- return ce(
345
- EL.Form,
346
- {
347
- class: {
348
- 'yl-form-box': true,
349
- 'yl-form-box-shrink': !this.isDrawerOpen,
350
- 'yl-form-box-inline': this.formProps.inline
351
- },
352
- style: `height:${this.boxHeight}`,
353
- props: Object.assign({ model: this.form }, this.formProps),
354
- ref: 'form',
355
- nativeOn: { submit: (e) => e.preventDefault() }
356
- },
357
- formItems
358
- )
359
- }
360
- }
361
- </script>
362
-
363
- <style scoped >
364
- .yl-form-item {
365
- display: flex;
366
- align-items: center;
367
-
368
- }
369
- ::v-deep .el-form-item__content {
370
- display: flex;
371
- flex: 1;
372
- margin: 0 !important;
373
- }
374
-
375
- .yl-form-fullitem .el-form-item__content {
376
- flex: 1;
377
- }
378
-
379
- .yl-form-item {
380
- display: inline-flex !important;
381
- /* margin-bottom: 20px; */
382
- }
383
- .yl-form-item .yl-form-item-grid .el-form-item__content {
384
- font-size: 0;
385
- }
386
- /* .content-box {
387
- position: absolute;
388
- right: 0;
389
- top: 0;
390
- background-color: rgba(255, 255, 255, 0.5);
391
- padding: 10px;
392
- height: 100%;
393
- box-shadow: 0 0 5px rgb(223, 222, 222);
394
- } */
395
- .item-label {
396
- display: inline-block;
397
- width: auto;
398
- overflow: hidden;
399
- text-overflow: ellipsis;
400
- white-space: nowrap;
401
- vertical-align: middle;
402
- }
403
- .yl-form-box-shrink {
404
- padding: 10px;
405
- overflow: hidden;
406
- /* border: 1px solid #c1c1c1; */
407
- background-color: #f1f1f1;
408
- /* box-shadow: inset 0 0 5px #c1c1c1; */
409
- }
410
- .yl-form-drawericon {
411
- display: inline-block;
412
- vertical-align: top;
413
- }
414
- .yl-form-drawericon-float {
415
- position: absolute;
416
- right: 0;
417
- top: 0;
418
- /* transform: translateY(-50%); */
419
- padding: 10px;
420
- z-index: 10;
421
- background-image: linear-gradient(to left, #ffa140, rgba(255, 255, 255, 0));
422
- opacity: 0.9;
423
- padding-left: 80px;
424
- }
425
- .yl-i-lebel {
426
- line-height: 12px;
427
- font-size: 12px;
428
- z-index: 5;
429
- right: 0;
430
- background-color: #979797;
431
- /* background-image: linear-gradient(to right,#dcdfe6 ,#fff); */
432
- padding: 2px 8px 4px 10px;
433
- border-radius: 4px 4px 0 0;
434
- color: #fff;
435
- width: auto;
436
- position: absolute;
437
- right: 0;
438
- top: 0;
439
- /* border: 1px solid #dcdfe6; */
440
- /* transform: scale(0.7); */
441
- border-radius: 0 4px 0px 10px;
442
- transform-origin: 100% 0;
443
- transform: scale(0.8);
444
- }
445
- .yl-r-icon {
446
- color: red;
447
- position: absolute;
448
- left: 0;
449
- top: 50%;
450
- z-index: 5;
451
- padding: 5px;
452
- line-height: 35px;
453
- transform: translateY(-50%);
454
- }
455
- .yl-form-slider {
456
- border: 1px solid #dcdfe6;
457
- border-radius: 4px;
458
- display: flex;
459
- padding: 0 20px 0 10px;
460
- line-height: 35px;
461
- }
462
- .yl-form-slider-span {
463
- padding-right: 15px;
464
- color: #c0c4cc;
465
- }
466
- .yl-form-box {
467
- white-space: normal;
468
- position: relative;
469
- transition: all 0.2s ease-out;
470
- border-radius: 4px;
471
- }
472
- .yl-form-item {
473
- white-space: nowrap;
474
- position: relative;
475
- }
476
- .yl-form-range-input {
477
- border-radius: 4px;
478
- border: 1px solid #dcdfe6;
479
- padding: 0 10px;
480
- /* line-height: 38px; */
481
- }
482
- /* .yl-form-range-input input:nth-of-type(1){
483
- margin-right: 10px;
484
- } */
485
- .yl-form-range-input input {
486
- width: 70px;
487
- border: none;
488
- height: 100%;
489
- outline: none;
490
- /* background-color: #dcdfe6; */
491
- padding: 7px;
492
- text-align: center;
493
- border-radius: 4px;
494
- }
495
- .yl-form-range-input input:focus {
496
- /* box-shadow: inset 0 0 2px #5c85e6; */
497
- }
498
- .yl-form-range-input input::placeholder {
499
- color: #c0c4cc;
500
- }
501
-
502
- .el-radio {
503
- margin-bottom: 0px!important;
504
- }
505
-
506
- </style>