HnRealNameBmwWeb/js/work/basic/SubContractorForm.js

808 lines
34 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var element;
var uploadId;
var nums = 5;
var flag = true;
var form
$(function () {
layui.use(['form', 'laydate', 'upload'], function () {
form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
var laydate = layui.laydate;
var upload = layui.upload;
var id = $("#id").val();
if (id == '') {
getCompanys(form,null);
} else {
}
form.render();
form.verify({
phone: [/(^$)|^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/, '请正确输入联系人电话'],
});
//多图片上传
var uploadcom1 =upload.render({
elem: '#test1',
url: ctxPath + '/SubContractor/uploadFile', //改成您自己的上传接口
multiple: false, //是否允许多文件上传默认未false
dataType: "json",
async:false,
// data: {"pickId": id},
exts: 'jpg|png|jpeg',
//acceptMime: 'image/jpg,image/png,image/jpeg,file/pdf,file/xlsx',
auto: false, //是否自动上传 默认为true
// number: 1, //最大上传数量
size: 1024*5, //最大文件大小单位k
bindAction: '#hideUpload1', //绑定的按钮
field: 'file', //传到后台的字段名,默认file
choose: function (obj) {
flag = false;
var suffixType = ''; //后缀类型
uploadcom1.config.elem.next()[0].value = '';
files = obj.pushFile();
obj.preview(function (index, file, result) {
var length = $('#demo1 img').length;
if (length > 0) {
return layer.msg("附件为1张请勿过多上传", {icon: 5});
}
$("#preview1").css("display","");
$('#demo1').append('<img src="' + result + '" id="' + index + '" alt="' + file.name + '" style="height: 80px;width: 80px;margin-right: 10px" class="layui-upload-img ">');
$('#' + index).bind('dblclick', function () {//双击删除指定预上传图片
delete files[index];//删除指定图片
$(this).remove();
var photoNum = $("#demo1").children().length;
if(photoNum === 0){
$("#preview1").css("display","none");
}
});
});
},
before: function (obj) {
this.data = {
id: uploadId,
accessoryType: "1"
};
if ($("[name='brand']").val() == '') {
return false;
} else {
console.log(files);
var names = '';
layui.each(files, function (index, file) {
console.log(file.name)
names += file.name + ',';
});
$("[name='image']").val(names)
console.log(names);
}
return true;
},
done: function (data) {
nums -= 1;
if(nums == 0 || $("#id").val() != ''){
reloading();
top.layer.msg('保存成功', {icon: 1, time: 2000});
nums = 5;
}
},
allDone: function (data) {
},
error: function (e) {
//请求异常回调
console.log(e)
}
});
//多图片上传
var uploadcom2 =upload.render({
elem: '#test2',
url: ctxPath + '/SubContractor/uploadFile', //改成您自己的上传接口
multiple: false, //是否允许多文件上传默认未false
dataType: "json",
async:false,
// data: {"pickId": id},
exts: 'jpg|png|jpeg',
//acceptMime: 'image/jpg,image/png,image/jpeg,file/pdf,file/xlsx',
auto: false, //是否自动上传 默认为true
// number: 1, //最大上传数量
size: 1024*5, //最大文件大小单位k
bindAction: '#hideUpload2', //绑定的按钮
field: 'file', //传到后台的字段名,默认file
choose: function (obj) {
flag = false;
var suffixType = ''; //后缀类型
uploadcom2.config.elem.next()[0].value = '';
files = obj.pushFile();
obj.preview(function (index, file, result) {
var length = $('#demo2 img').length;
if (length > 0) {
return layer.msg("附件为1张请勿过多上传", {icon: 5});
}
$("#preview2").css("display","");
$('#demo2').append('<img src="' + result + '" id="' + index + '" alt="' + file.name + '" style="height: 80px;width: 80px;margin-right: 10px" class="layui-upload-img ">');
$('#' + index).bind('dblclick', function () {//双击删除指定预上传图片
delete files[index];//删除指定图片
$(this).remove();
var photoNum = $("#demo2").children().length;
if(photoNum === 0){
$("#preview2").css("display","none");
}
});
});
},
before: function (obj) {
this.data = {
id: uploadId,
accessoryType: "2"
};
if ($("[name='brand']").val() == '') {
return false;
} else {
console.log(files);
var names = '';
layui.each(files, function (index, file) {
console.log(file.name)
names += file.name + ',';
});
$("[name='image']").val(names)
console.log(names);
}
return true;
},
done: function (data) {
nums -= 1;
if(nums == 0 || $("#id").val() != ''){
reloading();
top.layer.msg('保存成功', {icon: 1, time: 2000});
nums = 5;
}
},
allDone: function (data) {
},
error: function (e) {
//请求异常回调
console.log(e)
}
});
//多图片上传
var uploadcom3 =upload.render({
elem: '#test3',
url: ctxPath + '/SubContractor/uploadFile', //改成您自己的上传接口
multiple: false, //是否允许多文件上传默认未false
dataType: "json",
async:false,
// data: {"pickId": id},
exts: 'jpg|png|jpeg',
//acceptMime: 'image/jpg,image/png,image/jpeg,file/pdf,file/xlsx',
auto: false, //是否自动上传 默认为true
// number: 1, //最大上传数量
size: 1024*5, //最大文件大小单位k
bindAction: '#hideUpload3', //绑定的按钮
field: 'file', //传到后台的字段名,默认file
choose: function (obj) {
flag = false;
var suffixType = ''; //后缀类型
uploadcom3.config.elem.next()[0].value = '';
files = obj.pushFile();
obj.preview(function (index, file, result) {
var length = $('#demo3 img').length;
if (length > 0) {
return layer.msg("附件为1张请勿过多上传", {icon: 5});
}
$("#preview3").css("display","");
$('#demo3').append('<img src="' + result + '" id="' + index + '" alt="' + file.name + '" style="height: 80px;width: 80px;margin-right: 10px" class="layui-upload-img ">');
$('#' + index).bind('dblclick', function () {//双击删除指定预上传图片
delete files[index];//删除指定图片
$(this).remove();
var photoNum = $("#demo3").children().length;
if(photoNum === 0){
$("#preview3").css("display","none");
}
});
});
},
before: function (obj) {
this.data = {
id: uploadId,
accessoryType: "3"
};
if ($("[name='brand']").val() == '') {
return false;
} else {
console.log(files);
var names = '';
layui.each(files, function (index, file) {
console.log(file.name)
names += file.name + ',';
});
$("[name='image']").val(names)
console.log(names);
}
return true;
},
done: function (data) {
nums -= 1;
if(nums == 0 || $("#id").val() != ''){
reloading();
top.layer.msg('保存成功', {icon: 1, time: 2000});
nums = 5;
}
},
allDone: function (data) {
},
error: function (e) {
//请求异常回调
console.log(e)
}
});
//多图片上传
var uploadcom4 =upload.render({
elem: '#test4',
url: ctxPath + '/SubContractor/uploadFile', //改成您自己的上传接口
multiple: false, //是否允许多文件上传默认未false
dataType: "json",
async:false,
// data: {"pickId": id},
exts: 'jpg|png|jpeg',
//acceptMime: 'image/jpg,image/png,image/jpeg,file/pdf,file/xlsx',
auto: false, //是否自动上传 默认为true
// number: 1, //最大上传数量
size: 1024*5, //最大文件大小单位k
bindAction: '#hideUpload4', //绑定的按钮
field: 'file', //传到后台的字段名,默认file
choose: function (obj) {
flag = false;
var suffixType = ''; //后缀类型
uploadcom4.config.elem.next()[0].value = '';
files = obj.pushFile();
obj.preview(function (index, file, result) {
var length = $('#demo4 img').length;
if (length > 0) {
return layer.msg("附件为1张请勿过多上传", {icon: 5});
}
$("#preview4").css("display","");
$('#demo4').append('<img src="' + result + '" id="' + index + '" alt="' + file.name + '" style="height: 80px;width: 80px;margin-right: 10px" class="layui-upload-img ">');
$('#' + index).bind('dblclick', function () {//双击删除指定预上传图片
delete files[index];//删除指定图片
$(this).remove();
var photoNum = $("#demo4").children().length;
if(photoNum === 0){
$("#preview4").css("display","none");
}
});
});
},
before: function (obj) {
this.data = {
id: uploadId,
accessoryType: "4"
};
if ($("[name='brand']").val() == '') {
return false;
} else {
console.log(files);
var names = '';
layui.each(files, function (index, file) {
console.log(file.name)
names += file.name + ',';
});
$("[name='image']").val(names)
console.log(names);
}
return true;
},
done: function (data) {
nums -= 1;
if(nums == 0 || $("#id").val() != ''){
reloading();
top.layer.msg('保存成功', {icon: 1, time: 2000});
nums = 5;
}
},
allDone: function (data) {
},
error: function (e) {
//请求异常回调
console.log(e)
}
});
//多图片上传
var uploadcom5 =upload.render({
elem: '#test5',
url: ctxPath + '/SubContractor/uploadFile', //改成您自己的上传接口
multiple: false, //是否允许多文件上传默认未false
dataType: "json",
async:false,
// data: {"pickId": id},
exts: 'jpg|png|jpeg',
//acceptMime: 'image/jpg,image/png,image/jpeg,file/pdf,file/xlsx',
auto: false, //是否自动上传 默认为true
// number: 1, //最大上传数量
size: 1024*5, //最大文件大小单位k
bindAction: '#hideUpload5', //绑定的按钮
field: 'file', //传到后台的字段名,默认file
choose: function (obj) {
flag = false;
var suffixType = ''; //后缀类型
uploadcom5.config.elem.next()[0].value = '';
files = obj.pushFile();
obj.preview(function (index, file, result) {
var length = $('#demo5 img').length;
if (length > 0) {
return layer.msg("附件为1张请勿过多上传", {icon: 5});
}
$("#preview5").css("display","");
$('#demo5').append('<img src="' + result + '" id="' + index + '" alt="' + file.name + '" style="height: 80px;width: 80px;margin-right: 10px" class="layui-upload-img ">');
$('#' + index).bind('dblclick', function () {//双击删除指定预上传图片
delete files[index];//删除指定图片
$(this).remove();
var photoNum = $("#demo5").children().length;
if(photoNum === 0){
$("#preview5").css("display","none");
}
});
});
},
before: function (obj) {
this.data = {
id: uploadId,
accessoryType: "5"
};
if ($("[name='brand']").val() == '') {
return false;
} else {
console.log(files);
var names = '';
layui.each(files, function (index, file) {
console.log(file.name)
names += file.name + ',';
});
$("[name='image']").val(names)
console.log(names);
}
return true;
},
done: function (data) {
nums -= 1;
if(nums == 0 || $("#id").val() != ''){
reloading();
top.layer.msg('保存成功', {icon: 1, time: 2000});
nums = 5;
}
},
allDone: function (data) {
},
error: function (e) {
//请求异常回调
console.log(e)
}
});
var uploadcom6 =upload.render({
elem: '#test6',
url: ctxPath + '/SubContractor/uploadFile', //改成您自己的上传接口
multiple: false, //是否允许多文件上传默认未false
dataType: "json",
async:false,
// data: {"pickId": id},
exts: 'jpg|png|jpeg',
//acceptMime: 'image/jpg,image/png,image/jpeg,file/pdf,file/xlsx',
auto: false, //是否自动上传 默认为true
// number: 1, //最大上传数量
size: 1024*5, //最大文件大小单位k
bindAction: '#hideUpload6', //绑定的按钮
field: 'file', //传到后台的字段名,默认file
choose: function (obj) {
flag = false;
var suffixType = ''; //后缀类型
uploadcom6.config.elem.next()[0].value = '';
files = obj.pushFile();
obj.preview(function (index, file, result) {
var length = $('#demo6 img').length;
if (length > 0) {
return layer.msg("附件为1张请勿过多上传", {icon: 5});
}
$("#preview6").css("display","");
$('#demo6').append('<img src="' + result + '" id="' + index + '" alt="' + file.name + '" style="height: 80px;width: 80px;margin-right: 10px" class="layui-upload-img ">');
$('#' + index).bind('dblclick', function () {//双击删除指定预上传图片
delete files[index];//删除指定图片
$(this).remove();
var photoNum = $("#demo6").children().length;
if(photoNum === 0){
$("#preview6").css("display","none");
}
});
});
},
before: function (obj) {
this.data = {
id: uploadId,
accessoryType: "6"
};
if ($("[name='brand']").val() == '') {
return false;
} else {
console.log(files);
var names = '';
layui.each(files, function (index, file) {
console.log(file.name)
names += file.name + ',';
});
$("[name='image']").val(names)
console.log(names);
}
return true;
},
done: function (data) {
nums -= 1;
if(nums == 0 || $("#id").val() != ''){
reloading();
top.layer.msg('保存成功', {icon: 1, time: 2000});
nums = 5;
}
},
allDone: function (data) {
},
error: function (e) {
//请求异常回调
console.log(e)
}
});
// 验证成功后才会执行下面的操作
form.on('submit(formDemo)', function (data) {
var id = $("#id").val();
if (id == '') {
insertSubcontractor(data); // 新增工程
} else {
updateSubcontractor(data);
}
});
//执行一个laydate实例
laydate.render({
elem: '#einTime' //指定元素 元素选择器
, type: 'datetime' //选择时间类型 可选值:year(年) month(年月) date(年月日) time(时分秒) datetime(年月日时分秒)
, trigger: 'click'
, format: 'yyyy-MM-dd' //时间格式 常用时间格式:yyyy-MM-dd HH:mm:ss
// , value: new Date() //初始值 今天
, btns: ['clear', 'now', 'confirm'] //选择框右下角显示的按钮 清除-现在-确定
, done: function (value, date) {//时间回调
console.log(value);
console.log(date);
}
});
laydate.render({
elem: '#updateTime' //指定元素 元素选择器
, type: 'datetime' //选择时间类型 可选值:year(年) month(年月) date(年月日) time(时分秒) datetime(年月日时分秒)
, trigger: 'click'
, format: 'yyyy-MM-dd' //时间格式 常用时间格式:yyyy-MM-dd HH:mm:ss
// , value: new Date() //初始值 今天
, btns: ['clear', 'now', 'confirm'] //选择框右下角显示的按钮 清除-现在-确定
, done: function (value, date) {//时间回调
console.log(value);
console.log(date);
}
});
});
});
//新增分包商
function insertSubcontractor(formData) {
if ($("#companyId").val()=="-1"){
parent.layer.msg("请选择公司", {icon: 2, time: 2000});
}else if($("#demo1").children().length == 0){
parent.layer.msg("请上传营业执照", {icon: 2, time: 2000});
}else if($("#demo2").children().length == 0){
parent.layer.msg("请上传电子公章", {icon: 2, time: 2000});
}
/*else if($("#demo3").children().length == 0){
parent.layer.msg("请上传电子签名/法人印章", {icon: 2, time: 2000});
}*/
else if($("#demo4").children().length == 0){
parent.layer.msg("请上传安全许可证", {icon: 2, time: 2000});
}else if($("#demo5").children().length == 0){
parent.layer.msg("请上传法人身份证照(国徽)", {icon: 2, time: 2000});
}else if($("#demo6").children().length == 0){
parent.layer.msg("法人身份证照(人脸)", {icon: 2, time: 2000});
}else{
var formUrl = ctxPath + "/SubContractor/addSub";
$.ajax({
type: 'POST',
async: true, // 默认异步true,false表示同步
url: formUrl, // 请求地址
contentType: "application/json; charset=utf-8",
dataType: 'json', // 服务器返回数据类型
data: JSON.stringify(formData.field), //获取提交的表单字段
success: function (data) {
console.log(data);
uploadId = data;
if(data == '-1'){
parent.layer.msg('分包商已存在,请重新输入', {icon: 2, time: 2000});
}else{
if (data != "error") {
$("#hideUpload1").trigger("click");
$("#hideUpload2").trigger("click");
// $("#hideUpload3").trigger("click");
$("#hideUpload4").trigger("click");
$("#hideUpload5").trigger("click");
$("#hideUpload6").trigger("click");
} else if (data.resMsg == "保存失败") {
parent.layer.msg('保存失败', {icon: 2, time: 2000});
setTimeout("reloading()", 2100);
} else {
parent.layer.msg(data, {icon: 2, time: 2000});
setTimeout("reloading()", 2100);
}
}
},
error: function (XMLHttpRequest, textStatus, e) {
layer.msg('数据请求发生异常,请稍后重试', {icon: 16, scrollbar: false});
}
});
}
}
//修改分包商
function updateSubcontractor(formData) {
//var formUrl = ctxPath + "/SubContractor/updateSub";
if($("#demo1").children().length = 0){
parent.layer.msg("请上传营业执照", {icon: 2, time: 2000});
}else if($("#demo2").children().length = 0){
parent.layer.msg("请上传电子公章", {icon: 2, time: 2000});
}
/* else if($("#demo3").children().length = 0){
parent.layer.msg("请上传电子签名/法人印章", {icon: 2, time: 2000});
}*/
else if($("#demo4").children().length = 0){
parent.layer.msg("请上传安全许可证", {icon: 2, time: 2000});
}else if($("#demo5").children().length = 0){
parent.layer.msg("请上传法人身份证照(国徽)", {icon: 2, time: 2000});
}else if($("#demo6").children().length = 0){
parent.layer.msg("法人身份证照(人脸)", {icon: 2, time: 2000});
}else{
var formUrl = ctxPath + "/SubContractor/updateSub";
$.ajax({
type: 'POST',
async: true, // 默认异步true,false表示同步
url: formUrl, // 请求地址
contentType: "application/json; charset=utf-8",
data: JSON.stringify(formData.field), //获取提交的表单字段
success: function (data) {
if(data == '-1'){
parent.layer.msg('分包商已存在,请重新输入', {icon: 2, time: 2000});
}else{
if (data != "error") {
if(flag){
reloading();
top.layer.msg('保存成功', {icon: 1, time: 2000});
}
uploadId = $("#id").val();
$("#hideUpload1").trigger("click");
$("#hideUpload2").trigger("click");
// $("#hideUpload3").trigger("click");
$("#hideUpload4").trigger("click");
$("#hideUpload5").trigger("click");
$("#hideUpload6").trigger("click");
} else if (data == "保存失败") {
parent.layer.msg('保存失败', {icon: 2, time: 2000});
setTimeout("reloading()", 2100);
} else {
parent.layer.msg(data, {icon: 2, time: 2000});
setTimeout("reloading()", 2100);
}
}
},
error: function (e) {
console.log("########");
console.log(e);
console.log("########");
layer.msg('数据请求发生异常,请稍后重试', {icon: 16, scrollbar: false});
}
});
}
}
// 表单赋值
function setData(data) {
getCompanyss(data.companyId);
$("#id").val(data.id);
$("#subName").val(data.subName); // 分包商名称
$("#represent").val(data.represent); // 法人代表
$("#reContact").val(data.reContact); // 法人电话
$("#address").val(data.address); // 法人住址
$("#foreman").val(data.foreman); // 班组长
$("#foContact").val(data.foContact); // 班组长电话
$("#einTime").val(data.einTime); // 入场时间
$("#updateTime").val(data.updateTime); // 修改时间
var path1 = dataPath+"/"+data.businessURL; //营业执照
$("#preview1").css("display","");
var demo1 = $("#demo1");
var html = '';
html += '<img src="' + path1 + '" id="1" name="1" ondblclick="delPhoto(1)" style="height: 80px;width: 80px;margin-right: 10px" class="layui-upload-img ">';
demo1.append(html);
var path2 = dataPath+"/"+data.sealURL;
$("#preview2").css("display","");
var demo2 = $("#demo2");
var html = '';
html += '<img src="' + path2 + '" id="2" name="2" ondblclick="delPhoto(2)" style="height: 80px;width: 80px;margin-right: 10px" class="layui-upload-img ">';
demo2.append(html);
var path3 = dataPath+"/"+data.signatureURL;
$("#preview3").css("display","");
var demo3 = $("#demo3");
var html = '';
html += '<img src="' + path3 + '" id="3" name="3" ondblclick="delPhoto(3)" style="height: 80px;width: 80px;margin-right: 10px" class="layui-upload-img ">';
demo3.append(html);
var path4 = dataPath+"/"+data.safetyURL;
$("#preview4").css("display","");
var demo4 = $("#demo4");
var html = '';
html += '<img src="' + path4 + '" id="4" name="4" ondblclick="delPhoto(4)" style="height: 80px;width: 80px;margin-right: 10px" class="layui-upload-img ">';
demo4.append(html);
var path5 = dataPath+"/"+data.idCardJustURL;
$("#preview5").css("display","");
var demo5 = $("#demo5");
var html = '';
html += '<img src="' + path5 + '" id="5" name="5" ondblclick="delPhoto(5)" style="height: 80px;width: 80px;margin-right: 10px" class="layui-upload-img ">';
demo5.append(html);
var path6 = dataPath+"/"+data.idCardBackURL;
$("#preview6").css("display","");
var demo6 = $("#demo6");
var html = '';
html += '<img src="' + path6 + '" id="6" name="6" ondblclick="delPhoto(6)" style="height: 80px;width: 80px;margin-right: 10px" class="layui-upload-img ">';
demo6.append(html);
}
// 设置只读
function setReadOnly() {
$("#subName").attr("readonly", true);
$("#compangId").attr("readonly",true); // 公司名称
$("#represent").attr("readonly", true);
$("#address").attr("readonly", true);
$("#reContact").attr("readonly", true);//分包商法人电话
$("#foreman").attr("readonly", true);//班组长
$("#foContact").attr("readonly", true);//班组长电话
}
// 取消只读
function cancelReadOnly() {
$("#subName").attr("readonly", false);//分包商名称
$("#compangId").attr("readonly",false); // 公司名称
$("#represent").attr("readonly", false);//分包商法人
$("#reContact").attr("readonly", false);//分包商法人电话
$("#address").attr("readonly", false);
$("#foreman").attr("readonly", false);//班组长
$("#foContact").attr("readonly", false);//班组长电话
}
// 查看表单赋值
function setLookData(data) {
$("#id").val(data.id);
$("#companyId").val(data.orgName); // 公司名称
$("#subName").val(data.subName);
$("#represent").val(data.represent); // 法人代表
$("#address").val(data.address); // 法人住址
$("#reContact").val(data.reContact); // 法人电话
$("#foreman").val(data.foreman); // 班组长
$("#foContact").val(data.foContact); // 班组长电话
$("#einTime").val(data.einTime); // 入场时间
$("#updateTime").val(data.updateTime); // 修改时间
var path1 = dataPath+"/"+data.businessURL;
var html1 = "";
html1 +="<li class='disPhotoLi1'>";
html1 += '<img data-original="'+path1+'" src="' + path1 + '" class="img" width="200px" height="150px"/>';
html1 +=" </li>";
$("#businessPhoto").append(html1);
var path2 = dataPath+"/"+data.sealURL;
var html2 = "";
html2 +="<li class='disPhotoLi2'>";
html2 += '<img data-original="'+path2+'" src="' + path2 + '" class="img" width="200px" height="150px"/>';
html2 +=" </li>";
$("#sealPhoto").append(html2);
var path3 = dataPath+"/"+data.signatureURL;
var html3 = "";
html3 +="<li class='disPhotoLi3'>";
html3 += '<img data-original="'+path3+'" src="' + path3 + '" class="img" width="200px" height="150px"/>';
html3 +=" </li>";
$("#signaturePhoto").append(html3);
var path4 = dataPath+"/"+data.safetyURL;
var html4 = "";
html4 +="<li class='disPhotoLi4'>";
html4 += '<img data-original="'+path4+'" src="' + path4 + '" class="img" width="200px" height="150px"/>';
html4 +=" </li>";
$("#safetyPhoto").append(html4);
var path5 = dataPath+"/"+data.idCardBackURL;
var html5 = "";
html5 +="<li class='disPhotoLi5'>";
html5 += '<img data-original="'+path5+'" src="' + path5 + '" class="img" width="200px" height="150px"/>';
html5 +=" </li>";
$("#idCardBackPhoto").append(html5);
var path6 = dataPath+"/"+data.idCardJustURL;
var html6 = "";
html6 +="<li class='disPhotoLi6'>";
html6 += '<img data-original="'+path6+'" src="' + path6 + '" class="img" width="200px" height="150px"/>';
html6 +=" </li>";
$("#idCardJustPhoto").append(html6);
}
var deletePhoto = [];
function delPhoto(i) {
var parentcolor = document.getElementById("demo" + i);
var childcolor = document.getElementById(i+"");
var path = childcolor.name;
deletePhoto.push(path);
parentcolor.removeChild(childcolor);
var photoNum = $("#demo" + i).children().length;
if(photoNum == 0){
$("#preview" + i).css("display","none");
}
}
function getCompanys(form,companyId) {
$("#companyId").empty();
var s = $("#companyId").html();
$.ajax({
type: 'POST',
url: ctxPath + '/project/getCompanys',
data: {},
dataType: 'json',
success: function (data) {
if(data.length>0){
var str = '<option selected value="-1">请选择公司</option>';
for(var i = 0; i < data.length; i++) {
if(companyId == data[i].id) {
str += '<option selected value=\'' + data[i].id + '\'>' + data[i].name + '</option>';
} else {
str += '<option value=\'' + data[i].id + '\'>' + data[i].name + '</option>';
}
}
$("#companyId").append(str);
form.render('select'); //这里就是我们要渲染的地方了
}
}
})
}
function getCompanyss(companyId) {
$("#companyId").empty();
var s = $("#companyId").html();
$.ajax({
type: 'POST',
url: ctxPath + '/project/getCompanys',
data: {},
dataType: 'json',
success: function (data) {
if(data.length>0){
var str = '<option selected value="-1">请选择公司</option>';
for(var i = 0; i < data.length; i++) {
if(companyId == data[i].id) {
str += '<option selected value=\'' + data[i].id + '\'>' + data[i].name + '</option>';
} else {
str += '<option value=\'' + data[i].id + '\'>' + data[i].name + '</option>';
}
}
$("#companyId").append(str);
}
}
})
}
//设置弹窗关闭
function reloading() {
var index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
parent.layer.close(index); //再执行关闭
window.parent.example.ajax.reload( null, false ); // 刷新页面
}