@kyfe/hroa-ui 1.0.0 → 1.0.1

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 (77) hide show
  1. package/dist/hroa-ui.common.js +834 -1363
  2. package/dist/hroa-ui.css +1 -6
  3. package/dist/hroa-ui.umd.js +834 -1363
  4. package/dist/hroa-ui.umd.min.js +2 -2
  5. package/dist/img/add.713653a8.svg +1 -0
  6. package/dist/img/close.6ef706b9.svg +1 -0
  7. package/lib/getJsModule/index.css +1 -6
  8. package/lib/getJsModule/index.js +2 -2
  9. package/lib/hr-add-list/index.css +1 -0
  10. package/lib/hr-add-list/index.js +1 -0
  11. package/lib/hr-bottom-button/index.js +1 -1
  12. package/lib/hr-breadcrumb/index.css +1 -0
  13. package/lib/hr-breadcrumb/index.js +9 -0
  14. package/lib/hr-button/index.js +1 -1
  15. package/lib/hr-clipboard/index.js +1 -1
  16. package/lib/hr-condition-filtrate/index.js +1 -1
  17. package/lib/hr-condition-filtrate-popup/index.js +1 -1
  18. package/lib/hr-elasticity-box/index.js +1 -1
  19. package/lib/hr-elasticity-box-item/index.js +1 -1
  20. package/lib/hr-emotional-picture/index.js +1 -1
  21. package/lib/hr-employee-choose/index.js +1 -1
  22. package/lib/hr-img-list/index.css +1 -1
  23. package/lib/hr-img-list/index.js +1 -1
  24. package/lib/hr-info-card/index.js +1 -1
  25. package/lib/hr-information/index.css +1 -0
  26. package/lib/hr-information/index.js +1 -0
  27. package/lib/hr-license-plate-number/index.js +1 -1
  28. package/lib/hr-module-card/index.js +1 -1
  29. package/lib/hr-multiterm-choose/index.css +1 -1
  30. package/lib/hr-multiterm-choose/index.js +1 -1
  31. package/lib/hr-no-data/index.js +1 -1
  32. package/lib/hr-notice-bar/index.js +1 -1
  33. package/lib/hr-open-ks/index.js +1 -1
  34. package/lib/hr-pager/index.js +1 -1
  35. package/lib/hr-popup/index.css +1 -1
  36. package/lib/hr-popup/index.js +1 -1
  37. package/lib/hr-preview-file/index.js +1 -1
  38. package/lib/hr-rate/index.js +1 -1
  39. package/lib/hr-reason-textarea/index.js +1 -1
  40. package/lib/hr-search-input/index.js +1 -1
  41. package/lib/hr-select/index.js +1 -1
  42. package/lib/hr-select-list/index.css +1 -1
  43. package/lib/hr-select-list/index.js +2 -2
  44. package/lib/hr-single-choose/index.css +1 -1
  45. package/lib/hr-single-choose/index.js +1 -1
  46. package/lib/hr-slide-pager/index.js +1 -1
  47. package/lib/hr-sort/index.js +1 -1
  48. package/lib/hr-stack-image/index.js +1 -1
  49. package/lib/hr-tab-nav/index.js +1 -1
  50. package/lib/hr-view-item/index.js +1 -1
  51. package/lib/img/add.713653a8.svg +1 -0
  52. package/lib/img/close.6ef706b9.svg +1 -0
  53. package/lib/index/index.css +1 -6
  54. package/lib/index/index.js +2 -2
  55. package/lib/utils/index.js +1 -1
  56. package/package.json +1 -1
  57. package/packages/hr-add-list/image/add.svg +1 -0
  58. package/packages/hr-add-list/image/close.svg +1 -0
  59. package/packages/hr-add-list/index.js +7 -0
  60. package/packages/hr-add-list/src/index.vue +125 -0
  61. package/packages/hr-breadcrumb/index.js +3 -0
  62. package/packages/hr-breadcrumb/src/index.vue +87 -0
  63. package/packages/hr-breadcrumb//351/235/242/345/214/205/345/261/221.md +0 -0
  64. package/packages/hr-information/index.js +7 -0
  65. package/packages/hr-information/src/index.vue +71 -0
  66. package/packages/hr-multiterm-choose/src/index.vue +19 -12
  67. package/packages/hr-popup/src/index.vue +5 -1
  68. package/packages/hr-single-choose/src/index.vue +2 -2
  69. package/packages/hr-slide-pager/src/index.vue +6 -1
  70. package/lib/hr-at-input/index.css +0 -6
  71. package/lib/hr-at-input/index.js +0 -1
  72. package/packages/hr-at-input/index.js +0 -7
  73. package/packages/hr-at-input/src/blot/atPerson.js +0 -43
  74. package/packages/hr-at-input/src/index.vue +0 -472
  75. package/packages/hr-at-input/src/quill.snow.css +0 -945
  76. package/packages/hr-at-input/src/utils/index.js +0 -60
  77. /package/packages/{hr-at-input//346/224/257/346/214/201@/351/200/211/344/272/272/350/276/223/345/205/245/346/241/206.md" → hr-add-list//346/226/260/345/242/236/345/244/232/347/254/224/346/225/260/346/215/256.md"} +0 -0
@@ -1,472 +0,0 @@
1
- <template>
2
- <!-- 富文本编辑区域 -->
3
- <div class="hr-at-input ql-editor"
4
- :id="`editor${this.tag}`"
5
- @keydown.enter="onEnter"
6
- @keydown.delete="onDelete"
7
- @input="onInput"
8
- @paste="onPaste"
9
- ref="htmlContent"></div>
10
- </template>
11
-
12
- <script>
13
- // import oldQuill from 'quill'
14
- // 为了解决ios光标索引错乱问题,评论框组件优先使用2.0.4版本的quill(部分低版本安卓机器只能用1.3.7版本, 因为2.0.4版本有es6语法)
15
- // const Quill = oldQuill
16
- const Quill = window.Quill
17
- import AtPerson from './blot/atPerson.js'
18
- import { strTranslateAt, atTranslateStr } from './utils/index.js'
19
-
20
- export default {
21
- name: 'HrAtInput',
22
- // 实现v-model指令
23
- model: {
24
- // eslint-disable-next-line
25
- innerHTML: '',
26
- event: 'change'
27
- },
28
- props: {
29
- placeholder: {
30
- type: String,
31
- default: '请输入'
32
- },
33
- // 当同一页面有多个编辑器时,传入不同tag起区分编辑器的作用
34
- tag: {
35
- type: [String, Number],
36
- default: 1
37
- },
38
- value: {
39
- type: String,
40
- default: ''
41
- },
42
- maxLength: {
43
- type: Number,
44
- },
45
- },
46
- data () {
47
- return {
48
- textContent: '',
49
- htmlContent: '',
50
- len: 0,
51
- quill: null,
52
- selectionStatus: null, // 选区状态
53
- }
54
- },
55
- mounted () {
56
- Quill.register('formats/AtPerson', AtPerson)
57
-
58
-
59
- this.quill = new Quill(`#editor${this.tag}`, {
60
- placeholder: this.placeholder,
61
- })
62
-
63
- setTimeout(() => {
64
- this.initQuillCopyConfig()
65
- this.addEventListeners()
66
- this.initEmojiFocusEvent()
67
- })
68
- },
69
- computed: {
70
- isIos () {
71
- return (document.querySelector('#kuasheng-h5') && document.querySelector('#kuasheng-h5').className.indexOf('ios')) > -1
72
- },
73
- },
74
- watch: {
75
- placeholder (val) {
76
- this.quill.root.setAttribute('data-placeholder', val)
77
- },
78
- value (val) {
79
- this.setHtmlContentNew(val)
80
- }
81
- },
82
- methods: {
83
- /**
84
- * @description 将自定义标记文本转为at标签
85
- * @param {String} content
86
- * @param {Boolean} isQuillUse 是否在quill富文本使用(默认是)
87
- * @returns {String}
88
- */
89
- strTranslateAt,
90
- /**
91
- * @description at标签转化为自定义标识文本
92
- * @param {String} content
93
- * @returns {String}
94
- */
95
- atTranslateStr,
96
- /**
97
- * @description 添加quill匹配器来处理粘贴的内容
98
- */
99
- initQuillCopyConfig () {
100
- // 处理粘贴at标签
101
- this.quill.clipboard.addMatcher('AT', (node, delta) => {
102
- console.log('node----🔥', node)
103
- console.log('delta----🔥', delta)
104
- let arr = node.getAttribute('alt') && node.getAttribute('alt').split(', ')
105
- if (node.tagName === 'AT' && arr && arr.length) {
106
- delta.ops.forEach((op) => {
107
- op.insert['at'] = `${arr[1]}/${arr[0]}`
108
- delete op.attributes
109
- })
110
- }
111
- return delta
112
- })
113
- },
114
- /**
115
- * @description 监听输入框删除事件
116
- */
117
- onDelete () {
118
- this.$emit('delete')
119
- },
120
- /**
121
- * @description 给@人标识绑定聚焦事件,让其点击有焦点
122
- */
123
- initEmojiFocusEvent () {
124
- // 处理编辑器里面的@人标识可focus
125
- this.$refs.htmlContent.querySelector('.ql-editor').addEventListener('click', async (e) => {
126
- console.log('e.target', e)
127
- if (e.target.parentNode.tagName === 'AT' && e.target.parentNode.className === 'at') {
128
- let blot = Quill.find(e.target.parentNode)
129
- let index = this.quill && this.quill.getIndex(blot) + 1
130
- // index正常返回数字,则设置选区
131
- if (Object.prototype.toString.call(index) === '[object Number]') {
132
- this.quill && this.quill.setSelection(index, 0)
133
- }
134
- return
135
- }
136
- })
137
- },
138
- /**
139
- * @description 接收AT选人页面选中人员数据,并回显到输入框内 (父组件调用)
140
- * @param {Array} userList 人员集合(数据结构:[{employeeNumber, employeeName}])
141
- */
142
- setAtPersonList (userList) {
143
- userList.forEach(async (item, index) => {
144
- this.insertAtCursor(item, index)
145
- })
146
- setTimeout(() => {
147
- // 这里执行onInput是为了走里面的超出字数截断文本逻辑
148
- this.onInput({ inputType: 'atPerson' })
149
- }, 100)
150
- },
151
- /**
152
- * @description 插入at自定义标签
153
- * @param {*} assignObj 人员信息对象
154
- * @param {*} index 人员对象数组索引
155
- */
156
- async insertAtCursor (assignObj, index) {
157
- this.quill.focus()
158
- await this.delayFn(10)
159
- let rangeIndex = this.quill.selection.savedRange.index
160
- console.log('rangeIndex---index', rangeIndex, index)
161
-
162
- // @人员标签插入
163
- const employeeNumber = assignObj.employeeNumber || ''
164
- const employeeName = assignObj.employeeName || assignObj.name || ''
165
-
166
- // this.quill.insertEmbed(rangeIndex, 'at', {
167
- // alt: `$_hl{${employeeNumber}, ${employeeName}}`,
168
- // text: `@${employeeName}`,
169
- // })
170
-
171
- let html = `<at>${employeeName}/${employeeNumber}</at>`
172
- this.quill.clipboard.dangerouslyPasteHTML(rangeIndex, `${html}`)
173
-
174
- // 输入@选择人员后,清除@字符
175
- if (!this.isBtnUse && index === 0) {
176
- this.quill.deleteText(rangeIndex - 1, 1)
177
- this.isBtnUse = false
178
- }
179
-
180
- // 插入成功后移动光标
181
- // this.quill.setSelection(rangeIndex + 1, 0)
182
- },
183
- /**
184
- * @description 同步阻塞延迟函数
185
- * @param {*} time 毫秒
186
- */
187
- delayFn (time) {
188
- return new Promise(resolve => {
189
- setTimeout(() => {
190
- resolve()
191
- }, time)
192
- })
193
- },
194
- /**
195
- * @description 聚焦输入框 唤起键盘
196
- * @param {Boolean} isFocusEnd 光标是否置尾
197
- */
198
- focusInput (isFocusEnd = false) {
199
- this.quill && this.quill.focus()
200
-
201
- // 兼容ios无法唤起键盘
202
- if (this.isIos && this.inputTemp) {
203
- this.inputTemp.focus()
204
- }
205
- // 光标置尾
206
- if (isFocusEnd) {
207
- this.quill && this.quill.setSelection(this.len || this.quill.getLength(), 0)
208
- }
209
- },
210
- /**
211
- * @description 输入框失焦
212
- */
213
- blurInput () {
214
- this.quill.blur()
215
- },
216
- /**
217
- * @description 监听quill各种事件
218
- */
219
- addEventListeners () {
220
- this.$refs.htmlContent.querySelector('.ql-editor').addEventListener('focus', () => {
221
- this.$emit('focus')
222
- })
223
-
224
- this.$refs.htmlContent.querySelector('.ql-editor').addEventListener('input', () => {
225
- this.setQuillPlaceholder('')
226
- })
227
-
228
- this.$refs.htmlContent.querySelector('.ql-editor').addEventListener('blur', () => {
229
- this.setQuillPlaceholder(this.placeholder)
230
- this.$emit('blur')
231
- })
232
-
233
- this.quill.on('text-change', (delta, oldDelta, source) => {
234
- // 获取内容
235
- this.htmlContent = this.$refs.htmlContent.querySelector('.ql-editor').innerHTML
236
- this.textContent = this.$refs.htmlContent.querySelector('.ql-editor').textContent
237
- this.handleChange(this.textContent, this.htmlContent)
238
-
239
- if (source == 'user') {
240
- // 判断用户手动输入的@字符
241
- if (delta && ((delta.ops[0] && delta.ops[0].insert && delta.ops[0].insert == '@') ||
242
- (delta.ops[1] && delta.ops[1].insert && delta.ops[1].insert == '@'))) {
243
- console.log('判断新输入的@字符')
244
- // 去选人页面
245
- this.goToSelectAtPerson()
246
- } else {
247
- const length = this.quill.getLength()
248
- if (length <= 1) this.setQuillPlaceholder(this.placeholder)
249
-
250
- // 兼容ios在标签后输入光标会跳的问题
251
- if (delta.ops[delta.ops.length - 1].insert && this.isIos) {
252
- const selection = this.quill.getSelection().index + delta.ops[delta.ops.length - 1].insert.length
253
- this.quill.setSelection(selection)
254
- }
255
- }
256
- }
257
- })
258
- },
259
- /**
260
- * @description 设置输入框提示语
261
- * @param {*} text
262
- */
263
- setQuillPlaceholder (text) {
264
- const editorContainer = this.quill.container.childNodes[0]
265
- editorContainer.setAttribute('data-placeholder', text)
266
- },
267
- /**
268
- * @description 去选人页面
269
- * @param {Boolean} isBtnUse 是否按钮触发的 (按钮触发的去选人则输入框无需删除@符号处理)
270
- */
271
- goToSelectAtPerson (isBtnUse = false) {
272
- this.isBtnUse = isBtnUse
273
- this.$nextTick(() => {
274
- // 跳转之前把键盘收起,否则返回详情会出现样式问题
275
- this.quill.enable(true)
276
- this.quill.blur()
277
- setTimeout(() => {
278
- // 通知父组件打开选择At人员页面
279
- this.$emit('openSelectAtPersonPage', this.getHasSelectedCount())
280
- })
281
- })
282
- },
283
- /**
284
- * @description 获取当前评论已@人数
285
- * @returns { Number }
286
- */
287
- getHasSelectedCount () {
288
- let content = this.$refs.htmlContent.querySelector('.ql-editor').innerHTML
289
- let str = atTranslateStr(content)
290
- let resArr = str.match(/\$_hl{(\S+, \S+)}/g)
291
- return (resArr && resArr.length) || 0
292
- },
293
- /**
294
- * @description html转delta
295
- */
296
- htmlToDelta (html) {
297
- let delta = window.Quill ? this.quill.clipboard.convertHTML(html) : this.quill.clipboard.convert(html) // 把html转换成delta,因为quill只识别delta
298
-
299
- delta.forEach(v => {
300
- // 兼容pc端表情
301
- if (v.insert && v.insert.image && v.insert.image.indexOf('http://erphostjs.kye-erp.com/kuasheng-emoji') > -1) {
302
- v.attributes = { width: '16' }
303
- }
304
- })
305
- return delta
306
- },
307
- /**
308
- * @description 设置编辑器内容
309
- * @param {string} html
310
- */
311
- setHtmlContentNew (html) {
312
- let rangeIndex = this.quill.selection.savedRange.index
313
-
314
- // 将自定义标记文本转为at标签
315
- html = strTranslateAt(html)
316
-
317
- this.htmlContent = html
318
-
319
- let delta = this.htmlToDelta(html)
320
-
321
- this.quill && this.quill.setContents(delta, 'user')
322
- this.$nextTick(() => {
323
- this.htmlLength()
324
- })
325
-
326
- // 原先有聚焦的场景下赋值才需要聚焦,非编辑场景下赋值无需聚焦
327
- if (this.quill.hasFocus()) {
328
- this.quill.setSelection(rangeIndex, 0)
329
- }
330
- },
331
- htmlLength () {
332
- let textContent = this.$refs.htmlContent.querySelector('.ql-editor').textContent || ''
333
- this.textContent = textContent
334
- this.len = (this.quill && this.quill.getLength()) - 1
335
- this.$emit('update:richInputLength', this.len)
336
- },
337
- /**
338
- * @description 获取文本内容及文本长度,并发送给外部组件
339
- */
340
- handleChange (textContent, innerHTML) {
341
- this.len = (this.quill && this.quill.getLength()) - 1
342
- this.$emit('change', innerHTML)
343
- this.$emit('update:richInputLength', this.len)
344
- },
345
- /**
346
- * @description 监听输入框input事件
347
- * @param {*} e
348
- */
349
- onInput (e) {
350
- setTimeout(() => {
351
- let { inputType } = e
352
- let index_old = this.quill && this.quill.getSelection() && this.quill.getSelection().index - 1
353
-
354
- // 获取当前内容长度
355
- let len = this.quill.getLength() - 1
356
- this.len = len
357
- let maxLength = this.maxLength
358
-
359
- // 忽略粘贴事件
360
- if (inputType !== 'insertFromPaste' && maxLength && len >= maxLength) {
361
- // 获取当前索引
362
- let index = index_old || maxLength || 0
363
-
364
- index = index - (len - maxLength) + 1
365
-
366
- if (index > maxLength) {
367
- index = maxLength
368
- }
369
-
370
- // 超出限制长度,截取
371
- this.quill.deleteText(index, len - maxLength)
372
- }
373
-
374
- if (inputType !== 'insertFromPaste' && maxLength && len > maxLength) {
375
- window.vant.Toast('字数超限')
376
- }
377
- this.$emit('input')
378
- })
379
- },
380
- /**
381
- * @description 监听输入框粘贴事件
382
- * @param {*} e
383
- */
384
- onPaste (e) {
385
- let { type } = e
386
-
387
- setTimeout(() => {
388
- // 获取当前内容长度
389
- let maxLength = this.maxLength
390
- // 获取粘贴内容后的总长度
391
- let len_Total = this.quill.getLength() - 1
392
-
393
- // 忽略粘贴事件
394
- if (type === 'paste' && maxLength && len_Total >= maxLength) {
395
- // 获取初始索引 index_old
396
- let selection_old = this.quill && this.quill.getSelection()
397
- let index_old = selection_old && selection_old.index || this.cursorIndex
398
-
399
- // 获取当前索引
400
- let index = index_old || maxLength || 0
401
-
402
- index = index - (len_Total - maxLength) + 1
403
-
404
- // 超出限制长度,截取
405
- this.quill.deleteText(index - 1, len_Total - maxLength)
406
- window.vant.Toast('字数超限')
407
- this.len = this.quill.getLength() - 1
408
- }
409
-
410
- this.$emit('input')
411
- }, 1)
412
- },
413
- /**
414
- * @description 监听输入框换行事件
415
- * @param {*} e
416
- */
417
- onEnter () {
418
- let index_old = this.quill && this.quill.getSelection() && this.quill.getSelection().index - 1
419
-
420
- // 获取当前内容长度
421
- let len = this.quill.getLength() - 1
422
- let maxLength = this.maxLength
423
-
424
- // 忽略粘贴事件
425
- if (maxLength && len >= maxLength) {
426
- // 获取当前索引
427
- let index = index_old || maxLength || 0
428
-
429
- if (index > maxLength) {
430
- index = maxLength
431
- }
432
-
433
- // 超出限制长度,截取
434
- this.quill.deleteText(index, len - maxLength)
435
- }
436
-
437
- setTimeout(() => {
438
- // 换行后需要定位到换行位置
439
- document.getSelection() && document.getSelection().getRangeAt(0) && document.getSelection().getRangeAt(0).commonAncestorContainer && document.getSelection().getRangeAt(0).commonAncestorContainer.scrollIntoView({ behavior: "auto", block: "center", inline: "center" })
440
- })
441
- },
442
- }
443
- }
444
- </script>
445
-
446
- <style lang="less">
447
- @import "./quill.snow.css";
448
- .hr-at-input {
449
- width: 100%;
450
- min-height: 22px;
451
- background: #fff;
452
- font-size: 14px;
453
- padding: 0px !important;
454
- border-radius: 4px;
455
-
456
- // 更改placeholder样式
457
- &.ql-editor .ql-blank::before {
458
- color: #a5a5a5;
459
- content: attr(data-placeholder);
460
- font-style: inherit;
461
- // pointer-events: none;
462
- position: absolute;
463
- left: 12px;
464
- right: 0;
465
- font-size: 13px;
466
- }
467
-
468
- .ql-editor {
469
- text-align: left !important;
470
- }
471
- }
472
- </style>