xs-common-plugins 1.1.2 → 1.1.6

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 (139) hide show
  1. package/README.md +37 -0
  2. package/package.json +1 -1
  3. package/src/App.vue +11 -11
  4. package/src/common/common.js +143 -14
  5. package/src/common/createMenuId.js +7 -7
  6. package/src/common/uploadImgToBase64.js +12 -12
  7. package/src/common/utils.js +95 -95
  8. package/src/components/Breadcrumb/index.vue +81 -81
  9. package/src/components/Col_TableCell/data.js +4 -4
  10. package/src/components/Col_TableCell/index.scss +77 -77
  11. package/src/components/Col_TableCell/index.vue +43 -43
  12. package/src/components/Col_TableCell/methods.js +19 -19
  13. package/src/components/Hamburger/index.vue +44 -44
  14. package/src/components/ReportCmp/data.js +3 -3
  15. package/src/components/ReportCmp/index.scss +29 -29
  16. package/src/components/ReportCmp/index.vue +2 -2
  17. package/src/components/ReportCmp/methods.js +30 -30
  18. package/src/components/Search/cascader/data.js +3 -3
  19. package/src/components/Search/cascader/index.scss +17 -17
  20. package/src/components/Search/cascader/index.vue +96 -96
  21. package/src/components/Search/cascader/methods.js +41 -41
  22. package/src/components/Search/data.js +5 -5
  23. package/src/components/Search/hk_cascader/index.vue +104 -104
  24. package/src/components/Search/hk_cascader_qudao/index.vue +94 -94
  25. package/src/components/Search/methods.js +86 -86
  26. package/src/components/Search/product_option/data.js +3 -3
  27. package/src/components/Search/product_option/index.scss +68 -68
  28. package/src/components/Search/product_option/index.vue +419 -419
  29. package/src/components/Search/product_option/methods.js +46 -46
  30. package/src/components/Search/select/data.js +3 -3
  31. package/src/components/Search/select/index.scss +2 -2
  32. package/src/components/Search/select/index.vue +114 -114
  33. package/src/components/Search/select/methods.js +51 -51
  34. package/src/components/Search_filter/data.js +5 -5
  35. package/src/components/Search_filter/index.vue +88 -88
  36. package/src/components/Search_filter/methods.js +43 -43
  37. package/src/components/TableCmp/data.js +3 -3
  38. package/src/components/TableCmp/index.scss +22 -22
  39. package/src/components/TableCmp/index.vue +98 -98
  40. package/src/components/TableCmp/methods.js +35 -35
  41. package/src/components/home/BarChart.vue +118 -118
  42. package/src/components/home/LineChart.vue +146 -146
  43. package/src/components/home/Panel.vue +135 -135
  44. package/src/components/home/PanelGroup.vue +146 -146
  45. package/src/components/home/PieChart.vue +81 -81
  46. package/src/components/home/RaddarChart.vue +119 -119
  47. package/src/components/home/TabLayout.vue +88 -88
  48. package/src/components/home/TableList.vue +158 -158
  49. package/src/components/home/Teng.vue +248 -248
  50. package/src/components/home/TransactionTable.vue +49 -49
  51. package/src/components/home/mixins/resize.js +55 -55
  52. package/src/components/im/methods.js +25 -25
  53. package/src/components/image-singleUpload/data.js +3 -3
  54. package/src/components/image-singleUpload/index.scss +26 -26
  55. package/src/components/image-singleUpload/index.vue +56 -56
  56. package/src/components/image-singleUpload/methods.js +30 -30
  57. package/src/components/image-upload/data.js +7 -7
  58. package/src/components/image-upload/index.vue +41 -41
  59. package/src/components/image-upload/methods.js +80 -80
  60. package/src/components/multiple-image-upload/data.js +11 -11
  61. package/src/components/multiple-image-upload/index.scss +8 -8
  62. package/src/components/multiple-image-upload/index.vue +63 -63
  63. package/src/components/multiple-image-upload/methods.js +45 -45
  64. package/src/components/pro-upload/data.js +3 -3
  65. package/src/components/pro-upload/index.scss +4 -4
  66. package/src/components/pro-upload/index.vue +89 -89
  67. package/src/components/pro-upload/methods.js +86 -86
  68. package/src/components/report_set/index.scss +44 -44
  69. package/src/components/report_set/index.vue +153 -153
  70. package/src/components/search-page/src/index.scss +5 -5
  71. package/src/components/search-page/src/index.vue +76 -76
  72. package/src/components/search-page/src/methods.js +36 -36
  73. package/src/mixin/dialog.js +31 -31
  74. package/src/mixin/dlg.js +46 -46
  75. package/src/mixin/newDialog.js +19 -19
  76. package/src/mixin/report.js +82 -82
  77. package/src/mixin/table.js +93 -93
  78. package/src/mixin/tableCell/colTableCell_analysis.js +103 -103
  79. package/src/mixin/upload.js +22 -22
  80. package/src/mixin/vmodel.js +26 -26
  81. package/src/plugins/im/components/conversation-list/index.css +91 -91
  82. package/src/plugins/im/components/conversation-list/index.json +3 -3
  83. package/src/plugins/im/components/conversation-list/index.vue +89 -89
  84. package/src/plugins/im/components/loading/loading.css +69 -69
  85. package/src/plugins/im/components/loading/loading.json +3 -3
  86. package/src/plugins/im/components/loading/loading.vue +14 -14
  87. package/src/plugins/im/components/msg-image/index.json +3 -3
  88. package/src/plugins/im/components/msg-text/index.json +3 -3
  89. package/src/plugins/im/components/msg-text/index.vue +24 -24
  90. package/src/plugins/im/im-plug-in/Protobuf-2.3.7.min.js +1 -1
  91. package/src/plugins/im/im-plug-in/RongCallLib-3.1.5.min.js +74 -74
  92. package/src/plugins/im/im-plug-in/RongIMLib-4.1.0.js +17420 -17420
  93. package/src/plugins/im/im-plug-in/init.js +216 -216
  94. package/src/plugins/im/im-plug-in/qiniu.js +266 -266
  95. package/src/plugins/im/im-plug-in/send-data.js +431 -431
  96. package/src/plugins/im/im-plug-in/upload.js +232 -232
  97. package/src/plugins/im/lib/RongIMEmoji-2.2.6.js +332 -332
  98. package/src/plugins/im/lib/RongIMLib-3.0.7.2-dev.js +11635 -11635
  99. package/src/plugins/im/lib/RongIMLib-3.0.7.2-dev.min.js +6 -6
  100. package/src/plugins/im/utils/underscore-1.8.3.js +1531 -1531
  101. package/src/plugins/im/utils/utils.js +149 -149
  102. package/src/plugins/row-col-cmp/colCmp/data.js +3 -3
  103. package/src/plugins/row-col-cmp/colCmp/index.scss +50 -50
  104. package/src/plugins/row-col-cmp/colCmp/index.vue +53 -53
  105. package/src/plugins/row-col-cmp/colCmp/methods.js +25 -25
  106. package/src/plugins/row-col-cmp/rowCmp/data.js +3 -3
  107. package/src/plugins/row-col-cmp/rowCmp/index.scss +3 -3
  108. package/src/plugins/row-col-cmp/rowCmp/index.vue +43 -43
  109. package/src/plugins/row-col-cmp/rowCmp/methods.js +29 -29
  110. package/src/router/index.js +47 -43
  111. package/src/store/getters.js +13 -13
  112. package/src/store/index.js +58 -58
  113. package/src/store/modules/app.js +55 -55
  114. package/src/store/modules/dic.js +1 -1
  115. package/src/store/modules/settings.js +28 -28
  116. package/src/store/modules/user.js +94 -94
  117. package/src/store/modules/widgetdata.js +42 -42
  118. package/src/styles/element-ui.scss +49 -49
  119. package/src/styles/mixin.scss +28 -28
  120. package/src/styles/sidebar.scss +210 -210
  121. package/src/styles/transition.scss +48 -48
  122. package/src/styles/variables.scss +25 -25
  123. package/src/utils/get-page-title.js +10 -10
  124. package/src/utils/getMenu.js +2 -1
  125. package/src/utils/global-config.js +15 -15
  126. package/src/utils/index.js +332 -332
  127. package/src/utils/localStorage.js +21 -21
  128. package/src/utils/validate.js +20 -20
  129. package/src/views/layout/components/AllSearch/index.vue +44 -44
  130. package/src/views/layout/components/AppMain.vue +50 -50
  131. package/src/views/layout/components/Navbar.vue +43 -2
  132. package/src/views/layout/components/Sidebar/FixiOSBug.js +26 -26
  133. package/src/views/layout/components/Sidebar/Item.vue +28 -28
  134. package/src/views/layout/components/Sidebar/Link.vue +34 -34
  135. package/src/views/layout/components/Sidebar/Logo.vue +79 -79
  136. package/src/views/layout/components/Sidebar/SidebarItem.vue +67 -67
  137. package/src/views/layout/components/Sidebar/index.vue +114 -114
  138. package/src/views/layout/components/index.js +3 -3
  139. package/src/views/layout/index.vue +105 -105
