Merge remote-tracking branch 'origin/feature/feature-20250331-h5' into feature/feature-20250331-h5
This commit is contained in:
@@ -1,56 +1,62 @@
|
||||
<template>
|
||||
<table class="matrix-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td v-for="col in columns" :key="col.option">
|
||||
<!-- 编辑状态,单次点击出输入框,失焦后关闭 -->
|
||||
<input
|
||||
v-if="col.editor"
|
||||
v-model="col.option"
|
||||
v-focus
|
||||
type="text"
|
||||
@focusout="col.editor = false"
|
||||
@click="handleRowNameChange(col.option!)"
|
||||
/>
|
||||
<span v-else @click="handleRowNameChange(col.option!)" v-html="col.option"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td v-for="col in columns" :key="col.option">
|
||||
<!-- 编辑状态,单次点击出输入框,失焦后关闭 -->
|
||||
<input
|
||||
v-if="col.editor"
|
||||
v-model="col.option"
|
||||
v-focus
|
||||
type="text"
|
||||
@focusout="col.editor = false"
|
||||
@click="handleRowNameChange(col.option!)"
|
||||
/>
|
||||
<span v-else @click="handleRowNameChange(col.option!)" v-html="col.option"></span>
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(row, rowIndex) in rows" :key="rowIndex">
|
||||
<th v-html="row.option"></th>
|
||||
<td v-for="(col, colIndex) in columns" :key="colIndex">
|
||||
<input
|
||||
type="text"
|
||||
:value="matrixAnswer[`${rowIndex + 1}_${colIndex + 1}`]"
|
||||
@change="handleColNameChange(row.option, col.option, $event, rowIndex, colIndex)"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-for="(row, rowIndex) in rows" :key="rowIndex">
|
||||
<th v-html="row.option"></th>
|
||||
<td v-for="(col, colIndex) in columns" :key="colIndex">
|
||||
<input
|
||||
type="text"
|
||||
:value="matrixAnswer[`${rowIndex + 1}_${colIndex + 1}`]"
|
||||
@change="handleColNameChange(row.option, col.option, $event, rowIndex, colIndex)"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, defineProps, defineEmits } from 'vue';
|
||||
import {vFocus } from "@/utils/directives/useVFocus"
|
||||
import { defineProps, defineEmits } from 'vue';
|
||||
import { vFocus } from '@/utils/directives/useVFocus';
|
||||
|
||||
const props = defineProps<{
|
||||
rows: { option: string }[];
|
||||
columns: { option: string, editor?: boolean }[];
|
||||
columns: { option: string; editor?: boolean }[];
|
||||
questionType: number;
|
||||
matrixAnswer: { [key: string]: any };
|
||||
}>();
|
||||
|
||||
const emits = defineEmits(['update:matrixAnswer']);
|
||||
|
||||
const handleRowNameChange = (value: string) => {
|
||||
console.log(`row change: ${value}`);
|
||||
const handleRowNameChange = (/* value: string */) => {
|
||||
// console.log(`row change: ${value}`);
|
||||
// 你可以在这里添加其他逻辑
|
||||
};
|
||||
|
||||
const handleColNameChange = (rowOption: string, colOption: string, e: Event, rowIndex: number, colIndex: number) => {
|
||||
const handleColNameChange = (
|
||||
rowOption: string,
|
||||
colOption: string,
|
||||
e: Event,
|
||||
rowIndex: number,
|
||||
colIndex: number
|
||||
) => {
|
||||
const target = e.target as HTMLInputElement;
|
||||
const key = `R${rowIndex + 1}_C${colIndex + 1}`;
|
||||
const newMatrixAnswer = { ...props.matrixAnswer, [key]: target.value };
|
||||
@@ -71,4 +77,4 @@ const handleColNameChange = (rowOption: string, colOption: string, e: Event, row
|
||||
border: 1px solid #ddd;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user