Ver código fonte

表头分离表格 多行句子 填空

natasha 1 ano atrás
pai
commit
f722dff4b9

+ 172 - 1
src/components/Adult/inputModules/HeaderSeparate/components/CellEdit.vue

@@ -65,6 +65,77 @@
         />
       </template>
 
+      <template v-else-if="cellData.type === 'mulText'">
+        <div class="adult-book-input-item">
+            <span class="adult-book-lable">题干部分:</span>
+            <el-button type="primary" @click="setOptionDetail()"
+              >添加句子</el-button
+            >
+          </div>
+          <div
+            v-if="cellData.mulText.detail.length > 0"
+            style="padding: 10px 0px 10px 86px"
+          >
+            <ul
+              class="option-detail-detail"
+              v-for="(dItem, dIndex) in cellData.mulText.detail"
+              :key="'ddItem' + dIndex"
+            >
+              <li
+                v-for="(ddItem, ddIndex) in dItem.detail"
+                :key="'ddItem' + dIndex + ddIndex"
+              >
+                <span
+                  :class="[
+                    ddItem.config.wordPadding.indexOf('left') > -1
+                      ? 'dleft'
+                      : '',
+                    ddItem.config.wordPadding.indexOf('right') > -1
+                      ? 'dright'
+                      : '',
+                    !ddItem.sentence ? 'placeholder' : '',
+                  ]"
+                  >{{ ddItem.sentence }}</span
+                >
+              </li>
+              <i
+                class="el-icon-edit"
+                @click.prevent="
+                  setOptionDetail('edit', dItem, dIndex)
+                "
+                style="margin-left: 14px"
+              ></i>
+              <i
+                class="el-icon-delete"
+                @click.prevent="deleteOptionDetail(cellData.mulText.detail, dIndex)"
+                style="margin-left: 14px"
+              ></i>
+            </ul>
+          </div>
+          <div class="correct-box">
+            <div
+              style="width: 600px"
+            >
+              <div style="padding-top: 10px">
+                <span style="display: block; margin-bottom: 10px"
+                  >句子填空答案:<b style="font-size: 12px"
+                    >请输入本题答案,答案用换行符隔开;如果有的输入框没有答案,答案请输入??</b
+                  ></span
+                >
+                <el-input
+                  class="adult-book-input"
+                  type="textarea"
+                  :autosize="{ minRows: 2 }"
+                  v-model="cellData.mulText.correct.completeInput"
+                  placeholder="请输入句子填空答案"
+                  @blur="onBlur"
+                  maxlength="200"
+                ></el-input>
+              </div>
+            </div>
+          </div>
+      </template>
+
       <template v-if="cellData.isCross">
         <div>勾叉答案</div>
         <CrossTick :cellData="cellData" />
@@ -73,15 +144,30 @@
     <div slot="footer">
       <el-button type="primary" @click="confirm">确定</el-button>
     </div>
+    <el-dialog
+      title="添加句子"
+      :close-on-click-modal="false"
+      :modal-append-to-body="false"
+      append-to-body
+      :visible.sync="addStemVisible"
+      width="50%"
+    >
+      <SentenceSegTemp :detail="optionItemDetail" :segModel="'words'" :type="'config_table'" />
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="addStemVisible = false">取 消</el-button>
+        <el-button type="primary" @click="saveOptionDetail">确 定</el-button>
+      </span>
+    </el-dialog>
   </el-dialog>
 </template>
 
 <script>
 import SentenceSegwordChs from "@/components/Adult/inputModules/SentenceSegwordChs/index.vue";
 import CrossTick from "./CrossTick.vue";
