shijiplus-web-plugin 0.1.16 → 0.1.18

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/README.md CHANGED
@@ -1,4 +1,5 @@
1
- # shijiplus-web-tool
1
+ # shijiplus-web-plugin
2
+
2
3
 
3
4
  ## Project setup
4
5
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shijiplus-web-plugin",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "files": [
5
5
  "src"
6
6
  ],
package/src/libs/util.js CHANGED
@@ -1,7 +1,78 @@
1
+
2
+ import { forEach, hasOneOf, oneOf, objEqual } from './tools'
3
+
1
4
  import { export_json_to_excel as exportJsonToExcel, exportJsonToExcelBlob } from './excel'
2
5
 
3
- export const hasChild = (item) => {
4
- return item.children && item.children.length !== 0
6
+
7
+ export const createBtn = (h, { props, directives, txt, callback, danger, style, icon }) => {
8
+ return h('Button', {
9
+ directives: directives,
10
+ style: style,
11
+ props: {
12
+ type: danger ? 'error' : 'primary',
13
+ size: 'small',
14
+ icon: icon,
15
+ ghost: true,
16
+ ...props
17
+ },
18
+ on: {
19
+ click: () => {
20
+ if (callback) {
21
+ callback()
22
+ }
23
+ }
24
+ }
25
+ }, txt)
26
+ }
27
+
28
+ export const btn = (h, txt, callback, danger) => {
29
+ return h('Button', {
30
+ props: {
31
+ type: danger ? 'error' : 'primary',
32
+ size: 'small',
33
+ ghost: true
34
+ },
35
+ on: {
36
+ click: () => {
37
+ callback()
38
+ }
39
+ }
40
+ }, txt)
41
+ }
42
+ /**
43
+ * @param {String} url
44
+ * @description 从URL中解析参数
45
+ */
46
+ export const getParams = url => {
47
+ const keyValueArr = url.split('?')[1].split('&')
48
+ let paramObj = {}
49
+ keyValueArr.forEach(item => {
50
+ const keyValue = item.split('=')
51
+ paramObj[keyValue[0]] = keyValue[1]
52
+ })
53
+ return paramObj
54
+ }
55
+
56
+
57
+ /**
58
+ * 按属性名称和value搜索列表内容
59
+ * @param arr
60
+ * @param attrName
61
+ * @param attrVal
62
+ * @returns {null|*}
63
+ */
64
+ export const searchInObjArray = (arr, attrName, attrVal) => {
65
+ if (arr && attrName && attrVal) {
66
+ for (let i = 0; i < arr.length; ++i) {
67
+ if (arr[i] && arr[i][attrName] && arr[i][attrName] === attrVal) {
68
+ return arr[i]
69
+ }
70
+ }
71
+ let rtn = {}
72
+ rtn[attrName] = attrVal
73
+ return rtn
74
+ }
75
+ return null
5
76
  }
6
77
 
7
78
  export const exportTableExcelBlob = (tableData, tableColumn, fileName) => {