ai-question-pro 0.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.
- package/README.md +33 -0
- package/components/demo/api/index.js +18 -0
- package/components/demo/index.js +7 -0
- package/components/demo/plugins/cache.js +77 -0
- package/components/demo/src/CyTreeSelect.vue +209 -0
- package/components/demo/src/main.vue +536 -0
- package/components/demo/src/questionItem.vue +146 -0
- package/components/demo/static/addQuesTitBg.png +0 -0
- package/components/demo/static/robot.png +0 -0
- package/components/demo/static/unzan_bg.png +0 -0
- package/components/demo/static/unzan_plain.png +0 -0
- package/components/demo/static/zan_bg.png +0 -0
- package/components/demo/static/zan_plain.png +0 -0
- package/components/demo/utils/request.js +76 -0
- package/components/index.js +15 -0
- package/dist/ai-question.common.js +5468 -0
- package/dist/ai-question.common.js.map +1 -0
- package/dist/ai-question.umd.js +5479 -0
- package/dist/ai-question.umd.js.map +1 -0
- package/dist/ai-question.umd.min.js +4 -0
- package/dist/ai-question.umd.min.js.map +1 -0
- package/dist/demo.html +1 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# ai-questtion
|
|
2
|
+
|
|
3
|
+
## Project setup
|
|
4
|
+
```
|
|
5
|
+
npm install
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
### Compiles and minifies for production
|
|
9
|
+
```
|
|
10
|
+
npm run build
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Customize configuration
|
|
14
|
+
See [Configuration Reference](https://cli.vuejs.org/config/).
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### test-project是测试组件项目
|
|
18
|
+
|
|
19
|
+
### 公司自用组件 npm i ai-question
|
|
20
|
+
|
|
21
|
+
### 调用方法
|
|
22
|
+
...
|
|
23
|
+
|
|
24
|
+
this.$refs.name.showAddQuestion()
|
|
25
|
+
...
|
|
26
|
+
|
|
27
|
+
### top控制侧边弹框到顶部的距离
|
|
28
|
+
|
|
29
|
+
### knowledgeList根据elment传参格式传入树形数据
|
|
30
|
+
|
|
31
|
+
### propFormat知识点传参格式修改 {value : 'xxx',label : 'xxx','children' : 'xxx'}
|
|
32
|
+
|
|
33
|
+
### join加入题库
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import request from '../utils/request'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const getAiQuestion = (data) => {
|
|
5
|
+
return request({
|
|
6
|
+
url: '/xh/aiQuestion',
|
|
7
|
+
method: 'post',
|
|
8
|
+
data: data
|
|
9
|
+
})
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const agreeQuestion = (data) => {
|
|
13
|
+
return request({
|
|
14
|
+
url: `/xh/evaluateQuestion`,
|
|
15
|
+
method: 'post',
|
|
16
|
+
data: data
|
|
17
|
+
})
|
|
18
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const sessionCache = {
|
|
2
|
+
set (key, value) {
|
|
3
|
+
if (!sessionStorage) {
|
|
4
|
+
return
|
|
5
|
+
}
|
|
6
|
+
if (key != null && value != null) {
|
|
7
|
+
sessionStorage.setItem(key, value)
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
get (key) {
|
|
11
|
+
if (!sessionStorage) {
|
|
12
|
+
return null
|
|
13
|
+
}
|
|
14
|
+
if (key == null) {
|
|
15
|
+
return null
|
|
16
|
+
}
|
|
17
|
+
return sessionStorage.getItem(key)
|
|
18
|
+
},
|
|
19
|
+
setJSON (key, jsonValue) {
|
|
20
|
+
if (jsonValue != null) {
|
|
21
|
+
this.set(key, JSON.stringify(jsonValue))
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
getJSON (key) {
|
|
25
|
+
const value = this.get(key)
|
|
26
|
+
if (value != null) {
|
|
27
|
+
return JSON.parse(value)
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
remove (key) {
|
|
31
|
+
sessionStorage.removeItem(key);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const localCache = {
|
|
35
|
+
set (key, value) {
|
|
36
|
+
if (!localStorage) {
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
if (key != null && value != null) {
|
|
40
|
+
localStorage.setItem(key, value)
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
get (key) {
|
|
44
|
+
if (!localStorage) {
|
|
45
|
+
return null
|
|
46
|
+
}
|
|
47
|
+
if (key == null) {
|
|
48
|
+
return null
|
|
49
|
+
}
|
|
50
|
+
return localStorage.getItem(key)
|
|
51
|
+
},
|
|
52
|
+
setJSON (key, jsonValue) {
|
|
53
|
+
if (jsonValue != null) {
|
|
54
|
+
this.set(key, JSON.stringify(jsonValue))
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
getJSON (key) {
|
|
58
|
+
const value = this.get(key)
|
|
59
|
+
if (value != null) {
|
|
60
|
+
return JSON.parse(value)
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
remove (key) {
|
|
64
|
+
localStorage.removeItem(key);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default {
|
|
69
|
+
/**
|
|
70
|
+
* 会话级缓存
|
|
71
|
+
*/
|
|
72
|
+
session: sessionCache,
|
|
73
|
+
/**
|
|
74
|
+
* 本地缓存
|
|
75
|
+
*/
|
|
76
|
+
local: localCache
|
|
77
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-select
|
|
3
|
+
:title="multiple? optionData.name : ''"
|
|
4
|
+
ref="select"
|
|
5
|
+
:value="value"
|
|
6
|
+
placeholder="请选择"
|
|
7
|
+
size="medium"
|
|
8
|
+
clearable
|
|
9
|
+
:disabled="disabled"
|
|
10
|
+
:filterable="filterable"
|
|
11
|
+
:filter-method="filterMethod"
|
|
12
|
+
style="width: 100%; "
|
|
13
|
+
@clear="clear"
|
|
14
|
+
@visible-change="visibleChange"
|
|
15
|
+
>
|
|
16
|
+
<el-option
|
|
17
|
+
ref="option"
|
|
18
|
+
class="tree-select__option"
|
|
19
|
+
:value="optionData.id"
|
|
20
|
+
:label="optionData.name"
|
|
21
|
+
>
|
|
22
|
+
<el-tree
|
|
23
|
+
ref="tree"
|
|
24
|
+
class="tree-select__tree"
|
|
25
|
+
:class="`tree-select__tree--${multiple ? 'checked' : 'radio'}`"
|
|
26
|
+
:node-key="nodeKey"
|
|
27
|
+
:data="data"
|
|
28
|
+
:props="props"
|
|
29
|
+
:default-expanded-keys="[value]"
|
|
30
|
+
:show-checkbox="multiple"
|
|
31
|
+
:highlight-current="!multiple"
|
|
32
|
+
:expand-on-click-node="multiple"
|
|
33
|
+
:filter-node-method="filterNode"
|
|
34
|
+
@node-click="handleNodeClick"
|
|
35
|
+
@check-change="handleCheckChange"
|
|
36
|
+
></el-tree>
|
|
37
|
+
</el-option>
|
|
38
|
+
</el-select>
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<script>
|
|
42
|
+
export default {
|
|
43
|
+
name: 'TreeSelect',
|
|
44
|
+
props: {
|
|
45
|
+
// v-model绑定
|
|
46
|
+
value: {
|
|
47
|
+
type: [String, Number],
|
|
48
|
+
default: ''
|
|
49
|
+
},
|
|
50
|
+
multiple: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: false
|
|
53
|
+
},
|
|
54
|
+
// 树形的数据
|
|
55
|
+
data: {
|
|
56
|
+
type: Array,
|
|
57
|
+
default: function () {
|
|
58
|
+
return []
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
// 每个树节点用来作为唯一标识的属性
|
|
62
|
+
nodeKey: {
|
|
63
|
+
type: [String, Number],
|
|
64
|
+
default: 'id'
|
|
65
|
+
},
|
|
66
|
+
filterable: {
|
|
67
|
+
type: Boolean,
|
|
68
|
+
default: false
|
|
69
|
+
},
|
|
70
|
+
disabled: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
default: false
|
|
73
|
+
},
|
|
74
|
+
// tree的props配置
|
|
75
|
+
props: {
|
|
76
|
+
type: Object,
|
|
77
|
+
default: function () {
|
|
78
|
+
return {
|
|
79
|
+
label: 'label',
|
|
80
|
+
children: 'children'
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
data() {
|
|
86
|
+
return {
|
|
87
|
+
optionData: {
|
|
88
|
+
id: '',
|
|
89
|
+
name: ''
|
|
90
|
+
},
|
|
91
|
+
filterFlag: false
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
watch: {
|
|
95
|
+
value: {
|
|
96
|
+
handler(val) {
|
|
97
|
+
if (!this.isEmpty(this.data)) {
|
|
98
|
+
this.init(val)
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
immediate: true
|
|
102
|
+
},
|
|
103
|
+
data: function (val) {
|
|
104
|
+
if (!this.isEmpty(val)) {
|
|
105
|
+
this.init(this.value)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
created() {},
|
|
110
|
+
methods: {
|
|
111
|
+
// 是否为空
|
|
112
|
+
isEmpty(val) {
|
|
113
|
+
for (let key in val) {
|
|
114
|
+
return false
|
|
115
|
+
}
|
|
116
|
+
return true
|
|
117
|
+
},
|
|
118
|
+
handleNodeClick(data) {
|
|
119
|
+
if (this.multiple) {
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
this.$emit('input', data[this.nodeKey])
|
|
123
|
+
this.$refs.select.visible = false
|
|
124
|
+
},
|
|
125
|
+
handleCheckChange() {
|
|
126
|
+
const nodes = this.$refs.tree.getCheckedNodes()
|
|
127
|
+
const value = nodes.map((item) => item[this.nodeKey]).join(',')
|
|
128
|
+
this.$emit('input', value)
|
|
129
|
+
},
|
|
130
|
+
init(val) {
|
|
131
|
+
// 多选
|
|
132
|
+
if (this.multiple) {
|
|
133
|
+
const arr = val.toString().split(',')
|
|
134
|
+
this.$nextTick(() => {
|
|
135
|
+
this.$refs.tree.setCheckedKeys(arr)
|
|
136
|
+
const nodes = this.$refs.tree.getCheckedNodes()
|
|
137
|
+
this.optionData.id = val
|
|
138
|
+
this.optionData.name = nodes
|
|
139
|
+
.map((item) => item[this.props.label])
|
|
140
|
+
.join(',')
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
// 单选
|
|
144
|
+
else {
|
|
145
|
+
val = val === '' ? null : val
|
|
146
|
+
this.$nextTick(() => {
|
|
147
|
+
this.$refs.tree.setCurrentKey(val)
|
|
148
|
+
if (val === null) {
|
|
149
|
+
return
|
|
150
|
+
}
|
|
151
|
+
const node = this.$refs.tree.getNode(val)
|
|
152
|
+
this.optionData.id = val
|
|
153
|
+
this.optionData.name = node.label
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
visibleChange(e) {
|
|
158
|
+
if (e) {
|
|
159
|
+
const tree = this.$refs.tree
|
|
160
|
+
this.filterFlag && tree.filter('')
|
|
161
|
+
this.filterFlag = false
|
|
162
|
+
let selectDom = null
|
|
163
|
+
if(this.multiple) {
|
|
164
|
+
selectDom = tree.$el.querySelector('.el-tree-node.is-checked')
|
|
165
|
+
} else {
|
|
166
|
+
selectDom = tree.$el.querySelector('.is-current')
|
|
167
|
+
}
|
|
168
|
+
setTimeout(() => {
|
|
169
|
+
this.$refs.select.scrollToOption({ $el: selectDom })
|
|
170
|
+
}, 0)
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
clear() {
|
|
174
|
+
this.$emit('input', '')
|
|
175
|
+
},
|
|
176
|
+
filterMethod(val) {
|
|
177
|
+
this.filterFlag = true
|
|
178
|
+
this.$refs.tree.filter(val)
|
|
179
|
+
},
|
|
180
|
+
filterNode(value, data) {
|
|
181
|
+
if (!value) return true
|
|
182
|
+
const label = this.props.label || 'name'
|
|
183
|
+
return data[label].indexOf(value) !== -1
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
</script>
|
|
188
|
+
|
|
189
|
+
<style lang="scss">
|
|
190
|
+
.tree-select__option {
|
|
191
|
+
&.el-select-dropdown__item {
|
|
192
|
+
height: auto;
|
|
193
|
+
line-height: 1;
|
|
194
|
+
padding: 0;
|
|
195
|
+
background-color: #fff;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.tree-select__tree {
|
|
200
|
+
padding: 4px 20px;
|
|
201
|
+
font-weight: 400;
|
|
202
|
+
&.tree-select__tree--radio {
|
|
203
|
+
.el-tree-node.is-current > .el-tree-node__content {
|
|
204
|
+
color: black;
|
|
205
|
+
font-weight: 700;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
</style>
|