yks-element 1.0.0 → 1.0.4

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 (308) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +49 -4
  3. package/lib/theme-chalk/alert.css +1 -0
  4. package/lib/theme-chalk/aside.css +1 -0
  5. package/lib/theme-chalk/autocomplete.css +1 -0
  6. package/lib/theme-chalk/avatar.css +1 -0
  7. package/lib/theme-chalk/backtop.css +1 -0
  8. package/lib/theme-chalk/badge.css +1 -0
  9. package/lib/theme-chalk/base.css +1 -0
  10. package/lib/theme-chalk/breadcrumb-item.css +0 -0
  11. package/lib/theme-chalk/breadcrumb.css +1 -0
  12. package/lib/theme-chalk/button-group.css +0 -0
  13. package/lib/theme-chalk/button.css +1 -0
  14. package/lib/theme-chalk/buttons.css +1 -0
  15. package/lib/theme-chalk/calendar.css +1 -0
  16. package/lib/theme-chalk/card.css +1 -0
  17. package/lib/theme-chalk/carousel-item.css +1 -0
  18. package/lib/theme-chalk/carousel.css +1 -0
  19. package/lib/theme-chalk/cascader-panel.css +1 -0
  20. package/lib/theme-chalk/cascader.css +1 -0
  21. package/lib/theme-chalk/checkbox-button.css +0 -0
  22. package/lib/theme-chalk/checkbox-group.css +0 -0
  23. package/lib/theme-chalk/checkbox.css +1 -0
  24. package/lib/theme-chalk/col.css +1 -0
  25. package/lib/theme-chalk/collapse-item.css +0 -0
  26. package/lib/theme-chalk/collapse.css +1 -0
  27. package/lib/theme-chalk/color-picker.css +1 -0
  28. package/lib/theme-chalk/common.css +1 -0
  29. package/lib/theme-chalk/container.css +1 -0
  30. package/lib/theme-chalk/date-picker.css +1 -0
  31. package/lib/theme-chalk/descriptions-item.css +1 -0
  32. package/lib/theme-chalk/descriptions.css +1 -0
  33. package/lib/theme-chalk/dialog.css +1 -0
  34. package/lib/theme-chalk/display.css +1 -0
  35. package/lib/theme-chalk/divider.css +1 -0
  36. package/lib/theme-chalk/drawer.css +1 -0
  37. package/lib/theme-chalk/dropdown-item.css +0 -0
  38. package/lib/theme-chalk/dropdown-menu.css +0 -0
  39. package/lib/theme-chalk/dropdown.css +1 -0
  40. package/lib/theme-chalk/element-ui.css +1 -0
  41. package/lib/theme-chalk/element-variables.css +0 -0
  42. package/lib/theme-chalk/element.css +1 -0
  43. package/lib/theme-chalk/empty.css +1 -0
  44. package/{dist/fonts/element-icons.732389de.ttf → lib/theme-chalk/fonts/element-icons.ttf} +0 -0
  45. package/{dist/fonts/element-icons.535877f5.woff → lib/theme-chalk/fonts/element-icons.woff} +0 -0
  46. package/lib/theme-chalk/fonts/iconfont.ttf +0 -0
  47. package/lib/theme-chalk/fonts/iconfont.woff +0 -0
  48. package/lib/theme-chalk/footer.css +1 -0
  49. package/lib/theme-chalk/form-item.css +0 -0
  50. package/lib/theme-chalk/form.css +1 -0
  51. package/lib/theme-chalk/header.css +1 -0
  52. package/lib/theme-chalk/icon.css +1 -0
  53. package/lib/theme-chalk/icons.css +1 -0
  54. package/lib/theme-chalk/image.css +1 -0
  55. package/lib/theme-chalk/index.css +1 -0
  56. package/lib/theme-chalk/infinite-scroll.css +0 -0
  57. package/lib/theme-chalk/infiniteScroll.css +0 -0
  58. package/lib/theme-chalk/input-number.css +1 -0
  59. package/lib/theme-chalk/input.css +1 -0
  60. package/lib/theme-chalk/link.css +1 -0
  61. package/lib/theme-chalk/loading.css +1 -0
  62. package/lib/theme-chalk/main.css +1 -0
  63. package/lib/theme-chalk/menu-item-group.css +0 -0
  64. package/lib/theme-chalk/menu-item.css +0 -0
  65. package/lib/theme-chalk/menu.css +1 -0
  66. package/lib/theme-chalk/message-box.css +1 -0
  67. package/lib/theme-chalk/message.css +1 -0
  68. package/lib/theme-chalk/multimedia.css +1 -0
  69. package/lib/theme-chalk/notification.css +1 -0
  70. package/lib/theme-chalk/option-group.css +1 -0
  71. package/lib/theme-chalk/option.css +1 -0
  72. package/lib/theme-chalk/page-header.css +1 -0
  73. package/lib/theme-chalk/pagination.css +1 -0
  74. package/lib/theme-chalk/paginations.css +1 -0
  75. package/lib/theme-chalk/popconfirm.css +1 -0
  76. package/lib/theme-chalk/popover.css +1 -0
  77. package/lib/theme-chalk/popper.css +1 -0
  78. package/lib/theme-chalk/progress.css +1 -0
  79. package/lib/theme-chalk/radio-button.css +1 -0
  80. package/lib/theme-chalk/radio-group.css +1 -0
  81. package/lib/theme-chalk/radio.css +1 -0
  82. package/lib/theme-chalk/rate.css +1 -0
  83. package/lib/theme-chalk/reset.css +1 -0
  84. package/lib/theme-chalk/result.css +1 -0
  85. package/lib/theme-chalk/row.css +1 -0
  86. package/lib/theme-chalk/scrollbar.css +1 -0
  87. package/lib/theme-chalk/scrollbars.css +1 -0
  88. package/lib/theme-chalk/select-dropdown.css +1 -0
  89. package/lib/theme-chalk/select.css +1 -0
  90. package/lib/theme-chalk/selects.css +1 -0
  91. package/lib/theme-chalk/skeleton-item.css +1 -0
  92. package/lib/theme-chalk/skeleton.css +1 -0
  93. package/lib/theme-chalk/slider.css +1 -0
  94. package/lib/theme-chalk/spinner.css +1 -0
  95. package/lib/theme-chalk/step.css +1 -0
  96. package/lib/theme-chalk/steps.css +1 -0
  97. package/lib/theme-chalk/submenu.css +0 -0
  98. package/lib/theme-chalk/switch.css +1 -0
  99. package/lib/theme-chalk/tab-pane.css +0 -0
  100. package/lib/theme-chalk/table-column.css +1 -0
  101. package/lib/theme-chalk/table.css +1 -0
  102. package/lib/theme-chalk/tables.css +1 -0
  103. package/lib/theme-chalk/tabs.css +1 -0
  104. package/lib/theme-chalk/tag.css +1 -0
  105. package/lib/theme-chalk/time-picker.css +1 -0
  106. package/lib/theme-chalk/time-select.css +1 -0
  107. package/lib/theme-chalk/timeline-item.css +1 -0
  108. package/lib/theme-chalk/timeline.css +1 -0
  109. package/lib/theme-chalk/tinymce.css +1 -0
  110. package/lib/theme-chalk/tooltip.css +1 -0
  111. package/lib/theme-chalk/topic.css +1 -0
  112. package/lib/theme-chalk/transfer.css +1 -0
  113. package/lib/theme-chalk/tree.css +1 -0
  114. package/lib/theme-chalk/upload.css +1 -0
  115. package/lib/theme-chalk/uploadfile.css +1 -0
  116. package/lib/theme-chalk/video.css +1 -0
  117. package/lib/yks.js +1 -0
  118. package/package.json +101 -51
  119. package/packages/Dialog/index.js +8 -0
  120. package/packages/Dialog/src/index.vue +89 -0
  121. package/packages/Multimedia/index.js +8 -0
  122. package/packages/Multimedia/src/index.vue +136 -0
  123. package/packages/Pagination/index.js +8 -0
  124. package/packages/Pagination/src/index.vue +111 -0
  125. package/packages/Scrollbar/index.js +8 -0
  126. package/packages/Scrollbar/src/index.vue +20 -0
  127. package/packages/Select/index.js +8 -0
  128. package/packages/Select/src/index.vue +350 -0
  129. package/packages/Select/src/option.vue +29 -0
  130. package/packages/Table/index.js +8 -0
  131. package/packages/Table/src/index.vue +141 -0
  132. package/packages/Tinymce/index.js +8 -0
  133. package/packages/Tinymce/src/config.js +25 -0
  134. package/packages/Tinymce/src/index.vue +450 -0
  135. package/packages/Topic/index.js +23 -0
  136. package/packages/Topic/src/attachment.vue +114 -0
  137. package/packages/Topic/src/audioFrequency.vue +114 -0
  138. package/packages/Topic/src/clozeFillInBlanks.vue +237 -0
  139. package/packages/Topic/src/compound.vue +191 -0
  140. package/packages/Topic/src/config.js +132 -0
  141. package/packages/Topic/src/fillInBlanks.vue +242 -0
  142. package/packages/Topic/src/indefiniteChoice.vue +0 -0
  143. package/packages/Topic/src/judgment.vue +110 -0
  144. package/packages/Topic/src/matching.vue +0 -0
  145. package/packages/Topic/src/multiple.vue +163 -0
  146. package/packages/Topic/src/pictureAnswer.vue +113 -0
  147. package/packages/Topic/src/shortAnswer.vue +124 -0
  148. package/packages/Topic/src/single.vue +163 -0
  149. package/packages/UploadFile/index.js +8 -0
  150. package/packages/UploadFile/src/index.vue +358 -0
  151. package/packages/Video/index.js +8 -0
  152. package/packages/Video/src/index.vue +204 -0
  153. package/packages/assets/mixins/topic.js +137 -0
  154. package/packages/assets/utils/index.js +83 -0
  155. package/packages/assets/utils/topic.js +132 -0
  156. package/packages/icon/default/icons.js +182 -0
  157. package/packages/icon/default/icons.min.js +1 -0
  158. package/packages/icon/default/index.js +7 -0
  159. package/packages/icon/ks-pdf.png +0 -0
  160. package/packages/icon/ks-ppt.png +0 -0
  161. package/packages/icon/ks-word.png +0 -0
  162. package/packages/icon/ks-xslx.png +0 -0
  163. package/packages/icon/music-bg.png +0 -0
  164. package/packages/icon/video-bg.png +0 -0
  165. package/packages/index.js +221 -0
  166. package/packages/option/index.js +6 -0
  167. package/packages/styles/_mixin.scss +93 -0
  168. package/packages/styles/_variables.scss +40 -0
  169. package/packages/styles/alert.scss +147 -0
  170. package/packages/styles/aside.scss +7 -0
  171. package/packages/styles/autocomplete.scss +80 -0
  172. package/packages/styles/avatar.scss +51 -0
  173. package/packages/styles/backtop.scss +22 -0
  174. package/packages/styles/badge.scss +57 -0
  175. package/packages/styles/base.scss +2 -0
  176. package/packages/styles/breadcrumb-item.scss +0 -0
  177. package/packages/styles/breadcrumb.scss +55 -0
  178. package/packages/styles/button-group.scss +0 -0
  179. package/packages/styles/button.scss +262 -0
  180. package/packages/styles/buttons.scss +59 -0
  181. package/packages/styles/calendar.scss +79 -0
  182. package/packages/styles/card.scss +32 -0
  183. package/packages/styles/carousel-item.scss +50 -0
  184. package/packages/styles/carousel.scss +161 -0
  185. package/packages/styles/cascader-panel.scss +120 -0
  186. package/packages/styles/cascader.scss +182 -0
  187. package/packages/styles/checkbox-button.scss +0 -0
  188. package/packages/styles/checkbox-group.scss +0 -0
  189. package/packages/styles/checkbox.scss +359 -0
  190. package/packages/styles/col.scss +156 -0
  191. package/packages/styles/collapse-item.scss +0 -0
  192. package/packages/styles/collapse.scss +63 -0
  193. package/packages/styles/color-picker.scss +384 -0
  194. package/packages/styles/common/popup.scss +42 -0
  195. package/packages/styles/common/transition.scss +99 -0
  196. package/packages/styles/common/var.scss +1028 -0
  197. package/packages/styles/common.scss +204 -0
  198. package/packages/styles/container.scss +14 -0
  199. package/packages/styles/date-picker/date-picker.scss +97 -0
  200. package/packages/styles/date-picker/date-range-picker.scss +101 -0
  201. package/packages/styles/date-picker/date-table.scss +151 -0
  202. package/packages/styles/date-picker/month-table.scss +82 -0
  203. package/packages/styles/date-picker/picker-panel.scss +117 -0
  204. package/packages/styles/date-picker/picker.scss +197 -0
  205. package/packages/styles/date-picker/time-picker.scss +85 -0
  206. package/packages/styles/date-picker/time-range-picker.scss +31 -0
  207. package/packages/styles/date-picker/time-spinner.scss +110 -0
  208. package/packages/styles/date-picker/year-table.scss +51 -0
  209. package/packages/styles/date-picker.scss +12 -0
  210. package/packages/styles/descriptions-item.scss +42 -0
  211. package/packages/styles/descriptions.scss +111 -0
  212. package/packages/styles/dialog.scss +123 -0
  213. package/packages/styles/display.scss +12 -0
  214. package/packages/styles/divider.scss +47 -0
  215. package/packages/styles/drawer.scss +219 -0
  216. package/packages/styles/dropdown-item.scss +0 -0
  217. package/packages/styles/dropdown-menu.scss +0 -0
  218. package/packages/styles/dropdown.scss +182 -0
  219. package/packages/styles/element-ui.scss +135 -0
  220. package/packages/styles/element-variables.scss +794 -0
  221. package/packages/styles/element.scss +86 -0
  222. package/packages/styles/empty.scss +45 -0
  223. package/packages/styles/fonts/element-icons.ttf +0 -0
  224. package/packages/styles/fonts/element-icons.woff +0 -0
  225. package/packages/styles/fonts/iconfont.ttf +0 -0
  226. package/packages/styles/fonts/iconfont.woff +0 -0
  227. package/packages/styles/footer.scss +8 -0
  228. package/packages/styles/form-item.scss +0 -0
  229. package/packages/styles/form.scss +167 -0
  230. package/packages/styles/header.scss +8 -0
  231. package/packages/styles/icon.scss +1167 -0
  232. package/packages/styles/icons.scss +69 -0
  233. package/packages/styles/image.scss +179 -0
  234. package/packages/styles/index.scss +18 -0
  235. package/packages/styles/infinite-scroll.scss +0 -0
  236. package/packages/styles/infiniteScroll.scss +0 -0
  237. package/packages/styles/input-number.scss +180 -0
  238. package/packages/styles/input.scss +360 -0
  239. package/packages/styles/link.scss +81 -0
  240. package/packages/styles/loading.scss +96 -0
  241. package/packages/styles/main.scss +12 -0
  242. package/packages/styles/menu-item-group.scss +0 -0
  243. package/packages/styles/menu-item.scss +0 -0
  244. package/packages/styles/menu.scss +289 -0
  245. package/packages/styles/message-box.scss +226 -0
  246. package/packages/styles/message.scss +120 -0
  247. package/packages/styles/mixins/_button.scss +81 -0
  248. package/packages/styles/mixins/config.scss +4 -0
  249. package/packages/styles/mixins/function.scss +44 -0
  250. package/packages/styles/mixins/mixins.scss +190 -0
  251. package/packages/styles/mixins/utils.scss +39 -0
  252. package/packages/styles/multimedia.scss +58 -0
  253. package/packages/styles/notification.scss +99 -0
  254. package/packages/styles/option-group.scss +42 -0
  255. package/packages/styles/option.scss +36 -0
  256. package/packages/styles/page-header.scss +41 -0
  257. package/packages/styles/pagination.scss +295 -0
  258. package/packages/styles/paginations.scss +33 -0
  259. package/packages/styles/popconfirm.scss +16 -0
  260. package/packages/styles/popover.scss +40 -0
  261. package/packages/styles/popper.scss +101 -0
  262. package/packages/styles/progress.scss +141 -0
  263. package/packages/styles/radio-button.scss +113 -0
  264. package/packages/styles/radio-group.scss +9 -0
  265. package/packages/styles/radio.scss +199 -0
  266. package/packages/styles/rate.scss +49 -0
  267. package/packages/styles/reset.scss +79 -0
  268. package/packages/styles/result.scss +61 -0
  269. package/packages/styles/row.scss +43 -0
  270. package/packages/styles/scrollbar.scss +72 -0
  271. package/packages/styles/scrollbars.scss +5 -0
  272. package/packages/styles/select-dropdown.scss +62 -0
  273. package/packages/styles/select.scss +152 -0
  274. package/packages/styles/selects.scss +98 -0
  275. package/packages/styles/skeleton-item.scss +84 -0
  276. package/packages/styles/skeleton.scss +40 -0
  277. package/packages/styles/slider.scss +250 -0
  278. package/packages/styles/spinner.scss +44 -0
  279. package/packages/styles/step.scss +317 -0
  280. package/packages/styles/steps.scss +20 -0
  281. package/packages/styles/submenu.scss +0 -0
  282. package/packages/styles/switch.scss +116 -0
  283. package/packages/styles/tab-pane.scss +0 -0
  284. package/packages/styles/table-column.scss +97 -0
  285. package/packages/styles/table.scss +564 -0
  286. package/packages/styles/tables.scss +45 -0
  287. package/packages/styles/tabs.scss +602 -0
  288. package/packages/styles/tag.scss +163 -0
  289. package/packages/styles/time-picker.scss +8 -0
  290. package/packages/styles/time-select.scss +37 -0
  291. package/packages/styles/timeline-item.scss +86 -0
  292. package/packages/styles/timeline.scss +14 -0
  293. package/packages/styles/tinymce.scss +43 -0
  294. package/packages/styles/tooltip.scss +141 -0
  295. package/packages/styles/topic.scss +57 -0
  296. package/packages/styles/transfer.scss +227 -0
  297. package/packages/styles/tree.scss +123 -0
  298. package/packages/styles/upload.scss +603 -0
  299. package/packages/styles/uploadfile.scss +34 -0
  300. package/packages/styles/video.scss +98 -0
  301. package/types/index.d.ts +4 -0
  302. package/dist/demo.html +0 -10
  303. package/dist/yks.common.js +0 -64801
  304. package/dist/yks.css +0 -1
  305. package/dist/yks.umd.js +0 -64811
  306. package/dist/yks.umd.min.js +0 -15
  307. package/packages/button/index.vue +0 -16
  308. package/packages/index.ts +0 -12
