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,139 @@
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 DEFAULT_DATE_FORMAT = 'YYYY-MM-DD'
6
+ const DEFAULT_DATETIME_FORMAT = 'YYYY-MM-DD HH:mm:ss'
7
+ const defaultQueryConfig = {
8
+ component: 'el-date-picker',
9
+ opt: Opt.BTW,
10
+ val: [], // 默认值
11
+ props: {
12
+ type: `daterange`,
13
+ clearable: true,
14
+ valueFormat: DEFAULT_DATE_FORMAT,
15
+ // (易用性提升)
16
+ shortcuts: [{
17
+ text: '最近1h',
18
+ value: () => {
19
+ const end = new Date()
20
+ const start = new Date(end)
21
+ start.setTime(start.getTime() - 3600 * 1000)
22
+ return [start, end]
23
+ }
24
+ }, {
25
+ text: '最近1天',
26
+ value: () => {
27
+ const end = new Date()
28
+ const start = new Date(end)
29
+ start.setTime(start.getTime() - 3600 * 1000 * 24)
30
+ return [start, end]
31
+ }
32
+ }, {
33
+ text: '最近1周',
34
+ value: () => {
35
+ const end = new Date()
36
+ const start = new Date()
37
+ start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
38
+ return [start, end]
39
+ }
40
+ }, {
41
+ text: '最近1月',
42
+ value: () => {
43
+ const end = new Date()
44
+ const start = new Date()
45
+ start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
46
+ return [start, end]
47
+ }
48
+ }, {
49
+ text: '最近3月',
50
+ value: () => {
51
+ const end = new Date()
52
+ const start = new Date()
53
+ start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
54
+ return [start, end]
55
+ }
56
+ }, {
57
+ text: '最近1年',
58
+ value: () => {
59
+ const end = new Date()
60
+ const start = new Date(end)
61
+ start.setFullYear(end.getFullYear() - 1)
62
+ return [start, end]
63
+ }
64
+ }]
65
+ },
66
+ condMapFn: (cond) => {
67
+ const conds = []
68
+ const [start, end] = cond.val
69
+ if (start) {
70
+ conds.push(new Cond(cond.col, Opt.GE, start))
71
+ }
72
+ if (end) {
73
+ conds.push(new Cond(cond.col, Opt.LE, end))
74
+ }
75
+ return conds
76
+ }
77
+
78
+ }
79
+ const defaultEditConfig = {
80
+ component: 'el-date-picker',
81
+ opt: Opt.BTW,
82
+ val: null, // 默认值
83
+ props: {
84
+ type: "date",
85
+ clearable: true,
86
+ valueFormat: DEFAULT_DATE_FORMAT,
87
+ class: 'fc-table-inline-edit-component',
88
+ editable: true,
89
+ rules: []
90
+ }
91
+ }
92
+
93
+ export default {
94
+ query: (config, type) => {
95
+ let val = defaultQueryConfig.val;
96
+ const {props: {defaultVal, ...validProps} = {}} = config
97
+ const {type: dateType = 'date'} = validProps;
98
+ if (type === 'quick') {
99
+ val = ternary(isUndefined(defaultVal), val, defaultVal);
100
+ }
101
+ if (type === 'dynamic' || type === 'stored') {
102
+ validProps.teleported = false // 防止动筛二选时popover关闭
103
+ }
104
+ const {valueFormat} = validProps;
105
+ if (config.props.type === 'datetime') {
106
+ if (isUndefined(valueFormat)) {
107
+ validProps.valueFormat = DEFAULT_DATETIME_FORMAT;
108
+ }
109
+ // 限定时分秒的默认区间值(易用性提升)
110
+ validProps.defaultTime = [
111
+ new Date(0, 0, 0, 0, 0 ,0, 0),
112
+ new Date(0, 0, 0, 23, 59, 59, 999)]
113
+ }
114
+ config.val = val;
115
+ config.props = {
116
+ ...validProps,
117
+ type: `${dateType}range`
118
+ }
119
+ return merge(config, defaultQueryConfig, true, false)
120
+ },
121
+ edit: (config, type) => {
122
+ const {label, props: {defaultVal, ...validProps} = {}} = config;
123
+ const {rules = []} = validProps;
124
+ // 如果含有值不为false的required属性, 则将其转换为rules规则添加到props中
125
+ if (validProps.hasOwnProperty('required') && validProps.required !== false) {
126
+ rules.push({required: true, message: `${label}不能为空`})
127
+ }
128
+ config.val = ternary(isUndefined(defaultVal), defaultEditConfig.val, defaultVal);
129
+ const {valueFormat} = validProps;
130
+ if (config.props.type === 'datetime' && isUndefined(valueFormat)) {
131
+ validProps.valueFormat = DEFAULT_DATETIME_FORMAT;
132
+ }
133
+ config.props = {
134
+ ...validProps,
135
+ rules: rules
136
+ }
137
+ return merge(config, defaultEditConfig, true, false)
138
+ }
139
+ }
@@ -0,0 +1,7 @@
1
+ import FastTableColumnDatePicker from './src/table-column-date-picker.vue'
2
+
3
+ FastTableColumnDatePicker.install = (app) => {
4
+ app.component(FastTableColumnDatePicker.name, FastTableColumnDatePicker)
5
+ }
6
+
7
+ export default FastTableColumnDatePicker
@@ -0,0 +1,54 @@
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-date-picker 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
+ </slot>
32
+ </slot>
33
+ </template>
34
+ </el-table-column>
35
+ </template>
36
+
37
+ <script>
38
+ import tableColumn from "../../../mixins/table-column"
39
+
40
+ export default {
41
+ name: "FastTableColumnDatePicker",
42
+ mixins: [tableColumn],
43
+ props: {
44
+ minWidth: {
45
+ type: String,
46
+ default: () => '150px'
47
+ }
48
+ }
49
+ }
50
+ </script>
51
+
52
+ <style scoped>
53
+
54
+ </style>
@@ -0,0 +1,83 @@
1
+ import {
2
+ addStartWith,
3
+ easyOptParse,
4
+ isUndefined,
5
+ merge,
6
+ ternary
7
+ } from "../../util/util";
8
+ import Opt from "../../model/opt.js"
9
+
10
+ const defaultQueryConfig = {
11
+ component: 'el-input',
12
+ opt: Opt.LIKE,
13
+ val: null, // 默认值
14
+ props: {
15
+ clearable: true,
16
+ placeholder: '请输入文件名...'
17
+ },
18
+ condMapFn: (cond) => {
19
+ const operators = {
20
+ '^!=': {
21
+ opt: Opt.NE,
22
+ valExtract: (cond) => cond.val.substring(2)
23
+ },
24
+ '^=': {
25
+ opt: Opt.EQ,
26
+ valExtract: (cond) => cond.val.substring(1)
27
+ },
28
+ '^~': {
29
+ opt: Opt.NLIKE,
30
+ valExtract: (cond) => cond.val.substring(1)
31
+ },
32
+ '^\\*': {
33
+ opt: Opt.LLIKE,
34
+ valExtract: (cond) => cond.val.substring(1)
35
+ },
36
+ '\\*$': {
37
+ opt: Opt.RLIKE,
38
+ valExtract: (cond) => cond.val.substring(0, cond.val.length - 1)
39
+ }
40
+ }
41
+ easyOptParse(cond, operators)
42
+ return [cond]
43
+ }
44
+ }
45
+ const defaultEditConfig = {
46
+ component: 'fast-upload',
47
+ val: null,
48
+ props: {
49
+ action: '/',
50
+ 'list-type': 'text',
51
+ class: 'fc-table-inline-edit-component',
52
+ multiple: false, // 默认单选文件
53
+ editable: true
54
+ }
55
+ }
56
+ export default {
57
+ query: (config, type) => {
58
+ let val = defaultQueryConfig.val;
59
+ const {props: {defaultVal, ...validProps} = {}} = config
60
+ if (type === 'quick') {
61
+ val = ternary(isUndefined(defaultVal), val, defaultVal);
62
+ }
63
+ config.val = val;
64
+ config.props = validProps;
65
+ return merge(config, defaultQueryConfig, true, false)
66
+ },
67
+ edit: (config, type, tableOption) => {
68
+ const {label, props = {}} = config;
69
+ const {defaultVal, rules = [], ...validProps} = props;
70
+ if (validProps.hasOwnProperty('required') && validProps.required !== false) {
71
+ rules.push({required: true, message: `${label}不能为空`})
72
+ }
73
+ config.val = ternary(isUndefined(defaultVal), defaultEditConfig.val, defaultVal)
74
+ config.props = {
75
+ ...validProps,
76
+ rules: rules
77
+ }
78
+ const finalConfig = merge(config, defaultEditConfig, true, false);
79
+ finalConfig.props.action = addStartWith(tableOption.uploadUrl, '/');
80
+ finalConfig.props.listType = 'text'; // 固定避免被自定义覆盖
81
+ return finalConfig;
82
+ }
83
+ }
@@ -0,0 +1,7 @@
1
+ import FastTableColumnFile from './src/table-column-file.vue'
2
+
3
+ FastTableColumnFile.install = (app) => {
4
+ app.component(FastTableColumnFile.name, FastTableColumnFile)
5
+ }
6
+
7
+ export default FastTableColumnFile
@@ -0,0 +1,79 @@
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
+ <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-upload v-model="row[row.status === 'normal' ? 'row' : 'editRow'][prop]"
22
+ v-bind="row['config'][prop]['props']"
23
+ list-type="text"
24
+ :disabled="true"
25
+ class="fc-fast-upload-file"></fast-upload>
26
+ </slot>
27
+ </template>
28
+ <slot name="edit" v-bind:row="row" v-bind:column="column" v-bind:$index="$index" v-else>
29
+ <fast-upload v-model="row['editRow'][prop]"
30
+ :data="{row: JSON.stringify(row['editRow']), col: prop}"
31
+ v-bind="row['config'][prop]['props']"
32
+ :ref="prop + $index"
33
+ :on-preview="(file) => onPreview(file, {row, column, $index})"
34
+ :before-remove="(file, files) => handleBeforeRemove(file, files, {row, column, $index})"
35
+ :on-remove="(file, files) => isFunction(onRemove) ? onRemove(file, files, {row, column, $index}) : null"
36
+ :response-handler="(response, file, files) => isFunction(responseHandler) ? responseHandler(response, file, files, {row, column, $index}) : response"
37
+ :on-success="(response, file, files) => isFunction(onSuccess) ? onSuccess(response, file, files, {row, column, $index}) : null"
38
+ :on-progress="(event ,file, files) => isFunction(onProgress) ? onProgress(event, file, files, {row, column, $index}) : null"
39
+ :on-change="(file, files) => isFunction(onChange) ? onChange(file, files, {row, column, $index}) : null"
40
+ :on-exceed="(file, files) => isFunction(onExceed) ? onExceed(file, files, {row, column, $index}) : null"
41
+ class="fc-fast-upload-file"/>
42
+ </slot>
43
+ </slot>
44
+ </template>
45
+ </el-table-column>
46
+ </template>
47
+
48
+ <script>
49
+ import FastUpload from "../../upload/src/fast-upload.vue"
50
+ import tableColumn from "../../../mixins/table-column"
51
+ import UploadMixin from "../../../mixins/upload.js"
52
+ import {isFunction} from "../../../util/util.js"
53
+
54
+ export default {
55
+ name: "FastTableColumnFile",
56
+ components: {FastUpload},
57
+ mixins: [tableColumn, UploadMixin],
58
+ props: {
59
+ minWidth: {
60
+ type: String,
61
+ default: () => '300px'
62
+ },
63
+ },
64
+ methods: {
65
+ isFunction,
66
+ handleBeforeRemove(file, files, scope) {
67
+ return isFunction(this.beforeRemove) ? this.beforeRemove(file, files, scope) : Promise.resolve(true) // Promise在模版中不识别?
68
+ }
69
+ }
70
+ }
71
+ </script>
72
+
73
+ <style scoped lang="scss">
74
+ .fc-fast-upload-file {
75
+ display: flex;
76
+ flex-direction: column;
77
+ justify-content: center;
78
+ }
79
+ </style>
@@ -0,0 +1,83 @@
1
+ import {
2
+ addStartWith,
3
+ easyOptParse,
4
+ isUndefined,
5
+ merge,
6
+ ternary
7
+ } from "../../util/util";
8
+ import Opt from "../../model/opt.js"
9
+
10
+ const defaultQueryConfig = {
11
+ component: 'el-input',
12
+ opt: Opt.LIKE,
13
+ val: null, // 默认值
14
+ props: {
15
+ clearable: true
16
+ },
17
+ condMapFn: (cond) => {
18
+ const operators = {
19
+ '^!=': {
20
+ opt: Opt.NE,
21
+ valExtract: (cond) => cond.val.substring(2)
22
+ },
23
+ '^=': {
24
+ opt: Opt.EQ,
25
+ valExtract: (cond) => cond.val.substring(1)
26
+ },
27
+ '^~': {
28
+ opt: Opt.NLIKE,
29
+ valExtract: (cond) => cond.val.substring(1)
30
+ },
31
+ '^\\*': {
32
+ opt: Opt.LLIKE,
33
+ valExtract: (cond) => cond.val.substring(1)
34
+ },
35
+ '\\*$': {
36
+ opt: Opt.RLIKE,
37
+ valExtract: (cond) => cond.val.substring(0, cond.val.length - 1)
38
+ }
39
+ }
40
+ easyOptParse(cond, operators)
41
+ return [cond]
42
+ }
43
+ }
44
+ const defaultEditConfig = {
45
+ component: 'fast-upload',
46
+ val: null,
47
+ props: {
48
+ action: '/',
49
+ listType: 'picture-card',
50
+ accept: 'image/*',
51
+ class: 'fc-table-inline-edit-component',
52
+ multiple: false, // 默认单选文件
53
+ editable: true
54
+ }
55
+ }
56
+ export default {
57
+ query: (config, type) => {
58
+ let val = defaultQueryConfig.val;
59
+ const {props: {defaultVal, ...validProps} = {}} = config
60
+ if (type === 'quick') {
61
+ val = ternary(isUndefined(defaultVal), val, defaultVal);
62
+ }
63
+ config.val = val;
64
+ config.props = validProps;
65
+ return merge(config, defaultQueryConfig, true, false)
66
+ },
67
+ edit: (config, type, tableOption) => {
68
+ const {label, props = {}} = config;
69
+ const {defaultVal, rules = [], ...validProps} = props;
70
+ if (validProps.hasOwnProperty('required') && validProps.required !== false) {
71
+ rules.push({required: true, message: `${label}不能为空`})
72
+ }
73
+ config.val = ternary(isUndefined(defaultVal), defaultEditConfig.val, defaultVal)
74
+ config.props = {
75
+ ...validProps,
76
+ rules: rules
77
+ }
78
+ const finalConfig = merge(config, defaultEditConfig, true, false);
79
+ finalConfig.props.action = addStartWith(tableOption.uploadUrl, '/');
80
+ finalConfig.props.listType = 'picture-card'; // 固定避免被自定义覆盖
81
+ return finalConfig;
82
+ }
83
+ }
@@ -0,0 +1,7 @@
1
+ import FastTableColumnImg from './src/table-column-img.vue'
2
+
3
+ FastTableColumnImg.install = (app) => {
4
+ app.component(FastTableColumnImg.name, FastTableColumnImg)
5
+ }
6
+
7
+ export default FastTableColumnImg
@@ -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
+ <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-upload v-model="row[row.status === 'normal' ? 'row' : 'editRow'][prop]"
22
+ v-bind="row['config'][prop]['props']"
23
+ list-type="picture-card"
24
+ :disabled="true"></fast-upload>
25
+ </slot>
26
+ </template>
27
+ <slot name="edit" v-bind:row="row" v-bind:column="column" v-bind:$index="$index" v-else>
28
+ <fast-upload v-model="row['editRow'][prop]"
29
+ v-bind="row['config'][prop]['props']"
30
+ :data="{row: JSON.stringify(row['editRow']), col: prop}"
31
+ :ref="prop + $index"
32
+ :on-preview="(file) => onPreview(file, {row, column, $index})"
33
+ :before-remove="(file, files) => handleBeforeRemove(file, files, {row, column, $index})"
34
+ :on-remove="(file, files) => isFunction(onRemove) ? onRemove(file, files, {row, column, $index}) : null"
35
+ :response-handler="(response, file, files) => isFunction(responseHandler) ? responseHandler(response, file, files, {row, column, $index}) : response"
36
+ :on-success="(response, file, files) => isFunction(onSuccess) ? onSuccess(response, file, files, {row, column, $index}) : null"
37
+ :on-progress="(event ,file, files) => isFunction(onProgress) ? onProgress(event, file, files, {row, column, $index}) : null"
38
+ :on-change="(file, files) => isFunction(onChange) ? onChange(file, files, {row, column, $index}) : null"
39
+ :on-exceed="(file, files) => isFunction(onExceed) ? onExceed(file, files, {row, column, $index}) : null"
40
+ />
41
+ </slot>
42
+ </slot>
43
+ </template>
44
+ </el-table-column>
45
+ </template>
46
+
47
+ <script>
48
+ import FastUpload from "../../upload/src/fast-upload.vue";
49
+ import tableColumn from "../../../mixins/table-column";
50
+ import UploadMixin from "../../../mixins/upload.js";
51
+ import {isFunction} from "../../../util/util.js";
52
+
53
+ export default {
54
+ name: "FastTableColumnImg",
55
+ components: {FastUpload},
56
+ mixins: [tableColumn, UploadMixin],
57
+ props: {
58
+ minWidth: {
59
+ type: String,
60
+ default: () => '100px'
61
+ },
62
+ },
63
+ methods: {
64
+ isFunction,
65
+ handleBeforeRemove(file, files, scope) {
66
+ return isFunction(this.beforeRemove) ? this.beforeRemove(file, files, scope) : Promise.resolve(true) // Promise在模版中不识别?
67
+ }
68
+ }
69
+ }
70
+ </script>
71
+
72
+ <style scoped lang="scss">
73
+ .img-list {
74
+ display: flex;
75
+ flex-wrap: wrap;
76
+ padding: 3px 0;
77
+ }
78
+
79
+ img {
80
+ object-fit: cover;
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
+
40
+ const defaultEditConfig = {
41
+ component: 'el-input',
42
+ val: null,
43
+ props: {
44
+ clearable: true,
45
+ class: 'fc-table-inline-edit-component',
46
+ editable: true,
47
+ rules: []
48
+ }
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 FastTableColumnInput from './src/table-column-input.vue'
2
+
3
+ FastTableColumnInput.install = (app) => {
4
+ app.component(FastTableColumnInput.name, FastTableColumnInput)
5
+ }
6
+
7
+ export default FastTableColumnInput