@dt-frames/ui 1.0.10 → 1.0.13

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/es/components/curd/src/components/dialog.d.ts +28 -18
  2. package/es/components/curd/src/components/props.d.ts +4 -4
  3. package/es/components/curd/src/types/curd.type.d.ts +3 -2
  4. package/es/components/forms/src/components/formIcon.d.ts +11 -6
  5. package/es/components/forms/src/components/formInputUseDialog.d.ts +903 -0
  6. package/es/components/forms/src/types/form.type.d.ts +3 -1
  7. package/es/components/index.d.ts +1 -1
  8. package/es/components/modal/src/components/modal.d.ts +2 -2
  9. package/es/components/modal/src/components/modalFooter.d.ts +9 -4
  10. package/es/components/modal/src/index.d.ts +10 -5
  11. package/es/components/modal/src/props.d.ts +2 -1
  12. package/es/components/modal/src/types/modal.type.d.ts +5 -2
  13. package/es/components/source/src/hooks/useFetch.d.ts +2 -2
  14. package/es/components/source/src/hooks/useSource.d.ts +4 -4
  15. package/es/components/table/src/components/TableHeader.d.ts +2 -2
  16. package/es/components/table/src/components/editable/CellComponent.d.ts +14 -0
  17. package/es/components/table/src/components/editable/EditTableCell.d.ts +88 -0
  18. package/es/components/table/src/components/editable/componentMap.d.ts +4 -0
  19. package/es/components/table/src/components/editable/index.d.ts +9 -0
  20. package/es/components/table/src/hooks/useCustomRow.d.ts +19 -0
  21. package/es/components/table/src/hooks/useTable.d.ts +2 -2
  22. package/es/components/table/src/index.d.ts +27 -4
  23. package/es/components/table/src/props.d.ts +5 -1
  24. package/es/components/table/src/types/table.type.d.ts +18 -2
  25. package/es/components/upload/index.d.ts +1 -2
  26. package/es/components/upload/src/helper.d.ts +1 -0
  27. package/es/components/upload/src/index.d.ts +40 -13
  28. package/es/components/upload/src/props.d.ts +4 -1
  29. package/es/components/upload/src/upload.d.ts +45 -10
  30. package/es/index.js +589 -212
  31. package/es/style/components/forms/index.less +23 -0
  32. package/es/style/components/table/index.less +6 -0
  33. package/es/style/components/upload/index.less +3 -11
  34. package/es/style/theme/header/index.less +1 -1
  35. package/package.json +1 -1
  36. package/src/components/curd/src/components/dialog.vue +7 -5
  37. package/src/components/curd/src/components/props.ts +4 -4
  38. package/src/components/curd/src/hooks/useCurd.tsx +1 -1
  39. package/src/components/curd/src/types/curd.type.ts +3 -2
  40. package/src/components/forms/index.less +23 -0
  41. package/src/components/forms/src/componentMap.ts +2 -0
  42. package/src/components/forms/src/components/formInputUseDialog.vue +43 -0
  43. package/src/components/forms/src/components/formItem.vue +10 -10
  44. package/src/components/forms/src/types/form.type.ts +6 -0
  45. package/src/components/index.ts +1 -2
  46. package/src/components/modal/src/components/modalFooter.vue +10 -2
  47. package/src/components/modal/src/hooks/useModal.ts +12 -4
  48. package/src/components/modal/src/index.vue +19 -8
  49. package/src/components/modal/src/props.ts +3 -2
  50. package/src/components/modal/src/types/modal.type.ts +5 -2
  51. package/src/components/source/src/hooks/useFetch.ts +6 -4
  52. package/src/components/source/src/hooks/useSource.ts +5 -4
  53. package/src/components/table/index.less +6 -0
  54. package/src/components/table/src/components/TableHeader.vue +2 -2
  55. package/src/components/table/src/components/editable/CellComponent.ts +57 -0
  56. package/src/components/table/src/components/editable/EditTableCell.vue +181 -0
  57. package/src/components/table/src/components/editable/componentMap.ts +18 -0
  58. package/src/components/table/src/components/editable/index.ts +58 -0
  59. package/src/components/table/src/hooks/useColumns.ts +15 -8
  60. package/src/components/table/src/hooks/useCustomRow.ts +86 -0
  61. package/src/components/table/src/hooks/useRowSelection.ts +1 -1
  62. package/src/components/table/src/hooks/useTable.ts +1 -1
  63. package/src/components/table/src/hooks/useTableHeader.ts +1 -1
  64. package/src/components/table/src/index.vue +20 -3
  65. package/src/components/table/src/props.ts +4 -1
  66. package/src/components/table/src/types/table.type.ts +30 -3
  67. package/src/components/upload/index.less +3 -11
  68. package/src/components/upload/index.ts +0 -2
  69. package/src/components/upload/src/helper.ts +29 -1
  70. package/src/components/upload/src/props.ts +4 -1
  71. package/src/components/upload/src/upload.vue +88 -63
  72. package/src/theme/header/index.less +1 -1
  73. package/src/components/upload/src/index.vue +0 -38