package/README.md CHANGED
@@ -238,3 +238,40 @@
238
238
  1.0.10
239
239
  1. 新增Search组件input元素change事件回调
240
240
  ```
241
+ ```
242
+ 1.0.12
243
+ 1. 弹窗组件增加可扩展参数
244
+ 2. 报表兼容
245
+ ```
246
+ ```
247
+ 1.0.13 (废弃)
248
+ 1. 弹窗组件增加可扩展参数(修复)
249
+ ```
250
+ ```
251
+ 1.0.14
252
+ 1. 修复插件
253
+ ```
254
+ ```
255
+ 1.1.0
256
+ 1. 测试插件
257
+ ```
258
+ ```
259
+ 1.1.3
260
+ 1. common.js 文件增加报表操作相关公用方法(查询配置信息, 查询列表数据)
261
+ ```
262
+ ```
263
+ 1.1.4
264
+ 1. common.js 增加 common.updateData() 修改数据后, 刷新列表页函数
265
+ 2. dic 字段, 移除 '0' 字符串 0 的 参数
266
+ 3. 移除 common.getReportList() 获取列表页数据 函数 空数据入参
267
+ ```
268
+ ```
269
+ 1.1.5
270
+ 1. common.js common.exportExcel (报表导出) 方法, 移除空条件
271
+ ```
272
+ ```
273
+ 1.1.6
274
+ 1. 增加多租户却换
275
+ 2. 兼容相同路由跳转警告问题
276
+ 3. common.js 增加公用方法 this.$common.dic() 用于查询字典单条/多条数据
277
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xs-common-plugins",
3
- "version": "1.1.2",
3
+ "version": "1.1.6",
4
4
  "private": false,
