| | |
| | | <div class="layui-inline"> |
| | | <label class="layui-form-label" style="width: 60px;">类别名称</label> |
| | | <div class="layui-input-inline"> |
| | | <input type="text" id="DictName" name="DictName" placeholder="请输入功能名称" autocomplete="off" class="layui-input"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline"> |
| | | <label class="layui-form-label" style="width: 70px;">父级字典号</label> |
| | | <div class="layui-input-inline"> |
| | | <select name="ParentNo" id="ParentNo" lay-verify="" lay-search=""> |
| | | <option value=""></option> |
| | | </select> |
| | | <input type="text" id="CategoryName" name="CategoryName" placeholder="请输入类别名称" autocomplete="off" class="layui-input"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline"> |
| | | <label class="layui-form-label" style="width: 45px;">区域</label> |
| | | <div class="layui-input-inline"> |
| | | <select name="Level" id="Level" lay-verify="" lay-search> |
| | | <select name="AreaNo" id="AreaNo" lay-verify="" lay-search> |
| | | <option value=""></option> |
| | | <option value="0">根目录</option> |
| | | <option value="1">下级目录</option> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | <!-- <div class="layui-inline"> |
| | | <label class="layui-form-label" style="width: 60px;">是否公开</label> |
| | | <div class="layui-input-inline"> |
| | | <select name="IsPublic" id="IsPublic" lay-verify="" lay-search> |
| | | <option value=""></option> |
| | | <option value="0">公开</option> |
| | | <option value="1">不公开</option> |
| | | </select> |
| | | </div> |
| | | </div> --> |
| | | <div class="layui-inline"> |
| | | <label class="layui-form-label" style="width: 60px;">允许编辑</label> |
| | | <div class="layui-input-inline"> |
| | | <select name="IsEdit" id="IsEdit" lay-verify="" lay-search> |
| | | <option value=""></option> |
| | | <option value="0">允许</option> |
| | | <option value="1">不允许</option> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline"> |
| | | <label class="layui-form-label" style="width: 60px;">允许增加</label> |
| | | <div class="layui-input-inline"> |
| | | <select name="IsAdd" id="IsAdd" lay-verify="" lay-search> |
| | | <option value=""></option> |
| | | <option value="0">允许</option> |
| | | <option value="1">不允许</option> |
| | | </select> |
| | | </div> |
| | | </div> |
| | |
| | | </div> |
| | | <div class="layui-card-body"> |
| | | <table id="LAY-app-content-list" lay-filter="LAY-app-content-list"></table> |
| | | <!-- 是否公开 --> |
| | | <script type="text/html" id="buttonIsPublic"> |
| | | {{# if(d.IsPublic=='0'){ }} |
| | | <button class="layui-btn layui-btn-radius layui-btn-xs">公开</button> |
| | | {{# } else if(d.IsPublic=='1') { }} |
| | | <button class="layui-btn layui-btn-radius layui-btn-danger layui-btn-xs">不公开</button> |
| | | {{# } }} |
| | | </script> |
| | | |
| | | <!-- 层级 --> |
| | | <script type="text/html" id="buttonLevel"> |
| | | {{# if(d.Level=='0'){ }} |
| | | <button class="layui-btn layui-btn-radius layui-btn-xs">根目录</button> |
| | | {{# } else if(d.Level=='1') { }} |
| | | <button class="layui-btn layui-btn-radius layui-btn-danger layui-btn-xs">下级目录</button> |
| | | {{# } }} |
| | | </script> |
| | | |
| | | <!-- 允许编辑 --> |
| | | <script type="text/html" id="buttonIsEdit"> |
| | | {{# if(d.IsEdit=='0'){ }} |
| | | <p>允许</p> |
| | | {{# } else if(d.IsEdit=='1') { }} |
| | | <p>不允许</p> |
| | | {{# } }} |
| | | </script> |
| | | |
| | | <!-- 允许添加 --> |
| | | <script type="text/html" id="buttonIsAdd"> |
| | | {{# if(d.IsAdd=='0'){ }} |
| | | <p>允许</p> |
| | | {{# } else if(d.IsAdd=='1') { }} |
| | | <p>不允许</p> |
| | | {{# } }} |
| | | </script> |
| | | <!-- 操作 --> |
| | | <script type="text/html" id="table-content-list"> |
| | | {{# if(d.IsEdit=='0'){ }} |
| | | <a class="layui-btn layui-btn-normal layui-btn-xs approvalBtnupt" lay-event="edit"> |
| | | <i class="layui-icon layui-icon-edit"></i>编辑 |
| | | </a> |
| | | {{# } else if(d.IsEdit=='1') }} |
| | | |
| | | <a class="layui-btn layui-btn-normal layui-btn-xs approvalBtnupt" lay-event="edit"> |
| | | <i class="layui-icon layui-icon-edit"></i>编辑 |
| | | </a> |
| | | <a class="layui-btn layui-btn-danger layui-btn-xs approvalBtndel" lay-event="del"> |
| | | <i class="layui-icon layui-icon-delete"></i>删除 |
| | | </a> |
| | |
| | | |
| | | var tableIns; |
| | | |
| | | //获取父级字典号 |
| | | sendData(IP + "/sys/GetDicParentListByLevel",{},'get',function(res){ |
| | | //获取区域信息 |
| | | sendData(IP + "/sys/GetStorageAreaList",{},'get',function(res){ |
| | | console.log(res) |
| | | if (res.code == 0) //成功 |
| | | { |
| | | parentnohtml = '<option value =""></option>'; |
| | | Areahtml = '<option value =""></option>'; |
| | | for (var i = 0; i < res.data.length; i++) { |
| | | //判断层级不是按钮 |
| | | if (res.data[i].Level == '0') |
| | | { |
| | | //根目录 |
| | | parentnohtml = parentnohtml + '<option value =' + res.data[i].DictNo + '>' + res.data[i].DictName + '</option>' |
| | | } |
| | | //根目录 |
| | | Areahtml = Areahtml + '<option value =' + res.data[i].AreaNo + '>' + res.data[i].AreaName + '</option>' |
| | | } |
| | | $("#ParentNo").append(parentnohtml); |
| | | $("#AreaNo").append(Areahtml); |
| | | form.render('select'); |
| | | } |
| | | }) |
| | | |
| | | function refreshTable(DictName,DictNo,Level,IsEdit,IsAdd) { |
| | | function refreshTable(CategoryName,AreaNo) { |
| | | var param = { |
| | | DictName: DictName, |
| | | DictNo: DictNo, |
| | | Level: Level, |
| | | IsEdit: IsEdit, |
| | | IsAdd: IsAdd |
| | | CategoryName: CategoryName, |
| | | AreaNo: AreaNo, |
| | | }; |
| | | console.log(param) |
| | | |
| | | sendData(IP + "/Sys/GetDicList?DictName="+DictName+"&&DictNo="+DictNo+"&&Level="+Level+"&&IsEdit="+IsEdit+"&&IsAdd="+IsAdd, {}, 'get', function(res) { |
| | | if (res.code == 0) { //成功 |
| | | sendData(IP + "/Sys/GetMaterialCategories", param, 'get', function(res) { |
| | | if (res.code == 1) { //成功 |
| | | var list = res.data; |
| | | $.extend(infoOptions, { |
| | | data: list |
| | |
| | | } |
| | | else //不成功 |
| | | { |
| | | layer.msg('获取字典列表信息失败!', { |
| | | layer.msg(res.msg, { |
| | | icon: 2, |
| | | time: 2000 //2秒关闭(如果不配置,默认是3秒) |
| | | }, function() {}); |
| | |
| | | }); |
| | | if (res.code == 0) { //成功 |
| | | for (var k = 0; k < res.data.length; k++) { |
| | | if (res.data[k].MenuName == "添加字典") { |
| | | if (res.data[k].MenuName == "新增类别") { |
| | | $(function() { |
| | | $("#approvalBtn").show(); |
| | | }); |
| | | } |
| | | if (res.data[k].MenuName == "删除字典") { |
| | | if (res.data[k].MenuName == "删除类别") { |
| | | $(function() { |
| | | $(".approvalBtndel").show(); |
| | | }); |
| | | } |
| | | if (res.data[k].MenuName == "编辑字典") { |
| | | if (res.data[k].MenuName == "编辑类别") { |
| | | console.log(1) |
| | | $(function() { |
| | | $(".approvalBtnupt").show(); |
| | | }); |
| | |
| | | title: '序号', type: 'numbers', fixed: 'left', width:65 |
| | | }, |
| | | { |
| | | field: 'DictNo', title: '字典编号', align: 'center', fixed: 'left' |
| | | field: 'CategoryNo', title: '类别编号', align: 'center', fixed: 'left',width:100 |
| | | }, |
| | | { |
| | | field: 'DictName', title: '字典名称', align: 'center' |
| | | field: 'CategoryName', title: '类别名称', align: 'center',width:100 |
| | | }, |
| | | { |
| | | field: 'ParentNo', title: '父级字典号', align: 'center' |
| | | field: 'AreaName', title: '绑定区域', align: 'center' |
| | | }, |
| | | // { |
| | | // field: 'WareHouseName', title: '所属仓库', align: 'center' |
| | | // }, |
| | | { |
| | | field: 'Ord', title: '显示顺序', align: 'center' |
| | | field: 'Demo', title: '备注', align: 'center' |
| | | }, |
| | | { |
| | | field: 'Level', title: '层级', align: 'center', templet: '#buttonLevel' |
| | | }, |
| | | { |
| | | field: 'IsPublic', templet: '#buttonIsPublic', title: '是否公开', align: 'center' |
| | | }, |
| | | { |
| | | field: 'IsEdit', title: '允许编辑', align: 'center', templet: '#buttonIsEdit' |
| | | }, |
| | | { |
| | | field: 'IsAdd', title: '允许增加', align: 'center', templet: '#buttonIsAdd' |
| | | }, |
| | | { |
| | | field: 'CreateName', title: '创建人', align: 'center' |
| | | field: 'CreateName', title: '创建人', align: 'center',width:100 |
| | | }, |
| | | { |
| | | field: 'CreateTime', title: '创建日期', align: 'center', |
| | | templet: function (d) { |
| | | return formatDate(d.CreateTime); |
| | | } |
| | | },width:165 |
| | | }, |
| | | { |
| | | field: 'UpdateName', title: '更改人', align: 'center',width:100 |
| | | }, |
| | | { |
| | | field: 'UpdateTime', title: '更改日期', align: 'center', |
| | | templet: function (d) { |
| | | return formatDate(d.UpdateTime); |
| | | },width:165 |
| | | }, |
| | | { |
| | | title: '操作', fixed: 'right', align: 'center', width: 200 , toolbar: '#table-content-list' |
| | |
| | | |
| | | //监听搜索 |
| | | form.on('submit(LAY-app-contlist-search)', function(data) { |
| | | console.log(data) |
| | | var DictName = data.field.DictName; |
| | | var DictNo = data.field.ParentNo; |
| | | var Level = data.field.Level; |
| | | var IsEdit = data.field.IsEdit; |
| | | var IsAdd = data.field.IsAdd; |
| | | refreshTable(DictName,DictNo,Level,IsEdit,IsAdd); |
| | | console.log(data.field) |
| | | var CategoryName = data.field.CategoryName; |
| | | var AreaNo = data.field.AreaNo; |
| | | refreshTable(CategoryName,AreaNo); |
| | | }); |
| | | var doing = true; |
| | | var $ = layui.$, |
| | |
| | | add: function() { |
| | | layer.open({ |
| | | type: 2, |
| | | title: '添加字典信息', |
| | | content: 'DictionaryForm.html', |
| | | title: '添加类别信息', |
| | | content: 'CategoryForm.html', |
| | | maxmin: true, |
| | | area: ['530px', '530px'], |
| | | btn: ['确定', '取消'], |
| | |
| | | var field = data.field; //获取提交的字段 |
| | | //提交 Ajax 成功后,静态更新表格中的数据 |
| | | var param = { |
| | | DictNo: field.DictNo, //字典编号 |
| | | DictName: field.DictName, //字典名称 |
| | | ParentNo: field.ParentNo, //父级字典号 |
| | | Ord: field.Ord, //显示顺序 |
| | | Level: field.Level, //层级 |
| | | IsPublic: field.IsPublic, //是否公开 |
| | | IsEdit: field.IsEdit, //允许编辑 |
| | | IsAdd: field.IsAdd //允许添加 |
| | | CategoryNo: field.CategoryNo, //区域编号 |
| | | CategoryName: field.CategoryName, //类别名称 |
| | | AreaNo: field.select, //区域编码 |
| | | Demo: field.Demo, //备注 |
| | | }; |
| | | if(field.Level == '1') |
| | | { |
| | | if(field.ParentNo == '') |
| | | { |
| | | layer.msg("当层级为子级时,父级目录不可为空!", { |
| | | icon: 2, |
| | | time: 2000 //2秒关闭(如果不配置,默认是3秒) |
| | | }, function() {doing = true;}); |
| | | } |
| | | else |
| | | { |
| | | console.log(11) |
| | | if(doing){ |
| | | doing = false; |
| | | sendData(IP + "/sys/AddDic", param, 'post',function(res) { |
| | | console.log(res); |
| | | if (res.code == 0) { //成功 |
| | | layer.msg(res.msg, { |
| | | icon: 1, |
| | | time: 2000 //2秒关闭(如果不配置,默认是3秒) |
| | | }, function() { |
| | | layer.close(index); //关闭弹层 |
| | | refreshTable($("#DictName").val(),$("#ParentNo").val(),$("#Level").val(), $("#IsEdit").val(), $("#IsAdd").val()); |
| | | doing = true; |
| | | }); |
| | | } |
| | | else |
| | | { //不成功 |
| | | layer.msg(res.msg, { |
| | | icon: 2, |
| | | time: 2000 //2秒关闭(如果不配置,默认是3秒) |
| | | }, function() {doing = true;}); |
| | | } |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | console.log(123); |
| | | } |
| | | } |
| | | } |
| | | |
| | | }); |
| | | if(doing){ |
| | | doing = false; |
| | | sendData(IP + "/sys/InsertMaterialCategories", param, 'post',function(res) { |
| | | console.log(res); |
| | | if (res.code == 1) { //成功 |
| | | layer.msg(res.msg, { |
| | | icon: 1, |
| | | time: 2000 //2秒关闭(如果不配置,默认是3秒) |
| | | }, function() { |
| | | layer.close(index); //关闭弹层 |
| | | refreshTable($("#CategoryName").val(),$("#AreaNo").val()); |
| | | doing = true; |
| | | }); |
| | | } |
| | | else |
| | | { //不成功 |
| | | layer.msg(res.msg, { |
| | | icon: 2, |
| | | time: 2000 //2秒关闭(如果不配置,默认是3秒) |
| | | }, function() {doing = true;}); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | submit.trigger('click'); |
| | | } |
| | | }); |
| | |
| | | } |
| | | } |
| | | var uid = $.cookie('userId'); |
| | | refreshTable("","","","",""); |
| | | refreshTable("",""); |
| | | table.on('tool(LAY-app-content-list)', function(obj) { |
| | | var data = obj.data; |
| | | // console.log(obj.data) |
| | | //删除 |
| | | if (obj.event === 'del') |
| | | { |
| | | layer.confirm('确定删除选中的字典?', function(index) { |
| | | // console.log(data); |
| | | layer.confirm('确定删除选中的类别?', function(index) { |
| | | |
| | | cusid = data.Id; |
| | | console.log(cusid); |
| | | var arr = []; |
| | | arr.push(cusid); //属性 |
| | | |
| | | var param = { |
| | | Ids: arr |
| | | Id: cusid |
| | | }; |
| | | console.log(param); |
| | | // arr.push(param); |
| | | if(doing) |
| | | { |
| | | doing = false; |
| | | sendData(IP + "/sys/DelDic?Id="+data.Id+"", {} , 'get', function(res) { |
| | | sendData(IP + "/sys/DeleteMaterialCategories", param , 'post', function(res) { |
| | | console.log(res); |
| | | if (res.code == 0) |
| | | if (res.code == 1) |
| | | { //成功 |
| | | layer.msg(res.msg, { |
| | | icon: 1, |
| | | time: 2000 //2秒关闭(如果不配置,默认是3秒) |
| | | }, function() { |
| | | refreshTable($("#DictName").val(),$("#ParentNo").val(),$("#Level").val(), $("#IsEdit").val(), $("#IsAdd").val()); |
| | | refreshTable($("#CategoryName").val(),$("#AreaNo").val()); |
| | | //table.reload('LAY-app-content-list'); //数据刷新 |
| | | doing = true; |
| | | }); |
| | |
| | | cusId = data.Id; |
| | | layer.open({ |
| | | type: 2, |
| | | title: '编辑字典信息', |
| | | content: 'DictionaryForm.html?id=' + cusId, |
| | | title: '编辑类别信息', |
| | | content: 'CategoryForm.html?id=' + cusId, |
| | | maxmin: true, |
| | | area: ['500px', '450px'], |
| | | area: ['530px', '530px'], |
| | | btn: ['确定', '取消'], |
| | | yes: function(index, layero) { |
| | | var iframeWindow = window['layui-layer-iframe' + index], |
| | |
| | | //提交 Ajax 成功后,静态更新表格中的数据 |
| | | var param = { |
| | | Id: cusId, |
| | | DictNo: field.DictNo, |
| | | DictName: field.DictName, |
| | | ParentNo: field.ParentNo, |
| | | Ord: field.Ord, |
| | | Level: field.Level, |
| | | IsPublic: field.IsPublic, |
| | | IsEdit: field.IsEdit, |
| | | IsAdd: field.IsAdd |
| | | CategoryNo: field.CategoryNo, //区域编号 |
| | | CategoryName: field.CategoryName, //类别名称 |
| | | AreaNo: field.select, //区域编码 |
| | | Demo: field.Demo, //备注 |
| | | }; |
| | | if(doing) |
| | | { |
| | | doing = false; |
| | | sendData(IP + "/sys/ExitDic", param, 'post', |
| | | sendData(IP + "/sys/ExitMaterialCategories", param, 'post', |
| | | function(res) { |
| | | if (res.code == 0) |
| | | if (res.code == 1) |
| | | { //成功 |
| | | layer.msg("修改成功", { |
| | | icon: 1, |
| | | time: 1000 //2秒关闭(如果不配置,默认是3秒) |
| | | }, function() { |
| | | layer.close(index); //关闭弹层 |
| | | refreshTable($("#DictName").val(),$("#ParentNo").val(),$("#Level").val(), $("#IsEdit").val(), $("#IsAdd").val()); |
| | | refreshTable($("#CategoryName").val(),$("#AreaNo").val()); |
| | | //table.reload('LAY-app-content-list'); //数据刷新 |
| | | doing = true; |
| | | }); |