1
0

cate2.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. {extend name="public/layout"/} {block name="title"}分类管理{/block} {block name="body"}
  2. <style>
  3. html,
  4. body {
  5. height: 80%;
  6. min-width: 500px;
  7. background-color: #fff;
  8. }
  9. .bodys {
  10. width: 100%;
  11. box-sizing: border-box;
  12. padding: 20px;
  13. }
  14. .layTitle {
  15. color: #CCCCCC;
  16. }
  17. .addSecond {
  18. color: #249EFB;
  19. cursor: pointer;
  20. }
  21. .addSeconds {
  22. color: #249EFB;
  23. cursor: pointer;
  24. }
  25. .deleteSecond {
  26. color: rgb(230, 66, 66);
  27. cursor: pointer;
  28. }
  29. .editSecond {
  30. color: #249EFB;
  31. cursor: pointer;
  32. }
  33. .secondBox {
  34. padding: 10px 0px;
  35. display: flex;
  36. }
  37. .layContentBox {
  38. flex: 1;
  39. display: flex;
  40. flex-wrap: wrap;
  41. margin-left: 10px;
  42. }
  43. .layContentBox>div {
  44. margin-bottom: 10px;
  45. margin-right: 10px;
  46. margin-left: 0px !important;
  47. }
  48. .layui-btn-primary {
  49. position: relative;
  50. }
  51. .relative {
  52. position: relative;
  53. }
  54. .layicons {
  55. position: absolute;
  56. top: -15px;
  57. right: -10px;
  58. color: #666666;
  59. }
  60. .layicon {
  61. position: absolute;
  62. top: -15px;
  63. right: -10px;
  64. color: #666666;
  65. }
  66. .fixedbtn {
  67. position: fixed;
  68. width: 100%;
  69. height: 50px;
  70. bottom: 0px;
  71. left: 0px;
  72. display: flex;
  73. align-items: center;
  74. justify-content: space-between;
  75. box-sizing: border-box;
  76. padding: 0px 15px;
  77. background-color: #fff;
  78. }
  79. .newCate12 {
  80. color: #249EFB;
  81. font-size: 14px;
  82. cursor: pointer;
  83. }
  84. .ml10 {
  85. margin-left: 10px;
  86. }
  87. </style>
  88. <body>
  89. <div class="bodys">
  90. <form class="layui-form layui-form-box" style="padding-bottom: 50px;">
  91. {notempty name='cate'}
  92. {volist name='cate' id='v'}
  93. <div>
  94. <div class="layTitle">
  95. <span>
  96. {if condition='$v.is_case eq 1'}
  97. {$v.title}【案例类】
  98. {else/}
  99. {$v.title}【图文类】
  100. {/if}
  101. </span>
  102. {if condition='$v.is_case eq 1'}
  103. <span class="addSeconds" data-id='{$v.id}'>+添加分类</span>
  104. {else/}
  105. <span class="addSecond" data-id='{$v.id}'>+添加二级分类</span>
  106. {/if}
  107. <span class="editSecond ml10 itemText" data-val="{$v.title}" data-id='{$v.id}'>编辑分类</span>
  108. <span class="deleteSecond ml10" data-id='{$v.id}'>删除分类</span>
  109. </div>
  110. {notempty name='$v.child'}
  111. {volist name='$v.child' id='vo'}
  112. <div class="secondBox">
  113. {if condition="$vo.title eq '小区'"}
  114. <div class="layui-btn layui-btn-normal layui-btn-sm relative itemText" data-val='{$vo.title}' data-id='{$vo.id}'>
  115. {$vo.title}
  116. <i class="layui-icon layui-icon-close-fill layicons" data-id='{$vo.id}'></i>
  117. </div>
  118. <div class="layui-btn layui-btn-primary layui-btn-sm ml10 addElement" data-id='{$vo.id}'>+添加小区</div>
  119. {elseif($vo.title == '风格')/}
  120. <div class="layui-btn layui-btn-normal layui-btn-sm relative itemText" data-val='{$vo.title}' data-id='{$vo.id}'>
  121. {$vo.title}
  122. <i class="layui-icon layui-icon-close-fill layicons" data-id='{$vo.id}'></i>
  123. </div>
  124. <div class="layui-btn layui-btn-primary layui-btn-sm ml10 addElement" data-id='{$vo.id}'>+添加风格</div>
  125. {elseif($vo.title == '户型')/}
  126. <div class="layui-btn layui-btn-normal layui-btn-sm relative itemText" data-val='{$vo.title}' data-id='{$vo.id}'>
  127. {$vo.title}
  128. <i class="layui-icon layui-icon-close-fill layicons" data-id='{$vo.id}'></i>
  129. </div>
  130. <div class="layui-btn layui-btn-primary layui-btn-sm ml10 addElement" data-id='{$vo.id}'>+添加户型</div>
  131. {else/}
  132. <div class="layui-btn layui-btn-normal layui-btn-sm relative itemText" data-val='{$vo.title}' data-id='{$vo.id}'>
  133. {$vo.title}
  134. <i class="layui-icon layui-icon-close-fill layicons" data-id='{$vo.id}'></i>
  135. </div>
  136. <div class="layui-btn layui-btn-primary layui-btn-sm ml10 addElement" data-id='{$vo.id}'>+添加</div>
  137. {/if}
  138. <div class="layContentBox">
  139. {notempty name='$vo.child'}
  140. {volist name='$vo.child' id='v2'}
  141. <div class="layui-btn layui-btn-primary layui-btn-sm itemText" data-val='{$v2.title}' data-id='{$v2.id}'>{$v2.title}
  142. <i class="layui-icon layui-icon-close-fill layicon" data-id='{$v2.id}'></i>
  143. </div>
  144. {/volist}
  145. {/notempty}
  146. </div>
  147. </div>
  148. {/volist}
  149. {/notempty}
  150. </div>
  151. {/volist}
  152. {else/}
  153. <span>请先添加分类</span>
  154. {/notempty}
  155. <div>
  156. </div>
  157. <div class="width56_ fixedbtn">
  158. <span class="newCate12">+新建分类</span>
  159. <div>
  160. <button type="button" lay-submit class="layui-btn layui-btn-normal pdlr30"
  161. lay-filter="spellgroup-submit" id="spellgroup-submit">确定</button>
  162. <button type="button" class="layui-btn layui-btn-primary pdlr30 cancel">取消</button>
  163. </div>
  164. </div>
  165. </form>
  166. </div>
  167. </body>
  168. {/block} {block name="js"}
  169. <script>
  170. layui.config({
  171. base: '__LAYUI__/',
  172. urlbase: '/sys'
  173. }).extend({
  174. index: 'lib/index' //主入口模块
  175. }).use(['index', 'form', 'upload'], function () {
  176. var $ = layui.$,
  177. layer = layui.layer,
  178. upload = layui.upload,
  179. form = layui.form;
  180. var type = '{$type}';//模块
  181. console.log(type)
  182. var pid = '{$pid}';//一级父id
  183. //添加保存
  184. form.on('submit(spellgroup-submit)', function (data) {
  185. var formData = new FormData(data.form);
  186. var index = parent.layer.getFrameIndex(window.name);
  187. parent.layui.table.reload('dev-table'); //重载表格
  188. parent.layer.close(index); //再执行关闭
  189. return false;
  190. });
  191. $('.cancel').click(function () {
  192. var index = parent.layer.getFrameIndex(window.name);
  193. parent.layer.close(index);
  194. })
  195. $('.newCate12').click(function () {
  196. window.parent.addnewtagfunc();
  197. })
  198. //添加三级分类
  199. $('.addElement').click(function () {
  200. var p_pid = $(this).data('id');
  201. layer.prompt({
  202. title: "添加",
  203. value: '',
  204. area: ['800px', '350px'] //自定义文本域宽高
  205. }, function (value, index, elem) {
  206. if (value == '') {
  207. layer.msg('请输入分类名称', { anim: 6, time: 1000 });
  208. return false;
  209. }
  210. if (value.length > 20) {
  211. layer.msg('分类名称超长', { anim: 0, time: 1000 });
  212. return false;
  213. }
  214. $.ajax({
  215. url: '{:url("smartScreen/saveCate")}',
  216. type: 'post',
  217. data: { title: value, level: 3, type: type, pid: p_pid },
  218. dataType: 'json',
  219. success: function (res) {
  220. if (res.code === 0) {
  221. layer.msg(res.msg, {
  222. anim: 0
  223. , time: 1500
  224. }, function () {
  225. layer.close(index);
  226. location.reload();
  227. });
  228. } else {
  229. layer.msg(res.msg, {
  230. anim: 6
  231. , time: 2000
  232. });
  233. }
  234. }
  235. });
  236. });
  237. })
  238. $('.addSecond').click(function() {
  239. var ppid = $(this).data('id');
  240. layer.prompt({
  241. title: "添加二级分类",
  242. value: '',
  243. area: ['800px', '350px'] //自定义文本域宽高
  244. }, function (value, index, elem) {
  245. if (value == '') {
  246. layer.msg('请输入分类名称', { anim: 6, time: 1000 });
  247. return false;
  248. }
  249. if (value.length > 20) {
  250. layer.msg('分类名称超长', { anim: 0, time: 1000 });
  251. return false;
  252. }
  253. $.ajax({
  254. url: '{:url("smartScreen/saveCate")}',
  255. type: 'post',
  256. data: {title:value,level:2,type:type,pid:ppid},
  257. dataType: 'json',
  258. success: function(res) {
  259. if(res.code === 0) {
  260. layer.msg(res.msg, {
  261. anim: 0
  262. ,time: 1000
  263. }, function() {
  264. layer.close(index);
  265. location.reload();
  266. });
  267. } else {
  268. layer.msg(res.msg, {
  269. anim: 6
  270. , time: 1000
  271. });
  272. }
  273. }
  274. });
  275. });
  276. })
  277. $('.addSeconds').click(function() {
  278. var ppid = $(this).data('id');
  279. layer.prompt({
  280. title: "添加分类",
  281. value: '',
  282. area: ['800px', '350px'] //自定义文本域宽高
  283. }, function (value, index, elem) {
  284. if (value == '') {
  285. layer.msg('请输入分类名称', { anim: 6, time: 1000 });
  286. return false;
  287. }
  288. if (value.length > 20) {
  289. layer.msg('分类名称超长', { anim: 0, time: 1000 });
  290. return false;
  291. }
  292. $.ajax({
  293. url: '{:url("smartScreen/saveCate")}',
  294. type: 'post',
  295. data: {title:value,level:2,type:type,pid:ppid},
  296. dataType: 'json',
  297. success: function(res) {
  298. if(res.code === 0) {
  299. layer.msg(res.msg, {
  300. anim: 0
  301. ,time: 1000
  302. }, function() {
  303. layer.close(index);
  304. location.reload();
  305. });
  306. } else {
  307. layer.msg(res.msg, {
  308. anim: 6
  309. , time: 1000
  310. });
  311. }
  312. }
  313. });
  314. });
  315. })
  316. $('.layicon').click(function (e) {
  317. var id = $(this).data('id');
  318. layer.confirm('确定要删除此分类么?', function () {
  319. $.get("{:url('smartScreen/delCate')}?id=" + id, function (res) {
  320. if (res.code === 0) {
  321. layer.msg(res.msg, { anim: 0 , time: 1000}, function () {
  322. location.reload();
  323. });
  324. } else {
  325. layer.msg(res.msg, { anim: 6 , time: 1000});
  326. }
  327. });
  328. });
  329. e.stopPropagation();
  330. })
  331. //删除二级
  332. $('.layicons').click(function (e) {
  333. var id = $(this).data('id');
  334. layer.confirm('确定要删除此分类么?', function () {
  335. $.get("{:url('smartScreen/delCate2')}?id=" + id, function (res) {
  336. if (res.code === 0) {
  337. layer.msg(res.msg, { anim: 0 , time: 1000}, function () {
  338. location.reload();
  339. });
  340. } else {
  341. layer.msg(res.msg, { anim: 6 , time: 1000});
  342. }
  343. });
  344. });
  345. e.stopPropagation();
  346. })
  347. $('.itemText').click(function (e) {
  348. var id = $(this).data('id');
  349. var title = $(this).data('val');
  350. layer.prompt({
  351. title: "编辑",
  352. value: title,
  353. area: ['800px', '350px'] //自定义文本域宽高
  354. }, function (value, index, elem) {
  355. if (value == '') {
  356. layer.msg('请输入分类名称', { anim: 6, time: 1000 });
  357. return false;
  358. }
  359. if (value.length > 20) {
  360. layer.msg('分类名称超长', { anim: 0, time: 1000 });
  361. return false;
  362. }
  363. $.ajax({
  364. url: '{:url("smartScreen/editCate")}',
  365. type: 'post',
  366. data: { title: value, id: id },
  367. dataType: 'json',
  368. success: function (res) {
  369. if (res.code === 0) {
  370. layer.msg(res.msg, {
  371. anim: 0
  372. , time: 1000
  373. }, function () {
  374. layer.close(index);
  375. location.reload();
  376. });
  377. } else {
  378. layer.msg(res.msg, {
  379. anim: 6
  380. , time: 1000
  381. });
  382. }
  383. }
  384. });
  385. });
  386. });
  387. $('.deleteSecond').click(function(e) {
  388. var id = $(this).data('id');
  389. layer.confirm('确定要删除此标签么?', function () {
  390. $.get("{:url('smartScreen/delCate1')}?id=" + id, function (res) {
  391. if (res.code === 0) {
  392. layer.msg(res.msg, { anim: 0, time: 1000 }, function () {
  393. window.parent.reloadPageFunc();
  394. location.reload();
  395. });
  396. } else {
  397. layer.msg(res.msg, { anim: 6 , time: 1000});
  398. }
  399. });
  400. });
  401. e.stopPropagation();
  402. })
  403. })
  404. </script>
  405. {/block}