el-plus-crud 0.0.39 → 0.0.41

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.
Files changed (73) hide show
  1. package/.eslintrc.js +78 -78
  2. package/.prettierrc.js +39 -39
  3. package/CHANGELOG.md +5 -1
  4. package/build.js +31 -31
  5. package/dist/el-plus-crud.mjs +1803 -1801
  6. package/dist/el-plus-crud.umd.js +7 -7
  7. package/dist/style.css +1 -1
  8. package/example/App.vue +67 -67
  9. package/example/main.js +18 -18
  10. package/index.html +13 -13
  11. package/lib/components/el-plus-form/ElPlusForm.vue +771 -774
  12. package/lib/components/el-plus-form/ElPlusFormDialog.vue +90 -90
  13. package/lib/components/el-plus-form/ElPlusFormGroup.vue +116 -116
  14. package/lib/components/el-plus-form/components/ElPlusFormArea.vue +61 -61
  15. package/lib/components/el-plus-form/components/ElPlusFormAutocomplete.vue +49 -49
  16. package/lib/components/el-plus-form/components/ElPlusFormBtn.vue +102 -102
  17. package/lib/components/el-plus-form/components/ElPlusFormBtns.vue +133 -133
  18. package/lib/components/el-plus-form/components/ElPlusFormCascader.vue +63 -63
  19. package/lib/components/el-plus-form/components/ElPlusFormCascaderPanel.vue +53 -53
  20. package/lib/components/el-plus-form/components/ElPlusFormCheckbox.vue +44 -44
  21. package/lib/components/el-plus-form/components/ElPlusFormCheckboxButton.vue +44 -44
  22. package/lib/components/el-plus-form/components/ElPlusFormColor.vue +38 -38
  23. package/lib/components/el-plus-form/components/ElPlusFormDate.vue +39 -39
  24. package/lib/components/el-plus-form/components/ElPlusFormDaterange.vue +46 -46
  25. package/lib/components/el-plus-form/components/ElPlusFormDatetime.vue +40 -40
  26. package/lib/components/el-plus-form/components/ElPlusFormFile.vue +47 -47
  27. package/lib/components/el-plus-form/components/ElPlusFormImage.vue +113 -113
  28. package/lib/components/el-plus-form/components/ElPlusFormLink.vue +281 -281
  29. package/lib/components/el-plus-form/components/ElPlusFormLkuser.vue +489 -489
  30. package/lib/components/el-plus-form/components/ElPlusFormNbinput.vue +53 -53
  31. package/lib/components/el-plus-form/components/ElPlusFormNumber.vue +146 -146
  32. package/lib/components/el-plus-form/components/ElPlusFormQuickInput.vue +94 -94
  33. package/lib/components/el-plus-form/components/ElPlusFormRadio.vue +42 -42
  34. package/lib/components/el-plus-form/components/ElPlusFormRate.vue +38 -38
  35. package/lib/components/el-plus-form/components/ElPlusFormSelect.vue +161 -161
  36. package/lib/components/el-plus-form/components/ElPlusFormSlider.vue +38 -38
  37. package/lib/components/el-plus-form/components/ElPlusFormSwitch.vue +38 -38
  38. package/lib/components/el-plus-form/components/ElPlusFormTag.vue +78 -78
  39. package/lib/components/el-plus-form/components/ElPlusFormText.vue +99 -99
  40. package/lib/components/el-plus-form/components/ElPlusFormTextarea.vue +49 -49
  41. package/lib/components/el-plus-form/components/ElPlusFormTransfer.vue +44 -44
  42. package/lib/components/el-plus-form/components/ElPlusFormTree.vue +76 -76
  43. package/lib/components/el-plus-form/components/ElPlusFormTreeSelect.vue +59 -59
  44. package/lib/components/el-plus-form/components/ElPlusFormUpload.vue +368 -368
  45. package/lib/components/el-plus-form/components/components/file-icons/FileIcons.vue +135 -135
  46. package/lib/components/el-plus-form/components/components/file-icons/data/index.ts +27 -27
  47. package/lib/components/el-plus-form/components/components/file-icons/images/doc.svg +12 -12
  48. package/lib/components/el-plus-form/components/components/file-icons/images/file.svg +18 -18
  49. package/lib/components/el-plus-form/components/components/file-icons/images/jpg.svg +13 -13
  50. package/lib/components/el-plus-form/components/components/file-icons/images/pdf.svg +12 -12
  51. package/lib/components/el-plus-form/components/components/file-icons/images/png.svg +12 -12
  52. package/lib/components/el-plus-form/components/components/file-icons/images/ppt.svg +12 -12
  53. package/lib/components/el-plus-form/components/components/file-icons/images/xls.svg +12 -12
  54. package/lib/components/el-plus-form/components/index.ts +17 -17
  55. package/lib/components/el-plus-form/data/file.ts +74 -74
  56. package/lib/components/el-plus-form/mixins/index.ts +115 -113
  57. package/lib/components/el-plus-form/util/index.ts +257 -257
  58. package/lib/components/el-plus-form/util/validate.ts +332 -332
  59. package/lib/components/el-plus-table/components/columnItem.vue +205 -205
  60. package/lib/components/el-plus-table/components/header.vue +240 -240
  61. package/lib/components/el-plus-table/components/statisticInfo.vue +47 -47
  62. package/lib/components/el-plus-table/util/index.ts +147 -147
  63. package/lib/config/index.ts +30 -30
  64. package/lib/index.d.ts +4 -4
  65. package/lib/index.ts +51 -51
  66. package/package.json +1 -1
  67. package/types/axios.d.ts +13 -13
  68. package/types/formList.d.ts +440 -440
  69. package/types/layout.d.ts +57 -57
  70. package/types/mitt.d.ts +38 -38
  71. package/types/pinia.d.ts +149 -149
  72. package/types/views.d.ts +329 -329
  73. package/vite.config.ts +78 -78
