From eb81da78f83ae28eaf4e9237fb08a16f81b04748 Mon Sep 17 00:00:00 2001 From: java110 <928255095@qq.com> Date: Sun, 7 Feb 2021 10:02:50 +0800 Subject: [PATCH] ss --- .../editQuestionAnswer.html | 4 +- .../editQuestionAnswerTitle.html | 73 +++++--- .../editQuestionAnswerTitle.js | 174 ++++++++++-------- .../questionAnswerTitleManage.html | 2 +- .../questionAnswerTitleManage.js | 9 + 5 files changed, 161 insertions(+), 101 deletions(-) diff --git a/public/components/property/editQuestionAnswer/editQuestionAnswer.html b/public/components/property/editQuestionAnswer/editQuestionAnswer.html index cb3338298..d25e494e1 100644 --- a/public/components/property/editQuestionAnswer/editQuestionAnswer.html +++ b/public/components/property/editQuestionAnswer/editQuestionAnswer.html @@ -43,8 +43,8 @@
- +
diff --git a/public/components/property/editQuestionAnswerTitle/editQuestionAnswerTitle.html b/public/components/property/editQuestionAnswerTitle/editQuestionAnswerTitle.html index 134a4f635..0ca253023 100644 --- a/public/components/property/editQuestionAnswerTitle/editQuestionAnswerTitle.html +++ b/public/components/property/editQuestionAnswerTitle/editQuestionAnswerTitle.html @@ -1,37 +1,58 @@ - \ No newline at end of file diff --git a/public/components/property/editQuestionAnswerTitle/editQuestionAnswerTitle.js b/public/components/property/editQuestionAnswerTitle/editQuestionAnswerTitle.js index 397ba65f7..71a9ff1f4 100644 --- a/public/components/property/editQuestionAnswerTitle/editQuestionAnswerTitle.js +++ b/public/components/property/editQuestionAnswerTitle/editQuestionAnswerTitle.js @@ -1,115 +1,145 @@ -(function(vc,vm){ +(function (vc, vm) { vc.extends({ - data:{ - editQuestionAnswerTitleInfo:{ - titleId:'', -titleType:'', -qaTitle:'', -seq:'', - + data: { + editQuestionAnswerTitleInfo: { + titleId: '', + titleType: '', + qaTitle: '', + seq: '', + qaId: '', + objId: '', + objType: '', + titleValues: [] } }, - _initMethod:function(){ + _initMethod: function () { - }, - _initEvent:function(){ - vc.on('editQuestionAnswerTitle','openEditQuestionAnswerTitleModal',function(_params){ + }, + _initEvent: function () { + vc.on('editQuestionAnswerTitle', 'openEditQuestionAnswerTitleModal', function (_params) { vc.component.refreshEditQuestionAnswerTitleInfo(); $('#editQuestionAnswerTitleModel').modal('show'); - vc.copyObject(_params, vc.component.editQuestionAnswerTitleInfo ); + vc.copyObject(_params, vc.component.editQuestionAnswerTitleInfo); + $that.editQuestionAnswerTitleInfo.titleValues = _params.questionAnswerTitleValues; vc.component.editQuestionAnswerTitleInfo.communityId = vc.getCurrentCommunity().communityId; }); }, - methods:{ - editQuestionAnswerTitleValidate:function(){ - return vc.validate.validate({ - editQuestionAnswerTitleInfo:vc.component.editQuestionAnswerTitleInfo - },{ - 'editQuestionAnswerTitleInfo.titleType':[ -{ - limit:"required", - param:"", - errInfo:"题目类型不能为空" + methods: { + editQuestionAnswerTitleValidate: function () { + return vc.validate.validate({ + editQuestionAnswerTitleInfo: vc.component.editQuestionAnswerTitleInfo + }, { + 'editQuestionAnswerTitleInfo.titleType': [ + { + limit: "required", + param: "", + errInfo: "题目类型不能为空" }, - { - limit:"num", - param:"", - errInfo:"题目类型格式错误" + { + limit: "num", + param: "", + errInfo: "题目类型格式错误" }, ], -'editQuestionAnswerTitleInfo.qaTitle':[ -{ - limit:"required", - param:"", - errInfo:"问卷题目不能为空" + 'editQuestionAnswerTitleInfo.qaTitle': [ + { + limit: "required", + param: "", + errInfo: "问卷题目不能为空" }, - { - limit:"maxLength", - param:"256", - errInfo:"问卷题目太长" + { + limit: "maxLength", + param: "256", + errInfo: "问卷题目太长" }, ], -'editQuestionAnswerTitleInfo.seq':[ -{ - limit:"required", - param:"", - errInfo:"顺序不能为空" + 'editQuestionAnswerTitleInfo.seq': [ + { + limit: "required", + param: "", + errInfo: "顺序不能为空" }, - { - limit:"num", - param:"", - errInfo:"顺序必须是数字" + { + limit: "num", + param: "", + errInfo: "顺序必须是数字" }, ], -'editQuestionAnswerTitleInfo.titleId':[ -{ - limit:"required", - param:"", - errInfo:"题目ID不能为空" + 'editQuestionAnswerTitleInfo.titleId': [ + { + limit: "required", + param: "", + errInfo: "题目ID不能为空" }] - }); - }, - editQuestionAnswerTitle:function(){ - if(!vc.component.editQuestionAnswerTitleValidate()){ + }); + }, + editQuestionAnswerTitle: function () { + if (!vc.component.editQuestionAnswerTitleValidate()) { vc.toast(vc.validate.errInfo); - return ; + return; } vc.http.apiPost( - 'questionAnswerTitle.updateQuestionAnswerTitle', + '/questionAnswer/updateQuestionAnswerTitle', JSON.stringify(vc.component.editQuestionAnswerTitleInfo), { - emulateJSON:true - }, - function(json,res){ + emulateJSON: true + }, + function (json, res) { //vm.menus = vm.refreshMenuActive(JSON.parse(json),0); let _json = JSON.parse(json); if (_json.code == 0) { //关闭model $('#editQuestionAnswerTitleModel').modal('hide'); - vc.emit('questionAnswerTitleManage','listQuestionAnswerTitle',{}); - return ; + vc.emit('questionAnswerTitleManage', 'listQuestionAnswerTitle', {}); + return; } vc.message(_json.msg); - }, - function(errInfo,error){ + }, + function (errInfo, error) { console.log('请求失败处理'); vc.message(errInfo); - }); + }); }, - refreshEditQuestionAnswerTitleInfo:function(){ - vc.component.editQuestionAnswerTitleInfo= { - titleId:'', -titleType:'', -qaTitle:'', -seq:'', - + refreshEditQuestionAnswerTitleInfo: function () { + vc.component.editQuestionAnswerTitleInfo = { + titleId: '', + titleType: '', + qaTitle: '', + seq: '', + objId: '', + objType: '', + titleValues: [] } + }, + _addEditTitleValue: function () { + $that.editQuestionAnswerTitleInfo.titleValues.push( + { + qaValue: '', + seq: $that.editQuestionAnswerTitleInfo.titleValues.length + 1 + } + ); + }, + _deleteEditTitleValue: function (_seq) { + console.log(_seq); + + let _newTitleValues = []; + let _tmpTitleValues = $that.editQuestionAnswerTitleInfo.titleValues; + _tmpTitleValues.forEach(item => { + if (item.seq != _seq) { + _newTitleValues.push({ + qaValue: item.qaValue, + seq: _newTitleValues.length + 1 + }) + } + }); + + $that.editQuestionAnswerTitleInfo.titleValues = _newTitleValues; } } }); -})(window.vc,window.vc.component); +})(window.vc, window.vc.component); diff --git a/public/pages/property/questionAnswerTitleManage/questionAnswerTitleManage.html b/public/pages/property/questionAnswerTitleManage/questionAnswerTitleManage.html index 4bed5d393..9a54ce0a9 100644 --- a/public/pages/property/questionAnswerTitleManage/questionAnswerTitleManage.html +++ b/public/pages/property/questionAnswerTitleManage/questionAnswerTitleManage.html @@ -75,7 +75,7 @@ {{questionAnswerTitle.titleId}} - {{questionAnswerTitle.titleType}} + {{_getTitleTypeName(questionAnswerTitle.titleType)}} {{questionAnswerTitle.qaTitle}} {{questionAnswerTitle.seq}} diff --git a/public/pages/property/questionAnswerTitleManage/questionAnswerTitleManage.js b/public/pages/property/questionAnswerTitleManage/questionAnswerTitleManage.js index c0645fbcc..30e0e2a13 100644 --- a/public/pages/property/questionAnswerTitleManage/questionAnswerTitleManage.js +++ b/public/pages/property/questionAnswerTitleManage/questionAnswerTitleManage.js @@ -91,6 +91,15 @@ } else { vc.component.questionAnswerTitleManageInfo.moreCondition = true; } + }, + _getTitleTypeName:function(_titleType){ + if(_titleType == '1001'){ + return '单选'; + }else if(_titleType == '2002'){ + return '多选'; + }else{ + return '简答'; + } }