郑州第一人民医院UI

addCheck.html 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <script src="../Script/Common/huayi.load.js"></script>
  6. <script src="../Script/Common/huayi.config.js"></script>
  7. <link href="../css/init.css" rel="stylesheet" />
  8. <link href="../css/eid/bootstrap-editable.css" rel="stylesheet" />
  9. <title>试题选项</title>
  10. <style>
  11. .Content {
  12. padding: 10px;
  13. }
  14. .btn {
  15. background: #249fea;
  16. color: #fff;
  17. }
  18. .Btn_box {
  19. margin-top: 20px;
  20. color: #fff;
  21. }
  22. .inpBox select {
  23. width: 150px;
  24. padding: 3px 6px;
  25. }
  26. .F_Remark {
  27. width: 100%;
  28. }
  29. .tab {
  30. border-bottom: 1px solid #ccc;
  31. }
  32. .rightAdd {
  33. margin-bottom: 20px;
  34. }
  35. </style>
  36. </head>
  37. <body>
  38. <div>
  39. <div class="Content">
  40. <div class="Check_box">
  41. <button class="rightAdd btn size-14"><i class="fa fa-plus size-14"></i>增加</button>
  42. <table id="tbr" style="width: 100%;">
  43. <thead>
  44. <tr>
  45. <th data-align="center" data-field="id" data-formatter="setCode">序号</th>
  46. <th data-align="center" data-field="questname" data-formatter="Check">内容</th>
  47. <th data-align="center" data-field="grade" data-formatter="formatterFraction">分数</th>
  48. <th data-align="center" data-field="id" data-formatter="Removes">操作</th>
  49. </tr>
  50. </thead>
  51. <tbody>
  52. </tbody>
  53. </table>
  54. </div>
  55. </div>
  56. </div>
  57. <script src="../js/eid/bootstrap-editable.js"></script>
  58. <script>
  59. var wid = helper.request.queryString("Str");
  60. var $tableLeft = $('#tbr');
  61. //console.log(wid);
  62. $(document).ready(function() {
  63. if(wid) {
  64. loadTable()
  65. //添加行
  66. $(".rightAdd ").click(function() {
  67. var index = $tableLeft.bootstrapTable('getData').length;
  68. //console.log(index)
  69. $.ajax({
  70. type: 'get',
  71. url: huayi.config.callcenter_url + "testusertypeapi/api/TestUserType/AddTestQuestion",
  72. data: {
  73. testid: wid,
  74. questname: '',
  75. grade: '',
  76. token: $.cookie("token")
  77. },
  78. dataType: 'JSON',
  79. success: function(data) {
  80. if(data.state.toLowerCase() == 'success') {
  81. // $tableLeft.bootstrapTable('insertRow', {
  82. // index: index,
  83. // row: {
  84. // }
  85. // });
  86. $tableLeft.bootstrapTable('refresh');
  87. }
  88. },
  89. error: function() {
  90. alert("error");
  91. }
  92. });
  93. });
  94. }
  95. //列表
  96. });
  97. //序号
  98. function setCode(value, row, index) {
  99. return index + 1;
  100. }
  101. //修改
  102. function Check(value, row, index) {
  103. return '<a title="点击编辑" class="username" id="' + row.id + '" index="' + row.testid + '"fraction="' + row.grade + '">' + value + '</a>'
  104. }
  105. function formatterFraction(value, row, index) {
  106. return '<a title="点击编辑" class="fraction" id="' + row.id + '" index="' + row.testid + '"questname="' + row.questname + '">' + value + '</a>'
  107. }
  108. //操作
  109. function Removes(value, row, index) {
  110. var idStr = JSON.stringify(value).replace(/\"/g,"'");
  111. return '<div style="color: red"><a onclick="Remove(' + idStr + ')" >删除<i class="fa fa-remove size-14"></i></a></div>'
  112. }
  113. function loadTable() {
  114. //销毁表格
  115. $tableLeft.bootstrapTable('destroy');
  116. // 初始化表格,动态从服务器加载数据
  117. $tableLeft.bootstrapTable({
  118. method: "get", //使用get请求到服务器获取数据
  119. url: huayi.config.callcenter_url + "testusertypeapi/api/TestUserType/Gettestquestinfo",
  120. striped: true, //表格显示条纹
  121. smartDisplay:false, //不显示分页,总条数
  122. pagination: false, //启动分页
  123. pageSize: 5, //每页显示的记录数
  124. pageNumber: 1, //当前第几页
  125. pageList: [5, 20, 50, 100], //记录数可选列表
  126. search: false, //是否启用查询
  127. showColumns: false, //显示下拉框勾选要显示的列
  128. showRefresh: false, //显示刷新按钮
  129. sidePagination: "server", //表示服务端请求
  130. //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
  131. //设置为limit可以获取limit, offset, search, sort, order
  132. queryParamsType: "undefined",
  133. queryParams: function queryParams(params) { //设置查询参数
  134. var param = {
  135. pageindex: params.pageNumber,
  136. pagesize: params.pageSize,
  137. testid: wid,
  138. token: $.cookie("token"),
  139. };
  140. return param;
  141. },
  142. responseHandler: function(res) {
  143. return {
  144. // "total": res.data.total, //总页数
  145. "rows": res.data //数据
  146. };
  147. },
  148. onLoadSuccess: function() { //加载成功时执行
  149. editOptions();
  150. editFraction();
  151. //layer.msg("加载成功");
  152. },
  153. onLoadError: function() { //加载失败时执行
  154. //layer.msg("加载数据失败", { time: 1500, icon: 2 });
  155. }
  156. });
  157. }
  158. //删除
  159. function Remove(val) {
  160. $.ajax({
  161. type: 'get',
  162. url: huayi.config.callcenter_url + "testusertypeapi/api/TestUserType/DelQuestion",
  163. data: {
  164. id: val,
  165. token: $.cookie("token")
  166. },
  167. dataType: 'JSON',
  168. success: function(data) {
  169. if(data.state.toLowerCase() == 'success') {
  170. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  171. parent.layer.close(index); //再执行关闭
  172. parent.Finish();
  173. parent.layer.msg("删除成功");
  174. }
  175. },
  176. error: function() {
  177. alert("error");
  178. }
  179. });
  180. }
  181. //编辑
  182. function editOptions() {
  183. $("#tbr a.username").editable({
  184. type: "text", //编辑框的类型。支持text|textarea|select|date|checklist等
  185. disabled: false, //是否禁用编辑
  186. emptytext: "请输入选项", //空值的默认文本
  187. mode: "inline", //编辑框的模式:支持popup和inline两种模式,默认是popup
  188. url: function(params) {
  189. $.ajax({
  190. type: 'get',
  191. url: huayi.config.callcenter_url + "testusertypeapi/api/TestUserType/updateQuestion",
  192. data: {
  193. Id: $(this).attr("id"),
  194. questname: params.value,
  195. grade: $(this).attr("fraction"),
  196. testid: $(this).attr("index"),
  197. token: $.cookie("token")
  198. },
  199. dataType: 'JSON',
  200. success: function(data) {
  201. if(data.state.toLowerCase() == 'success') {
  202. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  203. //parent.layer.close(index); //再执行关闭
  204. parent.Finish();
  205. parent.layer.msg("保存成功");
  206. }
  207. },
  208. });
  209. },
  210. });
  211. }
  212. function editFraction() {
  213. $("#tbr a.fraction").editable({
  214. type: "text", //编辑框的类型。支持text|textarea|select|date|checklist等
  215. disabled: false, //是否禁用编辑
  216. emptytext: "请输入选项", //空值的默认文本
  217. mode: "inline", //编辑框的模式:支持popup和inline两种模式,默认是popup
  218. url: function(params) {
  219. $.ajax({
  220. type: 'get',
  221. url: huayi.config.callcenter_url + "testusertypeapi/api/TestUserType/updateQuestion",
  222. data: {
  223. Id: $(this).attr("id"),
  224. grade: params.value,
  225. questname: $(this).attr("questname"),
  226. testid: $(this).attr("index"),
  227. token: $.cookie("token")
  228. },
  229. dataType: 'JSON',
  230. success: function(data) {
  231. if(data.state.toLowerCase() == 'success') {
  232. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  233. //parent.layer.close(index); //再执行关闭
  234. parent.Finish();
  235. parent.layer.msg("保存成功");
  236. }
  237. },
  238. });
  239. },
  240. });
  241. }
  242. </script>
  243. </body>
  244. </html>