yks-element 1.0.317 → 1.0.320

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.
@@ -0,0 +1,194 @@
1
+ <template>
2
+ <div class="single">
3
+ <div class="single-stem__label required__label">题干</div>
4
+ <yks-tinymce
5
+ key="itemContent"
6
+ :value="fromData.itemContent"
7
+ :toolbar="toolbar"
8
+ :plugins="plugins"
9
+ :charLimit="topicDataExtent.itemContentLength || 20000"
10
+
11
+ :fileParams="getFileTypes('stem', fromData.stemAttrs)"
12
+ :uploadFileToHwCloud="uploadFileToHwCloud"
13
+ :uploadFileFunction="uploadFileFunction"
14
+ menubar=""
15
+ height="200px"
16
+ @change="($event) => getTinymceEdit($event, 'stem')"
17
+ @delte="($event) => handleDelteAttrs($event, 'stem', fromData.stemAttrs)"
18
+ />
19
+
20
+ <div class="yks-flex single-single">
21
+ <span class="single-single__label required__label">选项</span>
22
+ <span class="yks-fs-12 yks-info">请在编辑完选项后选择正确的答案</span>
23
+ </div>
24
+ <el-radio-group v-model="fromData.answer">
25
+ <div
26
+ v-for="(item, index) in fromData.itemList"
27
+ :key="`itemList${index}`"
28
+ class="yks-flex v-start yks-mb10"
29
+ >
30
+ <el-radio :label="item.optionName" class="yks-w_60 yks-mr10"></el-radio>
31
+ <yks-tinymce
32
+ :key="`itemList${index}`"
33
+ :value="item.content"
34
+ :toolbar="toolbar"
35
+ :plugins="plugins"
36
+ :charLimit="topicDataExtent.answerLength || 5000"
37
+
38
+ :fileParams="getFileTypes('option', item.optionAttrs)"
39
+ :uploadFileToHwCloud="uploadFileToHwCloud"
40
+ :uploadFileFunction="uploadFileFunction"
41
+ inline
42
+ height="80px"
43
+ menubar=""
44
+ class="flex-1 radio-tinymce"
45
+ @change="($event) => changeItem($event, item)"
46
+ @delte="($event) => handleDelteAttrs($event, 'option', item.optionAttrs, item)"
47
+ />
48
+ <el-button
49
+ v-if="fromData.itemList.length > 2"
50
+ type="text"
51
+ class="yks-danger"
52
+ @click="handleDelte(index)"
53
+ >删除</el-button
54
+ >
55
+ </div>
56
+ </el-radio-group>
57
+ <el-button v-if="fromData.itemList.length < 14" type="primary" @click="handleAddItem"
58
+ >新增选项</el-button
59
+ >
60
+ <div class="single-stem__label">答案解析</div>
61
+ <yks-tinymce
62
+ key="description"
63
+ :value="fromData.description"
64
+ :toolbar="toolbar"
65
+ :plugins="plugins"
66
+ :charLimit="topicDataExtent.descriptionLength || 20000"
67
+
68
+ :fileParams="getFileTypes('analysis', fromData.descriptionAttrs)"
69
+ :uploadFileToHwCloud="uploadFileToHwCloud"
70
+ :uploadFileFunction="uploadFileFunction"
71
+ menubar=""
72
+ height="200px"
73
+ @change="($event) => getTinymceEdit($event, 'analysis')"
74
+ @delte="($event) => handleDelteAttrs($event, 'analysis', fromData.descriptionAttrs)"
75
+ />
76
+ </div>
77
+ </template>
78
+ <script>
79
+ import YksTinymce from '../../Tinymce/index'
80
+ import TopicMixins from '../../assets/mixins/topic'
81
+ import { letter, stemItemType, optionItemType, analysisItemType } from './config'
82
+
83
+ export default {
84
+ name: 'Single',
85
+ components: { YksTinymce },
86
+ mixins: [TopicMixins],
87
+ methods: {
88
+ /**
89
+ * data 富文本数据
90
+ * field 对象名
91
+ * type 类型
92
+ */
93
+ getTinymceEdit(data, type) {
94
+ switch (type) {
95
+ case 'stem':
96
+ data.itemAttr.type = stemItemType[data.itemAttr.type]
97
+ this.fromData.itemContent = data.value
98
+ if (data.itemAttr.type && data.itemAttr.content) {
99
+ this.fromData.stemAttrs.push(data.itemAttr)
100
+ }
101
+ break
102
+ case 'analysis':
103
+ data.itemAttr.type = analysisItemType[data.itemAttr.type]
104
+ this.fromData.description = data.value
105
+ if (data.itemAttr.type && data.itemAttr.content) {
106
+ this.fromData.descriptionAttrs.push(data.itemAttr)
107
+ }
108
+ break
109
+ default:
110
+ break
111
+ }
112
+ this.$emit('change', this.fromData)
113
+ },
114
+
115
+ changeItem(data, row) {
116
+ data.itemAttr.type = optionItemType[data.itemAttr.type]
117
+ if (data.itemAttr.type && data.itemAttr.content) {
118
+ row.optionAttrs.push(data.itemAttr)
119
+ this.$set(row, 'optionAttrs', row.optionAttrs)
120
+ }
121
+ this.$set(row, 'content', data.value)
122
+ this.$emit('change', this.fromData)
123
+ },
124
+
125
+ handleDelte(index) {
126
+ const { itemList } = this.fromData
127
+ itemList.splice(index, 1)
128
+ this.fromData.itemList = itemList.map((v, index) => {
129
+ return {
130
+ ...v,
131
+ optionName: letter[index]
132
+ }
133
+ })
134
+ this.$emit('change', this.fromData)
135
+ },
136
+
137
+ handleDelteAttrs(data, type, list, row = {}) {
138
+ const listAttrs = list
139
+ listAttrs.splice(data.index, 1)
140
+ switch (type) {
141
+ case 'stem':
142
+ this.fromData.stemAttrs = listAttrs
143
+ break
144
+ case 'option':
145
+ this.$set(row, 'optionAttrs', listAttrs)
146
+ break
147
+ case 'analysis':
148
+ this.fromData.descriptionAttrs = listAttrs
149
+ break
150
+ default:
151
+ break
152
+ }
153
+ this.$emit('change', this.fromData)
154
+ },
155
+
156
+ handleAddItem() {
157
+ const { itemList } = this.fromData
158
+ this.fromData.itemList.push({
159
+ optionName: letter[itemList.length],
160
+ content: '',
161
+ optionAttrs: []
162
+ })
163
+
164
+ this.$emit('change', this.fromData)
165
+ }
166
+ }
167
+ }
168
+ </script>
169
+
170
+ <style lang="scss" scoped>
171
+ .single-single {
172
+ margin: 30px 0;
173
+ .single-single__label {
174
+ font-weight: 700;
175
+ font-size: 18px;
176
+ width: 100px;
177
+ }
178
+ }
179
+ .single-stem__label {
180
+ font-weight: 700;
181
+ font-size: 18px;
182
+ margin: 30px 0;
183
+ }
184
+ .radio-tinymce {
185
+ font-size: 14px;
186
+ margin-right: 20px;
187
+ }
188
+
189
+ ::v-deep {
190
+ .el-radio-group {
191
+ display: block;
192
+ }
193
+ }
194
+ </style>
@@ -102,8 +102,7 @@ export default {
102
102
  },
