fast-crud-ui3 1.5.16-tsc-beta → 1.5.16

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/fast-crud-ui3.cjs.js +7 -7
  2. package/lib/fast-crud-ui3.es.js +1960 -2003
  3. package/lib/fast-crud-ui3.umd.js +7 -7
  4. package/lib/style.css +1 -1
  5. package/package.json +5 -18
  6. package/lib/assets/fonts/iconfont.d.ts +0 -0
  7. package/lib/components/checkbox-group/index.d.ts +0 -2
  8. package/lib/components/checkbox-group/src/fast-checkbox-group.d.ts +0 -72
  9. package/lib/components/content-dialog/index.d.ts +0 -2
  10. package/lib/components/content-dialog/src/fast-cell-content.d.ts +0 -83
  11. package/lib/components/json-viewer/index.d.ts +0 -2
  12. package/lib/components/json-viewer/src/fast-json-viewer.d.ts +0 -48
  13. package/lib/components/mapping.d.ts +0 -5
  14. package/lib/components/object-picker/index.d.ts +0 -2
  15. package/lib/components/object-picker/src/fast-object-picker.d.ts +0 -132
  16. package/lib/components/select/index.d.ts +0 -2
  17. package/lib/components/select/src/fast-select.d.ts +0 -83
  18. package/lib/components/table/index.d.ts +0 -2
  19. package/lib/components/table/src/RowConfirm.d.ts +0 -39
  20. package/lib/components/table/src/dynamic-filter-form.d.ts +0 -118
  21. package/lib/components/table/src/dynamic-filter-list.d.ts +0 -57
  22. package/lib/components/table/src/easy-filter.d.ts +0 -118
  23. package/lib/components/table/src/export-confirm.d.ts +0 -12
  24. package/lib/components/table/src/quick-filter-form.d.ts +0 -42
  25. package/lib/components/table/src/row-form.d.ts +0 -33
  26. package/lib/components/table/src/stored-filter-manager.d.ts +0 -55
  27. package/lib/components/table/src/stored-filter.d.ts +0 -37
  28. package/lib/components/table/src/table-head-cell.d.ts +0 -9
  29. package/lib/components/table/src/table.d.ts +0 -497
  30. package/lib/components/table/src/util.d.ts +0 -77
  31. package/lib/components/table-column/config.d.ts +0 -5
  32. package/lib/components/table-column/index.d.ts +0 -2
  33. package/lib/components/table-column/src/table-column.d.ts +0 -256
  34. package/lib/components/table-column-date-picker/config.d.ts +0 -5
  35. package/lib/components/table-column-date-picker/index.d.ts +0 -2
  36. package/lib/components/table-column-date-picker/src/table-column-date-picker.d.ts +0 -173
  37. package/lib/components/table-column-file/config.d.ts +0 -5
  38. package/lib/components/table-column-file/index.d.ts +0 -2
  39. package/lib/components/table-column-file/src/table-column-file.d.ts +0 -285
  40. package/lib/components/table-column-img/config.d.ts +0 -5
  41. package/lib/components/table-column-img/index.d.ts +0 -2
  42. package/lib/components/table-column-img/src/table-column-img.d.ts +0 -285
  43. package/lib/components/table-column-input/config.d.ts +0 -5
  44. package/lib/components/table-column-input/index.d.ts +0 -2
  45. package/lib/components/table-column-input/src/table-column-input.d.ts +0 -173
  46. package/lib/components/table-column-number/config.d.ts +0 -5
  47. package/lib/components/table-column-number/index.d.ts +0 -2
  48. package/lib/components/table-column-number/src/table-column-number.d.ts +0 -173
  49. package/lib/components/table-column-object/config.d.ts +0 -5
  50. package/lib/components/table-column-object/index.d.ts +0 -2
  51. package/lib/components/table-column-object/src/table-column-object.d.ts +0 -315
  52. package/lib/components/table-column-select/config.d.ts +0 -5
  53. package/lib/components/table-column-select/index.d.ts +0 -2
  54. package/lib/components/table-column-select/src/table-column-select.d.ts +0 -276
  55. package/lib/components/table-column-switch/config.d.ts +0 -5
  56. package/lib/components/table-column-switch/index.d.ts +0 -2
  57. package/lib/components/table-column-switch/src/table-column-switch.d.ts +0 -175
  58. package/lib/components/table-column-textarea/config.d.ts +0 -5
  59. package/lib/components/table-column-textarea/index.d.ts +0 -2
  60. package/lib/components/table-column-textarea/src/table-column-textarea.d.ts +0 -173
  61. package/lib/components/table-column-time-picker/config.d.ts +0 -5
  62. package/lib/components/table-column-time-picker/index.d.ts +0 -2
  63. package/lib/components/table-column-time-picker/src/table-column-time-picker.d.ts +0 -173
  64. package/lib/components/upload/index.d.ts +0 -2
  65. package/lib/components/upload/src/fast-upload.d.ts +0 -120
  66. package/lib/global.d.ts +0 -42
  67. package/lib/index.d.ts +0 -56
  68. package/lib/mixins/table-column.d.ts +0 -104
  69. package/lib/mixins/upload.d.ts +0 -15
  70. package/lib/model/cond.d.ts +0 -25
  71. package/lib/model/editComponentConfig.d.ts +0 -25
  72. package/lib/model/fastTableOption.d.ts +0 -355
  73. package/lib/model/filterComponentConfig.d.ts +0 -57
  74. package/lib/model/opt.d.ts +0 -20
  75. package/lib/model/order.d.ts +0 -7
  76. package/lib/model/pageQuery.d.ts +0 -23
  77. package/lib/model/query.d.ts +0 -33
  78. package/lib/model/rel.d.ts +0 -5
  79. package/lib/util/cache.d.ts +0 -17
  80. package/lib/util/dialog.d.ts +0 -49
  81. package/lib/util/escape.d.ts +0 -7
  82. package/lib/util/http.d.ts +0 -8
  83. package/lib/util/pick.d.ts +0 -14
  84. package/lib/util/util.d.ts +0 -252
  85. package/packages/assets/fonts/iconfont.css +0 -163
  86. package/packages/assets/fonts/iconfont.js +0 -1
  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 +0 -7
  91. package/packages/components/checkbox-group/src/fast-checkbox-group.vue +0 -83
  92. package/packages/components/content-dialog/index.js +0 -7
  93. package/packages/components/content-dialog/src/fast-cell-content.vue +0 -115
  94. package/packages/components/json-viewer/index.js +0 -7
  95. package/packages/components/json-viewer/src/fast-json-viewer.vue +0 -54
  96. package/packages/components/mapping.js +0 -95
  97. package/packages/components/object-picker/index.js +0 -7
  98. package/packages/components/object-picker/src/fast-object-picker.vue +0 -170
  99. package/packages/components/select/index.js +0 -7
  100. package/packages/components/select/src/fast-select.vue +0 -89
  101. package/packages/components/table/index.js +0 -7
  102. package/packages/components/table/src/RowConfirm.vue +0 -87
  103. package/packages/components/table/src/dynamic-filter-form.vue +0 -253
  104. package/packages/components/table/src/dynamic-filter-list.vue +0 -172
  105. package/packages/components/table/src/easy-filter.vue +0 -129
  106. package/packages/components/table/src/export-confirm.vue +0 -55
  107. package/packages/components/table/src/quick-filter-form.vue +0 -140
  108. package/packages/components/table/src/row-form.vue +0 -137
  109. package/packages/components/table/src/stored-filter-manager.vue +0 -240
  110. package/packages/components/table/src/stored-filter.vue +0 -180
  111. package/packages/components/table/src/table-head-cell.vue +0 -41
  112. package/packages/components/table/src/table.vue +0 -1309
  113. package/packages/components/table/src/util.js +0 -496
  114. package/packages/components/table-column/config.js +0 -64
  115. package/packages/components/table-column/index.js +0 -7
  116. package/packages/components/table-column/src/table-column.vue +0 -44
  117. package/packages/components/table-column-date-picker/config.js +0 -139
  118. package/packages/components/table-column-date-picker/index.js +0 -7
  119. package/packages/components/table-column-date-picker/src/table-column-date-picker.vue +0 -54
  120. package/packages/components/table-column-file/config.js +0 -83
  121. package/packages/components/table-column-file/index.js +0 -7
  122. package/packages/components/table-column-file/src/table-column-file.vue +0 -79
  123. package/packages/components/table-column-img/config.js +0 -83
  124. package/packages/components/table-column-img/index.js +0 -7
  125. package/packages/components/table-column-img/src/table-column-img.vue +0 -82
  126. package/packages/components/table-column-input/config.js +0 -77
  127. package/packages/components/table-column-input/index.js +0 -7
  128. package/packages/components/table-column-input/src/table-column-input.vue +0 -60
  129. package/packages/components/table-column-number/config.js +0 -89
  130. package/packages/components/table-column-number/index.js +0 -7
  131. package/packages/components/table-column-number/src/table-column-number.vue +0 -54
  132. package/packages/components/table-column-object/config.js +0 -66
  133. package/packages/components/table-column-object/index.js +0 -7
  134. package/packages/components/table-column-object/src/table-column-object.vue +0 -75
  135. package/packages/components/table-column-select/config.js +0 -66
  136. package/packages/components/table-column-select/index.js +0 -7
  137. package/packages/components/table-column-select/src/table-column-select.vue +0 -101
  138. package/packages/components/table-column-switch/config.js +0 -55
  139. package/packages/components/table-column-switch/index.js +0 -7
  140. package/packages/components/table-column-switch/src/table-column-switch.vue +0 -82
  141. package/packages/components/table-column-textarea/config.js +0 -77
  142. package/packages/components/table-column-textarea/index.js +0 -7
  143. package/packages/components/table-column-textarea/src/table-column-textarea.vue +0 -56
  144. package/packages/components/table-column-time-picker/config.js +0 -62
  145. package/packages/components/table-column-time-picker/index.js +0 -7
  146. package/packages/components/table-column-time-picker/src/table-column-time-picker.vue +0 -53
  147. package/packages/components/upload/index.js +0 -7
  148. package/packages/components/upload/src/fast-upload.vue +0 -272
  149. package/packages/global.d.ts +0 -42
  150. package/packages/index.js +0 -145
  151. package/packages/mixins/table-column.js +0 -133
  152. package/packages/mixins/upload.js +0 -14
  153. package/packages/model/cond.js +0 -65
  154. package/packages/model/editComponentConfig.js +0 -72
  155. package/packages/model/fastTableOption.js +0 -538
  156. package/packages/model/filterComponentConfig.js +0 -185
  157. package/packages/model/opt.js +0 -21
  158. package/packages/model/order.js +0 -16
  159. package/packages/model/pageQuery.js +0 -31
  160. package/packages/model/query.js +0 -93
  161. package/packages/model/rel.js +0 -5
  162. package/packages/style.scss +0 -5
  163. package/packages/util/cache.js +0 -92
  164. package/packages/util/dialog.js +0 -133
  165. package/packages/util/escape.js +0 -34
  166. package/packages/util/http.js +0 -18
  167. package/packages/util/pick.js +0 -92
  168. package/packages/util/util.js +0 -833
