ylwl-cpscoms 1.0.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.
- package/README.md +15 -0
- package/es/SlAlert/index.vue.js +58 -0
- package/es/SlAlert/index.vue2.js +37 -0
- package/es/SlAlert/index.vue3.js +6 -0
- package/es/SlDescriptions/index.vue.js +55 -0
- package/es/SlDescriptions/index.vue2.js +57 -0
- package/es/SlDescriptions/index.vue3.js +6 -0
- package/es/SlDescriptions/renderOptions.vue.js +25 -0
- package/es/SlDescriptions/renderOptions.vue2.js +31 -0
- package/es/SlDialog/dialogPlus.js +159 -0
- package/es/SlDialog/index.js +202 -0
- package/es/SlDrawer/index.js +54 -0
- package/es/SlForm/index.vue.js +26 -0
- package/es/SlForm/index.vue2.js +433 -0
- package/es/SlForm/index.vue3.js +6 -0
- package/es/SlForm/mixinRender.js +239 -0
- package/es/SlForm/otherItem/titleItem.vue.js +39 -0
- package/es/SlForm/otherItem/titleItem.vue2.js +20 -0
- package/es/SlForm/otherItem/titleItem.vue3.js +6 -0
- package/es/SlGuide/index.vue.js +38 -0
- package/es/SlGuide/index.vue2.js +133 -0
- package/es/SlGuide/index.vue3.js +6 -0
- package/es/SlGuide/index.vue4.js +6 -0
- package/es/SlMessageBox/index.js +46 -0
- package/es/SlPage/index.vue.js +147 -0
- package/es/SlPage/index.vue2.js +312 -0
- package/es/SlPage/index.vue3.js +6 -0
- package/es/SlTable/components/colSetting.vue.js +94 -0
- package/es/SlTable/components/colSetting.vue2.js +66 -0
- package/es/SlTable/components/colSetting.vue3.js +6 -0
- package/es/SlTable/index.vue.js +171 -0
- package/es/SlTable/index.vue2.js +390 -0
- package/es/SlTable/index.vue3.js +6 -0
- package/es/SlTitle/index.vue.js +41 -0
- package/es/SlTitle/index.vue2.js +26 -0
- package/es/SlTitle/index.vue3.js +6 -0
- package/es/_virtual/_rollupPluginBabelHelpers.js +247 -0
- package/es/index.js +41 -0
- package/es/node_modules/shepherd.js/dist/css/shepherd.css.js +7 -0
- package/es/node_modules/style-inject/dist/style-inject.es.js +28 -0
- package/es/node_modules/vue-runtime-helpers/dist/normalize-component.js +76 -0
- package/es/utils/index.js +51 -0
- package/package.json +106 -0
- package/src/SlAlert/SlAlert.stories.js +108 -0
- package/src/SlAlert/index.vue +54 -0
- package/src/SlAlert/remark.md +16 -0
- package/src/SlDescriptions/SlDescriptions.stories.js +119 -0
- package/src/SlDescriptions/index.vue +60 -0
- package/src/SlDescriptions/renderOptions.vue +27 -0
- package/src/SlDialog/README-PLUS.md +74 -0
- package/src/SlDialog/README.md +114 -0
- package/src/SlDialog/dialogPlus.js +160 -0
- package/src/SlDialog/index.js +170 -0
- package/src/SlDrawer/SlDrawer.stories.js +154 -0
- package/src/SlDrawer/index.js +62 -0
- package/src/SlForm/SlForm.stories.js +120 -0
- package/src/SlForm/index.css +141 -0
- package/src/SlForm/index.vue +365 -0
- package/src/SlForm/mixinRender.js +228 -0
- package/src/SlForm/otherItem/titleItem.vue +31 -0
- package/src/SlForm/remark.md +607 -0
- package/src/SlGuide/SlGuide.stories.js +100 -0
- package/src/SlGuide/index.vue +166 -0
- package/src/SlGuide/remark.md +90 -0
- package/src/SlMessageBox/index.js +35 -0
- package/src/SlPage/README.md +515 -0
- package/src/SlPage/SlPage.stories.js +125 -0
- package/src/SlPage/index.css +38 -0
- package/src/SlPage/index.vue +266 -0
- package/src/SlPage/remark.md +283 -0
- package/src/SlTable/SlTable.stories.js +118 -0
- package/src/SlTable/components/colSetting.vue +86 -0
- package/src/SlTable/index.vue +541 -0
- package/src/SlTitle/SlTitle.stories.js +98 -0
- package/src/SlTitle/index.vue +49 -0
- package/src/global.css +5 -0
- package/src/index.js +47 -0
- package/src/store/index.js +20 -0
- package/src/utils/index.js +47 -0
- package/src/utils/tableConfig.js +33 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import Vue from 'vue'
|
|
2
|
+
import { Button } from 'element-ui'
|
|
3
|
+
import { isMobileDevice } from '../utils'
|
|
4
|
+
export function createCommandDialog(options) {
|
|
5
|
+
const defaultOptions = {
|
|
6
|
+
title: '提示',
|
|
7
|
+
width: '50%',
|
|
8
|
+
specialWidth: '',
|
|
9
|
+
closeOnClickModal: false,
|
|
10
|
+
contentComponent: null,
|
|
11
|
+
contentProps: {},
|
|
12
|
+
footerBtns: [],
|
|
13
|
+
cancelButtonText: '取消',
|
|
14
|
+
confirmButtonText: '确定',
|
|
15
|
+
isShowBtn: true,
|
|
16
|
+
showClose: true,
|
|
17
|
+
closeOnPressEscape: false,
|
|
18
|
+
customClass: ''
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const mergedOptions = { ...defaultOptions, ...options }
|
|
22
|
+
|
|
23
|
+
const Constructor = Vue.extend({
|
|
24
|
+
data() {
|
|
25
|
+
return {
|
|
26
|
+
visible: false // 初始状态为 false
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
created() {
|
|
30
|
+
// 在 created 钩子中,将配置项直接浅拷贝到 this 实例上
|
|
31
|
+
Object.assign(this, mergedOptions)
|
|
32
|
+
},
|
|
33
|
+
mounted() {
|
|
34
|
+
Vue.nextTick(() => {
|
|
35
|
+
this.visible = true
|
|
36
|
+
})
|
|
37
|
+
},
|
|
38
|
+
methods: {
|
|
39
|
+
handleBeforeClose() {
|
|
40
|
+
this.visible = false
|
|
41
|
+
},
|
|
42
|
+
handleClose(done) {
|
|
43
|
+
this.handleBeforeClose()
|
|
44
|
+
if (typeof this.onClose === 'function') {
|
|
45
|
+
this.onClose(this)
|
|
46
|
+
}
|
|
47
|
+
this.$once('closed', () => {
|
|
48
|
+
this.$destroy()
|
|
49
|
+
document.body.removeChild(this.$el)
|
|
50
|
+
})
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
handleCancel() {
|
|
54
|
+
this.handleBeforeClose()
|
|
55
|
+
if (typeof this.onCancel === 'function') {
|
|
56
|
+
this.onCancel()
|
|
57
|
+
}
|
|
58
|
+
this.handleClose()
|
|
59
|
+
},
|
|
60
|
+
async handleConfirm() {
|
|
61
|
+
// body组件中统一confirm方法(不能用在别的地方)
|
|
62
|
+
let shouldClose = true
|
|
63
|
+
if (this.$refs.contentComponent.confirm) {
|
|
64
|
+
try {
|
|
65
|
+
const result = await this.$refs.contentComponent.confirm()
|
|
66
|
+
if (result === false) shouldClose = false
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.error('弹窗确认时发生错误:', error)
|
|
69
|
+
shouldClose = false
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (typeof this.onConfirm === 'function' && shouldClose) {
|
|
73
|
+
this.onConfirm()
|
|
74
|
+
}
|
|
75
|
+
if (shouldClose) {
|
|
76
|
+
this.handleClose()
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
// 函数 return false 弹窗不消失; 不返回或者true 弹窗消失
|
|
80
|
+
async footerBtnsClick(type) {
|
|
81
|
+
if (this.$refs.contentComponent && this.$refs.contentComponent[type]) {
|
|
82
|
+
const result = await this.$refs.contentComponent[type]()
|
|
83
|
+
if (result !== false) {
|
|
84
|
+
this.handleClose()
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
this.handleClose()
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
render(h) {
|
|
93
|
+
const footerContent = this.footerBtns.length
|
|
94
|
+
? h('div',
|
|
95
|
+
this.footerBtns.map(item => h(Button, {
|
|
96
|
+
props: {
|
|
97
|
+
type: item.type || 'default',
|
|
98
|
+
size: 'small'
|
|
99
|
+
},
|
|
100
|
+
on: {
|
|
101
|
+
click: () => this.footerBtnsClick(item.value)
|
|
102
|
+
}
|
|
103
|
+
}, item.label)
|
|
104
|
+
)
|
|
105
|
+
) : h('div', [
|
|
106
|
+
h(Button, {
|
|
107
|
+
props: {
|
|
108
|
+
type: 'default',
|
|
109
|
+
size: 'small'
|
|
110
|
+
},
|
|
111
|
+
on: {
|
|
112
|
+
click: this.handleCancel
|
|
113
|
+
}
|
|
114
|
+
}, this.cancelButtonText),
|
|
115
|
+
h(Button, {
|
|
116
|
+
props: {
|
|
117
|
+
type: 'primary',
|
|
118
|
+
size: 'small'
|
|
119
|
+
},
|
|
120
|
+
on: {
|
|
121
|
+
click: this.handleConfirm
|
|
122
|
+
}
|
|
123
|
+
}, this.confirmButtonText)
|
|
124
|
+
])
|
|
125
|
+
|
|
126
|
+
return h(
|
|
127
|
+
'el-dialog',
|
|
128
|
+
{
|
|
129
|
+
props: {
|
|
130
|
+
title: this.title,
|
|
131
|
+
visible: this.visible,
|
|
132
|
+
width: isMobileDevice() ? '90%' : this.specialWidth ? this.specialWidth : this.width === '30%' ? '30%' : '50%',
|
|
133
|
+
'close-on-click-modal': this.closeOnClickModal,
|
|
134
|
+
showClose: this.showClose,
|
|
135
|
+
'close-on-press-escape': this.closeOnPressEscape,
|
|
136
|
+
customClass: this.customClass
|
|
137
|
+
},
|
|
138
|
+
on: {
|
|
139
|
+
'update:visible': (val) => {
|
|
140
|
+
this.visible = val
|
|
141
|
+
},
|
|
142
|
+
'before-close': this.handleBeforeClose,
|
|
143
|
+
'close': this.handleClose,
|
|
144
|
+
'closed': () => { this.$emit('closed') }
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
[
|
|
148
|
+
h(this.contentComponent, {
|
|
149
|
+
props: this.contentProps,
|
|
150
|
+
ref: 'contentComponent',
|
|
151
|
+
scopedSlots: this.$scopedSlots,
|
|
152
|
+
on: {
|
|
153
|
+
onClose: () => {
|
|
154
|
+
this.handleClose()
|
|
155
|
+
},
|
|
156
|
+
onConfirm: () => {
|
|
157
|
+
this.handleConfirm()
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}),
|
|
161
|
+
!this.isShowBtn ? '' : h('template', { slot: 'footer' }, [footerContent])
|
|
162
|
+
]
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
const instance = new Constructor().$mount()
|
|
168
|
+
|
|
169
|
+
document.body.appendChild(instance.$el)
|
|
170
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { createCommandDrawer } from './index.js'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Components/SlDrawer',
|
|
5
|
+
parameters: {
|
|
6
|
+
docs: {
|
|
7
|
+
description: {
|
|
8
|
+
component: '命令式抽屉组件,通过 `createCommandDrawer(options)` 函数调用打开。基于 el-drawer 封装,支持传入自定义内容组件、Props 和事件监听。'
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const codeBlock = (code) => `
|
|
15
|
+
<div style="margin-top:24px;border-top:1px solid #eee;padding-top:16px">
|
|
16
|
+
<p style="font-size:14px;font-weight:600;color:#666;margin-bottom:8px;">使用代码:</p>
|
|
17
|
+
<pre style="background:#f5f5f5;padding:16px;border-radius:4px;overflow-x:auto;font-size:13px;line-height:1.6;white-space:pre-wrap;word-break:break-all"><code>${escapeHtml(code.trim())}</code></pre>
|
|
18
|
+
</div>`
|
|
19
|
+
|
|
20
|
+
function escapeHtml(str) {
|
|
21
|
+
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 演示用的简单内容组件
|
|
25
|
+
const DemoContent = {
|
|
26
|
+
props: { message: { type: String, default: '' } },
|
|
27
|
+
template: `
|
|
28
|
+
<div style="padding:20px">
|
|
29
|
+
<p>{{ message }}</p>
|
|
30
|
+
<p style="color:#999;font-size:13px;margin-top:12px">这是通过 createCommandDrawer 打开的内容区域。</p>
|
|
31
|
+
</div>`
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ---- 基础用法 ----
|
|
35
|
+
const defaultCode = `<!-- 使用方式 -->
|
|
36
|
+
<script>
|
|
37
|
+
import { createCommandDrawer } from '@/components/global/SlDrawer'
|
|
38
|
+
|
|
39
|
+
createCommandDrawer({
|
|
40
|
+
title: '抽屉标题',
|
|
41
|
+
size: '30%',
|
|
42
|
+
direction: 'rtl',
|
|
43
|
+
contentComponent: YourComponent,
|
|
44
|
+
closeDrawer: () => {
|
|
45
|
+
console.log('抽屉已关闭')
|
|
46
|
+
},
|
|
47
|
+
contentProps: {
|
|
48
|
+
message: 'Hello'
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
</script>`
|
|
52
|
+
|
|
53
|
+
export const Default = () => ({
|
|
54
|
+
methods: {
|
|
55
|
+
openDrawer() {
|
|
56
|
+
createCommandDrawer({
|
|
57
|
+
title: '用户详情',
|
|
58
|
+
size: '30%',
|
|
59
|
+
direction: 'rtl',
|
|
60
|
+
contentComponent: DemoContent,
|
|
61
|
+
closeDrawer: () => {
|
|
62
|
+
console.log('抽屉已关闭')
|
|
63
|
+
},
|
|
64
|
+
contentProps: {
|
|
65
|
+
message: '这是通过命令式 API 打开的抽屉'
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
template: `
|
|
71
|
+
<div>
|
|
72
|
+
<el-button type="primary" @click="openDrawer">打开抽屉</el-button>
|
|
73
|
+
${codeBlock(defaultCode)}
|
|
74
|
+
</div>`
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
Default.storyName = '基础用法'
|
|
78
|
+
|
|
79
|
+
// ---- 左侧弹出 ----
|
|
80
|
+
const leftCode = `<!-- 左侧弹出 -->
|
|
81
|
+
createCommandDrawer({
|
|
82
|
+
title: '筛选条件',
|
|
83
|
+
size: '25%',
|
|
84
|
+
direction: 'ltr',
|
|
85
|
+
contentComponent: FilterPanel,
|
|
86
|
+
closeDrawer: () => {},
|
|
87
|
+
contentProps: { ... }
|
|
88
|
+
})`
|
|
89
|
+
|
|
90
|
+
export const LeftDirection = () => ({
|
|
91
|
+
methods: {
|
|
92
|
+
openDrawer() {
|
|
93
|
+
createCommandDrawer({
|
|
94
|
+
title: '筛选条件',
|
|
95
|
+
size: '25%',
|
|
96
|
+
direction: 'ltr',
|
|
97
|
+
contentComponent: DemoContent,
|
|
98
|
+
closeDrawer: () => {
|
|
99
|
+
console.log('左侧抽屉已关闭')
|
|
100
|
+
},
|
|
101
|
+
contentProps: {
|
|
102
|
+
message: '从左侧弹出的抽屉'
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
template: `
|
|
108
|
+
<div>
|
|
109
|
+
<el-button type="success" @click="openDrawer">左侧弹出</el-button>
|
|
110
|
+
${codeBlock(leftCode)}
|
|
111
|
+
</div>`
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
LeftDirection.storyName = '左侧弹出'
|
|
115
|
+
|
|
116
|
+
// ---- 大尺寸 ----
|
|
117
|
+
const largeCode = `<!-- 大尺寸抽屉 -->
|
|
118
|
+
createCommandDrawer({
|
|
119
|
+
title: '编辑信息',
|
|
120
|
+
size: '50%',
|
|
121
|
+
direction: 'rtl',
|
|
122
|
+
contentComponent: EditForm,
|
|
123
|
+
closeDrawer: () => { this.loadData() },
|
|
124
|
+
contentProps: { data: rowData },
|
|
125
|
+
contentListeners: {
|
|
126
|
+
'save-success': () => { this.refresh() }
|
|
127
|
+
}
|
|
128
|
+
})`
|
|
129
|
+
|
|
130
|
+
export const LargeSize = () => ({
|
|
131
|
+
methods: {
|
|
132
|
+
openDrawer() {
|
|
133
|
+
createCommandDrawer({
|
|
134
|
+
title: '编辑信息',
|
|
135
|
+
size: '50%',
|
|
136
|
+
direction: 'rtl',
|
|
137
|
+
contentComponent: DemoContent,
|
|
138
|
+
closeDrawer: () => {
|
|
139
|
+
console.log('大尺寸抽屉已关闭')
|
|
140
|
+
},
|
|
141
|
+
contentProps: {
|
|
142
|
+
message: '大尺寸抽屉,适合表单编辑场景'
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
template: `
|
|
148
|
+
<div>
|
|
149
|
+
<el-button type="warning" @click="openDrawer">大尺寸抽屉(50%)</el-button>
|
|
150
|
+
${codeBlock(largeCode)}
|
|
151
|
+
</div>`
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
LargeSize.storyName = '大尺寸抽屉'
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
|
|
2
|
+
import Vue from 'vue'
|
|
3
|
+
|
|
4
|
+
export function createCommandDrawer(options) {
|
|
5
|
+
const Constructor = Vue.extend({
|
|
6
|
+
data() {
|
|
7
|
+
return {
|
|
8
|
+
visible: true,
|
|
9
|
+
...options
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
methods: {
|
|
13
|
+
handleClose(done) {
|
|
14
|
+
this.visible = false
|
|
15
|
+
this.closeDrawer()
|
|
16
|
+
done()
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
render(h) {
|
|
20
|
+
const componentListeners = this.contentListeners || {}
|
|
21
|
+
return h(
|
|
22
|
+
'el-drawer',
|
|
23
|
+
{
|
|
24
|
+
props: {
|
|
25
|
+
title: this.title,
|
|
26
|
+
size: this.size,
|
|
27
|
+
direction: this.direction,
|
|
28
|
+
beforeClose: this.handleClose,
|
|
29
|
+
visible: this.visible
|
|
30
|
+
|
|
31
|
+
},
|
|
32
|
+
on: {
|
|
33
|
+
input: (val) => {
|
|
34
|
+
this.visible = val
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
[
|
|
39
|
+
h(this.contentComponent, {
|
|
40
|
+
props: this.contentProps,
|
|
41
|
+
on: componentListeners
|
|
42
|
+
})
|
|
43
|
+
]
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const instance = new Constructor().$mount()
|
|
49
|
+
|
|
50
|
+
document.body.appendChild(instance.$el)
|
|
51
|
+
|
|
52
|
+
instance.visible = true
|
|
53
|
+
window.addEventListener('keydown', (event) => {
|
|
54
|
+
if (event.code === 'Space' || event.key === ' ') {
|
|
55
|
+
event.preventDefault()
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
instance.$once('close', () => {
|
|
59
|
+
instance.$destroy()
|
|
60
|
+
document.body.removeChild(instance.$el)
|
|
61
|
+
})
|
|
62
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import SlForm from './index.vue'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Components/SlForm',
|
|
5
|
+
component: SlForm,
|
|
6
|
+
parameters: {
|
|
7
|
+
docs: {
|
|
8
|
+
description: {
|
|
9
|
+
component: '动态表单组件,通过 data 配置数组驱动渲染。支持 input、select、datePicker、radio、switch、rangeInput、title、slot 等控件类型。支持表单校验、联动、重置等功能。'
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const codeBlock = (code) => `
|
|
16
|
+
<div style="margin-top:24px;border-top:1px solid #eee;padding-top:16px">
|
|
17
|
+
<p style="font-size:14px;font-weight:600;color:#666;margin-bottom:8px;">使用代码:</p>
|
|
18
|
+
<pre style="background:#f5f5f5;padding:16px;border-radius:4px;overflow-x:auto;font-size:13px;line-height:1.6;white-space:pre-wrap;word-break:break-all"><code>${escapeHtml(code.trim())}</code></pre>
|
|
19
|
+
</div>`
|
|
20
|
+
|
|
21
|
+
function escapeHtml(str) {
|
|
22
|
+
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// ---- 搜索表单 ----
|
|
26
|
+
const searchCode = `<!-- 搜索表单(inline 模式) -->
|
|
27
|
+
<sl-form v-model="form" :data="options"
|
|
28
|
+
:showlabel="false"
|
|
29
|
+
:form-props="{ inline: true, size: 'small' }" />`
|
|
30
|
+
|
|
31
|
+
export const SearchForm = () => ({
|
|
32
|
+
components: { SlForm },
|
|
33
|
+
data() {
|
|
34
|
+
return {
|
|
35
|
+
form: {},
|
|
36
|
+
options: [
|
|
37
|
+
{ label: '用户名', type: 'input', model: 'userName', privateAttrs: { placeholder: '请输入用户名' } },
|
|
38
|
+
{ label: '状态', type: 'select', model: 'status', options: [
|
|
39
|
+
{ label: '启用', value: 1 }, { label: '禁用', value: 0 }
|
|
40
|
+
], props: { placeholder: '请选择状态' } },
|
|
41
|
+
{ label: '创建时间', type: 'datePicker', model: 'createTime', privateProps: { type: 'daterange', valueFormat: 'yyyy-MM-dd' } }
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
template: `
|
|
46
|
+
<div>
|
|
47
|
+
<sl-form ref="form" v-model="form" :data="options" :showlabel="false" :form-props="{ inline: true, size: 'small' }" />
|
|
48
|
+
<div style="margin-top:12px;color:#666;font-size:13px">表单值:{{ form }}</div>
|
|
49
|
+
${codeBlock(searchCode)}
|
|
50
|
+
</div>`
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
SearchForm.storyName = '搜索表单(inline)'
|
|
54
|
+
|
|
55
|
+
// ---- 编辑表单 ----
|
|
56
|
+
const editCode = `<!-- 编辑表单(非 inline) -->
|
|
57
|
+
<sl-form v-model="form" :data="options" item-width="100%"
|
|
58
|
+
:form-props="{ inline: false, size: 'small', labelWidth: '120px' }" />`
|
|
59
|
+
|
|
60
|
+
export const EditForm = () => ({
|
|
61
|
+
components: { SlForm },
|
|
62
|
+
data() {
|
|
63
|
+
return {
|
|
64
|
+
form: { userName: '张三', status: 1 },
|
|
65
|
+
options: [
|
|
66
|
+
{ label: '用户名', type: 'input', model: 'userName', rules: [
|
|
67
|
+
{ required: true, message: '请输入用户名', trigger: 'blur' }
|
|
68
|
+
]},
|
|
69
|
+
{ label: '状态', type: 'radio', model: 'status', options: [
|
|
70
|
+
{ label: '启用', value: 1 }, { label: '禁用', value: 0 }
|
|
71
|
+
], rules: [
|
|
72
|
+
{ required: true, message: '请选择状态', trigger: 'change' }
|
|
73
|
+
]},
|
|
74
|
+
{ label: '备注', type: 'input', model: 'remark', privateAttrs: { type: 'textarea', rows: 3 }, remark: '选填,最多200字' },
|
|
75
|
+
{ label: '开关', type: 'switch', model: 'enable', value: true }
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
template: `
|
|
80
|
+
<div style="max-width:600px">
|
|
81
|
+
<sl-form ref="form" v-model="form" :data="options" item-width="100%" :form-props="{ inline: false, size: 'small', labelWidth: '120px' }" />
|
|
82
|
+
<div style="margin-top:12px;color:#666;font-size:13px">表单值:{{ form }}</div>
|
|
83
|
+
${codeBlock(editCode)}
|
|
84
|
+
</div>`
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
EditForm.storyName = '编辑表单'
|
|
88
|
+
|
|
89
|
+
// ---- 带标题分组 ----
|
|
90
|
+
const titleCode = `<!-- 使用 title 类型分组 -->
|
|
91
|
+
<sl-form v-model="form" :data="options" item-width="100%"
|
|
92
|
+
:form-props="{ inline: false, size: 'small', labelWidth: '120px' }">
|
|
93
|
+
<el-button type="primary" size="small">保存</el-button>
|
|
94
|
+
</sl-form>`
|
|
95
|
+
|
|
96
|
+
export const WithTitle = () => ({
|
|
97
|
+
components: { SlForm },
|
|
98
|
+
data() {
|
|
99
|
+
return {
|
|
100
|
+
form: {},
|
|
101
|
+
options: [
|
|
102
|
+
{ type: 'title', label: '基本信息', model: 'title1' },
|
|
103
|
+
{ label: '姓名', type: 'input', model: 'name' },
|
|
104
|
+
{ label: '年龄', type: 'input', model: 'age' },
|
|
105
|
+
{ type: 'title', label: '联系方式', model: 'title2' },
|
|
106
|
+
{ label: '手机号', type: 'input', model: 'phone' },
|
|
107
|
+
{ label: '邮箱', type: 'input', model: 'email' }
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
template: `
|
|
112
|
+
<div style="max-width:600px">
|
|
113
|
+
<sl-form ref="form" v-model="form" :data="options" item-width="100%" :form-props="{ inline: false, size: 'small', labelWidth: '120px' }">
|
|
114
|
+
<el-button type="primary" size="small">保存</el-button>
|
|
115
|
+
</sl-form>
|
|
116
|
+
${codeBlock(titleCode)}
|
|
117
|
+
</div>`
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
WithTitle.storyName = '带标题分组'
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
.yl-form-item {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
|
|
5
|
+
}
|
|
6
|
+
::v-deep .el-form-item__content {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex: 1;
|
|
9
|
+
margin: 0 !important;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.yl-form-fullitem .el-form-item__content {
|
|
13
|
+
flex: 1;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.yl-form-item {
|
|
17
|
+
display: inline-flex !important;
|
|
18
|
+
/* margin-bottom: 20px; */
|
|
19
|
+
}
|
|
20
|
+
.yl-form-item .yl-form-item-grid .el-form-item__content {
|
|
21
|
+
font-size: 0;
|
|
22
|
+
}
|
|
23
|
+
.content-box {
|
|
24
|
+
position: absolute;
|
|
25
|
+
right: 0;
|
|
26
|
+
top: 0;
|
|
27
|
+
background-color: rgba(255, 255, 255, 0.5);
|
|
28
|
+
padding: 10px;
|
|
29
|
+
height: 100%;
|
|
30
|
+
box-shadow: 0 0 5px rgb(223, 222, 222);
|
|
31
|
+
}
|
|
32
|
+
.item-label {
|
|
33
|
+
display: inline-block;
|
|
34
|
+
width: auto;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
text-overflow: ellipsis;
|
|
37
|
+
white-space: nowrap;
|
|
38
|
+
vertical-align: middle;
|
|
39
|
+
}
|
|
40
|
+
.yl-form-box-shrink {
|
|
41
|
+
padding: 10px;
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
/* border: 1px solid #c1c1c1; */
|
|
44
|
+
background-color: #f1f1f1;
|
|
45
|
+
/* box-shadow: inset 0 0 5px #c1c1c1; */
|
|
46
|
+
}
|
|
47
|
+
.yl-form-drawericon {
|
|
48
|
+
display: inline-block;
|
|
49
|
+
vertical-align: top;
|
|
50
|
+
}
|
|
51
|
+
.yl-form-drawericon-float {
|
|
52
|
+
position: absolute;
|
|
53
|
+
right: 0;
|
|
54
|
+
top: 0;
|
|
55
|
+
/* transform: translateY(-50%); */
|
|
56
|
+
padding: 10px;
|
|
57
|
+
z-index: 10;
|
|
58
|
+
background-image: linear-gradient(to left, #ffa140, rgba(255, 255, 255, 0));
|
|
59
|
+
opacity: 0.9;
|
|
60
|
+
padding-left: 80px;
|
|
61
|
+
}
|
|
62
|
+
.yl-i-lebel {
|
|
63
|
+
line-height: 12px;
|
|
64
|
+
font-size: 12px;
|
|
65
|
+
z-index: 5;
|
|
66
|
+
right: 0;
|
|
67
|
+
background-color: #979797;
|
|
68
|
+
/* background-image: linear-gradient(to right,#dcdfe6 ,#fff); */
|
|
69
|
+
padding: 2px 8px 4px 10px;
|
|
70
|
+
border-radius: 4px 4px 0 0;
|
|
71
|
+
color: #fff;
|
|
72
|
+
width: auto;
|
|
73
|
+
position: absolute;
|
|
74
|
+
right: 0;
|
|
75
|
+
top: 0;
|
|
76
|
+
/* border: 1px solid #dcdfe6; */
|
|
77
|
+
/* transform: scale(0.7); */
|
|
78
|
+
border-radius: 0 4px 0px 10px;
|
|
79
|
+
transform-origin: 100% 0;
|
|
80
|
+
transform: scale(0.8);
|
|
81
|
+
}
|
|
82
|
+
.yl-r-icon {
|
|
83
|
+
color: red;
|
|
84
|
+
position: absolute;
|
|
85
|
+
left: 0;
|
|
86
|
+
top: 50%;
|
|
87
|
+
z-index: 5;
|
|
88
|
+
padding: 5px;
|
|
89
|
+
line-height: 35px;
|
|
90
|
+
transform: translateY(-50%);
|
|
91
|
+
}
|
|
92
|
+
.yl-form-slider {
|
|
93
|
+
border: 1px solid #dcdfe6;
|
|
94
|
+
border-radius: 4px;
|
|
95
|
+
display: flex;
|
|
96
|
+
padding: 0 20px 0 10px;
|
|
97
|
+
line-height: 35px;
|
|
98
|
+
}
|
|
99
|
+
.yl-form-slider-span {
|
|
100
|
+
padding-right: 15px;
|
|
101
|
+
color: #c0c4cc;
|
|
102
|
+
}
|
|
103
|
+
.yl-form-box {
|
|
104
|
+
white-space: normal;
|
|
105
|
+
position: relative;
|
|
106
|
+
transition: all 0.2s ease-out;
|
|
107
|
+
border-radius: 4px;
|
|
108
|
+
}
|
|
109
|
+
.yl-form-item {
|
|
110
|
+
white-space: nowrap;
|
|
111
|
+
position: relative;
|
|
112
|
+
}
|
|
113
|
+
.yl-form-range-input {
|
|
114
|
+
border-radius: 4px;
|
|
115
|
+
border: 1px solid #dcdfe6;
|
|
116
|
+
padding: 0 10px;
|
|
117
|
+
/* line-height: 38px; */
|
|
118
|
+
}
|
|
119
|
+
/* .yl-form-range-input input:nth-of-type(1){
|
|
120
|
+
margin-right: 10px;
|
|
121
|
+
} */
|
|
122
|
+
.yl-form-range-input input {
|
|
123
|
+
width: 70px;
|
|
124
|
+
border: none;
|
|
125
|
+
height: 100%;
|
|
126
|
+
outline: none;
|
|
127
|
+
/* background-color: #dcdfe6; */
|
|
128
|
+
padding: 7px;
|
|
129
|
+
text-align: center;
|
|
130
|
+
border-radius: 4px;
|
|
131
|
+
}
|
|
132
|
+
.yl-form-range-input input:focus {
|
|
133
|
+
/* box-shadow: inset 0 0 2px #5c85e6; */
|
|
134
|
+
}
|
|
135
|
+
.yl-form-range-input input::placeholder {
|
|
136
|
+
color: #c0c4cc;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.el-radio {
|
|
140
|
+
margin-bottom: 0px!important;
|
|
141
|
+
}
|