index.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. {extend name="common/common2" /}
  2. {block name="main"}
  3. <div class="ibox">
  4. <div class="ibox-content">
  5. <div class="row">
  6. <div class="col-xs-8">
  7. <a href="javascript:;" url="{:url('add')}" data-title="新增{$m_name}" onclick="layer_open(this,1)" class="btn btn-sm btn-primary">新增</a>
  8. <a href="javascript:;" onclick="batchSorts()" class="btn btn-sm btn-warning">保存排序</a>
  9. <a href="javascript:;" onclick="batchSave()" class="btn btn-sm btn-info">批量保存时间代码、运送积分、优先级</a>
  10. </div>
  11. <div class="col-xs-4" style="text-align: right;">
  12. <form class="form-inline" id="form-search" action="{:url('index')}">
  13. <div class="input-group">
  14. <input type="text" class="form-control" name="title" placeholder="名称">
  15. </div>
  16. <div class="input-group">
  17. <select name="enable" class="form-control">
  18. <option value="">选择状态</option>
  19. <option value="0">禁用</option>
  20. <option value="1">正常</option>
  21. </select>
  22. </div>
  23. <div class="input-group">
  24. <span class="input-group-btn">
  25. <button class="btn-sm btn-primary" type="button" id ="search-btn" ><i class="fa fa-search"></i></button>
  26. </span> &nbsp;
  27. <span class="input-group-btn">
  28. <button class="btn-sm btn-warning" type="button" id="search-clear"><i class="fa fa-undo"></i></button>
  29. </span>
  30. <span class="input-group-btn">-->
  31. <button class="btn-sm btn-primary" data-url="{:url('import')}" type="button" id ="upload" ><i class="fa fa-upload"></i></button>
  32. </span>
  33. </div>
  34. </form>
  35. </div>
  36. </div>
  37. </div>
  38. <div class="ibox-content">
  39. <div class="jqGrid_wrapper">
  40. <table id="table" style="border-collapse: collapse"></table>
  41. <div id="pager"></div>
  42. </div>
  43. </div>
  44. </div>
  45. {/block}
  46. {block name="script"}
  47. <script>
  48. $(function () {
  49. $(window).bind("resize",function(){
  50. var width=$(".jqGrid_wrapper").width();
  51. $("#table").setGridWidth(width);
  52. });
  53. $.jgrid.defaults.styleUI="Bootstrap";
  54. $("#table").jqGrid({
  55. url:"{:url('index')}",
  56. datatype: "json",
  57. colModel:[
  58. {label:'ID',name:'id',index:'id', width:30,sortable: false},
  59. {label:'名称',name:'title',index:'title',width:80,editable: false,sortable: false},
  60. // {label:'时间代码',name:'timeName',index:'timeName',width:80,editable: false,sortable: false},
  61. {label:'时间代码',name:'time_id',index:'time_id',width:80,sortable: true,formatter: function (a, b, c) {
  62. let times = c.times;
  63. let arr = [];
  64. for (let a in times) {
  65. arr.push({
  66. key: times[a].id,
  67. value: times[a].title
  68. })
  69. }
  70. let str = '';
  71. str += '<select style="width: 100%;" name="priority" onchange="sjdmChange('+c.id+',this)">';
  72. for (let i=0; i< arr.length;i++){
  73. if(arr[i].key === a){
  74. str += '<option value="'+arr[i].key+'" selected>'+arr[i].value+'</option>';
  75. }else {
  76. str += '<option value="'+arr[i].key+'">'+arr[i].value+'</option>';
  77. }
  78. }
  79. str += '</select>';
  80. return str;
  81. }},
  82. {label:'开始地点',name:'startsName',index:'startsName',width:80,editable: false,sortable: false},
  83. {label:'结束地点',name:'endsName',index:'endsName',width:80,editable: false,sortable: false},
  84. // {label:'任务优先级',name:'priorityName',index:'priorityName',width:80,editable: false,sortable: false},
  85. // {label:'任务优先级',index:'priority',width:40, editable: true, edittype: "select", editoptions:{value:{2:'常规',3:'紧急'},formatter: "select"}},
  86. {label:'任务优先级',name:'priority',index:'priority',width:60,sortable: true,formatter: function (a, b, c) {
  87. let priorityList = c.priorityList;
  88. let arr = [];
  89. for (let a in priorityList) {
  90. arr.push({
  91. key: a,
  92. value: priorityList[a]
  93. })
  94. }
  95. let str = '';
  96. str += '<select style="width: 100%;" name="priority" onchange="yxjChange('+c.id+',this)">';
  97. for (let i=0; i< arr.length;i++){
  98. if(i === a){
  99. str += '<option value="'+arr[i].key+'" selected>'+arr[i].value+'</option>';
  100. }else {
  101. str += '<option value="'+arr[i].key+'">'+arr[i].value+'</option>';
  102. }
  103. }
  104. str += '</select>';
  105. return str;
  106. }},
  107. // {label:'运送积分',name:'score',index:'score',width:80,editable: false,sortable: false},
  108. {label:'运送积分',name:'score',index:'score',width:40,sortable: true,formatter: function (a, b, c) {
  109. return '<input type="number" data-url="{:url('batchSave')}" class="form-control input-sm userscore" data-id="'+c.id+'" data-old="'+a+'" value="'+a+'" />';
  110. }},
  111. {label:'是否是病人',name:'cate',index:'cate',width:60,editable: false,sortable: false,formatter:function (a,b,c){
  112. if(a == 1){
  113. return '是';
  114. } else{
  115. return '否';
  116. }
  117. }},
  118. {label:'排序',name:'sort',index:'sort',width:40,sortable: true,formatter: function (a, b, c) {
  119. return '<input type="number" data-url="{:url('changeSort')}" class="form-control input-sm usersorts" data-id="'+c.id+'" data-old="'+a+'" value="'+a+'" />';
  120. }},
  121. {label:'状态',name:'enable',index:'enable',width:40,editable: false,sortable: false,formatter:function (a,b,c){
  122. if(a == 0){
  123. var url = "{:url('changeField',[],'')}/fn/enable/fv/1/id/"+c.id;
  124. return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-danger" title="禁用">禁用</span></a>';
  125. } else{
  126. var url = "{:url('changeField',[],'')}/fn/enable/fv/0/id/"+c.id;
  127. return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-primary" title="正常">正常</span></a>';
  128. }
  129. }},
  130. {label:'颜色',name:'color',index:'color',width:40,editable: false,sortable: false,formatter:function (a,b,c){
  131. return '<div style="width: 20px;height: 20px;background-color:'+a+' "></div>';
  132. }},
  133. {label:'操作',width:50,sortable: false,formatter: function (a, b, c) {
  134. var editurl = "{:url('add',[],'')}/id/"+c.id;
  135. var delurl = "{:url('del',[],'')}/id/"+c.id;
  136. var btn = '<a url="'+editurl+'" href="javascript:;" data-title="编辑{$m_name}" onclick="layer_open(this,1)"><span class="label label-primary" title="编辑">编辑</span></a>&nbsp;';
  137. // btn += '<a href="'+delurl+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
  138. return btn;
  139. }},
  140. ],
  141. rowNum:10,
  142. rowList:[10,20,30,50,100],
  143. pager: '#pager',
  144. sortname: 'sort',
  145. viewrecords: true,
  146. autowidth:true,
  147. mtype: 'post',
  148. height: 'auto',
  149. emptyrecords: "暂无数据",
  150. sortorder: "asc",
  151. caption:"{$m_name}列表",
  152. loadComplete: function (xhr) {
  153. if(xhr.code==0){
  154. layer.msg(xhr.msg);
  155. return false;
  156. }
  157. },
  158. });
  159. });
  160. function batchSorts() {
  161. let data = [];
  162. $('.usersorts').each(function(){
  163. data.push({
  164. id: $(this).attr('data-id'),
  165. sort: $(this).val(),
  166. })
  167. });
  168. let url = "{:url('ConveyCate/batchSort')}";
  169. $.post(url,{data:JSON.stringify(data)},function (res) {
  170. if(res.code == 1){
  171. updateAlert('操作成功','alert-success');
  172. setTimeout(function(){
  173. $('#top-alert').find('button').click();
  174. },1500);
  175. $("#table").trigger("reloadGrid");
  176. }else{
  177. updateAlert(data.msg,'alert-danger');
  178. setTimeout(function(){
  179. $('#top-alert').find('button').click();
  180. },1500);
  181. }
  182. });
  183. }
  184. var yxjData = [];
  185. function yxjChange(id,_self){
  186. yxjData.push({
  187. id:id,
  188. priority:$(_self).val(),
  189. })
  190. }
  191. var timeData = [];
  192. function sjdmChange(tid,_self2){
  193. timeData.push({
  194. id:tid,
  195. timeId:$(_self2).val(),
  196. })
  197. }
  198. function batchSave(){
  199. let scoreData = [];
  200. $('.userscore').each(function(){
  201. scoreData.push({
  202. id: $(this).attr('data-id'),
  203. score: $(this).val(),
  204. })
  205. });
  206. let data = {
  207. yxj:yxjData,
  208. time:timeData,
  209. score:scoreData
  210. };
  211. let url = "{:url('ConveyCate/batchSave')}";
  212. $.post(url,{data:JSON.stringify(data)},function (res) {
  213. if(res.code == 1){
  214. updateAlert('操作成功','alert-success');
  215. setTimeout(function(){
  216. $('#top-alert').find('button').click();
  217. },1500);
  218. $("#table").trigger("reloadGrid");
  219. }else{
  220. updateAlert(data.msg,'alert-danger');
  221. setTimeout(function(){
  222. $('#top-alert').find('button').click();
  223. },1500);
  224. }
  225. });
  226. }
  227. </script>
  228. {/block}