@@ -1,46 +1,49 @@
1
1
  <template>
2
- <div class="file-header">
3
- <div>
4
- <Upload
5
- :accept="getStringAccept"
6
- :multiple="multiple"
7
- :before-upload="beforeUpload"
8
- :show-upload-list="false"
9
- >
10
- <Button type="primary">
11
- <span v-icon="'ic:baseline-file-upload'"></span>
12
- 文件上传
2
+ <div class="dt-file">
3
+ <div class="file-header">
4
+ <div>
5
+ <Upload
6
+ :accept="getStringAccept"
7
+ :multiple="multiple"
8
+ :before-upload="beforeUpload"
9
+ :show-upload-list="false"
10
+ >
11
+ <Button type="primary">
12
+ <span v-icon="'ic:baseline-file-upload'"></span>
13
+ 文件上传
14
+ </Button>
15
+ </Upload>
16
+ <Button type="primary" v-if="showTemplateDownload" @click="templateDownload">
17
+ <span v-icon="'ic:baseline-file-download'"></span>
18
+ 模板下载
13
19
  </Button>
14
- </Upload>
15
- <Button type="primary" v-if="showTemplateDownload" @click="templateDownload">
16
- <span v-icon="'ic:baseline-file-download'"></span>
17
- 模板下载
18
- </Button>
20
+ </div>
21
+ <slot></slot>
19
22
  </div>
20
- <slot></slot>
21
- </div>
22
23
 
23
- <div class="file-type-tips ant-alert-info">
24
- <span v-icon="'ant-design:info-circle-outlined'"></span>
25
- <i>请上传pptx、doc、jpg、jpeg、png、bmp、gif、xls、xlsx、txt、rar、zip、7z、tar、gz格式文件</i>
26
- </div>
27
-
28
- <DtTable @register="registerTable"></DtTable>
29
-
30
- <Image
31
- :width="200"
32
- :style="{ display: 'none' }"
33
- :preview="{
34
- visible: imgVisable,
35
- onVisibleChange: setImgVisible,
36
- }"
37
- src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
38
- ></Image>
24
+ <div class="file-type-tips ant-alert-info">
25
+ <span v-icon="'ant-design:info-circle-outlined'"></span>
26
+ <i>{{ getHelpText }}</i>
27
+ </div>
28
+
29
+ <DtTable @register="registerTable"></DtTable>
30
+
31
+ <Image
32
+ :width="200"
33
+ :style="{ display: 'none' }"
34
+ :preview="{
35
+ visible: imgVisable,
36
+ onVisibleChange: setImgVisible,
37
+ }"
38
+ :src="imgSrcRef"
39
+ ></Image>
39
40
 
41
+ </div>
42
+
40
43
  </template>
41
44
 
42
45
  <script lang="ts" setup>
43
- import { h, ref, toRefs, watchEffect } from 'vue'
46
+ import { h, ref, toRefs, watchEffect, watch, computed } from 'vue'
44
47
  import { Button, Upload, Image } from 'ant-design-vue'
45
48
  import { DtTable, useTable } from '../../table'
46
49
  import { basicUploadProps } from './props'
@@ -53,62 +56,77 @@
53
56
 
54
57
  const filesRef = ref([])
55
58
  const historyFilesRef = ref([])
56
- const allFilesRef = ref([])
59
+ const allFilesRef = computed(() => {
60
+ return [...historyFilesRef.value, ...filesRef.value ]
61
+ })
57
62
 
58
63
  // 控制图片预览显示隐藏
59
64
  const imgVisable = ref( false )
65
+ const imgSrcRef = ref()
60
66
  const setImgVisible = (value) => imgVisable.value = value
61
67
 
62
68
  const props = defineProps( basicUploadProps )
63
69
 
64
70
  const { accept, helpText, maxNumber, maxSize } = toRefs(props)
65
- const { getStringAccept } = useHelpers( accept, helpText, maxNumber, maxSize )
71
+ const {
72
+ getStringAccept,
73
+ getHelpText
74
+ } = useHelpers( accept, helpText, maxNumber, maxSize )
66
75
 
76
+ const isImage = (fileType: string) => ['pdf', 'jpg', 'jpeg', 'png', 'bmp', 'gif'].includes( fileType )
67
77
 
