@netang/quasar 0.1.86 → 0.1.88

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 +69 -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.88",
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,70 @@ 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: httpValue,
1207
+ data: httpData,
1208
+ } = Object.assign({
1209
+ field: 'id',
1210
+ value: [],
1211
+ data: {},
1212
+ }, options)
1213
+
1214
+ const _isValidValue = $n_isValidValue(httpValue)
1215
+ if (_isValidValue || $n_isValidArray(httpValue)) {
1216
+
1217
+ let per_page
1218
+ let value
1219
+ let compare
1220
+
1221
+ if (_isValidValue) {
1222
+ compare = dicts.SEARCH_COMPARE_TYPE__EQUAL
1223
+ value = httpValue
1224
+ per_page = 1
1225
+ } else {
1226
+ compare = dicts.SEARCH_COMPARE_TYPE__IN
1227
+ value = $n_uniq(httpValue)
1228
+ per_page = value.length
1229
+ }
1230
+
1231
+ const { status, data } = await $n_http({
1232
+ url,
1233
+ // 头部请求
1234
+ headers: {
1235
+ // 添加头部查看请求
1236
+ Pview: 1,
1237
+ },
1238
+ data: Object.assign({
1239
+ n_search: [
1240
+ {
1241
+ field,
1242
+ compare,
1243
+ value,
1244
+ },
1245
+ ],
1246
+ page: 1,
1247
+ per_page,
1248
+ }, httpData),
1249
+ })
1250
+
1251
+ if (
1252
+ status
1253
+ && $n_isValidArray($n.get(data, 'rows'))
1254
+ ) {
1255
+ return data.rows
1256
+ }
1257
+ }
1258
+
1259
+ return []
1260
+ }
1261
+
1196
1262
  /**
1197
1263
  * 业务表格
1198
1264
  */
@@ -1201,6 +1267,9 @@ const $table = {
1201
1267
  create,
1202
1268
  // 获取表格配置
1203
1269
  config,
1270
+
1271
+ // 获取表格浏览数据
1272
+ getViewData,
1204
1273
  }
1205
1274
 
1206
1275
  export default $table