@@ -0,0 +1,124 @@
1
+ <template>
2
+ <div class="single">
3
+ <div class="topic-stem__label required__label">题干</div>
4
+ <yks-tinymce
5
+ key="itemContent"
6
+ v-model="fromData.itemContent"
7
+ :toolbar="toolbar"
8
+ :plugins="plugins"
9
+ :charLimit="topicDataExtent.itemContentLength || 20000"
10
+ :fileParams="getFileTypes('stem', fromData.stemAttrs)"
11
+ :uploadFileToHwCloud="uploadFileToHwCloud"
12
+ :uploadFileFunction="uploadFileFunction"
13
+ menubar=""
14
+ height="200px"
15
+ @change="($event) => getTinymceEdit($event, 'stem')"
16
+ @delte="($event) => handleDelteAttrs($event, 'stem', fromData.stemAttrs)"
17
+ />
18
+ <div class="topic-stem__label required__label">标准答案</div>
19
+ <yks-tinymce
20
+ key="answer"
21
+ v-model="fromData.answer"
22
+ :toolbar="toolbar"
23
+ :plugins="plugins"
24
+ :charLimit="topicDataExtent.answerLength || 5000"
25
+ :fileParams="getFileTypes('answer', fromData.answerAttrs)"
26
+ :uploadFileToHwCloud="uploadFileToHwCloud"
27
+ :uploadFileFunction="uploadFileFunction"
28
+ menubar=""
29
+ height="200px"
30
+ @change="($event) => getTinymceEdit($event, 'answer')"
31
+ @delte="($event) => handleDelteAttrs($event, 'answer', fromData.answerAttrs)"
32
+ />
33
+ <div class="fill__other">
34
+ <div class="text__warning">
35
+ 如果勾选考生端开启数学公式编辑器,在PC端考生答题页面,本题答题区域考生可以使用数据公式编辑器。
36
+ </div>
37
+ <div class="yks-mt10">
38
+ <el-checkbox v-model="fromData.mathematical"
39
+ >考生端开启数学公式编辑器(只适用于PC端答题)</el-checkbox
40
+ >
41
+ </div>
42
+ </div>
43
+ <div class="topic-stem__label">答案解析</div>
44
+ <yks-tinymce
45
+ key="description"
46
+ v-model="fromData.description"
47
+ :toolbar="toolbar"
48
+ :plugins="plugins"
49
+ :charLimit="topicDataExtent.descriptionLength || 20000"
50
+ :fileParams="getFileTypes('analysis', fromData.descriptionAttrs)"
51
+ :uploadFileToHwCloud="uploadFileToHwCloud"
52
+ :uploadFileFunction="uploadFileFunction"
53
+ menubar=""
54
+ height="200px"
55
+ @change="($event) => getTinymceEdit($event, 'analysis')"
56
+ @delte="($event) => handleDelteAttrs($event, 'analysis', fromData.descriptionAttrs)"
57
+ />
58
+ </div>
59
+ </template>
60
+ <script>
61
+ import TopicMixins from 'yks/assets/mixins/topic'
62
+ import { stemItemType, shortItemType, analysisItemType } from './config'
63
+
64
+ export default {
65
+ name: 'YksShortanswer',
66
+ mixins: [TopicMixins],
67
+ methods: {
68
+ /**
69
+ * data 富文本数据
70
+ * field 对象名
71
+ * type 类型
72
+ */
73
+ getTinymceEdit(data, type) {
74
+ switch (type) {
75
+ case 'stem':
76
+ data.itemAttr.type = stemItemType[data.itemAttr.type]
77
+ this.fromData.itemContent = data.value
78
+ if (data.itemAttr.type && data.itemAttr.content) {
79
+ this.fromData.stemAttrs.push(data.itemAttr)
80
+ }
81
+ break
82
+ case 'answer':
83
+ data.itemAttr.type = shortItemType[data.itemAttr.type]
84
+ this.fromData.answer = data.value
85
+ if (data.itemAttr.type && data.itemAttr.content) {
86
+ this.fromData.answerAttrs.push(data.itemAttr)
87
+ }
88
+ break
89
+ case 'analysis':
90
+ data.itemAttr.type = analysisItemType[data.itemAttr.type]
91
+ this.fromData.description = data.value
92
+
93
+ if (data.itemAttr.type && data.itemAttr.content) {
94
+ this.fromData.descriptionAttrs.push(data.itemAttr)
95
+ }
96
+ break
97
+ default:
98
+ break
99
+ }
100
+ this.$emit('change', this.fromData)
101
+ },
102
+
103
+ handleDelteAttrs(data, type, list, row = {}) {
104
+ const listAttrs = list
105
+ listAttrs.splice(data.index, 1)
106
+ switch (type) {
107
+ case 'stem':
108
+ this.fromData.stemAttrs = listAttrs
109
+ break
110
+ case 'answer':
111
+ this.fromData.answerAttrs = listAttrs
112
+ break
113
+ case 'analysis':
114
+ this.fromData.descriptionAttrs = listAttrs
115
+ break
116
+ default:
117
+ break
118
+ }
119
+ this.$emit('change', this.fromData)
120
+ }
121
+ }
122
+ }
123
+ </script>
124
+
@@ -0,0 +1,163 @@
1
+ <template>
2
+ <div class="yks-topics">
3
+ <div class="topic-stem__label required__label">题干</div>
4
+ <yks-tinymce
5
+ key="itemContent"
6
+ v-model="fromData.itemContent"
7
+ :toolbar="toolbar"
8
+ :plugins="plugins"
9
+ :charLimit="topicDataExtent.itemContentLength || 20000"
10
+ :fileParams="getFileTypes('stem', fromData.stemAttrs)"
11
+ :uploadFileToHwCloud="uploadFileToHwCloud"
12
+ :uploadFileFunction="uploadFileFunction"
13
+ menubar=""
14
+ height="200px"
15
+ @change="($event) => getTinymceEdit($event, 'stem')"
16
+ @delte="($event) => handleDelteAttrs($event, 'stem', fromData.stemAttrs)"
17
+ />
18
+
19
+ <div class="yks-flex cloze-single">
20
+ <span class="single-single__label required__label">选项</span>
21
+ <span class="yks-fs-12 yks-info">请在编辑完选项后选择正确的答案</span>
22
+ </div>
23
+ <el-radio-group v-model="fromData.answer">
24
+ <div
25
+ v-for="(item, index) in fromData.itemList"
26
+ :key="`itemList${index}`"
27
+ class="yks-flex v-start yks-mb10"
28
+ >
29
+ <el-radio :label="item.optionName" class="yks-w_60 yks-mr10"></el-radio>
30
+ <yks-tinymce
31
+ :key="`itemList${index}`"
32
+ v-model="item.content"
33
+ :toolbar="toolbar"
34
+ :plugins="plugins"
35
+ :charLimit="topicDataExtent.answerLength || 5000"
36
+ :fileParams="getFileTypes('option', item.optionAttrs)"
37
+ :uploadFileToHwCloud="uploadFileToHwCloud"
38
+ :uploadFileFunction="uploadFileFunction"
39
+ inline
40
+ height="80px"
41
+ menubar=""
42
+ class="flex-1 radio-tinymce"
43
+ @change="($event) => changeItem($event, item)"
44
+ @delte="($event) => handleDelteAttrs($event, 'option', item.optionAttrs, item)"
45
+ />
46
+ <el-button
47
+ v-if="fromData.itemList.length > 2"
48
+ type="text"
49
+ class="yks-danger"
50
+ @click="handleDelte(index)"
51
+ >删除</el-button
52
+ >
53
+ </div>
54
+ </el-radio-group>
55
+ <el-button v-if="fromData.itemList.length < 14" type="primary" @click="handleAddItem"
56
+ >新增选项</el-button
57
+ >
58
+ <div class="topic-stem__label">答案解析</div>
59
+ <yks-tinymce
60
+ key="description"
61
+ v-model="fromData.description"
62
+ :toolbar="toolbar"
63
+ :plugins="plugins"
64
+ :charLimit="topicDataExtent.descriptionLength || 20000"
65
+ :fileParams="getFileTypes('analysis', fromData.descriptionAttrs)"
66
+ :uploadFileToHwCloud="uploadFileToHwCloud"
67
+ :uploadFileFunction="uploadFileFunction"
68
+ menubar=""
69
+ height="200px"
70
+ @change="($event) => getTinymceEdit($event, 'analysis')"
71
+ @delte="($event) => handleDelteAttrs($event, 'analysis', fromData.descriptionAttrs)"
72
+ />
73
+ </div>
74
+ </template>
75
+ <script>
76
+ import TopicMixins from 'yks/assets/mixins/topic'
77
+ import { letter, stemItemType, optionItemType, analysisItemType } from './config'
78
+
79
+ export default {
80
+ name: 'YksSingle',
81
+ mixins: [TopicMixins],
82
+ methods: {
83
+ /**
84
+ * data 富文本数据
85
+ * field 对象名
86
+ * type 类型
87
+ */
88
+ getTinymceEdit(data, type) {
89
+ switch (type) {
90
+ case 'stem':
91
+ data.itemAttr.type = stemItemType[data.itemAttr.type]
92
+ this.fromData.itemContent = data.value
93
+ if (data.itemAttr.type && data.itemAttr.content) {
94
+ this.fromData.stemAttrs.push(data.itemAttr)
95
+ }
96
+ break
97
+ case 'analysis':
98
+ data.itemAttr.type = analysisItemType[data.itemAttr.type]
99
+ this.fromData.description = data.value
100
+ if (data.itemAttr.type && data.itemAttr.content) {
101
+ this.fromData.descriptionAttrs.push(data.itemAttr)
102
+ }
103
+ break
104
+ default:
105
+ break
106
+ }
107
+ this.$emit('change', this.fromData)
108
+ },
109
+
110
+ changeItem(data, row) {
111
+ data.itemAttr.type = optionItemType[data.itemAttr.type]
112
+ if (data.itemAttr.type && data.itemAttr.content) {
113
+ row.optionAttrs.push(data.itemAttr)
114
+ this.$set(row, 'optionAttrs', row.optionAttrs)
115
+ }
116
+ this.$set(row, 'content', data.value)
117
+ this.$emit('change', this.fromData)
118
+ },
119
+
120
+ handleDelte(index) {
121
+ const { itemList } = this.fromData
122
+ itemList.splice(index, 1)
123
+ this.fromData.itemList = itemList.map((v, index) => {
124
+ return {
125
+ ...v,
126
+ optionName: letter[index]
127
+ }
128
+ })
129
+ this.$emit('change', this.fromData)
130
+ },
131
+
132
+ handleDelteAttrs(data, type, list, row = {}) {
133
+ const listAttrs = list
134
+ listAttrs.splice(data.index, 1)
135
+ switch (type) {
136
+ case 'stem':
137
+ this.fromData.stemAttrs = listAttrs
138
+ break
139
+ case 'option':
140
+ this.$set(row, 'optionAttrs', listAttrs)
141
+ break
142
+ case 'analysis':
143
+ this.fromData.descriptionAttrs = listAttrs
144
+ break
145
+ default:
146
+ break
147
+ }
148
+ this.$emit('change', this.fromData)
149
+ },
150
+
151
+ handleAddItem() {
152
+ const { itemList } = this.fromData
153
+ this.fromData.itemList.push({
154
+ optionName: letter[itemList.length],
155
+ content: '',
156
+ optionAttrs: []
157
+ })
158
+
159
+ this.$emit('change', this.fromData)
160
+ }
161
+ }
162
+ }
163
+ </script>
@@ -0,0 +1,8 @@
1
+ import YksUploadfile from './src/index';
2
+
3
+ /* istanbul ignore next */
4
+ YksUploadfile.install = function(Vue) {
5
+ Vue.component(YksUploadfile.name, YksUploadfile);
6
+ };
7
+
8
+ export default YksUploadfile;
@@ -0,0 +1,358 @@
1
+ <template>
2
+ <yks-dialog
3
+ :before-close="onClose"
4
+ :close-on-click-modal="false"
5
+ :destroy-on-close="true"
6
+ :title="title"
7
+ :show.sync="show"
8
+ append-to-body
9
+ width="600px"
10
+ height="300px"
11
+ @close="onClose"
12
+ @sure="onSure"
13
+ >
14
+ <div v-if="fileData.fileType === 'recording'" class="upload-dialog yks-tc">
15
+ <h1 class="dialog-title">{{ formatTimes(timestamp) }}</h1>
16
+ <div class="dialog-recording yks-flex h-center" @click="onRecord">
17
+ <i :class="['icon-recording', iconName]"></i>
18
+ </div>
19
+ <div class="yks-mt10 yks-fs-12 info">
20
+ 语音录入时长限制{{ (fileData.fileSize / 60).toFixed(2) }}分钟
21
+ </div>
22
+ <audio
23
+ ref="audioS"
24
+ :src="fileSrc"
25
+ class="dialog-audio"
26
+ @timeupdate="onTimeupdate"
27
+ ></audio>
28
+ </div>
29
+ <div v-else class="upload-dialog yks-tc">
30
+ <Upload
31
+ ref="uploadFile"
32
+ drag
33
+ action=""
34
+ show-file-list
35
+ :multiple="false"
36
+ :accept="accept"
37
+ :auto-upload="false"
38
+ :limit="1"
39
+ :on-change="beforeUpload"
40
+ >
41
+ <i class="el-icon-upload"></i>
42
+ <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
43
+ <div slot="tip" class="el-upload__tip">{{ tipsMsg }}</div>
44
+ </Upload>
45
+ </div>
46
+ <template slot="footer">
47
+ <div v-if="$slots.footer">
48
+ <slot name="footer" :row="fileDataRow"> </slot>
49
+ </div>
50
+ <div v-else>
51
+ <el-button
52
+ type="primary"
53
+ icon="el-icon-upload"
54
+ :disabled="!fileSrc || loading"
55
+ :loading="loading"
56
+ @click="handleUpload"
57
+ >上传文件</el-button
58
+ >
59
+ <el-button
60
+ type="danger"
61
+ icon="el-icon-delete"
62
+ :disabled="!fileSrc"
63
+ @click="hanleDelete"
64
+ >删除文件</el-button
65
+ >
66
+ </div>
67
+ </template>
68
+ </yks-dialog>
69
+ </template>
70
+
71
+ <script>
72
+ import { Upload, Message, MessageBox } from 'element-ui'
73
+
74
+ import { formatTime } from 'yks/assets/utils/index'
75
+
76
+ if (navigator.mediaDevices === undefined) {
77
+ navigator.mediaDevices = {}
78
+ }
79
+
80
+ if (navigator.mediaDevices.getUserMedia === undefined) {
81
+ navigator.mediaDevices.getUserMedia = function (constraints) {
82
+ const getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia
83
+ if (!getUserMedia) {
84
+ return Promise.reject(new Error('getUserMedia is not implemented in this browser'))
85
+ }
86
+ return new Promise(function (resolve, reject) {
87
+ getUserMedia.call(navigator, constraints, resolve, reject)
88
+ })
89
+ }
90
+ }
91
+
92
+ export default {
93
+ name: 'YksUploadfile',
94
+ components: {
95
+ Upload
96
+ },
97
+ props: {
98
+ show: {
99
+ type: Boolean,
100
+ default: false
101
+ },
102
+ title: {
103
+ type: String,
104
+ default: ''
105
+ },
106
+ /* 上传函数 */
107
+ uploadFileFunction: {
108
+ type: Function
109
+ },
110
+ /*
111
+ fileType: 上传类型
112
+ typeList: 文件类型
113
+ fileSize: 文件大小
114
+ */
115
+ fileData: {
116
+ type: Object,
117
+ default: () => {
118
+ return {}
119
+ }
120
+ }
121
+ },
122
+ data() {
123
+ return {
124
+ /* 录音状态 */
125
+ playStatus: false,
126
+
127
+ /* 播放状态 */
128
+ playing: false,
129
+
130
+ /* 媒体流 */
131
+ mediaRecorder: null,
132
+
133
+ /* 录音文件地址 */
134
+ fileSrc: '',
135
+
136
+ /* 录音时长 */
137
+ timestamp: 0,
138
+
139
+ /* 记录录音时长 */
140
+ recordTimestamp: 0,
141
+
142
+ /* 定时器 */
143
+ interval: null,
144
+
145
+ /* 文件信息 */
146
+ data: null,
147
+
148
+ loading: false
149
+ }
150
+ },
151
+ computed: {
152
+ accept() {
153
+ const { typeList } = this.fileData
154
+ if (typeList && typeList.length > 0) {
155
+ return '.' + typeList.join(',.')
156
+ }
157
+ return ''
158
+ },
159
+ tipsMsg() {
160
+ let msg = ''
161
+ let type = ''
162
+ const { typeList, fileSize } = this.fileData
163
+ if (typeList && typeList.length > 0) {
164
+ type = typeList.join('、')
165
+ msg = `只能上传${type}文件`
166
+ if (fileSize) {
167
+ return `${msg},且不超过${fileSize}MB`
168
+ }
169
+ }
170
+ if (fileSize) {
171
+ msg += `文件大小不超过${fileSize}MB`
172
+ }
173
+ return msg
174
+ },
175
+ iconName() {
176
+ if (this.fileSrc && !this.playing) {
177
+ return 'el-icon-caret-right'
178
+ }
179
+ if (this.playStatus || this.playing) {
180
+ return 'icon-pause'
181
+ }
182
+ return 'el-icon-microphone'
183
+ },
184
+ fileDataRow() {
185
+ return this.data || {}
186
+ }
187
+ },
188
+ watch: {
189
+ timestamp(val) {
190
+ if (val <= 0.2) {
191
+ clearInterval(this.interval)
192
+ this.playing = false
193
+ this.timestamp = this.recordTimestamp
194
+ }
195
+ },
196
+ show(val) {
197
+ if (val) {
198
+ this.resetData()
199
+ }
200
+ }
201
+ },
202
+ created() {
203
+ console.log(this.$slots.footer)
204
+ },
205
+ methods: {
206
+ formatTimes(value) {
207
+ return formatTime(value)
208
+ },
209
+ resetData() {
210
+ this.fileSrc = ''
211
+ this.data = ''
212
+ this.timestamp = 0
213
+ this.recordTimestamp = 0
214
+ this.playStatus = false
215
+ this.playing = false
216
+ },
217
+
218
+ beforeUpload(file) {
219
+ const name = file.name.substr(file.name.lastIndexOf('.') + 1).toLowerCase()
220
+ const { typeList, fileSize } = this.fileData
221
+ const isLt2M = file.size / 1024 / 1024 > fileSize
222
+ const isType = typeList.includes(name)
223
+ const type = typeList.join('、')
224
+ if (fileSize && isLt2M) {
225
+ Message.error(`上传文件大小不能超过 ${fileSize}MB!`)
226
+ this.$refs.uploadFile.clearFiles()
227
+ return false
228
+ }
229
+ if (typeList && !isType) {
230
+ Message.error(`只能上传${type}文件!`)
231
+ this.$refs.uploadFile.clearFiles()
232
+ return false
233
+ }
234
+ this.fileSrc = file
235
+ this.data = file
236
+ return true
237
+ },
238
+
239
+ async handleUpload() {
240
+ this.loading = true
241
+ try {
242
+ const data = await this.uploadFileFunction({
243
+ file: this.data,
244
+ fileData: this.fileData,
245
+ fileSrc: this.fileSrc
246
+ })
247
+ this.$emit('sure', data)
248
+ this.onClose()
249
+ } catch (error) {
250
+ console.log(error)
251
+ }
252
+ this.loading = false
253
+ },
254
+
255
+ onTimeupdate(el) {
256
+ this.timestamp = this.recordTimestamp - el.target.currentTime
257
+ },
258
+
259
+ hanleDelete() {
260
+ MessageBox.confirm('是否删除当前文件?', '提示', {
261
+ confirmButtonText: '确定',
262
+ cancelButtonText: '取消',
263
+ type: 'warning'
264
+ })
265
+ .then(() => {
266
+ this.fileSrc = ''
267
+ this.data = ''
268
+ this.timestamp = 0
269
+ this.recordTimestamp = 0
270
+ this.$refs.uploadFile.clearFiles()
271
+ })
272
+ .catch(() => {
273
+ //
274
+ })
275
+ },
276
+
277
+ /* 录音 */
278
+ async onRecord() {
279
+ if (this.fileSrc) {
280
+ if (this.playing) {
281
+ this.$refs.audioS.pause()
282
+ this.playing = false
283
+ } else {
284
+ this.$refs.audioS.play()
285
+ this.playing = true
286
+ }
287
+ return
288
+ }
289
+ try {
290
+ if (this.playStatus) {
291
+ this.mediaRecorder.stop()
292
+ this.playStatus = false
293
+ this.mediaRecorder = ''
294
+ clearInterval(this.interval)
295
+ this.interval = null
296
+ this.recordTimestamp = this.timestamp
297
+ } else {
298
+ this.interval = setInterval(() => {
299
+ this.timestamp += 1
300
+ if (this.fileData.fileSize <= this.timestamp) {
301
+ this.onRecord()
302
+ }
303
+ }, 1000)
304
+ const audio = await navigator.mediaDevices.getUserMedia({
305
+ audio: true,
306
+ video: false
307
+ })
308
+ this.mediaRecorder = new MediaRecorder(audio)
309
+ this.mediaRecorder.start()
310
+ this.playStatus = true
311
+ this.mediaRecorder.addEventListener('dataavailable', (el) => {
312
+ this.fileSrc = URL.createObjectURL(el.data)
313
+ this.data = el
314
+ })
315
+ }
316
+ } catch (error) {
317
+ const params = error
318
+ this.playStatus = false
319
+ this.mediaRecorder = ''
320
+ clearInterval(this.interval)
321
+ this.interval = null
322
+ this.recordTimestamp = 0
323
+ this.timestamp = 0
324
+ let errorMessage
325
+ switch (params.name) {
326
+ case 'NotAllowedError':
327
+ errorMessage = '用户拒绝,请在浏览器打开录音权限!'
328
+ break
329
+ case 'PermissionDeniedError':
330
+ errorMessage = '用户已禁止网页调用录音设备'
331
+ break
332
+ case 'NotFoundError':
333
+ errorMessage = '没接入录音设备'
334
+ break
335
+ case 'DevicesNotFoundError':
336
+ errorMessage = '录音设备未找到'
337
+ break
338
+ case 'NotSupportedError':
339
+ errorMessage = '不支持录音功能'
340
+ break
341
+ default:
342
+ errorMessage = '录音调用错误'
343
+ break
344
+ }
345
+ Message.error(errorMessage)
346
+ }
347
+ },
348
+
349
+ onClose() {
350
+ this.$emit('update:show', false)
351
+ },
352
+
353
+ onSure() {
354
+ this.onClose()
355
+ }
356
+ }
357
+ }
358
+ </script>
@@ -0,0 +1,8 @@
1
+ import YksVideo from './src/index';
2
+
3
+ /* istanbul ignore next */
4
+ YksVideo.install = function(Vue) {
5
+ Vue.component(YksVideo.name, YksVideo);
6
+ };
7
+
8
+ export default YksVideo;