fast-crud-ui3 1.5.16 → 1.5.18-beta

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 (168) hide show
  1. package/lib/assets/fonts/iconfont.d.ts +0 -0
  2. package/lib/components/checkbox-group/index.d.ts +2 -0
  3. package/lib/components/checkbox-group/src/fast-checkbox-group.d.ts +72 -0
  4. package/lib/components/content-dialog/index.d.ts +2 -0
  5. package/lib/components/content-dialog/src/fast-cell-content.d.ts +83 -0
  6. package/lib/components/json-viewer/index.d.ts +2 -0
  7. package/lib/components/json-viewer/src/fast-json-viewer.d.ts +48 -0
  8. package/lib/components/mapping.d.ts +5 -0
  9. package/lib/components/object-picker/index.d.ts +2 -0
  10. package/lib/components/object-picker/src/fast-object-picker.d.ts +132 -0
  11. package/lib/components/select/index.d.ts +2 -0
  12. package/lib/components/select/src/fast-select.d.ts +83 -0
  13. package/lib/components/table/index.d.ts +2 -0
  14. package/lib/components/table/src/RowConfirm.d.ts +39 -0
  15. package/lib/components/table/src/dynamic-filter-form.d.ts +118 -0
  16. package/lib/components/table/src/dynamic-filter-list.d.ts +57 -0
  17. package/lib/components/table/src/easy-filter.d.ts +118 -0
  18. package/lib/components/table/src/export-confirm.d.ts +12 -0
  19. package/lib/components/table/src/quick-filter-form.d.ts +42 -0
  20. package/lib/components/table/src/row-form.d.ts +33 -0
  21. package/lib/components/table/src/stored-filter-manager.d.ts +55 -0
  22. package/lib/components/table/src/stored-filter.d.ts +37 -0
  23. package/lib/components/table/src/table-head-cell.d.ts +9 -0
  24. package/lib/components/table/src/table.d.ts +507 -0
  25. package/lib/components/table/src/util.d.ts +77 -0
  26. package/lib/components/table-column/config.d.ts +5 -0
  27. package/lib/components/table-column/index.d.ts +2 -0
  28. package/lib/components/table-column/src/table-column.d.ts +256 -0
  29. package/lib/components/table-column-date-picker/config.d.ts +5 -0
  30. package/lib/components/table-column-date-picker/index.d.ts +2 -0
  31. package/lib/components/table-column-date-picker/src/table-column-date-picker.d.ts +173 -0
  32. package/lib/components/table-column-file/config.d.ts +5 -0
  33. package/lib/components/table-column-file/index.d.ts +2 -0
  34. package/lib/components/table-column-file/src/table-column-file.d.ts +285 -0
  35. package/lib/components/table-column-img/config.d.ts +5 -0
  36. package/lib/components/table-column-img/index.d.ts +2 -0
  37. package/lib/components/table-column-img/src/table-column-img.d.ts +285 -0
  38. package/lib/components/table-column-input/config.d.ts +5 -0
  39. package/lib/components/table-column-input/index.d.ts +2 -0
  40. package/lib/components/table-column-input/src/table-column-input.d.ts +173 -0
  41. package/lib/components/table-column-number/config.d.ts +5 -0
  42. package/lib/components/table-column-number/index.d.ts +2 -0
  43. package/lib/components/table-column-number/src/table-column-number.d.ts +173 -0
  44. package/lib/components/table-column-object/config.d.ts +5 -0
  45. package/lib/components/table-column-object/index.d.ts +2 -0
  46. package/lib/components/table-column-object/src/table-column-object.d.ts +315 -0
  47. package/lib/components/table-column-select/config.d.ts +5 -0
  48. package/lib/components/table-column-select/index.d.ts +2 -0
  49. package/lib/components/table-column-select/src/table-column-select.d.ts +276 -0
  50. package/lib/components/table-column-switch/config.d.ts +5 -0
  51. package/lib/components/table-column-switch/index.d.ts +2 -0
  52. package/lib/components/table-column-switch/src/table-column-switch.d.ts +175 -0
  53. package/lib/components/table-column-textarea/config.d.ts +5 -0
  54. package/lib/components/table-column-textarea/index.d.ts +2 -0
  55. package/lib/components/table-column-textarea/src/table-column-textarea.d.ts +173 -0
  56. package/lib/components/table-column-time-picker/config.d.ts +5 -0
  57. package/lib/components/table-column-time-picker/index.d.ts +2 -0
  58. package/lib/components/table-column-time-picker/src/table-column-time-picker.d.ts +173 -0
  59. package/lib/components/upload/index.d.ts +2 -0
  60. package/lib/components/upload/src/fast-upload.d.ts +120 -0
  61. package/lib/fast-crud-ui3.cjs.js +44 -17
  62. package/lib/fast-crud-ui3.es.js +9991 -5946
  63. package/lib/fast-crud-ui3.umd.js +44 -17
  64. package/lib/global.d.ts +42 -0
  65. package/lib/index.d.ts +56 -0
  66. package/lib/mixins/table-column.d.ts +104 -0
  67. package/lib/mixins/upload.d.ts +15 -0
  68. package/lib/model/cond.d.ts +48 -0
  69. package/lib/model/editComponentConfig.d.ts +25 -0
  70. package/lib/model/fastTableOption.d.ts +513 -0
  71. package/lib/model/filterComponentConfig.d.ts +55 -0
  72. package/lib/model/opt.d.ts +20 -0
  73. package/lib/model/order.d.ts +28 -0
  74. package/lib/model/pageQuery.d.ts +43 -0
  75. package/lib/model/query.d.ts +101 -0
  76. package/lib/model/rel.d.ts +5 -0
  77. package/lib/style.css +1 -1
  78. package/lib/util/cache.d.ts +17 -0
  79. package/lib/util/dialog.d.ts +49 -0
  80. package/lib/util/escape.d.ts +7 -0
  81. package/lib/util/http.d.ts +8 -0
  82. package/lib/util/pick.d.ts +9 -0
  83. package/lib/util/util.d.ts +311 -0
  84. package/package.json +19 -5
  85. package/packages/assets/fonts/iconfont.css +163 -0
  86. package/packages/assets/fonts/iconfont.js +1 -0
  87. package/packages/assets/fonts/iconfont.ttf +0 -0
  88. package/packages/assets/fonts/iconfont.woff +0 -0
  89. package/packages/assets/fonts/iconfont.woff2 +0 -0
  90. package/packages/components/checkbox-group/index.js +7 -0
  91. package/packages/components/checkbox-group/src/fast-checkbox-group.vue +83 -0
  92. package/packages/components/content-dialog/index.js +7 -0
  93. package/packages/components/content-dialog/src/fast-cell-content.vue +115 -0
  94. package/packages/components/json-viewer/index.js +7 -0
  95. package/packages/components/json-viewer/src/fast-json-viewer.vue +54 -0
  96. package/packages/components/mapping.js +95 -0
  97. package/packages/components/object-picker/index.js +7 -0
  98. package/packages/components/object-picker/src/fast-object-picker.vue +170 -0
  99. package/packages/components/select/index.js +7 -0
  100. package/packages/components/select/src/fast-select.vue +90 -0
  101. package/packages/components/table/index.js +7 -0
  102. package/packages/components/table/src/RowConfirm.vue +87 -0
  103. package/packages/components/table/src/dynamic-filter-form.vue +253 -0
  104. package/packages/components/table/src/dynamic-filter-list.vue +172 -0
  105. package/packages/components/table/src/easy-filter.vue +129 -0
  106. package/packages/components/table/src/export-confirm.vue +55 -0
  107. package/packages/components/table/src/quick-filter-form.vue +140 -0
  108. package/packages/components/table/src/row-form.vue +137 -0
  109. package/packages/components/table/src/stored-filter-manager.vue +240 -0
  110. package/packages/components/table/src/stored-filter.vue +180 -0
  111. package/packages/components/table/src/table-head-cell.vue +41 -0
  112. package/packages/components/table/src/table.vue +1309 -0
  113. package/packages/components/table/src/util.js +496 -0
  114. package/packages/components/table-column/config.js +64 -0
  115. package/packages/components/table-column/index.js +7 -0
  116. package/packages/components/table-column/src/table-column.vue +44 -0
  117. package/packages/components/table-column-date-picker/config.js +139 -0
  118. package/packages/components/table-column-date-picker/index.js +7 -0
  119. package/packages/components/table-column-date-picker/src/table-column-date-picker.vue +54 -0
  120. package/packages/components/table-column-file/config.js +83 -0
  121. package/packages/components/table-column-file/index.js +7 -0
  122. package/packages/components/table-column-file/src/table-column-file.vue +79 -0
  123. package/packages/components/table-column-img/config.js +83 -0
  124. package/packages/components/table-column-img/index.js +7 -0
  125. package/packages/components/table-column-img/src/table-column-img.vue +82 -0
  126. package/packages/components/table-column-input/config.js +77 -0
  127. package/packages/components/table-column-input/index.js +7 -0
  128. package/packages/components/table-column-input/src/table-column-input.vue +60 -0
  129. package/packages/components/table-column-number/config.js +89 -0
  130. package/packages/components/table-column-number/index.js +7 -0
  131. package/packages/components/table-column-number/src/table-column-number.vue +54 -0
  132. package/packages/components/table-column-object/config.js +66 -0
  133. package/packages/components/table-column-object/index.js +7 -0
  134. package/packages/components/table-column-object/src/table-column-object.vue +75 -0
  135. package/packages/components/table-column-select/config.js +67 -0
  136. package/packages/components/table-column-select/index.js +7 -0
  137. package/packages/components/table-column-select/src/table-column-select.vue +101 -0
  138. package/packages/components/table-column-switch/config.js +55 -0
  139. package/packages/components/table-column-switch/index.js +7 -0
  140. package/packages/components/table-column-switch/src/table-column-switch.vue +82 -0
  141. package/packages/components/table-column-textarea/config.js +77 -0
  142. package/packages/components/table-column-textarea/index.js +7 -0
  143. package/packages/components/table-column-textarea/src/table-column-textarea.vue +56 -0
  144. package/packages/components/table-column-time-picker/config.js +62 -0
  145. package/packages/components/table-column-time-picker/index.js +7 -0
  146. package/packages/components/table-column-time-picker/src/table-column-time-picker.vue +53 -0
  147. package/packages/components/upload/index.js +7 -0
  148. package/packages/components/upload/src/fast-upload.vue +272 -0
  149. package/packages/global.d.ts +42 -0
  150. package/packages/index.js +145 -0
  151. package/packages/mixins/table-column.js +133 -0
  152. package/packages/mixins/upload.js +14 -0
  153. package/packages/model/cond.js +74 -0
  154. package/packages/model/editComponentConfig.js +72 -0
  155. package/packages/model/fastTableOption.js +769 -0
  156. package/packages/model/filterComponentConfig.js +191 -0
  157. package/packages/model/opt.js +21 -0
  158. package/packages/model/order.js +37 -0
  159. package/packages/model/pageQuery.js +52 -0
  160. package/packages/model/query.js +161 -0
  161. package/packages/model/rel.js +5 -0
  162. package/packages/style.scss +5 -0
  163. package/packages/util/cache.js +92 -0
  164. package/packages/util/dialog.js +133 -0
  165. package/packages/util/escape.js +34 -0
  166. package/packages/util/http.js +18 -0
  167. package/packages/util/pick.js +92 -0
  168. package/packages/util/util.js +892 -0