103
103
  /* 上传函数 */
104
104
  uploadFileFunction: {
105
- type: Function,
106
- required: true
105
+ type: Function
107
106
  },
108
107
  /*
109
108
  fileType: 上传类型
@@ -0,0 +1,137 @@
1
+ import { toolbar, plugins, toolbarSpare } from '../utils/topic'
2
+
3
+ export default {
4
+ model: {
5
+ prop: 'fromData',
6
+ event: 'change'
7
+ },
8
+ props: {
9
+ topicDataExtent: {
10
+ type: Object,
11
+ default: () => {
12
+ return {}
13
+ }
14
+ },
15
+ uploadFileCloud: {
16
+ required: true,
17
+ type: Function
18
+ },
19
+ fromData: {
20
+ required: true,
21
+ type: Object,
22
+ default: () => {
23
+ return {}
24
+ }
25
+ }
26
+ },
27
+ data() {
28
+ return {
29
+ pageLoading: false,
30
+ processing: false,
31
+ toolbar: toolbar,
32
+ toolbarSpare: toolbarSpare,
33
+ plugins: plugins,
34
+ topic: {
35
+ single: '单项选择题',
36
+ multiple: '多项选择题',
37
+ judgment: '判断题',
38
+ short_answer: '简答题'
39
+ }
40
+ }
41
+ },
42
+ methods: {
43
+ /**
44
+ * 获取题类型
45
+ * @param {string} type
46
+ * @return {Object}
47
+ */
48
+ getFileType(type, data) {
49
+ if (data) {
50
+ let params = {}
51
+ switch (type) {
52
+ case 'stem':
53
+ params = {
54
+ stem_voiceRecord: 'recording',
55
+ stem_video: 'video',
56
+ stem_audio: 'audio',
57
+ stem_document: 'file'
58
+ }
59
+ break
60
+ case 'answer':
61
+ params = {
62
+ answer_voiceRecord: 'recording',
63
+ answer_video: 'video',
64
+ answer_audio: 'audio',
65
+ answer_document: 'file'
66
+ }
67
+ break
68
+ case 'option':
69
+ params = {
70
+ option_voiceRecord: 'recording',
71
+ option_video: 'video',
72
+ option_audio: 'audio',
73
+ option_document: 'file'
74
+ }
75
+ break
76
+ case 'analysis':
77
+ params = {
78
+ description_voiceRecord: 'recording',
79
+ description_video: 'video',
80
+ description_audio: 'audio',
81
+ description_document: 'file'
82
+ }
83
+ break
84
+ }
85
+ const fileType = params[data.type]
86
+
87
+ return {
88
+ ...data,
89
+ fileType
90
+ }
91
+ }
92
+ return false
93
+ },
94
+ getFileTypes(type, list) {
95
+ return (list || []).map((v) => this.getFileType(type, v))
96
+ },
97
+ async uploadFileToHwCloud(file) {
98
+ try {
99
+ const fileData = new FormData()
100
+ fileData.append('fileType', 'stem')
101
+ fileData.append('file', file.blob())
102
+ const { data, code } = await this.uploadFileCloud(fileData)
103
+ if (code === 20000) {
104
+ return data
105
+ } else {
106
+ return ''
107
+ }
108
+ } catch (error) {
109
+ console.log(error)
110
+ return ''
111
+ }
112
+ },
113
+ async uploadFileFunction({ file, fileData }) {
114
+ try {
115
+ const fileDatas = new FormData()
116
+ if (fileData.fileType === 'recording') {
117
+ const fileNmae = Date.now() + '.mp3'
118
+ const files = new File([file.data], fileNmae)
119
+ fileDatas.append('fileType', 'multimediaFile')
120
+ fileDatas.append('file', files)
121
+ } else {
122
+ fileDatas.append('fileType', 'multimediaFile')
123
+ fileDatas.append('file', file.raw)
124
+ }
125
+ const { data, code } = await this.uploadFileCloud(fileDatas)
126
+ if (code === 20000) {
127
+ return data
128
+ } else {
129
+ return Promise.reject(new Error('出错了'))
130
+ }
131
+ } catch (error) {
132
+ console.log(error)
133
+ return Promise.reject(error)
134
+ }
135
+ }
136
+ }
137
+ }
@@ -0,0 +1,132 @@
1
+ /**
2
+ * uploadRecording 录音
3
+ * uploadVideo 视频
4
+ * uploadAudio 音频
5
+ * uploadFile 文件
6
+ */
7
+
8
+ export const toolbar = [
9
+ 'bold underline italic strikethrough | kityformula-editor subscript superscript charmap | link image | table | removeformat | uploadRecording uploadVideo uploadAudio uploadFile'
10
+ ]
11
+
12
+ /* 选项、填空等 */
13
+ export const toolbarSpare = ['kityformula-editor subscript superscript charmap']
14
+
15
+ /* 插件 */
16
+ export const plugins = ['kityformula-editor powerpaste lists image media table charmap imagetools']
17
+
18
+ /* 选项字符 */
19
+ export const letter = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N']
20
+
21
+ /* 自定义添加菜单项(录音、上传视频、上传音乐、上传文件):题干 / 标题 - 类型 */
22
+ export const stemItemType = {
23
+ recording: 'stem_voiceRecord',
24
+ video: 'stem_video',
25
+ audio: 'stem_audio',
26
+ file: 'stem_document'
27
+ }
28
+
29
+ /* 自定义添加菜单项(录音、上传视频、上传音乐、上传文件): 标准答案 - 类型 */
30
+ export const shortItemType = {
31
+ recording: 'answer_voiceRecord',
32
+ video: 'answer_video',
33
+ audio: 'answer_audio',
34
+ file: 'answer_document'
35
+ }
36
+
37
+ /* 自定义添加菜单项(录音、上传视频、上传音乐、上传文件): 选项 - 类型 */
38
+ export const optionItemType = {
39
+ recording: 'option_voiceRecord',
40
+ video: 'option_video',
41
+ audio: 'option_audio',
42
+ file: 'option_document'
43
+ }
44
+
45
+ /* 自定义添加菜单项(录音、上传视频、上传音乐、上传文件): 答案解析 - 类型 */
46
+ export const analysisItemType = {
47
+ recording: 'description_voiceRecord',
48
+ video: 'description_video',
49
+ audio: 'description_audio',
50
+ file: 'description_document'
51
+ }
52
+
53
+ /**
54
+ * 获取题类型
55
+ * @param {string} type
56
+ * @return {Object}
57
+ */
58
+ export const getFileType = (type, data) => {
59
+ if (data) {
60
+ let params = {}
61
+ switch (type) {
62
+ case 'stem':
63
+ params = {
64
+ stem_voiceRecord: 'recording',
65
+ stem_video: 'video',
66
+ stem_audio: 'audio',
67
+ stem_document: 'file'
68
+ }
69
+ break
70
+ case 'answer':
71
+ params = {
72
+ answer_voiceRecord: 'recording',
73
+ answer_video: 'video',
74
+ answer_audio: 'audio',
75
+ answer_document: 'file'
76
+ }
77
+ break
78
+ case 'option':
79
+ params = {
80
+ option_voiceRecord: 'recording',
81
+ option_video: 'video',
82
+ option_audio: 'audio',
83
+ option_document: 'file'
84
+ }
85
+ break
86
+ case 'analysis':
87
+ params = {
88
+ description_voiceRecord: 'recording',
89
+ description_video: 'video',
90
+ description_audio: 'audio',
91
+ description_document: 'file'
92
+ }
93
+ break
94
+ }
95
+ const fileType = params[data.type]
96
+
97
+ return {
98
+ ...data,
99
+ fileType
100
+ }
101
+ }
102
+ return false
103
+ }
104
+
105
+ export const itemDataLists = () => {
106
+ return [
107
+ {
108
+ optionName: 'A',
109
+ content: '',
110
+ optionAttrs: [],
111
+ score: ''
112
+ },
113
+ {
114
+ optionName: 'B',
115
+ content: '',
116
+ optionAttrs: [],
117
+ score: ''
118
+ },
119
+ {
120
+ optionName: 'C',
121
+ content: '',
122
+ optionAttrs: [],
123
+ score: ''
124
+ },
125
+ {
126
+ optionName: 'D',
127
+ content: '',
128
+ optionAttrs: [],
129
+ score: ''
130
+ }
131
+ ]
132
+ }
package/packages/index.js CHANGED
@@ -94,6 +94,18 @@ import YksUploadfile from './UploadFile'
94
94
  import YksVideo from './Video'
