@scenetechnology/cj_element_table 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/.browserslistrc +4 -0
  2. package/.env.base +11 -0
  3. package/.env.dev +23 -0
  4. package/.env.gitee +23 -0
  5. package/.env.pro +24 -0
  6. package/.env.test +23 -0
  7. package/.eslintrc.js +18 -0
  8. package/README.md +24 -0
  9. package/babel.config.js +6 -0
  10. package/dist/cj_element_table.common.js +66535 -0
  11. package/dist/cj_element_table.common.js.map +1 -0
  12. package/dist/cj_element_table.css +1 -0
  13. package/dist/cj_element_table.umd.js +66554 -0
  14. package/dist/cj_element_table.umd.js.map +1 -0
  15. package/dist/cj_element_table.umd.min.js +61 -0
  16. package/dist/cj_element_table.umd.min.js.map +1 -0
  17. package/dist/demo.html +1 -0
  18. package/package.json +42 -0
  19. package/packages/components/SaveViewDialog.vue +109 -0
  20. package/packages/components/exportExcel.js +305 -0
  21. package/packages/components/exportTable.vue +361 -0
  22. package/packages/components/historyDialog.vue +100 -0
  23. package/packages/components/index.vue +1235 -0
  24. package/packages/components/tablesetting.vue +344 -0
  25. package/packages/components/tuo-drag.vue +197 -0
  26. package/packages/components/viewEdit.vue +239 -0
  27. package/packages/index.js +13 -0
  28. package/public/favicon.ico +0 -0
  29. package/public/index.html +17 -0
  30. package/src/App.vue +59 -0
  31. package/src/api/All.ts +104 -0
  32. package/src/assets/images/TablehederTool.png +0 -0
  33. package/src/assets/images/addIcon.png +0 -0
  34. package/src/assets/images/blue_lock.png +0 -0
  35. package/src/assets/images/changeIcon.png +0 -0
  36. package/src/assets/images/downImg.png +0 -0
  37. package/src/assets/images/kong_icon.png +0 -0
  38. package/src/assets/images/lbIcon.png +0 -0
  39. package/src/assets/images/lookImg.png +0 -0
  40. package/src/assets/images/model_title_icon.png +0 -0
  41. package/src/assets/images/pgIcon.png +0 -0
  42. package/src/assets/images/pzIcon.png +0 -0
  43. package/src/assets/images/tuozhui_icon.png +0 -0
  44. package/src/assets/images/view_save_icon.png +0 -0
  45. package/src/assets/images/view_setting_icon.png +0 -0
  46. package/src/assets/images/yaIcon.png +0 -0
  47. package/src/assets/logo.png +0 -0
  48. package/src/components/Dialog/index.ts +3 -0
  49. package/src/components/Dialog/src/Dialog.vue +72 -0
  50. package/src/components/HelloWorld.vue +60 -0
  51. package/src/components/Upload/index.vue +287 -0
  52. package/src/config/axios/config.ts +122 -0
  53. package/src/config/axios/index.ts +48 -0
  54. package/src/config/axios/service.ts +118 -0
  55. package/src/main.ts +13 -0
  56. package/src/router/index.ts +16 -0
  57. package/src/shims-vue.d.ts +6 -0
  58. package/tsconfig.json +41 -0
  59. package/types/global.d.ts +39 -0
  60. package/types/vite-env.d.ts +0 -0
  61. package/vue.config.js +24 -0