@@ -1,240 +1,240 @@
1
- <template>
2
- <div class="el-plus-table-header-info">
3
- <template v-if="props.toolbar && Object.keys(props.toolbar || {}).length">
4
- <el-form :inline="true" class="el-plus-table-header-form" :style="{ justifyContent: !props.toolbar.formConfig && props.toolbar.btnRight ? 'flex-end' : 'space-between' }">
5
- <div v-if="props.toolbar.formConfig" class="el-plus-table-form-items">
6
- <ElPlusForm ref="elPlusFormRef" v-bind="formConfig" v-model="props.modelValue" labelWidth="1" :requestFn="handelQueryData" :showBtns="false" :isTable="true">
7
- <template #row>
8
- <div class="table-header-form-btns">
9
- <ElPlusFormBtn type="primary" icon="ele-Search" :loading="loading" :desc="{ label: '查询', on: { click: handelSearch }, size }" />
10
- <ElPlusFormBtn :desc="{ label: '重置', on: { click: handelReset }, size }" />
11
- <ElPlusFormBtn type="primary" v-if="props.toolbar.export" :desc="{ label: '导出Excel', size, mask: true, on: { click: handelDownload } }" />
12
- <ElPlusTableSettingColumn ref="settingColumnRef" v-if="tbName" :tbName="tbName" :column="column || []" :size="size" />
13
- <ElPlusFormBtn v-for="(item, i) in headerBtns" :key="i" :desc="item" :loading="loading" />
14
- </div>
15
- </template>
16
- </ElPlusForm>
17
- </div>
18
- <div v-else class="el-plus-table-header-btns" :style="{ 'min-width': isMobile() ? '100%' : headerBtns && headerBtns.length > 0 ? headerBtns.length * 110 + 'px' : '10px' }">
19
- <div class="el-plus-table-header-btn">
20
- <ElPlusFormBtn v-for="(item, i) in headerBtns" :key="i" :desc="item" :loading="loading" />
21
- </div>
22
- </div>
23
- </el-form>
24
- </template>
25
- <!-- 如果这里有tbname, 则需要显示设置列按钮 -->
26
- <template v-else-if="!!tbName">
27
- <div class="el-plus-table-header-form">
28
- <div class="table-header-form-btns" style="margin-bottom: 16px">
29
- <ElPlusTableSettingColumn ref="settingColumnRef" v-if="tbName" :tbName="tbName" :column="column || []" :size="size" :showText="true" />
30
- </div>
31
- </div>
32
- </template>
33
- </div>
34
- </template>
35
- <script lang="ts" setup>
36
- import { ref, computed, onMounted, nextTick, inject } from 'vue'
37
- import ElPlusTableSettingColumn from './settingColumn.vue'
38
- import ElPlusFormBtn from '../../el-plus-form/components/ElPlusFormBtn.vue'
39
- import { isMobile, handelBtnType, mapToUrlStr } from '../util'
40
-
41
- const defaultConf = inject('defaultConf') as ICRUDConfig
42
-
43
- const emits = defineEmits(['query'])
44
- const props = withDefaults(
45
- defineProps<{
46
- modelValue?: { [key: string]: any } | {}
47
- column: Array<IColumnItem> | null
48
- tbName: string
49
- toolbar: ITableToolbar | null
50
- isDialog: boolean
51
- loading: boolean
52
- isShowRefresh: boolean
53
- size: string
54
- }>(),
55
- { tbName: '', toolbar: null, isDialog: false, loading: false, isShowRefresh: true, size: 'default' }
56
- )
57
-
58
- const elPlusFormRef = ref()
59
- const settingColumnRef = ref()
60
-
61
- const headerBtns = computed(() => {
62
- const btns = [] as any[]
63
- if (props.toolbar && props.toolbar.btns) {
64
- props.toolbar.btns.map((item: any) => {
65
- btns.push({ ...handelBtnType(item), size: item.size || props.size })
66
- })
67
- }
68
- return btns
69
- })
70
-
71
- const formConfig = computed(() => {
72
- const tempConf = props.toolbar?.formConfig
73
- if (tempConf?.formDesc) {
74
- Object.values(tempConf?.formDesc).map((item) => {
75
- if (item.width) return
76
- let width = 300
77
- switch (item.type) {
78
- case 'daterange':
79
- case 'input':
80
- case 'area':
81
- width = 300
82
- break
83
- }
84
- item.width = width + 'px'
85
- })
86
- }
87
- return tempConf
88
- })
89
-
90
- function handelQueryData() {
91
- // 通知父类执行查询
92
- emits('query')
93
- }
94
-
95
- /**
96
- * 下载
97
- * @param data
98
- */
99
- async function handelDownload({ callBack }: IBtnBack) {
100
- if (props.toolbar?.export) {
101
- // 创建请求
102
- const xhr = new XMLHttpRequest()
103
- let url = props.toolbar.export.url || ''
104
- if (props.toolbar.export.fetch) {
105
- url = (await props.toolbar.export.fetch(Object.assign({}, elPlusFormRef.value?.getData(), props.toolbar.export?.data || {}))) as string
106
- } else {
107
- if (!props.toolbar.export.noQuery) {
108
- url += (url.indexOf('?') >= 0 ? '&' : '?') + mapToUrlStr(Object.assign({}, elPlusFormRef.value?.getData(), props.toolbar.export?.data || {}))
109
- }
110
- }
111
- xhr.open('get', url, true)
112
- // 转换流
113
- xhr.responseType = 'blob'
114
- // 是否授权
115
- if (props.toolbar.export.isAuth !== false && defaultConf.token) {
116
- let token = defaultConf.token
117
- if (typeof defaultConf.token === 'function') {
118
- token = defaultConf.token()
119
- }
120
- xhr.setRequestHeader('Authorization', 'Bearer ' + token)
121
- }
122
- xhr.onload = function () {
123
- if (this.status == 200) {
124
- const aLink = document.createElement('a')
125
- aLink.href = window.URL.createObjectURL(this.response)
126
- // 自定义文件名
127
- aLink.download = (props.toolbar?.export?.name || new Date().getTime()) + '.xls'
128
- aLink.click()
129
- window.URL.revokeObjectURL(url)
130
- setTimeout(() => {
131
- callBack && callBack()
132
- }, 1000)
133
- }
134
- }
135
- xhr.onerror = function () {
136
- setTimeout(() => {
137
- callBack && callBack()
138
- }, 1000)
139
- }
140
- xhr.send()
141
- }
142
- }
143
-
144
- /**
145
- * 处理搜索
146
- */
147
- function handelSearch() {
148
- elPlusFormRef.value.submit()
149
- }
150
-
151
- /**
152
- * 处理重置
153
- */
154
- function handelReset() {
155
- elPlusFormRef.value.clear()
156
- nextTick(() => {
157
- elPlusFormRef.value.submit()
158
- })
159
- }
160
-
161
- /**
162
- * 初始化列
163
- */
164
- function initCol() {
165
- if (props.tbName) {
166
- settingColumnRef.value?.initCol()
167
- } else {
168
- // 没有下一层,这里需要在这一层级初始化一下
169
- props.column?.map((item: any) => {
170
- // 这里初始化一下vif
171
- if (item.vif !== undefined && item.vif !== null) {
172
- if (typeof item.vif === 'function') {
173
- item._vif = item.vif(item)
174
- } else {
175
- item._vif = !!item.vif
176
- }
177
- } else {
178
- item._vif = true
179
- }
180
- })
181
- }
182
- }
183
-
184
- onMounted(() => {})
185
-
186
- defineExpose({ getData: () => elPlusFormRef.value?.getData(), initCol })
187
- </script>
188
- <style lang="scss">
189
- .el-plus-table-header-info {
190
- .el-plus-table-header-form {
191
- display: flex;
192
- flex-wrap: wrap;
193
- align-items: center;
194
-
195
- .el-form {
196
- display: flex;
197
- justify-content: flex-start;
198
- flex-wrap: wrap;
199
-
200
- .el-form-item {
201
- margin-bottom: 16px !important;
202
- .el-form-item__label {
203
- width: auto !important;
204
- }
205
- }
206
- .waterfall-panel {
207
- width: auto !important;
208
- align-items: center;
209
- }
210
- .table-header-form-btns {
211
- white-space: nowrap;
212
- display: flex;
213
- flex-wrap: wrap;
214
- align-items: center;
215
- & > * {
216
- margin-bottom: 16px;
217
- }
218
- }
219
- }
220
-
221
- .el-plus-table-header-btns {
222
- display: flex;
223
- align-items: center;
224
- flex-wrap: wrap;
225
-
226
- .el-plus-table-header-btn {
227
- height: 40px;
228
- display: flex;
229
- align-items: center;
230
- margin-right: 10px;
231
- }
232
- }
233
- }
234
- }
235
- </style>
236
- <style lang="scss" scoped="">
237
- .el-plus-table-header-info {
238
- width: 100%;
239
- }
240
- </style>
1
+ <template>
2
+ <div class="el-plus-table-header-info">
3
+ <template v-if="props.toolbar && Object.keys(props.toolbar || {}).length">
4
+ <el-form :inline="true" class="el-plus-table-header-form" :style="{ justifyContent: !props.toolbar.formConfig && props.toolbar.btnRight ? 'flex-end' : 'space-between' }">
5
+ <div v-if="props.toolbar.formConfig" class="el-plus-table-form-items">
6
+ <ElPlusForm ref="elPlusFormRef" v-bind="formConfig" v-model="props.modelValue" labelWidth="1" :requestFn="handelQueryData" :showBtns="false" :isTable="true">
7
+ <template #row>
8
+ <div class="table-header-form-btns">
9
+ <ElPlusFormBtn type="primary" icon="ele-Search" :loading="loading" :desc="{ label: '查询', on: { click: handelSearch }, size }" />
10
+ <ElPlusFormBtn :desc="{ label: '重置', on: { click: handelReset }, size }" />
11
+ <ElPlusFormBtn type="primary" v-if="props.toolbar.export" :desc="{ label: '导出Excel', size, mask: true, on: { click: handelDownload } }" />
12
+ <ElPlusTableSettingColumn ref="settingColumnRef" v-if="tbName" :tbName="tbName" :column="column || []" :size="size" />
13
+ <ElPlusFormBtn v-for="(item, i) in headerBtns" :key="i" :desc="item" :loading="loading" />
14
+ </div>
15
+ </template>
16
+ </ElPlusForm>
17
+ </div>
18
+ <div v-else class="el-plus-table-header-btns" :style="{ 'min-width': isMobile() ? '100%' : headerBtns && headerBtns.length > 0 ? headerBtns.length * 110 + 'px' : '10px' }">
19
+ <div class="el-plus-table-header-btn">
20
+ <ElPlusFormBtn v-for="(item, i) in headerBtns" :key="i" :desc="item" :loading="loading" />
21
+ </div>
22
+ </div>
23
+ </el-form>
24
+ </template>
25
+ <!-- 如果这里有tbname, 则需要显示设置列按钮 -->
26
+ <template v-else-if="!!tbName">
27
+ <div class="el-plus-table-header-form">
28
+ <div class="table-header-form-btns" style="margin-bottom: 16px">
29
+ <ElPlusTableSettingColumn ref="settingColumnRef" v-if="tbName" :tbName="tbName" :column="column || []" :size="size" :showText="true" />
30
+ </div>
31
+ </div>
32
+ </template>
33
+ </div>
34
+ </template>
35
+ <script lang="ts" setup>
36
+ import { ref, computed, onMounted, nextTick, inject } from 'vue'
37
+ import ElPlusTableSettingColumn from './settingColumn.vue'
38
+ import ElPlusFormBtn from '../../el-plus-form/components/ElPlusFormBtn.vue'
39
+ import { isMobile, handelBtnType, mapToUrlStr } from '../util'
40
+
41
+ const defaultConf = inject('defaultConf') as ICRUDConfig
42
+
43
+ const emits = defineEmits(['query'])
44
+ const props = withDefaults(
45
+ defineProps<{
46
+ modelValue?: { [key: string]: any } | {}
47
+ column: Array<IColumnItem> | null
48
+ tbName: string
49
+ toolbar: ITableToolbar | null
50
+ isDialog: boolean
51
+ loading: boolean
52
+ isShowRefresh: boolean
53
+ size: string
54
+ }>(),
55
+ { tbName: '', toolbar: null, isDialog: false, loading: false, isShowRefresh: true, size: 'default' }
56
+ )
57
+
58
+ const elPlusFormRef = ref()
59
+ const settingColumnRef = ref()
60
+
61
+ const headerBtns = computed(() => {
62
+ const btns = [] as any[]
63
+ if (props.toolbar && props.toolbar.btns) {
64
+ props.toolbar.btns.map((item: any) => {
65
+ btns.push({ ...handelBtnType(item), size: item.size || props.size })
66
+ })
67
+ }
68
+ return btns
69
+ })
70
+
71
+ const formConfig = computed(() => {
72
+ const tempConf = props.toolbar?.formConfig
73
+ if (tempConf?.formDesc) {
74
+ Object.values(tempConf?.formDesc).map((item) => {
75
+ if (item.width) return
76
+ let width = 300
77
+ switch (item.type) {
78
+ case 'daterange':
79
+ case 'input':
80
+ case 'area':
81
+ width = 300
82
+ break
83
+ }
84
+ item.width = width + 'px'
85
+ })
86
+ }
87
+ return tempConf
88
+ })
89
+
90
+ function handelQueryData() {
91
+ // 通知父类执行查询
92
+ emits('query')
93
+ }
94
+
95
+ /**
96
+ * 下载
97
+ * @param data
98
+ */
99
+ async function handelDownload({ callBack }: IBtnBack) {
100
+ if (props.toolbar?.export) {
101
+ // 创建请求
102
+ const xhr = new XMLHttpRequest()
103
+ let url = props.toolbar.export.url || ''
104
+ if (props.toolbar.export.fetch) {
105
+ url = (await props.toolbar.export.fetch(Object.assign({}, elPlusFormRef.value?.getData(), props.toolbar.export?.data || {}))) as string
106
+ } else {
107
+ if (!props.toolbar.export.noQuery) {
108
+ url += (url.indexOf('?') >= 0 ? '&' : '?') + mapToUrlStr(Object.assign({}, elPlusFormRef.value?.getData(), props.toolbar.export?.data || {}))
109
+ }
110
+ }
111
+ xhr.open('get', url, true)
112
+ // 转换流
113
+ xhr.responseType = 'blob'
114
+ // 是否授权
115
+ if (props.toolbar.export.isAuth !== false && defaultConf.token) {
116
+ let token = defaultConf.token
117
+ if (typeof defaultConf.token === 'function') {
118
+ token = defaultConf.token()
119
+ }
120
+ xhr.setRequestHeader('Authorization', 'Bearer ' + token)
121
+ }
122
+ xhr.onload = function () {
123
+ if (this.status == 200) {
124
+ const aLink = document.createElement('a')
125
+ aLink.href = window.URL.createObjectURL(this.response)
126
+ // 自定义文件名
127
+ aLink.download = (props.toolbar?.export?.name || new Date().getTime()) + '.xls'
128
+ aLink.click()
129
+ window.URL.revokeObjectURL(url)
130
+ setTimeout(() => {
131
+ callBack && callBack()
132
+ }, 1000)
133
+ }
134
+ }
135
+ xhr.onerror = function () {
136
+ setTimeout(() => {
137
+ callBack && callBack()
138
+ }, 1000)
139
+ }
140
+ xhr.send()
141
+ }
142
+ }
143
+
144
+ /**
145
+ * 处理搜索
146
+ */
147
+ function handelSearch() {
148
+ elPlusFormRef.value.submit()
149
+ }
150
+
151
+ /**
152
+ * 处理重置
153
+ */
154
+ function handelReset() {
155
+ elPlusFormRef.value.clear()
156
+ nextTick(() => {
157
+ elPlusFormRef.value.submit()
158
+ })
159
+ }
160
+
161
+ /**
162
+ * 初始化列
163
+ */
164
+ function initCol() {
165
+ if (props.tbName) {
166
+ settingColumnRef.value?.initCol()
167
+ } else {
168
+ // 没有下一层,这里需要在这一层级初始化一下
169
+ props.column?.map((item: any) => {
170
+ // 这里初始化一下vif
171
+ if (item.vif !== undefined && item.vif !== null) {
172
+ if (typeof item.vif === 'function') {
173
+ item._vif = item.vif(item)
174
+ } else {
175
+ item._vif = !!item.vif
176
+ }
177
+ } else {
178
+ item._vif = true
179
+ }
180
+ })
181
+ }
182
+ }
183
+
184
+ onMounted(() => {})
185
+
186
+ defineExpose({ getData: () => elPlusFormRef.value?.getData(), initCol })
187
+ </script>
188
+ <style lang="scss">
189
+ .el-plus-table-header-info {
190
+ .el-plus-table-header-form {
191
+ display: flex;
192
+ flex-wrap: wrap;
193
+ align-items: center;
194
+
195
+ .el-form {
196
+ display: flex;
197
+ justify-content: flex-start;
198
+ flex-wrap: wrap;
199
+
200
+ .el-form-item {
201
+ margin-bottom: 16px !important;
202
+ .el-form-item__label {
203
+ width: auto !important;
204
+ }
205
+ }
206
+ .waterfall-panel {
207
+ width: auto !important;
208
+ align-items: center;
209
+ }
210
+ .table-header-form-btns {
211
+ white-space: nowrap;
212
+ display: flex;
213
+ flex-wrap: wrap;
214
+ align-items: center;
215
+ & > * {
216
+ margin-bottom: 16px;
217
+ }
218
+ }
219
+ }
220
+
221
+ .el-plus-table-header-btns {
222
+ display: flex;
223
+ align-items: center;
224
+ flex-wrap: wrap;
225
+
226
+ .el-plus-table-header-btn {
227
+ height: 40px;
228
+ display: flex;
229
+ align-items: center;
230
+ margin-right: 10px;
231
+ }
232
+ }
233
+ }
234
+ }
235
+ </style>
236
+ <style lang="scss" scoped="">
237
+ .el-plus-table-header-info {
238
+ width: 100%;
239
+ }
240
+ </style>
@@ -1,47 +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>
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>
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>
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>