From eeff64f494ed72d8acaa13d653c9f3ee181ac950 Mon Sep 17 00:00:00 2001 From: unknown <qq1940665526@163.com> Date: 星期五, 07 六月 2024 16:09:46 +0800 Subject: [PATCH] 优化 --- src/books/lifeCare/view/chapter005.vue | 77 +++++++++++++++++--------------------- 1 files changed, 34 insertions(+), 43 deletions(-) diff --git a/src/books/lifeCare/view/chapter005.vue b/src/books/lifeCare/view/chapter005.vue index 5361ced..44c2af2 100644 --- a/src/books/lifeCare/view/chapter005.vue +++ b/src/books/lifeCare/view/chapter005.vue @@ -191,8 +191,8 @@ :style="{ width: index == 0 || - index == chapter005.tableData151.length - 1 - ? '100px' + index == chapter005.headersData.length - 1 + ? '150px' : '', }" v-for="(header, index) in chapter005.headersData" @@ -209,23 +209,20 @@ > <td v-for="(cell, cellIndex) in row" :key="cellIndex"> <template v-if="cell === ''"> - <input - type="text" - v-model="chapter005.tableData151[rowIndex][cellIndex]" - @blur=" - updateCell(rowIndex, cellIndex, $event.target.value) - " - /> + <div + contenteditable + @blur="updateCell(rowIndex, cellIndex, $event)" + > + {{ chapter005.tableData151[rowIndex][cellIndex] }} + </div> </template> <template v-else> - <input - :readonly="cellIndex == 0" - type="text" - :value="chapter005.tableData151[rowIndex][cellIndex]" - @blur=" - updateCell(rowIndex, cellIndex, $event.target.value) - " - /> + <div + :contenteditable="cellIndex != 0" + @blur="updateCell(rowIndex, cellIndex, $event)" + > + {{ chapter005.tableData151[rowIndex][cellIndex] }} + </div> </template> </td> </tr> @@ -1475,30 +1472,20 @@ > <td v-for="(cell, cellIndex) in row" :key="cellIndex"> <template v-if="cell === ''"> - <input - type="text" - v-model="chapter005.tableData155[rowIndex][cellIndex]" - @blur=" - updateCell155( - rowIndex, - cellIndex, - $event.target.value - ) - " - /> + <div + contenteditable + @blur="updateCell155(rowIndex, cellIndex, $event)" + > + {{ chapter005.tableData155[rowIndex][cellIndex] }} + </div> </template> <template v-else> - <input - type="text" - :value="chapter005.tableData155[rowIndex][cellIndex]" - @blur=" - updateCell155( - rowIndex, - cellIndex, - $event.target.value - ) - " - /> + <div + contenteditable + @blur="updateCell155(rowIndex, cellIndex, $event)" + > + {{ chapter005.tableData155[rowIndex][cellIndex] }} + </div> </template> </td> </tr> @@ -3665,9 +3652,9 @@ } localStorage.setItem("chapter005", JSON.stringify(this.chapter005)); }, - updateCell(rowIndex, cellIndex, value) { + updateCell(rowIndex, cellIndex, e) { // 鏇存柊鍗曞厓鏍兼暟鎹� - this.$set(this.chapter005.tableData151[rowIndex], cellIndex, value); + this.$set(this.chapter005.tableData151[rowIndex], cellIndex, e.target.innerText); localStorage.setItem("chapter005", JSON.stringify(this.chapter005)); }, updateCell152(rowIndex, cellIndex, value) { @@ -3685,9 +3672,13 @@ this.$set(this.chapter005.tableData154[rowIndex], cellIndex, value); localStorage.setItem("chapter005", JSON.stringify(this.chapter005)); }, - updateCell155(rowIndex, cellIndex, value) { + updateCell155(rowIndex, cellIndex, e) { // 鏇存柊鍗曞厓鏍兼暟鎹� - this.$set(this.chapter005.tableData155[rowIndex], cellIndex, value); + this.$set( + this.chapter005.tableData155[rowIndex], + cellIndex, + e.target.innerText + ); localStorage.setItem("chapter005", JSON.stringify(this.chapter005)); }, updateCell156(rowIndex, cellIndex, value) { -- Gitblit v1.9.1