sh-view 2.9.23 → 2.10.0
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/package.json +3 -3
- package/packages/components/sh-form/js/useForm.js +10 -0
- package/packages/components/sh-table/js/tableMethods.js +4 -0
- package/packages/components/sh-table/js/useTable.js +9 -0
- package/packages/index.js +4 -4
- package/packages/vxeTable/index.js +23 -20
- package/packages/vxeTable/render/globalRenders.jsx +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sh-view",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"description": "基于vxe-table二次封装,更包含Alert,Badge,Card,CodeEditor,Col,Corner,CountTo,Drawer,Empty,Form,Header,Icon,List,Loading,Modal,Noticebar,Poptip,Progress,PullRefresh,Query,Result,Row,Split,Grid,Table,Tabs,Tag,Toolbar,Tree,Upload,WaterFall,WaterMark等丰富组件库",
|
|
5
5
|
"main": "packages/index.js",
|
|
6
6
|
"typings": "types/index.d.ts",
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"jszip": "^3.10.1",
|
|
37
37
|
"lunar-typescript": "^1.6.10",
|
|
38
38
|
"popper.js": "^1.16.1",
|
|
39
|
-
"sh-tools": "^2.
|
|
39
|
+
"sh-tools": "^2.3.0",
|
|
40
40
|
"vue": "^3.5.20",
|
|
41
41
|
"vue-masonry": "^0.16.0",
|
|
42
42
|
"vue-router": "^4.5.1",
|
|
43
43
|
"vxe-pc-ui": "^4.11.24",
|
|
44
|
-
"vxe-table": "^4.17.
|
|
44
|
+
"vxe-table": "^4.17.38"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@typescript-eslint/eslint-plugin": "^6.9.0",
|
|
@@ -92,6 +92,15 @@ export default function (props, context, proxy, isForm) {
|
|
|
92
92
|
const validate = callback => {
|
|
93
93
|
return formRef.value.validate(callback)
|
|
94
94
|
}
|
|
95
|
+
// 表单验证抛异常
|
|
96
|
+
const validateCatch = async callback => {
|
|
97
|
+
return formRef.value.validate(callback)
|
|
98
|
+
let validateResult = await formRef.value.validate(callback)
|
|
99
|
+
if (validateResult) {
|
|
100
|
+
return Promise.reject(validateResult)
|
|
101
|
+
}
|
|
102
|
+
return Promise.resolve()
|
|
103
|
+
}
|
|
95
104
|
// 初始化表单项
|
|
96
105
|
const initFormItems = () => {
|
|
97
106
|
let formItemsArr = props.items
|
|
@@ -211,6 +220,7 @@ export default function (props, context, proxy, isForm) {
|
|
|
211
220
|
formCollapsed,
|
|
212
221
|
formToggleBtnShow,
|
|
213
222
|
validate,
|
|
223
|
+
validateCatch,
|
|
214
224
|
formBtnCollapsed,
|
|
215
225
|
onFormSubmit,
|
|
216
226
|
onFormSubmitInvalid,
|
|
@@ -128,10 +128,14 @@ export const turnColumnItemFilters = (column, props) => {
|
|
|
128
128
|
// 转换表头校验规则
|
|
129
129
|
export const getFieldRules = (ori, rules) => {
|
|
130
130
|
if (isTrue(ori['renderRequire'])) {
|
|
131
|
+
let propsType = $vUtils.get(ori, 'renderProps.type')
|
|
131
132
|
let dataType = 'string'
|
|
132
133
|
let arrayType = ['$vCheckgroup', '$vUpload', '$vTable']
|
|
134
|
+
let numberType = ['$vProgress', '$vMoney']
|
|
133
135
|
if (arrayType.includes(ori['renderName']) || (['$vSelect', '$vTree'].includes(ori['renderName']) && isTrue(ori.renderProps?.multiple))) {
|
|
134
136
|
dataType = 'array'
|
|
137
|
+
} else if (numberType.includes(ori['renderName']) || ['number', 'integer', 'float'].includes(propsType)) {
|
|
138
|
+
dataType = 'number'
|
|
135
139
|
}
|
|
136
140
|
let defaultRuleOption = { message: getDefaultMessage(ori['renderName'], ori['title']), type: dataType, trigger: 'blur' }
|
|
137
141
|
let fieldRules = [{ required: true, ...defaultRuleOption }]
|
|
@@ -514,6 +514,14 @@ export default function (props, context, proxy, isGrid) {
|
|
|
514
514
|
const validate = (rows = true) => {
|
|
515
515
|
return tableRef.value.validate(rows)
|
|
516
516
|
}
|
|
517
|
+
// 表格验证抛异常
|
|
518
|
+
const validateCatch = async (rows = true) => {
|
|
519
|
+
let validateResult = await tableRef.value.validate(rows)
|
|
520
|
+
if (validateResult) {
|
|
521
|
+
return Promise.reject(validateResult)
|
|
522
|
+
}
|
|
523
|
+
return Promise.resolve()
|
|
524
|
+
}
|
|
517
525
|
// 刷新表格视图
|
|
518
526
|
const refreshRender = data => {
|
|
519
527
|
return tableRef.value.reloadData(data || props.dataSourse)
|
|
@@ -710,6 +718,7 @@ export default function (props, context, proxy, isGrid) {
|
|
|
710
718
|
setImportData,
|
|
711
719
|
refreshRender,
|
|
712
720
|
validate,
|
|
721
|
+
validateCatch,
|
|
713
722
|
getSelectionData,
|
|
714
723
|
getFullData,
|
|
715
724
|
handleTableAddRow,
|
package/packages/index.js
CHANGED
|
@@ -16,7 +16,7 @@ const install = function (root, option = {}) {
|
|
|
16
16
|
root.use(components, option)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
const
|
|
19
|
+
const ShView = {
|
|
20
20
|
name: packageConfig.name,
|
|
21
21
|
version: packageConfig.version,
|
|
22
22
|
install
|
|
@@ -27,10 +27,10 @@ let defaultBg = 'padding: 5px; color: #111; background: #f5f7f9; font-weight: bo
|
|
|
27
27
|
let tagBg1 = 'padding: 5px; color: #fff; background: #8e2eff; font-weight: bold;'
|
|
28
28
|
let tagBg2 = 'padding: 5px; color: #333; background: #ffee2e; font-weight: bold;'
|
|
29
29
|
if ((window.navigator.language || window.navigator.browserLanguage).toLowerCase() === 'zh-cn') {
|
|
30
|
-
consInfo = `%c由%c${
|
|
30
|
+
consInfo = `%c由%c${ShView.name}%c提供技术支持,版本%c${ShView.version}%c`
|
|
31
31
|
} else {
|
|
32
|
-
consInfo = `%cPowered by%c${
|
|
32
|
+
consInfo = `%cPowered by%c${ShView.name}%c,version%c${ShView.version}%c`
|
|
33
33
|
}
|
|
34
34
|
console.info(consInfo, defaultBg, tagBg1, defaultBg, tagBg2, defaultBg)
|
|
35
35
|
|
|
36
|
-
export default
|
|
36
|
+
export default ShView
|
|
@@ -286,26 +286,8 @@ VXETable.renderer.mixin(filterRenders)
|
|
|
286
286
|
// 便捷化全局提示
|
|
287
287
|
const statusList = ['info', 'success', 'warning', 'error']
|
|
288
288
|
const vModal = VXEUI.modal
|
|
289
|
-
let vMessage = {
|
|
290
|
-
confirm: options => {
|
|
291
|
-
return new Promise(async resolve => {
|
|
292
|
-
let opts = Object.assign({}, uiOptions.message, typeof options === 'string' ? { content: options } : options)
|
|
293
|
-
let type = await vModal.confirm({ showHeader: Boolean(opts.title), ...opts })
|
|
294
|
-
if (type === 'confirm') resolve(type)
|
|
295
|
-
})
|
|
296
|
-
}
|
|
297
|
-
}
|
|
289
|
+
let vMessage = {}
|
|
298
290
|
let vNotice = {}
|
|
299
|
-
statusList.forEach(status => {
|
|
300
|
-
vMessage[status] = options => {
|
|
301
|
-
let opts = Object.assign({ status }, uiOptions.message, typeof options === 'string' ? { content: options } : options)
|
|
302
|
-
return vModal.message(opts)
|
|
303
|
-
}
|
|
304
|
-
vNotice[status] = options => {
|
|
305
|
-
let opts = Object.assign({ status }, uiOptions.message, typeof options === 'string' ? { content: options } : options)
|
|
306
|
-
return vModal.notification(opts)
|
|
307
|
-
}
|
|
308
|
-
})
|
|
309
291
|
|
|
310
292
|
const index = {
|
|
311
293
|
install(Vue, { uiOption, tableOption, pdfOption, xlsxOption, menuOption, editorOption }) {
|
|
@@ -324,6 +306,24 @@ const index = {
|
|
|
324
306
|
Vue.use(VXEUI)
|
|
325
307
|
Vue.use(VXETable)
|
|
326
308
|
|
|
309
|
+
vMessage.confirm = options => {
|
|
310
|
+
return new Promise(async resolve => {
|
|
311
|
+
let opts = Object.assign({}, vuiOption.message, typeof options === 'string' ? { content: options } : options)
|
|
312
|
+
let type = await vModal.confirm({ showHeader: Boolean(opts.title), ...opts })
|
|
313
|
+
if (type === 'confirm') resolve(type)
|
|
314
|
+
})
|
|
315
|
+
}
|
|
316
|
+
statusList.forEach(status => {
|
|
317
|
+
vMessage[status] = options => {
|
|
318
|
+
let opts = Object.assign({ status }, vuiOption.message, typeof options === 'string' ? { content: options } : options)
|
|
319
|
+
return vModal.message(opts)
|
|
320
|
+
}
|
|
321
|
+
vNotice[status] = options => {
|
|
322
|
+
let opts = Object.assign({ status }, vuiOption.message, typeof options === 'string' ? { content: options } : options)
|
|
323
|
+
return vModal.notification(opts)
|
|
324
|
+
}
|
|
325
|
+
})
|
|
326
|
+
|
|
327
327
|
Vue.config.globalProperties.$vUtils = utils
|
|
328
328
|
Vue.config.globalProperties.$vModal = vModal
|
|
329
329
|
Vue.config.globalProperties.$vMessage = vMessage
|
|
@@ -333,6 +333,9 @@ const index = {
|
|
|
333
333
|
Vue.config.globalProperties.$vUiSetup = vuiOption
|
|
334
334
|
Vue.config.globalProperties.$vTableSetup = vtableOption
|
|
335
335
|
Vue.config.globalProperties.$vxePluginNames = publicRendersNames
|
|
336
|
-
}
|
|
336
|
+
},
|
|
337
|
+
vModal,
|
|
338
|
+
vMessage,
|
|
339
|
+
vNotice
|
|
337
340
|
}
|
|
338
341
|
export default index
|
|
@@ -271,8 +271,8 @@ const extraRenders = {
|
|
|
271
271
|
},
|
|
272
272
|
renderEdit(renderOpts, params) {
|
|
273
273
|
let field = params.row[params.column.property + 'field'] || params.column.property
|
|
274
|
-
let renderName = params.row[field + 'RenderName'] || ''
|
|
275
|
-
return
|
|
274
|
+
let renderName = params.row[field + 'RenderName'] || '$vInput'
|
|
275
|
+
return publicRenders[renderName].renderEdit(renderOpts, params)
|
|
276
276
|
},
|
|
277
277
|
renderItemContent(renderOpts, params) {
|
|
278
278
|
let field = params.data[params.property + 'field'] || params.property
|