<!DOCTYPE html>
|
<html>
|
<head>
|
<meta charset="utf-8" />
|
<title>新增/编辑角色</title>
|
<meta name="renderer" content="webkit">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
|
<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
|
<script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
|
<script src="../../../layuiadmin/layui/layui.js"></script>
|
<script src="../../../layuiadmin/Scripts/json2.js"></script>
|
<script src="../../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
|
<script src="../../../layuiadmin/Scripts/webConfig.js"></script>
|
<script src="../../../layuiadmin/PubCustom.js"></script>
|
<style>
|
.main-btn { /*头部主按钮*/
|
padding: 0 2px; /*调整按钮左右空隙大小*/
|
height: 30px;
|
line-height: 30px;
|
}
|
|
.btn-title {
|
font-size: 16px;
|
}
|
/* 防止下拉框的下拉列表被隐藏---必须设置--- */
|
.layui-table-cell {
|
overflow: visible !important;
|
}
|
/* 使得下拉框与单元格刚好合适 */
|
td .layui-form-select {
|
margin-top: -10px;
|
margin-left: -15px;
|
margin-right: -15px;
|
}
|
|
.layui-form-item .layui-inline {
|
margin-top: 5px;
|
margin-bottom: 5px;
|
margin-right: 0px;
|
}
|
|
.layui-form-label {
|
width: 25%;
|
}
|
</style>
|
|
</head>
|
<body>
|
<div class="layui-fluid" style="padding: 0;">
|
<div class="layui-card" style="padding: 2px;background-color: #efefef;">
|
<div class="layui-card-body" style="padding: 1px;">
|
<form class="layui-form" action="" lay-filter="formData" style="background-color:white;">
|
<div style="padding: 10px; ">
|
<button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnSave" id="btnSave">保存</button>
|
<button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button" lay-submit="" lay-filter="btnEdit" id="btnEdit">退出</button>
|
</div>
|
<div class="layui-tab" lay-filter="tab-POStockInBill">
|
<ul class="layui-tab-title" lay-filter="tab-all">
|
<li lay-id="1" style="padding:1px;" class="layui-this">基本信息</li>
|
</ul>
|
<div class="layui-tab-content">
|
<!--基本信息-->
|
<div class="layui-tab-item layui-show">
|
<div class="layui-form-item" style="padding-top: 10px;">
|
<div class="layui-row">
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">角色名</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="GroupName" lay-verify="GroupName" id="GroupName" value="">
|
<input type="hidden" class="layui-input" name="HGroupID" lay-verify="HGroupID" id="HGroupID" value="0">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">级别</label>
|
<div class="layui-input-block" style="margin-left: 120px; width: 185px;">
|
<select name="HLev" id="HLev" lay-verify="HLev">
|
<option value="总经理级">总经理</option>
|
<option value="副总级">副总经理</option>
|
<option value="质量总监">质量总监</option>
|
<option value="部长级">部长级</option>
|
<option value="主管级">主管级</option>
|
<option value="工程师">工程师</option>
|
<option value="班组长级">班组长级</option>
|
<option value="组员级">组员级</option>
|
</select>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label">对应组织</label>
|
<div class="layui-input-block" style="margin-left: 120px; width: 185px;">
|
<input type="hidden" class="layui-input" lay-verify="HCREATEORGID" name="HCREATEORGID" id="HCREATEORGID">
|
<select name="HUSEORGID" id="HUSEORGID" lay-verify="HUSEORGID">
|
<!--动态渲染组织-->
|
</select>
|
</div>
|
</div>
|
<div class="layui-inline" style="width: 45%;">
|
<label class="layui-form-label" style="width: 85px;">说明</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="Explain" id="Explain" lay-verify="Explain" placeholder="请输入内容" onmouseover="this.title=this.value">
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
|
<table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
|
</form>
|
</div>
|
</div>
|
</div>
|
<script>
|
|
layui.config({
|
base: '../../../layuiadmin/' //静态资源所在路径
|
}).extend({
|
index: 'lib/index' //主入口模块
|
}).use(['index', 'form', 'laydate', 'table', 'element', 'laydate'], function () {
|
|
//#region 公共变量
|
|
var $ = layui.$
|
, admin = layui.admin
|
, layer = layui.layer
|
, table = layui.table
|
, form = layui.form
|
, element = layui.element
|
, laydate = layui.laydate
|
var option = [];
|
//#endregion
|
|
//#region 进入页面即加载
|
|
//初始化
|
set_ClearBill();
|
Organ();
|
|
var params = getUrlVars();
|
var OperationType = params[params[0]]; //从参数中获取 数据类型 1添加 保存 2复制 3 编辑
|
var linterid = params[params[1]]; //从参数中获取 单据内码
|
|
var linterid_copy = params[params[1]]; //如果为复制操作,记录 被复制单据 的内码
|
|
if (linterid == null || linterid == 0) {
|
OperationType = 1;
|
linterid = 0;
|
} else if (OperationType == 2) { //复制
|
RoadBillMain(linterid);
|
linterid = 0;
|
}
|
else {//如果修改则走下面
|
RoadBillMain(linterid);
|
}
|
|
//#endregion
|
|
//#region 触发事件:包括form.on(){}格式的所有点击事件、选择事件等
|
|
|
//选择销售订单号按钮
|
|
//退出
|
form.on('submit(btnEdit)', function (data) {
|
if (OperationType == 1 && linterid != "") {
|
Pub_Close(2);
|
} else {
|
Pub_Close(1);
|
}
|
});
|
|
//保存提交
|
form.on('submit(btnSave)', function (data) {//提交
|
if (AllowLoadData(data)) {
|
set_AddNew(data);
|
}
|
});
|
|
//#endregion
|
|
//#region 此页面所有的方法
|
|
// 初始化界面
|
function set_ClearBill() {
|
set_InitGrid();
|
get_Display();
|
}
|
|
function set_InitGrid() {
|
option = {
|
elem: '#mainTable'
|
, height: 600
|
, cellMinWidth: 90
|
, limit: 500
|
, cols: [[
|
{ type: 'checkbox', fixed: 'left' }
|
, { field: 'hmainid', title: '单据ID', hide: true }
|
, { field: '用户编码', title: '用户编码' }
|
, { field: '用户名称', title: '用户名称' }
|
, { field: '对应职员', title: '对应职员' }
|
, { field: '对应保管', title: '对应保管' }
|
, { field: '对应验收', title: '对应验收' }
|
, { field: '对应业务员', title: '对应业务员' }
|
, { field: '对应部门', title: '对应部门' }
|
, { field: '对应仓库', title: '对应仓库' }
|
, { field: '对应调入仓库', title: '对应调入仓库' }
|
, { field: '对应供应商', title: '对应供应商' }
|
, { field: '对应CLOUD账号', title: '对应CLOUD账号' }
|
, { field: '对应CLOUD组织', title: '对应CLOUD组织' }
|
]]
|
}
|
}
|
|
//加载数据到网格
|
function get_Display() {
|
var wait = layer.load();//遮罩
|
$.ajax({
|
url: GetWEBURL() + '/Xt_User/list',
|
type: "GET",
|
data: { "sWhere": "", user: sessionStorage["HUserName"] },
|
success: function (data1) {
|
if (data1.count == 1) {
|
option.data = data1.data;
|
table.render(option);
|
layer.close(wait);
|
get_DisplayUserGroupInfoList();
|
} else {
|
layer.close(wait);
|
layer.alert(data1.code + data1.Message, { icon: 5 });
|
}
|
}, error: function () {
|
layer.close(wait);
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
});
|
}
|
|
//加载绑定角色数据
|
function get_DisplayUserGroupInfoList() {
|
var sWhere = "and GroupId=" + linterid;
|
var wait = layer.load();//遮罩
|
$.ajax({
|
url: GetWEBURL() + '/Xt_UserGroup/UserGroupInfoList',
|
type: "GET",
|
data: { "sWhere": sWhere },
|
success: function (data1) {
|
layer.close(wait);
|
if (data1.count == 1) {
|
if (data1.data.length > 0) {
|
for (var i = 0; i < data1.data.length; i++) {
|
for (var j = 0; j < option.data.length; j++) {
|
if (data1.data[i].UserId == option.data[j]["用户编码"]) {
|
option.data[j]["LAY_CHECKED"] = true;
|
break;
|
}
|
}
|
}
|
table.render(option);
|
}
|
} else {
|
layer.close(wait);
|
layer.alert(data1.code + data1.Message, { icon: 5 });
|
}
|
}, error: function () {
|
layer.close(wait);
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
});
|
}
|
|
//保存HMaker
|
function set_AddNew(data) {
|
|
if (OperationType == 2) {
|
data.field.Explain = data.field.Explain + "#复制原角色ID:" + linterid_copy;
|
}
|
|
var num = [];
|
for (var i = 0; i < table.checkStatus('mainTable').data.length; i++) {
|
num.push(table.checkStatus('mainTable').data[i]["用户编码"]);
|
}
|
|
var sMainStr = JSON.stringify(data.field);
|
var sSubStr = num.toString() == "" ? "-1" : num.toString();
|
var sMainSub = sMainStr + ';' + sSubStr + ';' + OperationType + ";" + sessionStorage["HUserName"];
|
|
var index = layer.load();
|
$.ajax({
|
type: "POST",
|
url: GetWEBURL() + "/Xt_UserGroup/UserGroupInfoEdit",
|
async: true,
|
data: { "sMainSub": sMainSub },
|
dataType: "json",
|
success: function (data) {
|
if (data.count == 1) {
|
$('#btnSave').addClass("layui-btn-disabled").attr("disabled", true);
|
layer.close(index);
|
layer.msg("提交成功");
|
}
|
else {
|
layer.close(index);
|
layer.msg(data.Message, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
|
}
|
},
|
error: function (err) {
|
layer.close(index);
|
layer.msg("错误:" + err, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
|
}
|
});
|
}
|
|
//编辑 页面赋值
|
function RoadBillMain(linterid)//加载表头
|
{
|
var sWhere = " and HGroupID=" + linterid ;
|
$.ajax({
|
url: GetWEBURL() + "/Xt_UserGroup/list",
|
type: "GET",
|
async: false,
|
data: { "sWhere": sWhere},
|
success: function (d) {
|
//主表
|
form.val("formData", {
|
"HGroupID": linterid
|
, "GroupName": d.data[0].角色
|
, "HLev": d.data[0].级别
|
, "Explain": d.data[0].说明
|
, "HUSEORGID": d.data[0].HUSEORGID
|
, "HCREATEORGID": d.data[0].HCREATEORGID
|
});
|
form.render('select');
|
}
|
})
|
}
|
|
//非空验证
|
function AllowLoadData(data) {
|
|
if ($("#GroupName").val() == "") {
|
layer.msg("角色名不能为空!");
|
return false;
|
}
|
|
return true;
|
}
|
|
//获取参数
|
function getUrlVars() {
|
var vars = [], hash;
|
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
for (var i = 0; i < hashes.length; i++) {
|
hash = hashes[i].split('=');
|
vars.push(hash[0]);
|
vars[hash[0]] = hash[1];
|
}
|
return vars;
|
}
|
|
|
//获取组织
|
function Organ() {
|
//获取登录页组织列
|
var Organization = '';
|
$.ajax({
|
type: "get",
|
url: GetWEBURL() + "/Web/GetOrganizations",
|
async: false,
|
success: function (result) {
|
if (result.count == 1) { // 说明验证成功了,
|
var data = result.data;
|
for (var i = 0; i < data.length; i++) {
|
Organization += '<option style="color:blue;" value="' + data[i].ID + '">' + data[i].Name + '</option>';
|
}
|
$("#HUSEORGID").append(Organization);
|
$("#HUSEORGID").val(sessionStorage["OrganizationID"])
|
$("#HCREATEORGID").val(sessionStorage["OrganizationID"])
|
form.render('select');
|
}
|
layer.closeAll("loading");
|
}
|
})
|
}
|
|
|
//#endregion
|
|
});
|
|
|
</script>
|
</body>
|
</html>
|