|
@@ -0,0 +1,420 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html>
|
|
|
+<head>
|
|
|
+ <meta charset="utf-8">
|
|
|
+ <title>添加运维宝典</title>
|
|
|
+ <meta name="renderer" content="webkit">
|
|
|
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
|
|
+ <meta name="viewport"
|
|
|
+ content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
|
|
+ <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
|
|
|
+ <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+
|
|
|
+<div class="layui-fluid">
|
|
|
+ <div class="layui-card">
|
|
|
+ <div class="layui-card-body">
|
|
|
+ <form class="layui-form" action="" lay-filter="component-form-element">
|
|
|
+ <div class="layui-form-item">
|
|
|
+ <div class="layui-inline">
|
|
|
+ <label class="layui-form-label"><font color='red' size="4">*</font>科目:</label>
|
|
|
+ <div class="layui-input-inline">
|
|
|
+ <select name="subject" id="id_subject" lay-verify="required" lay-filter="subjectChange">
|
|
|
+ <option value="">请选择科目</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="layui-inline">
|
|
|
+ <label class="layui-form-label"><font color='red' size="4">*</font>试卷类型:</label>
|
|
|
+ <div class="layui-input-inline">
|
|
|
+ <select name="type" lay-verify="required" lay-filter="typeChange" id="id_type">
|
|
|
+ <option value="1" selected>固定试卷</option>
|
|
|
+ <option value="2">随机试卷</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </div>
|
|
|
+
|
|
|
+
|
|
|
+ <div class="layui-form-item" id="fixed_exampaper">
|
|
|
+ <div class="layui-inline">
|
|
|
+ <label class="layui-form-label"><font color='red' size="4">*</font>选择试卷:</label>
|
|
|
+ <div class="layui-input-inline">
|
|
|
+ <input type="text" id="exampaper_name" class="layui-input">
|
|
|
+ </div>
|
|
|
+ <div class="layui-input-inline">
|
|
|
+ <button type="button" class="layui-btn" id="search_btn">查询 </button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="layui-form-item">
|
|
|
+ <div id="fixed">
|
|
|
+ <label class="layui-form-label"></label>
|
|
|
+ <div class="layui-input-block" id="id_table">
|
|
|
+ <div id="tableRes" class="table-overlay" style="align-items: center">
|
|
|
+ <table id="dataTable" lay-filter="dataTable"></table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div id="random">
|
|
|
+ <div class="layui-form-item">
|
|
|
+ <label class="layui-form-label"><font color='red' size="4">*</font>配置:</label>
|
|
|
+ <div class="layui-inline" style="width: 80%">
|
|
|
+ <label class="layui-form-label">单选题:</label>
|
|
|
+ <div class="layui-inline" style="width: 85%">
|
|
|
+ 每题
|
|
|
+ <div class="layui-inline" style="width: 10%">
|
|
|
+ <input type="text" lay-verify="intGtz" name="single_scores" autocomplete="off" class="layui-input">
|
|
|
+ </div>
|
|
|
+ 分
|
|
|
+ ,简单
|
|
|
+ <div class="layui-inline" style="width: 10%">
|
|
|
+ <input type="text" lay-verify="intGtz" name="single_simple_count" autocomplete="off" class="layui-input single">
|
|
|
+ </div>
|
|
|
+
|
|
|
+ ,中等
|
|
|
+ <div class="layui-inline" style="width: 10%">
|
|
|
+ <input type="text" lay-verify="intGtz" name="single_mid_count" autocomplete="off" class="layui-input single">
|
|
|
+ </div>
|
|
|
+ ,困难
|
|
|
+ <div class="layui-inline" style="width: 10%">
|
|
|
+ <input type="text" lay-verify="intGtz" name="single_hard_count" autocomplete="off" class="layui-input single">
|
|
|
+ </div>
|
|
|
+ <div class="layui-inline" style="width: 10%">
|
|
|
+ <label id="id_single_total_count" class="layui-form-label">共 题</label>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="layui-form-item">
|
|
|
+ <label class="layui-form-label"></label>
|
|
|
+ <div class="layui-inline" style="width: 80%">
|
|
|
+ <label class="layui-form-label">多选题:</label>
|
|
|
+ <div class="layui-inline" style="width: 85%">
|
|
|
+ 每题
|
|
|
+ <div class="layui-inline" style="width: 10%">
|
|
|
+ <input type="text" lay-verify="intGtz" name="multiple_scores" autocomplete="off" class="layui-input">
|
|
|
+ </div>
|
|
|
+ 分
|
|
|
+ ,简单
|
|
|
+ <div class="layui-inline" style="width: 10%">
|
|
|
+ <input type="text" lay-verify="intGtz" name="multiple_simple_count" autocomplete="off" class="layui-input multiple">
|
|
|
+ </div>
|
|
|
+
|
|
|
+ ,中等
|
|
|
+ <div class="layui-inline" style="width: 10%">
|
|
|
+ <input type="text" lay-verify="intGtz" name="multiple_mid_count" autocomplete="off" class="layui-input multiple">
|
|
|
+ </div>
|
|
|
+ ,困难
|
|
|
+ <div class="layui-inline" style="width: 10%">
|
|
|
+ <input type="text" lay-verify="intGtz" name="multiple_hard_count" autocomplete="off" class="layui-input multiple">
|
|
|
+ </div>
|
|
|
+ <div class="layui-inline" style="width: 10%">
|
|
|
+ <label id="id_multiple_total_count" class="layui-form-label">共 题</label>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="layui-form-item">
|
|
|
+ <label class="layui-form-label"></label>
|
|
|
+ <div class="layui-inline" style="width: 80%">
|
|
|
+ <label class="layui-form-label">判断题:</label>
|
|
|
+ <div class="layui-inline" style="width: 85%">
|
|
|
+ 每题
|
|
|
+ <div class="layui-inline" style="width: 10%">
|
|
|
+ <input type="text" lay-verify="intGtz" name="judgment_scores" autocomplete="off" class="layui-input">
|
|
|
+ </div>
|
|
|
+ 分
|
|
|
+ ,简单
|
|
|
+ <div class="layui-inline" style="width: 10%">
|
|
|
+ <input type="text" lay-verify="intGtz" name="judgment_simple_count" autocomplete="off" class="layui-input judgment">
|
|
|
+ </div>
|
|
|
+
|
|
|
+ ,中等
|
|
|
+ <div class="layui-inline" style="width: 10%">
|
|
|
+ <input type="text" lay-verify="intGtz" name="judgment_mid_count" autocomplete="off" class="layui-input judgment">
|
|
|
+ </div>
|
|
|
+ ,困难
|
|
|
+ <div class="layui-inline" style="width: 10%">
|
|
|
+ <input type="text" lay-verify="intGtz" name="judgment_hard_count" autocomplete="off" class="layui-input judgment">
|
|
|
+ </div>
|
|
|
+ <div class="layui-inline" style="width: 10%">
|
|
|
+ <label id="id_judgment_total_count" class="layui-form-label">共 题</label>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="layui-form-item">
|
|
|
+ <label class="layui-form-label"></label>
|
|
|
+ <div class="layui-inline" style="width: 80%">
|
|
|
+ <label class="layui-form-label">填空题:</label>
|
|
|
+ <div class="layui-inline" style="width: 85%">
|
|
|
+ 每题
|
|
|
+ <div class="layui-inline" style="width: 10%">
|
|
|
+ <input type="text" lay-verify="intGtz" name="fill_scores" autocomplete="off" class="layui-input">
|
|
|
+ </div>
|
|
|
+ 分
|
|
|
+ ,简单
|
|
|
+ <div class="layui-inline" style="width: 10%">
|
|
|
+ <input type="text" lay-verify="intGtz" name="fill_simple_count" autocomplete="off" class="layui-input fill">
|
|
|
+ </div>
|
|
|
+
|
|
|
+ ,中等
|
|
|
+ <div class="layui-inline" style="width: 10%">
|
|
|
+ <input type="text" lay-verify="intGtz" name="fill_mid_count" autocomplete="off" class="layui-input fill">
|
|
|
+ </div>
|
|
|
+ ,困难
|
|
|
+ <div class="layui-inline" style="width: 10%">
|
|
|
+ <input type="text" lay-verify="intGtz" name="fill_hard_count" autocomplete="off" class="layui-input fill">
|
|
|
+ </div>
|
|
|
+ <div class="layui-inline" style="width: 10%">
|
|
|
+ <label id="id_fill_total_count" class="layui-form-label">共 题</label>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <button class="layui-btn" id="id_save" lay-submit lay-filter="component-form-element"
|
|
|
+ style="display: none">保存
|
|
|
+ </button>
|
|
|
+ </form>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
+
|
|
|
+
|
|
|
+<script src="../../layuiadmin/layui/layui.js"></script>
|
|
|
+<script>
|
|
|
+ layui.config({
|
|
|
+ base: '../../../layuiadmin/' //静态资源所在路径
|
|
|
+ }).extend({
|
|
|
+ index: 'lib/index',
|
|
|
+ }).use(['index', 'form', 'utils', 'table', ], function () {
|
|
|
+ var $ = layui.$
|
|
|
+ , admin = layui.admin
|
|
|
+ , table = layui.table
|
|
|
+ , form = layui.form;
|
|
|
+
|
|
|
+ var exam_id = layui.view.getParameterByName('exam_id');
|
|
|
+
|
|
|
+
|
|
|
+ admin.req({
|
|
|
+ url: '/admin/subject/dict/',
|
|
|
+ done: function (res) {
|
|
|
+ var subject = res.data.subject;
|
|
|
+ var subject_node = $('#id_subject');
|
|
|
+ for (var i in subject) {
|
|
|
+ var pid = subject[i].id;
|
|
|
+ var subject_value = subject[i].name;
|
|
|
+ subject_node.append("<option value='" + pid + "'>" + subject_value + "</option>");
|
|
|
+ }
|
|
|
+ form.render();
|
|
|
+ loadData()
|
|
|
+ }
|
|
|
+ });
|
|
|
+ var loadData = function () {
|
|
|
+ var subject = $('#id_subject').val();
|
|
|
+ var type = $('#id_type').val();
|
|
|
+ if (type === '1'){
|
|
|
+ $('#fixed').show();
|
|
|
+ $('#fixed_exampaper').show();
|
|
|
+ $('#random').hide();
|
|
|
+
|
|
|
+ if (subject){
|
|
|
+ table_reload(subject)
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ $('#fixed').hide();
|
|
|
+ $('#fixed_exampaper').hide();
|
|
|
+ $('#random').show();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $('.single').on("input", function (e) {
|
|
|
+ var total = 0;
|
|
|
+ $('.single').each(function (i) {
|
|
|
+ var target = $('.single')[i];
|
|
|
+ var val = parseInt(target.value);
|
|
|
+ if(!isNaN(val) && val){
|
|
|
+ total += val
|
|
|
+ }
|
|
|
+ });
|
|
|
+ var txt = '共 ' + total + ' 题';
|
|
|
+ $('#id_single_total_count').html(txt);
|
|
|
+ });
|
|
|
+ $('.multiple').on("input", function (e) {
|
|
|
+ var total = 0;
|
|
|
+ $('.multiple').each(function (i) {
|
|
|
+ var target = $('.multiple')[i];
|
|
|
+ var val = parseInt(target.value);
|
|
|
+ if(!isNaN(val) && val){
|
|
|
+ total += val
|
|
|
+ }
|
|
|
+ });
|
|
|
+ var txt = '共 ' + total + ' 题';
|
|
|
+ $('#id_multiple_total_count').html(txt);
|
|
|
+ });
|
|
|
+ $('.fill').on("input", function (e) {
|
|
|
+ var total = 0;
|
|
|
+ $('.fill').each(function (i) {
|
|
|
+ var target = $('.fill')[i];
|
|
|
+ var val = parseInt(target.value);
|
|
|
+ if(!isNaN(val) && val){
|
|
|
+ total += val
|
|
|
+ }
|
|
|
+ });
|
|
|
+ var txt = '共 ' + total + ' 题';
|
|
|
+ $('#id_fill_total_count').html(txt);
|
|
|
+ });
|
|
|
+ $('.judgment').on("input", function (e) {
|
|
|
+ var total = 0;
|
|
|
+ $('.judgment').each(function (i) {
|
|
|
+ var target = $('.judgment')[i];
|
|
|
+ var val = parseInt(target.value);
|
|
|
+ if(!isNaN(val) && val){
|
|
|
+ total += val
|
|
|
+ }
|
|
|
+ });
|
|
|
+ var txt = '共 ' + total + ' 题';
|
|
|
+ $('#id_judgment_total_count').html(txt);
|
|
|
+ });
|
|
|
+
|
|
|
+ form.render(null, 'component-form-element');
|
|
|
+
|
|
|
+ $('#search_btn').on('click', function () {
|
|
|
+ var subject = $('#id_subject').val();
|
|
|
+ var name = $('#exampaper_name').val();
|
|
|
+ table_reload(subject, name)
|
|
|
+ });
|
|
|
+
|
|
|
+ var typeChange = function (value) {
|
|
|
+ // 如果试卷类型是固定试卷 根据科目和类型 去后端请求相应类型的试卷 加载 如果是 随机试卷 改变table
|
|
|
+ if (value === '2'){
|
|
|
+ $('#fixed').hide();
|
|
|
+ $('#fixed_exampaper').hide();
|
|
|
+ $('#random').show();
|
|
|
+ }else if (value === '1'){
|
|
|
+ $('#fixed').show();
|
|
|
+ $('#fixed_exampaper').show();
|
|
|
+ $('#random').hide();
|
|
|
+ }else{
|
|
|
+ layer.msg('请选择一个合法试卷类型!', {icon: 2});
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ var subject = $('#id_subject').val();
|
|
|
+ if (subject && value === '1'){
|
|
|
+ table_reload(subject);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ var subjectChange = function (value) {
|
|
|
+ // 如果试卷类型是 固定试卷 科目改变了添加相应科目的固定试卷 如果是随机试卷不做处理
|
|
|
+ var type = $('#id_type').val();
|
|
|
+ if (type && type === '1'){
|
|
|
+ table_reload(value);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ // 试卷类型修改 重新加载table
|
|
|
+ form.on('select(typeChange)', function (data) {
|
|
|
+ if (!data.value) return;
|
|
|
+ typeChange(data.value)
|
|
|
+ });
|
|
|
+ // 科目改变 重新加载table
|
|
|
+ form.on('select(subjectChange)', function (data) {
|
|
|
+ if (!data.value) return;
|
|
|
+ subjectChange(data.value)
|
|
|
+ });
|
|
|
+
|
|
|
+ var tbWidth = $('#tableRes').width();
|
|
|
+ var cols = [
|
|
|
+ {title: '', type: 'radio', width: '5%', },
|
|
|
+ {title: '编号', type: 'numbers', width: '8%', },
|
|
|
+ {title: '名称', field: 'name', width: '20%', },
|
|
|
+ {title: '科目', field: 'subject_name', width: '15%', },
|
|
|
+ {title: '总分', field: 'question_total_scores', width: '10%', },
|
|
|
+ {title: '及格线', field: 'passline', width: '10%', },
|
|
|
+ {title: '添加人', field: 'create_user_text', width: '10%', },
|
|
|
+ {title: '时间', field: 'create_time', width: '22%', },
|
|
|
+ ]
|
|
|
+
|
|
|
+ var layTableId = 'layTable';
|
|
|
+ var tableIns = table.render({
|
|
|
+ elem: '#dataTable',
|
|
|
+ id: layTableId,
|
|
|
+ data: [],
|
|
|
+ width: tbWidth,
|
|
|
+ page: true,
|
|
|
+ limit: 10,
|
|
|
+ loading: true,
|
|
|
+ even: true,
|
|
|
+ cols: [cols],
|
|
|
+ done: function (data, date, total) {
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ var table_reload = function (subject, name='') {
|
|
|
+ admin.req({
|
|
|
+ url: '/admin/exampaper/?subject=' + subject + '&name=' + name,
|
|
|
+ type: 'get',
|
|
|
+ done: function (res) {
|
|
|
+ tableIns.reload({
|
|
|
+ data: res.data,
|
|
|
+ cols: [cols],
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ form.on('submit(component-form-element)', function(data){
|
|
|
+ if (data.field.type === '1'){
|
|
|
+ var url = '/admin/exam/' + exam_id + '/allocation_fixed_exampaper/';
|
|
|
+ var tableData = table.cache[layTableId], exampaper_id = '', checked = 0;
|
|
|
+
|
|
|
+ for (var i = 0; i < tableData.length; i++) {
|
|
|
+ if (tableData[i].LAY_CHECKED){
|
|
|
+ checked += 1;
|
|
|
+ exampaper_id = tableData[i].id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (checked !==1 ){
|
|
|
+ layer.msg('请选择一张试卷!', {icon: 2});
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ data.field['exampaper_id'] = exampaper_id
|
|
|
+ }else{
|
|
|
+ url = '/admin/exam/' + exam_id + '/allocation_random_exampaper/';
|
|
|
+ }
|
|
|
+
|
|
|
+ admin.req({
|
|
|
+ url: url
|
|
|
+ , data: data.field
|
|
|
+ , type: 'post'
|
|
|
+ ,done: function(res){
|
|
|
+ parent.layui.onSubmitChild(res.data);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+
|
|
|
+ parent.layui.submitChild = function () {
|
|
|
+ $("#id_save").click();
|
|
|
+ };
|
|
|
+ });
|
|
|
+</script>
|
|
|
+</body>
|
|
|
+</html>
|