| | |
| | | }) |
| | | |
| | | TSLoad(); |
| | | fetchButtonsData(); |
| | | }); |
| | | function TSLoad() { |
| | | $("#topleft").html(""); |
| | |
| | | html1 += '<span class="layui-icon layui-icon-addition imgicon0" onclick="Add(event,this,1)"></span>'; |
| | | html1 += '</div>'; |
| | | html1 += '</div>'; |
| | | $("#topleft").append(html1); |
| | | $("#topleft").append(html1); |
| | | } |
| | | }, |
| | | error: function (err) { |
| | |
| | | } |
| | | var HManagerID = 0; |
| | | var HGroupID = 0; |
| | | |
| | | //加载当前用户按钮 |
| | | function fetchButtonsData() { |
| | | $.ajax({ |
| | | url: GetWEBURL() + '/ReportPlatForm/getButtonlist', |
| | | type: "GET", |
| | | data: { "user": sessionStorage["HUserName"] }, |
| | | success: function (data1) { |
| | | if (data1.data && data1.data.length > 0) { |
| | | // 清空现有内容 |
| | | $("#button-container").empty(); |
| | | var colClass = ''; // 动态设置列的样式 |
| | | let largestColClass = 'layui-col-md4'; // 默认新增按钮大小(假设最多是 3 个按钮一排) |
| | | |
| | | // 遍历每个按钮数据并生成对应的 HTML |
| | | data1.data.forEach(function (buttonData, index) { |
| | | // 根据 defaultSize 字段选择合适的列宽 |
| | | switch (buttonData.按钮大小) { |
| | | case '小': |
| | | colClass = 'layui-col-md3'; // 一排4个 |
| | | break; |
| | | case '中': |
| | | colClass = 'layui-col-md4'; // 一排3个 |
| | | break; |
| | | case '大': |
| | | colClass = 'layui-col-md6'; // 一排2个 |
| | | break; |
| | | default: |
| | | colClass = 'layui-col-md4'; // 默认设置为中等大小(3个一排) |
| | | } |
| | | |
| | | // 更新最大列宽:取最大列宽 |
| | | if (colClass === 'layui-col-md6') { |
| | | largestColClass = colClass; // 如果当前列宽是 'layui-col-md6',说明是最宽的 |
| | | } else if (colClass === 'layui-col-md4' && largestColClass !== 'layui-col-md6') { |
| | | largestColClass = colClass; // 默认列宽为 'layui-col-md4',小于 'layui-col-md6' |
| | | } else if (colClass === 'layui-col-md3' && largestColClass === 'layui-col-md4') { |
| | | largestColClass = colClass; // 如果当前列宽是 'layui-col-md3',小于 'layui-col-md4' |
| | | } |
| | | |
| | | var html = ''; |
| | | html += '<div class="' + colClass + '" id="btn' + index + '">'; |
| | | html += ' <div class="cnt bottomright" id="button' + index + '" onclick="' + buttonData.事件名称 + '(event, this)">'; |
| | | html += ' <span class="layui-icon ' + buttonData.图标 + ' imgicon"></span>'; |
| | | html += ' <span class="imgtitle">' + buttonData.名称 + '</span>'; |
| | | html += ' </div>'; |
| | | html += ' <span class="layui-icon layui-icon-delete delete" onclick="deleteButton(event, \'' + buttonData.HItemID + '\')"></span>'; // 修改删除按钮事件,传递 id1 和 id2 |
| | | html += '</div>'; |
| | | // 将生成的 HTML 追加到 #button-container |
| | | $("#button-container").append(html); |
| | | }); |
| | | |
| | | // 添加一个新增按钮 |
| | | var html1 = ''; |
| | | html1 += '<div class="layui-col-sm12 ' + largestColClass + '">'; |
| | | html1 += ' <div class="cnt bottomright">'; |
| | | html1 += ' <span class="layui-icon layui-icon-addition imgtitle" onclick="Add_Buttton(event,this,1)"></span>'; |
| | | html1 += ' </div>'; |
| | | html1 += '</div>'; |
| | | |
| | | $("#button-container").append(html1); |
| | | } else { |
| | | // 如果没有按钮数据,展示默认的空白新增按钮 |
| | | var html1 = ''; |
| | | html1 += '<div class="layui-col-sm12 layui-col-md4">'; |
| | | html1 += ' <div class="cnt bottomright">'; |
| | | html1 += ' <span class="layui-icon layui-icon-addition imgtitle" onclick="Add_Buttton(event,this,1)"></span>'; |
| | | html1 += ' </div>'; |
| | | html1 += '</div>'; |
| | | $("#button-container").append(html1); |
| | | } |
| | | }, |
| | | error: function (error) { |
| | | console.log('获取按钮数据失败', error); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 删除按钮的事件处理函数 |
| | | function deleteButton(event, HItemID) { |
| | | event.stopPropagation(); // 防止事件冒泡,避免触发按钮的点击事件 |
| | | //逻辑删除方法 |
| | | layer.confirm("确认要删除吗,删除后不能恢复", { title: "删除确认" }, function (index) { |
| | | $.ajax({ |
| | | url: GetWEBURL() + "/ReportPlatForm/DeleteButtonlist", |
| | | type: "GET", |
| | | data: { "HItemID": HItemID }, |
| | | dataType: "json",//数据类型可以为 text xml json script jsonp |
| | | success: function (data) { |
| | | if (data.count > 0) { |
| | | fetchButtonsData(); //执行查询过程 |
| | | layer.close(index); |
| | | layer.msg(data.Message, { time: 1 * 2000, icon: 1 }); |
| | | return false; |
| | | } |
| | | else { |
| | | layer.alert(data.Message, { time: 1 * 2000, icon: 5 }); |
| | | return false; |
| | | } |
| | | }, |
| | | error: function (err) { |
| | | layer.alert(err.Message, { time: 1 * 2000, icon: 5 }); |
| | | return false; |
| | | } |
| | | }); |
| | | }) |
| | | } |
| | | |
| | | //添加按钮 |
| | | function Add_Buttton(event, obj, i) { |
| | | event.stopPropagation(); //阻止冒泡 |
| | | //页面层-自定义 |
| | | layer.open({ |
| | | type: 2 //此处以iframe举例 |
| | | , title: '按钮绑定' |
| | | , area: ['90%', '90%'] |
| | | , shadeClose: false //开启遮罩关闭 |
| | | , shade: 0.5 |
| | | , maxmin: true |
| | | , content: ['生产管理/报工平台功能页/LineBind_Button.html', 'yes'] |
| | | , btn: ['确定', '取消'] |
| | | , btn1: function (index, layero, e) { |
| | | |
| | | //按钮【按钮一】的回调 |
| | | var body = layer.getChildFrame('body', index); //得到iframe页的body内容 |
| | | |
| | | var HUserName = sessionStorage["HUserName"]; |
| | | var HButtonID = body.find("#HButtonID").val(); |
| | | var HButtonName = body.find("#HName").val(); |
| | | var HButtonSize = body.find("#HButtonSize").val(); |
| | | var HButtonOrder = body.find("#HButtonOrder").val(); |
| | | $.ajax( |
| | | { |
| | | url: GetWEBURL() + "/ReportPlatForm/AddButtonlist", //方法所在页面和方法名 |
| | | dataType: "json", |
| | | type: "Get", |
| | | async: false, |
| | | data: { |
| | | "HUserName": HUserName, |
| | | "HButtonID": HButtonID, |
| | | "HButtonName": HButtonName, |
| | | "HButtonSize": HButtonSize, |
| | | "HButtonOrder": HButtonOrder |
| | | |
| | | }, |
| | | success: function (data) { |
| | | if (data.count == 1) { // 说明验证成功了, |
| | | fetchButtonsData(); //执行查询过程 |
| | | layer.close(index); |
| | | layer.msg(data.Message, { time: 1 * 2000, icon: 1 }); |
| | | return false; |
| | | } |
| | | else { |
| | | layer.close(index); |
| | | layer.alert(data.Message, { icon: 5 }); |
| | | return false; |
| | | |
| | | } |
| | | }, |
| | | error: function (err) { |
| | | layer.alert(err.Message, { time: 1 * 2000, icon: 5 }); |
| | | return false; |
| | | } |
| | | }); |
| | | } |
| | | , btn2: function (index, layero) { |
| | | //按钮【按钮二】的回调 |
| | | //return false 开启该代码可禁止点击该按钮关闭 |
| | | } |
| | | |
| | | , zIndex: layer.zIndex //重点1 |
| | | , success: function (layero, index) { |
| | | |
| | | } |
| | | , end: function () { |
| | | |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | //选中资源 |
| | | function Check(obj, i) { |
| | | wktag = 0; |
| | |
| | | |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | //删除资源 |
| | | function Delete(event, obj, i) { |
| | | event.stopPropagation(); //阻止冒泡 |
| | |
| | | //非空验证 |
| | | function AllowLoadData(body) { //非空验证 |
| | | var Result = true; |
| | | //if (body.find("#HUserName").val() == '' || body.find("#HUserName").val() == null) { |
| | | // layer.msg("用户名不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" }); |
| | | // return Result = false; |
| | | //} |
| | | if (body.find("#HSourceID").val() == '' || body.find("#HSourceID").val() == null) { |
| | | layer.msg("生产资源不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" }); |
| | | return Result = false; |
| | |
| | | <div class="layui-col-sm12 layui-col-md4"> |
| | | <fieldset style="border: 1px solid #eee;box-shadow: 0 2px 5px 0 rgb(0 0 0 / 10%);"> |
| | | <legend style="color: #5FB878">操作台</legend> |
| | | <div class="content4"> |
| | | <div class="layui-row layui-col-space10"> |
| | | <div class="content4" > |
| | | <!--<div class="layui-row layui-col-space10"> |
| | | <div class="layui-col-sm12 layui-col-md4" onclick="OpenWork(event,this)"> |
| | | <div class="cnt bottomright"> |
| | | <span class="layui-icon layui-icon-play imgicon"></span> |
| | |
| | | <span class="layui-icon layui-icon-layer imgicon"></span> |
| | | <span class="imgtitle">异常验收</span> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div>--> |
| | | <div class="layui-row layui-col-space10" id="button-container"> |
| | | |
| | | </div> |
| | | </div> |
| | | </fieldset> |
| | | </div> |