@ddwl/ddwl-ui 1.1.3 → 1.1.5-beta.1

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.
@@ -1,39 +1,39 @@
1
- <!-- 二次确认气泡 -->
2
- <template>
3
- <el-popconfirm
4
- :title="title"
5
- cancel-button-type=""
6
- icon="el-icon-warning"
7
- @confirm="confirm"
8
- >
9
- <span slot="reference" :class="`${type}-text-btn`">{{ buttonName }}</span>
10
- </el-popconfirm>
11
- </template>
12
-
13
- <script>
14
- export default {
15
- name: 'DPopconfirm',
16
- props: {
17
- title: {
18
- default: '您确定删除该信息?',
19
- type: String
20
- },
21
- buttonName: {
22
- default: '删除',
23
- type: String
24
- },
25
- type: {
26
- default: 'primary',
27
- type: String
28
- }
29
- },
30
- data () {
31
- return {}
32
- },
33
- methods: {
34
- confirm () {
35
- this.$emit('confirm')
36
- }
37
- }
38
- }
39
- </script>
1
+ <!-- 二次确认气泡 -->
2
+ <template>
3
+ <el-popconfirm
4
+ :title="title"
5
+ cancel-button-type=""
6
+ icon="el-icon-warning"
7
+ @confirm="confirm"
8
+ >
9
+ <span slot="reference" :class="`${type}-text-btn`">{{ buttonName }}</span>
10
+ </el-popconfirm>
11
+ </template>
12
+
13
+ <script>
14
+ export default {
15
+ name: 'DPopconfirm',
16
+ props: {
17
+ title: {
18
+ default: '您确定删除该信息?',
19
+ type: String
20
+ },
21
+ buttonName: {
22
+ default: '删除',
23
+ type: String
24
+ },
25
+ type: {
26
+ default: 'primary',
27
+ type: String
28
+ }
29
+ },
30
+ data () {
31
+ return {}
32
+ },
33
+ methods: {
34
+ confirm () {
35
+ this.$emit('confirm')
36
+ }
37
+ }
38
+ }
39
+ </script>
@@ -1,14 +1,14 @@
1
- <!-- eslint-disable vue/require-default-prop -->
2
- <script>
3
- export default {
4
- name: 'DRender',
5
- functional: true,
6
- props: {
7
- scope: Object,
8
- render: Function
9
- },
10
- render: (h, ctx) => {
11
- return ctx.props.render ? ctx.props.render(ctx.props.scope, h) : ''
12
- }
13
- }
14
- </script>
1
+ <!-- eslint-disable vue/require-default-prop -->
2
+ <script>
3
+ export default {
4
+ name: 'DRender',
5
+ functional: true,
6
+ props: {
7
+ scope: Object,
8
+ render: Function
9
+ },
10
+ render: (h, ctx) => {
11
+ return ctx.props.render ? ctx.props.render(ctx.props.scope, h) : ''
12
+ }
13
+ }
14
+ </script>
@@ -1,257 +1,257 @@
1
- <!-- 搜索组件 -->
2
- <template>
3
- <div class="d-search-form">
4
- <el-row class="flex-wrap" :gutter="gutter">
5
- <el-col
6
- v-for="(item, index) in list"
7
- v-show="showCol(index)"
8
- :key="item.prop"
9
- :span="item.span || Math.floor(24 / cell)"
10
- class="col-item"
11
- >
12
- <div class="search-item">
13
- <div class="search-item-label">
14
- {{ item.label }}
15
- </div>
16
- <form-item v-model="form[item.prop]" :config="item" />
17
- </div>
18
- </el-col>
19
- <el-col :span="hiddenIndex === list.length || expend ? emptySpan : 0" style="height: 68px;">
20
- <span />
21
- </el-col>
22
- <el-col v-if="hasSlot && expend && !suffixSlot" :span="24 - submitSpan" class="mb16">
23
- <slot />
24
- </el-col>
25
- <el-col :span="submitSpan">
26
- <div
27
- :style="{
28
- 'margin-top': hasSlot && expend && !suffixSlot ? '0px' : '24px'
29
- }"
30
- class="d-search-form-btn"
31
- >
32
- <el-button type="primary" :disabled="searchLoading" @click="search">
33
- 查询
34
- </el-button>
35
- <el-button :disabled="searchLoading" @click="reset">
36
- 重置
37
- </el-button>
38
- <el-button
39
- v-if="list.length > hiddenIndex"
40
- class="expend-btn"
41
- :class="`el-icon-arrow-${expend ? 'up' : 'down'}`"
42
- @click="changeStatus"
43
- />
44
- </div>
45
- </el-col>
46
- <el-col v-if="hasSlot && (!expend || suffixSlot)" :span="20" class="mb16">
47
- <slot />
48
- </el-col>
49
- </el-row>
50
- </div>
51
- </template>
52
-
53
- <script>
54
- import FormItem from '../form-item'
55
- import { cloneDeep } from 'lodash'
56
-
57
- // 初始化表单
58
- let initForm = {}
59
-
60
- export default {
61
- name: 'DSearchForm',
62
- components: {
63
- FormItem
64
- },
65
- model: {
66
- prop: 'value',
67
- event: 'change'
68
- },
69
- props: {
70
- config: {
71
- require: true,
72
- default: () => [],
73
- type: Array
74
- },
75
- cell: {
76
- default: 6,
77
- type: Number
78
- },
79
- gutter: {
80
- default: 16,
81
- type: Number
82
- },
83
- value: {
84
- default: () => {},
85
- type: Object
86
- },
87
- searchData: {
88
- default: null,
89
- type: Function
90
- },
91
- buttonSpan: {
92
- default: 0,
93
- type: Number
94
- }
95
- },
96
- data () {
97
- return {
98
- list: [],
99
- hiddenIndex: 0,
100
- emptySpan: 0,
101
- expend: false,
102
- searchLoading: false,
103
- // 判断是否有插槽节点,目前只在组件初始化完成时判断
104
- hasSlot: false,
105
- suffixSlot: true
106
- }
107
- },
108
- computed: {
109
- form: {
110
- get () {
111
- return this.value
112
- },
113
- set (value) {
114
- this.$emit('change', value)
115
- }
116
- },
117
- submitSpan () {
118
- return this.buttonSpan || 24 / this.cell
119
- },
120
- spanList () {
121
- return this.list.map(item => item.span || Math.floor(24 / this.cell)) || []
122
- },
123
- showCol () {
124
- return (index) => {
125
- return this.expend || index < this.hiddenIndex
126
- }
127
- }
128
- },
129
- watch: {
130
- config: {
131
- handler () {
132
- this.list = this.config.filter(item => !item.hidden)
133
- },
134
- deep: true,
135
- immediate: true
136
- },
137
- spanList: {
138
- handler (val, oldVal) {
139
- if (!val.length || JSON.stringify(val) === JSON.stringify(oldVal)) {
140
- return
141
- }
142
- this.calcSpan()
143
- },
144
- deep: true,
145
- immediate: true
146
- }
147
- },
148
- created () {
149
- initForm = cloneDeep(this.value)
150
- this.$nextTick(() => {
151
- this.hasSlot = !!(this.$slots.default && this.$slots.default.length)
152
- this.calcSpan()
153
- })
154
- },
155
- methods: {
156
- /**
157
- * @description: 查询
158
- */
159
- async search () {
160
- this.$emit('search')
161
- if (this.searchData) {
162
- try {
163
- this.searchLoading = true
164
- await this.searchData({ pageNum: 1 }, this.form)
165
- this.searchLoading = false
166
- } catch (e) {
167
- this.searchLoading = false
168
- }
169
- }
170
- },
171
- /**
172
- * @description: 重置
173
- */
174
- async reset () {
175
- this.form = cloneDeep(initForm)
176
- this.$emit('search')
177
- if (this.searchData) {
178
- this.resetLoading = true
179
- await this.searchData({ pageNum: 1 }, this.form)
180
- this.resetLoading = false
181
- }
182
- },
183
- /**
184
- * @description: 展开/收起
185
- */
186
- changeStatus () {
187
- this.expend = !this.expend
188
- this.$emit('expand-change', this.expend)
189
- },
190
- calcSpan () {
191
- let hiddenIndex = 1
192
- const total = this.spanList.length ? this.spanList.reduce((a, b, index) => {
193
- const sum = a + b
194
- if (hiddenIndex < 2) {
195
- if (24 - sum < this.submitSpan) {
196
- hiddenIndex = index
197
- }
198
- if (24 - sum >= this.submitSpan && index === this.spanList.length - 1) {
199
- hiddenIndex = index + 1
200
- }
201
- }
202
- return sum
203
- }) : 0
204
- this.hiddenIndex = hiddenIndex
205
-
206
- const offsetSpan = 24 - total % 24
207
- if (this.hasSlot) {
208
- if (offsetSpan < this.submitSpan || offsetSpan === 24) {
209
- this.suffixSlot = false
210
- this.emptySpan = 0
211
- } else {
212
- this.suffixSlot = true
213
- this.emptySpan = offsetSpan >= this.submitSpan ? offsetSpan - this.submitSpan : 24 - this.submitSpan
214
- }
215
- } else {
216
- this.emptySpan = offsetSpan >= this.submitSpan ? offsetSpan - this.submitSpan : 24 - this.submitSpan
217
- }
218
- }
219
- }
220
- }
221
- </script>
222
-
223
- <style lang="scss" scoped>
224
- .d-search-form {
225
- margin-bottom: 4px;
226
- .col-item {
227
- align-items: end;
228
- }
229
- .el-select {
230
- width: 100%;
231
- .el-input_inner {
232
- height: 32px;
233
- }
234
- }
235
- &-btn {
236
- text-align: right;
237
- margin-bottom: 16px;
238
- }
239
- &-overflow {
240
- margin-top: 24px;
241
- }
242
- .expend-btn {
243
- padding: 4px 8px;
244
- }
245
- }
246
- .search-item {
247
- margin-bottom: 12px;
248
- &-label {
249
- margin-bottom: 4px;
250
- font-weight: 400;
251
- color: #333333;
252
- }
253
- :deep(.el-input__inner) {
254
- height: 32px !important;
255
- }
256
- }
257
- </style>
1
+ <!-- 搜索组件 -->
2
+ <template>
3
+ <div class="d-search-form">
4
+ <el-row class="flex-wrap" :gutter="gutter">
5
+ <el-col
6
+ v-for="(item, index) in list"
7
+ v-show="showCol(index)"
8
+ :key="item.prop"
9
+ :span="item.span || Math.floor(24 / cell)"
10
+ class="col-item"
11
+ >
12
+ <div class="search-item">
13
+ <div class="search-item-label">
14
+ {{ item.label }}
15
+ </div>
16
+ <form-item v-model="form[item.prop]" :config="item" />
17
+ </div>
18
+ </el-col>
19
+ <el-col :span="hiddenIndex === list.length || expend ? emptySpan : 0" style="height: 68px;">
20
+ <span />
21
+ </el-col>
22
+ <el-col v-if="hasSlot && expend && !suffixSlot" :span="24 - submitSpan" class="mb16">
23
+ <slot />
24
+ </el-col>
25
+ <el-col :span="submitSpan">
26
+ <div
27
+ :style="{
28
+ 'margin-top': hasSlot && expend && !suffixSlot ? '0px' : '24px'
29
+ }"
30
+ class="d-search-form-btn"
31
+ >
32
+ <el-button type="primary" :disabled="searchLoading" @click="search">
33
+ 查询
34
+ </el-button>
35
+ <el-button :disabled="searchLoading" @click="reset">
36
+ 重置
37
+ </el-button>
38
+ <el-button
39
+ v-if="list.length > hiddenIndex"
40
+ class="expend-btn"
41
+ :class="`el-icon-arrow-${expend ? 'up' : 'down'}`"
42
+ @click="changeStatus"
43
+ />
44
+ </div>
45
+ </el-col>
46
+ <el-col v-if="hasSlot && (!expend || suffixSlot)" :span="20" class="mb16">
47
+ <slot />
48
+ </el-col>
49
+ </el-row>
50
+ </div>
51
+ </template>
52
+
53
+ <script>
54
+ import FormItem from '../form-item'
55
+ import { cloneDeep } from 'lodash'
56
+
57
+ // 初始化表单
58
+ let initForm = {}
59
+
60
+ export default {
61
+ name: 'DSearchForm',
62
+ components: {
63
+ FormItem
64
+ },
65
+ model: {
66
+ prop: 'value',
67
+ event: 'change'
68
+ },
69
+ props: {
70
+ config: {
71
+ require: true,
72
+ default: () => [],
73
+ type: Array
74
+ },
75
+ cell: {
76
+ default: 6,
77
+ type: Number
78
+ },
79
+ gutter: {
80
+ default: 16,
81
+ type: Number
82
+ },
83
+ value: {
84
+ default: () => {},
85
+ type: Object
86
+ },
87
+ searchData: {
88
+ default: null,
89
+ type: Function
90
+ },
91
+ buttonSpan: {
92
+ default: 0,
93
+ type: Number
94
+ }
95
+ },
96
+ data () {
97
+ return {
98
+ list: [],
99
+ hiddenIndex: 0,
100
+ emptySpan: 0,
101
+ expend: false,
102
+ searchLoading: false,
103
+ // 判断是否有插槽节点,目前只在组件初始化完成时判断
104
+ hasSlot: false,
105
+ suffixSlot: true
106
+ }
107
+ },
108
+ computed: {
109
+ form: {
110
+ get () {
111
+ return this.value
112
+ },
113
+ set (value) {
114
+ this.$emit('change', value)
115
+ }
116
+ },
117
+ submitSpan () {
118
+ return this.buttonSpan || 24 / this.cell
119
+ },
120
+ spanList () {
121
+ return this.list.map(item => item.span || Math.floor(24 / this.cell)) || []
122
+ },
123
+ showCol () {
124
+ return (index) => {
125
+ return this.expend || index < this.hiddenIndex
126
+ }
127
+ }
128
+ },
129
+ watch: {
130
+ config: {
131
+ handler () {
132
+ this.list = this.config.filter(item => !item.hidden)
133
+ },
134
+ deep: true,
135
+ immediate: true
136
+ },
137
+ spanList: {
138
+ handler (val, oldVal) {
139
+ if (!val.length || JSON.stringify(val) === JSON.stringify(oldVal)) {
140
+ return
141
+ }
142
+ this.calcSpan()
143
+ },
144
+ deep: true,
145
+ immediate: true
146
+ }
147
+ },
148
+ created () {
149
+ initForm = cloneDeep(this.value)
150
+ this.$nextTick(() => {
151
+ this.hasSlot = !!(this.$slots.default && this.$slots.default.length)
152
+ this.calcSpan()
153
+ })
154
+ },
155
+ methods: {
156
+ /**
157
+ * @description: 查询
158
+ */
159
+ async search () {
160
+ this.$emit('search')
161
+ if (this.searchData) {
162
+ try {
163
+ this.searchLoading = true
164
+ await this.searchData({ pageNum: 1 }, this.form)
165
+ this.searchLoading = false
166
+ } catch (e) {
167
+ this.searchLoading = false
168
+ }
169
+ }
170
+ },
171
+ /**
172
+ * @description: 重置
173
+ */
174
+ async reset () {
175
+ this.form = cloneDeep(initForm)
176
+ this.$emit('search')
177
+ if (this.searchData) {
178
+ this.resetLoading = true
179
+ await this.searchData({ pageNum: 1 }, this.form)
180
+ this.resetLoading = false
181
+ }
182
+ },
183
+ /**
184
+ * @description: 展开/收起
185
+ */
186
+ changeStatus () {
187
+ this.expend = !this.expend
188
+ this.$emit('expand-change', this.expend)
189
+ },
190
+ calcSpan () {
191
+ let hiddenIndex = 1
192
+ const total = this.spanList.length ? this.spanList.reduce((a, b, index) => {
193
+ const sum = a + b
194
+ if (hiddenIndex < 2) {
195
+ if (24 - sum < this.submitSpan) {
196
+ hiddenIndex = index
197
+ }
198
+ if (24 - sum >= this.submitSpan && index === this.spanList.length - 1) {
199
+ hiddenIndex = index + 1
200
+ }
201
+ }
202
+ return sum
203
+ }) : 0
204
+ this.hiddenIndex = hiddenIndex
205
+
206
+ const offsetSpan = 24 - total % 24
207
+ if (this.hasSlot) {
208
+ if (offsetSpan < this.submitSpan || offsetSpan === 24) {
209
+ this.suffixSlot = false
210
+ this.emptySpan = 0
211
+ } else {
212
+ this.suffixSlot = true
213
+ this.emptySpan = offsetSpan >= this.submitSpan ? offsetSpan - this.submitSpan : 24 - this.submitSpan
214
+ }
215
+ } else {
216
+ this.emptySpan = offsetSpan >= this.submitSpan ? offsetSpan - this.submitSpan : 24 - this.submitSpan
217
+ }
218
+ }
219
+ }
220
+ }
221
+ </script>
222
+
223
+ <style lang="scss" scoped>
224
+ .d-search-form {
225
+ margin-bottom: 4px;
226
+ .col-item {
227
+ align-items: end;
228
+ }
229
+ .el-select {
230
+ width: 100%;
231
+ .el-input_inner {
232
+ height: 32px;
233
+ }
234
+ }
235
+ &-btn {
236
+ text-align: right;
237
+ margin-bottom: 16px;
238
+ }
239
+ &-overflow {
240
+ margin-top: 24px;
241
+ }
242
+ .expend-btn {
243
+ padding: 4px 8px;
244
+ }
245
+ }
246
+ .search-item {
247
+ margin-bottom: 12px;
248
+ &-label {
249
+ margin-bottom: 4px;
250
+ font-weight: 400;
251
+ color: #333333;
252
+ }
253
+ :deep(.el-input__inner) {
254
+ height: 32px !important;
255
+ }
256
+ }
257
+ </style>