123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428 |
- {extend name="public/layout"/} {block name="title"}分类管理{/block} {block name="body"}
- <style>
- html,
- body {
- height: 80%;
- min-width: 500px;
- background-color: #fff;
- }
- .bodys {
- width: 100%;
- box-sizing: border-box;
- padding: 20px;
- }
- .layTitle {
- color: #CCCCCC;
- }
- .addSecond {
- color: #249EFB;
- cursor: pointer;
- }
- .addSeconds {
- color: #249EFB;
- cursor: pointer;
- }
- .deleteSecond {
- color: rgb(230, 66, 66);
- cursor: pointer;
- }
- .editSecond {
- color: #249EFB;
- cursor: pointer;
- }
- .secondBox {
- padding: 10px 0px;
- display: flex;
- }
- .layContentBox {
- flex: 1;
- display: flex;
- flex-wrap: wrap;
- margin-left: 10px;
- }
- .layContentBox>div {
- margin-bottom: 10px;
- margin-right: 10px;
- margin-left: 0px !important;
- }
- .layui-btn-primary {
- position: relative;
- }
- .relative {
- position: relative;
- }
- .layicons {
- position: absolute;
- top: -15px;
- right: -10px;
- color: #666666;
- }
- .layicon {
- position: absolute;
- top: -15px;
- right: -10px;
- color: #666666;
- }
- .fixedbtn {
- position: fixed;
- width: 100%;
- height: 50px;
- bottom: 0px;
- left: 0px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- box-sizing: border-box;
- padding: 0px 15px;
- background-color: #fff;
- }
- .newCate12 {
- color: #249EFB;
- font-size: 14px;
- cursor: pointer;
- }
- .ml10 {
- margin-left: 10px;
- }
- </style>
- <body>
- <div class="bodys">
- <form class="layui-form layui-form-box" style="padding-bottom: 50px;">
- {notempty name='cate'}
- {volist name='cate' id='v'}
- <div>
- <div class="layTitle">
- <span>
- {if condition='$v.is_case eq 1'}
- {$v.title}【案例类】
- {else/}
- {$v.title}【图文类】
- {/if}
- </span>
- {if condition='$v.is_case eq 1'}
- <span class="addSeconds" data-id='{$v.id}'>+添加分类</span>
- {else/}
- <span class="addSecond" data-id='{$v.id}'>+添加二级分类</span>
- {/if}
- <span class="editSecond ml10 itemText" data-val="{$v.title}" data-id='{$v.id}'>编辑分类</span>
- <span class="deleteSecond ml10" data-id='{$v.id}'>删除分类</span>
- </div>
- {notempty name='$v.child'}
- {volist name='$v.child' id='vo'}
- <div class="secondBox">
- {if condition="$vo.title eq '小区'"}
- <div class="layui-btn layui-btn-normal layui-btn-sm relative itemText" data-val='{$vo.title}' data-id='{$vo.id}'>
- {$vo.title}
- <i class="layui-icon layui-icon-close-fill layicons" data-id='{$vo.id}'></i>
- </div>
- <div class="layui-btn layui-btn-primary layui-btn-sm ml10 addElement" data-id='{$vo.id}'>+添加小区</div>
- {elseif($vo.title == '风格')/}
- <div class="layui-btn layui-btn-normal layui-btn-sm relative itemText" data-val='{$vo.title}' data-id='{$vo.id}'>
- {$vo.title}
- <i class="layui-icon layui-icon-close-fill layicons" data-id='{$vo.id}'></i>
- </div>
- <div class="layui-btn layui-btn-primary layui-btn-sm ml10 addElement" data-id='{$vo.id}'>+添加风格</div>
- {elseif($vo.title == '户型')/}
- <div class="layui-btn layui-btn-normal layui-btn-sm relative itemText" data-val='{$vo.title}' data-id='{$vo.id}'>
- {$vo.title}
- <i class="layui-icon layui-icon-close-fill layicons" data-id='{$vo.id}'></i>
- </div>
- <div class="layui-btn layui-btn-primary layui-btn-sm ml10 addElement" data-id='{$vo.id}'>+添加户型</div>
- {else/}
- <div class="layui-btn layui-btn-normal layui-btn-sm relative itemText" data-val='{$vo.title}' data-id='{$vo.id}'>
- {$vo.title}
- <i class="layui-icon layui-icon-close-fill layicons" data-id='{$vo.id}'></i>
- </div>
- <div class="layui-btn layui-btn-primary layui-btn-sm ml10 addElement" data-id='{$vo.id}'>+添加</div>
- {/if}
-
- <div class="layContentBox">
- {notempty name='$vo.child'}
- {volist name='$vo.child' id='v2'}
- <div class="layui-btn layui-btn-primary layui-btn-sm itemText" data-val='{$v2.title}' data-id='{$v2.id}'>{$v2.title}
- <i class="layui-icon layui-icon-close-fill layicon" data-id='{$v2.id}'></i>
- </div>
- {/volist}
- {/notempty}
- </div>
- </div>
-
- {/volist}
- {/notempty}
- </div>
- {/volist}
- {else/}
- <span>请先添加分类</span>
- {/notempty}
- <div>
- </div>
- <div class="width56_ fixedbtn">
- <span class="newCate12">+新建分类</span>
- <div>
- <button type="button" lay-submit class="layui-btn layui-btn-normal pdlr30"
- lay-filter="spellgroup-submit" id="spellgroup-submit">确定</button>
- <button type="button" class="layui-btn layui-btn-primary pdlr30 cancel">取消</button>
- </div>
- </div>
- </form>
- </div>
- </body>
- {/block} {block name="js"}
- <script>
- layui.config({
- base: '__LAYUI__/',
- urlbase: '/sys'
- }).extend({
- index: 'lib/index' //主入口模块
- }).use(['index', 'form', 'upload'], function () {
- var $ = layui.$,
- layer = layui.layer,
- upload = layui.upload,
- form = layui.form;
- var type = '{$type}';//模块
- console.log(type)
- var pid = '{$pid}';//一级父id
- //添加保存
- form.on('submit(spellgroup-submit)', function (data) {
- var formData = new FormData(data.form);
- var index = parent.layer.getFrameIndex(window.name);
- parent.layui.table.reload('dev-table'); //重载表格
- parent.layer.close(index); //再执行关闭
- return false;
- });
- $('.cancel').click(function () {
- var index = parent.layer.getFrameIndex(window.name);
- parent.layer.close(index);
- })
- $('.newCate12').click(function () {
- window.parent.addnewtagfunc();
- })
- //添加三级分类
- $('.addElement').click(function () {
- var p_pid = $(this).data('id');
- layer.prompt({
- title: "添加",
- value: '',
- area: ['800px', '350px'] //自定义文本域宽高
- }, function (value, index, elem) {
- if (value == '') {
- layer.msg('请输入分类名称', { anim: 6, time: 1000 });
- return false;
- }
- if (value.length > 20) {
- layer.msg('分类名称超长', { anim: 0, time: 1000 });
- return false;
- }
- $.ajax({
- url: '{:url("smartScreen/saveCate")}',
- type: 'post',
- data: { title: value, level: 3, type: type, pid: p_pid },
- dataType: 'json',
- success: function (res) {
- if (res.code === 0) {
- layer.msg(res.msg, {
- anim: 0
- , time: 1500
- }, function () {
- layer.close(index);
- location.reload();
- });
- } else {
- layer.msg(res.msg, {
- anim: 6
- , time: 2000
- });
- }
- }
- });
- });
- })
- $('.addSecond').click(function() {
- var ppid = $(this).data('id');
- layer.prompt({
- title: "添加二级分类",
- value: '',
- area: ['800px', '350px'] //自定义文本域宽高
- }, function (value, index, elem) {
- if (value == '') {
- layer.msg('请输入分类名称', { anim: 6, time: 1000 });
- return false;
- }
- if (value.length > 20) {
- layer.msg('分类名称超长', { anim: 0, time: 1000 });
- return false;
- }
-
- $.ajax({
- url: '{:url("smartScreen/saveCate")}',
- type: 'post',
- data: {title:value,level:2,type:type,pid:ppid},
- dataType: 'json',
- success: function(res) {
- if(res.code === 0) {
- layer.msg(res.msg, {
- anim: 0
- ,time: 1000
- }, function() {
- layer.close(index);
- location.reload();
- });
- } else {
- layer.msg(res.msg, {
- anim: 6
- , time: 1000
- });
- }
- }
- });
- });
- })
- $('.addSeconds').click(function() {
- var ppid = $(this).data('id');
- layer.prompt({
- title: "添加分类",
- value: '',
- area: ['800px', '350px'] //自定义文本域宽高
- }, function (value, index, elem) {
- if (value == '') {
- layer.msg('请输入分类名称', { anim: 6, time: 1000 });
- return false;
- }
- if (value.length > 20) {
- layer.msg('分类名称超长', { anim: 0, time: 1000 });
- return false;
- }
-
- $.ajax({
- url: '{:url("smartScreen/saveCate")}',
- type: 'post',
- data: {title:value,level:2,type:type,pid:ppid},
- dataType: 'json',
- success: function(res) {
- if(res.code === 0) {
- layer.msg(res.msg, {
- anim: 0
- ,time: 1000
- }, function() {
- layer.close(index);
- location.reload();
- });
- } else {
- layer.msg(res.msg, {
- anim: 6
- , time: 1000
- });
- }
- }
- });
- });
- })
- $('.layicon').click(function (e) {
- var id = $(this).data('id');
- layer.confirm('确定要删除此分类么?', function () {
- $.get("{:url('smartScreen/delCate')}?id=" + id, function (res) {
- if (res.code === 0) {
- layer.msg(res.msg, { anim: 0 , time: 1000}, function () {
- location.reload();
- });
- } else {
- layer.msg(res.msg, { anim: 6 , time: 1000});
- }
- });
- });
- e.stopPropagation();
- })
- //删除二级
- $('.layicons').click(function (e) {
- var id = $(this).data('id');
- layer.confirm('确定要删除此分类么?', function () {
- $.get("{:url('smartScreen/delCate2')}?id=" + id, function (res) {
- if (res.code === 0) {
- layer.msg(res.msg, { anim: 0 , time: 1000}, function () {
- location.reload();
- });
- } else {
- layer.msg(res.msg, { anim: 6 , time: 1000});
- }
- });
- });
- e.stopPropagation();
- })
- $('.itemText').click(function (e) {
- var id = $(this).data('id');
- var title = $(this).data('val');
- layer.prompt({
- title: "编辑",
- value: title,
- area: ['800px', '350px'] //自定义文本域宽高
- }, function (value, index, elem) {
- if (value == '') {
- layer.msg('请输入分类名称', { anim: 6, time: 1000 });
- return false;
- }
- if (value.length > 20) {
- layer.msg('分类名称超长', { anim: 0, time: 1000 });
- return false;
- }
- $.ajax({
- url: '{:url("smartScreen/editCate")}',
- type: 'post',
- data: { title: value, id: id },
- dataType: 'json',
- success: function (res) {
- if (res.code === 0) {
- layer.msg(res.msg, {
- anim: 0
- , time: 1000
- }, function () {
- layer.close(index);
- location.reload();
- });
- } else {
- layer.msg(res.msg, {
- anim: 6
- , time: 1000
- });
- }
- }
- });
- });
- });
- $('.deleteSecond').click(function(e) {
- var id = $(this).data('id');
- layer.confirm('确定要删除此标签么?', function () {
- $.get("{:url('smartScreen/delCate1')}?id=" + id, function (res) {
- if (res.code === 0) {
- layer.msg(res.msg, { anim: 0, time: 1000 }, function () {
- window.parent.reloadPageFunc();
- location.reload();
- });
- } else {
- layer.msg(res.msg, { anim: 6 , time: 1000});
- }
- });
- });
- e.stopPropagation();
- })
- })
- </script>
- {/block}
|