+import SentenceSegTemp from "../../../common/SentenceSegTemp";
 
 export default {
-  components: { SentenceSegwordChs, CrossTick },
+  components: { SentenceSegwordChs, CrossTick, SentenceSegTemp },
   props: {
     visible: {
       type: Boolean,
@@ -116,6 +202,8 @@ export default {
           value: "mulText",
         },
       ],
+      addStemVisible: false,
+      optionItemDetail: null,
     };
   },
   computed: {
@@ -131,6 +219,69 @@ export default {
     confirm() {
       this.$emit("close");
     },
+    //添加句子
+    setOptionDetail( type, dItem, dIndex) {
+      let _this = this;
+      _this.addStemVisible = true;
+      if (type == "edit") {
+        this.optionItemDetail = JSON.parse(JSON.stringify(dItem));
+      } else {
+        let obj = {
+          hengLeg: -1,
+          detail: [
+            {
+              pyPosition: "top", //top 拼音在上面;bottom 拼音在下面
+              sentence: "", //句子
+              segList: [], //分词结果
+              seg_words: "",
+              wordsList: [],
+              hengList: [],
+              config: {
+                fontSize: "16px",
+                fontColor: "#000",
+                fontFamily: "FZJCGFKTK",
+                wordPadding: [],
+                conAlign: 'center'
+              },
+              input_Isexample: false
+            },
+          ],
+          fn_check_list: {
+            record_check: "",
+          },
+        };
+        this.optionItemDetail = JSON.parse(JSON.stringify(obj));
+      }
+      this.datailIndex = dIndex;
+      this.detailSelectType = type;
+    },
+    //删除句子
+    deleteOptionDetail(detail, dIndex) {
+        this.$confirm("确定要删除吗?", "提示", {
+            confirmButtonText: "确定",
+            cancelButtonText: "取消",
+            type: "warning",
+        })
+        .then(() => {
+            detail.splice(dIndex, 1);
+        })
+    },
+    //保存句子
+    saveOptionDetail() {
+      let _this = this;
+      _this.addStemVisible = false;
+      if (_this.detailSelectType == "edit") {
+        let optionItem = JSON.parse(JSON.stringify(_this.optionItemDetail));
+        _this.cellData.mulText.detail[_this.datailIndex] =
+          optionItem;
+      } else {
+        let optionItem = JSON.parse(JSON.stringify(_this.optionItemDetail));
+        _this.cellData.mulText.detail.push(optionItem);
+      }
+    },
+    onBlur(item, field) {
+      item[field] = item[field] ? item[field].trim() : "";
+    },
   },
 };
 </script>
@@ -150,6 +301,26 @@ export default {
     width: 70px;
   }
 }
+.option-detail-detail {
+  clear: both;
+  overflow: hidden;
+  margin-bottom: 10px;
+  > li {
+    float: left;
+    > span {
+      float: left;
+      &.dleft {
+        padding-left: 4px;
+      }
+      &.dright{
+        padding-right: 4px;
+      }
+    }
+  }
+  > i {
+    float: left;
+  }
+}
 </style>
 
 <style lang="scss">

+ 96 - 0
src/components/Adult/inputModules/HeaderSeparate/index.vue

@@ -45,6 +45,17 @@
       <table class="preview-table">
         <thead>
           <tr>
+            <td></td>
+            <td
+              v-for="(item, k) in curQue.tableData.colsConfig.width"
+              :key="`tfoot-${k}`"
+            >
+              第{{k+1}}列
+            </td>
+            <td></td>
+          </tr>
+          <tr>
+            <th></th>
             <th v-for="(num, i) in curQue.tableData.headers" :key="`th-${i}`">
               <el-input v-model="num.text">
                 <template slot="prepend">文本</template>
@@ -60,11 +71,39 @@
                 </el-select>
               </el-input>
             </th>
+            <th></th>
           </tr>
         </thead>
         <tbody>
           <tr v-for="(row, i) in curQue.tableData.body" :key="`tr-${i}`">
+            <td width="60">第{{i+1}}行</td>
             <td v-for="(col, j) in row.content" :key="`td-${j}`">
+              <p>{{col.message+' '+col.text+' '+col.sentence_data.sentence}}</p>
+              <template v-if="col.mulText">
+                <ul
+                class="option-detail-detail"
+                v-for="(dItem, dIndex) in col.mulText.detail"
+                :key="'ddItem' + dIndex"
+                >
+                <li
+                    v-for="(ddItem, ddIndex) in dItem.detail"
+                    :key="'ddItem' + dIndex + ddIndex"
+                >
+                    <span
+                    :class="[
+                        ddItem.config.wordPadding.indexOf('left') > -1
+                        ? 'dleft'
+                        : '',
+                        ddItem.config.wordPadding.indexOf('right') > -1
+                        ? 'dright'
+                        : '',
+                        !ddItem.sentence ? 'placeholder' : '',
+                    ]"
+                    >{{ ddItem.sentence }}</span
+                    >
+                </li>
+                </ul>
+              </template>
               <el-button @click="edit(i, j)">编辑</el-button>
             </td>
             <td>
@@ -72,6 +111,7 @@
             </td>
           </tr>
           <tr>
+            <td></td>
             <td
               v-for="(width, i) in curQue.tableData.colsConfig.width"
               :key="`width-${i}`"
@@ -81,6 +121,7 @@
               </el-input>
               <el-button size="mini" @click="deleteCol(i)">删除列</el-button>
             </td>
+            <td></td>
           </tr>
         </tbody>
       </table>
