This commit is contained in:
java110 2021-02-07 10:02:50 +08:00
parent 591eb00145
commit eb81da78f8
5 changed files with 161 additions and 101 deletions

View File

@ -43,8 +43,8 @@
<div class="form-group row">
<label class="col-sm-2 col-form-label">备注</label>
<div class="col-sm-10">
<input v-model="editQuestionAnswerInfo.remark" type="text" placeholder="选填,请填写备注"
class="form-control">
<textarea v-model="editQuestionAnswerInfo.remark" placeholder="选填,请填写备注"
class="form-control"></textarea>
</div>
</div>

View File

@ -1,37 +1,58 @@
<div id = "editQuestionAnswerTitleModel" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" >
<div id="editQuestionAnswerTitleModel" class="modal fade" tabindex="-1" role="dialog"
aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body">
<h3 class="m-t-none m-b ">修改问卷题目</h3>
<h3 class="m-t-none m-b ">修改</h3>
<div class="ibox-content">
<div>
<div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">题目类型</label>
<div class="col-sm-10">
<select class="custom-select" v-model="editQuestionAnswerTitleInfo.titleType">
<option selected disabled value="">必填,请选择题目类型</option>
<option value="1001">单选</option>
<option value="2002">多选</option>
<option value="3003">简答题</option>
</select> </div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">问卷题目</label>
<div class="col-sm-10">
<input v-model="editQuestionAnswerTitleInfo.qaTitle" type="text" placeholder="必填,请填写问卷题目" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">顺序</label>
<div class="col-sm-10">
<input v-model="editQuestionAnswerTitleInfo.seq" type="text" placeholder="必填,请填写顺序" class="form-control">
</div>
</div>
<label class="col-sm-2 col-form-label">题目类型</label>
<div class="col-sm-10">
<select class="custom-select" v-model="editQuestionAnswerTitleInfo.titleType">
<option selected disabled value="">必填,请选择题目类型</option>
<option value="1001">单选</option>
<option value="2002">多选</option>
<option value="3003">简答题</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">问卷题目</label>
<div class="col-sm-10">
<input v-model="editQuestionAnswerTitleInfo.qaTitle" type="text"
placeholder="必填,请填写问卷题目" class="form-control">
</div>
</div>
<div class="form-group row" v-for="(item,index) in editQuestionAnswerTitleInfo.titleValues">
<label class="col-sm-2 col-form-label">选项{{item.seq}}</label>
<div class="col-sm-8">
<input v-model="item.qaValue" type="text" placeholder="必填,请填写选项内容"
class="form-control">
</div>
<div class="col-sm-2" v-if="index == editQuestionAnswerTitleInfo.titleValues.length-1">
<button class="btn btn-link float-right" type="button"
v-on:click="_addEditTitleValue()">增加选项</button>
</div>
<div class="col-sm-2" v-else>
<button class="btn btn-link float-right" type="button"
v-on:click="_deleteEditTitleValue(item.seq)">删除选项</button>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">顺序</label>
<div class="col-sm-10">
<input v-model="editQuestionAnswerTitleInfo.seq" type="text" placeholder="必填,请填写顺序"
class="form-control">
</div>
</div>
<div class="ibox-content">
<button class="btn btn-primary float-right" type="button" v-on:click="editQuestionAnswerTitle()" ><i class="fa fa-check"></i>&nbsp;保存</button>
<button type="button" class="btn btn-warning float-right" style="margin-right:20px;" data-dismiss="modal">取消</button>
<button class="btn btn-primary float-right" type="button"
v-on:click="editQuestionAnswerTitle()"><i class="fa fa-check"></i>&nbsp;保存</button>
<button type="button" class="btn btn-warning float-right" style="margin-right:20px;"
data-dismiss="modal">取消</button>
</div>
</div>
</div>
@ -39,4 +60,4 @@
</div>
</div>
</div>
</div>
</div>

View File

@ -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);

View File

@ -75,7 +75,7 @@
<tbody>
<tr v-for="questionAnswerTitle in questionAnswerTitleManageInfo.questionAnswerTitles">
<td class="text-center">{{questionAnswerTitle.titleId}}</td>
<td class="text-center">{{questionAnswerTitle.titleType}}</td>
<td class="text-center">{{_getTitleTypeName(questionAnswerTitle.titleType)}}</td>
<td class="text-center">{{questionAnswerTitle.qaTitle}}</td>
<td class="text-center">{{questionAnswerTitle.seq}}</td>
<td class="text-center">

View File

@ -91,6 +91,15 @@
} else {
vc.component.questionAnswerTitleManageInfo.moreCondition = true;
}
},
_getTitleTypeName:function(_titleType){
if(_titleType == '1001'){
return '单选';
}else if(_titleType == '2002'){
return '多选';
}else{
return '简答';
}
}