123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495 |
- <template>
- <div class="mc_box">
- <div class="mc_addBox">
- <div class="mc_addBox_add">
- <div class="title">请添加题目类型与数量</div>
- <div class="select">
- <el-select
- v-model="topicType"
- placeholder="题目类型"
- clearable
- class="e-select"
- >
- <el-option
- v-for="item in options"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- <el-input
- v-model="number"
- placeholder="请输入题目数量"
- size="normal"
- clearable
- @change="numberPan"
- class="e-input"
- ></el-input>
- <img
- src="@/assets/icon/new/addStage.png"
- class="e-img"
- @click="addCheck"
- />
- </div>
- </div>
- <div class="mc_addBox_add">
- <div class="title">请添加试卷组件</div>
- <div class="btnBox">
- <!-- <el-button type="primary" size="mini" v-for="item in buttonOptions" :key="item.type" class="e-button"
- @click="addQtype(item.type)">{{ item.name }}</el-button> -->
- <button
- v-for="item in buttonOptions"
- :key="item.type"
- class="pub_test_btn"
- :class="{
- pub_test_btn_group: item.type == 1,
- pub_test_btn_page: item.type == 2,
- }"
- @click="addQtype(item.type)"
- >
- {{ item.name }}
- </button>
- </div>
- </div>
- <div class="mc_addBox_add">
- <div class="title">智能创建</div>
- <div class="btnBox">
- <aiCreate2 :aiJson="manualJson" @changeJson="changeJson"></aiCreate2>
- </div>
- </div>
- </div>
- <div class="mc_checkBox">
- <checkOrder
- :checkC.sync="checkC"
- :checkJson="checkJson"
- @changeJson="changeJson"
- ></checkOrder>
- <div class="e_btn">
- <el-button type="primary" size="mini" @click="nextSteps()"
- >下一步</el-button
- >
- </div>
- </div>
- </div>
- </template>
- <script>
- import checkOrder from "../components/checkOrder.vue";
- import aiCreate2 from "./aiCreate2.vue";
- import minxinVue from "../minxins/minxin";
- export default {
- mixins: [minxinVue],
- components: {
- checkOrder,
- aiCreate2,
- },
- props: {
- manualJson: {
- type: Array,
- },
- },
- data() {
- return {
- topicType: "",
- number: "",
- checkJson: [
- // {
- // ttype: 1, //题目分类 1普通题目 2分组 3分页
- // type: 1, //题型分类 1选择题, 3问答题 4添加文档
- // array:[] //题目
- // }
- ],
- checkC: "",
- };
- },
- watch: {
- manualJson: {
- handler: function (newVal, oldVal) {
- this.checkJson = this.depthCopy(newVal);
- },
- deep: true,
- },
- },
- methods: {
- numberPan() {
- if (/[^\d]/.test(this.number)) {
- this.$message.error("请填写数字");
- this.number = "";
- }
- },
- changeJson(json) {
- this.checkJson = json;
- this.$emit("update:manualJson", json);
- },
- addCheck() {
- if (!this.topicType) {
- this.$message.error("请选择题目类型");
- return;
- }
- if (!this.number) {
- this.$message.error("请填写题目数量");
- return;
- }
- let type = 1;
- if (this.checkJson.length > 0) {
- for (var i = 0; i < this.checkJson.length; i++) {
- if (this.checkJson[i].ttype == 2) {
- type = 2;
- } else if (this.checkJson[i].ttype == 3) {
- type = 3;
- }
- }
- }
- if (this.checkC) {
- let _check = this.checkC.replace("x", "").split("-");
- let _json = this.checkJson[_check[0]];
- let json = {
- ttype: 1,
- type: this.topicType,
- };
- if (this.topicType == 1) {
- json.json = {
- title: "标题",
- type: 1,
- array: [
- { option: "选项1", img: "" },
- { option: "选项2", img: "" },
- ],
- answer: "",
- };
- } else if (this.topicType == 3) {
- json.json = {
- title: "标题",
- type: 1,
- answer: "",
- };
- } else if (this.topicType == 5) {
- json.json = {
- title: "标题",
- type: 1,
- detail: "",
- };
- } else if (this.topicType == 6) {
- json.json = {
- title: "标题",
- detail: "",
- courses:[]
- };
- } else if (this.topicType == 7) {
- json.json = {
- title: "标题",
- detail: "",
- small: 0,
- big: 10,
- };
- }
- if (_json.array) {
- if (type == 3 && _check.length == 2) {
- if (this.checkJson[_check[0]].array[_check[1]].array) {
- for (var i = 0; i < this.number; i++) {
- this.checkJson[_check[0]].array[_check[1]].array.push(json);
- }
- } else {
- for (var i = 0; i < this.number; i++) {
- this.checkJson[_check[0]].array.splice(
- parseInt(_check[1]) + 1,
- 0,
- json
- );
- }
- }
- } else if (type == 3 && _check.length == 3) {
- for (var i = 0; i < this.number; i++) {
- this.checkJson[_check[0]].array[_check[1]].array.splice(
- parseInt(_check[2]) + 1,
- 0,
- json
- );
- }
- } else if (type == 2 && _check.length == 2) {
- for (var i = 0; i < this.number; i++) {
- this.checkJson[_check[0]].array.splice(
- parseInt(_check[1]) + 1,
- 0,
- json
- );
- }
- } else if (type == 2 && _check.length == 1) {
- for (var i = 0; i < this.number; i++) {
- this.checkJson[_check[0]].array.push(json);
- }
- } else if (type == 3 && _check.length == 1) {
- if (
- this.checkJson[_check[0]].array[0] &&
- this.checkJson[_check[0]].array[0].array
- ) {
- for (var i = 0; i < this.number; i++) {
- this.checkJson[_check[0]].array[0].array.push(json);
- }
- } else {
- for (var i = 0; i < this.number; i++) {
- this.checkJson[_check[0]].array.push(json);
- }
- }
- }
- } else {
- for (var i = 0; i < this.number; i++) {
- this.checkJson.splice(parseInt(_check[0]) + 1, 0, json);
- }
- }
- } else {
- if (type == 1) {
- for (var i = 0; i < this.number; i++) {
- let json1 = {
- ttype: 1,
- type: this.topicType,
- };
- if (this.topicType == 1) {
- json1.json = {
- title: "标题",
- type: 1,
- array: [
- { option: "选项1", img: "" },
- { option: "选项2", img: "" },
- ],
- answer: "",
- };
- } else if (this.topicType == 3) {
- json1.json = {
- title: "标题",
- type: 1,
- answer: "",
- };
- } else if (this.topicType == 5) {
- json1.json = {
- title: "标题",
- type: 1,
- detail: "",
- };
- } else if (this.topicType == 6) {
- json1.json = {
- title: "标题",
- detail: "",
- courses:[]
- };
- } else if (this.topicType == 7) {
- json1.json = {
- title: "标题",
- detail: "",
- small: 0,
- big: 10,
- };
- }
- this.checkJson.push(json1);
- }
- } else if (type == 3 || type == 2) {
- this.$message.error("请选中分页或者分组添加题目");
- return;
- }
- }
- this.topicType = "";
- this.number = "";
- this.$emit("update:manualJson", this.checkJson);
- },
- addQtype(type) {
- if (type == 1) {
- let type = 1;
- if (this.checkJson.length > 0) {
- for (var i = 0; i < this.checkJson.length; i++) {
- if (this.checkJson[i].ttype == 1) {
- type = 2;
- } else if (this.checkJson[i].ttype == 3) {
- type = 3;
- }
- }
- }
- let json = {
- ttype: 2,
- array: [],
- isopen: true,
- };
- if (type == 1) {
- if (this.checkC) {
- let _check = this.checkC.replace("x", "").split("-");
- this.checkJson.splice(parseInt(_check[0]) + 1, 0, json);
- } else {
- this.checkJson.push(json);
- }
- } else if (type == 2) {
- this.checkJson = [
- {
- ttype: 2,
- array: this.depthCopy(this.checkJson),
- isopen: true,
- },
- ];
- } else if (type == 3) {
- if (this.checkC) {
- let _check = this.checkC.replace("x", "").split("-");
- if (
- _check.length > 1 &&
- this.checkJson[_check[0]].array[0] &&
- this.checkJson[_check[0]].array[0].array
- ) {
- this.checkJson[_check[0]].array.splice(
- parseInt(_check[1]) + 1,
- 0,
- json
- );
- } else if (
- this.checkJson[_check[0]].array[0] &&
- !this.checkJson[_check[0]].array[0].array
- ) {
- this.checkJson[_check[0]].array = [
- {
- ttype: 2,
- array: this.depthCopy(this.checkJson[_check[0]].array),
- isopen: true,
- },
- ];
- } else {
- this.checkJson[_check[0]].array.push(json);
- }
- } else {
- this.$message.error("请选中分页添加分组");
- return;
- }
- }
- } else if (type == 2) {
- let type = 1;
- if (this.checkJson.length > 0) {
- for (var i = 0; i < this.checkJson.length; i++) {
- if (this.checkJson[i].ttype == 1 || this.checkJson[i].ttype == 2) {
- type = 2;
- }
- }
- }
- if (type == 1) {
- let json = {
- ttype: 3,
- array: [],
- isopen: true,
- };
- if (this.checkC) {
- let _check = this.checkC.replace("x", "").split("-");
- this.checkJson.splice(parseInt(_check[0]) + 1, 0, json);
- } else {
- this.checkJson.push(json);
- }
- } else {
- this.checkJson = [
- {
- ttype: 3,
- array: this.depthCopy(this.checkJson),
- isopen: true,
- },
- ];
- }
- }
- this.$emit("update:manualJson", this.checkJson);
- },
- depthCopy(s) {
- return JSON.parse(JSON.stringify(s));
- },
- nextSteps() {
- this.$emit("nextSteps");
- },
- },
- mounted() {
- this.checkJson = this.depthCopy(this.manualJson);
- this.$forceUpdate();
- },
- };
- </script>
- <style scoped>
- .mc_box {
- width: 90%;
- margin: 10px auto;
- display: flex;
- }
- .mc_addBox {
- width: 400px;
- border: 1px solid #898989;
- border-radius: 8px;
- padding: 20px 20px;
- box-sizing: border-box;
- min-height: 350px;
- height: fit-content;
- }
- .mc_addBox_add {
- }
- .mc_addBox_add + .mc_addBox_add {
- margin-top: 10px;
- }
- .mc_addBox_add .title {
- margin-bottom: 10px;
- font-size: 15px;
- font-weight: 700;
- display: flex;
- align-items: center;
- }
- .mc_addBox_add .title::before {
- content: "";
- width: 10px;
- height: 10px;
- border-radius: 50%;
- background: rgb(54, 129, 252);
- margin-right: 10px;
- display: block;
- }
- .mc_addBox_add .select {
- display: flex;
- align-items: center;
- }
- .mc_addBox_add .btnBox {
- display: flex;
- flex-wrap: wrap;
- }
- .mc_addBox_add .select .e-select {
- }
- .mc_addBox_add .select .e-input {
- margin-left: 10px;
- }
- .mc_addBox_add .select .e-img {
- cursor: pointer;
- width: 20px;
- margin-left: 10px;
- }
- .mc_addBox_add .btnBox .e-button {
- }
- .mc_checkBox {
- width: calc(100% - 420px);
- margin-left: 20px;
- border: 1px solid #898989;
- border-radius: 8px;
- padding: 20px;
- box-sizing: border-box;
- display: flex;
- flex-direction: column;
- }
- .e_btn {
- width: 100%;
- margin-top: auto;
- display: flex;
- justify-content: center;
- }
- </style>
|