@@ -154,6 +195,13 @@ export default {
                       seg_words: "",
                       wordsList: [],
                     },
+                    mulText:{
+                        correct: {
+                            completeInput: ""
+                        },
+                        detail: [],
+                        input_Isexample: false,
+                    }
                   },
                   {
                     type: "content",
@@ -176,6 +224,13 @@ export default {
                       seg_words: "",
                       wordsList: [],
                     },
+                    mulText:{
+                        correct: {
+                            completeInput: ""
+                        },
+                        detail: [],
+                        input_Isexample: false,
+                    }
                   },
                   {
                     type: "content",
@@ -198,6 +253,13 @@ export default {
                       seg_words: "",
                       wordsList: [],
                     },
+                    mulText:{
+                        correct: {
+                            completeInput: ""
+                        },
+                        detail: [],
+                        input_Isexample: false,
+                    }
                   },
                 ],
               },
@@ -260,6 +322,13 @@ export default {
             seg_words: "",
             wordsList: [],
           },
+          mulText:{
+            correct: {
+                completeInput: ""
+            },
+            detail: [],
+            input_Isexample: false,
+          }
         });
       });
       this.curQue.tableData.headers.push({
@@ -305,6 +374,13 @@ export default {
             seg_words: "",
             wordsList: [],
           },
+          mulText:{
+            correct: {
+                completeInput: ""
+            },
+            detail: [],
+            input_Isexample: false,
+          }
         });
       }
       this.curQue.tableData.body.push({
@@ -379,5 +455,25 @@ export default {
       }
     }
   }
+  .option-detail-detail {
+    clear: both;
+    overflow: hidden;
+    margin-bottom: 10px;
+    > li {
+        float: left;
+        > span {
+        float: left;
+        &.dleft {
+            padding-left: 4px;
+        }
+        &.dright{
+            padding-right: 4px;
+        }
+        }
+    }
+    > i {
+        float: left;
+    }
+  }
 }
 </style>

+ 0 - 1
src/components/Adult/preview/ConfigurableTable.vue

@@ -682,7 +682,6 @@ export default {
           });
         });
       }
-      console.log(this.curQue)
     },
     //词和标点合一起
     mergeWordSymbol(sItem) {

+ 285 - 2
src/components/Adult/preview/HeaderSparate/index.vue

@@ -178,6 +178,61 @@
                     </span>
                   </div>
                 </div>
+                <div class="stem-content" v-else-if="col.type === 'mulText'">
+                    <div
+                        :class="[
+                            'sent-main',
+                        ]"
+                        v-for="(sdItem, sdIndex) in col.mulText.detail"
+                        :key="'sent-option-items' + j + sdIndex"
+                        >
+                        <div class="sent-que-box">
+                            <div
+                            class="sent-que"
+                            v-for="(sddItem, sddIndex) in sdItem.detail"
+                            :key="'sent-option-items' + j + sdIndex + sddIndex"
+                            :style="{
+                                paddingLeft:
+                                sddItem.config.wordPadding.indexOf('left') > -1
+                                    ? '4px'
+                                    : '0px',
+                                paddingRight:
+                                sddItem.config.wordPadding.indexOf('right') > -1
+                                    ? '4px'
+                                    : '0px',
+                            }"
+                            >
+                            <!-- 补全句子 -->
+                            <OneSentenceTemp
+                                :detail="sddItem"
+                                :pyPosition="curQue.pinyinPosition"
+                                :TaskModel="TaskModel"
+                                :Bookanswer="curQue.Bookanswer[i].content[j]"
+                                :judgeAnswer="judgeAnswer"
+                                :correctAnswer="col.mulText.correct.complateArr"
+                                :isInput="true"
+                                :fn_check_list="[]"
+                                :pyNumber="col.pyNumber && col.pyNumber[sdIndex]"
+                                :hengLeg="sdItem.hengLeg"
+                                :maxFontsize="sdItem.maxFontsize"
+                            />
+                            <template
+                                v-if="
+                                sddItem.img_list &&
+                                sddItem.img_list.length > 0 &&
+                                sddItem.img_list[0].id
+                                "
+                            >
+                                <img
+                                :src="sddItem.img_list[0].id"
+                                class="sddItem_img_list"
+                                :style="[imgStyle(sddItem)]"
+                                />
+                            </template>
+                            </div>
+                        </div>
+                    </div>
+                </div>
                 <CrossTick
                   v-if="col.isCross"
                   :index="i"
@@ -202,9 +257,10 @@
 <script>
 import CrossTick from "./CrossTick.vue";
 import AnswerTitle from "../../preview/components/AnswerTitle.vue";
