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.
- package/lib/assets/fonts/iconfont.d.ts +0 -0
- package/lib/components/checkbox-group/index.d.ts +2 -0
- package/lib/components/checkbox-group/src/fast-checkbox-group.d.ts +72 -0
- package/lib/components/content-dialog/index.d.ts +2 -0
- package/lib/components/content-dialog/src/fast-cell-content.d.ts +83 -0
- package/lib/components/json-viewer/index.d.ts +2 -0
- package/lib/components/json-viewer/src/fast-json-viewer.d.ts +48 -0
- package/lib/components/mapping.d.ts +5 -0
- package/lib/components/object-picker/index.d.ts +2 -0
- package/lib/components/object-picker/src/fast-object-picker.d.ts +132 -0
- package/lib/components/select/index.d.ts +2 -0
- package/lib/components/select/src/fast-select.d.ts +83 -0
- package/lib/components/table/index.d.ts +2 -0
- package/lib/components/table/src/RowConfirm.d.ts +39 -0
- package/lib/components/table/src/dynamic-filter-form.d.ts +118 -0
- package/lib/components/table/src/dynamic-filter-list.d.ts +57 -0
- package/lib/components/table/src/easy-filter.d.ts +118 -0
- package/lib/components/table/src/export-confirm.d.ts +12 -0
- package/lib/components/table/src/quick-filter-form.d.ts +42 -0
- package/lib/components/table/src/row-form.d.ts +33 -0
- package/lib/components/table/src/stored-filter-manager.d.ts +55 -0
- package/lib/components/table/src/stored-filter.d.ts +37 -0
- package/lib/components/table/src/table-head-cell.d.ts +9 -0
- package/lib/components/table/src/table.d.ts +507 -0
- package/lib/components/table/src/util.d.ts +77 -0
- package/lib/components/table-column/config.d.ts +5 -0
- package/lib/components/table-column/index.d.ts +2 -0
- package/lib/components/table-column/src/table-column.d.ts +256 -0
- package/lib/components/table-column-date-picker/config.d.ts +5 -0
- package/lib/components/table-column-date-picker/index.d.ts +2 -0
- package/lib/components/table-column-date-picker/src/table-column-date-picker.d.ts +173 -0
- package/lib/components/table-column-file/config.d.ts +5 -0
- package/lib/components/table-column-file/index.d.ts +2 -0
- package/lib/components/table-column-file/src/table-column-file.d.ts +285 -0
- package/lib/components/table-column-img/config.d.ts +5 -0
- package/lib/components/table-column-img/index.d.ts +2 -0
- package/lib/components/table-column-img/src/table-column-img.d.ts +285 -0
- package/lib/components/table-column-input/config.d.ts +5 -0
- package/lib/components/table-column-input/index.d.ts +2 -0
- package/lib/components/table-column-input/src/table-column-input.d.ts +173 -0
- package/lib/components/table-column-number/config.d.ts +5 -0
- package/lib/components/table-column-number/index.d.ts +2 -0
- package/lib/components/table-column-number/src/table-column-number.d.ts +173 -0
- package/lib/components/table-column-object/config.d.ts +5 -0
- package/lib/components/table-column-object/index.d.ts +2 -0
- package/lib/components/table-column-object/src/table-column-object.d.ts +315 -0
- package/lib/components/table-column-select/config.d.ts +5 -0
- package/lib/components/table-column-select/index.d.ts +2 -0
- package/lib/components/table-column-select/src/table-column-select.d.ts +276 -0
- package/lib/components/table-column-switch/config.d.ts +5 -0
- package/lib/components/table-column-switch/index.d.ts +2 -0
- package/lib/components/table-column-switch/src/table-column-switch.d.ts +175 -0
- package/lib/components/table-column-textarea/config.d.ts +5 -0
- package/lib/components/table-column-textarea/index.d.ts +2 -0
- package/lib/components/table-column-textarea/src/table-column-textarea.d.ts +173 -0
- package/lib/components/table-column-time-picker/config.d.ts +5 -0
- package/lib/components/table-column-time-picker/index.d.ts +2 -0
- package/lib/components/table-column-time-picker/src/table-column-time-picker.d.ts +173 -0
- package/lib/components/upload/index.d.ts +2 -0
- package/lib/components/upload/src/fast-upload.d.ts +120 -0
- package/lib/fast-crud-ui3.cjs.js +44 -17
- package/lib/fast-crud-ui3.es.js +9991 -5946
- package/lib/fast-crud-ui3.umd.js +44 -17
- package/lib/global.d.ts +42 -0
- package/lib/index.d.ts +56 -0
- package/lib/mixins/table-column.d.ts +104 -0
- package/lib/mixins/upload.d.ts +15 -0
- package/lib/model/cond.d.ts +48 -0
- package/lib/model/editComponentConfig.d.ts +25 -0
- package/lib/model/fastTableOption.d.ts +513 -0
- package/lib/model/filterComponentConfig.d.ts +55 -0
- package/lib/model/opt.d.ts +20 -0
- package/lib/model/order.d.ts +28 -0
- package/lib/model/pageQuery.d.ts +43 -0
- package/lib/model/query.d.ts +101 -0
- package/lib/model/rel.d.ts +5 -0
- package/lib/style.css +1 -1
- package/lib/util/cache.d.ts +17 -0
- package/lib/util/dialog.d.ts +49 -0
- package/lib/util/escape.d.ts +7 -0
- package/lib/util/http.d.ts +8 -0
- package/lib/util/pick.d.ts +9 -0
- package/lib/util/util.d.ts +311 -0
- package/package.json +19 -5
- package/packages/assets/fonts/iconfont.css +163 -0
- package/packages/assets/fonts/iconfont.js +1 -0
- package/packages/assets/fonts/iconfont.ttf +0 -0
- package/packages/assets/fonts/iconfont.woff +0 -0
- package/packages/assets/fonts/iconfont.woff2 +0 -0
- package/packages/components/checkbox-group/index.js +7 -0
- package/packages/components/checkbox-group/src/fast-checkbox-group.vue +83 -0
- package/packages/components/content-dialog/index.js +7 -0
- package/packages/components/content-dialog/src/fast-cell-content.vue +115 -0
- package/packages/components/json-viewer/index.js +7 -0
- package/packages/components/json-viewer/src/fast-json-viewer.vue +54 -0
- package/packages/components/mapping.js +95 -0
- package/packages/components/object-picker/index.js +7 -0
- package/packages/components/object-picker/src/fast-object-picker.vue +170 -0
- package/packages/components/select/index.js +7 -0
- package/packages/components/select/src/fast-select.vue +90 -0
- package/packages/components/table/index.js +7 -0
- package/packages/components/table/src/RowConfirm.vue +87 -0
- package/packages/components/table/src/dynamic-filter-form.vue +253 -0
- package/packages/components/table/src/dynamic-filter-list.vue +172 -0
- package/packages/components/table/src/easy-filter.vue +129 -0
- package/packages/components/table/src/export-confirm.vue +55 -0
- package/packages/components/table/src/quick-filter-form.vue +140 -0
- package/packages/components/table/src/row-form.vue +137 -0
- package/packages/components/table/src/stored-filter-manager.vue +240 -0
- package/packages/components/table/src/stored-filter.vue +180 -0
- package/packages/components/table/src/table-head-cell.vue +41 -0
- package/packages/components/table/src/table.vue +1309 -0
- package/packages/components/table/src/util.js +496 -0
- package/packages/components/table-column/config.js +64 -0
- package/packages/components/table-column/index.js +7 -0
- package/packages/components/table-column/src/table-column.vue +44 -0
- package/packages/components/table-column-date-picker/config.js +139 -0
- package/packages/components/table-column-date-picker/index.js +7 -0
- package/packages/components/table-column-date-picker/src/table-column-date-picker.vue +54 -0
- package/packages/components/table-column-file/config.js +83 -0
- package/packages/components/table-column-file/index.js +7 -0
- package/packages/components/table-column-file/src/table-column-file.vue +79 -0
- package/packages/components/table-column-img/config.js +83 -0
- package/packages/components/table-column-img/index.js +7 -0
- package/packages/components/table-column-img/src/table-column-img.vue +82 -0
- package/packages/components/table-column-input/config.js +77 -0
- package/packages/components/table-column-input/index.js +7 -0
- package/packages/components/table-column-input/src/table-column-input.vue +60 -0
- package/packages/components/table-column-number/config.js +89 -0
- package/packages/components/table-column-number/index.js +7 -0
- package/packages/components/table-column-number/src/table-column-number.vue +54 -0
- package/packages/components/table-column-object/config.js +66 -0
- package/packages/components/table-column-object/index.js +7 -0
- package/packages/components/table-column-object/src/table-column-object.vue +75 -0
- package/packages/components/table-column-select/config.js +67 -0
- package/packages/components/table-column-select/index.js +7 -0
- package/packages/components/table-column-select/src/table-column-select.vue +101 -0
- package/packages/components/table-column-switch/config.js +55 -0
- package/packages/components/table-column-switch/index.js +7 -0
- package/packages/components/table-column-switch/src/table-column-switch.vue +82 -0
- package/packages/components/table-column-textarea/config.js +77 -0
- package/packages/components/table-column-textarea/index.js +7 -0
- package/packages/components/table-column-textarea/src/table-column-textarea.vue +56 -0
- package/packages/components/table-column-time-picker/config.js +62 -0
- package/packages/components/table-column-time-picker/index.js +7 -0
- package/packages/components/table-column-time-picker/src/table-column-time-picker.vue +53 -0
- package/packages/components/upload/index.js +7 -0
- package/packages/components/upload/src/fast-upload.vue +272 -0
- package/packages/global.d.ts +42 -0
- package/packages/index.js +145 -0
- package/packages/mixins/table-column.js +133 -0
- package/packages/mixins/upload.js +14 -0
- package/packages/model/cond.js +74 -0
- package/packages/model/editComponentConfig.js +72 -0
- package/packages/model/fastTableOption.js +769 -0
- package/packages/model/filterComponentConfig.js +191 -0
- package/packages/model/opt.js +21 -0
- package/packages/model/order.js +37 -0
- package/packages/model/pageQuery.js +52 -0
- package/packages/model/query.js +161 -0
- package/packages/model/rel.js +5 -0
- package/packages/style.scss +5 -0
- package/packages/util/cache.js +92 -0
- package/packages/util/dialog.js +133 -0
- package/packages/util/escape.js +34 -0
- package/packages/util/http.js +18 -0
- package/packages/util/pick.js +92 -0
- package/packages/util/util.js +892 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import FastCheckboxGroup from "./components/checkbox-group";
|
|
2
|
+
import FastCellContent from "./components/content-dialog/src/fast-cell-content.vue";
|
|
3
|
+
import FastJsonViewer from "./components/json-viewer/src/fast-json-viewer.vue";
|
|
4
|
+
import FastSelect from "./components/select";
|
|
5
|
+
import FastUpload from "./components/upload";
|
|
6
|
+
import FastObjectPicker from './components/object-picker'
|
|
7
|
+
import FastTable from './components/table'
|
|
8
|
+
import FastTableColumn from './components/table-column'
|
|
9
|
+
import FastTableColumnDatePicker from './components/table-column-date-picker'
|
|
10
|
+
import FastTableColumnImg from './components/table-column-img'
|
|
11
|
+
import FastTableColumnFile from './components/table-column-file'
|
|
12
|
+
import FastTableColumnInput from './components/table-column-input'
|
|
13
|
+
import FastTableColumnNumber from './components/table-column-number'
|
|
14
|
+
import FastTableColumnObject from './components/table-column-object'
|
|
15
|
+
import FastTableColumnSelect from './components/table-column-select'
|
|
16
|
+
import FastTableColumnSwitch from './components/table-column-switch'
|
|
17
|
+
import FastTableColumnTextarea from './components/table-column-textarea'
|
|
18
|
+
import FastTableColumnTimePicker from './components/table-column-time-picker'
|
|
19
|
+
import {openDialog} from "./util/dialog";
|
|
20
|
+
import {pick} from "./util/pick";
|
|
21
|
+
import "./style.scss"
|
|
22
|
+
import FastTableOption from "./model/fastTableOption.js";
|
|
23
|
+
import Opt from './model/opt.js'
|
|
24
|
+
import Cond from './model/cond.js'
|
|
25
|
+
import Order from './model/order.js'
|
|
26
|
+
import Query from './model/query.js'
|
|
27
|
+
import PageQuery from './model/pageQuery.js'
|
|
28
|
+
import {
|
|
29
|
+
isEmpty,
|
|
30
|
+
isString,
|
|
31
|
+
isNumber,
|
|
32
|
+
isArray,
|
|
33
|
+
ifBlank,
|
|
34
|
+
isFunction,
|
|
35
|
+
isObject,
|
|
36
|
+
isBoolean,
|
|
37
|
+
isNull,
|
|
38
|
+
isUndefined,
|
|
39
|
+
defaultIfEmpty,
|
|
40
|
+
defaultIfBlank,
|
|
41
|
+
camelCaseTo,
|
|
42
|
+
caseToCamel,
|
|
43
|
+
clear,
|
|
44
|
+
deepClone,
|
|
45
|
+
merge,
|
|
46
|
+
coverMerge
|
|
47
|
+
} from "./util/util";
|
|
48
|
+
|
|
49
|
+
const components = [
|
|
50
|
+
FastCheckboxGroup,
|
|
51
|
+
FastSelect,
|
|
52
|
+
FastUpload,
|
|
53
|
+
FastObjectPicker,
|
|
54
|
+
FastTable,
|
|
55
|
+
FastTableColumn,
|
|
56
|
+
FastTableColumnDatePicker,
|
|
57
|
+
FastTableColumnFile,
|
|
58
|
+
FastTableColumnImg,
|
|
59
|
+
FastTableColumnInput,
|
|
60
|
+
FastTableColumnNumber,
|
|
61
|
+
FastTableColumnObject,
|
|
62
|
+
FastTableColumnSelect,
|
|
63
|
+
FastTableColumnSwitch,
|
|
64
|
+
FastTableColumnTextarea,
|
|
65
|
+
FastTableColumnTimePicker
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
const directives = [
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
// 全局应用上下文
|
|
72
|
+
let globalAppContext = null
|
|
73
|
+
const install = function (app, opts = {}) {
|
|
74
|
+
globalAppContext = app._context // 保存上下文
|
|
75
|
+
if (opts.hasOwnProperty('$http')) {
|
|
76
|
+
FastTableOption.$http = opts.$http
|
|
77
|
+
}
|
|
78
|
+
if (opts.hasOwnProperty('$router')) {
|
|
79
|
+
FastTableOption.$router = opts.$router
|
|
80
|
+
}
|
|
81
|
+
components.forEach(component => {
|
|
82
|
+
app.component(component.name, component);
|
|
83
|
+
});
|
|
84
|
+
directives.forEach(directive => {
|
|
85
|
+
app.use(directive)
|
|
86
|
+
})
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const util = {
|
|
90
|
+
isEmpty,
|
|
91
|
+
isString,
|
|
92
|
+
isNumber,
|
|
93
|
+
isArray,
|
|
94
|
+
ifBlank,
|
|
95
|
+
isFunction,
|
|
96
|
+
isObject,
|
|
97
|
+
isBoolean,
|
|
98
|
+
isNull,
|
|
99
|
+
isUndefined,
|
|
100
|
+
defaultIfEmpty,
|
|
101
|
+
defaultIfBlank,
|
|
102
|
+
camelCaseTo,
|
|
103
|
+
caseToCamel,
|
|
104
|
+
clear,
|
|
105
|
+
deepClone,
|
|
106
|
+
merge,
|
|
107
|
+
coverMerge,
|
|
108
|
+
openDialog,
|
|
109
|
+
pick
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export {
|
|
113
|
+
FastCheckboxGroup,
|
|
114
|
+
FastCellContent,
|
|
115
|
+
FastJsonViewer,
|
|
116
|
+
FastSelect,
|
|
117
|
+
FastUpload,
|
|
118
|
+
FastObjectPicker,
|
|
119
|
+
FastTable,
|
|
120
|
+
FastTableColumn,
|
|
121
|
+
FastTableColumnDatePicker,
|
|
122
|
+
FastTableColumnFile,
|
|
123
|
+
FastTableColumnImg,
|
|
124
|
+
FastTableColumnInput,
|
|
125
|
+
FastTableColumnNumber,
|
|
126
|
+
FastTableColumnObject,
|
|
127
|
+
FastTableColumnSelect,
|
|
128
|
+
FastTableColumnSwitch,
|
|
129
|
+
FastTableColumnTextarea,
|
|
130
|
+
FastTableColumnTimePicker,
|
|
131
|
+
FastTableOption,
|
|
132
|
+
Opt,
|
|
133
|
+
PageQuery,
|
|
134
|
+
Query,
|
|
135
|
+
Order,
|
|
136
|
+
Cond,
|
|
137
|
+
util
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// 获取App上下文
|
|
141
|
+
export const getAppContext = () => globalAppContext
|
|
142
|
+
|
|
143
|
+
export default {
|
|
144
|
+
install
|
|
145
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import {colEditable} from "../components/table/src/util"
|
|
2
|
+
import FastTableHeadCell from "../components/table/src/table-head-cell.vue"
|
|
3
|
+
import FastCellContent from "../components/content-dialog/src/fast-cell-content.vue";
|
|
4
|
+
import {convertKeyFromCaseToCamel, replaceKey} from "../util/util.js";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
inject: ['openDynamicFilterForm', 'tableStyle', 'context'],
|
|
8
|
+
emits: ['change', 'focus', 'blur', 'input', 'clear'],
|
|
9
|
+
components: {FastTableHeadCell, FastCellContent},
|
|
10
|
+
props: {
|
|
11
|
+
prop: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
label: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true
|
|
18
|
+
},
|
|
19
|
+
// 值为Boolean且为true时, 则将单元格内容作为链接地址; 值为字符串其非空时,将值作为跳转地址,且以超链接的形式展示单元格内容, 并支持点击, 值支持路由地址、路由名、绝对地址
|
|
20
|
+
link: {
|
|
21
|
+
type: [Boolean, String],
|
|
22
|
+
default: () => false
|
|
23
|
+
},
|
|
24
|
+
// 以实现某一列不显示, 仍然可以参与生成筛选项
|
|
25
|
+
hidden: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: () => false
|
|
28
|
+
},
|
|
29
|
+
// 此列是否支持过滤. 若为false, 则简筛、快筛、动筛都将不支持。此优先级高于quickFilter和dynamicFilter
|
|
30
|
+
filter: {
|
|
31
|
+
type: [Boolean, Number],
|
|
32
|
+
default: () => true
|
|
33
|
+
},
|
|
34
|
+
// 此列是否支持快筛
|
|
35
|
+
quickFilter: {
|
|
36
|
+
type: [Boolean, Number],
|
|
37
|
+
default: () => false
|
|
38
|
+
},
|
|
39
|
+
quickFilterBlock: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: () => false
|
|
42
|
+
},
|
|
43
|
+
// 快筛更多配置: 解决筛选项级联问题
|
|
44
|
+
quickFilterConfig: Object, // {onChange: Function, onClick: Function}
|
|
45
|
+
// 此列是否支持动筛: 若为false, 则列头不可点击
|
|
46
|
+
dynamicFilter: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: () => true
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* 1.5.12 是否唯一, 若为true, 新增或更新时, 会校验此值的唯一性(前后端均校验)
|
|
52
|
+
*/
|
|
53
|
+
unique: {
|
|
54
|
+
type: Boolean,
|
|
55
|
+
default: () => false
|
|
56
|
+
},
|
|
57
|
+
// deprecated: 1.6.0
|
|
58
|
+
firstFilter: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: () => false
|
|
61
|
+
},
|
|
62
|
+
showOverflowTooltip: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
default: () => false
|
|
65
|
+
},
|
|
66
|
+
/**
|
|
67
|
+
* 显示的字符长度, 超长时会显示"...", 并支持弹窗预览完整信息
|
|
68
|
+
*/
|
|
69
|
+
showLength: {
|
|
70
|
+
type: Number,
|
|
71
|
+
default: () => Number.MAX_VALUE
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
data() {
|
|
75
|
+
let attrs = convertKeyFromCaseToCamel(this.$attrs, '-');
|
|
76
|
+
attrs = replaceKey(attrs, '_q')
|
|
77
|
+
attrs = replaceKey(attrs, '_e')
|
|
78
|
+
return {
|
|
79
|
+
columnProp: {
|
|
80
|
+
...attrs,
|
|
81
|
+
prop: this.prop,
|
|
82
|
+
label: this.label,
|
|
83
|
+
filter: this.filter,
|
|
84
|
+
dynamicFilter: this.dynamicFilter,
|
|
85
|
+
order: '' // '', 'asc', 'desc'
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
methods: {
|
|
90
|
+
/**
|
|
91
|
+
* 是否展示编辑模式
|
|
92
|
+
* @param fatRow
|
|
93
|
+
* @param column element原生列配置
|
|
94
|
+
* @param $index 当前行索引
|
|
95
|
+
* @returns {boolean}
|
|
96
|
+
*/
|
|
97
|
+
canEdit(fatRow, column, $index) {
|
|
98
|
+
return colEditable.call(this.context !== null && this.context !== undefined ? this.context : this, fatRow, column.property);
|
|
99
|
+
},
|
|
100
|
+
showLabel(fatRow) {
|
|
101
|
+
const {row, editRow, status} = fatRow;
|
|
102
|
+
return status === 'normal' ? row[this.prop] : editRow[this.prop];
|
|
103
|
+
},
|
|
104
|
+
headCellClick(column) {
|
|
105
|
+
if (this.filter !== false && this.dynamicFilter !== false) {
|
|
106
|
+
this.openDynamicFilterForm(this.columnProp)
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
// change事件上抛并触发验证
|
|
110
|
+
handleChange(val, scope) {
|
|
111
|
+
this.$emit('change', val, scope);
|
|
112
|
+
const {column, $index, row: {editRow, config}} = scope;
|
|
113
|
+
const {property} = column;
|
|
114
|
+
const ref = this.$refs[property + $index];
|
|
115
|
+
const {eventMethods: {valid} = {}, props} = config[property]
|
|
116
|
+
if (valid) {
|
|
117
|
+
valid(val, editRow, ref, props);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
handleFocus(event, scope) {
|
|
121
|
+
this.$emit('focus', event, scope)
|
|
122
|
+
},
|
|
123
|
+
handleBlur(event, scope) {
|
|
124
|
+
this.$emit('blur', event, scope)
|
|
125
|
+
},
|
|
126
|
+
handleInput(val, scope) {
|
|
127
|
+
this.$emit('input', val, scope);
|
|
128
|
+
},
|
|
129
|
+
handleClear(scope) {
|
|
130
|
+
this.$emit('clear', scope);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
onPreview: Function,
|
|
4
|
+
beforeRemove: Function,
|
|
5
|
+
onRemove: Function,
|
|
6
|
+
onSuccess: Function,
|
|
7
|
+
onError: Function,
|
|
8
|
+
onProgress: Function,
|
|
9
|
+
onChange: Function,
|
|
10
|
+
onExceed: Function,
|
|
11
|
+
beforeUpload: Function,
|
|
12
|
+
responseHandler: Function
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {assert, defaultIfBlank, isEmpty, isObject, isString} from "../util/util.js";
|
|
2
|
+
import Opt from "./opt.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {typeof Opt[keyof typeof Opt]} OptValue
|
|
6
|
+
*/
|
|
7
|
+
class Cond {
|
|
8
|
+
/**
|
|
9
|
+
* 字段名
|
|
10
|
+
* @type {string}
|
|
11
|
+
*/
|
|
12
|
+
col;
|
|
13
|
+
/**
|
|
14
|
+
* 操作符
|
|
15
|
+
* @type {OptValue}
|
|
16
|
+
*/
|
|
17
|
+
opt;
|
|
18
|
+
/**
|
|
19
|
+
* 值
|
|
20
|
+
* @type {object}
|
|
21
|
+
*/
|
|
22
|
+
val;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 构造函数
|
|
26
|
+
* @param col 字段
|
|
27
|
+
* @param opt {OptValue} 操作符,可以使用常量
|
|
28
|
+
* @param val 值
|
|
29
|
+
*/
|
|
30
|
+
constructor(col, opt, val) {
|
|
31
|
+
assert(isString(col) && !isEmpty(col), 'col必须为有效字符串')
|
|
32
|
+
assert(Object.values(Opt).indexOf(opt) > -1, `opt无效:${opt}`)
|
|
33
|
+
this.col = col;
|
|
34
|
+
this.opt = opt;
|
|
35
|
+
this.val = val;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 设置操作符
|
|
40
|
+
* @param opt {string}
|
|
41
|
+
* @return {Cond}
|
|
42
|
+
*/
|
|
43
|
+
setOpt(opt) {
|
|
44
|
+
this.opt = opt;
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 设置值
|
|
50
|
+
* @param val {object}
|
|
51
|
+
* @return {Cond}
|
|
52
|
+
*/
|
|
53
|
+
setVal(val) {
|
|
54
|
+
this.val = val;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 通过json构建一个Cond条件对象
|
|
60
|
+
* @param condJson {object} 条件的json
|
|
61
|
+
* @return {Cond}
|
|
62
|
+
*/
|
|
63
|
+
static build(condJson) {
|
|
64
|
+
if (condJson instanceof Cond) {
|
|
65
|
+
return condJson;
|
|
66
|
+
}
|
|
67
|
+
assert(isObject(condJson), 'cond不是json格式!')
|
|
68
|
+
const {col, opt = Opt.EQ, val} = condJson
|
|
69
|
+
assert(!isEmpty(col), 'cond格式不正确: 无col属性或其值为空!')
|
|
70
|
+
return new Cond(col, defaultIfBlank(opt, Opt.EQ), val);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default Cond
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {isEmpty, isFunction, isNull, isUndefined} from "../util/util.js";
|
|
2
|
+
import FastTableOption from "./fastTableOption.js";
|
|
3
|
+
import Opt from './opt.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 编辑组件配置
|
|
7
|
+
*/
|
|
8
|
+
class EditComponentConfig {
|
|
9
|
+
component;
|
|
10
|
+
col;
|
|
11
|
+
label;
|
|
12
|
+
props;
|
|
13
|
+
val;
|
|
14
|
+
editable; // 是否可编辑, true 表示可编辑, false表示不可编辑, insert-表示新增时可编辑, update-表示更新时可编辑. 默认为true.
|
|
15
|
+
type; // inline, form
|
|
16
|
+
eventMethods; // 组件事件触发时调用其中的方法,例如参数验证
|
|
17
|
+
|
|
18
|
+
constructor({component, col, label, props, val, eventMethods, type, unique, tableOption}) {
|
|
19
|
+
this.component = component;
|
|
20
|
+
this.col = col;
|
|
21
|
+
this.label = label;
|
|
22
|
+
const {editable, ...validProps} = props; // 移除props中的editable属性,避免editable对组件影响
|
|
23
|
+
this.props = validProps;
|
|
24
|
+
this.val = val;
|
|
25
|
+
this.editable = editable;
|
|
26
|
+
this.eventMethods = eventMethods;
|
|
27
|
+
this.type = type;
|
|
28
|
+
// 将unique转换为 props.rules一部分
|
|
29
|
+
if (unique !== false && (tableOption instanceof FastTableOption)) {
|
|
30
|
+
const pkField = tableOption.idField
|
|
31
|
+
const uniqueValidator = async (rule, value, callback, source, options) => {
|
|
32
|
+
if (isNull(value) || isUndefined(value)) {
|
|
33
|
+
return Promise.resolve()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const {getRow} = rule
|
|
37
|
+
if (!isFunction(getRow)) {
|
|
38
|
+
// 无法获取当前行
|
|
39
|
+
console.error('无法进行唯一性校验:无法获取当前记录完整数据')
|
|
40
|
+
return Promise.resolve()
|
|
41
|
+
}
|
|
42
|
+
const currentRow = getRow()
|
|
43
|
+
const pkVal = currentRow[pkField]
|
|
44
|
+
if (type === 'inline') {
|
|
45
|
+
if (isEmpty(tableOption.ref?.editRows)) {
|
|
46
|
+
return Promise.resolve()
|
|
47
|
+
}
|
|
48
|
+
const editRows = tableOption.ref.editRows.map(fatRow => fatRow.editRow)
|
|
49
|
+
const duplicates = editRows.filter(row => row[rule.field] === value && row[pkField] !== pkVal)
|
|
50
|
+
if (duplicates.length > 0) {
|
|
51
|
+
return Promise.reject(`【${label}】${value}已存在于其它编辑行`)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 后端唯一性校验
|
|
56
|
+
const result = await tableOption._exist([
|
|
57
|
+
{col: pkField, opt: Opt.NE, val: pkVal}, // 避免自身编辑时误报
|
|
58
|
+
{col: col, opt: Opt.EQ, val: value}
|
|
59
|
+
])
|
|
60
|
+
if (result) { // 表示存在
|
|
61
|
+
return Promise.reject(`【${label}】${value}已存在`)
|
|
62
|
+
}
|
|
63
|
+
return Promise.resolve()
|
|
64
|
+
}
|
|
65
|
+
props?.rules.push({
|
|
66
|
+
validator: uniqueValidator, trigger: 'blur'
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default EditComponentConfig
|