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.
- package/es/SlForm/index.vue.js +1 -1
- package/es/SlForm/index.vue3.js +1 -1
- package/package.json +7 -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
- package/src/DtTable/index.vue +0 -779
- package/src/SlAlert/SlAlert.stories.js +0 -108
- package/src/SlAlert/index.vue +0 -55
- package/src/SlAlert/remark.md +0 -16
- package/src/SlDescriptions/SlDescriptions.stories.js +0 -119
- package/src/SlDescriptions/index.vue +0 -60
- package/src/SlDescriptions/renderOptions.vue +0 -27
- package/src/SlDialog/README-PLUS.md +0 -74
- package/src/SlDialog/README.md +0 -114
- package/src/SlDialog/dialogPlus.js +0 -160
- package/src/SlDialog/index.js +0 -170
- package/src/SlDrawer/SlDrawer.stories.js +0 -154
- package/src/SlDrawer/index.js +0 -62
- package/src/SlForm/SlForm.stories.js +0 -120
- package/src/SlForm/index.vue +0 -506
- package/src/SlForm/mixinRender.js +0 -228
- package/src/SlForm/otherItem/titleItem.vue +0 -31
- package/src/SlForm/remark.md +0 -607
- package/src/SlGuide/SlGuide.stories.js +0 -100
- package/src/SlGuide/index.vue +0 -166
- package/src/SlGuide/remark.md +0 -90
- package/src/SlMessageBox/index.js +0 -35
- package/src/SlPage/README.md +0 -515
- package/src/SlPage/SlPage.stories.js +0 -125
- package/src/SlPage/index.vue +0 -303
- package/src/SlPage/remark.md +0 -283
- package/src/SlTable/SlTable.stories.js +0 -118
- package/src/SlTable/components/colSetting.vue +0 -86
- package/src/SlTable/index.vue +0 -541
- package/src/SlTitle/SlTitle.stories.js +0 -98
- package/src/SlTitle/index.vue +0 -49
- package/src/global.css +0 -5
- package/src/index.js +0 -49
- package/src/store/index.js +0 -20
- package/src/utils/index.js +0 -47
- package/src/utils/tableConfig.js +0 -33
package/src/SlTable/index.vue
DELETED
|
@@ -1,541 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="sl-table">
|
|
3
|
-
<el-table
|
|
4
|
-
v-loading="loading"
|
|
5
|
-
ref="elTable"
|
|
6
|
-
:data="tableData"
|
|
7
|
-
:border="true"
|
|
8
|
-
:key="headKey"
|
|
9
|
-
:stripe="true"
|
|
10
|
-
:default-sort = "{ prop: 'buserId', order: 'descending' }"
|
|
11
|
-
:cell-class-name="cellClassName"
|
|
12
|
-
:header-cell-class-name="cellClassName"
|
|
13
|
-
v-bind="$attrs"
|
|
14
|
-
:row-key="otherConfig && otherConfig.rowKey ? otherConfig.rowKey : 'id'"
|
|
15
|
-
size="small"
|
|
16
|
-
class="custom-table"
|
|
17
|
-
style="width: 100%"
|
|
18
|
-
height="100%"
|
|
19
|
-
max-height="100%"
|
|
20
|
-
@selection-change="handleSelectionChange"
|
|
21
|
-
@sort-change="handleSortChange"
|
|
22
|
-
v-on="$listeners"
|
|
23
|
-
>
|
|
24
|
-
<!-- ascending, descending -->
|
|
25
|
-
<template v-for="(item, index) in realColumns" >
|
|
26
|
-
<el-table-column
|
|
27
|
-
v-if="item.type == 'selection' || item.type == 'index'"
|
|
28
|
-
:fixed="isMobileDevice() ? false : item.type == 'selection' ? 'left' : ''"
|
|
29
|
-
type="selection"
|
|
30
|
-
v-bind="item"
|
|
31
|
-
:key="item.prop"
|
|
32
|
-
>
|
|
33
|
-
</el-table-column>
|
|
34
|
-
<el-table-column
|
|
35
|
-
v-if="(hasKey(item, 'isShow') ? item.isShow : true) && !item.type && isShowTableColumn(item)"
|
|
36
|
-
:key="item.prop + index"
|
|
37
|
-
:fixed="isMobileDevice() ? false : item.fixed || false"
|
|
38
|
-
:prop="item.prop"
|
|
39
|
-
:label="item.label"
|
|
40
|
-
:align="'center'"
|
|
41
|
-
:sortable="item.sortable || false"
|
|
42
|
-
:width="item.width || ''"
|
|
43
|
-
:minWidth ="item.minWidth || ''"
|
|
44
|
-
:show-overflow-tooltip="showOverflowTooltip(item)"
|
|
45
|
-
>
|
|
46
|
-
<template slot="header" slot-scope="{ column, $index }">
|
|
47
|
-
<!-- <span v-if="item.prop === 'operate'">
|
|
48
|
-
{{ column.label }}
|
|
49
|
-
</span> -->
|
|
50
|
-
<slot v-if="item.headerTemplate" :name="item.headerTemplate"></slot>
|
|
51
|
-
<!-- @mousedown="handleMounseDown($event, column, $index)"
|
|
52
|
-
@dragover="handleDragover($event, column, $index)" -->
|
|
53
|
-
<span
|
|
54
|
-
v-else
|
|
55
|
-
>
|
|
56
|
-
{{ column.label }}
|
|
57
|
-
</span>
|
|
58
|
-
<el-tooltip v-if="item.headerTip && item.headerTip.content && (typeOf(item.headerTip.isShow, 'function') ? item.headerTip.isShow(row) : true)" :content="item.headerTip.content" placement="top">
|
|
59
|
-
<i class="el-icon-info"></i>
|
|
60
|
-
</el-tooltip>
|
|
61
|
-
</template>
|
|
62
|
-
<template slot-scope="{ row, column, $index }">
|
|
63
|
-
<template v-if="item.prop === 'operate'">
|
|
64
|
-
<template v-for="(btnItem) in (typeOf(item.list, 'function') ? item.list({row}) : item.list)" >
|
|
65
|
-
<el-button
|
|
66
|
-
v-if="btnItem.isShow ? btnItem.isShow(row, column, $index) : true"
|
|
67
|
-
:key="btnItem.label"
|
|
68
|
-
type="text"
|
|
69
|
-
:style="{ color: btnItem.type === 'danger' ? '#f56c6c' : '' }"
|
|
70
|
-
size="mini"
|
|
71
|
-
v-bind="btnItem.props"
|
|
72
|
-
@click="btnItem.click(row, column, $index, $event)"
|
|
73
|
-
>
|
|
74
|
-
{{ btnItem.label }}
|
|
75
|
-
</el-button>
|
|
76
|
-
</template>
|
|
77
|
-
</template>
|
|
78
|
-
<template v-else>
|
|
79
|
-
<span v-if="hasKey(item, 'render')" v-html="item.render({row})"></span>
|
|
80
|
-
<slot v-else-if="item.template" :name="item.template" :row="row"></slot>
|
|
81
|
-
<span v-else>{{ row[item.prop] }}</span>
|
|
82
|
-
<el-tooltip v-if="item.tip && item.tip.key && (typeOf(item.tip.isShow, 'function') ? item.tip.isShow(row) : true)" :content="row[item.tip.key]" placement="top">
|
|
83
|
-
<el-button type="text" size="samll" icon="el-icon-info" style="color: red; padding: 0"></el-button>
|
|
84
|
-
</el-tooltip>
|
|
85
|
-
</template>
|
|
86
|
-
</template>
|
|
87
|
-
</el-table-column>
|
|
88
|
-
</template>
|
|
89
|
-
|
|
90
|
-
</el-table>
|
|
91
|
-
<el-pagination
|
|
92
|
-
v-if="showPagination"
|
|
93
|
-
:current-page="currentPage"
|
|
94
|
-
:page-sizes="[10, 20, 50, 100]"
|
|
95
|
-
:page-size="pageSize"
|
|
96
|
-
:total="total"
|
|
97
|
-
background
|
|
98
|
-
style="float: right;"
|
|
99
|
-
layout="total, sizes, prev, pager, next, jumper"
|
|
100
|
-
@size-change="handleSizeChange"
|
|
101
|
-
@current-change="handleCurrentChange"
|
|
102
|
-
>
|
|
103
|
-
</el-pagination>
|
|
104
|
-
</div>
|
|
105
|
-
</template>
|
|
106
|
-
|
|
107
|
-
<script>
|
|
108
|
-
import { typeOf, hasKey, getValueByPath, isMobileDevice } from '@/components/global/utils'
|
|
109
|
-
export default {
|
|
110
|
-
props: {
|
|
111
|
-
tableApi: { type: Function, default: () => ({}) },
|
|
112
|
-
columns: { type: Array, default: () => [] },
|
|
113
|
-
params: { type: Object, default: () => {} },
|
|
114
|
-
filterForm: { type: Array, default: () => [] },
|
|
115
|
-
otherConfig: { type: Object, default: () => {} },
|
|
116
|
-
projectFrom: { type: String, default: '' },
|
|
117
|
-
autoRequest: { type: Boolean, default: false },
|
|
118
|
-
defaultSeachParams: { type: Object, default: () => {} },
|
|
119
|
-
// 是否需要分页
|
|
120
|
-
showPagination: { type: Boolean, default: true },
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
// itemWidth: { type: String, default: '' },
|
|
124
|
-
// data: { type: Array, default: () => [] },
|
|
125
|
-
// showlabel: { type: Boolean, default: true },
|
|
126
|
-
// drawer: { type: Boolean, default: false }, // 开启抽屉模式
|
|
127
|
-
// formProps: { type: Object, default: () => ({ inline: true }) },
|
|
128
|
-
// formItemProps: { type: Object, default: () => ({}) },
|
|
129
|
-
},
|
|
130
|
-
data() {
|
|
131
|
-
return {
|
|
132
|
-
loading: false,
|
|
133
|
-
currentPage: 1,
|
|
134
|
-
pageSize: 10,
|
|
135
|
-
total: 0,
|
|
136
|
-
draggingIndex: null,
|
|
137
|
-
realColumns: this.columns,
|
|
138
|
-
// tableData: [],
|
|
139
|
-
tableData: [],
|
|
140
|
-
dragState: {
|
|
141
|
-
start: -3, // 起始元素的 index 防止初始化cellStyle时序号、展开等默认样式改变,最好小于-3
|
|
142
|
-
end: -3, // 移动鼠标时所覆盖的元素 index
|
|
143
|
-
dragging: false, // 是否正在拖动
|
|
144
|
-
direction: undefined // 拖动方向
|
|
145
|
-
},
|
|
146
|
-
headKey: 'dragHead', // 表头数组变换位置时,重绘table(不更新该值,表头数组变化时,页面不会改变)
|
|
147
|
-
scrollX: 0, // 初始x轴scroll位置(用于定位X轴滚动条)
|
|
148
|
-
hrender: this.$createElement,
|
|
149
|
-
selectedListIds: [],
|
|
150
|
-
selectedList: [],
|
|
151
|
-
defaultParams: {}
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
created() {
|
|
155
|
-
// console.log(this, "xzchizcjzxioj")
|
|
156
|
-
// console.log(this.$parent.$slots, "xzchizcjzxioj")
|
|
157
|
-
// console.log(this.$attrs, "asdasdasdasd")
|
|
158
|
-
this.defaultParams = this.defaultSeachParams
|
|
159
|
-
this.autoRequest && this.getTableData()
|
|
160
|
-
},
|
|
161
|
-
watch: {
|
|
162
|
-
defaultSeachParams: {
|
|
163
|
-
handler(newVal) {
|
|
164
|
-
if (newVal && typeof newVal === 'object') {
|
|
165
|
-
this.defaultParams = {
|
|
166
|
-
...this.defaultParams,
|
|
167
|
-
...newVal
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
immediate: true,
|
|
172
|
-
deep: true
|
|
173
|
-
},
|
|
174
|
-
columns: {
|
|
175
|
-
deep: true,
|
|
176
|
-
immediate: true,
|
|
177
|
-
handler(val) {
|
|
178
|
-
this.realColumns = Array.isArray(val) ? [...val] : []
|
|
179
|
-
this.$nextTick(() => {
|
|
180
|
-
this.$refs.elTable.doLayout()
|
|
181
|
-
})
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
computed: {
|
|
186
|
-
|
|
187
|
-
processedParams() {
|
|
188
|
-
const processedParams = { ...this.params, ...this.defaultParams }
|
|
189
|
-
// 如果有多选的筛选选项 就要配置这个projectFrom
|
|
190
|
-
if (this.projectFrom === 'ares') {
|
|
191
|
-
this.filterForm.forEach(item => {
|
|
192
|
-
if (item.type === 'select' && item.props && item.props.multiple) {
|
|
193
|
-
// console.log(processedParams[item.model] && processedParams[item.model].length === 0,"||||")
|
|
194
|
-
if (!processedParams[item.model] || processedParams[item.model].length === 0) {
|
|
195
|
-
processedParams[item.model] = []
|
|
196
|
-
}
|
|
197
|
-
} else if (item.type === 'datePicker' && item.privateProps && item.privateProps.type === 'daterange') {
|
|
198
|
-
if (processedParams[item.model] && processedParams[item.model].length > 0 && item.callback) {
|
|
199
|
-
const setValueObj = item.callback(processedParams[item.model])
|
|
200
|
-
Object.keys(setValueObj).forEach(key => {
|
|
201
|
-
processedParams[key] = setValueObj[key]
|
|
202
|
-
})
|
|
203
|
-
delete processedParams[item.model]
|
|
204
|
-
}
|
|
205
|
-
} else if (item.type === 'datePicker' || item.type === 'rangeInput') {
|
|
206
|
-
delete processedParams[item.model]
|
|
207
|
-
}
|
|
208
|
-
})
|
|
209
|
-
return processedParams
|
|
210
|
-
} else {
|
|
211
|
-
this.filterForm.forEach(item => {
|
|
212
|
-
if (item.type === 'select' && item.props && item.props.multiple) {
|
|
213
|
-
if (processedParams[item.model]) {
|
|
214
|
-
processedParams[item.model] = processedParams[item.model].join(',')
|
|
215
|
-
} else {
|
|
216
|
-
processedParams[item.model] = ''
|
|
217
|
-
}
|
|
218
|
-
} else if (item.type === 'datePicker' && item.privateProps && item.privateProps.type === 'daterange') {
|
|
219
|
-
if (processedParams[item.model] && processedParams[item.model].length > 0 && item.callback) {
|
|
220
|
-
const setValueObj = item.callback(processedParams[item.model])
|
|
221
|
-
Object.keys(setValueObj).forEach(key => {
|
|
222
|
-
processedParams[key] = setValueObj[key]
|
|
223
|
-
})
|
|
224
|
-
delete processedParams[item.model]
|
|
225
|
-
}
|
|
226
|
-
} else if (item.type === 'datePicker') {
|
|
227
|
-
delete processedParams[item.model]
|
|
228
|
-
}
|
|
229
|
-
})
|
|
230
|
-
// console.log(processedParams, "processedParamsBycps")
|
|
231
|
-
return processedParams
|
|
232
|
-
}
|
|
233
|
-
},
|
|
234
|
-
|
|
235
|
-
// columns() {
|
|
236
|
-
// return this.columns
|
|
237
|
-
// }
|
|
238
|
-
},
|
|
239
|
-
methods: {
|
|
240
|
-
typeOf,
|
|
241
|
-
hasKey,
|
|
242
|
-
isMobileDevice,
|
|
243
|
-
isShowTableColumn(item) {
|
|
244
|
-
if (hasKey(item, 'isAlwaysShow') && typeof item.isAlwaysShow === 'function') {
|
|
245
|
-
return item.isAlwaysShow({
|
|
246
|
-
item: item
|
|
247
|
-
})
|
|
248
|
-
} else if (hasKey(item, 'isAlwaysShow') && typeof item.isAlwaysShow === 'string') {
|
|
249
|
-
return item.isAlwaysShow
|
|
250
|
-
} else {
|
|
251
|
-
return true
|
|
252
|
-
}
|
|
253
|
-
},
|
|
254
|
-
async getTableData() {
|
|
255
|
-
try {
|
|
256
|
-
// console.log(this.otherConfig.requestBodyCof, "this.tableApi")
|
|
257
|
-
this.loading = true
|
|
258
|
-
const pageSize = this.otherConfig.requestBodyCof && this.otherConfig.requestBodyCof.pageSize ? this.otherConfig.requestBodyCof.pageSize : 'pageSize'
|
|
259
|
-
const currentPage = this.otherConfig.requestBodyCof && this.otherConfig.requestBodyCof.currentPage ? this.otherConfig.requestBodyCof.currentPage : 'currentPage'
|
|
260
|
-
const params = {
|
|
261
|
-
[currentPage]: this.currentPage,
|
|
262
|
-
[pageSize]: this.pageSize,
|
|
263
|
-
...this.processedParams
|
|
264
|
-
}
|
|
265
|
-
if(!this.showPagination) {
|
|
266
|
-
delete params[pageSize]
|
|
267
|
-
delete params[currentPage]
|
|
268
|
-
}
|
|
269
|
-
const res = await this.tableApi(params)
|
|
270
|
-
// 默认路径
|
|
271
|
-
let listPath = ['data', 'list']
|
|
272
|
-
let totalPath = ['data', 'total']
|
|
273
|
-
let statusCodePath = 'code'
|
|
274
|
-
|
|
275
|
-
// 检查 otherConfig 是否包含 responderCof
|
|
276
|
-
if (this.otherConfig.responderCof) {
|
|
277
|
-
statusCodePath = this.otherConfig.responderCof.statusCode || statusCodePath
|
|
278
|
-
listPath = this.otherConfig.responderCof.list || listPath
|
|
279
|
-
totalPath = this.otherConfig.responderCof.total || totalPath
|
|
280
|
-
}
|
|
281
|
-
const statusCode = getValueByPath(res, statusCodePath)
|
|
282
|
-
if (statusCode === 1) {
|
|
283
|
-
console.log(getValueByPath(res, listPath), "res", getValueByPath(res, totalPath))
|
|
284
|
-
if ((getValueByPath(res, listPath) && getValueByPath(res, totalPath) > 0 ) || (getValueByPath(res, listPath) && !this.showPagination)) {
|
|
285
|
-
this.tableData = getValueByPath(res, listPath).map(res => {
|
|
286
|
-
const newData = { ...res }
|
|
287
|
-
this.realColumns.forEach(column => {
|
|
288
|
-
if (column.isSwitchNumber && newData.hasOwnProperty(column.prop)) {
|
|
289
|
-
newData[column.prop] = Number(newData[column.prop])
|
|
290
|
-
}
|
|
291
|
-
})
|
|
292
|
-
return newData
|
|
293
|
-
})
|
|
294
|
-
} else {
|
|
295
|
-
this.tableData = []
|
|
296
|
-
}
|
|
297
|
-
// this.tableData = getValueByPath(res, listPath) || []
|
|
298
|
-
this.total = (typeof getValueByPath(res, totalPath) === 'string' ? Number(getValueByPath(res, totalPath)) : getValueByPath(res, totalPath)) || 0
|
|
299
|
-
this.$listeners.callback && this.$listeners.callback({
|
|
300
|
-
apiInfo: res,
|
|
301
|
-
allRequestParams: {
|
|
302
|
-
[currentPage]: this.currentPage,
|
|
303
|
-
[pageSize]: this.pageSize,
|
|
304
|
-
...this.processedParams
|
|
305
|
-
}
|
|
306
|
-
})
|
|
307
|
-
this.loading = false
|
|
308
|
-
}
|
|
309
|
-
} catch (error) {
|
|
310
|
-
console.log(error, "error")
|
|
311
|
-
this.tableData = []
|
|
312
|
-
this.loading = false
|
|
313
|
-
} finally {
|
|
314
|
-
this.loading = false
|
|
315
|
-
}
|
|
316
|
-
},
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
handleSizeChange(val) {
|
|
320
|
-
console.log(`每页 ${val} 条`, this.columns)
|
|
321
|
-
this.pageSize = val
|
|
322
|
-
this.getTableData()
|
|
323
|
-
},
|
|
324
|
-
handleCurrentChange(val) {
|
|
325
|
-
console.log(this.params, "this.paramsthis.params")
|
|
326
|
-
console.log(`当前页: ${val}`)
|
|
327
|
-
this.currentPage = val
|
|
328
|
-
this.getTableData()
|
|
329
|
-
},
|
|
330
|
-
// 不更换页数量
|
|
331
|
-
getCurrentPageList() {
|
|
332
|
-
this.getTableData()
|
|
333
|
-
},
|
|
334
|
-
/** 鼠标摁下触发 */
|
|
335
|
-
handleMounseDown(e, column, $index) {
|
|
336
|
-
this.dragState.dragging = true
|
|
337
|
-
this.dragState.start = parseInt($index - 0)
|
|
338
|
-
// 添加鼠标抬起事件 消除鼠标摁下立刻松开问题
|
|
339
|
-
document.addEventListener('mouseup', this.handleMouseUp)
|
|
340
|
-
// 添加拖拽结束事件
|
|
341
|
-
document.addEventListener('dragend', this.handleMouseUp)
|
|
342
|
-
|
|
343
|
-
// 对选中的表头允许其拖拽
|
|
344
|
-
const dragclass = '.el-table__header-wrapper .' + column.id
|
|
345
|
-
const dragDom = document.querySelectorAll(dragclass)
|
|
346
|
-
dragDom.forEach((dom) => {
|
|
347
|
-
// 允许表头块可以被拖拽 draggable 属性 不允许拖拽dragover等相关拖拽事件无法触发
|
|
348
|
-
dom.setAttribute('draggable', true)
|
|
349
|
-
})
|
|
350
|
-
},
|
|
351
|
-
|
|
352
|
-
/** 鼠标在拖拽移动时触发 */
|
|
353
|
-
handleDragover(e, column, $index) {
|
|
354
|
-
if (this.dragState.dragging) {
|
|
355
|
-
// 获取当前滚动条的位置
|
|
356
|
-
const scrollDom = this.$refs.elTable.bodyWrapper
|
|
357
|
-
this.scrollX = scrollDom.scrollLeft
|
|
358
|
-
const index = parseInt($index - 0) // 记录起始列
|
|
359
|
-
/** 实时更改鼠标处于表头的位置 */
|
|
360
|
-
if (index - this.dragState.start !== 0) {
|
|
361
|
-
this.dragState.direction =
|
|
362
|
-
index - this.dragState.start < 0 ? 'left' : 'right' // 判断拖动方向
|
|
363
|
-
this.dragState.end = parseInt($index - 0)
|
|
364
|
-
} else {
|
|
365
|
-
this.dragState.end = this.dragState.start
|
|
366
|
-
this.dragState.direction = null
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
},
|
|
370
|
-
|
|
371
|
-
/** 鼠标抬起或拖拽结束触发 */
|
|
372
|
-
handleMouseUp() {
|
|
373
|
-
// 更新拖拽后的表头
|
|
374
|
-
this.headDraged(this.dragState)
|
|
375
|
-
const { end } = this.dragState
|
|
376
|
-
// 初始化拖动状态
|
|
377
|
-
this.dragState = {
|
|
378
|
-
start: end,
|
|
379
|
-
end: -9,
|
|
380
|
-
dragging: false,
|
|
381
|
-
direction: undefined
|
|
382
|
-
}
|
|
383
|
-
document.removeEventListener('mouseup', this.handleMouseUp)
|
|
384
|
-
document.removeEventListener('dragend', this.handleMouseUp)
|
|
385
|
-
|
|
386
|
-
setTimeout(() => {
|
|
387
|
-
// 重置拖拽状态
|
|
388
|
-
this.dragState.start = -9
|
|
389
|
-
}, 200)
|
|
390
|
-
},
|
|
391
|
-
|
|
392
|
-
// 更新拖拽后的表头
|
|
393
|
-
headDraged({ start, end, direction }) {
|
|
394
|
-
console.log(direction, 'direction')
|
|
395
|
-
if (direction) {
|
|
396
|
-
const originColumn = this.realColumns[start]
|
|
397
|
-
// 有位置交换时,原先位置的元素删除,再在目标处插入
|
|
398
|
-
this.realColumns.splice(start, 1)
|
|
399
|
-
this.realColumns.splice(end, 0, originColumn)
|
|
400
|
-
this.headKey = new Date().getTime() + '' // 更新table key值
|
|
401
|
-
this.$nextTick(() => {
|
|
402
|
-
// 因为表头重绘后滚动条会移到最左端初始位置,因此如果是在中间部分拖拽,还需要把滚动条在定位到该位置
|
|
403
|
-
this.$refs.elTable.bodyWrapper.scrollLeft = this.scrollX
|
|
404
|
-
})
|
|
405
|
-
console.log('handleDrop', this.realColumns)
|
|
406
|
-
this.$emit('setStorageCustomCol', this.realColumns)
|
|
407
|
-
}
|
|
408
|
-
},
|
|
409
|
-
|
|
410
|
-
// 拖动虚线样式设置
|
|
411
|
-
cellClassName({ columnIndex }) {
|
|
412
|
-
const { start, end, direction } = this.dragState
|
|
413
|
-
const target = columnIndex - 0
|
|
414
|
-
if (target === start) {
|
|
415
|
-
return 'drag_start'
|
|
416
|
-
} else if (target === end) {
|
|
417
|
-
return `drag_end_${direction}`
|
|
418
|
-
}
|
|
419
|
-
return ''
|
|
420
|
-
},
|
|
421
|
-
|
|
422
|
-
// 重新设置表头
|
|
423
|
-
resetColumns(columns) {
|
|
424
|
-
console.log(columns, "columns")
|
|
425
|
-
this.realColumns = columns
|
|
426
|
-
this.headKey = new Date().getTime() + ''
|
|
427
|
-
},
|
|
428
|
-
handleSelectionChange(val) {
|
|
429
|
-
// console.log(val, '123')
|
|
430
|
-
this.selectedListIds = val.map(item => item[this.otherConfig.rowKey || 'id'])
|
|
431
|
-
this.selectedList = val
|
|
432
|
-
},
|
|
433
|
-
showOverflowTooltip(item) {
|
|
434
|
-
if (isMobileDevice()) return false
|
|
435
|
-
if (item.prop === 'operate') return false
|
|
436
|
-
if (item.overflowTooltip) return true
|
|
437
|
-
if (this.otherConfig && !this.otherConfig.donShowOverflowTooltip) return true
|
|
438
|
-
if (this.otherConfig && this.otherConfig.donShowOverflowTooltip) return false
|
|
439
|
-
},
|
|
440
|
-
handleSortChange({ column, prop, order }) {
|
|
441
|
-
// console.log(column, prop, order, 'column, prop, order');
|
|
442
|
-
this.$emit('sortChangeByApi', { column, prop, order })
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
</script>
|
|
447
|
-
<style scoped>
|
|
448
|
-
/* 内联 CSS(避免 @import 导致 ::v-deep 未被 Vue 编译器处理而丢失样式) */
|
|
449
|
-
/* .sl-table {
|
|
450
|
-
display: flex;
|
|
451
|
-
flex: 1 1 0;
|
|
452
|
-
flex-direction: column;
|
|
453
|
-
} */
|
|
454
|
-
@media (max-width: 768px) {
|
|
455
|
-
.sl-table {
|
|
456
|
-
display: flex;
|
|
457
|
-
flex-direction: column;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
@media (min-width: 769px) {
|
|
462
|
-
.sl-table {
|
|
463
|
-
flex: 1 1 0;
|
|
464
|
-
display: flex;
|
|
465
|
-
flex-direction: column;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
.el-table {
|
|
470
|
-
display: flex;
|
|
471
|
-
flex-direction: column
|
|
472
|
-
}
|
|
473
|
-
/deep/ .el-table__header-wrapper {
|
|
474
|
-
flex: 1 0 1;
|
|
475
|
-
}
|
|
476
|
-
/* /deep/ .el-table__body-wrapper {
|
|
477
|
-
overflow-y: auto;
|
|
478
|
-
flex: 1 1 0;
|
|
479
|
-
} */
|
|
480
|
-
/* 移动端样式 */
|
|
481
|
-
@media (max-width: 768px) {
|
|
482
|
-
/deep/ .el-table__body-wrapper {
|
|
483
|
-
overflow-y: auto;
|
|
484
|
-
height: 100%!important;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
@media (min-width: 769px) {
|
|
489
|
-
/deep/ .el-table__body-wrapper {
|
|
490
|
-
/* overflow-y: auto; */
|
|
491
|
-
flex: 1 1 0;
|
|
492
|
-
/* z-index: 100; */
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
/deep/ .el-pagination {
|
|
497
|
-
display: flex;
|
|
498
|
-
justify-content: end;
|
|
499
|
-
margin-top: 20px;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
/* 移动端样式 */
|
|
503
|
-
@media (max-width: 768px) {
|
|
504
|
-
/deep/ .el-pagination {
|
|
505
|
-
flex-wrap: wrap;
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
/* /deep/ .custom-table .el-table__header-wrapper th { */
|
|
510
|
-
/* cursor: move; 改变鼠标悬停时的光标样式 */
|
|
511
|
-
/* user-select: none; 禁止用户选择文本 */
|
|
512
|
-
/* cursor: move; */
|
|
513
|
-
/* } */
|
|
514
|
-
|
|
515
|
-
/deep/ .el-table .drag_start {
|
|
516
|
-
opacity: 0.8;
|
|
517
|
-
color: #f3e8e8fd;
|
|
518
|
-
transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
|
|
519
|
-
-webkit-transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
|
|
520
|
-
-moz-transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
|
|
521
|
-
-ms-transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
|
|
522
|
-
-o-transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
/deep/ .el-table .drag_end_left {
|
|
526
|
-
border-left: 2px dotted rgba(0, 0, 0, 0.938);
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
/deep/ .el-table .drag_end_right {
|
|
530
|
-
border-right: 2px dotted rgba(0, 0, 0, 0.938);
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
/* /deep/ .el-table .el-table__header-wrapper .el-table__cell { */
|
|
534
|
-
/* cursor: move; */
|
|
535
|
-
/* } */
|
|
536
|
-
|
|
537
|
-
/deep/ .el-icon-info {
|
|
538
|
-
vertical-align: middle;
|
|
539
|
-
}
|
|
540
|
-
</style>
|
|
541
|
-
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import SlTitle from './index.vue'
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: 'Components/SlTitle',
|
|
5
|
-
component: SlTitle,
|
|
6
|
-
argTypes: {
|
|
7
|
-
title: { control: 'text', description: '标题文字' }
|
|
8
|
-
},
|
|
9
|
-
parameters: {
|
|
10
|
-
docs: {
|
|
11
|
-
description: {
|
|
12
|
-
component: '页面标题组件,左侧显示标题文字(带蓝色竖线装饰),右侧插槽可放置操作按钮。'
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const codeBlock = (code) => `
|
|
19
|
-
<div style="margin-top:24px;border-top:1px solid #eee;padding-top:16px">
|
|
20
|
-
<p style="font-size:14px;font-weight:600;color:#666;margin-bottom:8px;">使用代码:</p>
|
|
21
|
-
<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>
|
|
22
|
-
</div>`
|
|
23
|
-
|
|
24
|
-
function escapeHtml(str) {
|
|
25
|
-
return str
|
|
26
|
-
.replace(/&/g, '&')
|
|
27
|
-
.replace(/</g, '<')
|
|
28
|
-
.replace(/>/g, '>')
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// ---- 基础用法(带操作按钮) ----
|
|
32
|
-
const defaultCode = `<!-- 使用方式 -->
|
|
33
|
-
<sl-title title="基本信息">
|
|
34
|
-
<el-button type="primary" size="small">编辑</el-button>
|
|
35
|
-
</sl-title>`
|
|
36
|
-
|
|
37
|
-
export const Default = (args, { argTypes }) => ({
|
|
38
|
-
components: { SlTitle },
|
|
39
|
-
props: Object.keys(argTypes),
|
|
40
|
-
template: `
|
|
41
|
-
<div>
|
|
42
|
-
<sl-title v-bind="$props">
|
|
43
|
-
<el-button type="primary" size="small">编辑</el-button>
|
|
44
|
-
</sl-title>
|
|
45
|
-
${codeBlock(defaultCode)}
|
|
46
|
-
</div>`
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
Default.args = {
|
|
50
|
-
title: '基本信息'
|
|
51
|
-
}
|
|
52
|
-
Default.storyName = '基础用法'
|
|
53
|
-
|
|
54
|
-
// ---- 纯标题 ----
|
|
55
|
-
const noActionCode = `<!-- 纯标题,无右侧操作 -->
|
|
56
|
-
<sl-title title="纯标题" />`
|
|
57
|
-
|
|
58
|
-
export const NoAction = (args, { argTypes }) => ({
|
|
59
|
-
components: { SlTitle },
|
|
60
|
-
props: Object.keys(argTypes),
|
|
61
|
-
template: `
|
|
62
|
-
<div>
|
|
63
|
-
<sl-title v-bind="$props" />
|
|
64
|
-
${codeBlock(noActionCode)}
|
|
65
|
-
</div>`
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
NoAction.args = {
|
|
69
|
-
title: '纯标题'
|
|
70
|
-
}
|
|
71
|
-
NoAction.storyName = '纯标题'
|
|
72
|
-
|
|
73
|
-
// ---- 多个操作按钮 ----
|
|
74
|
-
const multiActionCode = `<!-- 多个操作按钮 -->
|
|
75
|
-
<sl-title title="用户列表">
|
|
76
|
-
<el-button type="primary" size="mini">新增</el-button>
|
|
77
|
-
<el-button type="success" size="mini">导出</el-button>
|
|
78
|
-
<el-button size="mini">刷新</el-button>
|
|
79
|
-
</sl-title>`
|
|
80
|
-
|
|
81
|
-
export const MultiAction = (args, { argTypes }) => ({
|
|
82
|
-
components: { SlTitle },
|
|
83
|
-
props: Object.keys(argTypes),
|
|
84
|
-
template: `
|
|
85
|
-
<div>
|
|
86
|
-
<sl-title v-bind="$props">
|
|
87
|
-
<el-button type="primary" size="mini">新增</el-button>
|
|
88
|
-
<el-button type="success" size="mini">导出</el-button>
|
|
89
|
-
<el-button size="small">刷新</el-button>
|
|
90
|
-
</sl-title>
|
|
91
|
-
${codeBlock(multiActionCode)}
|
|
92
|
-
</div>`
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
MultiAction.args = {
|
|
96
|
-
title: '用户列表'
|
|
97
|
-
}
|
|
98
|
-
MultiAction.storyName = '多个操作按钮'
|
package/src/SlTitle/index.vue
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="sl_title">
|
|
3
|
-
<div class="title_name">
|
|
4
|
-
{{ title }}
|
|
5
|
-
</div>
|
|
6
|
-
<div>
|
|
7
|
-
<slot></slot>
|
|
8
|
-
</div>
|
|
9
|
-
</div>
|
|
10
|
-
</template>
|
|
11
|
-
<script>
|
|
12
|
-
export default {
|
|
13
|
-
name: 'SlTitle',
|
|
14
|
-
props: {
|
|
15
|
-
title: {
|
|
16
|
-
type: String,
|
|
17
|
-
default: ''
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
data() {
|
|
21
|
-
return {
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
methods: {
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
</script>
|
|
29
|
-
<style lang="css" scoped>
|
|
30
|
-
.sl_title {
|
|
31
|
-
display: flex;
|
|
32
|
-
justify-content: space-between;
|
|
33
|
-
margin: 10px 0;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.title_name {
|
|
37
|
-
font-weight: 700;
|
|
38
|
-
color: #000;
|
|
39
|
-
font-size: 12px;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
.title_name::before {
|
|
44
|
-
content: " ";
|
|
45
|
-
border: 2px solid #409EFF;
|
|
46
|
-
margin-right: 10px;
|
|
47
|
-
margin-left: 2px;
|
|
48
|
-
}
|
|
49
|
-
</style>
|