@@ -0,0 +1,361 @@
1
+ <template>
2
+ <el-dialog v-model="modelValue" title="列表设置" :width="800">
3
+ <div class="content">
4
+ <div style="flex: 3;">
5
+ <div class="classTitle">
6
+ 选择导出范围
7
+ </div>
8
+ <el-radio-group v-model="export_type" @change="change_tabledata">
9
+ <el-radio :value="0">全部数据</el-radio>
10
+ <el-radio :value="1">当前列表数据</el-radio>
11
+ <el-radio :value="2">已选中数据</el-radio>
12
+ </el-radio-group>
13
+ <div class="classTitle">
14
+ 选择列表显示字段
15
+ <ElCheckbox style="margin-left:5px;font-weight: 400;font-size: 14px;color: #666666;" :indeterminate="indeterminate" v-model="checkAll" @click.prevent.native="handleCheckAll">全选</ElCheckbox>
16
+ </div>
17
+ <ElCheckboxGroup v-model="checkAllGroup" >
18
+ <el-checkbox :disabled="item.require" @change="change_check(item, $event)" v-for="(item, index) in columnsList" :key="index" :label="item.label">
19
+ {{ item.label }} {{ item.checked }}
20
+ <span v-if="item.require">(必选字段)</span>
21
+ </el-checkbox>
22
+ </ElCheckboxGroup>
23
+ </div>
24
+ <div style="flex:2;">
25
+ <div style="display: flex;align-items: center;justify-content: space-between;">
26
+ <span style="font-weight: 400;font-size: 15px;color: #333333;">已选择字段</span>
27
+ </div>
28
+ <tuo-drag v-if="modelValue" @updatesortColumns="updatesortColumns" ref="tuoDrags" :checkAllGroupObj="checkAllGroupObj" :initialSortColumns="sortColumns"></tuo-drag>
29
+ </div>
30
+ </div>
31
+ <template #footer>
32
+ <ElButton @click="handleReset">取消</ElButton>
33
+ <ElButton type="primary" @click="handleSubmit('custom')" :loading="exportBtnLoading" style="margin-left: 8px">导出</ElButton>
34
+ </template>
35
+ </el-dialog>
36
+ </template>
37
+
38
+ <script setup lang="ts">
39
+ import { ref, watch, computed, onMounted } from 'vue'
40
+ import {
41
+ ElCheckbox,
42
+ ElCheckboxGroup,
43
+ ElPagination,
44
+ ElButton,
45
+ ElDropdown,
46
+ ElDropdownMenu,
47
+ ElDropdownItem,
48
+ ElInput,
49
+ ElDialog,
50
+ ElSelect,
51
+ ElOption
52
+ } from 'element-plus'
53
+ import * as exportExcel from './exportExcel.js'
54
+ // import { getToken } from '@/libs/util'
55
+ import tuoDrag from './tuo-drag.vue'
56
+
57
+ const props = defineProps({
58
+ modelValue: {
59
+ type: Boolean,
60
+ required: true
61
+ },
62
+ exportXlsxName:{
63
+ type:String
64
+ },
65
+ columnsList: {
66
+ type: Array,
67
+ default: () => []
68
+ },
69
+ tableData: {
70
+ type: Array,
71
+ default: () => []
72
+ },
73
+ columnSetting: {
74
+ type: Object,
75
+ default: () => ({})
76
+ },
77
+ title: {
78
+ type: String,
79
+ default: ''
80
+ },
81
+ width: {
82
+ type: [String, Number],
83
+ default: '800px'
84
+ }
85
+ })
86
+
87
+ const emit = defineEmits(['update:modelValue',"updateTable"])
88
+
89
+ const modelValue = computed({
90
+ get: () => props.modelValue,
91
+ set: (val) => emit('update:modelValue', val)
92
+ })
93
+ const exportBtnAllLoading = ref(false)
94
+ const exportBtnLoading = ref(false)
95
+ const sortColumns = ref([])
96
+ const columnsOptionList = ref([])
97
+ const modalLoading = ref(false)
98
+ const indeterminate = ref(false)
99
+ const checkRequireGroup=ref([])
100
+ const checkAll = ref(false)
101
+ const checkAllGroup = ref([])
102
+ const tempCheckAllGroup=ref([])
103
+ const checkAllGroupObj = ref({})
104
+ const dropSortColumns = ref([])
105
+ const freeze = ref('')
106
+ const tuoDrags = ref(null)
107
+ const table_data_arr=ref([])
108
+ const export_type=ref(0)
109
+ const export_tabledata=ref([])
110
+ const initColumns = (val: any[]) => {
111
+ checkAllGroup.value = []
112
+ sortColumns.value = []
113
+ const tempColumnsOptionList = []
114
+ val.forEach((item, index) => {
115
+ tempCheckAllGroup.value.push(item.label)
116
+ if (item.require) {
117
+ // checkAllGroup.value.push(item.label)
118
+ checkRequireGroup.value.push(item.label)
119
+ }
120
+ tempColumnsOptionList.push({
121
+ label: '至第' + (index + 1) + '列',
122
+ value: index + 1
123
+ })
124
+ })
125
+ tempColumnsOptionList.push({
126
+ label: '不冻结',
127
+ value: '不冻结'
128
+ })
129
+ if (props.columnSetting.id) {
130
+ // console.log(props.columnSettingObj)
131
+ checkAllGroup.value = [...checkAllGroup.value, ...props.columnSetting.content.checkColumnData]
132
+ freeze.value = props.columnSetting.content.freeze
133
+ }
134
+ columnsOptionList.value = tempColumnsOptionList
135
+ sortColumns.value = [...checkAllGroup.value]
136
+
137
+ if (checkAllGroup.value.length === val.length) {
138
+ checkAll.value = true
139
+ checkAllGroup.value = tempCheckAllGroup.value
140
+ indeterminate.value = false
141
+ } else if (checkAllGroup.value.length > 1) {
142
+ checkAll.value = false
143
+ indeterminate.value = true
144
+ } else {
145
+ checkAll.value = false
146
+ indeterminate.value = false
147
+ }
148
+ }
149
+
150
+ watch(
151
+ () => props.columnsList,
152
+ (val) => {
153
+ initColumns(val)
154
+ }
155
+ )
156
+
157
+ watch(
158
+ () => props.columnSetting,
159
+ (newVal) => {
160
+ if (newVal !== undefined) {
161
+ initColumns(props.columnsList)
162
+ }
163
+ },
164
+ { immediate: true }
165
+ )
166
+
167
+ onMounted(() => {
168
+ initColumns(props.columnsList)
169
+ })
170
+ const handleCheckAll = () => {
171
+ if(checkAllGroup.value.length!=tempCheckAllGroup.value.length){ //全选
172
+ tempCheckAllGroup.value.map(item=>{
173
+ let status=sortColumns.value.some(sort=>{
174
+ return item==sort
175
+ })
176
+ if(!status){
177
+ sortColumns.value.push(item)
178
+ }
179
+ })
180
+ sortColumns.value=sortColumns.value.concat([])
181
+ checkAllGroup.value=tempCheckAllGroup.value
182
+ checkAllGroup.value=checkAllGroup.value.concat([])
183
+ checkAll.value=true
184
+ indeterminate.value=false
185
+ }else{ //取消全选
186
+ checkAllGroup.value=checkRequireGroup.value
187
+ checkAllGroup.value=checkAllGroup.value.concat([])
188
+ let sort=[]
189
+ sortColumns.value.map(item=>{
190
+ checkRequireGroup.value.map(require=>{
191
+ if(require==item){
192
+ sort.push(item)
193
+ }
194
+ })
195
+ })
196
+ sortColumns.value=sort
197
+ sortColumns.value= sortColumns.value.concat([])
198
+ if(checkRequireGroup.value.length==0){
199
+ indeterminate.value=false
200
+ checkAll.value=false
201
+ }else{
202
+ indeterminate.value=true
203
+ checkAll.value=false
204
+ }
205
+
206
+ }
207
+ }
208
+ const change_check = (item: any,event) => {
209
+ if(event){
210
+ sortColumns.value.push(item.label)
211
+ }else{
212
+ sortColumns.value.map((col,index)=>{
213
+ if(col==item.label){
214
+ sortColumns.value.splice(index,1)
215
+ }
216
+ })
217
+ }
218
+ sortColumns.value=sortColumns.value.concat([])
219
+ console.log(sortColumns.value,event,2222)
220
+ if (checkAllGroup.value.length === tempCheckAllGroup.value.length) { //判断全选按钮状态
221
+ indeterminate.value = false
222
+ checkAll.value = true
223
+ } else if (checkAllGroup.value.length > 0) {
224
+ indeterminate.value = true
225
+ checkAll.value = false
226
+ } else {
227
+ indeterminate.value = false
228
+ checkAll.value = false
229
+ }
230
+ }
231
+
232
+ const handleReset = () => {
233
+ modelValue.value = false
234
+ }
235
+ const isNull = (val: string[]) => {
236
+ return val === null || val === void 0 || val === '' || (val).toString() === 'NaN'
237
+ }
238
+
239
+ const updatesortColumns = (val: string[],type) => {
240
+ if(type=="custom"){
241
+ table_data_arr.value=val
242
+ }else{
243
+ dropSortColumns.value = val
244
+ }
245
+ }
246
+ const handleSubmit = (type) => {
247
+ if(type=="custom"){
248
+ dropSortColumns.value=[]
249
+ props.columnsList.forEach((item, index) => {
250
+ sortColumns.value.forEach((item2, index2) => {
251
+ if(item.label==item2){
252
+ dropSortColumns.value.push(item)
253
+ }
254
+ })
255
+ })
256
+ export_tabledata.value=table_data_arr.value[export_type.value]
257
+ }else{
258
+ export_tabledata.value=props.tableData
259
+ }
260
+ console.log( dropSortColumns.value,export_tabledata.value,111)
261
+ let columns=[]
262
+ dropSortColumns.value.map(item => {
263
+ columns.push({
264
+ name: item.label??item,
265
+ _width: 30 // 注意:这里是封装后才能这样写,exceljs table columns 没有width
266
+ })
267
+ })
268
+ // 生成rows
269
+ let rows = []
270
+ export_tabledata.value.map(item => {
271
+ let arr = []
272
+ dropSortColumns.value.map(sub => {
273
+ arr.push(!isNull(item[sub.prop]) ? item[sub.prop] : '')
274
+ })
275
+ rows.push(arr)
276
+ })
277
+ console.log(columns,rows,222)
278
+ // 表头样式设置 - 生成_cellStyle
279
+ let _cellStyle = []
280
+ dropSortColumns.value.map((item, index) => {
281
+ _cellStyle.push({
282
+ coords: [index, 0], // 代表表格第一行第一列 [横坐标,纵坐标]
283
+ style: {
284
+ border: {
285
+ top: { style: 'thin' },
286
+ left: { style: 'thin' },
287
+ bottom: { style: 'thin' },
288
+ right: { style: 'thin' }
289
+ },
290
+ alignment: { vertical: 'middle', horizontal: 'center' }
291
+ },
292
+ })
293
+ })
294
+ exportExcel.$export([
295
+ {
296
+ name: 'MyTestTable',
297
+ ref: 'A1',
298
+ headerRow: true,
299
+ totalsRow: false,
300
+ style: {
301
+ theme: 'TableStyleLight1',
302
+ },
303
+ columns: columns,
304
+ rows: rows,
305
+ _tableBorder: true,
306
+ _cellStyle: [..._cellStyle],
307
+ _mergeCells: []
308
+ }
309
+ ], {
310
+ sheetName: 'My Sheet',
311
+ fileName: props.exportXlsxName,
312
+ })
313
+ }
314
+ defineExpose({ handleSubmit,updatesortColumns })
315
+ </script>
316
+
317
+ <style scoped>
318
+ .dialog-content {
319
+ padding: 20px;
320
+ }
321
+
322
+ .dialog-footer {
323
+ display: flex;
324
+ justify-content: flex-end;
325
+ gap: 10px;
326
+ }
327
+
328
+ /* :deep(.el-checkbox-group) {
329
+ display: flex;
330
+ flex-direction: column;
331
+ gap: 10px;
332
+ } */
333
+ .classTitle::before{
334
+ content: "*";
335
+ display: inline-block;
336
+ margin-right: 4px;
337
+ line-height: 1;
338
+ font-family: SimSun;
339
+ font-size: 12px;
340
+ color: #ed4014;
341
+ }
342
+ .classTitle{
343
+ display: flex;
344
+ justify-content: flex-start;
345
+ align-items: center;
346
+ font-family: PingFang SC;
347
+ font-weight: 400;
348
+ font-size: 15px;
349
+ color: #333;
350
+ }
351
+ .content {
352
+ display: flex;
353
+ justify-content: space-between;
354
+ padding: 20px;
355
+ }
356
+ .headerTitle{
357
+ font-weight: 500;
358
+ font-size: 16px;
359
+ color: #1D2027;
360
+ }
361
+ </style>
@@ -0,0 +1,100 @@
1
+ <template>
2
+ <ElDialog
3
+ v-model="dialogVisible"
4
+ :title="title"
5
+ :width="1000"
6
+ :close-on-click-modal="false"
7
+ @close="handleClose"
8
+ >
9
+ <TableComponent ref="tableRef" :maxHeight="400" :initial-query="query" :tableData="tableData" :columns="columns" :show-input-buttons="false" :show-output-buttons="false" :showTableSettingButtons="false" :show-view-setting-buttons="false" @search="handleSearch"/>
10
+ </ElDialog>
11
+ </template>
12
+
13
+ <script lang="ts" setup>
14
+ // import { Dialog } from '@/components/Dialog'
15
+ import TableComponent from './index.vue'
16
+ import { ref, watch,onMounted} from 'vue'
17
+ import { ElTable, ElTableColumn, ElPagination,ElDialog, ElScrollbar } from 'element-plus'
18
+ import { useRoute } from 'vue-router'
19
+ import { ImportRecord_index} from '@/api/All.ts'
20
+ const props = defineProps({
21
+ modelValue: {
22
+ type: Boolean,
23
+ default: false
24
+ },
25
+ type: {
26
+ type: String,
27
+ default: 'input' //ouput
28
+ },
29
+ title: {
30
+ type: String,
31
+ default: '导入记录'
32
+ },
33
+ width: {
34
+ type: String,
35
+ default: '500px'
36
+ }
37
+ })
38
+ const columns = [
39
+ { prop: 'create_time', label: '导入时间',required: true },
40
+ { prop: 'success', label: '导入成功数据条数',required: true },
41
+ { prop: 'error', label: '导入失败数据条数',required: true }
42
+ ]
43
+
44
+ const emit = defineEmits(['update:modelValue', 'confirm', 'cancel'])
45
+
46
+ const dialogVisible = ref(props.modelValue)
47
+ const tableData = ref()
48
+ const total = ref(0)
49
+ let route_path = ''
50
+ const route = useRoute()
51
+ if(route&&route.name)
52
+ {
53
+ route_path = route.name
54
+ }
55
+
56
+ const query = ref({
57
+ page: 1,
58
+ rows: 10,
59
+ tag: route_path
60
+ })
61
+ onMounted(() => {
62
+ handleSearch()
63
+ })
64
+
65
+ const handleSearch = (query) => {
66
+ if(props.type == 'input'){
67
+ ImportRecord_index(query).then((res) => {
68
+ tableData.value = res.data
69
+ total.value = res.data.total
70
+ })
71
+ }
72
+ }
73
+ watch(() => props.modelValue, (val) => {
74
+ dialogVisible.value = val
75
+ })
76
+ watch(() => dialogVisible.value, (val) => {
77
+ emit('update:modelValue', val)
78
+ })
79
+ const handleClose = () => {
80
+ dialogVisible.value = false
81
+ }
82
+ </script>
83
+
84
+ <style scoped>
85
+ .dialog-content {
86
+ padding: 20px;
87
+ }
88
+
89
+ .pagination-container {
90
+ margin-top: 20px;
91
+ display: flex;
92
+ justify-content: flex-end;
93
+ }
94
+
95
+ .dialog-footer {
96
+ display: flex;
97
+ justify-content: flex-end;
98
+ gap: 10px;
99
+ }
100
+ </style>