68
- const [registerTable, { }] = useTable({
78
+ const [registerTable] = useTable({
69
79
  tableSetting: false,
70
80
  pagination: false,
71
81
  dataSource: allFilesRef,
72
82
  columns: [
73
83
  { title: '文件名称', dataIndex: 'fileName' },
74
- { title: '上传状态', dataIndex: 'fileStatue', render(row) {
75
- return h('span', {
76
- style: `color: ${ row.status === 0 ? 'orange' : 'green' }`,
77
- }, row.fileStatue)
78
- } },
84
+ { title: '上传状态', dataIndex: 'fileStatue', className: 'orange' },
79
85
  ],
80
86
  operations: {
81
87
  expand: true,
82
88
  btns: [
83
89
  { title: '预览', icon: 'ic:baseline-remove-red-eye',
84
90
  ifShow(row) {
85
- const supportFileTypes = ['pdf', 'jpg', 'jpeg', 'png', 'bmp', 'gif']
86
- return supportFileTypes.includes( row.fileName.split('.').pop() )
91
+ if( !props.showView ) return false
92
+ return isImage( row.fileName.split('.').pop() )
87
93
  },
88
- action: () => {
89
- setImgVisible(true)
94
+ action: ({ row }) => {
95
+ if( isImage( row.fileName.split('.').pop() ) ) {
96
+ setImgVisible(true)
97
+ }
90
98
  }
91
99
  },
92
- { title: '编辑', icon: 'mdi:text-box-edit-outline' },
93
- { title: '删除', icon: 'mdi:delete-outline' }
100
+ { title: '删除', icon: 'mdi:delete-outline', action: ({row}) => {
101
+ if( !row.status ) historyFilesRef.value = historyFilesRef.value.filter( it => it.fileId !== row.fileId )
102
+ else {
103
+ filesRef.value = filesRef.value.filter( it => it.fileId !== row.fileId )
104
+ }
105
+ } }
94
106
  ]
95
107
  }
96
108
  })
97
109
 
98
-
99
- watchEffect(() => {
100
- historyFilesRef.value = props.defaultFiles.map(file => {
101
- return {
102
- ...file,
103
- fileName: file.fileName,
104
- status: 0,
105
- fileStatue: '历史上传'
110
+ watch(
111
+ () => props.defaultFiles,
112
+ v => {
113
+ if( v ) {
114
+ historyFilesRef.value = props.defaultFiles.map((file, index) => {
115
+ return {
116
+ ...file,
117
+ fileId: file.id || index,
118
+ fileName: file.fileName,
119
+ status: 0,
120
+ fileStatue: '历史上传'
121
+ }
122
+ })
106
123
  }
107
- })
124
+ },
125
+ {
126
+ immediate: true
127
+ }
128
+ )
108
129
 
109
- allFilesRef.value = [...historyFilesRef.value, ...filesRef.value]
110
- })
111
-
112
130
 
113
131
  function beforeUpload(file: File) {
114
132
  const { maxSize } = props
@@ -139,13 +157,20 @@
139
157
  if (currentChunk < chunks) {
140
158
  loadNext();
141
159
  } else {
142
- filesRef.value.push({
160
+ let fileObj = {
143
161
  fileName: file.name,
144
162
  fileId: spark.end(),
145
163
  file,
146
164
  status: 1,
147
165
  fileStatue: '待上传'
148
- })
166
+ }
167
+
168
+ if( props.multiple ) {
169
+ filesRef.value.push(fileObj)
170
+ } else {
171
+ historyFilesRef.value = []
172
+ filesRef.value = [fileObj]
173
+ }
149
174
  }
150
175
  }
151
176
 
@@ -417,7 +417,7 @@
417
417
  margin-bottom: 20px;
418
418
 
419
419
  .select-item{
420
- width: 130px;
420
+ width: 130px !important;
421
421
  }
422
422
  }
423
423
 
@@ -1,38 +0,0 @@
1
- <template>
2
- <DtModal
3
- @save="handleSave()"
4
- @register="register"
5
- >
6
- <div class="dt-upload-wrap">
7
- <DtUpload ref="uploadRef" :defaultFiles="defaultFiles">
8
- 111
9
- </DtUpload>
10
- </div>
11
- </DtModal>
12
- </template>
13
-
14
- <script lang="ts" setup>
15
- import { ref } from 'vue'
16
- import { DtModal, useModal } from '../../modal'
17
- import DtUpload from './upload.vue'
18
-
19
- const uploadRef = ref(null)
20
- const emites = defineEmits(['register'])
21
-
22
- // 注册弹框
23
- const [register] = useModal({
24
- width: '700px',
25
- title: '文件上传',
26
- maskClosable: false,
27
- })
28
-
29
- const defaultFiles = [
30
- { fileName: '叮咚发票667.09.pdf', fileId: '1' }
31
- ]
32
-
33
- // 保存
34
- function handleSave() {
35
- console.log(uploadRef.value.allFilesRef)
36
- alert("s-s-s-")
37
- }
38
- </script>