5
5
  "description": "向上公共代码部分",
6
6
  "author": "祝玲云 <1902733517@qq.com>",
package/src/App.vue CHANGED
@@ -1,12 +1,12 @@
1
- <template>
2
- <div id="app">
3
- <router-view />
4
- <router-view name="websocket" />
5
- </div>
6
- </template>
7
-
8
- <script>
9
-
10
- </script>
11
-
1
+ <template>
2
+ <div id="app">
3
+ <router-view />
4
+ <router-view name="websocket" />
5
+ </div>
6
+ </template>
7
+
8
+ <script>
9
+
10
+ </script>
11
+
12
12
  <style lang="scss" src="./styles/table.scss"></style>
@@ -4,6 +4,7 @@ import router from '@/router/index'
4
4
  import store from '@/store/index'
5
5
  import {OrgEnum} from '@/utils/enum'
6
6
  import filterRules from '@/utils/filterRules'
7
+ import request from "xs-request";
7
8
 
8
9
  const common = {}
9
10
 
@@ -139,15 +140,23 @@ common.updateById = (that, url, query, callBack) => {
139
140
  })
140
141
  }
141
142
  /**
142
- * 判断多条数据
143
- * @param {*} that
144
- * @param {*} row 要判断的数据
145
- * @param {*} title 无数据/ 提示操作的 关键字
146
- * @param {*} check 默认 true 二次弹窗确认即将要做的提醒
143
+ * 判断多条数据 返回 true/false 或者 重新拼接好的 ids []
144
+ * @param {Object} that this
145
+ * @param {Array} row 要判断的数据
146
+ * @param {String} title 无数据/ 提示操作的 关键字
147
+ * @param {String} prop 默认 id 要取出数组中哪个字段汇成新数组
148
+ * @param {Boolean} check 默认 true 二次弹窗确认即将要做的提醒
149
+ *
150
+ * 使用场景 (列表页上批量操作数据后刷新列表页)
151
+ * async updateRows () {
152
+ * let ids = await this.$common.checkRows(this, this.selectRows, 'xxx')
153
+ * if(!ids) retuen
154
+ * this.$common.updateData(that, 'ask.xxx.xxx', {保存对象})
155
+ * }
147
156
  */
