adtec-core-package 0.8.5 → 0.8.6
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
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ElMessage } from 'element-plus'
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Create by丁盼
|
|
3
5
|
* 说明: tableTool
|
|
@@ -7,20 +9,28 @@
|
|
|
7
9
|
export default {
|
|
8
10
|
/**
|
|
9
11
|
* 校验表格数据是否为空
|
|
10
|
-
* @param table
|
|
12
|
+
* @param table 表格对象
|
|
13
|
+
* @param rules 校验规则
|
|
11
14
|
*/
|
|
12
|
-
validateTableData(table: any): Boolean {
|
|
15
|
+
validateTableData(table: any,rules:any): Boolean {
|
|
13
16
|
try {
|
|
14
|
-
table.data.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (!row[
|
|
18
|
-
|
|
17
|
+
const data=table.value?table.value.data:table.data
|
|
18
|
+
data.forEach((row: any,index:number) => {
|
|
19
|
+
for(let v in rules){
|
|
20
|
+
if (!row[v]) {
|
|
21
|
+
let msg=rules[v].message
|
|
22
|
+
if(msg){
|
|
23
|
+
msg=msg.replace('{index}',index+1)
|
|
24
|
+
}
|
|
25
|
+
throw new Error(msg)
|
|
19
26
|
}
|
|
20
|
-
}
|
|
27
|
+
}
|
|
21
28
|
})
|
|
22
29
|
return true
|
|
23
|
-
} catch (e) {
|
|
30
|
+
} catch (e:any) {
|
|
31
|
+
if(e.message) {
|
|
32
|
+
ElMessage.error(e.message)
|
|
33
|
+
}
|
|
24
34
|
return false
|
|
25
35
|
}
|
|
26
36
|
},
|