+import OneSentenceTemp from "../components/OneSentenceTemp.vue";
 
 export default {
-  components: { CrossTick, AnswerTitle },
+  components: { CrossTick, AnswerTitle, OneSentenceTemp },
   props: {
     curQue: {
       type: Object,
@@ -217,11 +273,19 @@ export default {
     judgeAnswer: {
       type: String,
     },
+    TaskModel: {
+      type: String,
+    }
   },
   data() {
     return {
       isAnswerMode: false,
       userError: false,
+      userAnswer: {
+        completeInput: []
+      },
+      userBookanswer:[],
+      chsFhList: [",", "。", "”", ":", "》", "?", "!", ";"],
     };
   },
   computed: {
@@ -283,11 +347,15 @@ export default {
     }
     if (!this.curQue.Bookanswer) {
       let arr = [];
+      let flag = false // 是否含有多个句子类型
       this.curQue.tableData.body.forEach((item, i) => {
         arr.push({
           content: [],
         });
         item.content.forEach((items) => {
+            if(items.type === 'mulText'){
+                flag = true
+            }
           arr[i].content.push({
             answer: "",
             CrossAnswer: "",
@@ -296,7 +364,9 @@ export default {
           });
         });
       });
-      this.$set(this.curQue, "Bookanswer", arr);
+      if(!flag){
+        this.$set(this.curQue, "Bookanswer", arr);
+      }
     } else {
       this.curQue.Bookanswer.forEach((item) => {
         item.content.forEach((item) => {
@@ -308,6 +378,9 @@ export default {
       });
     }
   },
+  mounted() {
+    this.handleData();
+  },
   methods: {
     enterAnswer(i, j, type) {
       if (type == "input") {
@@ -425,6 +498,179 @@ export default {
         colIndex === -1 && (rowIndex === -1 || j === body[0].content.length - 1)
       );
     },
+    handleData() {
+      let Bookanswer = [];
+      let itemLeg = 0;
+      this.totalHasPy = false;
+      let option = JSON.parse(JSON.stringify(this.curQue.tableData.body));
+      let completeImage = [];
+      option.forEach((item, index) => {
+        Bookanswer.push({content: []});
+        completeImage = [];
+        itemLeg = item.length > itemLeg ? item.length : itemLeg;
+        item.content.forEach((items, indexs) => {
+            if(items.mulText){
+                let userAnswer = JSON.parse(JSON.stringify(this.userAnswer));
+                let correct = JSON.parse(JSON.stringify(items.mulText.correct));
+                let complateArr = correct.completeInput.split("\n");
+                complateArr.forEach((itemI, indexI) => {
+                    if (itemI == "??" || itemI == "??") {
+                    complateArr[indexI] = "";
+                    }
+                });
+                items.mulText.correct.complateArr = complateArr;
+                this.curQue.tableData.body[index].content[indexs].mulText.correct.complateArr = complateArr;
+                Bookanswer[index].content.push(userAnswer);
+                let hengIndex = 0;
+                items.pyNumber = [];
+
+                items.mulText.detail.forEach((sdItem, sdIndex) => {
+                    let isHasPY = 0;
+                    let maxFontsize = 0;
+                    sdItem.detail.forEach((sddItem) => {
+                    if (sddItem.wordsList.length > 0) {
+                        sddItem.wordsList.forEach((sItem, sIndex) => {
+                        let reg = /_{2,}/g;
+                        if (reg.test(sItem.chs)) {
+                            sItem.index = sIndex;
+                            sItem.isHeng = true;
+                            sItem.hengIndex = hengIndex;
+                            hengIndex++;
+                        }
+                        //补全句子
+                        if (
+                            !this.curQue.Bookanswer 
+                        ) {
+                            let reg = /_{2,}/g;
+                            if (reg.test(sItem.chs)) {
+                            let bool = false;
+                            if (sddItem.hasOwnProperty("input_Isexample")) {
+                                bool = sddItem.input_Isexample;
+                            } else {
+                                bool = items.Isexample;
+                            }
+                            let obj = null;
+                            if (!sddItem.input_tian) {
+                                obj = {
+                                answer:
+                                    bool && complateArr[sItem.hengIndex]
+                                    ? complateArr[sItem.hengIndex]
+                                    : "",
+                                userAnswerJudge:
+                                    bool || !complateArr[sItem.hengIndex]
+                                    ? ""
+                                    : "[JUDGE##F##JUDGE]",
+                                input_Isexample: bool ? true : false,
+                                };
+                                Bookanswer[index].content[indexs].completeInput.push(
+                                JSON.parse(JSON.stringify(obj))
+                                );
+                            } else {
+                                if (sddItem.hengLeg == "-1") {
+                                completeImage.push(obj);
+                                } else {
+                                for (let i = 0; i < Number(sddItem.hengLeg); i++) {
+                                    completeImage.push(obj);
+                                }
+                                }
+                                Bookanswer[index].content[indexs].completeInput.push(
+                                JSON.parse(JSON.stringify(completeImage))
+                                );
+                            }
+                            }
+                        }
+
+                        this.mergeWordSymbol(sItem);
+                        if (sItem.pinyin) {
+                            isHasPY++;
+                            this.totalHasPy = true;
+                        }
+                        let fontSize = JSON.parse(JSON.stringify(sItem.fontSize));
+                        fontSize = Number(fontSize.replace("px", ""));
+                        maxFontsize = fontSize > maxFontsize ? fontSize : maxFontsize;
+                        });
+                    } else {
+                        if (sddItem.sentence) {
+                        let fontSize = JSON.parse(
+                            JSON.stringify(sddItem.config.fontSize)
+                        );
+                        fontSize = Number(fontSize.replace("px", ""));
+                        maxFontsize = fontSize > maxFontsize ? fontSize : maxFontsize;
+                        }
+                    }
+                    });
+                    sdItem.maxFontsize = maxFontsize;
+                    items.pyNumber.push(isHasPY);
+                });
+            }
+          
+        });
+      });
+      if (!this.curQue.Bookanswer) {
+        this.$set(
+          this.curQue,
+          "Bookanswer",
+          JSON.parse(JSON.stringify(Bookanswer))
+        );
+      } else {
+        let BookanswerStr = JSON.stringify(this.curQue.Bookanswer);
+        let errReg = /\[JUDGE##F##JUDGE\]/g;
+        if (errReg.test(BookanswerStr)) {
+          let errorArr = BookanswerStr.match(/\[JUDGE##F##JUDGE\]/g);
+          this.userErrorNumberTotal = errorArr.length;
+        }
+      }
+
+      this.$set(this.curQue.tableData, "body", option);
+      let contentWidth = 780;
+      if (this.curQue.img_list && this.curQue.img_list.length > 0) {
+        contentWidth = 780 - this.curQue.img_size;
+      }
+      if(itemLeg==1){
+        this.itemsWidth = 780
+      }else{
+        this.itemsWidth = Math.floor(contentWidth / itemLeg) - 16;
+      }
+      
+
+      // 把答错的挑出来
+      if (this.judgeAnswer == "standardAnswer") {
+        this.userErrorList = [];
+        this.userBookanswer = [];
+        this.curQue.tableData.body.forEach((item, index) => {
+            item.content.forEach((items, indexs) => {
+            if(items.mulText){
+                let flag = false;
+                // 句子填空
+                items.mulText.correct.complateArr.forEach((itemI, indexI) => {
+                if (
+                    itemI &&
+                    itemI !=
+                    this.curQue.Bookanswer[index].content[indexs].completeInput[indexI]
+                ) {
+                    flag = true;
+                }
+                });
+
+                if (flag) {
+                    this.userErrorList.push(items);
+                    this.userBookanswer.push(this.curQue.Bookanswer[index][indexs]);
+                    this.userError = true;
+                }
+            }
+            
+          });
+        });
+      }
+    },
+    //词和标点合一起
+    mergeWordSymbol(sItem) {
+      if (this.chsFhList.indexOf(sItem.chs) > -1) {
+        sItem.isShow = false;
+      } else {
+        sItem.isShow = true;
+      }
+    },
   },
 };
 </script>
@@ -575,6 +821,43 @@ export default {
     }
   }
 }
+.stem-content {
+    flex: 1;
+}
+.sent-main {
+    position: relative;
+    width: 100%;
+    display: flex;
+    flex-wrap: wrap;
+
+    box-sizing: border-box;
+    &-138 {
+        padding-right: 138px;
+    }
+    &-bottom {
+        margin-bottom: 9px;
+    }
+}
+.sent-que-box {
+    display: flex;
+    flex-wrap: wrap;
+    padding: 4px 0;
+}
+.sent-que {
+// font-size: 0;
+    &-flex {
+        flex: 1;
+        display: flex;
+        justify-content: space-between;
+        align-items: stretch;
+    }
+    .sentence-part {
+        flex: 1;
+    }
+    .sddItem_img_list {
+        height: 32px;
+    }
+}
 </style>
 <style lang="scss">
 .header-separate {