@netang/quasar 0.0.53 → 0.0.55

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 (115) hide show
  1. package/_docs/docs/.vuepress/client.js +39 -0
  2. package/_docs/docs/.vuepress/components/test.vue +23 -0
  3. package/_docs/docs/.vuepress/config.js +40 -0
  4. package/_docs/docs/.vuepress/configs/index.js +2 -0
  5. package/_docs/docs/.vuepress/configs/navbar/index.js +1 -0
  6. package/_docs/docs/.vuepress/configs/navbar/zh.js +16 -0
  7. package/_docs/docs/.vuepress/configs/sidebar/index.js +1 -0
  8. package/_docs/docs/.vuepress/configs/sidebar/zh.js +20 -0
  9. package/_docs/docs/.vuepress/public/css/index.css +3 -0
  10. package/_docs/docs/.vuepress/styles/index.scss +3 -0
  11. package/_docs/docs/components/field-table.md +63 -0
  12. package/_docs/docs/components/field-tree.md +1 -0
  13. package/{docs → _docs}/docs/index.md +0 -0
  14. package/{docs → _docs}/docs/utils/alert.md +0 -0
  15. package/{docs → _docs}/docs/utils/confirm.md +0 -0
  16. package/_docs/docs/utils/index.md +1 -0
  17. package/_docs/package.json +17 -0
  18. package/components/column-title/index.vue +2 -2
  19. package/components/data/index.vue +20 -23
  20. package/components/dialog/index.vue +26 -12
  21. package/components/dialog-table/index.vue +4 -2
  22. package/components/dragger/index.vue +3 -2
  23. package/components/drawer/index.vue +16 -9
  24. package/components/editor-code/index.vue +12 -5
  25. package/components/empty/index.vue +16 -1
  26. package/components/field-date/index.vue +48 -36
  27. package/components/field-table/index.vue +69 -43
  28. package/components/field-text/index.vue +6 -2
  29. package/components/field-tree/index.vue +40 -22
  30. package/components/input-number/index.vue +5 -4
  31. package/components/list-menu/index.vue +14 -2
  32. package/components/power-page/index.vue +10 -0
  33. package/components/private/components/index.js +7 -2
  34. package/components/private/components/move-to-tree/index.vue +7 -3
  35. package/components/private/edit-power-data/index.vue +92 -52
  36. package/components/private/table-visible-columns-button/index.vue +6 -2
  37. package/components/render/index.vue +21 -7
  38. package/components/search/index.vue +30 -2
  39. package/components/search-item/index.vue +24 -8
  40. package/components/select/index.vue +5 -2
  41. package/components/splitter/index.vue +13 -9
  42. package/components/table/index.vue +32 -5
  43. package/components/table-pagination/index.vue +0 -1
  44. package/components/table-splitter/index.vue +22 -3
  45. package/components/table-summary/index.vue +10 -3
  46. package/components/thumbnail/index.vue +16 -6
  47. package/components/toolbar/index.vue +0 -2
  48. package/components/uploader/index.vue +5 -2
  49. package/components/uploader-query/index.vue +48 -27
  50. package/components/value-format/index.vue +19 -12
  51. package/configs/area3.js +1 -0
  52. package/docs/404.html +33 -0
  53. package/docs/assets/404.html-60b35caa.js +1 -0
  54. package/docs/assets/404.html-d1e63d77.js +1 -0
  55. package/docs/assets/alert.html-568d4e94.js +1 -0
  56. package/docs/assets/alert.html-f5dbc3e9.js +1 -0
  57. package/docs/assets/app-8c3ae4de.js +6 -0
  58. package/docs/assets/back-to-top-8efcbe56.svg +1 -0
  59. package/docs/assets/confirm.html-7a1566f6.js +1 -0
  60. package/docs/assets/confirm.html-96f1b004.js +1 -0
  61. package/docs/assets/field-table.html-68d610b0.js +1 -0
  62. package/docs/assets/field-table.html-86cc3511.js +1 -0
  63. package/docs/assets/field-tree.html-45410c3c.js +1 -0
  64. package/docs/assets/field-tree.html-c98ac993.js +1 -0
  65. package/docs/assets/framework-204010b2.js +5 -0
  66. package/docs/assets/index.html-1695dd7c.js +1 -0
  67. package/docs/assets/index.html-65a4aa67.js +1 -0
  68. package/docs/assets/style-ac5a9aa6.css +1 -0
  69. package/docs/components/field-table.html +33 -0
  70. package/docs/components/field-tree.html +33 -0
  71. package/docs/index.html +33 -0
  72. package/docs/utils/alert.html +33 -0
  73. package/docs/utils/confirm.html +33 -0
  74. package/package.json +1 -1
  75. package/package2.json +30 -0
  76. package/store/index.js +3 -20
  77. package/utils/alert.js +3 -1
  78. package/utils/area.js +27 -14
  79. package/utils/arr.js +6 -2
  80. package/utils/auth.js +40 -35
  81. package/utils/bus.js +1 -1
  82. package/utils/config.js +42 -15
  83. package/utils/{confrim.js → confirm.js} +1 -1
  84. package/utils/copy.js +18 -0
  85. package/utils/dialog.js +7 -3
  86. package/utils/dict.js +5 -28
  87. package/utils/dictOptions.js +24 -0
  88. package/utils/form.js +6 -2
  89. package/utils/getData.js +21 -9
  90. package/utils/getFile.js +11 -5
  91. package/utils/getImage.js +23 -12
  92. package/utils/getTime.js +9 -4
  93. package/utils/index.js +61 -0
  94. package/utils/loading.js +3 -1
  95. package/utils/notify.js +1 -1
  96. package/utils/power.js +164 -118
  97. package/utils/previewImage.js +4 -2
  98. package/utils/price.js +12 -3
  99. package/utils/rule.js +5 -9
  100. package/utils/ruleValid.js +10 -0
  101. package/utils/search.js +81 -50
  102. package/utils/table.js +119 -87
  103. package/utils/timestamp.js +2 -2
  104. package/utils/toast.js +1 -1
  105. package/utils/tree.js +69 -46
  106. package/utils/uploader/qiniu.js +31 -15
  107. package/utils/uploader.js +87 -56
  108. package/utils/useAuth.js +12 -5
  109. package/utils/useRouter.js +16 -5
  110. package/utils/useUploader.js +0 -5
  111. package/docs/docs/.vuepress/config.js +0 -32
  112. package/docs/docs/components/field-table.md +0 -1
  113. package/docs/docs/components/field-tree.md +0 -1
  114. package/docs/package.json +0 -11
  115. package/utils/http.js +0 -251
