1
0

material_case.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. {extend name="public/layout"/} {block name="title"}在施工地{/block} {block name="body"}
  2. <link rel="stylesheet" href="__STATIC__/css/csspc.css">
  3. <link rel="stylesheet" href="__STATIC__/css/font.css">
  4. <style>
  5. html,body{height: 100%;min-width: 830px;}
  6. .bodys{height: 100%;overflow-y:auto;background: #F6F7FB;padding: 25px;}
  7. .huise333{color:#333;}
  8. .layui-input{height: 46px;}
  9. .layui-form-label{width:30%;padding: 0;}
  10. .layui-form-label input{width:100%;}
  11. .layui-input-block{width:68%;min-height: 46px;}
  12. .mjtext{width:100px;height: 46px;float:left;}
  13. .searchIco{right:5%;font-size:24px;color:#28A1FF;top:8%; text-align: center;line-height: 38px;cursor: pointer;}
  14. .bottom_btn{bottom:0;left:0;width:100%;background: #fff;padding: 10px 25px;}
  15. .checkallbox{top:0;left:0;width:100%;}
  16. .checkallbox .layui-form-checkbox[lay-skin=primary]{max-width:20px;max-height: 20px;margin-top:-4px;}
  17. .checkallbox .layui-form-checkbox[lay-skin=primary] i{width:20px;height: 20px;line-height: 20px;}
  18. .seach-box{height: 67vh;overflow-y: auto;padding-bottom: 20px;position: relative;}
  19. .seach-box li{overflow: hidden;}
  20. .seach-box .layui-form-checkbox{float:left;margin-top:16px;padding-right:20px;width:20px;height: 20px;}
  21. .seach-box .layui-form-checkbox i{width:20px;height: 20px;font-size: 16px;border: 1px solid rgb(210, 210, 210);line-height: 19px;}
  22. .chekboximg{width:20px;height: 20px;}
  23. .noneimgs{position: absolute;top:0;left:0;bottom:0;right:0;margin:auto;}
  24. </style>
  25. <body>
  26. <div class="bodys wpsr">
  27. <form class="layui-form layui-form-box woverflow width100_">
  28. <div class="woverflow">
  29. <div class="layui-input-kos wpsr wleft width40_">
  30. <input type="text" name="title" placeholder="请输入标题" autocomplete="off" class="layui-input ss-title">
  31. <i class="fa fa-search searchIco wpsa ds" aria-hidden="true"></i>
  32. </div>
  33. <div class="layui-form-item wright width55_" style="clear: none;">
  34. <label class="layui-form-label lh46">面积搜索:</label>
  35. <div class="layui-input-block">
  36. <input type="text" name="square_start" autocomplete="off" class="layui-input mjtext ss-mj-start">
  37. <p class="wleft font18 lh46 huise333 mdlr10">至</p>
  38. <input type="text" name="square_end" autocomplete="off" class="layui-input mjtext ss-mj-end">
  39. <p class="wleft font18 lh46 huise333 mdl10">m²</p>
  40. </div>
  41. </div>
  42. </div>
  43. <div class="wpsr">
  44. <div class="checkallbox mdb10">
  45. <input lay-skin="primary" type="checkbox" id="checkall" name="type" lay-filter="allChoose" value="checkall"/><span class="huise333">全选</span><span class="huise999 ids mdl20 font16">共<span class="count_case"></span>个案例</span>
  46. </div>
  47. <div class="seach-box">
  48. <ul id="case_ul"></ul>
  49. </div>
  50. </div>
  51. <div class="bottom_btn wpsa woverflow">
  52. <p class="wleft lanse lh38 font14">已选择装修案例(<span class="count">0</span>个)</p>
  53. <div class="wright">
  54. <button type="button" lay-submit class="layui-btn layui-btn-normal pdlr30" lay-filter="material_case_submit" id="material_case_submit">保存</button>
  55. <button type="button" class="layui-btn layui-btn-primary cancel_btn layui-border-blue pdlr30">取消</button>
  56. </div>
  57. </div>
  58. </form>
  59. </div>
  60. </body>
  61. {/block} {block name="js"}
  62. <script>
  63. layui.config({
  64. base: '__LAYUI__/',
  65. urlbase: '/sys'
  66. }).extend({
  67. index: 'lib/index' //主入口模块
  68. }).use(['index', 'form'], function() {
  69. var $ = layui.$,
  70. form = layui.form,
  71. arrlst = [],
  72. checkboxlist=[],
  73. checkboxlist1 = [],
  74. checkboxlist2 = [],
  75. count = 0,
  76. housetype_id = "{$housetype_id}",
  77. data = {
  78. title:'',
  79. square_start:0,
  80. square_end:0
  81. },
  82. listcount=0;
  83. $('.searchIco').click(function(){
  84. var sstitle = $('.ss-title').val();
  85. var ssmjstart = $('.ss-mj-start').val();
  86. var ssmjend = $('.ss-mj-end').val();
  87. var filterArray = [];
  88. function ssmjlist(square_start,square_end){
  89. filterArray = $.grep(arrlst,(currentValue) => {
  90. if(square_start==''){
  91. return currentValue.square < square_end;
  92. }else if(square_end==''){
  93. return currentValue.square == square_start;
  94. }else if(square_start!==''&&square_end!==''){
  95. return currentValue.square > square_start && currentValue.square < square_end;
  96. }
  97. });
  98. }
  99. ssmjlist(ssmjstart,ssmjend);
  100. var ssarrlist = arrlst.filter((item) => item.title.includes(sstitle));
  101. if(sstitle==''&&ssmjstart==''&&ssmjend==''){
  102. set_step_Html(ssarrlist,0);
  103. }else if(sstitle!==''&&ssmjstart==''&&ssmjend==''){
  104. set_step_Html(ssarrlist,1);
  105. }else if(sstitle==''&&ssmjstart!==''){
  106. set_step_Html(filterArray,1);
  107. }else if(sstitle==''&&ssmjend!==''){
  108. set_step_Html(filterArray,1);
  109. }else if(sstitle!==''&&ssmjstart!==''&&ssmjend!==''){
  110. var listarrbox=[];
  111. for(var i=0;i<ssarrlist.length;i++){
  112. for(var j=0;j<filterArray.length;j++){
  113. console.log(ssarrlist[i].id==filterArray[j].id)
  114. if(ssarrlist[i].id==filterArray[j].id){
  115. listarrbox.push(filterArray[j])
  116. }
  117. }
  118. }
  119. set_step_Html(listarrbox,1);
  120. }
  121. })
  122. ajax_api(data);
  123. function ajax_api(data){
  124. $.ajax({
  125. url: '{:url("building/material_case",["housetype_id"=> $housetype_id])}',
  126. type: 'post',
  127. dataType: 'json',
  128. data:data,
  129. success: function (res) {
  130. console.log(res)
  131. if(res.code==0){
  132. listcount=res.count;
  133. $('.count_case').html(res.count);
  134. arrlst = res.data;
  135. set_step_Html(arrlst,0);
  136. if(res.count==0){
  137. $('#case_ul').append('<img class="noneimgs" src="__STATIC__/img/nonedata.png"/>');
  138. }
  139. }
  140. }
  141. });
  142. }
  143. function set_step_Html(set_List,isarrs) {
  144. $('#case_ul')[0].innerHTML = $.map(set_List, (v, i) => {
  145. return `<li class="lh50 woverflow">
  146. <input class="ds mdt17 wleft" data-index="${i}" data-material_case_id="${v.id}" lay-filter="textCheck" ${v.selected?'checked':''} type="checkbox" name="" value="${v.id}" data-isoff="${v.selected}"/>
  147. <img class="wleft mdt15 chekboximg" src="__STATIC__/img/anliico.png"/>
  148. <p class="wleft width68_ mdl10 font18 textlh1">${v.title}</p>
  149. <p class="font18 wright width20_ huise999">面积:${v.square}m²</p>
  150. </li>`
  151. }).join('');
  152. var child = $(".seach-box input[type='checkbox']");
  153. if(isarrs==0){
  154. checkboxlist=[];
  155. }else{
  156. checkboxlist1=[];
  157. }
  158. child.each(function (index, item) {
  159. if($(this).data('isoff')){
  160. $(this).prop('checked',true)
  161. if(isarrs==0){
  162. checkboxlist.push(item.value);
  163. }else{
  164. checkboxlist1.push(item.value);
  165. }
  166. }
  167. });
  168. if(isarrs==0){
  169. count=checkboxlist.length
  170. }else{
  171. count=checkboxlist.length+checkboxlist1.length
  172. }
  173. $('.count').html(count);
  174. form.on('checkbox(allChoose)', function (data) {
  175. checkboxlist=[];
  176. child.each(function (index, item) {
  177. if(data.elem.checked){
  178. item.checked = data.elem.checked;
  179. if(isarrs==0){
  180. checkboxlist.push(item.value);
  181. }else{
  182. checkboxlist1.push(item.value);
  183. }
  184. }else{
  185. item.checked = false
  186. }
  187. });
  188. if(isarrs==0){
  189. count=checkboxlist.length
  190. }else{
  191. count=checkboxlist.length+checkboxlist1.length
  192. }
  193. $('.count').html(count);
  194. form.render('checkbox');
  195. });
  196. form.on('checkbox(textCheck)', function (data) {
  197. if(data.elem.checked){
  198. if(isarrs==0){
  199. checkboxlist.push(data.value);
  200. }else{
  201. checkboxlist1.push(data.value);
  202. }
  203. }else{
  204. $.each(checkboxlist, function(index,item) {
  205. if(item==data.value){
  206. checkboxlist.splice(index,1)
  207. }
  208. });
  209. $.each(checkboxlist1, function(index,item) {
  210. if(item==data.value){
  211. checkboxlist1.splice(index,1)
  212. }
  213. });
  214. }
  215. count=checkboxlist.length;
  216. $('.count').html(count);
  217. var parent = $(data.othis).closest('#case_ul');
  218. var inputlist = parent.find('li input');
  219. var listinput=[];
  220. for(var i=0;i<inputlist.length;i++){
  221. if(inputlist[i].checked){
  222. listinput.push(1);
  223. }
  224. }
  225. if(listinput.length==inputlist.length){
  226. $('#checkall').prop('checked', true);
  227. }else{
  228. $('#checkall').prop('checked', false);
  229. }
  230. form.render('checkbox');
  231. });
  232. form.render('checkbox');
  233. }
  234. form.on('submit(material_case_submit)', function(data) {
  235. $.ajax({
  236. url: '{:url("change_material_case")}',
  237. type: 'post',
  238. data: {
  239. housetype_id:housetype_id,
  240. material_case_id:arrmerge(checkboxlist,checkboxlist1).join(',')
  241. },
  242. dataType: 'json',
  243. success: function(res) {
  244. if(res.code === 0) {
  245. layer.msg(res.msg,{
  246. anim: 0,time: 1000,icon: 6,
  247. }, function() {
  248. var index = parent.layer.getFrameIndex(window.name);
  249. parent.layui.table.reload('grant'); //重载表格
  250. parent.layer.close(index); //再执行关闭
  251. });
  252. } else {
  253. layer.msg(res.msg, {anim: 0,time: 1000,icon: 5});
  254. }
  255. }
  256. });
  257. return false;
  258. });
  259. $('.cancel_btn').click(function(){
  260. var index = parent.layer.getFrameIndex(window.name);
  261. parent.layer.close(index);
  262. })
  263. function arrmerge(arr1,arr2){
  264. $.map(arr1,(v,index)=>{
  265. if(v !==''){
  266. let idx = arr2.indexOf(v);
  267. if(idx > -1){
  268. arr2.splice(idx,1)
  269. }
  270. }
  271. })
  272. checkboxlist = arr1.concat(arr2);
  273. return checkboxlist;
  274. }
  275. function arrmergew(arrs){
  276. let temp = [];
  277. for(let i=0;i<arrs.length;i++){
  278. if(temp.indexOf(arrs[i])===-1){
  279. temp.push(arrs[i])
  280. }
  281. }
  282. return temp;
  283. }
  284. })
  285. </script>
  286. {/block}