|
@@ -1,32 +1,32 @@
|
|
|
<template>
|
|
|
- <div class="pb_content" style="background: #F0F2F5;" v-loading="loading">
|
|
|
+ <div class="pb_content" style="background: #F0F2F5;" v-loading="loading || isloading">
|
|
|
<div class="pb_content_body" style="position: relative; margin: 0">
|
|
|
<div class="right">
|
|
|
<div class="courseTop">
|
|
|
<div class="stepsNav">
|
|
|
<el-breadcrumb separator-class="el-icon-arrow-right">
|
|
|
<el-breadcrumb-item :to="{
|
|
|
- path:
|
|
|
- '/testPerson?userid=' +
|
|
|
- userid +
|
|
|
- '&oid=' +
|
|
|
- oid +
|
|
|
- '&org=' +
|
|
|
- org +
|
|
|
- '&role=' +
|
|
|
- role,
|
|
|
- }" v-if="type == 3">个人中心</el-breadcrumb-item>
|
|
|
+ path:
|
|
|
+ '/testPerson?userid=' +
|
|
|
+ userid +
|
|
|
+ '&oid=' +
|
|
|
+ oid +
|
|
|
+ '&org=' +
|
|
|
+ org +
|
|
|
+ '&role=' +
|
|
|
+ role,
|
|
|
+ }" v-if="type == 3">个人中心</el-breadcrumb-item>
|
|
|
<el-breadcrumb-item :to="{
|
|
|
- path:
|
|
|
- '/testStudent?userid=' +
|
|
|
- userid +
|
|
|
- '&oid=' +
|
|
|
- oid +
|
|
|
- '&org=' +
|
|
|
- org +
|
|
|
- '&role=' +
|
|
|
- role,
|
|
|
- }" v-else>表单中心</el-breadcrumb-item>
|
|
|
+ path:
|
|
|
+ '/testStudent?userid=' +
|
|
|
+ userid +
|
|
|
+ '&oid=' +
|
|
|
+ oid +
|
|
|
+ '&org=' +
|
|
|
+ org +
|
|
|
+ '&role=' +
|
|
|
+ role,
|
|
|
+ }" v-else>表单中心</el-breadcrumb-item>
|
|
|
<el-breadcrumb-item>
|
|
|
<span style="color: rgb(15, 126, 255)">{{ title }}</span>
|
|
|
</el-breadcrumb-item>
|
|
@@ -38,12 +38,13 @@
|
|
|
<div class="edit_top">
|
|
|
<div class="op_btn">
|
|
|
<el-button type="primary" size="small" @click="refresh" v-if="isReset">刷新</el-button>
|
|
|
- <el-button type="primary" size="small" @click="reset" >重置</el-button>
|
|
|
+ <el-button type="primary" size="small" @click="reset">重置</el-button>
|
|
|
<el-button type="primary" size="small" @click="save" v-if="type != 3">保存</el-button>
|
|
|
<el-button type="primary" size="small" @click="publish">提交</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <topicVue :cJson="cJson" :title="title" :brief="brief" ref="topicVue" v-if="!loading"></topicVue>
|
|
|
+ <topicVue :cJson.sync="cJson" :title="title" :brief="brief" ref="topicVue" v-if="!loading"
|
|
|
+ @getTestWorkByCid="getTestWorkByCid" @publish2="publish2"></topicVue>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -65,6 +66,7 @@ export default {
|
|
|
cid: this.$route.query.cid,
|
|
|
tid: this.$route.query.tid,
|
|
|
type: this.$route.query.type,
|
|
|
+ updateType: this.$route.query.type,
|
|
|
steps: 1,
|
|
|
title: "",
|
|
|
brief: "",
|
|
@@ -75,6 +77,8 @@ export default {
|
|
|
loading: false,
|
|
|
look: "",
|
|
|
isReset: false,
|
|
|
+ isloading: false,
|
|
|
+ courseid: ''
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
@@ -87,7 +91,7 @@ export default {
|
|
|
type: "warning",
|
|
|
})
|
|
|
.then(() => {
|
|
|
- if(this.type == 3){
|
|
|
+ if (this.type == 3) {
|
|
|
this.goTo(
|
|
|
"/testPerson?userid=" +
|
|
|
this.userid +
|
|
@@ -98,7 +102,7 @@ export default {
|
|
|
"&role=" +
|
|
|
this.role
|
|
|
);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
this.goTo(
|
|
|
"/testStudent?userid=" +
|
|
|
this.userid +
|
|
@@ -126,13 +130,21 @@ export default {
|
|
|
type: "warning",
|
|
|
})
|
|
|
.then(() => {
|
|
|
- this.cJson = JSON.parse(JSON.stringify(this.cJson2));
|
|
|
- this.loading = true
|
|
|
- this.isReset = false
|
|
|
- setTimeout(() => {
|
|
|
- this.loading = false
|
|
|
- }, 0);
|
|
|
- this.$forceUpdate()
|
|
|
+ if(this.tid){
|
|
|
+ this.deleteTest(this.tid)
|
|
|
+ }else{
|
|
|
+ if(this.courseid){
|
|
|
+ this.cJson = this.setCourseid(JSON.parse(JSON.stringify(this.cJson2)));
|
|
|
+ }else{
|
|
|
+ this.cJson = JSON.parse(JSON.stringify(this.cJson2));
|
|
|
+ }
|
|
|
+ this.loading = true
|
|
|
+ this.isReset = false
|
|
|
+ setTimeout(() => {
|
|
|
+ this.loading = false
|
|
|
+ }, 0);
|
|
|
+ this.$forceUpdate()
|
|
|
+ }
|
|
|
})
|
|
|
.catch(() => {
|
|
|
|
|
@@ -146,13 +158,21 @@ export default {
|
|
|
type: "warning",
|
|
|
})
|
|
|
.then(() => {
|
|
|
- this.cJson = JSON.parse(JSON.stringify(this.cJson2));
|
|
|
- this.loading = true
|
|
|
- this.isReset = false
|
|
|
- setTimeout(() => {
|
|
|
- this.loading = false
|
|
|
- }, 0);
|
|
|
- this.$forceUpdate()
|
|
|
+ if(this.tid){
|
|
|
+ this.deleteTest(this.tid)
|
|
|
+ }else{
|
|
|
+ if(this.courseid){
|
|
|
+ this.cJson = this.setCourseid(JSON.parse(JSON.stringify(this.cJson2)));
|
|
|
+ }else{
|
|
|
+ this.cJson = JSON.parse(JSON.stringify(this.cJson2));
|
|
|
+ }
|
|
|
+ this.loading = true
|
|
|
+ this.isReset = false
|
|
|
+ setTimeout(() => {
|
|
|
+ this.loading = false
|
|
|
+ }, 0);
|
|
|
+ this.$forceUpdate()
|
|
|
+ }
|
|
|
})
|
|
|
.catch(() => {
|
|
|
|
|
@@ -222,6 +242,81 @@ export default {
|
|
|
console.error(err);
|
|
|
});
|
|
|
},
|
|
|
+ getTestWorkByCid(courseid) {
|
|
|
+ this.isloading = true
|
|
|
+ this.courseid = courseid
|
|
|
+ let params = {
|
|
|
+ cid: this.cid,
|
|
|
+ uid: this.userid,
|
|
|
+ };
|
|
|
+ let _courseid = courseid
|
|
|
+ this.ajax
|
|
|
+ .get(this.$store.state.api + "selectTestWorksCid", params)
|
|
|
+ .then((res) => {
|
|
|
+ if (res.data[0].length) {
|
|
|
+ console.log(res.data[0]);
|
|
|
+ let rData = res.data[0]
|
|
|
+ this.tid = ''
|
|
|
+ aa: for (var i = 0; i < rData.length; i++) {
|
|
|
+ let rDataJson = this.JSONSetting(JSON.parse(rData[i].courseJson))
|
|
|
+ let _json = JSON.parse(rData[i].courseJson)
|
|
|
+ for (var j = 0; j < rDataJson.length; j++) {
|
|
|
+ let _param = rDataJson[j]
|
|
|
+ if (_param.type == 6 && _param.json.answer2 && _param.json.answer2 == _courseid) {
|
|
|
+ console.log(_json);
|
|
|
+ this.cJson = _json
|
|
|
+ let cJson = this.setJSON(JSON.parse(JSON.stringify(this.cJson)))
|
|
|
+ let cJson2 = this.setJSON(this.setJson2(JSON.parse(JSON.stringify(this.cJson2))))
|
|
|
+ if (JSON.stringify(cJson) != JSON.stringify(cJson2)) {
|
|
|
+ this.isReset = true
|
|
|
+ }
|
|
|
+ this.tid = rData[i].id
|
|
|
+ this.$forceUpdate()
|
|
|
+ break aa;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!this.tid) {
|
|
|
+ this.cJson = this.setJSON(this.setCourseid(JSON.parse(JSON.stringify(this.cJson2))))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$forceUpdate()
|
|
|
+ this.isloading = false
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ this.isloading = false
|
|
|
+ console.error(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ JSONSetting(json) {
|
|
|
+ let _json = json
|
|
|
+ let array = []
|
|
|
+ _json.filter((item) => {
|
|
|
+ if (item.array) {
|
|
|
+ item.array = item.array.filter((item2) => {
|
|
|
+ if (item2.ttype == 1 && item2.json) {
|
|
|
+ array.push(item2)
|
|
|
+ }
|
|
|
+ if (item2.array) {
|
|
|
+ item2.array = item2.array.filter((item3) => {
|
|
|
+ if (item3.ttype == 1 && item3.json) {
|
|
|
+ array.push(item3)
|
|
|
+ }
|
|
|
+ return item3;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return item2;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (item.ttype == 1 && item.json) {
|
|
|
+ array.push(item)
|
|
|
+ }
|
|
|
+ console.log(item.array);
|
|
|
+ return item;
|
|
|
+ });
|
|
|
+ console.log(array);
|
|
|
+ return array;
|
|
|
+ },
|
|
|
setJSON(json) {
|
|
|
return json.filter((item) => {
|
|
|
if (item.array) {
|
|
@@ -283,6 +378,44 @@ export default {
|
|
|
console.log(checkArray);
|
|
|
return checkArray;
|
|
|
|
|
|
+ },
|
|
|
+ setCourseid(json) {
|
|
|
+ let _json = json;
|
|
|
+ // this.type = _json[0].ttype;
|
|
|
+ let checkArray = _json.filter((item) => {
|
|
|
+ if (item.array) {
|
|
|
+ item.array = item.array.filter((item2) => {
|
|
|
+ if (item2.ttype == 1 && item2.json && !item2.json.answer2 && item2.type != 6) {
|
|
|
+ item2.json.answer2 = [];
|
|
|
+ }else if(item2.type == 6){
|
|
|
+ item2.json.answer2 = this.courseid ? this.courseid : '';
|
|
|
+ }
|
|
|
+ if (item2.array) {
|
|
|
+ item2.array = item2.array.filter((item3) => {
|
|
|
+ if (item3.ttype == 1 && item3.json && !item3.json.answer2 && item3.type != 6) {
|
|
|
+ item3.json.answer2 = [];
|
|
|
+ }else if(item3.type == 6){
|
|
|
+ item3.json.answer2 = this.courseid ? this.courseid : '';
|
|
|
+ }
|
|
|
+ return item3;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return (
|
|
|
+ (item2.ttype != 1 && item2.array.length > 0) || item2.ttype == 1
|
|
|
+ );
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (item.ttype == 1 && item.json && !item.json.answer2 && item.type != 6) {
|
|
|
+ item.json.answer2 = [];
|
|
|
+ }else if(item.type == 6){
|
|
|
+ item.json.answer2 = this.courseid ? this.courseid : '';
|
|
|
+ }
|
|
|
+ console.log(item.array);
|
|
|
+ return (item.ttype != 1 && item.array.length > 0) || item.ttype == 1;
|
|
|
+ });
|
|
|
+ console.log(checkArray);
|
|
|
+ return checkArray;
|
|
|
+
|
|
|
},
|
|
|
getData() {
|
|
|
this.loading = true
|
|
@@ -306,9 +439,9 @@ export default {
|
|
|
}
|
|
|
console.log(this.testType);
|
|
|
this.look = res.data[0][0].look
|
|
|
- if(this.type == 3){
|
|
|
+ if (this.type == 3) {
|
|
|
this.getTestWorks2()
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
this.getTestWorks()
|
|
|
}
|
|
|
this.$forceUpdate();
|
|
@@ -355,17 +488,17 @@ export default {
|
|
|
console.log(cjson);
|
|
|
let params = [
|
|
|
{
|
|
|
- uid: (this.type == 3 && this.tid) ? this.tid : this.userid,
|
|
|
+ uid: (this.tid) ? this.tid : this.userid,
|
|
|
cid: this.cid,
|
|
|
cjson: encodeURIComponent(JSON.stringify(cjson)),
|
|
|
type: '2',
|
|
|
},
|
|
|
];
|
|
|
this.ajax
|
|
|
- .post(this.$store.state.api + ((this.type == 3&& this.tid) ? "addTestWorks2" : "addTestWorks"), params)
|
|
|
+ .post(this.$store.state.api + ((this.tid) ? "addTestWorks2" : "addTestWorks"), params)
|
|
|
.then((res) => {
|
|
|
this.$message.success('提交成功')
|
|
|
- if(this.type == 3){
|
|
|
+ if (this.type == 3) {
|
|
|
this.goTo(
|
|
|
"/testPerson?userid=" +
|
|
|
this.userid +
|
|
@@ -376,7 +509,7 @@ export default {
|
|
|
"&role=" +
|
|
|
this.role
|
|
|
);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
this.goTo(
|
|
|
"/testStudent?userid=" +
|
|
|
this.userid +
|
|
@@ -394,7 +527,48 @@ export default {
|
|
|
console.error(err);
|
|
|
});
|
|
|
},
|
|
|
-
|
|
|
+ publish2() {
|
|
|
+ this.isloading = true
|
|
|
+ let cjson = this.$refs['topicVue'].checkArray
|
|
|
+ console.log(cjson);
|
|
|
+ let params = [
|
|
|
+ {
|
|
|
+ uid: (this.tid) ? this.tid : this.userid,
|
|
|
+ cid: this.cid,
|
|
|
+ cjson: encodeURIComponent(JSON.stringify(cjson)),
|
|
|
+ type: '2',
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ this.ajax
|
|
|
+ .post(this.$store.state.api + ((this.tid) ? "addTestWorks2" : "addTestWorks"), params)
|
|
|
+ .then((res) => {
|
|
|
+ this.$message.success('保存成功')
|
|
|
+ setTimeout(() => {
|
|
|
+ this.isloading = false
|
|
|
+ }, 500);
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ this.$message.error("网络不佳");
|
|
|
+ this.isloading = false
|
|
|
+ console.error(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ deleteTest(tid) {
|
|
|
+ let _this = this;
|
|
|
+ let params = [
|
|
|
+ {
|
|
|
+ tid: tid
|
|
|
+ }
|
|
|
+ ];
|
|
|
+ _this.ajax
|
|
|
+ .post(_this.$store.state.api + "deleteTestCourseWorks", params)
|
|
|
+ .then(res => {
|
|
|
+ this.getTestWorkByCid(this.courseid)
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.error(err);
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
mounted() {
|
|
|
this.getData();
|