el-plus-crud 0.0.2
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/.eslintignore +18 -0
- package/.eslintrc.js +78 -0
- package/.lintstagedrc +3 -0
- package/.prettierrc.js +39 -0
- package/CHANGELOG.md +5 -0
- package/LICENSE +21 -0
- package/README.md +15 -0
- package/example/App.vue +79 -0
- package/example/assets/vue.svg +1 -0
- package/example/main.js +18 -0
- package/example/style.css +5 -0
- package/index.html +13 -0
- package/lib/components/el-plus-form/ElPlusForm.vue +744 -0
- package/lib/components/el-plus-form/ElPlusFormDialog.vue +107 -0
- package/lib/components/el-plus-form/components/ElPlusFormAutocomplete.vue +49 -0
- package/lib/components/el-plus-form/components/ElPlusFormBtn.vue +96 -0
- package/lib/components/el-plus-form/components/ElPlusFormBtns.vue +133 -0
- package/lib/components/el-plus-form/components/ElPlusFormCascader.vue +38 -0
- package/lib/components/el-plus-form/components/ElPlusFormCascaderPanel.vue +51 -0
- package/lib/components/el-plus-form/components/ElPlusFormCheckbox.vue +42 -0
- package/lib/components/el-plus-form/components/ElPlusFormCheckboxButton.vue +42 -0
- package/lib/components/el-plus-form/components/ElPlusFormColor.vue +38 -0
- package/lib/components/el-plus-form/components/ElPlusFormDate.vue +37 -0
- package/lib/components/el-plus-form/components/ElPlusFormDaterange.vue +44 -0
- package/lib/components/el-plus-form/components/ElPlusFormDatetime.vue +38 -0
- package/lib/components/el-plus-form/components/ElPlusFormFile.vue +47 -0
- package/lib/components/el-plus-form/components/ElPlusFormImage.vue +113 -0
- package/lib/components/el-plus-form/components/ElPlusFormInput.vue +56 -0
- package/lib/components/el-plus-form/components/ElPlusFormLink.vue +271 -0
- package/lib/components/el-plus-form/components/ElPlusFormNbinput.vue +51 -0
- package/lib/components/el-plus-form/components/ElPlusFormNumber.vue +107 -0
- package/lib/components/el-plus-form/components/ElPlusFormPassword.vue +39 -0
- package/lib/components/el-plus-form/components/ElPlusFormRadio.vue +42 -0
- package/lib/components/el-plus-form/components/ElPlusFormRate.vue +38 -0
- package/lib/components/el-plus-form/components/ElPlusFormSelect.vue +149 -0
- package/lib/components/el-plus-form/components/ElPlusFormSlider.vue +38 -0
- package/lib/components/el-plus-form/components/ElPlusFormStatus.vue +67 -0
- package/lib/components/el-plus-form/components/ElPlusFormSwitch.vue +38 -0
- package/lib/components/el-plus-form/components/ElPlusFormTag.vue +78 -0
- package/lib/components/el-plus-form/components/ElPlusFormText.vue +115 -0
- package/lib/components/el-plus-form/components/ElPlusFormTextarea.vue +45 -0
- package/lib/components/el-plus-form/components/ElPlusFormTransfer.vue +44 -0
- package/lib/components/el-plus-form/components/ElPlusFormTree.vue +53 -0
- package/lib/components/el-plus-form/components/ElPlusFormTreeSelect.vue +36 -0
- package/lib/components/el-plus-form/components/components/IconSelectorList.vue +92 -0
- package/lib/components/el-plus-form/components/components/file-icons/FileIcons.vue +135 -0
- package/lib/components/el-plus-form/components/components/file-icons/data/index.ts +27 -0
- package/lib/components/el-plus-form/components/components/file-icons/images/doc.svg +13 -0
- package/lib/components/el-plus-form/components/components/file-icons/images/file.svg +19 -0
- package/lib/components/el-plus-form/components/components/file-icons/images/jpg.svg +14 -0
- package/lib/components/el-plus-form/components/components/file-icons/images/pdf.svg +13 -0
- package/lib/components/el-plus-form/components/components/file-icons/images/png.svg +13 -0
- package/lib/components/el-plus-form/components/components/file-icons/images/ppt.svg +13 -0
- package/lib/components/el-plus-form/components/components/file-icons/images/xls.svg +13 -0
- package/lib/components/el-plus-form/components/index.ts +17 -0
- package/lib/components/el-plus-form/data/file.ts +74 -0
- package/lib/components/el-plus-form/images/icon/excel.png +0 -0
- package/lib/components/el-plus-form/images/icon/file.png +0 -0
- package/lib/components/el-plus-form/images/icon/pdf.png +0 -0
- package/lib/components/el-plus-form/images/icon/ppt.png +0 -0
- package/lib/components/el-plus-form/images/icon/txt.png +0 -0
- package/lib/components/el-plus-form/images/icon/word.png +0 -0
- package/lib/components/el-plus-form/images/icon/zip.png +0 -0
- package/lib/components/el-plus-form/mixins/index.ts +113 -0
- package/lib/components/el-plus-form/util/index.ts +266 -0
- package/lib/components/el-plus-form/util/validate.ts +310 -0
- package/lib/components/el-plus-table/ElPlusTable.vue +723 -0
- package/lib/components/el-plus-table/components/columnItem.vue +185 -0
- package/lib/components/el-plus-table/components/header.vue +185 -0
- package/lib/components/el-plus-table/components/settingColumn.vue +168 -0
- package/lib/components/el-plus-table/components/statisticInfo.vue +47 -0
- package/lib/components/el-plus-table/util/index.ts +123 -0
- package/lib/config/form.ts +12 -0
- package/lib/config/index.ts +9 -0
- package/lib/index.ts +29 -0
- package/package.json +65 -0
- package/public/vite.svg +1 -0
- package/tsconfig.json +68 -0
- package/types/axios.d.ts +13 -0
- package/types/formList.d.ts +365 -0
- package/types/global.d.ts +145 -0
- package/types/layout.d.ts +57 -0
- package/types/mitt.d.ts +38 -0
- package/types/pinia.d.ts +149 -0
- package/types/views.d.ts +329 -0
- package/vite.config.ts +68 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="el-plus-table-column-item" :class="[desc.inline ? 'el-plus-table-column-row' : 'el-plus-table-column-column']">
|
|
3
|
+
<template v-for="(item, i) in cells" :key="i + (item.options && item.options.length > 0 ? item.options[0].value || item.options[0].v : '0')">
|
|
4
|
+
<component v-if="item.vshow === undefined || item.vshow" v-bind="item" :isTable="true" :formData="props.scope?.row" :size="item.size || size" :rowIndex="rowIndex" v-model="props.scope.row[item.field]" :is="'el-plus-form-' + item.desc.type"> </component>
|
|
5
|
+
</template>
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
<script lang="ts" setup name="columnItem">
|
|
9
|
+
import { ref, onMounted, computed } from 'vue'
|
|
10
|
+
|
|
11
|
+
const props = defineProps<{
|
|
12
|
+
field?: string
|
|
13
|
+
desc: IColumnItem
|
|
14
|
+
scope: { [key: string]: any }
|
|
15
|
+
size?: string
|
|
16
|
+
}>()
|
|
17
|
+
|
|
18
|
+
const rowIndex = ref(props.scope?.$index || 0)
|
|
19
|
+
const cells = computed(() => {
|
|
20
|
+
const _cells = [] as any
|
|
21
|
+
|
|
22
|
+
// 判断有没有nodes
|
|
23
|
+
if (props.desc.nodes) {
|
|
24
|
+
props.desc.nodes.map((item, i) => {
|
|
25
|
+
_cells.push(handelItem(item.field || props.field, item, i))
|
|
26
|
+
})
|
|
27
|
+
} else {
|
|
28
|
+
const porpList = props.field ? props.field.split(',') : ([] as string[])
|
|
29
|
+
porpList.map((item, i) => {
|
|
30
|
+
_cells.push(handelItem(item, props.desc, i))
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
// 处理下没有prop的属性
|
|
34
|
+
if (_cells.length <= 0) {
|
|
35
|
+
_cells.push(handelItem('', props.desc, 0))
|
|
36
|
+
}
|
|
37
|
+
return _cells
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const handelItem = (prop: string, item: any, i: number) => {
|
|
41
|
+
const tempCell = {
|
|
42
|
+
field: prop,
|
|
43
|
+
desc: {
|
|
44
|
+
prop: prop,
|
|
45
|
+
default: '',
|
|
46
|
+
size: item.size || props.size || 'small'
|
|
47
|
+
}
|
|
48
|
+
} as any
|
|
49
|
+
Object.assign(tempCell.desc, item)
|
|
50
|
+
if (item.type === 'btn') {
|
|
51
|
+
tempCell.desc.btnType = item.btnType || 'primary'
|
|
52
|
+
tempCell.desc.plain = item.plain || true
|
|
53
|
+
tempCell.desc.text = true
|
|
54
|
+
}
|
|
55
|
+
if (item.type) {
|
|
56
|
+
if (item.type === 'text') {
|
|
57
|
+
tempCell.desc.default = '-'
|
|
58
|
+
}
|
|
59
|
+
if (item.type === 'tag') {
|
|
60
|
+
// tempCell.size = tempCell.size || 'small '
|
|
61
|
+
} else {
|
|
62
|
+
// tempCell.size = tempCell.size || size || 'small';
|
|
63
|
+
}
|
|
64
|
+
if (typeof item.type === 'string') {
|
|
65
|
+
tempCell.desc.type = item.type
|
|
66
|
+
} else {
|
|
67
|
+
tempCell.desc.type = item.type[i] || item.type[0]
|
|
68
|
+
}
|
|
69
|
+
if (item.format) {
|
|
70
|
+
if (typeof item.format === 'string' || typeof item.format === 'function') {
|
|
71
|
+
tempCell.desc.format = item.format
|
|
72
|
+
} else {
|
|
73
|
+
tempCell.desc.format = item.format[i] === null ? null : item.format[i] || item.format[0]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (item.title) {
|
|
77
|
+
if (typeof item.title === 'string') {
|
|
78
|
+
tempCell.desc.title = item.title
|
|
79
|
+
} else {
|
|
80
|
+
tempCell.desc.title = item.title[i] || item.title[0]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
tempCell.desc.type = 'text'
|
|
85
|
+
}
|
|
86
|
+
if (item.elType) {
|
|
87
|
+
tempCell.desc.elType = item.elType
|
|
88
|
+
}
|
|
89
|
+
if (item.linkType) {
|
|
90
|
+
tempCell.desc.linkType = item.linkType
|
|
91
|
+
}
|
|
92
|
+
if (item.linkId) {
|
|
93
|
+
tempCell.desc.linkId = item.linkId
|
|
94
|
+
}
|
|
95
|
+
if (item.color) {
|
|
96
|
+
tempCell.desc.style = item.style || {}
|
|
97
|
+
|
|
98
|
+
if (typeof item.color === 'function') {
|
|
99
|
+
tempCell.desc.style.color = item.color(props.scope?.row[props.field || ''], props.scope?.row, props.field)
|
|
100
|
+
} else if (typeof item.color === 'string') {
|
|
101
|
+
tempCell.desc.style.color = item.color
|
|
102
|
+
} else {
|
|
103
|
+
tempCell.desc.style.color = item.color[i] === null ? null : item.color[i] || item.color[0]
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (item.on) {
|
|
107
|
+
if (Object.prototype.toString.call(item.on) === '[object Array]') {
|
|
108
|
+
tempCell.desc.on = item.on[i] === null ? null : item.on[i] || item.on[0]
|
|
109
|
+
} else {
|
|
110
|
+
tempCell.desc.on = item.on
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (item.disabled) {
|
|
114
|
+
tempCell.disabled = true
|
|
115
|
+
}
|
|
116
|
+
// 处理下options
|
|
117
|
+
if (typeof item.options === 'function') {
|
|
118
|
+
tempCell.desc.options = item.options(props.scope)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// 处理下vif
|
|
122
|
+
tempCell.vshow = handelColumnVIf(item)
|
|
123
|
+
|
|
124
|
+
// 处理下attrs
|
|
125
|
+
if (item.attrs) {
|
|
126
|
+
if (typeof item.attrs === 'function') {
|
|
127
|
+
tempCell.desc.attrs = item.attrs(props.scope?.row)
|
|
128
|
+
} else {
|
|
129
|
+
tempCell.desc.attrs = item.attrs
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
tempCell.desc._label = item.label
|
|
134
|
+
|
|
135
|
+
// 处理attrs
|
|
136
|
+
return tempCell
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const handelColumnVIf = (item: any) => {
|
|
140
|
+
if (item.vshow !== undefined && item.vshow !== null && item.vshow !== '') {
|
|
141
|
+
if (typeof item.vshow === 'boolean') return item.vshow
|
|
142
|
+
if (typeof item.vshow === 'function') return item.vshow(props.scope?.row)
|
|
143
|
+
return !!item.vshow
|
|
144
|
+
}
|
|
145
|
+
return true
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
onMounted(() => {})
|
|
149
|
+
</script>
|
|
150
|
+
<style lang="scss" scoped>
|
|
151
|
+
.el-plus-table-column-item {
|
|
152
|
+
width: 100%;
|
|
153
|
+
display: flex;
|
|
154
|
+
|
|
155
|
+
:deep(.ele-form-text) {
|
|
156
|
+
text-overflow: ellipsis;
|
|
157
|
+
overflow: hidden;
|
|
158
|
+
white-space: nowrap;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.el-plus-table-column-row {
|
|
163
|
+
flex-direction: row;
|
|
164
|
+
|
|
165
|
+
& > div {
|
|
166
|
+
margin-right: 10px;
|
|
167
|
+
|
|
168
|
+
&:last-child {
|
|
169
|
+
margin: 0;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.el-plus-table-column-column {
|
|
175
|
+
flex-direction: column;
|
|
176
|
+
|
|
177
|
+
& > div {
|
|
178
|
+
margin-bottom: 10px;
|
|
179
|
+
|
|
180
|
+
&:last-child {
|
|
181
|
+
margin: 0;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
</style>
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="props.toolbar" class="el-plus-table-header-info">
|
|
3
|
+
<el-form :inline="true" class="el-plus-table-header-form" :style="{ justifyContent: !props.toolbar.formConfig && props.toolbar.btnRight ? 'flex-end' : 'space-between' }">
|
|
4
|
+
<div v-if="props.toolbar.formConfig" class="el-plus-table-form-items">
|
|
5
|
+
<ElPlusForm ref="elPlusFormRef" v-bind="formConfig" v-model="props.modelValue" labelWidth="1" :requestFn="handelQueryData" :showBtns="false" :isTable="true">
|
|
6
|
+
<template #row>
|
|
7
|
+
<div style="white-space: nowrap; display: flex; align-items: center; margin-bottom: 16px">
|
|
8
|
+
<ElPlusFormBtn type="primary" icon="ele-Search" :loading="loading" :desc="{ label: '查询', on: { click: handelSearch }, size }" />
|
|
9
|
+
<ElPlusFormBtn :desc="{ label: '重置', on: { click: handelReset }, size }" />
|
|
10
|
+
<ElPlusFormBtn type="primary" v-if="props.toolbar.export" :desc="{ label: '导出Excel', size, mask: true, on: { click: handelDownload } }" />
|
|
11
|
+
<ElPlusTableSettingColumn v-if="tbName" :tbName="tbName" :column="column || []" :size="size" />
|
|
12
|
+
<ElPlusFormBtn v-for="(item, i) in headerBtns" :key="i" :desc="item" :loading="loading" />
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
</ElPlusForm>
|
|
16
|
+
</div>
|
|
17
|
+
<div v-else class="el-plus-table-header-btns" :style="{ 'min-width': isMobile() ? '100%' : headerBtns && headerBtns.length > 0 ? headerBtns.length * 110 + 'px' : '10px' }">
|
|
18
|
+
<div class="el-plus-table-header-btn">
|
|
19
|
+
<ElPlusFormBtn v-for="(item, i) in headerBtns" :key="i" :desc="item" :loading="loading" />
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</el-form>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
<script lang="ts" setup name="EleTabletHeader">
|
|
26
|
+
import { ref, computed, onMounted, nextTick } from 'vue'
|
|
27
|
+
import ElPlusTableSettingColumn from './settingColumn.vue'
|
|
28
|
+
import ElPlusFormBtn from '@/components/el-plus-form/components/ElPlusFormBtn.vue'
|
|
29
|
+
import { isMobile, handelBtnType } from '../util'
|
|
30
|
+
|
|
31
|
+
const emits = defineEmits(['query'])
|
|
32
|
+
const props = withDefaults(
|
|
33
|
+
defineProps<{
|
|
34
|
+
modelValue?: { [key: string]: any } | {}
|
|
35
|
+
column: Array<IColumnItem> | null
|
|
36
|
+
tbName: string
|
|
37
|
+
toolbar: ITableToolbar | null
|
|
38
|
+
isDialog: boolean
|
|
39
|
+
loading: boolean
|
|
40
|
+
isShowRefresh: boolean
|
|
41
|
+
size: string
|
|
42
|
+
}>(),
|
|
43
|
+
{ tbName: '', toolbar: null, isDialog: false, loading: false, isShowRefresh: true, size: 'default' }
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
const elPlusFormRef = ref()
|
|
47
|
+
const headerBtns = computed(() => {
|
|
48
|
+
const btns = [] as any[]
|
|
49
|
+
if (props.toolbar && props.toolbar.btns) {
|
|
50
|
+
props.toolbar.btns.map((item: any) => {
|
|
51
|
+
btns.push({ ...handelBtnType(item), size: item.size || props.size })
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
return btns
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
const formConfig = computed(() => {
|
|
58
|
+
const tempConf = props.toolbar?.formConfig
|
|
59
|
+
if (tempConf?.formDesc) {
|
|
60
|
+
Object.values(tempConf?.formDesc).map((item) => {
|
|
61
|
+
if (item.width) return
|
|
62
|
+
let width = 300
|
|
63
|
+
switch (item.type) {
|
|
64
|
+
case 'daterange':
|
|
65
|
+
case 'input':
|
|
66
|
+
case 'area':
|
|
67
|
+
width = 300
|
|
68
|
+
break
|
|
69
|
+
}
|
|
70
|
+
item.width = width + 'px'
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
return tempConf
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
function handelQueryData() {
|
|
77
|
+
// 通知父类执行查询
|
|
78
|
+
emits('query')
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 下载
|
|
83
|
+
* @param data
|
|
84
|
+
*/
|
|
85
|
+
function handelDownload({ callBack }: IBtnBack) {
|
|
86
|
+
// if (props.toolbar?.export) {
|
|
87
|
+
// let url = props.toolbar.export.url
|
|
88
|
+
// url += (url.indexOf('?') >= 0 ? '&' : '?') + mapToUrlStr(Object.assign({}, elPlusFormRef.value?.getData(), props.toolbar.export?.data || {}))
|
|
89
|
+
// // 创建请求
|
|
90
|
+
// const xhr = new XMLHttpRequest()
|
|
91
|
+
// xhr.open('get', url, true)
|
|
92
|
+
// // 转换流
|
|
93
|
+
// xhr.responseType = 'blob'
|
|
94
|
+
// // 是否授权
|
|
95
|
+
// if (props.toolbar.export.isAuth !== false) {
|
|
96
|
+
// xhr.setRequestHeader('Authorization', Session.get(import.meta.env.VITE_TOKEN_KEY))
|
|
97
|
+
// }
|
|
98
|
+
// xhr.onload = function () {
|
|
99
|
+
// if (this.status == 200) {
|
|
100
|
+
// const aLink = document.createElement('a')
|
|
101
|
+
// aLink.href = window.URL.createObjectURL(this.response)
|
|
102
|
+
// // 自定义文件名
|
|
103
|
+
// aLink.download = (props.toolbar?.export?.name || new Date().getTime()) + '.xls'
|
|
104
|
+
// aLink.click()
|
|
105
|
+
// window.URL.revokeObjectURL(url)
|
|
106
|
+
// setTimeout(() => {
|
|
107
|
+
// callBack && callBack()
|
|
108
|
+
// }, 1000)
|
|
109
|
+
// }
|
|
110
|
+
// }
|
|
111
|
+
// xhr.onerror = function () {
|
|
112
|
+
// setTimeout(() => {
|
|
113
|
+
// callBack && callBack()
|
|
114
|
+
// }, 1000)
|
|
115
|
+
// }
|
|
116
|
+
// xhr.send()
|
|
117
|
+
// }
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 处理搜索
|
|
122
|
+
*/
|
|
123
|
+
function handelSearch() {
|
|
124
|
+
elPlusFormRef.value.submit()
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 处理重置
|
|
129
|
+
*/
|
|
130
|
+
function handelReset() {
|
|
131
|
+
elPlusFormRef.value.clear()
|
|
132
|
+
nextTick(() => {
|
|
133
|
+
elPlusFormRef.value.submit()
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
onMounted(() => {})
|
|
138
|
+
|
|
139
|
+
defineExpose({ getData: () => elPlusFormRef.value?.getData() })
|
|
140
|
+
</script>
|
|
141
|
+
<style lang="scss">
|
|
142
|
+
.el-plus-table-header-info {
|
|
143
|
+
.el-plus-table-header-form {
|
|
144
|
+
display: flex;
|
|
145
|
+
flex-wrap: wrap;
|
|
146
|
+
align-items: center;
|
|
147
|
+
|
|
148
|
+
.el-form {
|
|
149
|
+
display: flex;
|
|
150
|
+
justify-content: flex-start;
|
|
151
|
+
flex-wrap: wrap;
|
|
152
|
+
|
|
153
|
+
.el-form-item {
|
|
154
|
+
margin-bottom: 16px !important;
|
|
155
|
+
.el-form-item__label {
|
|
156
|
+
width: auto !important;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.waterfall-panel {
|
|
161
|
+
width: auto !important;
|
|
162
|
+
align-items: center;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.el-plus-table-header-btns {
|
|
167
|
+
display: flex;
|
|
168
|
+
align-items: center;
|
|
169
|
+
flex-wrap: wrap;
|
|
170
|
+
|
|
171
|
+
.el-plus-table-header-btn {
|
|
172
|
+
height: 40px;
|
|
173
|
+
display: flex;
|
|
174
|
+
align-items: center;
|
|
175
|
+
margin-right: 10px;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
</style>
|
|
181
|
+
<style lang="scss" scoped="">
|
|
182
|
+
.el-plus-table-header-info {
|
|
183
|
+
width: 100%;
|
|
184
|
+
}
|
|
185
|
+
</style>
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="el-plus-table-edit-column">
|
|
3
|
+
<el-button :plain="true" type="primary" icon="ele-Setting" @click="showSettingDialog" :size="size" title="编辑显示列" circle />
|
|
4
|
+
<!-- 编辑列 -->
|
|
5
|
+
<el-dialog title="编辑显示列" v-model="showSettingColumn" width="40%">
|
|
6
|
+
<template #default>
|
|
7
|
+
<div class="select-panel">
|
|
8
|
+
<el-checkbox v-model="checkAll" :indeterminate="isIndeterminate" @change="selectAll"> 全选 </el-checkbox>
|
|
9
|
+
</div>
|
|
10
|
+
<el-checkbox-group v-model="localColumn" @change="changeSelect" style="padding: 0 10px; flex-wrap: wrap; display: flex">
|
|
11
|
+
<template v-for="item in props.column" :key="item.label">
|
|
12
|
+
<el-checkbox v-if="item._vif" :label="item.label">
|
|
13
|
+
{{ item.label }}
|
|
14
|
+
</el-checkbox>
|
|
15
|
+
</template>
|
|
16
|
+
</el-checkbox-group>
|
|
17
|
+
</template>
|
|
18
|
+
<template #footer>
|
|
19
|
+
<div class="dialog-footer">
|
|
20
|
+
<el-button :size="size" @click="handelCancel"> 取 消 </el-button>
|
|
21
|
+
<el-button :size="size" type="primary" @click="changeColumnData"> 确 定 </el-button>
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
</el-dialog>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
<script lang="ts" setup name="ElPlusTableSettingColumn">
|
|
28
|
+
import { ref, onMounted } from 'vue'
|
|
29
|
+
import { ElMessage } from 'element-plus'
|
|
30
|
+
|
|
31
|
+
const props = defineProps<{
|
|
32
|
+
column: Array<IColumnItem>
|
|
33
|
+
tbName: string
|
|
34
|
+
size: string
|
|
35
|
+
}>()
|
|
36
|
+
|
|
37
|
+
const showSettingColumn = ref(false)
|
|
38
|
+
const localColumn = ref([] as Array<String>)
|
|
39
|
+
const localOldColumn = ref([] as Array<String>)
|
|
40
|
+
const isIndeterminate = ref(false)
|
|
41
|
+
const checkAll = ref(false)
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 打开弹框
|
|
45
|
+
*/
|
|
46
|
+
function showSettingDialog() {
|
|
47
|
+
showSettingColumn.value = true
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function changeColumnData() {
|
|
51
|
+
if (localColumn.value.length <= 0) {
|
|
52
|
+
ElMessage.warning('请至少选择一列!')
|
|
53
|
+
return false
|
|
54
|
+
}
|
|
55
|
+
// 定义一个需要隐藏的列表-存储到本地用
|
|
56
|
+
const hideList = [] as Array<String>
|
|
57
|
+
props.column.map((item: any) => {
|
|
58
|
+
if (localColumn.value.indexOf(item.label) < 0) {
|
|
59
|
+
hideList.push(item.label)
|
|
60
|
+
item.scShow = false
|
|
61
|
+
} else {
|
|
62
|
+
item.scShow = true
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
if (hideList.length > 0) {
|
|
66
|
+
localStorage.setItem('hideColumnsList_' + props.tbName, hideList.join('__'))
|
|
67
|
+
} else {
|
|
68
|
+
// 如果是对象,删除
|
|
69
|
+
localStorage.removeItem('hideColumnsList_' + props.tbName)
|
|
70
|
+
}
|
|
71
|
+
showSettingColumn.value = false
|
|
72
|
+
// 赋值
|
|
73
|
+
localOldColumn.value = localColumn.value
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 全选列
|
|
78
|
+
*/
|
|
79
|
+
function selectAll() {
|
|
80
|
+
localColumn.value = [] as Array<String>
|
|
81
|
+
if (checkAll.value) {
|
|
82
|
+
localColumn.value = props.column.map((item: any) => item.label)
|
|
83
|
+
}
|
|
84
|
+
isIndeterminate.value = false
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 复选框改变时触发
|
|
89
|
+
*/
|
|
90
|
+
function changeSelect() {
|
|
91
|
+
if (localColumn.value.length === 0) {
|
|
92
|
+
isIndeterminate.value = false
|
|
93
|
+
checkAll.value = false
|
|
94
|
+
} else if (props.column.length === localColumn.value.length) {
|
|
95
|
+
isIndeterminate.value = false
|
|
96
|
+
checkAll.value = true
|
|
97
|
+
} else {
|
|
98
|
+
isIndeterminate.value = true
|
|
99
|
+
checkAll.value = false
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 初始化选择列
|
|
105
|
+
* @param init
|
|
106
|
+
*/
|
|
107
|
+
function initLocalCheckList(init?: Boolean) {
|
|
108
|
+
// 从本地获取处理过的字段一级顺序
|
|
109
|
+
const tempLocalStr = localStorage.getItem('hideColumnsList_' + props.tbName) as String
|
|
110
|
+
let tempList: any[] = []
|
|
111
|
+
|
|
112
|
+
// 判断为空
|
|
113
|
+
if (tempLocalStr !== undefined && tempLocalStr !== null && tempLocalStr.length > 0) {
|
|
114
|
+
// 用两个下划线拆分
|
|
115
|
+
tempList = tempLocalStr.split('__')
|
|
116
|
+
}
|
|
117
|
+
props.column.map((item: any) => {
|
|
118
|
+
// 这里初始化一下vif
|
|
119
|
+
if (item.vif !== undefined && item.vif !== null) {
|
|
120
|
+
if (typeof item.vif === 'function') {
|
|
121
|
+
item._vif = item.vif(item)
|
|
122
|
+
} else {
|
|
123
|
+
item._vif = !!item.vif
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
item._vif = true
|
|
127
|
+
}
|
|
128
|
+
if (item._vif && tempList.indexOf(item.label) < 0) {
|
|
129
|
+
localColumn.value.push(item.label)
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
// 初始化的时候需要执行一次全选的状态校验
|
|
134
|
+
changeSelect()
|
|
135
|
+
if (init) {
|
|
136
|
+
changeColumnData()
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* 取消
|
|
142
|
+
*/
|
|
143
|
+
function handelCancel() {
|
|
144
|
+
showSettingColumn.value = false
|
|
145
|
+
// 还原
|
|
146
|
+
localColumn.value = localOldColumn.value
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
onMounted(() => {
|
|
150
|
+
if (props.tbName) {
|
|
151
|
+
initLocalCheckList(true)
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
</script>
|
|
155
|
+
<style lang="scss" scoped>
|
|
156
|
+
.el-plus-table-edit-column {
|
|
157
|
+
margin: 0 10px;
|
|
158
|
+
display: inline-block;
|
|
159
|
+
|
|
160
|
+
.select-panel {
|
|
161
|
+
width: 100%;
|
|
162
|
+
height: 30px;
|
|
163
|
+
padding: 0 10px;
|
|
164
|
+
border-bottom: 1px solid #eee;
|
|
165
|
+
margin-bottom: 10px;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
</style>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="el-plus-table-bottom-statistic-info">
|
|
3
|
+
<template v-for="(item, i) in props.statisticSetting.keys" :key="i">
|
|
4
|
+
<div class="statistic-info-item" v-if="props.statisticData && props.statisticData[item.key] !== undefined">
|
|
5
|
+
{{ item.label }}:
|
|
6
|
+
<span v-if="item.type && item.type === 'text'">
|
|
7
|
+
{{ props.statisticData[item.key] || 0 }}
|
|
8
|
+
</span>
|
|
9
|
+
<span v-else>
|
|
10
|
+
{{ formatMoney(props.statisticData[item.key] || 0) }}
|
|
11
|
+
</span>
|
|
12
|
+
{{ item.aftLabel }}
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
<script lang="ts" setup name="ELPlusTableStatisticInfo">
|
|
18
|
+
import {} from 'vue'
|
|
19
|
+
|
|
20
|
+
const props = defineProps<{
|
|
21
|
+
statisticSetting: { [key: string]: any }
|
|
22
|
+
statisticData: { [key: string]: any }
|
|
23
|
+
}>()
|
|
24
|
+
|
|
25
|
+
const formatMoney = (s: any, n?: any) => {
|
|
26
|
+
if (s && (s + '').indexOf('~') >= 0) {
|
|
27
|
+
return s
|
|
28
|
+
}
|
|
29
|
+
n = n > 0 && n <= 20 ? n : 2
|
|
30
|
+
if (!s || s === '' || typeof s === 'undefined') {
|
|
31
|
+
s = 0
|
|
32
|
+
}
|
|
33
|
+
s = parseFloat((s + '').replace(/[^\d\.-]/g, '')).toFixed(n) + ''
|
|
34
|
+
let isNegative = false
|
|
35
|
+
if (s.indexOf('-') === 0) {
|
|
36
|
+
isNegative = true
|
|
37
|
+
s = s.substr(1)
|
|
38
|
+
}
|
|
39
|
+
const l = s.split('.')[0].split('').reverse()
|
|
40
|
+
const r = s.split('.')[1]
|
|
41
|
+
let t = ''
|
|
42
|
+
for (let i = 0; i < l.length; i++) {
|
|
43
|
+
t += l[i] + ((i + 1) % 3 === 0 && i + 1 !== l.length ? ',' : '')
|
|
44
|
+
}
|
|
45
|
+
return (isNegative ? '-' : '') + t.split('').reverse().join('') + '.' + r
|
|
46
|
+
}
|
|
47
|
+
</script>
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { cloneDeep } from 'lodash'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 获取随机字符串
|
|
5
|
+
* @returns {string}
|
|
6
|
+
*/
|
|
7
|
+
export function getUID(): string {
|
|
8
|
+
let str = ''
|
|
9
|
+
const arr = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
|
|
10
|
+
for (let i = 0; i < 32; i++) {
|
|
11
|
+
let index = Math.floor(arr.length * Math.random())
|
|
12
|
+
if (index < 0) index = 0
|
|
13
|
+
str += arr[index]
|
|
14
|
+
}
|
|
15
|
+
return str
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// 判断类型
|
|
19
|
+
export function is(val: any, type: any) {
|
|
20
|
+
const typeArr = Array.isArray(type) ? type : [type]
|
|
21
|
+
const valType = Object.prototype.toString.call(val)
|
|
22
|
+
return typeArr.some((type) => `[object ${type}]` === valType)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 判断是否是移动端
|
|
27
|
+
*/
|
|
28
|
+
export function isMobile() {
|
|
29
|
+
if (navigator.userAgent.match(/('phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone')/i)) {
|
|
30
|
+
return true
|
|
31
|
+
} else {
|
|
32
|
+
return false
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 处理按钮类型
|
|
38
|
+
* @param item
|
|
39
|
+
*/
|
|
40
|
+
export function handelBtnType(item: any): Object {
|
|
41
|
+
switch (item.type) {
|
|
42
|
+
case undefined:
|
|
43
|
+
item.type = 'primary'
|
|
44
|
+
break
|
|
45
|
+
case 'add':
|
|
46
|
+
item.type = 'primary'
|
|
47
|
+
item.title = item.title || '新增'
|
|
48
|
+
item.icon = 'ele-Plus'
|
|
49
|
+
break
|
|
50
|
+
case 'edit':
|
|
51
|
+
item.type = 'primary'
|
|
52
|
+
item.title = item.title || '编辑'
|
|
53
|
+
item.icon = 'ele-EditPen'
|
|
54
|
+
break
|
|
55
|
+
case 'delete':
|
|
56
|
+
case 'del':
|
|
57
|
+
item.type = 'danger'
|
|
58
|
+
item.title = item.title || '删除'
|
|
59
|
+
item.icon = 'ele-Delete'
|
|
60
|
+
break
|
|
61
|
+
}
|
|
62
|
+
return item
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 处理列表表头,list转Map
|
|
67
|
+
*/
|
|
68
|
+
export function handelListColumn(columnList: Array<IColumnItem>, minWidth?: string): any[] {
|
|
69
|
+
const tempColumnList = [] as any[]
|
|
70
|
+
if (columnList && columnList.length > 0) {
|
|
71
|
+
// 不影响原有的对象,这里进行拷贝
|
|
72
|
+
cloneDeep(columnList).map((item: IColumnItem) => {
|
|
73
|
+
// 处理下一个单元格显示多个数据
|
|
74
|
+
if (item.nodes) {
|
|
75
|
+
const tempList = (handelListColumn(item.nodes, minWidth) as any)[0].children
|
|
76
|
+
item.nodes = tempList || item.nodes
|
|
77
|
+
}
|
|
78
|
+
// 检查type属性,没有type属性的自动补一个text类型
|
|
79
|
+
if (!item.type) {
|
|
80
|
+
item.type = 'text'
|
|
81
|
+
}
|
|
82
|
+
// 这里判断下type类型,然后进行一下表头和表格的对齐方式
|
|
83
|
+
switch (item.type) {
|
|
84
|
+
case 'image':
|
|
85
|
+
item.width = item.width || '110px'
|
|
86
|
+
item.align = item.align || 'left'
|
|
87
|
+
item.headerAlign = item.headerAlign || 'left'
|
|
88
|
+
break
|
|
89
|
+
case 'btns':
|
|
90
|
+
if (!item.minWidth && item.btns && item.btns.length >= 2) {
|
|
91
|
+
let labelLength = 0
|
|
92
|
+
item.btns.map((item: any) => (labelLength += typeof item.label === 'string' ? item.label.length : 4))
|
|
93
|
+
item.width = item.width || labelLength * 20 + 'px'
|
|
94
|
+
}
|
|
95
|
+
item.align = item.align || 'left'
|
|
96
|
+
item.headerAlign = item.headerAlign || 'left'
|
|
97
|
+
item.text = true
|
|
98
|
+
break
|
|
99
|
+
}
|
|
100
|
+
// item.minWidth = item.minWidth || 'auto'
|
|
101
|
+
item.minWidth = item.minWidth || (item.label !== '操作' ? minWidth : 'auto')
|
|
102
|
+
|
|
103
|
+
// 处理下‘操作’
|
|
104
|
+
item.showOverflowTooltip = item.label !== '操作'
|
|
105
|
+
|
|
106
|
+
if (item.parent) {
|
|
107
|
+
let isExists = false
|
|
108
|
+
tempColumnList.forEach((colum: any) => {
|
|
109
|
+
if (colum.label === item.parent) {
|
|
110
|
+
colum.children.push(item)
|
|
111
|
+
isExists = true
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
if (!isExists) {
|
|
115
|
+
tempColumnList.push({ label: item.parent, children: [item] })
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
tempColumnList.push(item)
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
return tempColumnList
|
|
123
|
+
}
|