269 lines
12 KiB
Plaintext
269 lines
12 KiB
Plaintext
|
|
|
|||
|
|
@{
|
|||
|
|
ViewBag.Title = "签到问题维护";
|
|||
|
|
}
|
|||
|
|
<div id="checkQuestion" style="width:100%"></div>
|
|||
|
|
|
|||
|
|
<div id="checkQuestionModify" style="display:none;">
|
|||
|
|
<form id="editform">
|
|||
|
|
<input id="id" type="hidden" name="id" value="0" />
|
|||
|
|
<table id="tb1" class="t1" style="width:100%">
|
|||
|
|
<tr>
|
|||
|
|
<td class="ltd" width="120px"><input id="code" class="l-text" name="code" type="hidden" />题干:</td>
|
|||
|
|
<td class="rtd"><textarea id="text" name="text" rows="10" cols="70"></textarea></td>
|
|||
|
|
</tr>
|
|||
|
|
@*<tr>
|
|||
|
|
<td class="ltd" width="120px"><input id="code" class="l-text" name="code" type="hidden" />问题日期:</td>
|
|||
|
|
<td class="rtd"><input id="check_date" class="l-text" name="check_date" /></td>
|
|||
|
|
</tr>*@
|
|||
|
|
@*<tr>
|
|||
|
|
<td class="ltd" width="120px"><input id="code" class="l-text" name="code" type="hidden" />答案:</td>
|
|||
|
|
<td class="rtd"><input id="answer" class="l-text" name="answer" /></td>
|
|||
|
|
</tr>*@
|
|||
|
|
<tr id="tr1" class="options">
|
|||
|
|
<td class="ltd" width="120px"><input id="code" class="l-text" name="code" type="hidden" />题目:</td>
|
|||
|
|
<td class="rtd"><input id="options1" class="l-text" style="width:440px" name="options" /> <button type="button" style="" onclick="addOption(this)">添加题目</button></td>
|
|||
|
|
</tr>
|
|||
|
|
</table>
|
|||
|
|
</form>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
@section scripts{
|
|||
|
|
<script type="text/javascript">
|
|||
|
|
$(function () {
|
|||
|
|
$("#check_date").ligerDateEditor();
|
|||
|
|
var manager = $("#checkQuestion").ligerGrid({
|
|||
|
|
url: "@Url.Action("getCheckQuestionList")",
|
|||
|
|
toolbar: {
|
|||
|
|
items: [
|
|||
|
|
{text: '添加', click: itemclick, icon: 'add'},
|
|||
|
|
{ line: true },
|
|||
|
|
{ text: '修改', click: itemclick, icon: "edit" },
|
|||
|
|
{ line: true },
|
|||
|
|
{ text: '删除', click: itemclick, icon: 'delete' }
|
|||
|
|
|
|||
|
|
]
|
|||
|
|
},
|
|||
|
|
title: "签到问题列表",
|
|||
|
|
parms: { },
|
|||
|
|
columns: [
|
|||
|
|
{ name: "id", id: "id", display: "id", width: 100, align: "center" },
|
|||
|
|
{ name: "text", display: "题干", width: 100, align: "center" },
|
|||
|
|
//{ name: "answer", display: "答案", width: 100, align: "center" },
|
|||
|
|
//{ name: "check_date", display: "问题日期", width: 100, align: "center" },
|
|||
|
|
{ name: "creater", display: "添加者", width: 100, align: "center" },
|
|||
|
|
{ name: "create_time", display: "添加时间", width: 100, align: "center" },
|
|||
|
|
{ name: "answer_yes", display: "是", width: 100, align: "center" },
|
|||
|
|
{ name: "answer_no", display: "否", width: 100, align: "center" },
|
|||
|
|
{ name: "answer_unknow", display: "不知道", width: 100, align: "center" }
|
|||
|
|
], width: "98%",
|
|||
|
|
height: "100%",
|
|||
|
|
rownumbers: false,
|
|||
|
|
usePager: false
|
|||
|
|
});
|
|||
|
|
manager.toggleCol("id", false);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
function itemclick(item){
|
|||
|
|
if (item.text == "添加") {
|
|||
|
|
$(".options2").remove();
|
|||
|
|
$("#id").val("0");
|
|||
|
|
$("#text").val("");
|
|||
|
|
$("#check_date").val("");
|
|||
|
|
$("#options1").val("");
|
|||
|
|
$.ligerDialog.open({
|
|||
|
|
title: "添加签到问题", target: $("#checkQuestionModify"),top:"15px", width: 750, height: 500, buttons: [{
|
|||
|
|
text: "确定", onclick: function (item, dialg) {
|
|||
|
|
f_save(dialg);
|
|||
|
|
}
|
|||
|
|
}, { text: "取消", onclick: function (item, dialg) { dialg.hidden(); } }]
|
|||
|
|
});
|
|||
|
|
} else if (item.text == "删除") {
|
|||
|
|
var r = liger.get("checkQuestion").getSelectedRow();
|
|||
|
|
if (!r) {
|
|||
|
|
$.ligerDialog.alert("请选择数据!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
var id = r.id;
|
|||
|
|
f_delete(id);
|
|||
|
|
}
|
|||
|
|
else if (item.text == "修改")
|
|||
|
|
{
|
|||
|
|
var r = liger.get("checkQuestion").getSelectedRow();
|
|||
|
|
if (!r) {
|
|||
|
|
$.ligerDialog.alert("请选择数据!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
$(".options2").remove();
|
|||
|
|
$("#id").val(r.id);
|
|||
|
|
$("#text").val(r.text);
|
|||
|
|
$("#check_date").val(r.check_date);
|
|||
|
|
$("#answer").val(r.answer);
|
|||
|
|
$("#options1").val("");
|
|||
|
|
$.ajax({
|
|||
|
|
url: "@Url.Action("getQuestionOptions")", type: "post", dataType: "json", data: {id:$("#id").val()},
|
|||
|
|
success: function (d) {
|
|||
|
|
$.ligerDialog.closeWaitting();
|
|||
|
|
|
|||
|
|
if (d.State == 1) {
|
|||
|
|
var options = d.options;
|
|||
|
|
var tb = document.getElementById("tb1");
|
|||
|
|
//var n = $("#tb1 tr:last");
|
|||
|
|
//var n = document.getElementById('tr1').rowIndex + 1;
|
|||
|
|
if (options.length>0) {
|
|||
|
|
$("#options1").val(options[0].options);
|
|||
|
|
if (options.length>1) {
|
|||
|
|
for (var i = 1; i < options.length; i++) {
|
|||
|
|
var newTr = tb.insertRow();//添加新行,trIndex就是要添加的位置
|
|||
|
|
newTr.innerHTML = '<tr id="tr1" class="options"> <td class="ltd" width = "120px" > <input id="code" class="l-text" name="code" type="hidden" />题目:</td > <td class="rtd"><input id="option2" style="width:440px" class="l-text" name="options" value="' + options[i].options + '" /> <button type="button" style="" onclick="deleteOption(this)">删除题目</button></td> </tr >';
|
|||
|
|
newTr.id = 'tr2';
|
|||
|
|
newTr.classList.add('options2');
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
beforeSend: function () {
|
|||
|
|
$.ligerDialog.waitting("请稍后……");
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
$.ligerDialog.open({
|
|||
|
|
title: "修改签到问题", target: $("#checkQuestionModify"), top: "15px", width: 750, height: 500, buttons: [{
|
|||
|
|
text: "确定", onclick: function (item, dialg) {
|
|||
|
|
f_save(dialg);
|
|||
|
|
}
|
|||
|
|
}, { text: "取消", onclick: function (item, dialg) { dialg.hidden(); } }]
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function f_save(dialg) {
|
|||
|
|
//if (!$("#sort").val()) {
|
|||
|
|
// $.ligerDialog.alert("序号不能为空!");
|
|||
|
|
// return;
|
|||
|
|
////}
|
|||
|
|
//console.log(getForm2("editform"));
|
|||
|
|
var keyvalues = getForm2("editform");
|
|||
|
|
//var id = $("#id").val();
|
|||
|
|
//var text = $("#text").val();
|
|||
|
|
//var check_date = $("#check_date").val();
|
|||
|
|
var id = keyvalues["id"];
|
|||
|
|
var text = keyvalues["text"];
|
|||
|
|
var check_date = keyvalues["check_date"];
|
|||
|
|
var answer = keyvalues["answer"];
|
|||
|
|
var options = keyvalues["options"];
|
|||
|
|
//var json = '{"id":"' + id + '","text":"' + text + '","answer":"' + answer + '","check_date":"' + check_date + '","options":"' + options + '"}';
|
|||
|
|
//var data = JSON.parse(json);
|
|||
|
|
var data = { id: id, text: text, answer: answer, check_date: check_date, options: options };
|
|||
|
|
$.ajax(
|
|||
|
|
{
|
|||
|
|
url: "@Url.Action("saveCheckQuestion")", type: "post", dataType: "json", data: data,
|
|||
|
|
success: function (d) {
|
|||
|
|
$.ligerDialog.closeWaitting();
|
|||
|
|
$.ligerDialog.alert(d.Message, function () {
|
|||
|
|
if (d.State == 1) {
|
|||
|
|
dialg.hidden();
|
|||
|
|
liger.get("checkQuestion").reload();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
beforeSend: function () {
|
|||
|
|
$.ligerDialog.waitting("正在保存请稍后……");
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function f_delete(id)
|
|||
|
|
{
|
|||
|
|
$.ajax(
|
|||
|
|
{
|
|||
|
|
url: "@Url.Action("deleteCheckQuestion")", type: "post", dataType: "json", data: { id: id },
|
|||
|
|
success: function (d) {
|
|||
|
|
$.ligerDialog.alert(d.Message, function () {
|
|||
|
|
if (d.State == 1) {
|
|||
|
|
liger.get("checkQuestion").reload();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function addOption(addButton)
|
|||
|
|
{
|
|||
|
|
var tb = document.getElementById("tb1");
|
|||
|
|
var n = document.getElementById('tr1').rowIndex + 1;
|
|||
|
|
//var n = $("#tb1 tr:last");
|
|||
|
|
//var n = $("#tb1>tbody>tr:not(:last)>td:not(:last-child)");
|
|||
|
|
var newTr = tb.insertRow();//添加新行,trIndex就是要添加的位置
|
|||
|
|
newTr.innerHTML = '<tr id="tr1" class="options"> <td class="ltd" width = "120px" > <input id="code" class="l-text" name="code" type="hidden" />题目:</td > <td class="rtd"><input id="option2" style="width:440px" class="l-text" name="options" /> <button type="button" style="" onclick="deleteOption(this)">删除题目</button></td> </tr >';
|
|||
|
|
newTr.id = 'tr2';
|
|||
|
|
newTr.classList.add('options2');
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function deleteOption(deleteButton) {
|
|||
|
|
deleteButton.parentNode.parentNode.remove();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function getForm2(formid) {
|
|||
|
|
var keyvalues = {};
|
|||
|
|
var form = document.getElementById(formid);
|
|||
|
|
var elements = form.elements;
|
|||
|
|
var have;
|
|||
|
|
|
|||
|
|
for (var i = 0; i < elements.length; i++) {
|
|||
|
|
var element = elements[i];
|
|||
|
|
if (element.disabled) {
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
var name = element.name;
|
|||
|
|
if (!name) {
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
var classs = element.classList;
|
|||
|
|
if (classs.contains("need")) {
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
//console.log(element.type);
|
|||
|
|
var value = "未知";
|
|||
|
|
switch (element.type) {
|
|||
|
|
case "text":
|
|||
|
|
case "textarea":
|
|||
|
|
case "number":
|
|||
|
|
case "hidden":
|
|||
|
|
case "select-one":
|
|||
|
|
value = element.value;
|
|||
|
|
break;
|
|||
|
|
case "button":
|
|||
|
|
value = element.innerHTML;
|
|||
|
|
break;
|
|||
|
|
case "checkbox":
|
|||
|
|
if (element.checked) {
|
|||
|
|
value = element.value;
|
|||
|
|
break;
|
|||
|
|
} else {
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
value = element.type;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
have = false;
|
|||
|
|
for (var key in keyvalues) {
|
|||
|
|
if (key == name) {
|
|||
|
|
keyvalues[name] += "," + value;
|
|||
|
|
have = true;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (have == false) {
|
|||
|
|
keyvalues[name] = value;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return keyvalues;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
</script>
|
|||
|
|
}
|