You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
187 lines
6.5 KiB
187 lines
6.5 KiB
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Demo</title>
|
|
<!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
|
|
<link href="../../static/layui/css/layui.css" rel="stylesheet">
|
|
|
|
<style>
|
|
.layui-input-block {
|
|
margin-left: 110px;
|
|
min-height: 36px;
|
|
width: 416px;
|
|
}
|
|
|
|
.layui-input-block {
|
|
margin-left: 72px;
|
|
min-height: 36px;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body class="layui-form">
|
|
<div class="layui-form-item" style="margin-top: 10px;">
|
|
<label class="layui-form-label" style="width: auto;">资源:</label>
|
|
<div class="layui-input-block" id="zyView">
|
|
</div>
|
|
<script id="zyScript" type="text/html">
|
|
<select id="zy" lay-filter="zy">
|
|
{{# layui.each(d, function(index, item){ }}
|
|
<option value="{{item.resource_type_code}}">{{item.resource_type_name}}</option>
|
|
{{# }); }}
|
|
</select>
|
|
</script>
|
|
</div>
|
|
<div id="ID-transfer-demo-showSearch" style="margin: 10px 0 0 10px;"></div>
|
|
|
|
<!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
|
|
<script src="../../static/layui/layui.js"></script>
|
|
<script>
|
|
layui.use(function () {
|
|
var form = layui.form;
|
|
var $ = layui.jquery;
|
|
var laytpl = layui.laytpl;
|
|
var transfer = layui.transfer;
|
|
|
|
var person_id = GetQueryString("person_id");
|
|
var duty_id = GetQueryString("duty_id");
|
|
|
|
var _transferValue = [];
|
|
|
|
//学部
|
|
$.ajax({
|
|
type: "GET",
|
|
async: false,
|
|
url: "/dsBase/dataAuthority/getResouceTypeList",
|
|
success: function (res) {
|
|
var zyTpl = zyScript.innerHTML;
|
|
var zyView = document.getElementById('zyView');
|
|
laytpl(zyTpl).render(res.data, function (html) {
|
|
zyView.innerHTML = html;
|
|
});
|
|
form.render();
|
|
}
|
|
});
|
|
|
|
localTransferValue();
|
|
function localTransferValue() {
|
|
$.ajax({
|
|
type: "GET",
|
|
async: false,
|
|
url: "/dsBase/dataAuthority/getPersonDutyResources?resource_type_code=" + $("#zy").val() + "&person_id=" + person_id + "&duties_id=" + duty_id,
|
|
success: function (res) {
|
|
if (res.count > 0) {
|
|
_transferValue = res.data.map(item => item.resource_id);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
$.ajax({
|
|
type: "GET",
|
|
async: false,
|
|
url: "/dsBase/dataAuthority/getResouceTypeList",
|
|
success: function (res) {
|
|
var zyTpl = zyScript.innerHTML;
|
|
var zyView = document.getElementById('zyView');
|
|
laytpl(zyTpl).render(res.data, function (html) {
|
|
zyView.innerHTML = html;
|
|
});
|
|
form.render();
|
|
}
|
|
});
|
|
|
|
localTransfer($("#zy").val());
|
|
|
|
|
|
form.on('select(zy)', function (data) {
|
|
localTransferValue();
|
|
localTransfer(data.value);
|
|
});
|
|
|
|
|
|
function localTransfer(res_code) {
|
|
$.ajax({
|
|
type: "GET",
|
|
async: false,
|
|
url: "/dsBase/dataAuthority/getResourceListByTypeCode?resource_type_code=" + res_code,
|
|
success: function (res) {
|
|
transfer.render({
|
|
elem: '#ID-transfer-demo-showSearch',
|
|
data: res.data,
|
|
value: _transferValue,
|
|
title: ['未配置', '已配置'],
|
|
showSearch: true,
|
|
onchange: function (data, index) {
|
|
if (index === 0) {
|
|
addDutyRes(data);
|
|
} else {
|
|
delDutyRes(data);
|
|
}
|
|
},
|
|
parseData: function (res) { // 解析成规定的 data 格式
|
|
return {
|
|
"value": res.resource_id,
|
|
"title": res.resource_name
|
|
};
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
function addDutyRes(ids) {
|
|
|
|
var resIds = ids.map(item => item.value).join(',');
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
async: false,
|
|
dataType: "json",
|
|
url: "/dsBase/dataAuthority/addPersonDutyResource",
|
|
data: {
|
|
"person_id": person_id,
|
|
"resource_type_code": $("#zy").val(),
|
|
"duties_id": duty_id,
|
|
"resource_ids": resIds
|
|
}
|
|
});
|
|
}
|
|
|
|
function delDutyRes(ids) {
|
|
var resIds = ids.map(item => item.value).join(',');
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
async: false,
|
|
dataType: "json",
|
|
url: "/dsBase/dataAuthority/delPersonDutyResource",
|
|
data: {
|
|
"person_id": person_id,
|
|
"resource_type_code": $("#zy").val(),
|
|
"duties_id": duty_id,
|
|
"resource_ids": resIds
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
function GetQueryString(name, istop) {
|
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
|
var r = window.location.search.substr(1).match(reg);
|
|
if (typeof (istop) != "undefined") r = top.location.search.substr(1).match(reg);
|
|
|
|
if (r != null) return unescape(r[2]);
|
|
return null;
|
|
}
|
|
|
|
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html> |