148
157
  common.checkRows = async (that, row, title, prop = "id", check = true) => {
149
158
  if(row.length == 0) {
150
- common.message(that, `无${title}的数据`, 'error');
159
+ common.message(that, `请选择数据`, 'error');
151
160
  return false;
152
161
  }
153
162
  if(check) {
@@ -157,9 +166,28 @@ common.updateById = (that, url, query, callBack) => {
157
166
  } catch (error) {
158
167
  return false
159
168
  }
169
+ } else {
170
+ return true
160
171
  }
161
172
  }
162
173
 
174
+ /**
175
+ * 修改数据后, 刷新列表页
176
+ * @param {Object} that 传值 this
177
+ * @param {String} url api 地址
178
+ * @param {Object} query 接口参数
179
+ * @param {Function} callBack 接口响应成功后, 界面上自行处理返回事件, 不传, 默认执行页面 getList 方法 (刷新列表页)
180
+ */
181
+ common.updateData = (that, url, query, callBack) => {
182
+ let request = common.getObject(url)
183
+ request(Object.assign({}, query)).then(res => {
184
+ if(res.code !== 0) return
185
+ common.message(that, res.message)
186
+ if(callBack) callBack(res)
187
+ else that.getList && that.getList()
188
+ })
189
+ }
190
+
163
191
 
164
192
  /**
165
193
  * 消息弹窗---自动消失
@@ -199,6 +227,7 @@ common.confirm = (that, message, title, callBack) => {
199
227
  }
200
228
  }
201
229
 
230
+
202
231
  /**
203
232
  * 发起弹窗
204
233
  * @param {*} options
@@ -208,15 +237,15 @@ common.confirm = (that, message, title, callBack) => {
208
237
  * props: {id: '', name: '' }, 带给弹窗组件的 prop 集合
209
238
  * srcData: {} , 带给弹窗组件的值 (已废弃, 不推荐使用, 推荐使用 props)
210
239
  * width: string, 弹窗宽度
211
- * showButton: Boolean , 是否显示 确认/取消按钮 (默认不显示) 显示时, 确认按钮默认触发组件页面的 confirm() 方法
240
+ * showButton: Boolean , 是否显示 确认/取消按钮 (默认不显示) 显示时, 确认按钮默认触发组件页面的 confirm() 方法, beforeClose() 方法弹窗关闭前被调用,同时暂停实例的关闭, 参数 done ,此时若需要关闭实例,可以调用done方法
212
241
  * callBack: function 获取 弹窗层返回值
213
- * beforeClose: function 弹窗点击关闭事件, 返回参数 done , 关闭弹窗事件
242
+ * dialogCfg: 弹窗的高级配置, 具体参数查看 element ui 下的 el-dialog
214
243
  * }
215
244
  *
216
245
  */
