|
@@ -75,7 +75,17 @@
|
|
|
:step="1"
|
|
|
class="word-num-input"
|
|
|
:precision="0"
|
|
|
- @change="handleChangeRows"
|
|
|
+ @change="handleChangeRows('row')"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="列数">
|
|
|
+ <el-input-number
|
|
|
+ v-model="data.property.column_count"
|
|
|
+ :min="1"
|
|
|
+ :step="1"
|
|
|
+ class="word-num-input"
|
|
|
+ :precision="0"
|
|
|
+ @change="handleChangeRows('column')"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
@@ -85,6 +95,7 @@
|
|
|
|
|
|
<script>
|
|
|
import QuestionMixin from '../common/QuestionMixin.js';
|
|
|
+import { getRandomNumber } from '@/utils/index';
|
|
|
|
|
|
import { selectTypeList, changeOptionType } from '@/views/exercise_questions/data/common';
|
|
|
import { replaceAnswerData, getOption } from '@/views/exercise_questions/data/replaceAnswer';
|
|
@@ -120,13 +131,32 @@ export default {
|
|
|
this.data.option_list.push(getOption());
|
|
|
},
|
|
|
// 修改行数
|
|
|
- handleChangeRows(val) {
|
|
|
- if (this.data.option_list.length >= val) {
|
|
|
- this.data.option_list = this.data.option_list.splice(0, val);
|
|
|
+ handleChangeRows(type) {
|
|
|
+ let row_count = this.data.property.row_count;
|
|
|
+ let column_count = this.data.property.column_count;
|
|
|
+ if (type === 'row') {
|
|
|
+ if (this.data.option_list.length >= row_count) {
|
|
|
+ this.data.option_list = this.data.option_list.splice(0, row_count);
|
|
|
+ } else {
|
|
|
+ let length = row_count - this.data.option_list.length;
|
|
|
+ for (let i = 0; i < length; i++) {
|
|
|
+ let table_item = [];
|
|
|
+ for (let j = 0; j < column_count; j++) {
|
|
|
+ table_item.push({ content: '', mark: getRandomNumber() });
|
|
|
+ }
|
|
|
+ this.data.option_list.push(table_item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (this.data.option_list[0].length >= column_count) {
|
|
|
+ this.data.option_list.forEach((item, index) => {
|
|
|
+ this.data.option_list[index] = item.splice(0, column_count);
|
|
|
+ });
|
|
|
} else {
|
|
|
- let length = val - this.data.option_list.length;
|
|
|
- for (let i = 0; i < length; i++) {
|
|
|
- this.addOption();
|
|
|
+ let length = column_count - this.data.option_list[0].length;
|
|
|
+ for (let i = 0; i < row_count; i++) {
|
|
|
+ for (let j = 0; j < length; j++) {
|
|
|
+ this.data.option_list[i].push({ content: '', mark: getRandomNumber() });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
},
|