fast-crud-ui3 1.5.16 → 1.5.17

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 +9978 -5939
  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 +510 -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 +89 -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 +66 -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 +761 -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,172 @@
1
+ <template>
2
+ <div class="fc-dynamic-filter-list">
3
+ <el-popover v-for="(f, index) in filters" popper-style="max-width: none; width: auto;" :key="f.col + '.' + index">
4
+ <template v-slot:reference>
5
+ <div class="fc-dynamic-filter-btns">
6
+ <el-button link class="fc-dynamic-filter-open-btn" :class="{'strikethrough': f.disabled}">
7
+ {{ ellipsis(f.condMsg, 30) }}
8
+ </el-button>
9
+ <el-button link class="fc-dynamic-filter-del-btn" :icon="Close"
10
+ @click.stop="delConfig(index)"></el-button>
11
+ </div>
12
+ </template>
13
+ <component class="component" :is="f.component" v-model="f.val" v-bind="f.props" :teleported="false" @change="onChange(f)"
14
+ v-if="f.opt !== Opt.NULL && f.opt !== Opt.NNULL && f.opt !== Opt.EMPTY && f.opt !== Opt.NEMPTY"/>
15
+ <div class="fc-dynamic-filter-footer">
16
+ <el-button type="primary" size="small" :icon="Search" @click="confirm">查询</el-button>
17
+ <el-button :type="f.disabled ? 'primary' : 'info'" plain size="small" @click="toggleFilter(f)">
18
+ {{ f.disabled ? '启用' : '禁用' }}
19
+ </el-button>
20
+ </div>
21
+ </el-popover>
22
+ <template v-if="filters.length > 1">
23
+ <el-button class="fc-dynamic-filter-clear-btn" link style="padding: 0; color: #d37c84" @click="clearFilters">
24
+ 清空
25
+ </el-button>
26
+ <el-button class="fc-dynamic-filter-clear-btn" type="info" link style="padding: 0;" @click="toggleAllFilters">
27
+ {{ allDisabled ? '全启' : '全禁' }}
28
+ </el-button>
29
+ </template>
30
+ </div>
31
+ </template>
32
+
33
+ <script>
34
+ import Opt from "../../../model/opt.js";
35
+ import {ellipsis} from '../../../util/util'
36
+ import {Close, Search} from "@element-plus/icons-vue"
37
+
38
+ export default {
39
+ name: "dynamic-filter-list",
40
+ emits: ['search'],
41
+ props: {
42
+ filters: {
43
+ type: Array,
44
+ default: () => []
45
+ },
46
+ size: {
47
+ type: String,
48
+ default: () => 'small'
49
+ }
50
+ },
51
+ computed: {
52
+ Search() {
53
+ return Search
54
+ },
55
+ Close() {
56
+ return Close
57
+ },
58
+ allDisabled() {
59
+ return this.filters.every(f => f.disabled)
60
+ }
61
+ },
62
+ data() {
63
+ return {
64
+ Opt: Opt
65
+ }
66
+ },
67
+ watch: {
68
+ 'filters' : function (filters) {
69
+ this.$nextTick(() => {
70
+ filters.forEach(f => f.updateCondMsg())
71
+ })
72
+ }
73
+ },
74
+ methods: {
75
+ ellipsis,
76
+ delConfig(index) {
77
+ this.filters.splice(index, 1)
78
+ this.confirm()
79
+ },
80
+ confirm(/*filter*/) {
81
+ this.$emit('search')
82
+ },
83
+ toggleFilter(filter) {
84
+ filter.disabled = !filter.disabled
85
+ this.confirm()
86
+ },
87
+ clearFilters() {
88
+ this.filters.splice(0, this.filters.length);
89
+ this.confirm()
90
+ },
91
+ toggleAllFilters() {
92
+ const {allDisabled} = this
93
+ this.filters.forEach(f => f.disabled = !allDisabled)
94
+ this.confirm()
95
+ },
96
+ onChange(filter) {
97
+ filter.updateCondMsg()
98
+ }
99
+ }
100
+ }
101
+ </script>
102
+
103
+ <style scoped lang="scss">
104
+ .fc-dynamic-filter-list {
105
+ display: flex;
106
+ flex-wrap: wrap;
107
+ column-gap: 5px;
108
+
109
+ .fc-dynamic-filter-btns {
110
+ &:hover {
111
+ .fc-dynamic-filter-open-btn {
112
+ text-decoration: underline;
113
+ }
114
+
115
+ .fc-dynamic-filter-del-btn {
116
+ //display: inline-block;
117
+ visibility: visible;
118
+ }
119
+ }
120
+ }
121
+
122
+ .strikethrough {
123
+ text-decoration: line-through !important;
124
+ color: #acacac !important;
125
+ }
126
+
127
+ .fc-dynamic-filter-open-btn {
128
+ color: gray;
129
+ padding: 3px 5px;
130
+ border: 1px solid #cacaca;
131
+ border-radius: 3px;
132
+ font-size: 13px !important;
133
+ }
134
+
135
+ .fc-dynamic-filter-del-btn {
136
+ visibility: hidden;
137
+ margin-left: 5px;
138
+ padding: 5px 0;
139
+ color: #8d4343;
140
+ font-size: 13px !important;
141
+ }
142
+
143
+ .fc-dynamic-filter-clear-btn {
144
+ font-size: 13px !important;
145
+ margin-left: 3px;
146
+ }
147
+ }
148
+
149
+ // 针对distinct后的checkbox调整样式
150
+ .component.fc-fast-checkbox-group {
151
+ margin: 10px 0;
152
+ max-width: 420px;
153
+ max-height: 300px;
154
+ overflow: auto;
155
+
156
+ :deep(.fc-checkbox-group) {
157
+ display: block;
158
+ }
159
+
160
+ :deep(.fc-checkbox-group .el-checkbox) {
161
+ display: block;
162
+ }
163
+
164
+ }
165
+
166
+ .fc-dynamic-filter-footer {
167
+ display: flex;
168
+ justify-content: center;
169
+ margin-top: 10px;
170
+ }
171
+
172
+ </style>
@@ -0,0 +1,129 @@
1
+ <template>
2
+ <div class="fc-easy-filter">
3
+ <template v-if="activeFilter">
4
+ <fast-select class="fc-easy-filter-column" :options="filters" v-model="activeFilterCol" label-key="label"
5
+ val-key="col"
6
+ :size="size"
7
+ :filterable="true"
8
+ @change="changeField"/>
9
+ <component ref="easyFilterComp" class="fc-easy-filter-value" :is="activeFilter.component"
10
+ v-model="activeFilter.val"
11
+ v-bind="activeFilter.props"
12
+ :size="size"
13
+ @clear="handleClear"
14
+ @keydown.enter="handleEnter"/>
15
+ </template>
16
+ </div>
17
+ </template>
18
+
19
+ <script>
20
+ import {nextTick} from "vue";
21
+ import FastSelect from "../../select/src/fast-select.vue";
22
+ import {RefreshLeft, Search} from "@element-plus/icons-vue";
23
+ import {isEmpty, isFunction, isUndefined} from "../../../util/util.js";
24
+
25
+ export default {
26
+ name: "easy-filter",
27
+ components: {FastSelect},
28
+ emits: ['search'],
29
+ props: {
30
+ filters: {
31
+ type: Array,
32
+ default: () => []
33
+ },
34
+ size: {
35
+ type: String,
36
+ default: () => 'small'
37
+ }
38
+ },
39
+ computed: {
40
+ RefreshLeft() {
41
+ return RefreshLeft
42
+ },
43
+ Search() {
44
+ return Search
45
+ },
46
+ activeFilter() {
47
+ if (this.filters.length === 0 || isEmpty(this.activeFilterCol)) {
48
+ return null
49
+ }
50
+ const activeFilter = this.filters.find(filter => filter.col === this.activeFilterCol)
51
+ activeFilter.disabled = false // 启用此列
52
+ return activeFilter
53
+ }
54
+ },
55
+ data() {
56
+ return {
57
+ activeFilterCol: null
58
+ }
59
+ },
60
+ created() {
61
+ this.initActiveFilterCol()
62
+ },
63
+ mounted() {
64
+ this.$nextTick(() => {
65
+ if (this.$refs.easyFilterComp && isFunction(this.$refs.easyFilterComp.focus)) {
66
+ setTimeout(() => {
67
+ this.$refs.easyFilterComp.focus()
68
+ }, 50) // 如果当前FastTable在ElDialog中,会因为visible之后的动画二导致渲染会稍晚一点, 只nextTick不够,这里稍等会会
69
+ }
70
+ })
71
+ },
72
+ watch: {
73
+ 'filters.length': function () {
74
+ this.initActiveFilterCol()
75
+ }
76
+ },
77
+ methods: {
78
+ initActiveFilterCol() {
79
+ if (!isEmpty(this.filters)) {
80
+ const activeFilter = this.filters.find(f => f.disabled === false)
81
+ this.activeFilterCol = isUndefined(activeFilter) ? this.filters[0].col : activeFilter.col
82
+ }
83
+ },
84
+ changeField() {
85
+ this.filters.map(filter => {
86
+ filter.disabled = (filter.col !== this.activeFilterCol) // 保证只有activeFilter生效, 这样就不用清理切换之前的控件值了,使用体验更好
87
+ })
88
+ },
89
+ handleClear() {
90
+ nextTick(() => {
91
+ this.$emit('search')
92
+ })
93
+ },
94
+ handleEnter() {
95
+ nextTick(() => {
96
+ this.$emit('search')
97
+ })
98
+ }
99
+ }
100
+ }
101
+ </script>
102
+
103
+ <style scoped lang="scss">
104
+ .fc-easy-filter {
105
+ display: flex;
106
+
107
+ .fc-easy-filter-column {
108
+ width: 100px;
109
+
110
+ :deep(.el-select__wrapper),
111
+ :deep(.el-input__wrapper) {
112
+ box-shadow: inset 0 1px 0 0 #DCDFE6, inset 0 -1px 0 0 #DCDFE6, inset 1px 0 0 0 #DCDFE6; // 阴影模拟边框, 无"右边框"
113
+ border-top-right-radius: 0;
114
+ border-bottom-right-radius: 0;
115
+ }
116
+ }
117
+
118
+ .fc-easy-filter-value {
119
+ width: 280px;
120
+ }
121
+
122
+ .fc-easy-filter-value :deep(.el-input__wrapper),
123
+ :deep(.fc-easy-filter-value.el-input__wrapper),
124
+ :deep(.fc-easy-filter-value .el-select__wrapper) {
125
+ border-top-left-radius: 0 !important;
126
+ border-bottom-left-radius: 0 !important;
127
+ }
128
+ }
129
+ </style>
@@ -0,0 +1,55 @@
1
+ <template>
2
+ <div class="export-confirm">
3
+ <el-table :data="columns">
4
+ <!-- <el-table-column prop="col" label="字段"/>-->
5
+ <el-table-column prop="label" label="标题行">
6
+ <template #default="{row}">
7
+ <el-input v-model="row.label" size="default" placeholder="请输入名称"></el-input>
8
+ </template>
9
+ </el-table-column>
10
+ <el-table-column prop="exportable" label="是否导出">
11
+ <template #default="{row}">
12
+ <el-switch v-model="row.exportable"></el-switch>
13
+ </template>
14
+ </el-table-column>
15
+ </el-table>
16
+ <div class="footer">
17
+ <span class="flex"></span>
18
+ <el-button :icon="Download" size="default" type="primary" plain @click="exportData(false)">导出当前页</el-button>
19
+ <el-button :icon="Download" size="default" type="primary" @click="exportData(true)">导出全部</el-button>
20
+ </div>
21
+ </div>
22
+ </template>
23
+
24
+ <script>
25
+ import {Download} from "@element-plus/icons-vue";
26
+
27
+ export default {
28
+ name: "export-confirm",
29
+ computed: {
30
+ Download() {
31
+ return Download
32
+ }
33
+ },
34
+ emits: ['ok'],
35
+ props: {
36
+ columns: Array
37
+ },
38
+ methods: {
39
+ exportData(all) {
40
+ this.$emit('ok', { columns: this.columns, all: all })
41
+ }
42
+ }
43
+ }
44
+ </script>
45
+
46
+ <style scoped lang="scss">
47
+ .footer {
48
+ display: flex;
49
+ margin-top: 10px;
50
+
51
+ .flex {
52
+ flex: 1;
53
+ }
54
+ }
55
+ </style>
@@ -0,0 +1,140 @@
1
+ <template>
2
+ <el-form ref="quickFilterForm" :inline="true" :label-width="option.style.formLabelWidth" class="fc-quick-filter-form"
3
+ :style="formStyle">
4
+ <el-form-item v-for="filter in visibleFilters"
5
+ :key="filter.col"
6
+ :prop="filter.col"
7
+ :label="filter.label + ':'"
8
+ :style="filter.props && filter.props.quickFilterBlock !== false ? formItemBlockStyle : ''"
9
+ :class="{'fc-block': filter.props && filter.props.quickFilterBlock !== false}"
10
+ class="fc-quick-filter-form-item">
11
+ <component :size="option.style.size" :is="filter.component" v-model="filter.val" v-bind="filter.props"
12
+ @change="handleChange(filter)" @click="handleClick(filter)"/>
13
+ </el-form-item>
14
+ <slot></slot>
15
+ </el-form>
16
+ </template>
17
+
18
+ <script>
19
+ import {ArrowDown, ArrowUp} from "@element-plus/icons-vue";
20
+ import {buildGridTemplateAreas, isFunction} from "../../../util/util.js";
21
+ import {FastTableOption} from "../../../index.js";
22
+
23
+ export default {
24
+ name: "quick-filter-form",
25
+ components: {ArrowDown, ArrowUp},
26
+ props: {
27
+ option: FastTableOption,
28
+ filters: {
29
+ type: Array,
30
+ default: () => []
31
+ }
32
+ },
33
+ data() {
34
+ return {
35
+ showNum: 3, // 收缩展示数量
36
+ showFormItems: [] // 显示的formItem, 元素对象格式为 {block: Boolean}
37
+ }
38
+ },
39
+ computed: {
40
+ /**
41
+ * quickFilterBlock的独占一行且排前面。注意: 必须浅拷贝
42
+ * @return {*[]}
43
+ */
44
+ visibleFilters() {
45
+ const {filters = []} = this;
46
+ // 确保独占一行的快筛项排前面
47
+ filters.sort((a, b) => {
48
+ const {props: propsA} = a;
49
+ const {props: propsB} = b;
50
+ if (propsA.quickFilterBlock !== false && propsB.quickFilterBlock === false) {
51
+ return -1
52
+ } else if (propsA.quickFilterBlock === false && propsB.quickFilterBlock !== false) {
53
+ return 1
54
+ }
55
+ return 0;
56
+ });
57
+ return filters
58
+ },
59
+ formStyle() {
60
+ const rowSpan = this.option.style.quickFilterSpan
61
+ const gridGap = this.option.style.quickFilterGridGap
62
+ const gridTemplateAreas = buildGridTemplateAreas(rowSpan, this.showFormItems)
63
+ return {
64
+ display: 'grid',
65
+ gridTemplateColumns: `repeat(${rowSpan}, 1fr)`,
66
+ gridTemplateAreas: gridTemplateAreas,
67
+ gap: gridGap
68
+ }
69
+ },
70
+ formItemBlockStyle() {
71
+ const rowSpan = this.option.style.quickFilterSpan
72
+ return {
73
+ gridColumn: `span ${rowSpan}`
74
+ }
75
+ },
76
+ formModel() {
77
+ const model = {}
78
+ this.filters.forEach(f => model[f.col] = f.val)
79
+ return model
80
+ }
81
+ },
82
+ mounted() {
83
+ this.$nextTick(() => {
84
+ if (this.$refs.quickFilterForm) {
85
+ const formItemEls = this.$refs.quickFilterForm.$el.querySelectorAll(".el-form-item")
86
+ this.showFormItems = Array.prototype.map.call(formItemEls, e => {
87
+ return {
88
+ block: e.classList.contains('fc-block')
89
+ }
90
+ })
91
+ }
92
+ })
93
+ },
94
+ methods: {
95
+ handleChange(filter) {
96
+ const {props: {quickFilterConfig = {}}} = filter
97
+ const {onChange} = quickFilterConfig
98
+ if (!isFunction(onChange)) {
99
+ return
100
+ }
101
+ const filtersMap = this.filters.reduce((result, item) => {
102
+ result[item.col] = item
103
+ return result
104
+ }, {})
105
+ const context = this.option.context
106
+ onChange.call(context, filter.val, this.formModel, filter, filtersMap)
107
+ },
108
+ handleClick(filter) {
109
+ const {props: {quickFilterConfig = {}}} = filter
110
+ const {onClick} = quickFilterConfig
111
+ if (!isFunction(onClick)) {
112
+ return
113
+ }
114
+ const filtersMap = this.filters.reduce((result, item) => {
115
+ result[item.col] = item
116
+ return result
117
+ }, {})
118
+ const context = this.option.context
119
+ onClick.call(context, this.formModel, filter, filtersMap)
120
+ }
121
+ }
122
+ }
123
+ </script>
124
+
125
+ <style lang="scss">
126
+ .fc-quick-filter-form > .el-form-item {
127
+ margin: 0 !important;
128
+ }
129
+ </style>
130
+ <style scoped lang="scss">
131
+ .fc-quick-filter-form {
132
+ .fc-quick-filter-form-btns {
133
+ margin-left: 10px;
134
+ }
135
+ :deep(.el-form-item__content > *) {
136
+ flex: 1;
137
+ }
138
+ }
139
+
140
+ </style>
@@ -0,0 +1,137 @@
1
+ <template>
2
+ <div class="fc-table-edit-form-wrapper">
3
+ <el-form ref="editForm"
4
+ class="fc-table-edit-form"
5
+ :model="formData"
6
+ :rules="rules"
7
+ :label-width="option.style.formLabelWidth">
8
+ <el-row v-for="row in localLayout" :key="row.col">
9
+ <el-col v-for="(span, col) in row" :span="span" :key="col">
10
+ <el-form-item :prop="col"
11
+ :label="config[col].label"
12
+ :key="col"
13
+ v-if="canEdit(col)">
14
+ <component :is="config[col].component"
15
+ v-bind="config[col].props"
16
+ v-model="formData[col]"
17
+ style="width: 100%"></component>
18
+ </el-form-item>
19
+ <span v-else>&nbsp;</span>
20
+ </el-col>
21
+ </el-row>
22
+ </el-form>
23
+ <div class="fc-table-edit-form-btns">
24
+ <el-button :size="option.style.size" type="primary" @click="submit">保存</el-button>
25
+ <el-button :size="option.style.size" @click="cancel">取消</el-button>
26
+ </div>
27
+ </div>
28
+ </template>
29
+
30
+ <script>
31
+ import {ElMessage} from 'element-plus';
32
+ import FastTableOption from "../../../model/fastTableOption.js";
33
+ import {isEmpty} from "../../../util/util";
34
+ import {colEditable} from "./util";
35
+
36
+ export default {
37
+ name: "row-form",
38
+ emits: ['ok', 'cancel'],
39
+ props: {
40
+ option: FastTableOption,
41
+ config: Object,
42
+ row: Object,
43
+ type: String,
44
+ layout: String
45
+ },
46
+ data() {
47
+ const formData = this.row.editRow
48
+ const ruleMap = {};
49
+ for (const col in this.config) {
50
+ const {component, props: {rules = []}} = this.config[col];
51
+ if (!isEmpty(rules)) {
52
+ rules.forEach(rule => rule.getRow = (() => formData)) // 为了自定义验证器里能获取到当前行 煞费苦心
53
+ ruleMap[col] = rules;
54
+ }
55
+ if (component === 'fast-object-picker') { // 对于FastObjectPicker需要特别把formData传进去
56
+ this.config[col].props.pickObject = formData;
57
+ }
58
+ }
59
+ return {
60
+ rules: ruleMap,
61
+ formData: formData
62
+ }
63
+ },
64
+ computed: {
65
+ localLayout() {
66
+ let {layout, config} = this;
67
+ const colArr = Object.keys(config);
68
+ if (isEmpty(layout)) {
69
+ layout = colArr.join(",");
70
+ }
71
+ return layout.split(",").map(row => {
72
+ const rowObj = {};
73
+ const cols = row.split("|");
74
+ const perSpan = Math.floor(24 / cols.length);
75
+ for (let i = 0; i < cols.length; i++) {
76
+ const key = cols[i].trim();
77
+ if (rowObj.hasOwnProperty(key)) {
78
+ rowObj[key] += perSpan;
79
+ } else {
80
+ rowObj[key] = perSpan;
81
+ }
82
+ }
83
+ return rowObj;
84
+ })
85
+ }
86
+ },
87
+ methods: {
88
+ /**
89
+ * 是否展示编辑模式
90
+ * @param col 列
91
+ * @param config 列配置
92
+ * @returns {boolean}
93
+ */
94
+ canEdit(col) {
95
+ return colEditable.call(this.option.context, {...this.row, status: this.type}, col);
96
+ },
97
+ cancel() {
98
+ const {context, beforeCancel} = this.option;
99
+ beforeCancel.call(context, {
100
+ fatRows: [this.row],
101
+ rows: [this.row.row],
102
+ status: this.type
103
+ }).then(() => {
104
+ this.$emit('cancel')
105
+ }).catch(() => {
106
+ // 不允许取消
107
+ })
108
+ },
109
+ submit() {
110
+ this.$refs['editForm'].validate().then(() => {
111
+ const fn = this.type === 'insert' ? this.option._insertRows : this.option._updateRows;
112
+ fn.call(this.option, [this.row]).then(() => {
113
+ this.$emit('ok')
114
+ })
115
+ }).catch((err) => {
116
+ console.error(err)
117
+ ElMessage.warning('表单校验未通过! 请检查输入内容');
118
+ })
119
+ }
120
+ }
121
+ }
122
+ </script>
123
+
124
+ <style scoped lang="scss">
125
+ .fc-table-edit-form-wrapper {
126
+ .fc-table-edit-form {
127
+ //display: grid;
128
+ //grid-template-columns: 1fr 1fr;
129
+ //column-gap: 20px;
130
+ }
131
+
132
+ .fc-table-edit-form-btns {
133
+ display: flex;
134
+ justify-content: right;
135
+ }
136
+ }
137
+ </style>