PingAnYeXianSZCG_Web 前端代码

addCheck.html 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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/Table/table1.css" rel="stylesheet" />
  8. <link rel="stylesheet" href="bootstrap-editable.css" />
  9. <link href="../css/init.css" rel="stylesheet" />
  10. <link rel="stylesheet" href="../css/Quality/bootstrap-editable.css" />
  11. <script src="bootstrap-editable.js"></script>
  12. <title></title>
  13. <style>
  14. .Content {
  15. padding: 10px;
  16. }
  17. .btn {
  18. background: #1ab394;
  19. color: #fff;
  20. }
  21. .Btn_box {
  22. margin-top: 20px;
  23. color: #fff;
  24. }
  25. .inpBox select {
  26. width: 150px;
  27. padding: 3px 6px;
  28. }
  29. .F_Remark {
  30. width: 100%;
  31. }
  32. .tab {
  33. border-bottom: 1px solid #ccc;
  34. }
  35. .rightAdd {
  36. margin-bottom: 20px;
  37. }
  38. </style>
  39. </head>
  40. <body>
  41. <div>
  42. <div class="Content">
  43. <div class="Check_box">
  44. <button class="rightAdd btn size-14"><i class="fa fa-plus size-14"></i>增加</button>
  45. <table id="tbr" style="width: 100%;">
  46. <thead>
  47. <tr>
  48. <th data-align="center" data-field="id" data-formatter="setCode">序号</th>
  49. <th data-align="center" data-field="F_ItemName" data-formatter="Check">选项</th>
  50. <th data-align="center" data-field="F_ItemId" data-formatter="Removes">操作</th>
  51. </tr>
  52. </thead>
  53. <tbody>
  54. </tbody>
  55. </table>
  56. </div>
  57. </div>
  58. </div>
  59. <script>
  60. var wid = helper.request.queryString("Str");
  61. console.log(wid);
  62. $(document).ready(function() {
  63. if(wid) {
  64. var $tableLeft = $('#tbr');
  65. //销毁表格
  66. $tableLeft.bootstrapTable('destroy');
  67. // 初始化表格,动态从服务器加载数据
  68. $tableLeft.bootstrapTable({
  69. method: "get", //使用get请求到服务器获取数据
  70. url: huayi.config.callcenter_url + "Questionnaire/GetQuestionItemList",
  71. // url: "//117.158.196.116:8878/IndexBase/GetList",
  72. striped: true, //表格显示条纹
  73. pagination: true, //启动分页
  74. pageSize: 5, //每页显示的记录数
  75. pageNumber: 1, //当前第几页
  76. pageList: [5, 20, 50, 100], //记录数可选列表
  77. search: false, //是否启用查询
  78. showColumns: false, //显示下拉框勾选要显示的列
  79. showRefresh: false, //显示刷新按钮
  80. sidePagination: "server", //表示服务端请求
  81. //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
  82. //设置为limit可以获取limit, offset, search, sort, order
  83. queryParamsType: "undefined",
  84. queryParams: function queryParams(params) { //设置查询参数
  85. var param = {
  86. pageindex: params.pageNumber,
  87. pagesize: params.pageSize,
  88. id: wid,
  89. token: $.cookie("token"),
  90. };
  91. return param;
  92. },
  93. onLoadSuccess: function() { //加载成功时执行
  94. // layer.msg("加载成功");
  95. $("#tbr a.username").editable({
  96. url: function(params) {
  97. var id = $(this).attr("id");
  98. var QuestionId = $(this).attr("index");
  99. console.log(params.value);
  100. $.ajax({
  101. type: 'POST',
  102. url: huayi.config.callcenter_url + "Questionnaire/CreateOrUpdateQuestionItem",
  103. data: {
  104. Id: id,
  105. name: params.value,
  106. QuestionId: QuestionId,
  107. token: $.cookie("token")
  108. },
  109. dataType: 'JSON',
  110. success: function(data) {
  111. if(data.state.toLowerCase() == 'success') {
  112. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  113. // parent.layer.close(index); //再执行关闭
  114. parent.Finish();
  115. parent.layer.msg("成功");
  116. }
  117. },
  118. error: function() {
  119. alert("error");
  120. }
  121. });
  122. },
  123. type: 'text'
  124. });
  125. },
  126. onLoadError: function() { //加载失败时执行
  127. //layer.msg("加载数据失败", { time: 1500, icon: 2 });
  128. }
  129. });
  130. //添加行
  131. $(".rightAdd ").click(function() {
  132. var index = $tableLeft.bootstrapTable('getData').length;
  133. $.ajax({
  134. type: 'POST',
  135. url: huayi.config.callcenter_url + "Questionnaire/CreateOrUpdateQuestionItem",
  136. data: {
  137. QuestionId: wid,
  138. token: $.cookie("token")
  139. },
  140. dataType: 'JSON',
  141. success: function(data) {
  142. if(data.state.toLowerCase() == 'success') {
  143. console.log(data.data);
  144. $tableLeft.bootstrapTable('insertRow', {
  145. index: index,
  146. row: {
  147. }
  148. });
  149. $tableLeft.bootstrapTable('refresh');
  150. }
  151. },
  152. error: function() {
  153. alert("error");
  154. }
  155. });
  156. });
  157. }
  158. //列表
  159. });
  160. //序号
  161. function setCode(value, row, index) {
  162. return index + 1;
  163. }
  164. //修改
  165. function Check(value, row, index) {
  166. return '<a title="点击移入" class="username" id="' + row.F_ItemId + '" index="' + row.F_QuestionId + '">' + value + '</a>'
  167. }
  168. //操作
  169. function Removes(value, row, index) {
  170. return '<div><a onclick="Remove(' + value + ')" ><i class="fa fa-remove size-14"></i></a></div>'
  171. }
  172. ;
  173. //删除
  174. function Remove(val) {
  175. $.ajax({
  176. type: 'POST',
  177. url: huayi.config.callcenter_url + "Questionnaire/DeleteQuestionItme",
  178. data: {
  179. id: val,
  180. token: $.cookie("token")
  181. },
  182. dataType: 'JSON',
  183. success: function(data) {
  184. if(data.state.toLowerCase() == 'success') {
  185. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  186. parent.layer.close(index); //再执行关闭
  187. parent.Finish();
  188. parent.layer.msg("删除成功");
  189. }
  190. },
  191. error: function() {
  192. alert("error");
  193. }
  194. });
  195. }
  196. //清除 CLEAN
  197. function Clean() {
  198. }
  199. </script>
  200. </body>
  201. </html>