@@ -1,140 +0,0 @@
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>
@@ -1,137 +0,0 @@
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>
@@ -1,240 +0,0 @@
1
- <template>
2
- <div class="fc-stored-filter-manager">
3
- <div class="fc-stored-filter-manager-btns">
4
- <el-button :icon="Plus" type="primary" plain @click="addStoreGroup">添加</el-button>
5
- <el-button type="success" plain @click="saveStoreGroup">保存</el-button>
6
- </div>
7
- <template v-for="g in groups">
8
- <el-card class="fc-stored-filter-item" shadow="hover" v-if="hiddenBuildIn === false || g.buildIn === false">
9
- <template #header>
10
- <div class="fc-stored-filter-item-header">
11
- <div style="display: flex">
12
- <el-input class="fc-stored-filter-item-label" placeholder="请输入组合名" v-model="g.label"
13
- :disabled="g.buildIn"/>&nbsp;
14
- <el-alert type="warning" :closable="false" show-icon v-if="!g.compatible">此筛选组不兼容, 请修改
15
- </el-alert>
16
- </div>
17
- <el-button type="danger" link @click="delStoreGroup(g)" v-if="!g.buildIn">删除</el-button>
18
- </div>
19
- </template>
20
- <div class="fc-dynamic-filter-list">
21
- <el-popover class="fc-stored-filter-item-cond" popper-style="max-width: none; width: auto; z-index: 3000"
22
- v-for="(f, index) in g.filters" :key="f.col + '.' + index" :disabled="g.buildIn">
23
- <template v-slot:reference>
24
- <div class="fc-dynamic-filter-btns">
25
- <el-button link class="fc-dynamic-filter-open-btn">
26
- {{ f.condMsg }}
27
- </el-button>
28
- <el-button link class="fc-dynamic-filter-del-btn" :icon="Close" v-if="!g.buildIn"
29
- @click.stop="delConfig(index, g.filters)"></el-button>
30
-
31
- <span style="margin-right: 10px; color: #909090;">且</span>
32
- </div>
33
- </template>
34
- <component class="component" :is="f.component" v-model="f.val" v-bind="f.props" :teleported="false" @change="onChange(f)"
35
- v-if="f.opt !== Opt.NULL && f.opt !== Opt.NNULL && f.opt !== Opt.EMPTY && f.opt !== Opt.NEMPTY"/>
36
- </el-popover>
37
-
38
- <el-dropdown max-height="200px" @command="(col) => handleAddCond(col, g)" v-if="!g.buildIn">
39
- <el-link :icon="Plus"></el-link>
40
- <template #dropdown>
41
- <el-dropdown-menu>
42
- <el-dropdown-item v-for="col in colsOption" :command="col.value">{{ col.label }}</el-dropdown-item>
43
- </el-dropdown-menu>
44
- </template>
45
- </el-dropdown>
46
- </div>
47
- </el-card>
48
- </template>
49
- <el-button style="text-decoration: underline;" link @click="() => hiddenBuildIn = !hiddenBuildIn">
50
- {{ hiddenBuildIn ? '显示' : '隐藏' }}内置的组合筛选项
51
- </el-button>
52
- </div>
53
- </template>
54
-
55
- <script>
56
- import {Close, Plus} from "@element-plus/icons-vue";
57
- import FastTableOption from '../../../model/fastTableOption.js'
58
- import Opt from '../../../model/opt.js'
59
- import {buildStoredFilterComponent, setCustomFilterGroups} from "./util.js";
60
- import * as util from "../../../util/util.js";
61
- import {ElMessage} from "element-plus";
62
-
63
- export default {
64
- name: "stored-filter-manager",
65
- emits: ['ok'],
66
- props: {
67
- tableOption: FastTableOption,
68
- columnConfig: Object,
69
- storeGroups: Array
70
- },
71
- data() {
72
- const groups = util.deepClone(this.storeGroups) // 避免修改外部
73
- groups.forEach(g => {
74
- if (util.isFunction(g.filters)) { // 瞬化某些filter
75
- g.filters = g.filters()
76
- }
77
- })
78
- return {
79
- hiddenBuildIn: true,
80
- groups: groups.sort((a, b) => a.buildIn - b.buildIn)
81
- }
82
- },
83
- computed: {
84
- Plus() {
85
- return Plus
86
- },
87
- Close() {
88
- return Close
89
- },
90
- Opt() {
91
- return Opt
92
- },
93
- colsOption() {
94
- return Object.entries(this.columnConfig).map(([col, config]) => {
95
- const {customConfig: {label}} = config
96
- return {value: col, label: label}
97
- })
98
- },
99
- },
100
- async created() {
101
- // 刷新条件显示
102
- for (let i = 0; i < this.groups.length; i++) {
103
- for (let j = 0; j < this.groups[i].filters.length; j++) {
104
- await this.groups[i].filters[j].updateCondMsg()
105
- }
106
- }
107
- },
108
- methods: {
109
- onChange(filter) {
110
- filter.updateCondMsg()
111
- },
112
- async handleAddCond(col, storeGroup) {
113
- const filter = buildStoredFilterComponent(col, this.columnConfig, this.tableOption)
114
- if (!util.isEmpty(filter)) {
115
- await filter.updateCondMsg()
116
- storeGroup.filters.push(filter)
117
- }
118
- },
119
- delConfig(index, filters) {
120
- filters.splice(index, 1)
121
- },
122
- addStoreGroup() {
123
- this.groups.unshift({
124
- label: '',
125
- filters: [],
126
- buildIn: false,
127
- compatible: true
128
- })
129
- },
130
- /**
131
- * 删除存筛: 只能删除自定义
132
- */
133
- delStoreGroup(group) {
134
- this.groups = this.groups.filter(g => g !== group)
135
- },
136
- /**
137
- * 保存自定义存筛到localStorage中,注意: 只保存自定义的
138
- */
139
- saveStoreGroup() {
140
- const toBeSavedGroups = this.groups.filter(g => g.buildIn === false)
141
- const labels = this.groups.map(g => g.label)
142
- const duplicateLabel = labels.filter((l, i) => labels.indexOf(l) !== i)
143
- // check
144
- util.assertTip(util.isEmpty(duplicateLabel), '组合名重复,请修改:' + [...new Set(duplicateLabel)])
145
- for (let i = 0; i < toBeSavedGroups.length; i++) {
146
- const {label, filters} = toBeSavedGroups[i]
147
- util.assertTip(!util.isEmpty(label), '请填写组合名')
148
- util.assertTip(label.length <= 10, `组合名长度不得超过10:${label}`)
149
- util.assertTip(!util.isEmpty(filters), `请为“${label}”配置筛选项`)
150
- util.assertTip(filters.every(f => f.isEffective()), `“${label}”存在无效筛选项`)
151
- }
152
- setCustomFilterGroups(this.tableOption, toBeSavedGroups)
153
- ElMessage.success('保存成功')
154
- this.$emit('ok')
155
- }
156
- }
157
- }
158
- </script>
159
-
160
- <style scoped lang="scss">
161
- .fc-stored-filter-manager {
162
- .fc-stored-filter-manager-btns {
163
- margin-bottom: 20px;
164
- }
165
-
166
- .fc-stored-filter-item {
167
- margin: 10px 0;
168
-
169
- :deep(.fc-stored-filter-item-header) {
170
- display: flex;
171
- justify-content: space-between;
172
- }
173
-
174
- .fc-stored-filter-item-label {
175
- width: 200px;
176
- }
177
-
178
-
179
- .fc-dynamic-filter-list {
180
- display: flex;
181
- flex-wrap: wrap;
182
- column-gap: 5px;
183
- align-items: center;
184
-
185
- .fc-dynamic-filter-btns {
186
- display: flex;
187
- align-items: center;
188
-
189
- &:hover {
190
- .fc-dynamic-filter-open-btn {
191
- text-decoration: underline;
192
- }
193
-
194
- .fc-dynamic-filter-del-btn {
195
- //display: inline-block;
196
- visibility: visible;
197
- }
198
- }
199
- }
200
-
201
- .fc-dynamic-filter-open-btn {
202
- color: gray;
203
- padding: 3px 5px;
204
- border: 1px solid #cacaca;
205
- border-radius: 3px;
206
- font-size: 15px !important;
207
- }
208
-
209
- .fc-dynamic-filter-del-btn {
210
- visibility: hidden;
211
- margin-left: 5px;
212
- padding: 5px 0;
213
- color: #8d4343;
214
- font-size: 13px !important;
215
- }
216
-
217
- .fc-dynamic-filter-clear-btn {
218
- font-size: 13px !important;
219
- margin-left: 3px;
220
- }
221
- }
222
-
223
- .component {
224
- margin: 10px 0;
225
- max-width: 420px;
226
- max-height: 300px;
227
- overflow: auto;
228
-
229
- :deep(.fc-checkbox-group) {
230
- display: block;
231
- }
232
-
233
- :deep(.fc-checkbox-group .el-checkbox) {
234
- display: block;
235
- }
236
-
237
- }
238
- }
239
- }
240
- </style>
@@ -1,180 +0,0 @@
1
- <template>
2
- <div class="fc-stored-btn">
3
- <el-dropdown :size="size">
4
- <el-button type="primary" :size="size">
5
- <span v-if="showLabel">{{ showLabel }}</span>
6
- <el-icon v-else>
7
- <Star/>
8
- </el-icon>&nbsp;
9
- <el-icon>
10
- <arrow-down/>
11
- </el-icon>
12
- </el-button>
13
- <template #dropdown>
14
- <el-dropdown-menu>
15
- <!-- <el-dropdown-item @click="clear">清空</el-dropdown-item>-->
16
- <el-dropdown-item v-for="item in storeGroups" :key="item.label"
17
- :style="{color: (groupLabels.indexOf(item.label) > -1) ? '#3f99f5 !important' : ''}"
18
- :disabled="!item.compatible"
19
- @click="handleClick(item, $event)">
20
- <el-icon v-show="groupLabels.indexOf(item.label) > -1">
21
- <Select/>
22
- </el-icon>
23
- <span>{{ item.label }}</span>
24
- </el-dropdown-item>
25
- <el-dropdown-item divided @click="toCustom">自定义</el-dropdown-item>
26
- </el-dropdown-menu>
27
- </template>
28
- </el-dropdown>
29
- </div>
30
- </template>
31
- <script>
32
- import {nextTick} from "vue"
33
- import {dayjs} from "element-plus"
34
- import {ArrowDown, Star, Select} from "@element-plus/icons-vue"
35
- import * as util from "../../../util/util.js"
36
- import FastTableOption from "../../../model/fastTableOption.js"
37
- import {openDialog} from "../../../util/dialog.js";
38
- import StoredFilterManager from "./stored-filter-manager.vue";
39
- import {buildFilterGroups, buildStoredFilterComponent, getCustomFilterGroups} from "./util.js"
40
-
41
- export default {
42
- name: "stored-filter",
43
- components: {ArrowDown, Star, Select},
44
- emits: ['change', 'update:modelValue'],
45
- props: {
46
- // 存筛label名组成的数组, 表示勾选项
47
- groupLabels: Array,
48
- size: String,
49
- tableOption: FastTableOption,
50
- columnConfig: Object
51
- },
52
- data() {
53
- return {
54
- storeGroups: [], // 存筛分组列表。元素格式: {label: '存筛名', filters: [{..}], buildIn: false, compatible: true}
55
- }
56
- },
57
- computed: {
58
- showLabel() {
59
- if (util.isEmpty(this.groupLabels)) {
60
- return ''
61
- }
62
- const firstLabel = this.groupLabels[0]
63
- return firstLabel + (this.groupLabels.length > 1 ? `+${this.groupLabels.length - 1}` : '')
64
- }
65
- },
66
- mounted() {
67
- nextTick(() => this.init())
68
- },
69
- methods: {
70
- init() {
71
- this.storeGroups.length = 0
72
- this.initCreateTimeFilter() // 基于创建时间构造内置存筛
73
- this.initDevCustomFilter() // 构造开发者预定义存筛
74
- this.initUserCustomFilter() // 构造用户自定义存筛
75
- this.storeGroups.sort((a, b) => b.compatible - a.compatible)
76
- },
77
- initCreateTimeFilter() {
78
- const {createTimeField} = this.tableOption
79
- if (util.isEmpty(createTimeField)) {
80
- return
81
- }
82
- const getFilters = (type) => {
83
- const createTimeFilter = buildStoredFilterComponent(createTimeField, this.columnConfig, this.tableOption)
84
- if (util.isNull(createTimeFilter)) {
85
- return []
86
- }
87
- const {props: {valueFormat}} = createTimeFilter
88
- const end = new Date()
89
- let start
90
- if (type === 'day') {
91
- start = util.getBeginOfDate(end)
92
- } else if (type === 'week') {
93
- start = util.getBeginOfWeek(end)
94
- } else if (type === 'month') {
95
- start = util.getBeginOfMonth(end)
96
- }
97
- createTimeFilter.val = [dayjs(start).format(valueFormat), dayjs(end).format(valueFormat)]
98
- return [createTimeFilter]
99
- }
100
-
101
- this.storeGroups.push({
102
- label: '当天新建', buildIn: true, compatible: true, filters: () => {
103
- return getFilters('day')
104
- }
105
- })
106
- this.storeGroups.push({
107
- label: '当周新建', buildIn: true, compatible: true, filters: () => {
108
- return getFilters('week')
109
- }
110
- })
111
- this.storeGroups.push({
112
- label: '当月新建', buildIn: true, compatible: true, filters: () => {
113
- return getFilters('month')
114
- }
115
- })
116
- },
117
- initDevCustomFilter() {
118
- const {condGroups = []} = this.tableOption
119
- const filterGroups = buildFilterGroups(this.tableOption, this.columnConfig, condGroups, true)
120
- this.storeGroups.push(...filterGroups)
121
- },
122
- initUserCustomFilter() {
123
- const filterGroups = getCustomFilterGroups(this.tableOption, this.columnConfig)
124
- this.storeGroups.push(...filterGroups)
125
- },
126
- handleClick(group, e) {
127
- const idx = this.groupLabels.indexOf(group.label)
128
- if (idx > -1) { // 取消
129
- this.groupLabels.splice(idx, 1)
130
- } else {
131
- if (!(e.ctrlKey || e.metaKey)) { // 支持按住ctrl/command点击可以选多个
132
- this.groupLabels.length = 0
133
- }
134
- this.groupLabels.push(group.label)
135
- }
136
- this.$emit('change')
137
- },
138
- toCustom() {
139
- openDialog({
140
- component: StoredFilterManager,
141
- props: {
142
- tableOption: this.tableOption,
143
- columnConfig: this.columnConfig,
144
- storeGroups: this.storeGroups
145
- },
146
- dialogProps: {
147
- title: '自定义组合筛选',
148
- width: '60%'
149
- }
150
- }).then(() => {
151
- this.init()
152
- })
153
-
154
- },
155
- clear() {
156
- this.groupLabels.length = 0
157
- this.$emit('change')
158
- },
159
- /**
160
- * 获取生效的筛选项, 通过勾选的存筛组(groupLabels),从storeGroups中解析出生效的filters并返回
161
- * @return {*[]}
162
- */
163
- getStoreFilters() {
164
- const effectFilters = []
165
- if (util.isEmpty(this.storeGroups)) {
166
- this.init()
167
- }
168
- for (const g of this.storeGroups) {
169
- if (this.groupLabels.indexOf(g.label) === -1) {
170
- continue
171
- }
172
- const filters = util.isFunction(g.filters) ? g.filters.call(this.tableOption.context) : g.filters
173
- util.assert(util.isArray(filters), `the filters prop of group(${g.label}) is wrong type, it should be a array, or a function that return a array`)
174
- effectFilters.push(...filters)
175
- }
176
- return effectFilters
177
- }
178
- }
179
- }
180
- </script>