95
95
  import YksOption from './option/index'
96
96
 
97
+ import {
98
+ Single,
99
+ Multiple,
100
+ Judgment,
101
+ FillInBlanks,
102
+ ShortAnswer,
103
+ PictureAnswer,
104
+ Compound,
105
+ AudioFrequency,
106
+ Attachment
107
+ } from './Topic/index'
108
+
97
109
  import locale from 'element-ui/src/locale'
98
110
  const components = [
99
111
  YskButton,
@@ -136,10 +148,19 @@ if (typeof window !== 'undefined' && window.Vue) {
136
148
  install(window.Vue)
137
149
  }
138
150
  export default {
139
- version: '1.0.317',
151
+ version: '1.0.320',
140
152
  locale: locale.use,
141
153
  i18n: locale.i18n,
142
154
  install,
155
+ Single,
156
+ Multiple,
157
+ Judgment,
158
+ FillInBlanks,
159
+ ShortAnswer,
160
+ PictureAnswer,
161
+ Compound,
162
+ AudioFrequency,
163
+ Attachment,
143
164
  /* element-ui */
144
165
  Pagination,
145
166
  Dialog,
@@ -1,3 +1,7 @@
1
+ @import './variables';
2
+ @import './mixin';
3
+ @import './element-variables';
4
+
1
5
  * {
2
6
  box-sizing: border-box;
3
7
  }
@@ -61,6 +65,10 @@
61
65
  -webkit-line-clamp: 4;
62
66
  }
63
67
 
68
+ .yks-w_60 {
69
+ width: 60px !important;
70
+ }
71
+
64
72
  .yks-w_80 {
65
73
  width: 80px !important;
66
74
  }
@@ -132,7 +140,7 @@
132
140
  &.f-wrap {
133
141
  flex-wrap: wrap;
134
142
  }
135
-
143
+
136
144
  .flex-1 {
137
145
  flex: 1;
138
146
  }
@@ -165,3 +173,28 @@
165
173
  .yks-fs-12 {
166
174
  font-size: 12px;
167
175
  }
176
+
177
+ .yks-primary {
178
+ color: $--color-primary;
179
+ }
180
+
181
+ .yks-success {
182
+ color: $--color-success;
183
+ }
184
+
185
+ .yks-warning {
186
+ color: $--color-warning;
187
+ }
188
+
189
+ .yks-info {
190
+ color: $--color-info;
191
+ }
192
+
193
+ .yks-danger {
194
+ color: $--color-danger;
195
+ }
196
+
197
+ .yks-disabled {
198
+ cursor: no-drop !important;
199
+ opacity: 0.5 !important;
200
+ }
@@ -2,9 +2,10 @@
2
2
  @import './mixin';
3
3
  @import './element-variables';
4
4
  // @import '~element-ui/lib/theme-chalk/index.css';
5
- @import '~element-ui/packages/theme-chalk/src/index.scss';
6
- @import './element-ui.scss';
7
- @import './common.scss';
8
- @import './icon.scss';
9
- @import './select.scss';
10
- @import './table.scss';
5
+ @import '~element-ui/packages/theme-chalk/src/index';
6
+ @import './element-ui';
7
+ @import './common';
8
+ @import './icon';
9
+ @import './select';
10
+ @import './table';
11
+ @import './topic'
@@ -0,0 +1,26 @@
1
+ @import './variables';
2
+ @import './mixin';
3
+ @import './element-variables';
4
+
5
+ .required__label {
6
+ position: relative;
7
+ &::before {
8
+ content: '*';
9
+ color: $--color-danger;
10
+ margin-right: 4px;
11
+ }
12
+ }
13
+
14
+ .text__warning {
15
+ color: $--color-danger;
16
+ }
17
+
18
+ .fill__other {
19
+ font-size: 12px;
20
+ padding: 10px;
21
+ background: #e1f5fe;
22
+ border: #bbdefb solid 1px;
23
+ border-radius: 5px;
24
+ margin-top: 10px;
25
+ }
26
+