text: webpackJsonp([4],{VZYi:function(t,e){},yTGp:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n("lC5x"),i=n.n(o),r=n("J0Oq"),s=n.n(r),a=n("c2Ch"),c=n("0aFO"),u={data:function(){return{loading:!0,flag:!0,form:{}}},methods:{getNaire:function(t){var e=this;return s()(i.a.mark(function n(){return i.a.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Object(a.c)("/naire/"+t).then(function(t){console.log(t),e.form=t,e.loading=!1});case 2:case"end":return n.stop()}},n,e)}))()},submitForm:function(){var t=this;this.validate(this.form)&&Object(a.e)("naire/edit",this.form).then(function(e){return 0===e.error_code?(Object(c.b)(e.msg),void t.$router.push("/home/list")):void Object(c.a)(e.msg)})},addQuestion:function(){this.form.questions.push({q_content:"",q_type:"单选",option:[{o_value:"选项一"}]})},delQuestion:function(t){var e=this;return s()(i.a.mark(function n(){var o;return i.a.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(1!=e.form.questions.length){n.next=2;break}return n.abrupt("return",Object(c.c)("已经是最后一题啦"));case 2:o=e.form.questions[t].id,e.form.questions[t].id?e.$confirm("此操作将永久删除该问题, 是否继续?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(s()(i.a.mark(function n(){var r;return i.a.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Object(a.a)("question/"+o);case 2:r=n.sent,console.log(r.data),e.form.questions.splice(t,1),0===r.data.error_code&&Object(c.b)("删除成功");case 6:case"end":return n.stop()}},n,e)}))):e.form.questions.splice(t,1);case 4:case"end":return n.stop()}},n,e)}))()},addMultiplyQuestion:function(){this.form.questions.push({q_content:"",q_type:"多选",option:[{o_value:"选项一"}]})},addOption:function(t){if(this.form.questions[t].option.length>=7)return Object(c.c)("一题最多添加7个选项噢");this.form.questions[t].option.push({o_value:"1"})},delOption:function(t,e){var n=this;return s()(i.a.mark(function o(){var r;return i.a.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(1!=n.form.questions[t].option.length){o.next=2;break}return o.abrupt("return",Object(c.c)("已经是最后一个啦"));case 2:r=n.form.questions[t].option[e].id,n.form.questions[t].option[e].id?n.$confirm("此操作将永久删除该选项, 是否继续?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(s()(i.a.mark(function o(){return i.a.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,Object(a.a)("option/"+r).then(function(o){0===o.error_code&&Object(c.b)("删除成功"),n.form.questions[t].option.splice(e,1)});case 2:case"end":return o.stop()}},o,n)}))):n.form.questions[t].option.splice(e,1);case 4:case"end":return o.stop()}},o,n)}))()},validate:function(t){var e=!0;return t&&t.n_title?(this.form.n_title=this.form.n_title.trim(),t.n_title.length<5?(Object(c.a)("问卷标题不少于五个字"),!1):(t.questions.forEach(function(t,n){""!=t.q_content&&t.q_content||(Object(c.a)("请完整填写"),e=!1),t.option.forEach(function(t,n){""!=t.o_value&&t.o_value||(Object(c.a)("请完整填写"),e=!1)})}),e)):(Object(c.a)("请完整填写"),!1)},back:function(){this.$router.back()}},created:function(){var t=this;return s()(i.a.mark(function e(){return i.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t.getNaire(t.$route.params.id);case 1:case"end":return e.stop()}},e,t)}))()}},l={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{directives:[{name:"loading",rawName:"v-loading",value:t.loading,expression:"loading"}],staticClass:"container"},[t._m(0),t._v(" "),n("el-form",{ref:"form",attrs:{model:t.form,"label-width":"80px"}},[n("el-form-item",{attrs:{label:"问卷标题"}},[n("el-input",{attrs:{maxlength:"30","show-word-limit":""},model:{value:t.form.n_title,callback:function(e){t.$set(t.form,"n_title",e)},expression:"form.n_title"}})],1)],1),t._v(" "),n("div",{staticClass:"button-group"},[n("el-button",{attrs:{type:"primary",size:"small"},on:{click:t.addQuestion}},[t._v("单选题 + ")]),t._v(" "),n("el-button",{attrs:{type:"primary",size:"small"},on:{click:t.addMultiplyQuestion}},[t._v("多选题 + ")])],1),t._v(" "),n("div",{staticClass:"question-wrap single-box"},t._l(t.form.questions,function(e,o){return n("div",[n("div",{staticClass:"question"},["单选"==e.q_type?n("el-form",{ref:"form",refInFor:!0,attrs:{model:t.form,"label-width":"80px",size:"medium"}},[n("el-form-item",{attrs:{label:"单选题 "+(o+1)}},[n("el-input",{attrs:{maxlength:"30","show-word-limit":""},model:{value:t.form.questions[o].q_content,callback:function(e){t.$set(t.form.questions[o],"q_content",e)},expression:"form.questions[qindex].q_content"}}),t._v(" "),n("el-button",{attrs:{type:"primary",icon:"el-icon-plus",circle:""},on:{click:function(e){return t.addOption(o)}}}),t._v(" "),n("el-button",{attrs:{type:"danger",icon:"el-icon-delete",circle:""},on:{click:function(e){return t.delQuestion(o)}}})],1),t._v(" "),t._l(t.form.questions[o].option,function(e,i){return[n("el-form-item",{attrs:{label:"选项"+(i+1)}},[n("el-input",{attrs:{maxlength:"15","show-word-limit":""},model:{value:t.form.questions[o].option[i].o_value,callback:function(e){t.$set(t.form.questions[o].option[i],"o_value",e)},expression:"form.questions[qindex].option[oindex].o_value"}}),t._v(" "),n("el-button",{attrs:{type:"danger",icon:"el-icon-delete",circle:""},on:{click:function(e){return t.delOption(o,i)}}})],1)]})],2):t._e(),t._v(" "),"多选"==e.q_type?n("el-form",{ref:"form",refInFor:!0,attrs:{model:t.form,"label-width":"80px",size:"medium"}},[n("el-form-item",{attrs:{label:"多选题 "+(o+1)}},[n("el-input",{attrs:{maxlength:"30","show-word-limit":""},model:{value:t.form.questions[o].q_content,callback:function(e){t.$set(t.form.questions[o],"q_content",e)},expression:"form.questions[qindex].q_content"}}),t._v(" "),n("el-button",{attrs:{type:"primary",icon:"el-icon-plus",circle:""},on:{click:function(e){return t.addOption(o)}}}),t._v(" "),n("el-button",{attrs:{type:"danger",icon:"el-icon-delete",circle:""},on:{click:function(e){return t.delQuestion(o)}}})],1),t._v(" "),t._l(t.form.questions[o].option,function(e,i){return[n("el-form-item",{attrs:{label:"选项"+(i+1)}},[n("el-input",{attrs:{maxlength:"10","show-word-limit":""},model:{value:t.form.questions[o].option[i].o_value,callback:function(e){t.$set(t.form.questions[o].option[i],"o_value",e)},expression:"form.questions[qindex].option[oindex].o_value"}}),t._v(" "),n("el-button",{attrs:{type:"danger",icon:"el-icon-delete",circle:""},on:{click:function(e){return t.delOption(o,i)}}})],1)]})],2):t._e()],1)])}),0),t._v(" "),n("div",{staticClass:"submit"},[n("el-button",{attrs:{type:"success"},on:{click:function(e){return t.submitForm()}}},[t._v("修改问卷")])],1)],1)},staticRenderFns:[function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"toolbar"},[e("div")])}]};var f=n("C7Lr")(u,l,!1,function(t){n("VZYi")},"data-v-fc04650c",null);e.default=f.exports}});
  //# sourceMappingURL=4.bb7f5a4d3d4c40c54c00.js.map