@@ -0,0 +1,82 @@
1
+ <template>
2
+ <el-table-column class-name="fc-table-column"
3
+ :prop="prop"
4
+ :label="label"
5
+ :min-width="minWidth"
6
+ :show-overflow-tooltip="showOverflowTooltip"
7
+ v-bind="$attrs"
8
+ v-if="!hidden">
9
+ <template #header="{column, $index}">
10
+ <fast-table-head-cell :column="columnProp" @click="headCellClick(column)">
11
+ <slot name="header" v-bind:column="column" v-bind:$index="$index">
12
+ <span>{{ label }}</span>
13
+ </slot>
14
+ </fast-table-head-cell>
15
+ </template>
16
+
17
+ <template #default="{row, column, $index}">
18
+ <slot v-bind:row="row" v-bind:column="column" v-bind:$index="$index">
19
+ <div v-if="!canEdit(row, column, $index)">
20
+ <slot name="normal" v-bind:row="row" v-bind:column="column" v-bind:$index="$index">
21
+ <fast-cell-content :value="showLabel(row)" :fat-row="row" :show-length="showLength" :linkTo="link"/>
22
+ </slot>
23
+ </div>
24
+ <slot name="edit" v-bind:row="row" v-bind:column="column" v-bind:$index="$index" v-else>
25
+ <el-switch v-model="row['editRow'][prop]"
26
+ v-bind="row['config'][prop]['props']"
27
+ :ref="prop + $index"
28
+ @change="(val) => handleChange(val, {row, column, $index})"></el-switch>
29
+ </slot>
30
+ </slot>
31
+ </template>
32
+ </el-table-column>
33
+ </template>
34
+
35
+ <script>
36
+ import tableColumn from "../../../mixins/table-column"
37
+
38
+ export default {
39
+ name: "FastTableColumnSwitch",
40
+ mixins: [tableColumn],
41
+ props: {
42
+ minWidth: {
43
+ type: String,
44
+ default: () => '100px'
45
+ }
46
+ },
47
+ methods: {
48
+ showLabel(fatRow) {
49
+ const {row, editRow, status, config} = fatRow
50
+ const {
51
+ props: {
52
+ activeValue = true,
53
+ activeText = '是',
54
+ inactiveValue = false,
55
+ inactiveText = '否'
56
+ } = {}
57
+ } = config[this.prop]
58
+ const options = [
59
+ {label: inactiveText, value: inactiveValue},
60
+ {label: activeText, value: activeValue}
61
+ ]
62
+ let val;
63
+ if (status === 'normal') {
64
+ val = row[this.prop];
65
+ } else {
66
+ val = editRow[this.prop];
67
+ }
68
+ if (options) {
69
+ const option = options.find(item => item.value === val);
70
+ if (option) {
71
+ return option.label
72
+ }
73
+ }
74
+ return val;
75
+ }
76
+ }
77
+ }
78
+ </script>
79
+
80
+ <style scoped>
81
+
82
+ </style>
@@ -0,0 +1,77 @@
1
+ import {easyOptParse, isUndefined, merge, ternary} from "../../util/util";
2
+ import Opt from "../../model/opt.js";
3
+
4
+ const defaultQueryConfig = {
5
+ component: 'el-input',
6
+ opt: Opt.LIKE,
7
+ val: null, // 默认值
8
+ props: {
9
+ clearable: true,
10
+ placeholder: `请输入..`
11
+ },
12
+ condMapFn: (cond) => {
13
+ const operators = {
14
+ '^!=': {
15
+ opt: Opt.NE,
16
+ valExtract: (cond) => cond.val.substring(2)
17
+ },
18
+ '^=': {
19
+ opt: Opt.EQ,
20
+ valExtract: (cond) => cond.val.substring(1)
21
+ },
22
+ '^~': {
23
+ opt: Opt.NLIKE,
24
+ valExtract: (cond) => cond.val.substring(1)
25
+ },
26
+ '^\\*': {
27
+ opt: Opt.LLIKE,
28
+ valExtract: (cond) => cond.val.substring(1)
29
+ },
30
+ '\\*$': {
31
+ opt: Opt.RLIKE,
32
+ valExtract: (cond) => cond.val.substring(0, cond.val.length - 1)
33
+ }
34
+ }
35
+ easyOptParse(cond, operators)
36
+ return [cond]
37
+ }
38
+ }
39
+ const defaultEditConfig = {
40
+ component: 'el-input',
41
+ val: null,
42
+ props: {
43
+ type: 'textarea',
44
+ rows: 1,
45
+ class: 'fc-table-inline-edit-component',
46
+ editable: true,
47
+ rules: [],
48
+ placeholder: '请输入..'
49
+ }
50
+ }
51
+ export default {
52
+ query: (config, type) => {
53
+ let val = defaultQueryConfig.val;
54
+ const {props: {defaultVal, ...validProps} = {}} = config
55
+ if (type === 'quick') {
56
+ val = ternary(isUndefined(defaultVal), val, defaultVal);
57
+ }
58
+ config.val = val;
59
+ config.props = validProps;
60
+ return merge(config, defaultQueryConfig, true, false)
61
+ },
62
+ edit: (config, type) => {
63
+ const {label, props = {}} = config;
64
+ const {defaultVal, rules = [], ...validProps} = props;
65
+ // 如果含有值不为false的required属性, 则将其转换为rules规则添加到props中
66
+ if (validProps.hasOwnProperty('required') && validProps.required !== false) {
67
+ rules.push({required: true, message: `${label}不能为空`})
68
+ }
69
+ config.val = ternary(isUndefined(defaultVal), defaultEditConfig.val, defaultVal);
70
+ config.props = {
71
+ ...validProps,
72
+ rules: rules
73
+ }
74
+ return merge(config, defaultEditConfig, true, false);
75
+ }
76
+
77
+ }
@@ -0,0 +1,7 @@
1
+ import FastTableColumnTextarea from './src/table-column-textarea.vue'
2
+
3
+ FastTableColumnTextarea.install = (app) => {
4
+ app.component(FastTableColumnTextarea.name, FastTableColumnTextarea)
5
+ }
6
+
7
+ export default FastTableColumnTextarea
@@ -0,0 +1,56 @@
1
+ <template>
2
+ <el-table-column class-name="fc-table-column"
3
+ :prop="prop"
4
+ :label="label"
5
+ :show-overflow-tooltip="showOverflowTooltip"
6
+ :min-width="minWidth"
7
+ v-bind="$attrs"
8
+ v-if="!hidden">
9
+ <template #header="{column, $index}">
10
+ <fast-table-head-cell :column="columnProp" @click="headCellClick(column)">
11
+ <slot name="header" v-bind:column="column" v-bind:$index="$index">
12
+ <span>{{ label }}</span>
13
+ </slot>
14
+ </fast-table-head-cell>
15
+ </template>
16
+
17
+ <template #default="{row, column, $index}">
18
+ <slot v-bind:row="row" v-bind:column="column" v-bind:$index="$index">
19
+ <template v-if="!canEdit(row, column, $index)">
20
+ <slot name="normal" v-bind:row="row" v-bind:column="column" v-bind:$index="$index">
21
+ <fast-cell-content :value="showLabel(row)" :fat-row="row" :show-length="showLength" :linkTo="link"/>
22
+ </slot>
23
+ </template>
24
+ <slot name="edit" v-bind:row="row" v-bind:column="column" v-bind:$index="$index" v-else>
25
+ <el-input v-model="row['editRow'][prop]"
26
+ v-bind="row['config'][prop]['props']"
27
+ :ref="prop + $index"
28
+ @change="(val) => handleChange(val, {row, column, $index})"
29
+ @blur="(event) => handleBlur(event, {row, column, $index})"
30
+ @focus="(event) => handleFocus(event, {row, column, $index})"
31
+ @input="(val) => handleInput(val, {row, column, $index})"
32
+ @clear="() => handleClear({row, column, $index})"></el-input>
33
+ </slot>
34
+ </slot>
35
+ </template>
36
+ </el-table-column>
37
+ </template>
38
+
39
+ <script>
40
+ import tableColumn from "../../../mixins/table-column"
41
+
42
+ export default {
43
+ name: "FastTableColumnTextarea",
44
+ mixins: [tableColumn],
45
+ props: {
46
+ minWidth: {
47
+ type: String,
48
+ default: () => '200px'
49
+ }
50
+ }
51
+ }
52
+ </script>
53
+
54
+ <style scoped>
55
+
56
+ </style>
@@ -0,0 +1,62 @@
1
+ import {isUndefined, merge, ternary} from "../../util/util";
2
+ import Cond from '../../model/cond.js'
3
+ import Opt from '../../model/opt.js'
4
+
5
+ const defaultQueryConfig = {
6
+ component: 'el-time-picker',
7
+ opt: Opt.BTW,
8
+ val: [],
9
+ props: {
10
+ clearable: true,
11
+ 'is-range': true,
12
+ 'value-format': 'HH:mm:ss'
13
+ },
14
+ condMapFn: (cond) => {
15
+ const conds = []
16
+ const [start, end] = cond.val
17
+ if (start) {
18
+ conds.push(new Cond(cond.col, Opt.GE, start))
19
+ }
20
+ if (end) {
21
+ conds.push(new Cond(cond.col, Opt.LE, end))
22
+ }
23
+ return conds
24
+ }
25
+ }
26
+ const defaultEditConfig = {
27
+ component: 'el-time-picker',
28
+ val: null,
29
+ props: {
30
+ clearable: true,
31
+ 'value-format': 'HH:mm:ss',
32
+ class: 'fc-table-inline-edit-component',
33
+ editable: true,
34
+ rules: []
35
+ }
36
+ }
37
+ export default {
38
+ query: (config, type) => {
39
+ let val = defaultQueryConfig.val;
40
+ const {props: {defaultVal, isRange, ...validProps} = {}} = config
41
+ if (type === 'quick') {
42
+ val = ternary(isUndefined(defaultVal), val, defaultVal);
43
+ }
44
+ config.val = val;
45
+ config.props = validProps;
46
+ return merge(config, defaultQueryConfig, true, false);
47
+ },
48
+ edit: (config, type) => {
49
+ const {label, props: {defaultVal, ...validProps} = {}} = config;
50
+ const {rules = []} = validProps;
51
+ // 如果含有值不为false的required属性, 则将其转换为rules规则添加到props中
52
+ if (validProps.hasOwnProperty('required') && validProps.required !== false) {
53
+ rules.push({required: true, message: `${label}不能为空`})
54
+ }
55
+ config.val = ternary(isUndefined(defaultVal), defaultEditConfig.val, defaultVal);
56
+ config.props = {
57
+ ...validProps,
58
+ rules: rules
59
+ }
60
+ return merge(config, defaultEditConfig, true, false)
61
+ }
62
+ }
@@ -0,0 +1,7 @@
1
+ import FastTableColumnTimePicker from './src/table-column-time-picker.vue'
2
+
3
+ FastTableColumnTimePicker.install = (app) => {
4
+ app.component(FastTableColumnTimePicker.name, FastTableColumnTimePicker)
5
+ }
6
+
7
+ export default FastTableColumnTimePicker
@@ -0,0 +1,53 @@
1
+ <template>
2
+ <el-table-column class-name="fc-table-column"
3
+ :prop="prop"
4
+ :label="label"
5
+ :show-overflow-tooltip="showOverflowTooltip"
6
+ v-bind="$attrs"
7
+ v-if="!hidden">
8
+ <template #header="{column, $index}">
9
+ <fast-table-head-cell :column="columnProp" @click="headCellClick(column)">
10
+ <slot name="header" v-bind:column="column" v-bind:$index="$index">
11
+ <span>{{ label }}</span>
12
+ </slot>
13
+ </fast-table-head-cell>
14
+ </template>
15
+
16
+ <template #default="{row, column, $index}">
17
+ <slot v-bind:row="row" v-bind:column="column" v-bind:$index="$index">
18
+ <div v-if="!canEdit(row, column, $index)">
19
+ <slot name="normal" v-bind:row="row" v-bind:column="column" v-bind:$index="$index">
20
+ <fast-cell-content :value="showLabel(row)" :fat-row="row" :show-length="showLength" :linkTo="link"/>
21
+ </slot>
22
+ </div>
23
+ <slot name="edit" v-bind:row="row" v-bind:column="column" v-bind:$index="$index" v-else>
24
+ <el-time-picker v-model="row['editRow'][prop]"
25
+ v-bind="row['config'][prop]['props']"
26
+ :ref="prop + $index"
27
+ @change="(val) => handleChange(val, {row, column, $index})"
28
+ @blur="(event) => handleBlur(event, {row, column, $index})"
29
+ @focus="(event) => handleFocus(event, {row, column, $index})"></el-time-picker>
30
+ </slot>
31
+ </slot>
32
+ </template>
33
+ </el-table-column>
34
+ </template>
35
+
36
+ <script>
37
+ import tableColumn from "../../../mixins/table-column"
38
+
39
+ export default {
40
+ name: "FastTableColumnTimePicker",
41
+ mixins: [tableColumn],
42
+ props: {
43
+ minWidth: {
44
+ type: String,
45
+ default: () => '120px'
46
+ }
47
+ }
48
+ }
49
+ </script>
50
+
51
+ <style scoped>
52
+
53
+ </style>
@@ -0,0 +1,7 @@
1
+ import FastUpload from "./src/fast-upload.vue";
2
+
3
+ FastUpload.install= (app) => {
4
+ app.component(FastUpload.name, FastUpload)
5
+ }
6
+
7
+ export default FastUpload;
@@ -0,0 +1,272 @@
1
+ <template>
2
+ <el-upload :file-list="files"
3
+ ref="uploadRef"
4
+ v-bind="$attrs"
5
+ :action="actionValue"
6
+ :limit="limit"
7
+ :list-type="listType"
8
+ :show-file-list="true"
9
+ :on-preview="onPreview"
10
+ :on-remove="onRemove"
11
+ :on-success="handleSuccess"
12
+ :on-progress="onProgress"
13
+ :on-change="onChange"
14
+ :on-exceed="onExceed"
15
+ :before-remove="beforeRemove"
16
+ class="fc-fast-upload"
17
+ :class="{'fc-fast-upload__hidden': hideUploadButton, 'fc-fast-upload__disable': disabled}">
18
+ <template #default>
19
+ <el-icon>
20
+ <Plus/>
21
+ </el-icon>
22
+ </template>
23
+ <template #file="{file}">
24
+ <!-- 图片 -->
25
+ <template v-if="isPicture">
26
+ <img class="el-upload-list__item-thumbnail" :src="file.url" alt=""/>
27
+ <span class="el-upload-list__item-actions">
28
+ <span class="el-upload-list__item-preview" @click="preview(file)">
29
+ <el-icon>
30
+ <ZoomIn/>
31
+ </el-icon>
32
+ </span>
33
+ <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file)">
34
+ <el-icon><Delete/></el-icon>
35
+ </span>
36
+ </span>
37
+ </template>
38
+ <!-- 普通文件 -->
39
+ <div style="word-break: break-all; display: inline-flex;" v-else>
40
+ <el-icon v-if="disabled">
41
+ <Paperclip/>
42
+ </el-icon>
43
+ <el-icon @click="handleRemove(file)" style="cursor: pointer; padding: 2px; color: #f56c6c;" v-else>
44
+ <Delete/>
45
+ </el-icon>
46
+ <el-link :href="file.url" style="margin-left: 3px;">{{ file.name }}</el-link>
47
+ </div>
48
+ </template>
49
+ </el-upload>
50
+ </template>
51
+
52
+ <script>
53
+ import {h, defineComponent} from "vue"
54
+ import {
55
+ isArray,
56
+ isEmpty,
57
+ isFunction,
58
+ getNameFromUrl,
59
+ getFirstUrlFromFileItems,
60
+ defaultIfBlank,
61
+ cutPrefix,
62
+ isString,
63
+ isUrl
64
+ } from "../../../util/util"
65
+ import UploadMixin from "../../../mixins/upload.js"
66
+ import FastTableOption from "../../../model/fastTableOption.js"
67
+ import {openDialog} from "../../../util/dialog"
68
+ import {Delete, Paperclip, Plus, ZoomIn} from "@element-plus/icons-vue"
69
+
70
+ export default {
71
+ name: "fast-upload",
72
+ components: {Paperclip, Delete, ZoomIn, Plus},
73
+ mixins: [UploadMixin],
74
+ emits: ['update:modelValue'],
75
+ props: {
76
+ /**
77
+ * 是否支持多文件
78
+ */
79
+ multiple: {
80
+ type: Boolean,
81
+ default: () => false
82
+ },
83
+ // multiple为true则应当是单个url地址, 否则为url数组
84
+ modelValue: {
85
+ type: [String, Array],
86
+ default: () => null
87
+ },
88
+ action: {
89
+ type: String,
90
+ default: () => '/'
91
+ },
92
+ listType: {
93
+ type: String,
94
+ default: () => 'text'
95
+ },
96
+ limit: {
97
+ type: Number,
98
+ default: () => 1
99
+ },
100
+ disabled: {
101
+ type: Boolean,
102
+ default: () => false
103
+ }
104
+ },
105
+ computed: {
106
+ files() {
107
+ const value = this.modelValue
108
+ let files = []
109
+ if (this.multiple) {
110
+ if (isArray(value)) {
111
+ files = value
112
+ } else {
113
+ if (!isEmpty(value)) {
114
+ files.push({name: getNameFromUrl(value), url: value})
115
+ }
116
+ }
117
+ } else {
118
+ const url = isArray(value) ? getFirstUrlFromFileItems(value) : value;
119
+ if (!isEmpty(url)) {
120
+ files.push({name: getNameFromUrl(value), url: url})
121
+ }
122
+ }
123
+ // 处理代理前缀
124
+ return files.map(f => {
125
+ return {name: f.name, url: this.disposeUrl(f.url, true)}
126
+ })
127
+ },
128
+ actionValue() {
129
+ return this.apiPrefix + this.action;
130
+ },
131
+ isPicture() {
132
+ return this.listType === 'picture-card';
133
+ },
134
+ hideUploadButton() {
135
+ return this.disabled || (!isEmpty(this.files) && this.files.length >= this.limit);
136
+ }
137
+ },
138
+ data() {
139
+ return {
140
+ apiPrefix: defaultIfBlank(FastTableOption.$http.defaults.baseURL, '')
141
+ }
142
+ },
143
+ methods: {
144
+ /**
145
+ * emit值
146
+ * @param fileList
147
+ */
148
+ emitValue(fileList) {
149
+ if (isEmpty(fileList)) {
150
+ this.$emit('update:modelValue', null)
151
+ return
152
+ }
153
+ const {multiple} = this
154
+ let val
155
+ if (multiple) {
156
+ val = fileList.map(f => {
157
+ return {
158
+ name: f.name,
159
+ url: this.disposeUrl(f.url, false)
160
+ }
161
+ })
162
+ } else {
163
+ val = this.disposeUrl(fileList[0].url, false)
164
+ }
165
+ this.$emit('update:modelValue', val)
166
+ },
167
+ handleSuccess(response, file, fileList) {
168
+ const responseHandler = isFunction(this.responseHandler) ? this.responseHandler : (response) => response
169
+ const url = responseHandler(response, file, fileList);
170
+ this.files.push({
171
+ name: file.name,
172
+ url: url
173
+ })
174
+ this.emitValue(this.files)
175
+ this.onSuccess(response, file, fileList)
176
+ },
177
+ /**
178
+ * 自定义移除,实现外部透传的beforeRemove和onRemove
179
+ * @param file
180
+ */
181
+ handleRemove(file) {
182
+ console.log(this.beforeRemove)
183
+ const beforeRemove = isFunction(this.beforeRemove) ? this.beforeRemove : () => Promise.resolve(true)
184
+ beforeRemove(file, this.files).then(flag => {
185
+ if (flag) {
186
+ const index = this.files.findIndex(f => f.url === file.url);
187
+ this.files.splice(index, 1);
188
+ this.emitValue(this.files)
189
+ this.onRemove(file, this.files)
190
+ }
191
+ })
192
+ },
193
+ /**
194
+ * 预览图片
195
+ * @param file
196
+ * @return {VNode}
197
+ */
198
+ preview(file) {
199
+ const imgPreviewComponent = defineComponent({
200
+ render() {
201
+ return h('img', {
202
+ src: file.url,
203
+ width: '100%'
204
+ })
205
+ }
206
+ })
207
+ openDialog({
208
+ component: imgPreviewComponent
209
+ })
210
+ },
211
+ /**
212
+ * 处理url
213
+ * @param url 待处理的url
214
+ * @param append 添加前缀? 若true则追加this.apiPrefix前缀; false则移除前面可能得前缀
215
+ * @return {*}
216
+ */
217
+ disposeUrl(url, append) {
218
+ if (!isString(url) || isEmpty(url) || isUrl(url)) {
219
+ return url
220
+ }
221
+ return append ? this.apiPrefix + url : cutPrefix(url, this.apiPrefix)
222
+ }
223
+ }
224
+ }
225
+ </script>
226
+
227
+ <style scoped lang="scss">
228
+ .fc-fast-upload {
229
+ :deep(.el-upload-list--picture-card) {
230
+ display: grid;
231
+ grid-template-columns: repeat(auto-fill, 48px);
232
+ grid-gap: 2px;
233
+ }
234
+
235
+ :deep(.el-upload-list--text .el-upload-list__item) {
236
+ margin: 3px 0 !important;
237
+ }
238
+
239
+ .el-upload-list__item-actions {
240
+ display: flex;
241
+ align-items: center;
242
+ justify-content: space-around;
243
+
244
+ & > * {
245
+ margin: 0 !important;
246
+
247
+ & i {
248
+ font-size: 14px;
249
+ }
250
+ }
251
+
252
+ &::after {
253
+ display: none;
254
+ }
255
+ }
256
+
257
+ img {
258
+ height: 100%;
259
+ object-fit: cover;
260
+ }
261
+ }
262
+
263
+ .fc-fast-upload.fc-fast-upload__hidden {
264
+ :deep(.el-upload) {
265
+ display: none;
266
+ }
267
+ }
268
+
269
+ .fc-fast-upload.fc-fast-upload__disable {
270
+ border: none !important;
271
+ }
272
+ </style>
@@ -0,0 +1,42 @@
1
+ // 引入你的组件实现(dts插件会为它们生成类型)
2
+ // 注意:这里要根据实际生成后的类型路径来写,或者直接引用源码
3
+ import FastTable from './components/table'
4
+ import FastSelect from './components/select'
5
+ import FastCheckboxGroup from './components/checkbox-group'
6
+ import FastObjectPicker from './components/object-picker'
7
+ import FastTableColumn from './components/table-column'
8
+ import FastTableColumnDatePicker from './components/table-column-date-picker'
9
+ import FastTableColumnFile from './components/table-column-file'
10
+ import FastTableColumnImg from './components/table-column-img'
11
+ import FastTableColumnInput from './components/table-column-input'
12
+ import FastTableColumnNumber from './components/table-column-number'
13
+ import FastTableColumnObject from './components/table-column-object'
14
+ import FastTableColumnSelect from './components/table-column-select'
15
+ import FastTableColumnSwitch from './components/table-column-switch'
16
+ import FastTableColumnTextarea from './components/table-column-textarea'
17
+ import FastTableColumnTimePicker from './components/table-column-time-picker'
18
+ import FastUpload from './components/upload'
19
+ // ... 引入其他所有组件
20
+
21
+ declare module '@vue/runtime-core' {
22
+ export interface GlobalComponents {
23
+ FastTable: typeof FastTable
24
+ FastSelect: typeof FastSelect
25
+ FastCheckboxGroup: typeof FastCheckboxGroup
26
+ FastObjectPicker: typeof FastObjectPicker
27
+ FastTableColumn: typeof FastTableColumn
28
+ FastTableColumnDatePicker: typeof FastTableColumnDatePicker
29
+ FastTableColumnFile: typeof FastTableColumnFile
30
+ FastTableColumnImg: typeof FastTableColumnImg
31
+ FastTableColumnInput: typeof FastTableColumnInput
32
+ FastTableColumnNumber: typeof FastTableColumnNumber
33
+ FastTableColumnObject: typeof FastTableColumnObject
34
+ FastTableColumnSelect: typeof FastTableColumnSelect
35
+ FastTableColumnSwitch: typeof FastTableColumnSwitch
36
+ FastTableColumnTextarea: typeof FastTableColumnTextarea
37
+ FastTableColumnTimePicker: typeof FastTableColumnTimePicker
38
+ FastUpload: typeof FastUpload
39
+ }
40
+ }
41
+
42
+ export {}