@netang/quasar 0.1.86 → 0.1.87

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 (2) hide show
  1. package/package.json +1 -1
  2. package/utils/$table.js +51 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netang/quasar",
3
- "version": "0.1.86",
3
+ "version": "0.1.87",
4
4
  "description": "netang-quasar",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
package/utils/$table.js CHANGED
@@ -51,6 +51,8 @@ import { NRenderKey, NPowerKey, NTableKey } from './symbols'
51
51
  const {
52
52
  // 表格配置
53
53
  tablesConfig,
54
+ // 字典常量
55
+ dicts,
54
56
  } = configs
55
57
 
56
58
  /**
@@ -1193,6 +1195,52 @@ function config(routePath, path, defaultValue) {
1193
1195
  return $n_cloneDeep($n_get(tablesConfig, $n_slash(routePath, 'start', false) + (path ? '.' + path : ''), defaultValue))
1194
1196
  }
1195
1197
 
1198
+ /**
1199
+ * 获取表格浏览数据
1200
+ */
1201
+ async function getViewData(options) {
1202
+
1203
+ const {
1204
+ url,
1205
+ field,
1206
+ value,
1207
+ } = Object.assign({
1208
+ field: 'id',
1209
+ value: [],
1210
+ }, options)
1211
+
1212
+ const _isValidValue = $n_isValidValue(value)
1213
+ if (_isValidValue || $n_isValidArray(value)) {
1214
+
1215
+ const { status, data } = await $n_http({
1216
+ url,
1217
+ // 头部请求
1218
+ headers: {
1219
+ // 添加头部查看请求
1220
+ Pview: 1,
1221
+ },
1222
+ data: {
1223
+ n_search: [
1224
+ {
1225
+ field,
1226
+ compare: _isValidValue ? dicts.SEARCH_COMPARE_TYPE__EQUAL : dicts.SEARCH_COMPARE_TYPE__IN,
1227
+ value: _isValidValue ? value : $n_uniq(value),
1228
+ },
1229
+ ],
1230
+ },
1231
+ })
1232
+
1233
+ if (
1234
+ status
1235
+ && $n_isValidArray($n.get(data, 'rows'))
1236
+ ) {
1237
+ return data.rows
1238
+ }
1239
+ }
1240
+
1241
+ return []
1242
+ }
1243
+
1196
1244
  /**
1197
1245
  * 业务表格
1198
1246
  */
@@ -1201,6 +1249,9 @@ const $table = {
1201
1249
  create,
1202
1250
  // 获取表格配置
1203
1251
  config,
1252
+
1253
+ // 获取表格浏览数据
1254
+ getViewData,
1204
1255
  }
1205
1256
 
1206
1257
  export default $table