You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
397 lines
19 KiB
397 lines
19 KiB
{extend name="public/container"}
|
|
{block name='head_top'}
|
|
<style>
|
|
.layui-table {
|
|
width: 100%!important;
|
|
}
|
|
|
|
.layui-form-item .special-label {
|
|
width: 50px;
|
|
float: left;
|
|
height: 30px;
|
|
line-height: 38px;
|
|
margin-left: 10px;
|
|
margin-top: 5px;
|
|
border-radius: 5px;
|
|
background-color: #0092DC;
|
|
text-align: center;
|
|
}
|
|
|
|
.layui-form-item .special-label i {
|
|
display: inline-block;
|
|
width: 18px;
|
|
height: 18px;
|
|
font-size: 18px;
|
|
color: #fff;
|
|
}
|
|
|
|
.layui-form-item .label-box {
|
|
border: 1px solid;
|
|
border-radius: 10px;
|
|
position: relative;
|
|
padding: 10px;
|
|
height: 30px;
|
|
color: #fff;
|
|
background-color: #393D49;
|
|
text-align: center;
|
|
cursor: pointer;
|
|
display: inline-block;
|
|
line-height: 10px;
|
|
}
|
|
|
|
.layui-form-item .label-box p {
|
|
line-height: inherit;
|
|
}
|
|
|
|
.edui-default .edui-for-image .edui-icon {
|
|
background-position: -380px 0px;
|
|
}
|
|
</style>
|
|
<script type="text/javascript" charset="utf-8" src="{__ADMIN_PATH}plug/ueditor/third-party/zeroclipboard/ZeroClipboard.js"></script>
|
|
<script type="text/javascript" charset="utf-8" src="{__ADMIN_PATH}plug/ueditor/ueditor.config.js"></script>
|
|
<script type="text/javascript" charset="utf-8" src="{__ADMIN_PATH}plug/ueditor/ueditor.all.min.js"></script>
|
|
{/block}
|
|
{block name="content"}
|
|
<div v-cloak id="app" class="layui-fluid">
|
|
<div class="layui-card">
|
|
<div class="layui-card-body">
|
|
<form class="layui-form" action="">
|
|
<div class="layui-tab layui-tab-brief" lay-filter="tab">
|
|
<ul class="layui-tab-title">
|
|
<li class="layui-this" lay-id="0">基本设置</li>
|
|
<!-- <li lay-id="1">题库选择</li> -->
|
|
<li v-show="type==2" lay-id="1">价格设置</li>
|
|
</ul>
|
|
<div class="layui-tab-content">
|
|
<div class="layui-tab-item layui-show">
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label required">{$type==1 ? '练习名称' : '背诵名称'}:</label>
|
|
<div class="layui-input-block">
|
|
<input type="text" name="name" v-model.trim="formData.name" autocomplete="off" placeholder="请输入{$type==1 ? '练习名称' : '背诵名称'}" maxlength="30" class="layui-input">
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label required">{$type==1 ? '练习分类' : '背诵过关'}:</label>
|
|
<div class="layui-input-block">
|
|
<select name="recite_id" v-model="formData.recite_id" lay-search="" lay-filter="recite_id">
|
|
<option value="">请选择{$type==1 ? '练习分类' : '背诵过关'}</option>
|
|
<option v-for="item in cateList" :value="item.id">{{item.name}}</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label">试题总数:</label>
|
|
<div class="layui-input-inline">
|
|
<input type="number" name="item_number" :value="formData.item_number" min="0" disabled autocomplete="off" class="layui-input">
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label">排序:</label>
|
|
<div class="layui-input-inline">
|
|
<input type="number" name="sort" :value="formData.sort" min="0" class="layui-input">
|
|
</div>
|
|
</div>
|
|
<!-- <div class="layui-inline">
|
|
<label class="layui-form-label">试题总数:</label>
|
|
<div class="layui-input-inline">
|
|
<input type="number" name="item_number" :value="sum" min="0" disabled autocomplete="off" class="layui-input">
|
|
</div>
|
|
</div> -->
|
|
</div>
|
|
|
|
<div class="layui-tab-item">
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label">付费方式:</label>
|
|
<div class="layui-input-block">
|
|
<input type="radio" name="pay_type" lay-filter="pay_type" v-model="formData.pay_type" value="1" title="付费">
|
|
<input type="radio" name="pay_type" lay-filter="pay_type" v-model="formData.pay_type" value="0" title="免费">
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item" v-show="formData.pay_type == 1">
|
|
<label class="layui-form-label">购买金额:</label>
|
|
<div class="layui-input-block">
|
|
<input style="width: 300px" type="number" name="money" lay-verify="number" v-model="formData.money" autocomplete="off" class="layui-input">
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label" style="padding: 9px 0;">会员付费方式:</label>
|
|
<div class="layui-input-block">
|
|
<input type="radio" name="member_pay_type" lay-filter="member_pay_type" v-model="formData.member_pay_type" value="1" title="付费">
|
|
<input type="radio" name="member_pay_type" lay-filter="member_pay_type" v-model="formData.member_pay_type" value="0" title="免费">
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item" v-show="formData.member_pay_type == 1">
|
|
<label class="layui-form-label" style="padding: 9px 0;">会员购买金额:</label>
|
|
<div class="layui-input-block">
|
|
<input style="width: 300px" type="number" name="member_money" lay-verify="number" v-model="formData.member_money" autocomplete="off" class="layui-input" min="0">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<div class="layui-input-block">
|
|
<button type="button" class="layui-btn layui-btn-primary" @click="clone_form">取消</button>
|
|
<button v-show="tabIndex" type="button" class="layui-btn layui-btn-primary" @click="tabChange(-1)">上一步</button>
|
|
<button v-show="(tabIndex != 1 && type == 1) || (tabIndex != 1 && type == 2)" type="button" class="layui-btn layui-btn-normal" @click="tabChange(1)">下一步</button>
|
|
<button v-show="(tabIndex == 1 && type == 1) || (tabIndex == 1 && type == 2)" type="button" class="layui-btn layui-btn-normal" @click="save">{$id ?'确认修改':'立即提交'}</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript" src="{__ADMIN_PATH}js/layuiList.js"></script>
|
|
{/block}
|
|
{block name='script'}
|
|
<script>
|
|
var id={$id},type={$type},test=<?=isset($test) ? $test : []?>;
|
|
|
|
require(['vue','helper','zh-cn','request','plupload','aliyun-oss','OssUpload'], function (Vue,$h) {
|
|
new Vue({
|
|
el: "#app",
|
|
data: {
|
|
cateList:[],
|
|
formData:{
|
|
name:test.name || '',
|
|
recite_id: test.recite_id || 0,
|
|
is_show: test.is_show || 1,
|
|
item_number:Number(test.item_number) || 0,
|
|
pay_type:test.pay_type || 0,
|
|
money:test.money || 0,
|
|
member_pay_type:test.member_pay_type || 0,
|
|
member_money:test.member_money || 0,
|
|
|
|
sort:Number(test.sort) || 0,
|
|
},
|
|
type:type,
|
|
mask:{
|
|
image:false
|
|
},
|
|
grade: [
|
|
{
|
|
grade_name:'优秀',
|
|
grade_standard: '91~100'
|
|
},
|
|
{
|
|
grade_name:'良好',
|
|
grade_standard: '81~90'
|
|
},
|
|
{
|
|
grade_name:'合格',
|
|
grade_standard: '61~80'
|
|
},
|
|
{
|
|
grade_name:'不合格',
|
|
grade_standard: '0~60'
|
|
}
|
|
],
|
|
difficultyHover: 0,
|
|
tabIndex: 0
|
|
},
|
|
computed: {
|
|
sum: function () {
|
|
return this.formData.single_number + this.formData.many_number + this.formData.judge_number;
|
|
},
|
|
total: function () {
|
|
return this.formData.single_number * this.formData.single_score + this.formData.many_number * this.formData.many_score + this.formData.judge_number * this.formData.judge_score;
|
|
}
|
|
},
|
|
methods: {
|
|
onRateClick: function (value) {
|
|
this.formData.difficulty = value;
|
|
},
|
|
onRateMousemove: function (value) {
|
|
this.difficultyHover = value;
|
|
},
|
|
onRateMouseleave: function () {
|
|
this.difficultyHover = 0;
|
|
},
|
|
onAdd: function () {
|
|
this.grade.push({
|
|
grade_name: '',
|
|
grade_standard: ''
|
|
});
|
|
},
|
|
onDel: function () {
|
|
this.grade.pop();
|
|
},
|
|
//删除图片
|
|
delect: function (key, index) {
|
|
var that = this;
|
|
if (index != undefined) {
|
|
that.formData[key].splice(index, 1);
|
|
that.$set(that.formData, key, that.formData[key]);
|
|
} else {
|
|
that.$set(that.formData, key, '');
|
|
}
|
|
},
|
|
//查看图片
|
|
look: function (pic) {
|
|
parent.$eb.openImage(pic);
|
|
},
|
|
//鼠标移入事件
|
|
enter: function (item) {
|
|
if (item) {
|
|
item.is_show = true;
|
|
} else {
|
|
this.mask = true;
|
|
}
|
|
},
|
|
//鼠标移出事件
|
|
leave: function (item) {
|
|
if (item) {
|
|
item.is_show = false;
|
|
} else {
|
|
this.mask = false;
|
|
}
|
|
},
|
|
changeIMG: function (key, value, multiple) {
|
|
if (multiple) {
|
|
var that = this;
|
|
value.map(function (v) {
|
|
that.formData[key].push({pic: v, is_show: false});
|
|
});
|
|
this.$set(this.formData, key, this.formData[key]);
|
|
} else {
|
|
this.$set(this.formData, key, value);
|
|
}
|
|
},
|
|
//上传图片
|
|
upload: function (key, count) {
|
|
ossUpload.createFrame('请选择图片', {fodder: key, max_count: count === undefined ? 0 : count},{w:800,h:550});
|
|
},
|
|
get_subject_list: function () {
|
|
var that = this;
|
|
layList.baseGet(layList.U({a: 'add_cate_list',p:{type:type}}), function (res) {
|
|
that.$set(that, 'cateList', res.data);
|
|
that.$nextTick(function () {
|
|
layList.form.render('select');
|
|
})
|
|
});
|
|
},
|
|
|
|
save: function () {
|
|
var that = this;
|
|
// var grade=that.grade;
|
|
// for(var i=0;i<grade.length;i++){
|
|
// var v=i+1;
|
|
// if(grade[i].grade_name=='' || grade[i].grade_standard=='') return layList.msg('第'+v+'没填完整');
|
|
// var arr=grade[i].grade_standard.split('~');
|
|
// if(arr.length<=1) return layList.msg('第'+v+'分数区间有误');
|
|
// if(arr[0]<0 || arr[1]<0) return layList.msg('第'+v+'分数区间分数不能小于0');
|
|
// }
|
|
that.$nextTick(function () {
|
|
if(!that.formData.name) return layList.msg('请输入' + (type === 1 ? '练习' : '背诵') + '名称');
|
|
if(that.formData.recite_id <= 0) return layList.msg('请选择' + (type === 1 ? '练习' : '背诵') + '过关');
|
|
|
|
if (that.formData.pay_type == 1 && type==2) {
|
|
if (Number(that.formData.money)<0 || that.formData.money == 0.00) return layList.msg('购买金额未填或填写不正确');
|
|
}
|
|
if (that.formData.member_pay_type == 1 && type==2) {
|
|
if (Number(that.formData.member_money)<0 || that.formData.member_money == 0.00) return layList.msg('会员购买金额未填或填写不正确');
|
|
}
|
|
|
|
var data={};
|
|
for (var key in that.formData) {
|
|
data[key] = that.formData[key]
|
|
}
|
|
layList.loadFFF();
|
|
layList.basePost(layList.U({
|
|
a: 'save_add',
|
|
q: {id: id,type:type}
|
|
}), data, function (res) {
|
|
layList.loadClear();
|
|
if (parseInt(id) == 0) {
|
|
layList.layer.confirm('添加成功,您要继续添加' + (type === 1 ? '练习' : '背诵') + '吗?', {
|
|
btn: ['继续添加', '立即提交'] //按钮
|
|
}, function (index) {
|
|
layList.layer.close(index);
|
|
}, function () {
|
|
parent.layer.closeAll();
|
|
});
|
|
} else {
|
|
layList.msg('修改成功', function () {
|
|
parent.layer.closeAll();
|
|
})
|
|
}
|
|
}, function (res) {
|
|
layList.msg(res.msg);
|
|
layList.loadClear();
|
|
});
|
|
})
|
|
},
|
|
clone_form: function () {
|
|
parent.layer.closeAll();
|
|
},
|
|
del:function (e) {
|
|
|
|
},
|
|
// 上一步、下一步
|
|
tabChange: function (value) {
|
|
layui.element.tabChange('tab', this.tabIndex + value);
|
|
}
|
|
},
|
|
mounted: function () {
|
|
var that=this;
|
|
window.changeIMG = that.changeIMG;
|
|
that.get_subject_list();
|
|
// that.get_questions_list();
|
|
// that.show_single_list();
|
|
// that.show_many_list();
|
|
// that.show_judge_list();
|
|
// if(grades && grades.length){
|
|
// that.grade=grades;
|
|
// }
|
|
this.$nextTick(function () {
|
|
layList.form.render();
|
|
layList.select('recite_id', function (obj) {
|
|
that.formData.recite_id = obj.value;
|
|
});
|
|
// layList.select('cate_id', function (obj) {
|
|
// that.formData.cate_id = obj.value;
|
|
// });
|
|
layList.form.on('radio(pay_type)', function (data) {
|
|
that.formData.pay_type = parseInt(data.value);
|
|
if(that.formData.pay_type!=1){
|
|
that.formData.money=0.00;
|
|
}
|
|
});
|
|
layList.form.on('radio(member_pay_type)', function (data) {
|
|
that.formData.member_pay_type = parseInt(data.value);
|
|
if(that.formData.member_pay_type!=1){
|
|
that.formData.member_money=0.00;
|
|
}
|
|
});
|
|
// layList.form.on('radio(is_score)', function (data) {
|
|
// that.formData.is_score = parseInt(data.value);
|
|
// });
|
|
// layList.form.on('radio(is_group)', function (data) {
|
|
// that.formData.is_group = parseInt(data.value);
|
|
// });
|
|
// layList.form.on('radio(is_show)', function (data) {
|
|
// that.formData.is_show = parseInt(data.value);
|
|
// });
|
|
// layList.form.on('radio(difficulty)', function (data) {
|
|
// that.formData.difficulty = parseInt(data.value);
|
|
// });
|
|
// 难度
|
|
layui.rate.render({
|
|
elem: '#rate',
|
|
value: that.formData.difficulty,
|
|
choose: function (value) {
|
|
that.formData.difficulty = value;
|
|
}
|
|
});
|
|
layui.element.on('tab(tab)', function (data) {
|
|
that.tabIndex = data.index;
|
|
layui.table.resize('table_1');
|
|
layui.table.resize('table_2');
|
|
layui.table.resize('table_3');
|
|
});
|
|
});
|
|
}
|
|
})
|
|
})
|
|
</script>
|
|
{/block}
|
|
|