12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145 |
- <template>
- <div>
- <section class="content">
- <div>
- <!-- 头信息 -->
- <div>
- <h3 class="box-title">题型创建->{{ detailName }}</h3>
- </div>
- <!-- 正文信息 -->
- <div class="box-body">
- <el-form
- :inline="true"
- :model="paperUnitForm"
- :rules="rules"
- ref="paperUnitForm"
- label-position="right"
- label-width="90px"
- >
- <el-form-item
- label="题型结构"
- class="pull-left"
- prop="questionType"
- >
- <el-select
- @change="getQuesNameList"
- v-model="paperUnitForm.questionType"
- placeholder="请选择"
- >
- <el-option
- v-for="item in quesTypes"
- :label="item.label"
- :value="item.value"
- :key="item.value"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="题目数量" prop="count">
- <el-button @click="propertyDialog = true;">
- {{ paperUnitForm.count }}
- </el-button>
- </el-form-item>
- <el-form-item label="每题分值" class="pull-left" prop="score">
- <el-input
- v-model.number="paperUnitForm.score"
- @change="muli"
- placeholder="请输入"
- ></el-input>
- </el-form-item>
- <el-form-item label="题型总分" class="pull-left" prop="totalScore">
- <el-input
- v-model="paperUnitForm.totalScore"
- :disabled="true"
- ></el-input>
- </el-form-item>
- <el-form-item label="来源大题" class="pull-left" prop="quesNames">
- <el-select
- multiple
- v-model="paperUnitForm.quesNames"
- placeholder="请选择"
- >
- <el-option
- v-for="item in quesNameList"
- :label="item.name"
- :value="item.code"
- :key="item.code"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item class="pull-right">
- <el-button
- size="small"
- type="primary"
- @click="submitForm('paperUnitForm');"
- >保 存</el-button
- >
- <el-button
- size="small"
- type="danger"
- @click="resetForm('paperUnitForm');"
- >重 置</el-button
- >
- <el-button
- size="small"
- type="primary"
- icon="caret-left"
- @click="back"
- >返 回</el-button
- >
- </el-form-item>
- </el-form>
- <!-- 页面列表 -->
- <el-table
- :data="unitStructs"
- border
- style="width: 100%;text-align:center;"
- >
- <el-table-column label="大题名称" width="100">
- <template slot-scope="scope">
- <div>
- <span>{{ scope.detailName }}</span>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="题型结构" width="100">
- <template slot-scope="scope">
- <div>
- <span>{{ getQuesTypeName(scope.row.questionType) }}</span>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="题目总数" width="100">
- <template slot-scope="scope">
- <div>
- <span>{{ scope.row.count }}</span>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="公开(简单)" width="130">
- <template slot-scope="scope">
- <div>
- <span>{{ scope.row.publicSimple }}</span>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="公开(中等)" width="130">
- <template slot-scope="scope">
- <div>
- <span>{{ scope.row.publicMedium }}</span>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="公开(困难)" width="130">
- <template slot-scope="scope">
- <div>
- <span>{{ scope.row.publicDifficulty }}</span>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="非公开(简单)" width="140">
- <template slot-scope="scope">
- <div>
- <span>{{ scope.row.noPublicSimple }}</span>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="非公开(中等)" width="140">
- <template slot-scope="scope">
- <div>
- <span>{{ scope.row.noPublicMedium }}</span>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="非公开(困难)" width="140">
- <template slot-scope="scope">
- <div>
- <span>{{ scope.row.noPublicDifficulty }}</span>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="每题分值" width="100">
- <template slot-scope="scope">
- <div>
- <span>{{ scope.row.score }}</span>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="题型总分" width="100">
- <template slot-scope="scope">
- <div>
- <span>{{ scope.row.totalScore }}</span>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="来源大题" width="150">
- <template slot-scope="scope">
- <div>
- <span>{{ getQuesNames(scope.row.quesNames) }}</span>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="140">
- <template slot-scope="scope">
- <div>
- <el-button
- size="mini"
- type="info"
- @click="openPaperDetailUnitStructDialog(scope.row.id);"
- >编辑</el-button
- >
- <el-button
- size="mini"
- type="danger"
- @click="deleteUnit(scope.row.id);"
- >删除</el-button
- >
- </div>
- </template>
- </el-table-column>
- </el-table>
- <!-- 小题信息 -->
- <el-dialog
- title="小题信息"
- :visible.sync="paperDetailUnitStructDialog"
- >
- <div>
- <el-form
- :inline="true"
- :model="paperUnitForm2"
- :rules="rules"
- ref="paperUnitForm2"
- >
- <el-row :gutter="45">
- <el-col :span="12">
- <el-form-item label="题型结构" prop="questionType">
- <el-select
- @change="getQuesNameList"
- v-model="paperUnitForm2.questionType"
- placeholder="请选择"
- >
- <el-option
- v-for="item in quesTypes"
- :label="item.label"
- :value="item.value"
- :key="item.value"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item
- label="每题分值"
- class="pull-left"
- prop="score"
- >
- <el-input
- v-model.number="paperUnitForm2.score"
- @change="muli2"
- placeholder="请输入"
- ></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="45">
- <el-col :span="12">
- <el-form-item label="题型总分" prop="totalScore">
- <el-input
- v-model="paperUnitForm2.totalScore"
- :disabled="true"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="来源大题" prop="quesNames">
- <el-select
- multiple
- v-model="paperUnitForm2.quesNames"
- placeholder="请选择"
- >
- <el-option
- v-for="item in quesNameList"
- :label="item.name"
- :value="item.code"
- :key="item.code"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :span="6">
- <div class="grid-content bg-purple">公开(简单)</div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">公开(中等)</div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">公开(困难)</div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">公开总数</div>
- </el-col>
- </el-row>
- <!-- 第二列 -->
- <el-row :gutter="20">
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm2.publicSimple"
- @change="
- unitCount(
- paperUnitForm2.publicSimple,
- 'publicSimple',
- paperUnitForm2
- );
- "
- ></el-input>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm2.publicMedium"
- @change="
- unitCount(
- paperUnitForm2.publicMedium,
- 'publicMedium',
- paperUnitForm2
- );
- "
- ></el-input>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm2.publicDifficulty"
- @change="
- unitCount(
- paperUnitForm2.publicDifficulty,
- 'publicDifficulty',
- paperUnitForm2
- );
- "
- ></el-input>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm2.publicSum"
- :disabled="true"
- ></el-input>
- </div>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :span="6">
- <div class="grid-content bg-purple">非公开(简单)</div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">非公开(中等)</div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">非公开(困难)</div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">非公开总数</div>
- </el-col>
- </el-row>
- <!-- 第四列 -->
- <el-row :gutter="20">
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm2.noPublicSimple"
- @change="
- unitCount(
- paperUnitForm2.noPublicSimple,
- 'noPublicSimple',
- paperUnitForm2
- );
- "
- ></el-input>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm2.noPublicMedium"
- @change="
- unitCount(
- paperUnitForm2.noPublicMedium,
- 'noPublicMedium',
- paperUnitForm2
- );
- "
- ></el-input>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm2.noPublicDifficulty"
- @change="
- unitCount(
- paperUnitForm2.noPublicDifficulty,
- 'noPublicDifficulty',
- paperUnitForm2
- );
- "
- ></el-input>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm2.noPublicSum"
- :disabled="true"
- ></el-input>
- </div>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :span="6">
- <div class="grid-content bg-purple">简单总数</div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">中等总数</div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">困难总数</div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">总数</div>
- </el-col>
- </el-row>
- <!-- 第六列 -->
- <el-row :gutter="20">
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm2.simpleSum"
- :disabled="true"
- ></el-input>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm2.mediumSum"
- :disabled="true"
- ></el-input>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm2.difficultySum"
- :disabled="true"
- ></el-input>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm2.count"
- :disabled="true"
- ></el-input>
- </div>
- </el-col>
- </el-row>
- <el-row>
- <div>
- <el-button
- type="primary"
- @click="editSubmitForm('paperUnitForm2');"
- >保 存</el-button
- >
- </div>
- </el-row>
- </el-form>
- </div>
- </el-dialog>
- <!-- 设置题目数量弹框 -->
- <el-dialog title="题目数量" :visible.sync="propertyDialog">
- <el-row :gutter="20">
- <el-col :span="6">
- <div class="grid-content bg-purple">公开(简单)</div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">公开(中等)</div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">公开(困难)</div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">公开总数</div>
- </el-col>
- </el-row>
- <!-- 第二列 -->
- <el-row :gutter="20">
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm.publicSimple"
- @change="
- unitCount(
- paperUnitForm.publicSimple,
- 'publicSimple',
- paperUnitForm
- );
- "
- ></el-input>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm.publicMedium"
- @change="
- unitCount(
- paperUnitForm.publicMedium,
- 'publicMedium',
- paperUnitForm
- );
- "
- ></el-input>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm.publicDifficulty"
- @change="
- unitCount(
- paperUnitForm.publicDifficulty,
- 'publicDifficulty',
- paperUnitForm
- );
- "
- ></el-input>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm.publicSum"
- :disabled="true"
- ></el-input>
- </div>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :span="6">
- <div class="grid-content bg-purple">非公开(简单)</div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">非公开(中等)</div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">非公开(困难)</div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">非公开总数</div>
- </el-col>
- </el-row>
- <!-- 第四列 -->
- <el-row :gutter="20">
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm.noPublicSimple"
- @change="
- unitCount(
- paperUnitForm.noPublicSimple,
- 'noPublicSimple',
- paperUnitForm
- );
- "
- ></el-input>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm.noPublicMedium"
- @change="
- unitCount(
- paperUnitForm.noPublicMedium,
- 'noPublicMedium',
- paperUnitForm
- );
- "
- ></el-input>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm.noPublicDifficulty"
- @change="
- unitCount(
- paperUnitForm.noPublicDifficulty,
- 'noPublicDifficulty',
- paperUnitForm
- );
- "
- ></el-input>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm.noPublicSum"
- :disabled="true"
- ></el-input>
- </div>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :span="6">
- <div class="grid-content bg-purple">简单总数</div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">中等总数</div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">困难总数</div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">总数</div>
- </el-col>
- </el-row>
- <!-- 第六列 -->
- <el-row :gutter="20">
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm.simpleSum"
- :disabled="true"
- ></el-input>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm.mediumSum"
- :disabled="true"
- ></el-input>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm.difficultySum"
- :disabled="true"
- ></el-input>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="grid-content bg-purple">
- <el-input
- v-model="paperUnitForm.count"
- :disabled="true"
- ></el-input>
- </div>
- </el-col>
- </el-row>
- <div style="margin-top:20px;margin-left:42%">
- <el-button type="primary" @click="propertyDialog = false;"
- >保 存</el-button
- >
- <el-button type="primary" @click="propertyDialog = false;"
- >返 回</el-button
- >
- </div>
- </el-dialog>
- </div>
- </div>
- </section>
- </div>
- </template>
- <script>
- import { QUESTION_API } from "@/constants/constants";
- import { QUESTION_TYPES } from "../constants/constants";
- import _ from "lodash";
- export default {
- data() {
- var checkIntegerNumber = (rule, value, callback) => {
- if (!value) {
- return callback(new Error("数值不能为空"));
- }
- setTimeout(() => {
- if (!Number.isInteger(value)) {
- callback(new Error("请输入整数"));
- } else {
- if (value < 0) {
- callback(new Error("必须大于0"));
- } else {
- callback();
- }
- }
- }, 100);
- };
- var checkDoubleNumber = (rule, value, callback) => {
- //var reg = /^[-\+]?\d+(\.\d+)?$/;
- var reg = /^\d+(?=\.{0,1}\d+$|$)/;
- if (!value) {
- return callback(new Error("数值不能为空"));
- }
- setTimeout(() => {
- if (!reg.test(value)) {
- callback(new Error("请输入数值"));
- } else {
- if (value < 0) {
- callback(new Error("必须大于等于0"));
- } else {
- callback();
- }
- }
- }, 100);
- };
- var validateQuesNames = (rule, value, callback) => {
- if (Array.isArray(value) && value.length == 0) {
- callback(new Error("请选择来源大题"));
- } else {
- callback();
- }
- };
- return {
- quesTypes: QUESTION_TYPES,
- courseNo: "",
- quesNameList: [],
- paperUnitForm: {
- id: "",
- questionType: "",
- count: 0,
- score: "",
- totalScore: "",
- quesNames: [],
- publicSimple: 0,
- publicMedium: 0,
- publicDifficulty: 0,
- noPublicSimple: 0,
- noPublicMedium: 0,
- noPublicDifficulty: 0,
- publicSum: 0,
- noPublicSum: 0,
- simpleSum: 0,
- mediumSum: 0,
- difficultySum: 0
- },
- paperUnitForm2: {
- id: "",
- questionType: "",
- count: "",
- score: "",
- totalScore: "",
- quesNames: [],
- publicSimple: 0,
- publicMedium: 0,
- publicDifficulty: 0,
- noPublicSimple: 0,
- noPublicMedium: 0,
- noPublicDifficulty: 0,
- publicSum: 0,
- noPublicSum: 0,
- simpleSum: 0,
- mediumSum: 0,
- difficultySum: 0
- },
- unitId: "",
- detailName: "",
- detailId: "",
- paperStructId: "",
- paperStruct: {},
- unitStructs: [],
- paperDetailUnitStructDialog: false,
- propertyDialog: false,
- rules: {
- questionType: [
- { required: true, message: "题型不能为空", trigger: "change" }
- ],
- count: [
- { validator: checkIntegerNumber, required: true, trigger: "blur" }
- ],
- score: [
- { required: true, validator: checkDoubleNumber, trigger: "blur" }
- ],
- quesNames: [{ validator: validateQuesNames, trigger: "change" }]
- }
- };
- },
- methods: {
- //查询来源大题名称
- getQuesNameList(quesType) {
- if (quesType && quesType.length > 0) {
- var quesTypeObj = {};
- var url = QUESTION_API + "/paperStruct/quesNames";
- if (this.courseNo !== "all") {
- quesTypeObj = {
- quesType: quesType,
- courseNo: this.courseNo
- };
- } else {
- quesTypeObj = {
- quesType: quesType
- };
- }
- this.$http.get(url, { params: quesTypeObj }).then(response => {
- console.log(response);
- this.quesNameList = response.data;
- this.initQuesNames();
- });
- }
- },
- initQuesNames() {
- var arr1 = _.difference(this.paperUnitForm.quesNames, this.quesNames);
- if (arr1.length > 0) {
- this.paperUnitForm.quesNames = [];
- }
- var arr2 = _.difference(this.paperUnitForm2.quesNames, this.quesNames);
- if (arr2.length > 0) {
- this.paperUnitForm2.quesNames = [];
- }
- },
- getQuesNames(quesNameList) {
- var quesNameStr = "";
- if (!Array.isArray(quesNameList)) {
- return quesNameStr;
- }
- for (let quesName of quesNameList) {
- if (quesNameStr === "") {
- quesNameStr += quesName;
- } else {
- quesNameStr += "," + quesName;
- }
- }
- return quesNameStr;
- },
- //查询列表集合
- searchForm() {
- this.loading = true;
- var paperStructStorge = sessionStorage.getItem("paperStruct");
- if (typeof paperStructStorge === "string") {
- var paperStruct = JSON.parse(paperStructStorge);
- this.paperStruct = paperStruct;
- this.unitStructs = this.getUnits();
- }
- },
- //保存
- submitForm(formData) {
- this.loading = true;
- this.$refs[formData].validate(valid => {
- if (valid) {
- var unitStruct = Object.assign({}, this.paperUnitForm);
- var ids = [];
- for (let unitStruct of this.unitStructs) {
- ids.push(unitStruct.id);
- }
- ids.sort();
- var maxId;
- if (ids.length == 0) {
- maxId = 1;
- } else {
- maxId = ids[ids.length - 1];
- }
- unitStruct.id = maxId + 1;
- this.unitStructs.push(unitStruct);
- this.resetForm();
- this.setUnits();
- sessionStorage.setItem(
- "paperStruct",
- JSON.stringify(this.paperStruct)
- );
- } else {
- return false;
- }
- });
- },
- editSubmitForm(formData) {
- this.$refs[formData].validate(valid => {
- if (valid) {
- for (let unitStruct of this.unitStructs) {
- if (unitStruct.id == this.paperUnitForm2.id) {
- unitStruct.questionType = this.paperUnitForm2.questionType;
- unitStruct.count = this.paperUnitForm2.count;
- unitStruct.score = this.paperUnitForm2.score;
- unitStruct.totalScore = this.paperUnitForm2.totalScore;
- unitStruct.quesNames = this.paperUnitForm2.quesNames;
- unitStruct.publicSimple = this.paperUnitForm2.publicSimple;
- unitStruct.publicMedium = this.paperUnitForm2.publicMedium;
- unitStruct.publicDifficulty = this.paperUnitForm2.publicDifficulty;
- unitStruct.noPublicSimple = this.paperUnitForm2.noPublicSimple;
- unitStruct.noPublicMedium = this.paperUnitForm2.noPublicMedium;
- unitStruct.noPublicDifficulty = this.paperUnitForm2.noPublicDifficulty;
- unitStruct.publicSum = this.paperUnitForm2.publicSum;
- unitStruct.noPublicSum = this.paperUnitForm2.noPublicSum;
- unitStruct.simpleSum = this.paperUnitForm2.simpleSum;
- unitStruct.mediumSum = this.paperUnitForm2.mediumSum;
- unitStruct.difficultySum = this.paperUnitForm2.difficultySum;
- this.setUnits();
- this.paperDetailUnitStructDialog = false;
- sessionStorage.setItem(
- "paperStruct",
- JSON.stringify(this.paperStruct)
- );
- }
- }
- }
- });
- },
- //重置
- resetForm() {
- this.paperUnitForm = {
- id: "",
- questionType: "",
- count: 0,
- score: "",
- totalScore: "",
- quesNames: [],
- publicSimple: 0,
- publicMedium: 0,
- publicDifficulty: 0,
- noPublicSimple: 0,
- noPublicMedium: 0,
- noPublicDifficulty: 0,
- publicSum: 0,
- noPublicSum: 0,
- simpleSum: 0,
- mediumSum: 0,
- difficultySum: 0
- };
- },
- //返回
- back() {
- this.$router.push({
- path: "/questions/insert_paper_structure/" + this.paperStructId
- });
- },
- muli() {
- this.paperUnitForm.totalScore =
- this.paperUnitForm.count * this.paperUnitForm.score;
- },
- muli2() {
- this.paperUnitForm2.totalScore =
- this.paperUnitForm2.count * this.paperUnitForm2.score;
- },
- getUnits() {
- var unitStructs = [];
- for (let paperDetailStruct of this.paperStruct.paperDetailStructs) {
- if (parseInt(paperDetailStruct.id) == this.detailId) {
- if (paperDetailStruct.unitStructs) {
- return paperDetailStruct.unitStructs;
- }
- }
- }
- return unitStructs;
- },
- setUnits() {
- for (let paperDetailStruct of this.paperStruct.paperDetailStructs) {
- if (parseInt(paperDetailStruct.id) == this.detailId) {
- paperDetailStruct.unitStructs = this.unitStructs;
- paperDetailStruct.totalScore = this.totalScore;
- paperDetailStruct.detailCount = this.detailCount;
- }
- }
- },
- getQuesTypeName(value) {
- for (let quesType of this.quesTypes) {
- if (value == quesType.value) {
- return quesType.label;
- }
- }
- },
- openPaperDetailUnitStructDialog(id) {
- this.unitId = id;
- for (let unitStruct of this.unitStructs) {
- if (unitStruct.id == id) {
- this.paperUnitForm2.id = id;
- this.paperUnitForm2.questionType = unitStruct.questionType;
- this.paperUnitForm2.count = unitStruct.count;
- this.paperUnitForm2.score = unitStruct.score;
- this.paperUnitForm2.totalScore = unitStruct.totalScore;
- this.paperUnitForm2.quesNames = unitStruct.quesNames;
- this.paperUnitForm2.publicSimple = unitStruct.publicSimple;
- this.paperUnitForm2.publicMedium = unitStruct.publicMedium;
- this.paperUnitForm2.publicDifficulty = unitStruct.publicDifficulty;
- this.paperUnitForm2.noPublicSimple = unitStruct.noPublicSimple;
- this.paperUnitForm2.noPublicMedium = unitStruct.noPublicMedium;
- this.paperUnitForm2.noPublicDifficulty =
- unitStruct.noPublicDifficulty;
- //实时计算,不存数据库
- this.paperUnitForm2.publicSum =
- this.paperUnitForm2.publicSimple +
- this.paperUnitForm2.publicMedium +
- this.paperUnitForm2.publicDifficulty;
- this.paperUnitForm2.noPublicSum =
- this.paperUnitForm2.noPublicSimple +
- this.paperUnitForm2.noPublicMedium +
- this.paperUnitForm2.noPublicDifficulty;
- this.paperUnitForm2.simpleSum =
- this.paperUnitForm2.publicSimple +
- this.paperUnitForm2.noPublicSimple;
- this.paperUnitForm2.mediumSum =
- this.paperUnitForm2.publicMedium +
- this.paperUnitForm2.noPublicMedium;
- this.paperUnitForm2.difficultySum =
- this.paperUnitForm2.publicDifficulty +
- this.paperUnitForm2.noPublicDifficulty;
- }
- }
- this.getQuesNameList(this.paperUnitForm2.questionType);
- this.paperDetailUnitStructDialog = true;
- },
- deleteUnit(id) {
- var unitStructs = this.unitStructs;
- for (let i = unitStructs.length - 1; i >= 0; i--) {
- if (unitStructs[i].id == id) {
- unitStructs.splice(i, 1);
- }
- }
- this.unitStructs = unitStructs;
- this.setUnits();
- sessionStorage.setItem("paperStruct", JSON.stringify(this.paperStruct));
- console.log(sessionStorage.getItem("paperStruct"));
- },
- //判断是否为正整数
- isPositiveInteger(s) {
- //是否为正整数
- var re = /^[0-9]+$/;
- return re.test(s);
- },
- //计算数量
- unitCount(data, rowType, paperUnitForm) {
- //计算前校验正整数
- if (!this.isPositiveInteger(data)) {
- if (rowType === "publicSimple") {
- setTimeout(function() {
- paperUnitForm.publicSimple = 0;
- }, 1);
- } else if (rowType === "publicMedium") {
- setTimeout(function() {
- paperUnitForm.publicMedium = 0;
- }, 1);
- } else if (rowType === "publicDifficulty") {
- setTimeout(function() {
- paperUnitForm.publicDifficulty = 0;
- }, 1);
- } else if (rowType === "noPublicSimple") {
- setTimeout(function() {
- paperUnitForm.noPublicSimple = 0;
- }, 1);
- } else if (rowType === "noPublicMedium") {
- setTimeout(function() {
- paperUnitForm.noPublicMedium = 0;
- }, 1);
- } else if (rowType === "noPublicDifficulty") {
- setTimeout(function() {
- paperUnitForm.noPublicDifficulty = 0;
- }, 1);
- }
- }
- setTimeout(function() {
- paperUnitForm.publicSimple = parseInt(paperUnitForm.publicSimple);
- paperUnitForm.publicMedium = parseInt(paperUnitForm.publicMedium);
- paperUnitForm.publicDifficulty = parseInt(
- paperUnitForm.publicDifficulty
- );
- paperUnitForm.noPublicSimple = parseInt(paperUnitForm.noPublicSimple);
- paperUnitForm.noPublicMedium = parseInt(paperUnitForm.noPublicMedium);
- paperUnitForm.noPublicDifficulty = parseInt(
- paperUnitForm.noPublicDifficulty
- );
- //公开总数
- paperUnitForm.publicSum =
- parseInt(paperUnitForm.publicSimple) +
- parseInt(paperUnitForm.publicMedium) +
- parseInt(paperUnitForm.publicDifficulty);
- //非公开总数
- paperUnitForm.noPublicSum =
- parseInt(paperUnitForm.noPublicSimple) +
- parseInt(paperUnitForm.noPublicMedium) +
- parseInt(paperUnitForm.noPublicDifficulty);
- //简单总数
- paperUnitForm.simpleSum =
- parseInt(paperUnitForm.publicSimple) +
- parseInt(paperUnitForm.noPublicSimple);
- //中等总数
- paperUnitForm.mediumSum =
- parseInt(paperUnitForm.publicMedium) +
- parseInt(paperUnitForm.noPublicMedium);
- //困难总数
- paperUnitForm.difficultySum =
- parseInt(paperUnitForm.publicDifficulty) +
- parseInt(paperUnitForm.noPublicDifficulty);
- //总数
- paperUnitForm.count =
- paperUnitForm.publicSum + paperUnitForm.noPublicSum;
- //分数
- paperUnitForm.totalScore = paperUnitForm.count * paperUnitForm.score;
- }, 5);
- }
- },
- computed: {
- totalScore() {
- var sum = 0.0;
- for (let unitStruct of this.unitStructs) {
- sum += unitStruct.totalScore;
- }
- return sum;
- },
- detailCount() {
- var count = 0.0;
- for (let unitStruct of this.unitStructs) {
- count += unitStruct.count;
- }
- return count;
- },
- quesNames() {
- var quesNames = [];
- for (let quesName of this.quesNameList) {
- quesNames.push(quesName.code);
- }
- return quesNames;
- }
- },
- //初始化查询
- created() {
- this.paperStructId = this.$route.params.id;
- this.detailName = this.$route.params.name;
- this.detailId = this.$route.params.detailId;
- this.courseNo = this.$route.params.courseNo;
- this.searchForm();
- }
- };
- </script>
- <style scoped>
- .el-row {
- margin-bottom: 20px;
- }
- .el-col {
- border-radius: 4px;
- }
- .bg-purple-dark {
- background: #dcdfe6;
- }
- .bg-purple {
- background: #dcdfe6;
- }
- .bg-purple-light {
- background: #f9fafc;
- }
- .grid-content {
- border-radius: 4px;
- min-height: 36px;
- }
- .row-bg {
- padding: 10px 0;
- background-color: #f9fafc;
- }
- </style>
|