123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- * Created by TT on 2018/1/26.
- */
- ;
- spa_define(function () {
- return $.use(["spa", "pagedatagrid", "util"], function (spa, pdgf, util) {
- return {
- main: function () {
- var root = spa.findInMain(".sys_answer_index");
- var pdg = pdgf.build(root);
- pdg.code.shell("showDay", function (env) {
- if (env.cd && env.cd[this.k]) {
- var day = env.cd[this.k];
- return day.substring(0, 4) + "年" + day.substring(4, 6) + "月" + day.substring(6, 8) + "日 " + day.substring(8, 10) + ":" + day.substring(10, 12);
- }
- return "";
- });
- pdg.code.listen($.dict.doTransfer);
- pdg.code.listen(function(){
- root.find(".hand-lm").each(function() {
- var $e = $(this);
- var aId = $e.attr("aId");
- if (aId) {
- util.get("http://www.ekexiu.com/ajax/leavemsg/count", {sid: aId,stype:4}, function (data) {
- $e.text(data);
- }, {});
- $e.removeClass("hand-lm");
- }
- });
- root.find(".hand-col").each(function() {
- var $e = $(this);
- var aId = $e.attr("aId");
- util.get("/ajax/content/countProfessor",{id:aId,type:9},function(data){
- $e.text(data);
- },{});
- $e.removeClass("hand-col");
- });
- root.find(".table-opt a.name").on("click",function () {
- var aId = $(this).parent().attr("aId");
- var qId = $(this).parent().attr("qId");
-
- window.open('http://www.ekexiu.com/qa-show.html?id='+qId+'&topid=' + aId);
- });
- root.find("a.author").on("click",function () {
- var professorId = $(this).parent().attr("professorId");
- if(professorId){
- window.open('http://www.ekexiu.com/userInforShow.html?professorId='+professorId);
- }
- })
- });
- root.find(".opt-query").on("click", function () {
- pdg.load();
- });
- pdg.load();
- root.find(".dt-tpl").on("click", "th.opt-check>i.icon-st-check", function () {
- var $this = $(this);
- $this.toggleClass("checked");
- if ($this.hasClass("checked")) {
- root.find(".dt-tpl td.opt-check>i.icon-st-check").addClass("checked");
- } else {
- root.find(".dt-tpl td.opt-check>i.icon-st-check").removeClass("checked");
- }
- });
- root.find(".dt-tpl").on("click", "td.opt-check>i.icon-st-check", function () {
- var $this = $(this);
- $this.toggleClass("checked");
- });
- root.find(".opt-del").on("click", function() {
- var $answer = root.find("td.opt-check>i.checked");
- if($answer.length) {
- if($answer.length > 1) {
- util.alert("只能选择一篇回答");
- } else {
- util.boxMsg({
- title: "删除回答",
- content: "您是否要删除选中的回答!删除后不可恢复",
- btns: [{
- caption: "确认",
- hand: function() {
- util.get("../ajax/qa/deleteAnswer", { id: $answer.attr("aId"),qid:$answer.attr("qId") }, function() { pdg.reload() }, {});
- }
- },
- { caption: "取消" }
- ]
- });
- }
- } else {
- util.alert("请选择一篇回答");
- }
- });
- root.find(".opt-edit").on("click", function() {
- var $answer = root.find("td.opt-check>i.checked");
- if ($answer.length) {
- if ($answer.length>1) {
- util.alert("只能选择一篇回答");
- }else {
- spa.showModal("sys_answer_edit", {
- id: $answer.attr("aId"),
- hand: function () {
- pdg.reload();
- }
- });
- }
- }else {
- util.alert("请选择一篇文章");
- }
- });
- root.find(".opt-view").on("click", function () {
- var $answer = root.find("td.opt-check>i.checked");
- if ($answer.length) {
- if ($answer.length > 1) {
- util.alert("只能选择一篇回答");
- } else {
- var aId = $answer.attr("aId");
- var qId = $answer.attr("qId");
- window.open('http://www.ekexiu.com/qa-show.html?id='+qId+'&topid=' + aId );
- }
- } else {
- util.alert("请选择一篇回答");
- }
- });
- root.find(".opt-count").on("click", function () {
- var $answer = root.find("td.opt-check>i.checked");
- if ($answer.length) {
- if ($answer.length>1) {
- util.alert("只能选择一篇回答");
- }else {
- spa.showModal("sys_answer_count", {
- id: $answer.attr("aId"),
- hand: function () {
- pdg.reload();
- }
- });
- }
- }else {
- util.alert("请选择一篇回答");
- }
- });
- }, mainDestory: function () {
- }
- };
- });
- });
|