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,86 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<el-table ref="dragTable" :data="columns" :border="true" row-key="prop" default-expand-all >
|
|
4
|
+
<el-table-column prop="drag" align="center" label="拖拽" width="60">
|
|
5
|
+
<template slot-scope="scope">
|
|
6
|
+
<i class="el-icon-rank" style="cursor: move;"></i>
|
|
7
|
+
</template>
|
|
8
|
+
</el-table-column>
|
|
9
|
+
<el-table-column prop="label" align="center" label="列名" />
|
|
10
|
+
<el-table-column prop="isShow" align="center" label="显示">
|
|
11
|
+
<template slot-scope="scope">
|
|
12
|
+
<el-switch v-model="scope.row.isShow" @change="changeTableColumn"></el-switch>
|
|
13
|
+
</template>
|
|
14
|
+
</el-table-column>
|
|
15
|
+
|
|
16
|
+
<template #empty>
|
|
17
|
+
<div class="table-empty">
|
|
18
|
+
<!-- <img src="../assets/images/notData.png" alt="notData" /> -->
|
|
19
|
+
<div>暂无可配置列</div>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
22
|
+
</el-table>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
<script>
|
|
26
|
+
import Sortable from 'sortablejs'
|
|
27
|
+
export default {
|
|
28
|
+
props: {
|
|
29
|
+
columns: { type: Array, default: () => [] }
|
|
30
|
+
},
|
|
31
|
+
data() {
|
|
32
|
+
return {
|
|
33
|
+
localColumns: []
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
watch: {
|
|
37
|
+
columns: {
|
|
38
|
+
handler(newVal) {
|
|
39
|
+
this.localColumns = [...newVal]
|
|
40
|
+
this.$nextTick(() => {
|
|
41
|
+
this.setSort()
|
|
42
|
+
})
|
|
43
|
+
},
|
|
44
|
+
deep: true,
|
|
45
|
+
immediate: true
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
mounted() {
|
|
50
|
+
this.$nextTick(() => {
|
|
51
|
+
this.setSort()
|
|
52
|
+
})
|
|
53
|
+
},
|
|
54
|
+
methods: {
|
|
55
|
+
setSort() {
|
|
56
|
+
const el = this.$refs.dragTable.$el.querySelectorAll('.el-table__body-wrapper > table > tbody')[0]
|
|
57
|
+
this.sortable = Sortable.create(el, {
|
|
58
|
+
ghostClass: 'sortable-ghost',
|
|
59
|
+
setData: function(dataTransfer) {
|
|
60
|
+
dataTransfer.setData('Text', '')
|
|
61
|
+
},
|
|
62
|
+
onEnd: evt => {
|
|
63
|
+
const { oldIndex, newIndex } = evt
|
|
64
|
+
this.handleDragEnd(oldIndex, newIndex)
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
},
|
|
68
|
+
handleDragEnd(oldIndex, newIndex) {
|
|
69
|
+
const columns = [...this.localColumns]
|
|
70
|
+
const targetRow = columns.splice(oldIndex, 1)[0]
|
|
71
|
+
columns.splice(newIndex, 0, targetRow)
|
|
72
|
+
this.localColumns = columns
|
|
73
|
+
this.$emit('update-columns', columns)
|
|
74
|
+
},
|
|
75
|
+
changeTableColumn() {
|
|
76
|
+
this.$emit('change-columns')
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
</script>
|
|
81
|
+
<style scoped>
|
|
82
|
+
.sortable-ghost {
|
|
83
|
+
opacity: 0.8;
|
|
84
|
+
background: #f0f9eb;
|
|
85
|
+
}
|
|
86
|
+
</style>
|
|
@@ -0,0 +1,541 @@
|
|
|
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
|
+
|