package/store/index.js CHANGED
@@ -19,28 +19,11 @@ export const statePower = ref({
19
19
  menus: [],
20
20
  })
21
21
 
22
- // 角色数据
23
- export const stateRole = ref({
24
- // 角色权限版本
25
- v: null,
26
- // all id
27
- all: {},
28
- // 页面
29
- urls: {},
30
- // 按钮
31
- btns: {},
32
- // 菜单
33
- menus: [],
34
- })
35
-
36
22
  // 时间差
37
23
  export const stateTimeDiff = ref(0)
38
24
 
39
- // loading
40
- export const stateLoading = ref(false)
41
-
42
25
  // 网络是否在线
43
- export const stateOnLine = ref(navigator.onLine)
26
+ // export const stateOnLine = ref(navigator.onLine)
44
27
 
45
- // 管理员信息状态
46
- export const stateAdminUserInfo = ref(initAuthStore())
28
+ // 用户信息状态
29
+ export const stateUserInfo = ref(initAuthStore())
package/utils/alert.js CHANGED
@@ -3,8 +3,10 @@ import { Dialog } from 'quasar'
3
3
  /**
4
4
  * 提示框
5
5
  */
6
- $n.alert = function(params) {
6
+ function alert(params) {
7
7
  return Dialog.create(Object.assign({
8
8
  title: '提示',
9
9
  }, params))
10
10
  }
11
+
12
+ export default alert
package/utils/area.js CHANGED
@@ -1,3 +1,11 @@
1
+ import $n_cloneDeep from 'lodash/cloneDeep'
2
+ import $n_get from 'lodash/get'
3
+ import $n_isValidArray from '@netang/utils/isValidArray'
4
+ import $n_indexOf from '@netang/utils/indexOf'
5
+ import $n_toTree from '@netang/utils/toTree'
6
+ import $n_trimString from '@netang/utils/trimString'
7
+ import $n_replaceAll from '@netang/utils/replaceAll'
8
+
1
9
  // 地址数据缓存
2
10
  let _areaData = null
3
11
 
@@ -5,7 +13,7 @@ let _areaData = null
5
13
  * 获取数据
6
14
  */
7
15
  function getData(level = 3, params) {
8
- return _getData(() => import('@/configs/area3'), level, params)
16
+ return _getData(() => import('../configs/area3'), level, params)
9
17
  }
10
18
  function _getData(areaData, level, params) {
11
19
  return new Promise(function(resolve) {
@@ -19,14 +27,14 @@ function _getData(areaData, level, params) {
19
27
  }, params)
20
28
 
21
29
  // 克隆树数据
22
- const treeData = $n.cloneDeep(_areaData)
30
+ const treeData = $n_cloneDeep(_areaData)
23
31
  const all = {}
24
32
  const rows = []
25
33
 
26
34
  // 是否有忽略省市区 id
27
- const isIgnore = $n.isValidArray(para.ignore)
35
+ const isIgnore = $n_isValidArray(para.ignore)
28
36
  function checkIgnore(id) {
29
- return isIgnore && $n.indexOf(para.ignore, id) > -1
37
+ return isIgnore && $n_indexOf(para.ignore, id) > -1
30
38
  }
31
39
 
32
40
  // 省
@@ -45,7 +53,7 @@ function _getData(areaData, level, params) {
45
53
  }
46
54
 
47
55
  // 市
48
- if (level > 1 && $n.isValidArray(item1[2])) {
56
+ if (level > 1 && $n_isValidArray(item1[2])) {
49
57
 
50
58
  for (let index2 = 0, len2 = item1[2].length; index2 < len2; index2++) {
51
59
  const item2 = item1[2][index2]
@@ -64,7 +72,7 @@ function _getData(areaData, level, params) {
64
72
  item1[2][index2] = all[item2[1]]
65
73
 
66
74
  // 区
67
- if (level > 2 && $n.isValidArray(item2[2])) {
75
+ if (level > 2 && $n_isValidArray(item2[2])) {
68
76
  for (let index3 = 0, len3 = item2[2].length; index3 < len3; index3++) {
69
77
  const item3 = item2[2][index3]
70
78
 
@@ -90,7 +98,7 @@ function _getData(areaData, level, params) {
90
98
  rows.push(all[key])
91
99
  }
92
100
 
93
- resolve($n.toTree({
101
+ resolve($n_toTree({
94
102
  data: rows,
95
103
  }))
96
104
  }
@@ -112,7 +120,7 @@ function _getData(areaData, level, params) {
112
120
  * 替换地址
113
121
  */
114
122
  function replaceArea(val) {
115
- val = $n.trimString(val)
123
+ val = $n_trimString(val)
116
124
  return val.replace(/直辖市/g, '')
117
125
  .replace(/市/g, '')
118
126
  .replace(/区/g, '')
@@ -166,7 +174,7 @@ async function getInfo(params) {
166
174
  const { attrs, nodes, tree } = areaData
167
175
 
168
176
  // 先通过地区编码来查找
169
- let data = $n.get(nodes, code)
177
+ let data = $n_get(nodes, code)
170
178
 
171
179
  // 如果没有找到, 则通过文字来查找
172
180
  if (! data) {
@@ -184,19 +192,19 @@ async function getInfo(params) {
184
192
  children: children1,
185
193
  } = item1
186
194
 
187
- const _text1 = $n.replaceAll(text1, '省', '')
195
+ const _text1 = $n_replaceAll(text1, '省', '')
188
196
 
189
197
  if (
190
198
  isAreaText ?
191
199
  (
192
200
  provinceText === text1
193
- || $n.replaceAll(provinceText, '省', '') === _text1
201
+ || $n_replaceAll(provinceText, '省', '') === _text1
194
202
  )
195
203
  : regionText.indexOf(_text1) > -1
196
204
  ) {
197
205
 
198
206
  // 获取市 start --------------------------------------------------
199
- if ($n.isValidArray(children1)) {
207
+ if ($n_isValidArray(children1)) {
200
208
 
201
209
  for (const item2 of children1) {
202
210
 
@@ -216,7 +224,7 @@ async function getInfo(params) {
216
224
  : regionText.indexOf(_text2) > -1
217
225
  ) {
218
226
  // 获取区 start --------------------------------------------------
219
- if ($n.isValidArray(children2)) {
227
+ if ($n_isValidArray(children2)) {
220
228
 
221
229
  if (areaText || regionText) {
222
230
 
@@ -379,9 +387,14 @@ async function getInfo(params) {
379
387
  return res
380
388
  }
381
389
 
382
- $n.area = {
390
+ /**
391
+ * 地区
392
+ */
393
+ const area = {
383
394
  // 获取数据
384
395
  getData,
385
396
  // 获取详情
386
397
  getInfo,
387
398
  }
399
+
400
+ export default area
package/utils/arr.js CHANGED
@@ -1,14 +1,16 @@
1
+ import $n_isFunction from 'lodash/isFunction'
2
+
1
3
  /*
2
4
  * 操作数组
3
5
  */
4
- $n.arr = {
6
+ const arr = {
5
7
 
6
8
  /**
7
9
  * 增加
8
10
  */
9
11
  add(children, index, newItem) {
10
12
  if (Array.isArray(children)) {
11
- children.splice(index + 1, 0, $n.isFunction(newItem) ? newItem() : newItem)
13
+ children.splice(index + 1, 0, $n_isFunction(newItem) ? newItem() : newItem)
12
14
  }
13
15
  },
14
16
 
@@ -45,3 +47,5 @@ $n.arr = {
45
47
  }
46
48
  },
47
49
  }
50
+
51
+ export default arr
package/utils/auth.js CHANGED
@@ -1,13 +1,16 @@
1
- import { useRouter } from 'vue-router'
1
+ import $n_router from '@netang/vue-utils/router'
2
2
 
3
- import { stateAdminUserInfo } from '../store'
4
- import { checkAdminUserInfo } from './useAuth'
3
+ import $n_isValidObject from '@netang/utils/isValidObject'
4
+ import $n_cookie from '@netang/utils/cookie'
5
+
6
+ import { stateUserInfo } from '../store'
7
+ import { checkUserInfo } from './useAuth'
5
8
 
6
9
  /**
7
10
  * 是否登录
8
11
  */
9
12
  function isLogin() {
10
- return stateAdminUserInfo.value.isLogin
13
+ return stateUserInfo.value.isLogin
11
14
  }
12
15
 
13
16
  /**
@@ -21,37 +24,37 @@ function updateLogin(res) {
21
24
  i,
22
25
  // 鉴权认证
23
26
  t,
24
- // 管理员基础信息
25
- admin_user_info,
27
+ // 用户基础信息
28
+ user_info,
26
29
  } = res
27
30
 
28
- // 更新管理员信息
29
- return _updateAdminUserInfo({
31
+ // 更新用户信息
32
+ return _updateUserInfo({
30
33
  id: i,
31
34
  token: t,
32
- info: $n.isValidObject(admin_user_info) ? admin_user_info : {},
35
+ info: $n_isValidObject(user_info) ? user_info : {},
33
36
  })
34
37
  }
35
38
 
36
39
  /**
37
- * 更新管理员信息
40
+ * 更新用户信息
38
41
  */
39
- function updateAdminUserInfo(res) {
40
- return _updateAdminUserInfo(Object.assign(
42
+ function updateUserInfo(res) {
43
+ return _updateUserInfo(Object.assign(
41
44
  {},
42
- stateAdminUserInfo.value,
45
+ stateUserInfo.value,
43
46
  res,
44
47
  ))
45
48
  }
46
- function _updateAdminUserInfo(res) {
49
+ function _updateUserInfo(res) {
47
50
 
48
- // 验证管理员信息
49
- if (! checkAdminUserInfo(res)) {
51
+ // 验证用户信息
52
+ if (! checkUserInfo(res)) {
50
53
 
51
54
  // 【调试模式】
52
55
  // --------------------------------------------------
53
56
  // #ifdef IS_DEBUG
54
- console.error('【验证错误 _updateAdminUserInfo】', valRes)
57
+ console.error('【验证错误 _updateUserInfo】', res)
55
58
  // #endif
56
59
  // --------------------------------------------------
57
60
 
@@ -61,38 +64,38 @@ function _updateAdminUserInfo(res) {
61
64
  // 设置已登录
62
65
  res.isLogin = true
63
66
 
64
- if (! $n.isValidObject(res.info)) {
67
+ if (! $n_isValidObject(res.info)) {
65
68
  res.info = {}
66
69
  }
67
70
 
68
71
  // 保存缓存(永久缓存)
69
- $n.cookie.set('_tk', res, 0)
72
+ $n_cookie.set('_tk', res, 0)
70
73
 
71
- // 设置管理员信息状态
72
- stateAdminUserInfo.value = res
74
+ // 设置用户信息状态
75
+ stateUserInfo.value = res
73
76
 
74
77
  return true
75
78
  }
76
79
 
77
80
  /**
78
- * 获取管理员数据
81
+ * 获取用户信息
79
82
  */
80
- function getAdminUserInfo() {
81
- return stateAdminUserInfo.value
83
+ function getUserInfo() {
84
+ return stateUserInfo.value
82
85
  }
83
86
 
84
87
  /**
85
- * 获取管理员 id
88
+ * 获取用户 id
86
89
  */
87
90
  function getAdminUserId() {
88
- return isLogin() ? stateAdminUserInfo.value.id : 0
91
+ return isLogin() ? stateUserInfo.value.id : 0
89
92
  }
90
93
 
91
94
  /**
92
95
  * 跳转登录页面
93
96
  */
94
97
  function pushLogin(query) {
95
- $n.router.push({
98
+ $n_router.push({
96
99
  path: 'login',
97
100
  query,
98
101
  })
@@ -104,10 +107,10 @@ function pushLogin(query) {
104
107
  function logout() {
105
108
 
106
109
  // 删除管理员信息
107
- $n.cookie.delete('_tk')
110
+ $n_cookie.delete('_tk')
108
111
 
109
- // 清空管理员信息状态
110
- stateAdminUserInfo.value = {
112
+ // 清空用户信息状态
113
+ stateUserInfo.value = {
111
114
  id: 0,
112
115
  isLogin: false,
113
116
  info: {},
@@ -117,15 +120,15 @@ function logout() {
117
120
  /**
118
121
  * 鉴权业务
119
122
  */
120
- $n.auth = {
123
+ const auth = {
121
124
  // 是否登录
122
125
  isLogin,
123
126
  // 登录后更新数据
124
127
  updateLogin,
125
- // 更新管理员信息
126
- updateAdminUserInfo,
127
- // 获取管理员数据
128
- getAdminUserInfo,
128
+ // 更新用户信息
129
+ updateUserInfo,
130
+ // 获取用户信息
131
+ getUserInfo,
129
132
  // 获取管理员 id
130
133
  getAdminUserId,
131
134
  // 跳转登录页面
@@ -133,3 +136,5 @@ $n.auth = {
133
136
  // 退出登录
134
137
  logout,
135
138
  }
139
+
140
+ export default auth
package/utils/bus.js CHANGED
@@ -3,4 +3,4 @@ import { EventBus } from 'quasar'
3
3
  /**
4
4
  * 事件总线
5
5
  */
6
- $n.bus = new EventBus()
6
+ export default new EventBus()
package/utils/config.js CHANGED
@@ -1,22 +1,49 @@
1
- import configData from '@/configs/production.json'
1
+ import $n_get from 'lodash/get'
2
+ import $n_merge from 'lodash/merge'
2
3
 
3
- // 【开发模式】
4
- // --------------------------------------------------
5
- // #if IS_DEBUG && IS_DEV
6
- import configDataDev from '@/configs/development.json'
7
- $n.merge(configData, configDataDev)
8
- // #endif
4
+ // 配置
5
+ export const configs = {
6
+ // api 请求公共数据地址
7
+ apiDataUrl: '',
8
+ // api 文件请求地址
9
+ apiFileUrl: '',
10
+ // 用户配置
11
+ userConfig: {},
12
+ // 用户字典
13
+ userDict: {},
14
+ // 字典变量
15
+ dicts: {},
16
+ // 自定义路由
17
+ routers: {},
18
+ // 表格配置
19
+ tablesConfig: {},
20
+ // 对话框组件
21
+ dialogComponents: {},
22
+ // 是否开启人民币分转元
23
+ priceCentToYuan: false,
24
+ // 上传器
25
+ uploader: {
26
+ upload: {},
27
+ limit: {
28
+ image: {
29
+ maxSize: 10,
30
+ exts: [ 'jpg', 'png', 'gif' ]
31
+ }
32
+ },
33
+ },
34
+ }
9
35
 
10
- // 【测试模式】
11
- // --------------------------------------------------
12
- // #if IS_DEBUG && IS_TEST
13
- import configDataTest from '@/configs/testing.json'
14
- $n.merge(configData, configDataTest)
15
- // #endif
36
+ /**
37
+ * 配置设置
38
+ * @param options
39
+ */
40
+ export function settings(options) {
41
+ $n_merge(configs, options)
42
+ }
16
43
 
17
44
  /**
18
45
  * 获取配置
19
46
  */
20
- $n.config = function(key = '', defaultValue = '') {
21
- return key ? $n.get(configData, key, defaultValue) : configData
47
+ export default function config(key = '', defaultValue = '') {
48
+ return key ? $n_get(configs.userConfig, key, defaultValue) : configs.userConfig
22
49
  }
@@ -3,7 +3,7 @@ import { Dialog } from 'quasar'
3
3
  /**
4
4
  * 确认框
5
5
  */
6
- $n.confirm = function(params) {
6
+ export default function confirm(params) {
7
7
  return Dialog.create(Object.assign({
8
8
  title: '提示',
9
9
  cancel: true,
package/utils/copy.js ADDED
@@ -0,0 +1,18 @@
1
+ import $n_copy from '@netang/utils/copy'
2
+
3
+ import $n_toast from './toast'
4
+
5
+ /**
6
+ * 复制
7
+ */
8
+ export default function copy(text, message) {
9
+ if (message) {
10
+ // 轻提示
11
+ $n_toast({
12
+ type: 'positive',
13
+ message,
14
+ })
15
+ }
16
+ // 复制
17
+ $n_copy(text)
18
+ }
package/utils/dialog.js CHANGED
@@ -1,3 +1,5 @@
1
+ import $n_has from 'lodash/has'
2
+
1
3
  import { inject } from 'vue'
2
4
  import { Dialog } from 'quasar'
3
5
 
@@ -10,9 +12,9 @@ import { NDialogKey } from './symbols'
10
12
  function create(params) {
11
13
  if (
12
14
  // 如果是路由组件
13
- $n.has(params, 'route')
15
+ $n_has(params, 'route')
14
16
  // 或自定义组件
15
- || $n.has(params, 'name')
17
+ || $n_has(params, 'name')
16
18
  ) {
17
19
  return Dialog.create({
18
20
  // 组件
@@ -35,9 +37,11 @@ function onInject() {
35
37
  /**
36
38
  * 对话框业务
37
39
  */
38
- $n.dialog = {
40
+ const dialog = {
39
41
  // 创建对话框
40
42
  create,
41
43
  // 获取对话框注入数据
42
44
  inject: onInject,
43
45
  }
46
+
47
+ export default dialog
package/utils/dict.js CHANGED
@@ -1,21 +1,16 @@
1
- import dictData from '@/configs/dict.json'
1
+ import $n_has from 'lodash/has'
2
2
 
3
- /**
4
- * 数据字典
5
- */
6
-
7
- // 设置字典数据
8
- $n.dictData = dictData
3
+ import { configs } from './config'
9
4
 
10
5
  /**
11
6
  * 获取字典值对应的文字
12
7
  */
13
- $n.dict = function(key, value, defaultValue = '') {
8
+ export default function dict(key, value, defaultValue = '') {
14
9
  if (
15
10
  key
16
- && $n.has(dictData, key)
11
+ && $n_has(configs.userDict, key)
17
12
  ) {
18
- for (const item of dictData[key]) {
13
+ for (const item of configs.userDict[key]) {
19
14
  if (item[1] === value) {
20
15
  return item[0]
21
16
  }
@@ -24,21 +19,3 @@ $n.dict = function(key, value, defaultValue = '') {
24
19
 
25
20
  return defaultValue
26
21
  }
27
-
28
- $n.dictOptions = function(key, textKey = 'label', valueKey = 'value') {
29
-
30
- const lists = []
31
-
32
- const dictItem = $n.get(dictData, key, [])
33
-
34
- for (const item of dictItem) {
35
-
36
- const val = {}
37
- val[textKey] = item[0]
38
- val[valueKey] = item[1]
39
-
40
- lists.push(val)
41
- }
42
-
43
- return lists
44
- }
@@ -0,0 +1,24 @@
1
+ import $n_get from 'lodash/get'
2
+
3
+ import { configs } from './config'
4
+
5
+ /**
6
+ * 数据字典选项
7
+ */
8
+ export default function dictOptions(key, textKey = 'label', valueKey = 'value') {
9
+
10
+ const lists = []
11
+
12
+ const dictItem = $n_get(configs.userDict, key, [])
13
+
14
+ for (const item of dictItem) {
15
+
16
+ const val = {}
17
+ val[textKey] = item[0]
18
+ val[valueKey] = item[1]
19
+
20
+ lists.push(val)
21
+ }
22
+
23
+ return lists
24
+ }
package/utils/form.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { ref, provide, inject } from 'vue'
2
2
 
3
+ import $n_has from 'lodash/has'
4
+
3
5
  import { NPowerKey, NFormKey } from './symbols'
4
6
 
5
7
  /**
@@ -18,7 +20,7 @@ function create(params) {
18
20
  }, params)
19
21
 
20
22
  // 获取权限注入
21
- const $power = $n.has(params, '$power') ? params.$power : inject(NPowerKey)
23
+ const $power = $n_has(params, '$power') ? params.$power : inject(NPowerKey)
22
24
 
23
25
  // ==========【返回】=================================================================================================
24
26
 
@@ -46,7 +48,9 @@ function create(params) {
46
48
  /**
47
49
  * 业务表单
48
50
  */
49
- $n.form = {
51
+ const form = {
50
52
  // 创建表单
51
53
  create,
52
54
  }
55
+
56
+ export default form
package/utils/getData.js CHANGED
@@ -1,19 +1,31 @@
1
1
  import { isRef } from 'vue'
2
2
 
3
+ import $n_isNil from 'lodash/isNil'
4
+ import $n_map from 'lodash/map'
5
+
6
+ import $n_http from '@netang/utils/http'
7
+
8
+ import { configs } from './config'
9
+
10
+ const {
11
+ // 请求公共数据地址
12
+ apiDataUrl,
13
+ } = configs
14
+
3
15
  /**
4
16
  * 获取公共数据
5
17
  */
6
- $n.getData = async function(url, pageStatus, emptyDescription, refValue) {
18
+ export default async function getData(url, pageStatus, emptyDescription, refValue) {
7
19
 
8
- const warn = $n.isNil(pageStatus) || ! isRef(pageStatus)
20
+ const warn = $n_isNil(pageStatus) || ! isRef(pageStatus)
9
21
 
10
22
  // 如果是数组, 说明需要同时请求多个地址
11
23
  // --------------------------------------------------
12
24
  if (Array.isArray(url)) {
13
25
 
14
- const result = await $n.http($n.map(url, function (item) {
26
+ const result = await $n_http($n_map(url, function (item) {
15
27
  return {
16
- url: $n.config('commonDataUrl') + item,
28
+ url: apiDataUrl + item,
17
29
  warn,
18
30
  }
19
31
  }))
@@ -25,7 +37,7 @@ $n.getData = async function(url, pageStatus, emptyDescription, refValue) {
25
37
  if (! warn) {
26
38
  pageStatus.value = false
27
39
  }
28
- if (! $n.isNil(emptyDescription) && isRef(emptyDescription)) {
40
+ if (! $n_isNil(emptyDescription) && isRef(emptyDescription)) {
29
41
  emptyDescription.value = data.msg
30
42
  }
31
43
  return false
@@ -38,22 +50,22 @@ $n.getData = async function(url, pageStatus, emptyDescription, refValue) {
38
50
 
39
51
  // 单个请求
40
52
  // --------------------------------------------------
41
- const { status, data } = await $n.http({
42
- url: $n.config('commonDataUrl') + url,
53
+ const { status, data } = await $n_http({
54
+ url: apiDataUrl + url,
43
55
  warn,
44
56
  })
45
57
  if (! status) {
46
58
  if (! warn) {
47
59
  pageStatus.value = false
48
60
  }
49
- if (! $n.isNil(emptyDescription) && isRef(emptyDescription)) {
61
+ if (! $n_isNil(emptyDescription) && isRef(emptyDescription)) {
50
62
  emptyDescription.value = data.msg
51
63
  }
52
64
  return false
53
65
  }
54
66
 
55
67
  // 直接设置 value
56
- if (! $n.isNil(refValue) && isRef(refValue)) {
68
+ if (! $n_isNil(refValue) && isRef(refValue)) {
57
69
  refValue.value = data
58
70
  }
59
71