217
246
  common.popup = (options) => {
218
247
  if (!options) return;
219
- let { title, component, srcData, width, showButton, callBack, beforeClose, props } = common.clone(options);
248
+ let { title, component, srcData, width, showButton, callBack, props, dialogCfg } = common.clone(options);
220
249
  if (!component) return;
221
250
  let e = document.createElement("div");
222
251
  document.getElementsByTagName("body")[0].appendChild(e);
@@ -228,7 +257,7 @@ common.popup = (options) => {
228
257
  if (showButton) {
229
258
  button = `<div style="text-align:right"><el-button size="medium" type='primary' @click="confirm">确认</el-button><el-button size="medium" @click="cancel()">取消</el-button></div>`
230
259
  }
231
- template = `<div v-if="visible"> <el-dialog :title="title" :visible.sync="visible" :width="width" :before-close="beforeClose" append-to-body><child ref="child" v-bind="props" :srcData="srcData" @close="close" @cancel="cancel" />${button}</el-dialog></div>`
260
+ template = `<div v-if="visible"> <el-dialog :title="title" v-bind="dialogCfg" :visible.sync="visible" :width="width" :before-close="beforeClose" append-to-body><child ref="child" v-bind="props" :srcData="srcData" @close="close" @cancel="cancel" />${button}</el-dialog></div>`
232
261
  }
233
262
  v = new Vue({
234
263
  el: e,
@@ -241,7 +270,8 @@ common.popup = (options) => {
241
270
  visible: true,
242
271
  width: width ? width : '30%',
243
272
  props: props ? props : null,
244
- srcData: srcData ? srcData : null
273
+ srcData: srcData ? srcData : null,
274
+ dialogCfg: dialogCfg ? dialogCfg: null
245
275
  }
246
276
  },
247
277
  components: {
@@ -254,10 +284,10 @@ common.popup = (options) => {
254
284
  }
255
285
  },
256
286
  beforeClose(done) {
257
- if(beforeClose) {
258
- beforeClose(done)
287
+ if (this.$refs.child.beforeClose) {
288
+ this.$refs.child.beforeClose(done);
259
289
  } else {
260
- done();
290
+ done()
261
291
  }
262
292
  },
263
293
  cancel () {
@@ -321,6 +351,10 @@ common.clone = (obj) => {
321
351
  common.exportExcel = async (url, query, fileName = 'demo', headers = { responseType: 'arraybuffer' }) => {
322
352
  let newQuery = JSON.parse(JSON.stringify(query))
323
353
  delete newQuery.data
354
+ for (const key in newQuery) {
355
+ if(newQuery[key] == null || newQuery[key] === '')
356
+ delete newQuery[key]
357
+ }
324
358
  const httpRequest = common.getObject(url)
325
359
  const response = await httpRequest(newQuery, headers)
326
360
  const blob = new Blob([response], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8' })
@@ -390,4 +424,99 @@ common.requiredList = (list) => {
390
424
  }
391
425
  }
392
426
 
427
+ /**
428
+ * 获取报表配置项
429
+ * @param {Object} that 指向 默认传 this
430
+ * @param {String} url 获取配置项 url
431
+ * @param {Object} query 接口参数
432
+ * @param {Function} callBack 自定义事件, 传此参数, 接口响应后, 后续事情自定义
433
+ * @param {String} methodName 接口响应后, 调用界面哪个方法
434
+ */
435
+ common.getReportCfg = (that, url, query, callBack, methodName = 'getReportList') => {
436
+ let request = common.getObject(url)
437
+ request(query).then(res => {
438
+ if(callBack) {
439
+ callBack(res)
440
+ } else {
441
+ that.config.reportList = res.data
442
+ if(res.data[0]) {
443
+ that.reportCfgVal = JSON.parse(res.data[0].jsonCfg)
444
+ that[methodName]();
445
+ }
446
+ }
447
+ })
448
+ }
449
+
450
+ /**
451
+ * 获取报表列表数据
452
+ * @param {*} that 指向 默认传 this
453
+ * @param {*} url 获取数据 url
454
+ * @param {*} query 接口参数 不传, 默认取值 this.data (查询条件) + this.reportCfgVal (报表配置项)
455
+ * @param {*} callBack 接口响应后, 自定义事件
456
+ */
457
+ common.getReportList = (that, url, query, callBack) => {
458
+ let newQuery = {}
459
+ if(query) newQuery = query
460
+ else {
461
+ let obj = Object.assign({}, that.data)
462
+ delete obj.data
463
+ // 移除空项查询条件
464
+ for (const key in obj) {
465
+ if(obj[key] == null || obj[key] === '')
466
+ delete obj[key]
467
+ }
468
+ newQuery = Object.assign(obj, {report: that.reportCfgVal})
469
+ }
470
+ let request = common.getObject(url)
471
+ request(newQuery).then(res => {
472
+ if(callBack) callBack(res)
473
+ else that.data = res.data
474
+ })
475
+ }
476
+
477
+
478
+ /**
479
+ * 字典表 里通过Id 查 name, 或者查询多条数据
480
+ * @param {Array} props ['服务名', '表名', '字段名']
481
+ * @param {String, Number, Array} val 值, 传入id, 或者 [id1, id2, ...]
482
+ *
483
+ * 使用案例 (异步方法)
484
+ * async getValue () {
485
+ * await this.$common.dic(['qccuser', 'Brand'], '10010')
486
+ * }
487
+ *
488
+ */
489
+
490
+ common.dic = async (props, val) => {
491
+ let isArray = Array.isArray(val)
492
+ let server = props[0] || ''
493
+ let tableName = props[1] || ''
494
+ let prop = props[2] || 'name'
495
+ let key = server + tableName
496
+ if(store.getters.dic[key]) {
497
+ if(isArray) return await getDicVal()
498
+ let row = store.getters.dic[key].find(item => item.id == val)
499
+ if(row && (row.isNull || row[prop] === null)) { return '' }
500
+ if(row) return row[prop]
501
+ if(!row) return await getDicVal()
502
+
503
+ } else {
504
+ return await getDicVal()
505
+ }
506
+ async function getDicVal () {
507
+ let servers = props[0] || "";
508
+ let tableName = props[1] || "";
509
+ let key = servers + tableName;
510
+ let url = servers + "/UserAll/Search/Dic/" + tableName;
511
+ let res = await request.post(url, isArray ? val : [val])
512
+ if (res.code !== 0) return;
513
+ store.commit("dic/SET_ASK", { key, val: res.data });
514
+ if(isArray) return res.data
515
+ else {
516
+ let row = res.data.find(item => item.id == val)
517
+ return row ? row[prop] : ''
518
+ }
519
+ }
520
+ }
521
+
393
522
  export default common
@@ -1,7 +1,7 @@
1
- import md5 from "js-md5";
2
- import { getConfig } from "@/utils/global-config";
3
- export function createMenuId(_fullPath) {
4
- return md5(getConfig("CLIENT_ID") + ":" + _fullPath);
5
- }
6
-
7
-
1
+ import md5 from "js-md5";
2
+ import { getConfig } from "@/utils/global-config";
3
+ export function createMenuId(_fullPath) {
4
+ return md5(getConfig("CLIENT_ID") + ":" + _fullPath);
5
+ }
6
+
7
+
@@ -1,13 +1,13 @@
1
- export function uploadImgToBase64(file) {
2
- return new Promise((resolve, reject) => {
3
- if (!window.FileReader) {
4
- console.error('抱歉,您的浏览器不支持 FileReader API!')
5
- }
6
- const reader = new FileReader()
7
- reader.readAsDataURL(file)
8
- reader.onload = function () { // 图片转base64完成后返回reader对象
9
- resolve(reader)
10
- }
11
- reader.onerror = reject
12
- })
1
+ export function uploadImgToBase64(file) {
2
+ return new Promise((resolve, reject) => {
3
+ if (!window.FileReader) {
4
+ console.error('抱歉,您的浏览器不支持 FileReader API!')
5
+ }
6
+ const reader = new FileReader()
7
+ reader.readAsDataURL(file)
8
+ reader.onload = function () { // 图片转base64完成后返回reader对象
9
+ resolve(reader)
10
+ }
11
+ reader.onerror = reject
12
+ })
13
13
  }
@@ -1,95 +1,95 @@
1
- export function isPlainObject(val) {
2
- return toString.call(val) === "[object Object]";
3
- }
4
-
5
- export function isArray(val) {
6
- return toString.call(val) === "[object Array]";
7
- }
8
-
9
- /**
10
- * 获取指定的URL参数值
11
- * URL:http://www.quwan.com/index?name=tyler
12
- * 参数:paramName URL参数
13
- * 调用方法:getParam("name")
14
- * 返回值:tyler
15
- */
16
- export function getParam(name) {
17
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
18
- var reg_rewrite = new RegExp("(^|/)" + name + "/([^/]*)(/|$)", "i");
19
- var r = window.location.search.substr(1).match(reg);
20
- var q = window.location.pathname.substr(1).match(reg_rewrite);
21
- if (r != null) {
22
- return unescape(r[2]);
23
- } else if (q != null) {
24
- return unescape(q[2]);
25
- } else {
26
- return null;
27
- }
28
- }
29
-
30
- export function getQuery(_url, name) {
31
- let search = _url ? _url : window.location.search;
32
- if (search) {
33
- const KEY_REDIRECT = "?";
34
- const startIndex = window.location.href.indexOf(KEY_REDIRECT);
35
- search = window.location.href.substring(startIndex + 1);
36
- }
37
-
38
- var vars = search.split("&");
39
- for (var i = 0; i < vars.length; i++) {
40
- var pair = vars[i].split("=");
41
- if (pair[0] == name) {
42
- return pair[1];
43
- }
44
- }
45
- return false;
46
- }
47
- export function checkedBoxRe(val, enumName, target) {
48
- let attr = "";
49
- let sourceList =
50
- (target.OrgEnum && target.OrgEnum[enumName]) || target.$orgEnum[enumName];
51
- const arr = sourceList.slice(0, -1).map(item => {
52
- return item.Id;
53
- });
54
- arr.forEach((item, index) => {
55
- if ((val & item) > 0) {
56
- attr += sourceList[index].Text + ",";
57
- }
58
- });
59
- if (attr.length > 0) {
60
- attr = attr.substr(0, attr.length - 1);
61
- }
62
- return attr;
63
- } /*节流函数,通过控制每次事件执行的时间间隔控制短时间多次执行方法
64
- handler:要执行的方法
65
- wait:每次点击事件执行的时间间隔(毫秒)
66
- */
67
- export function throttle(handler, wait = 1000) {
68
- var lastTime = 0;
69
- var self = this,
70
- arg = arguments;
71
-
72
- return function() {
73
- var nowTime = new Date().getTime();
74
- if (nowTime - lastTime > wait) {
75
- handler.apply(self, arg);
76
- lastTime = nowTime;
77
- }
78
- };
79
- }
80
-
81
- /*防抖函数,通过推迟每次事件执行的时间来减少不必要的查询
82
- handler:要执行的方法
83
- delay:每次事件执行的推迟时间(毫秒)
84
- */
85
- export function debounce(handler, delay) {
86
- var timer;
87
- return function() {
88
- var self = this,
89
- arg = arguments;
90
- clearTimeout(timer);
91
- timer = setTimeout(function() {
92
- handler.apply(self, arg);
93
- }, delay);
94
- };
95
- }
1
+ export function isPlainObject(val) {
2
+ return toString.call(val) === "[object Object]";
3
+ }
4
+
5
+ export function isArray(val) {
6
+ return toString.call(val) === "[object Array]";
7
+ }
8
+
9
+ /**
10
+ * 获取指定的URL参数值
11
+ * URL:http://www.quwan.com/index?name=tyler
12
+ * 参数:paramName URL参数
13
+ * 调用方法:getParam("name")
14
+ * 返回值:tyler
15
+ */
16
+ export function getParam(name) {
17
+ var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
18
+ var reg_rewrite = new RegExp("(^|/)" + name + "/([^/]*)(/|$)", "i");
19
+ var r = window.location.search.substr(1).match(reg);
20
+ var q = window.location.pathname.substr(1).match(reg_rewrite);
21
+ if (r != null) {
22
+ return unescape(r[2]);
23
+ } else if (q != null) {
24
+ return unescape(q[2]);
25
+ } else {
26
+ return null;
27
+ }
28
+ }
29
+
30
+ export function getQuery(_url, name) {
31
+ let search = _url ? _url : window.location.search;
32
+ if (search) {
33
+ const KEY_REDIRECT = "?";
34
+ const startIndex = window.location.href.indexOf(KEY_REDIRECT);
35
+ search = window.location.href.substring(startIndex + 1);
36
+ }
37
+
38
+ var vars = search.split("&");
39
+ for (var i = 0; i < vars.length; i++) {
40
+ var pair = vars[i].split("=");
41
+ if (pair[0] == name) {
42
+ return pair[1];
43
+ }
44
+ }
45
+ return false;
46
+ }
47
+ export function checkedBoxRe(val, enumName, target) {
48
+ let attr = "";
49
+ let sourceList =
50
+ (target.OrgEnum && target.OrgEnum[enumName]) || target.$orgEnum[enumName];
51
+ const arr = sourceList.slice(0, -1).map(item => {
52
+ return item.Id;
53
+ });
54
+ arr.forEach((item, index) => {
55
+ if ((val & item) > 0) {
56
+ attr += sourceList[index].Text + ",";
57
+ }
58
+ });
59
+ if (attr.length > 0) {
60
+ attr = attr.substr(0, attr.length - 1);
61
+ }
62
+ return attr;
63
+ } /*节流函数,通过控制每次事件执行的时间间隔控制短时间多次执行方法
64
+ handler:要执行的方法
65
+ wait:每次点击事件执行的时间间隔(毫秒)
66
+ */
67
+ export function throttle(handler, wait = 1000) {
68
+ var lastTime = 0;
69
+ var self = this,
70
+ arg = arguments;
71
+
72
+ return function() {
73
+ var nowTime = new Date().getTime();
74
+ if (nowTime - lastTime > wait) {
75
+ handler.apply(self, arg);
76
+ lastTime = nowTime;
77
+ }
78
+ };
79
+ }
80
+
81
+ /*防抖函数,通过推迟每次事件执行的时间来减少不必要的查询
82
+ handler:要执行的方法
83
+ delay:每次事件执行的推迟时间(毫秒)
84
+ */
85
+ export function debounce(handler, delay) {
86
+ var timer;
87
+ return function() {
88
+ var self = this,
89
+ arg = arguments;
90
+ clearTimeout(timer);
91
+ timer = setTimeout(function() {
92
+ handler.apply(self, arg);
93
+ }, delay);
94
+ };
95
+ }