99 <el-form label-position =" left" label-width =" 80px" class =" m-publish-exam" >
1010 <publish-client v-model =" primary.client" ></publish-client >
1111 <el-form-item label =" 状态" class =" m-publish-exam-common" >
12- <el-radio-group v-model =" primary.status " >
13- <el-radio value =" " >公开</el-radio >
14- <el-radio :value =" PRIVATE_STATUS " >私有</el-radio >
12+ <el-radio-group v-model =" primary.is_public " >
13+ <el-radio : value =" PUBLIC_VALUE " >公开</el-radio >
14+ <el-radio :value =" PRIVATE_VALUE " >私有</el-radio >
1515 </el-radio-group >
1616 </el-form-item >
1717 <el-form-item label =" 题目" class =" m-publish-exam-title" >
@@ -90,12 +90,13 @@ import User from "@jx3box/jx3box-common/js/user";
9090import { getQuestion , createQuestion , updateQuestion } from " @/service/publish/exam" ;
9191import { getLink } from " @jx3box/jx3box-common/js/utils" ;
9292const DEFAULT_CLIENT = " std" ;
93- const PRIVATE_STATUS = 2 ;
93+ const PUBLIC_VALUE = 1 ;
94+ const PRIVATE_VALUE = 0 ;
9495
9596function getDefaultPrimary () {
9697 return {
9798 client: DEFAULT_CLIENT ,
98- status : " " ,
99+ is_public : PUBLIC_VALUE ,
99100 title: " " ,
100101 type: " radio" ,
101102 options: [" " , " " , " " , " " ],
@@ -107,24 +108,15 @@ function getDefaultPrimary() {
107108 };
108109}
109110
110- function getFormStatus ( status ) {
111- return Number (status ) === PRIVATE_STATUS ? PRIVATE_STATUS : " " ;
111+ function getFormPublic ( isPublic ) {
112+ return Number (isPublic ) === PRIVATE_VALUE ? PRIVATE_VALUE : PUBLIC_VALUE ;
112113}
113114
114- function hasStatus (status ) {
115- return status !== " " && status !== undefined && status !== null ;
116- }
117-
118- function getSubmitData (primary , originalStatus ) {
115+ function getSubmitData (primary ) {
119116 const data = { ... primary };
120117 data .client = data .client || DEFAULT_CLIENT ;
121- if (Number (data .status ) === PRIVATE_STATUS ) {
122- data .status = PRIVATE_STATUS ;
123- } else if (hasStatus (originalStatus)) {
124- data .status = originalStatus;
125- } else {
126- delete data .status ;
127- }
118+ data .is_public = getFormPublic (data .is_public );
119+ delete data .status ;
128120 return data;
129121}
130122
@@ -134,8 +126,8 @@ export default {
134126 data : function () {
135127 return {
136128 primary: getDefaultPrimary (),
137- PRIVATE_STATUS ,
138- originalStatus : " " ,
129+ PUBLIC_VALUE ,
130+ PRIVATE_VALUE ,
139131 processing: false ,
140132 loading: false ,
141133
@@ -167,7 +159,7 @@ export default {
167159 methods: {
168160 publish : function () {
169161 this .processing = true ;
170- const data = getSubmitData (this .primary , this . id ? this . originalStatus : undefined );
162+ const data = getSubmitData (this .primary );
171163 const request = this .id ? updateQuestion (this .id , data) : createQuestion (data);
172164 request
173165 .then ((res ) => {
@@ -192,12 +184,11 @@ export default {
192184 getQuestion (this .id )
193185 .then ((res ) => {
194186 let data = res .data ;
195- this .originalStatus = data .status ;
196187 this .primary = {
197188 ... getDefaultPrimary (),
198189 ... data,
199190 client: data .client || DEFAULT_CLIENT ,
200- status : getFormStatus (data .status ),
191+ is_public : getFormPublic (data .is_public ),
201192 };
202193 this .primary .options = data .options ? JSON .parse (data .options ) : [" " , " " , " " , " " ];
203194 this .primary .tags = data .tags ? JSON .parse (data .tags ) : [];
0 commit comments