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.

172 lines
5.5 KiB

var selectedObj = {};
layui.use(['table', 'laytpl', 'form'], function () {
var table = layui.table
, laytpl = layui.laytpl
, form = layui.form;
// 获取父页传来的项目ID
var projectId = GetQueryString("project_id");
var flag = GetQueryString("flag");
if (flag === '2') { //更换监理
$('#saveNone').hide();
} else if (flag === '3') { //查看监理
$('#saveNone').hide();
$('#save').hide();
}
$("#selectedJlgs").val(selectedObj.orgName);
// 获取项目信息
$.ajax({
type: "GET",
dataType: "json",
url: "/dsBase/gtzz/getSubjectInfo",
data: {
subject_id: projectId
},
success: function (data) {
var projectInfoTpl = projectInfoScript.innerHTML,
projectInfoView = document.getElementById('projectInfoView');
laytpl(projectInfoTpl).render(data, function (html) {
projectInfoView.innerHTML = html;
});
}
});
//获取已选监理公司
$.ajax({
type: "GET",
dataType: "json",
url: "/dsBase/jianli/getSubjectJianLiPersonList",
data: {
subject_id: projectId,
step_code: '0302'
},
success: function (res) {
if (res.count > 0) {
selectedObj = { personId: res.data[0].person_id, orgName: res.data[0].bureau_name }
$("#selectedJlgs").val(res.data[0].bureau_name);
}
}
});
renderTable();
function renderTable() {
table.render({
elem: '#zhuanjiaListTableView'
, url: '/dsBase/jianli/getAllJianLiPersonList'
, cols: [[
{ field: '', title: '序号', align: 'center', type: 'numbers', width: "10%" }
, { align: 'center', field: 'bureau_name', title: '监理公司', }
, { align: 'center', type: 'radio', title: '操作', width: '10%' }
]]
, height: "275"
, parseData: function (res) {
for (var i in res.data) {
if (res.data[i].person_id === selectedObj.personId) {
res.data[i]["LAY_CHECKED"] = true;
}
}
return {
"code": res.code,
"msg": res.msg,
"count": res.count,
"data": res.data
};
}
});
};
table.on('radio(tableFilter)', function (obj) {
var data = obj.data;
selectedObj = { personId: data.person_id, orgName: data.bureau_name };
$("#selectedJlgs").val(data.bureau_name);
});
// 确定(保存)
$("#save").click(function () {
if ($.isEmptyObject(selectedObj)) {
layer.msg("请设置监理公司!", { icon: 2, time: 1500, shade: [0.1, '#000', true] });
return;
}
$.ajax({
type: "POST",
dataType: "json",
url: "/dsBase/jianli/saveSubjectJianLi",
data: {
subject_id: projectId,
step_code: '0302',
person_ids: selectedObj.personId
},
success: function (data) {
if (data.success) {
layer.msg("设置成功", { icon: 1, time: 1300, shade: [0.1, '#000', true] }, function () {
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
window.parent.parentTableRender('0206');
});
} else {
alert(data.message);
}
}
});
});
// 无需分配
$("#saveNone").click(function () {
layer.confirm('是否设置为无需监理?', { icon: 0 }, function (index) {
$.ajax({
type: "POST",
dataType: "json",
url: "/dsBase/jianli/saveSubjectJianLi",
data: {
subject_id: projectId,
step_code: '0302',
person_ids: ""
},
success: function (data) {
if (data.success) {
layer.msg("设置成功", { icon: 1, time: 1300, shade: [0.1, '#000', true] }, function () {
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
window.parent.parentTableRender('0206');
});
} else {
alert(data.message);
}
}
});
layer.close(index);
});
});
// 取消(关闭)
$("#close").click(function () {
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
});
// 获取参数值
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;
}
});