|
@@ -10,10 +10,10 @@
|
|
|
>
|
|
|
<colgroup>
|
|
|
<col
|
|
|
- v-for="(item, i) in curQue.tableData.colsConfig.width"
|
|
|
+ v-for="(col, i) in curQue.tableData.colsConfig.width"
|
|
|
:key="`col-${i}`"
|
|
|
- :style="{ width: `${item.val}px` }"
|
|
|
- >
|
|
|
+ :style="{ width: `${col.val}px` }"
|
|
|
+ />
|
|
|
</colgroup>
|
|
|
|
|
|
<caption v-if="curQue.isTitle">
|
|
@@ -24,24 +24,20 @@
|
|
|
|
|
|
<thead>
|
|
|
<tr
|
|
|
- v-for="(header, i) in curQue.tableData.headers"
|
|
|
+ v-for="({ content }, i) in curQue.tableData.headers"
|
|
|
:key="`thead-${i}`"
|
|
|
:style="{
|
|
|
'background-color': `${curQue.headerBgColor}`,
|
|
|
}"
|
|
|
>
|
|
|
- <template v-if="header.isMerge">
|
|
|
- <th :colspan="header.content.length">
|
|
|
- <div class="thead-merge">
|
|
|
- <span v-for="(item, j) in header.content" :key="`th-${i}-${j}`">
|
|
|
- {{ item.text }}
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </th>
|
|
|
- </template>
|
|
|
- <template v-else>
|
|
|
- <th v-for="(item, j) in header.content" :key="`th-${i}-${j}`">
|
|
|
- {{ item.text }}
|
|
|
+ <template v-for="({ text, colspan, rowspan }, j) in content">
|
|
|
+ <th
|
|
|
+ v-if="thIsShow(i, j)"
|
|
|
+ :key="`th-${i}-${j}`"
|
|
|
+ :colspan="colspan"
|
|
|
+ :rowspan="rowspan"
|
|
|
+ >
|
|
|
+ {{ text }}
|
|
|
</th>
|
|
|
</template>
|
|
|
</tr>
|
|
@@ -52,145 +48,163 @@
|
|
|
'text-align': `${curQue.textAlign}`,
|
|
|
}"
|
|
|
>
|
|
|
- <tr v-for="(data, i) in curQue.tableData.body" :key="`tr-${i}`">
|
|
|
- <td v-for="(item, j) in data.content" :key="`td-${i}-${j}`">
|
|
|
- <template v-if="item.type === 'content'">
|
|
|
- <template v-if="item.text.length > 0">
|
|
|
- {{ item.text }}
|
|
|
- </template>
|
|
|
- <template v-else>
|
|
|
- <el-input
|
|
|
- v-model="item.answer"
|
|
|
- type="textarea"
|
|
|
- :placeholder="`${isAnswerMode ? '' : '输入'}`"
|
|
|
- :disabled="isAnswerMode"
|
|
|
- :autosize="{ minRows: 1, maxRows: 6 }"
|
|
|
- @input="enterAnswer(i, j, $event)"
|
|
|
- />
|
|
|
- </template>
|
|
|
- </template>
|
|
|
+ <tr v-for="(row, i) in curQue.tableData.body" :key="`tr-${i}`">
|
|
|
+ <template v-for="(col, j) in row.content">
|
|
|
+ <td
|
|
|
+ v-if="tdIsShow(i, j)"
|
|
|
+ :key="`td-${i}-${j}`"
|
|
|
+ :colspan="col.colspan"
|
|
|
+ :rowspan="col.rowspan"
|
|
|
+ :class="[{ underline: col.isUnderline }]"
|
|
|
+ :style="{ 'background-color': `${col.background}` }"
|
|
|
+ >
|
|
|
+ <div class="cell-wrap">
|
|
|
+ <template v-if="col.type === 'content'">
|
|
|
+ <span v-if="col.text.length > 0" class="content">
|
|
|
+ {{ col.text }}
|
|
|
+ </span>
|
|
|
+ <template v-else>
|
|
|
+ <el-input
|
|
|
+ v-model="col.answer"
|
|
|
+ type="textarea"
|
|
|
+ :placeholder="`${isAnswerMode ? '' : '输入'}`"
|
|
|
+ :disabled="isAnswerMode"
|
|
|
+ :autosize="{ minRows: 1, maxRows: 6 }"
|
|
|
+ @input="enterAnswer(i, j, $event)"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
|
|
|
- <div v-else-if="item.type === 'preContent'" class="preContent">
|
|
|
- <span>{{ item.prefix }}</span>
|
|
|
- <template v-if="item.text.length > 0">
|
|
|
- {{ item.text }}
|
|
|
- </template>
|
|
|
- <template v-else>
|
|
|
- <el-input
|
|
|
- v-model="item.answer"
|
|
|
- type="textarea"
|
|
|
- :placeholder="`${isAnswerMode ? '' : '输入'}`"
|
|
|
- :disabled="isAnswerMode"
|
|
|
- :autosize="{ minRows: 1, maxRows: 6 }"
|
|
|
- @input="enterAnswer(i, j, $event)"
|
|
|
- />
|
|
|
- </template>
|
|
|
- </div>
|
|
|
+ <div v-else-if="col.type === 'preContent'" class="preContent">
|
|
|
+ <span>{{ col.prefix }}</span>
|
|
|
+ <template v-if="col.text.length > 0">
|
|
|
+ {{ col.text }}
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <el-input
|
|
|
+ v-model="col.answer"
|
|
|
+ type="textarea"
|
|
|
+ :placeholder="`${isAnswerMode ? '' : '输入'}`"
|
|
|
+ :disabled="isAnswerMode"
|
|
|
+ :autosize="{ minRows: 1, maxRows: 6 }"
|
|
|
+ @input="enterAnswer(i, j, $event)"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
|
|
|
- <div
|
|
|
- v-else-if="
|
|
|
- item.type === 'pinyin' || item.type === 'twoAnnotation'
|
|
|
- "
|
|
|
- class="sentence"
|
|
|
- :style="pinyinStyle"
|
|
|
- >
|
|
|
- <div>
|
|
|
- <span
|
|
|
- v-for="({ pinyin, chs }, k) in item.sentence_data.wordsList"
|
|
|
- :key="`${
|
|
|
- curQue.pinyinPosition === 'top' ||
|
|
|
- curQue.pinyinPosition === 'left'
|
|
|
- ? 'pinyin'
|
|
|
- : 'chs'
|
|
|
- }-${k}`"
|
|
|
- :class="[
|
|
|
- `${
|
|
|
- curQue.pinyinPosition === 'top' ||
|
|
|
- curQue.pinyinPosition === 'left'
|
|
|
- ? 'pinyin'
|
|
|
- : 'chs'
|
|
|
- }`,
|
|
|
- ]"
|
|
|
- >
|
|
|
- {{
|
|
|
- curQue.pinyinPosition === "top" ||
|
|
|
- curQue.pinyinPosition == "left"
|
|
|
- ? pinyin
|
|
|
- : chs
|
|
|
- }}
|
|
|
- </span>
|
|
|
- <span
|
|
|
- v-if="
|
|
|
- item.type === 'twoAnnotation' &&
|
|
|
- (curQue.pinyinPosition === 'right' ||
|
|
|
- curQue.pinyinPosition === 'bottom')
|
|
|
+ <div
|
|
|
+ v-else-if="
|
|
|
+ col.type === 'pinyin' || col.type === 'twoAnnotation'
|
|
|
"
|
|
|
- class="english"
|
|
|
+ class="sentence"
|
|
|
+ :style="pinyinStyle"
|
|
|
>
|
|
|
- ({{ item.text }})
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- <span
|
|
|
- v-for="({ pinyin, chs }, k) in item.sentence_data.wordsList"
|
|
|
- :key="`${
|
|
|
- curQue.pinyinPosition === 'top' ||
|
|
|
- curQue.pinyinPosition === 'left'
|
|
|
- ? 'chs'
|
|
|
- : 'pinyin'
|
|
|
- }-${k}`"
|
|
|
- :class="[
|
|
|
- `${
|
|
|
- curQue.pinyinPosition === 'top' ||
|
|
|
- curQue.pinyinPosition === 'left'
|
|
|
- ? 'chs'
|
|
|
- : 'pinyin'
|
|
|
- }`,
|
|
|
- ]"
|
|
|
- >
|
|
|
- {{
|
|
|
- curQue.pinyinPosition === "top" ||
|
|
|
- curQue.pinyinPosition == "left"
|
|
|
- ? chs
|
|
|
- : pinyin
|
|
|
- }}
|
|
|
- </span>
|
|
|
- <span
|
|
|
- v-if="
|
|
|
- item.type === 'twoAnnotation' &&
|
|
|
- (curQue.pinyinPosition === 'top' ||
|
|
|
- curQue.pinyinPosition === 'left')
|
|
|
- "
|
|
|
- class="english"
|
|
|
- >
|
|
|
- ({{ item.text }})
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div v-else-if="item.type === 'prePinyin'" class="pre-pinyin">
|
|
|
- <span>{{ item.prefix }}</span>
|
|
|
- <div class="right-pinyin">
|
|
|
- <div>
|
|
|
- <span
|
|
|
- v-for="({ pinyin }, k) in item.sentence_data.wordsList"
|
|
|
- :key="`pre-pinyin-${k}`"
|
|
|
- class="pinyin"
|
|
|
- >
|
|
|
- {{ pinyin }}
|
|
|
- </span>
|
|
|
+ <div>
|
|
|
+ <span
|
|
|
+ v-for="({ pinyin, chs }, k) in col.sentence_data
|
|
|
+ .wordsList"
|
|
|
+ :key="`${
|
|
|
+ curQue.pinyinPosition === 'top' ||
|
|
|
+ curQue.pinyinPosition === 'left'
|
|
|
+ ? 'pinyin'
|
|
|
+ : 'chs'
|
|
|
+ }-${k}`"
|
|
|
+ :class="[
|
|
|
+ `${
|
|
|
+ curQue.pinyinPosition === 'top' ||
|
|
|
+ curQue.pinyinPosition === 'left'
|
|
|
+ ? 'pinyin'
|
|
|
+ : 'chs'
|
|
|
+ }`,
|
|
|
+ ]"
|
|
|
+ >
|
|
|
+ {{
|
|
|
+ curQue.pinyinPosition === "top" ||
|
|
|
+ curQue.pinyinPosition == "left"
|
|
|
+ ? pinyin
|
|
|
+ : chs
|
|
|
+ }}
|
|
|
+ </span>
|
|
|
+ <span
|
|
|
+ v-if="
|
|
|
+ col.type === 'twoAnnotation' &&
|
|
|
+ (curQue.pinyinPosition === 'right' ||
|
|
|
+ curQue.pinyinPosition === 'bottom')
|
|
|
+ "
|
|
|
+ class="english"
|
|
|
+ >
|
|
|
+ ({{ col.text }})
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <span
|
|
|
+ v-for="({ pinyin, chs }, k) in col.sentence_data
|
|
|
+ .wordsList"
|
|
|
+ :key="`${
|
|
|
+ curQue.pinyinPosition === 'top' ||
|
|
|
+ curQue.pinyinPosition === 'left'
|
|
|
+ ? 'chs'
|
|
|
+ : 'pinyin'
|
|
|
+ }-${k}`"
|
|
|
+ :class="[
|
|
|
+ `${
|
|
|
+ curQue.pinyinPosition === 'top' ||
|
|
|
+ curQue.pinyinPosition === 'left'
|
|
|
+ ? 'chs'
|
|
|
+ : 'pinyin'
|
|
|
+ }`,
|
|
|
+ ]"
|
|
|
+ >
|
|
|
+ {{
|
|
|
+ curQue.pinyinPosition === "top" ||
|
|
|
+ curQue.pinyinPosition == "left"
|
|
|
+ ? chs
|
|
|
+ : pinyin
|
|
|
+ }}
|
|
|
+ </span>
|
|
|
+ <span
|
|
|
+ v-if="
|
|
|
+ col.type === 'twoAnnotation' &&
|
|
|
+ (curQue.pinyinPosition === 'top' ||
|
|
|
+ curQue.pinyinPosition === 'left')
|
|
|
+ "
|
|
|
+ class="english"
|
|
|
+ >
|
|
|
+ ({{ col.text }})
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- <div>
|
|
|
- <span
|
|
|
- v-for="({ pinyin, chs }, k) in item.sentence_data.wordsList"
|
|
|
- :key="`pre-chs-${k}`"
|
|
|
+
|
|
|
+ <div v-else-if="col.type === 'prePinyin'" class="pre-pinyin">
|
|
|
+ <span>{{ col.prefix }}</span>
|
|
|
+ <div
|
|
|
+ class="right-pinyin"
|
|
|
+ :style="{
|
|
|
+ 'grid-template-columns': `repeat(${col.sentence_data.wordsList.length}, auto)`,
|
|
|
+ }"
|
|
|
>
|
|
|
- {{ chs }}
|
|
|
- </span>
|
|
|
+ <span
|
|
|
+ v-for="({ pinyin }, k) in col.sentence_data.wordsList"
|
|
|
+ :key="`pre-pinyin-${k}`"
|
|
|
+ class="pinyin"
|
|
|
+ >
|
|
|
+ {{ pinyin }}
|
|
|
+ </span>
|
|
|
+ <span
|
|
|
+ v-for="({ pinyin, chs }, k) in col.sentence_data
|
|
|
+ .wordsList"
|
|
|
+ :key="`pre-chs-${k}`"
|
|
|
+ class="chs"
|
|
|
+ >
|
|
|
+ {{ chs }}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
+
|
|
|
+ <CrossTick v-if="col.isCross" />
|
|
|
</div>
|
|
|
- </div>
|
|
|
- </td>
|
|
|
+ </td>
|
|
|
+ </template>
|
|
|
</tr>
|
|
|
</tbody>
|
|
|
</table>
|
|
@@ -198,7 +212,10 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import CrossTick from "./HeaderSparate/CrossTick.vue";
|
|
|
+
|
|
|
export default {
|
|
|
+ components: { CrossTick },
|
|
|
props: {
|
|
|
curQue: {
|
|
|
type: Object,
|
|
@@ -262,6 +279,64 @@ export default {
|
|
|
value,
|
|
|
};
|
|
|
},
|
|
|
+ // th 是否生成
|
|
|
+ thIsShow(i, j) {
|
|
|
+ let headers = this.curQue.tableData.headers;
|
|
|
+ let col = 1;
|
|
|
+ let colIndex = headers[i].content.findIndex(({ colspan }, index) => {
|
|
|
+ if (index > j) return false;
|
|
|
+ let num = colspan === undefined ? 1 : Number(colspan);
|
|
|
+ if (num > 1) {
|
|
|
+ col = num;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (index === j && col > 1) return true;
|
|
|
+ if (col > 0) col -= 1;
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ let row = 1;
|
|
|
+ let rowIndex = headers.findIndex((item, index) => {
|
|
|
+ let rowspan = item.content[j].rowspan;
|
|
|
+ let num = rowspan === undefined ? 1 : Number(rowspan);
|
|
|
+ if (num > 1) {
|
|
|
+ row = num;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (index === i && row > 1) return true;
|
|
|
+ if (row > 0) row -= 1;
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ return colIndex === -1 && rowIndex === -1;
|
|
|
+ },
|
|
|
+ // rowspan colspan 控制td是否生成
|
|
|
+ tdIsShow(i, j) {
|
|
|
+ let body = this.curQue.tableData.body;
|
|
|
+ let col = 1;
|
|
|
+ let colIndex = body[i].content.findIndex(({ colspan }, index) => {
|
|
|
+ if (index > j) return false;
|
|
|
+ let num = colspan === undefined ? 1 : Number(colspan);
|
|
|
+ if (num > 1) {
|
|
|
+ col = num;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (index === j && col > 1) return true;
|
|
|
+ if (col > 0) col -= 1;
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ let row = 1;
|
|
|
+ let rowIndex = body.findIndex((item, index) => {
|
|
|
+ let rowspan = item.content[j].rowspan;
|
|
|
+ let num = rowspan === undefined ? 1 : Number(rowspan);
|
|
|
+ if (num > 1) {
|
|
|
+ row = num;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (index === i && row > 1) return true;
|
|
|
+ if (row > 0) row -= 1;
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ return colIndex === -1 && rowIndex === -1;
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
@@ -284,6 +359,10 @@ export default {
|
|
|
line-height: 1.95;
|
|
|
}
|
|
|
|
|
|
+ th {
|
|
|
+ font-family: "FZJCGFKTK", "GB-PINYINOK-B", "robot";
|
|
|
+ }
|
|
|
+
|
|
|
th,
|
|
|
td {
|
|
|
font-weight: normal;
|
|
@@ -297,6 +376,7 @@ export default {
|
|
|
}
|
|
|
|
|
|
.preContent {
|
|
|
+ font-family: "FZJCGFKTK", "GB-PINYINOK-B", "robot";
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
|
|
@@ -306,10 +386,28 @@ export default {
|
|
|
}
|
|
|
|
|
|
td {
|
|
|
+ // min-height: 51px;
|
|
|
+ // height: 51px;
|
|
|
+
|
|
|
+ .cell-wrap {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+
|
|
|
+ .content {
|
|
|
+ font-family: "FZJCGFKTK", "GB-PINYINOK-B", "robot";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .content {
|
|
|
+ font-family: "FZJCGFKTK", "GB-PINYINOK-B", "robot";
|
|
|
+ }
|
|
|
+
|
|
|
.sentence {
|
|
|
display: flex;
|
|
|
|
|
|
.english {
|
|
|
+ font-family: "robot";
|
|
|
opacity: 0.6;
|
|
|
}
|
|
|
}
|
|
@@ -322,16 +420,22 @@ export default {
|
|
|
.chs {
|
|
|
font-family: "FZJCGFKTK";
|
|
|
}
|
|
|
+
|
|
|
+ // 下划线
|
|
|
+ &.underline {
|
|
|
+ text-decoration: underline;
|
|
|
+ }
|
|
|
+
|
|
|
// 前缀 + 拼音
|
|
|
.pre-pinyin {
|
|
|
display: flex;
|
|
|
align-items: flex-end;
|
|
|
|
|
|
.right-pinyin {
|
|
|
- row-gap: 2px;
|
|
|
- flex-direction: column;
|
|
|
+ margin-left: 4px;
|
|
|
+ column-gap: 2px;
|
|
|
text-align: center;
|
|
|
- display: flex;
|
|
|
+ display: grid;
|
|
|
}
|
|
|
}
|
|
|
}
|