@netang/quasar 0.0.95 → 0.0.96

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.
@@ -248,8 +248,6 @@ export default {
248
248
 
249
249
  // 请求路径
250
250
  path: String,
251
- // 请求地址(如果为空, 则默认为表格路由地址)
252
- url: String,
253
251
  // 请求参数
254
252
  query: Object,
255
253
  // 附加请求数据
@@ -298,7 +296,7 @@ export default {
298
296
  default: 500
299
297
  },
300
298
  // 自定义请求方法
301
- onRequest: Function,
299
+ request: Function,
302
300
  },
303
301
 
304
302
  /**
@@ -402,6 +400,19 @@ export default {
402
400
  },
403
401
  // 刷新后清空已选数据
404
402
  refreshResetSelected: false,
403
+ // 自定义请求方法
404
+ async request({ httpOptions }) {
405
+ return $n_isFunction(props.request) ?
406
+ // 如果有自定义请求方法
407
+ await $n_runAsync(props.request)({
408
+ // http 请求参数
409
+ httpOptions,
410
+ // 对话框是否已显示
411
+ showDialog: showDialog.value,
412
+ }) :
413
+ // 否则请求数据
414
+ await $n_http(httpOptions)
415
+ },
405
416
  })
406
417
 
407
418
  // 创建睡眠实例
@@ -747,8 +758,8 @@ export default {
747
758
  async function onRequestSelected(value) {
748
759
 
749
760
  // 请求参数
750
- const options = {
751
- url: props.url ?? $table.routePath,
761
+ const httpOptions = {
762
+ url: $table.routePath,
752
763
  data: Object.assign(
753
764
  // 获取表格请求数据
754
765
  $table.getTableRequestData({
@@ -777,16 +788,16 @@ export default {
777
788
  }
778
789
 
779
790
  // 请求数据
780
- const { status, data } = $n_isFunction(props.onRequest) ?
791
+ const { status, data } = $n_isFunction(props.request) ?
781
792
  // 如果有自定义请求方法
782
- await $n_runAsync(props.onRequest)({
783
- options,
784
- props,
785
- // 是否在对话框中
786
- inDialog: showDialog.value,
793
+ await $n_runAsync(props.request)({
794
+ // http 请求参数
795
+ httpOptions,
796
+ // 对话框是否已显示
797
+ showDialog: showDialog.value,
787
798
  }) :
788
799
  // 否则请求数据
789
- await $n_http(options)
800
+ await $n_http(httpOptions)
790
801
 
791
802
  return status && $n_isValidArray($n_get(data, 'rows')) ? data.rows : []
792
803
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netang/quasar",
3
- "version": "0.0.95",
3
+ "version": "0.0.96",
4
4
  "description": "netang-quasar",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
package/utils/$table.js CHANGED
@@ -55,7 +55,7 @@ const {
55
55
  /**
56
56
  * 创建表格
57
57
  */
58
- function create(params) {
58
+ function create(options) {
59
59
 
60
60
  // ==========【数据】=================================================================================================
61
61
 
@@ -130,10 +130,10 @@ function create(params) {
130
130
  rowClick: null,
131
131
  // 双击表格行事件
132
132
  rowDblClick: null,
133
- }, params)
133
+ }, options)
134
134
 
135
135
  // 获取权限注入
136
- const $power = $n_has(params, '$power') ? params.$power : inject(NPowerKey)
136
+ const $power = $n_has(options, '$power') ? options.$power : inject(NPowerKey)
137
137
  const hasPowr = !! $power
138
138
 
139
139
  // 获取渲染注入
@@ -718,36 +718,31 @@ function create(params) {
718
718
  }
719
719
  } = props
720
720
 
721
- // 获取表格请求数据
722
- const data = getTableRequestData(props, isRequestSummary)
723
-
724
- let result
725
-
726
- // 如果有自定义请求方法
727
- if ($n_isFunction(o.request)) {
728
- result = await $n_runAsync(o.request)({
729
- data,
721
+ // http 请求参数
722
+ const httpOptions = Object.assign({
723
+ // 请求数据
724
+ url: $route.path,
725
+ // 请求数据
726
+ data: getTableRequestData(props, isRequestSummary),
727
+ // ~~~~~~ 先开启防抖, 如果后期遇到表格加载不出来的情况, 再关闭防抖
728
+ // 关闭防抖(允许重复请求)
729
+ // debounce: false,
730
+ }, o.httpSettings)
731
+
732
+ const { status, data: res } = $n_isFunction(o.request)
733
+ // 如果有自定义请求方法
734
+ ? await $n_runAsync(o.request)({
735
+ // http 请求参数
736
+ httpOptions,
737
+ // 表格声明属性
730
738
  props,
739
+ // 表格行数据
731
740
  rows: tableRows,
741
+ // 表格已选数据
732
742
  selected: tableSelected,
733
743
  })
734
-
735
- // 否则请求服务器
736
- } else {
737
- const opts = Object.assign({
738
- // 请求数据
739
- url: $route.path,
740
- // 请求数据
741
- data,
742
- // ~~~~~~ 先开启防抖, 如果后期遇到表格加载不出来的情况, 再关闭防抖
743
- // 关闭防抖(允许重复请求)
744
- // debounce: false,
745
- }, o.httpSettings)
746
-
747
- result = await $n_http(opts)
748
- }
749
-
750
- const { status, data: res } = result
744
+ // 否则请求服务器
745
+ : await $n_http(httpOptions)
751
746
 
752
747
  // 请求成功
753
748
  if (status) {