zydx-plus 1.32.198 → 1.32.199

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zydx-plus",
3
- "version": "1.32.198",
3
+ "version": "1.32.199",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -8,7 +8,6 @@
8
8
  </template>
9
9
 
10
10
  <script>
11
- import {json2html} from "html2json";
12
11
 
13
12
  export default {
14
13
  name: "zydx-tab",
@@ -89,6 +89,7 @@
89
89
  .subject-title{
90
90
  flex: 1;
91
91
  position: relative;
92
+ line-height: 26px;
92
93
  }
93
94
  .subject-title label{
94
95
  display: inline-block;
@@ -171,7 +172,10 @@ input[name='check'] {
171
172
  text-indent: 2em;
172
173
  font-weight: bold;
173
174
  font-size: 14px;
175
+ line-height: 26px;
174
176
  }
175
177
  .subject-html-cont{
176
178
  text-align: justify;
179
+ line-height: 26px;
180
+ text-indent: 2em;
177
181
  }
@@ -35,9 +35,9 @@
35
35
  </div>
36
36
  </div>
37
37
  <div class="choice" v-if="item.testKey">
38
- <div class="choice-box" v-for="(ts,ind) in JSON.parse(item.testKey)">
38
+ <div class="choice-box" v-for="(ts,ind) in item.testKey">
39
39
  <label>
40
- <input :disabled="disabled" @change="answerChange($event,item,JSON.parse(item.testKey),index)" :type="ques(item.quesType)?'radio':'checkbox'" :name="index" />
40
+ <input :disabled="disabled" :checked="ts.checked" @change="answerChange($event,item,index)" :type="ques(item.quesType)?'radio':'checkbox'" :name="index" />
41
41
  <span>{{ ts.index }}. {{ ts.content[0] }}</span>
42
42
  </label>
43
43
  </div>
@@ -100,7 +100,7 @@ export default {
100
100
  data: {
101
101
  handler: function (val, oldVal) {
102
102
  this.value = val
103
- this.value.map((item,index) => {
103
+ this.value.map((item,index) => { // 转换html
104
104
  item.choice = true
105
105
  item.right = 0
106
106
  item.top = 0
@@ -110,14 +110,31 @@ export default {
110
110
  return x
111
111
  })
112
112
  }
113
+ if(item.testKey) {
114
+ item.testKey = JSON.parse(item.testKey).map(x => {
115
+ if(this.ques(item.quesType)) { // 判断是否单选
116
+ x.checked = x.index === item.answer;
117
+ }else {
118
+ for(let i=0; i<item.answer.length; i++) {
119
+ if(x.index === item.answer[i]) {
120
+ x.checked = true
121
+ break
122
+ }else {
123
+ x.checked = false
124
+ }
125
+ }
126
+ }
127
+ return x
128
+ })
129
+ }
113
130
  return item
114
131
  })
115
- this.$nextTick(() => {
116
- const w = this.$refs.parer.offsetWidth
132
+ this.$nextTick(() => { // 保证所有的数据都渲染完毕
133
+ const w = this.$refs.parer.offsetWidth // 获取父级宽度
117
134
  for(let i = 0; i< this.$refs.subject.length; i++) {
118
135
  this.value[i].right = w - this.$refs.subject[i].offsetLeft
119
136
  if(this.$refs.b && this.$refs.b.length > 0) {
120
- if(this.value[i].right < this.$refs.b[i].offsetWidth) this.value[i].top = 25
137
+ if(this.value[i].right < this.$refs.b[i].offsetWidth) this.value[i].top = 25 // 判断是否换行
121
138
  }
122
139
  }
123
140
  })
@@ -133,17 +150,17 @@ export default {
133
150
  },
134
151
  emits: ['change','modify','del','changeAll','replaceData','choiceData','answer'],
135
152
  methods: {
136
- answerChange(e,v,n,id) {
153
+ answerChange(e,v,id) {
137
154
  let answerArr = []
138
155
  const ids = document.getElementsByName(id)
139
156
  ids.forEach((x,index) => {
140
157
  if(x.checked) {
141
- answerArr.push(n[index])
158
+ answerArr.push(v.testKey[index].index)
142
159
  }
143
160
  })
144
161
  this.$emit('answer',{
145
162
  ...v,
146
- answer: answerArr
163
+ answer: this.ques(v.quesType)? answerArr[0]: answerArr
147
164
  })
148
165
  },
149
166
  checkboxChange(e,index) {
@@ -165,9 +182,8 @@ export default {
165
182
  },
166
183
  styleText(v) {
167
184
  if(!v || v === 'null') return
168
- const data = JSON.parse(v)
169
- for(let i=0; i< data.length; i++) {
170
- if(data[i].content[0].length > 20) {
185
+ for(let i=0; i< v.length; i++) {
186
+ if(v[i].content[0].length > 20) {
171
187
  return true
172
188
  }
173
189
  }
@@ -57,6 +57,7 @@ export default {
57
57
  },
58
58
  methods: {
59
59
  init() {
60
+ if(!this.page) return
60
61
  this.htmlArr = []
61
62
  this.pHeight = 0
62
63
  this.html = ''
package/src/index.js CHANGED
@@ -77,7 +77,7 @@ function install(app) {
77
77
  }
78
78
 
79
79
  export default {
80
- version: '1.32.198',
80
+ version: '1.32.199',
81
81
  install,
82
82
  Calendar,
83
83
  Message,