angular.module('push')
.controller('technicalBrokerEditCompanyInfoCtrl', function ($scope,$stateParams,$ionicActionSheet,$ionicSlideBoxDelegate, UtilService,AccountService,ActivityService,
UserService,$ionicScrollDelegate,$timeout,ModelService,CloudFolderService,
DockingService, TechnicalBrokerPublishTrainService,
$ionicModal,SqliteStorageService,$ionicPopup,ConfigService) {
// 走企业记录id
// TODO
var connid = $stateParams.connid;
// var connid = 1971;
// 图片
$scope.imagelist = [];
// 删除的图片list
var delimageidlist = [];
var delimages = "";//删除的图片id,","分割
// 删除的id集合
var delproduceInfolist = [];//删除对接信息产品list
var delgreatProduceInfolist = [];//删除高新产品
var deltechrequirelist = [];//删除对接信息的需求
var delprojectCenterInfolist = [];//删除工程中心信息
var delresearchInfolist = [];//删除研发投入
var delrealInfolist = [];//删除实际收入
var delimportantProjectlist = [];//删除重大科研项目
var deladviceInfolist = [];//删除项目建议
var delexperienceInfolist = [];//删除对接信息产学研
var deltalentInfolist = [];//删除高端人才
var delintellectuallist = [];//删除专利信息
var delproduceInfos = "";//删除对接信息产品id,","分割
var delgreatProduceInfos = "";//删除高新产品
var deltechrequires = "";//删除对接信息的需求
var delprojectCenterInfos = "";//删除工程中心信息
var delresearchInfos = "";//删除研发投入
var delrealInfos = "";//删除实际收入
var delimportantProjects = "";//删除重大科研项目
var deladviceInfos="";//删除项目建议
var delexperienceInfos="";//删除对接信息产学研id,","分割
var deltalentInfos="";//删除高端人才
var delintellectuals="";//删除专利信息
//产品信息
$scope.produceInfoList = [{
id: 0,
productname: "",// 产品名称
productdescription: ""//产品描述
}];
//高新产品
$scope.greatProduceInfoList= [{
id: 0,
productname: "",// 产品名称
productdescription: ""//产品描述
}];
//需求信息
$scope.demandInfoList=[{
id: 0,
companyid: 0,
techtype: 0,
techtypename: "",
techrequirementname: "",
cooperationmodel: "",
cooperationmodelname: "",// 合作模式名称
capital_scale: 0,
techrequirementdetail: "",
images: "", // 图片
demandInfoimagelist:[],// app端图片插件进行传递的变量(需求图片)
}];
//工程中心信息
$scope.projectCenterInfoList= [{
id: 0,
yid: 0,
yearname: "",// 选择项名称
yvalue1: ""// 金额
}];
//研发投入信息
$scope.researchInfoList = [{
id: 0,
yid: 0,
yearname: "",// 选择项名称
yvalue1: ""// 金额
}];
//实际收入与预计投入信息
$scope.realInfoList= [{
id: 0,
yid: 0,
yearname: "",//选择项名称
yvalue1: "",// 销售收入
yvalue2: "",// 净利润
yvalue3: "" // 上缴税收
}];
//重大科研项目信息
$scope.importantProjectList= [{
id: 0,
yid: 0,
yearname: "",// 选择项名称
yvalue1: ""// 项目内容
}];
//项目建议
$scope.adviceInfoList= [{
id: 0,
projectname: "",//
projectdescription: "",//
projectsuggest: ""// 申报项目建议
}];
//产学研经验
$scope.experienceInfoList=[{
id: 0,
cooperateschool: "",// 合作院校
cooperatedetail: ""// 合作内容
}];
//人才
$scope.talentInfoList=[{
id: 0,
name: "",// 人才姓名
tel: "",// 手机号
position: "",// 职位
academicdegree: 0,// 学位
academicdegreename: "",// 学位名称
responsible: "",// 负责工作
about: ""// 人才简介
}];
//专利
$scope.patentInfoList=[{
id: 0,
intellectualpropertyname: "",// 名称
applyperson: "",// 主要完成人
licensenumber: "",// 申请号/授权号
// licensedate: ""// 授权日期
}];
//切换到对应页面
var activity=['baseInfo','productInfo','demandInfo','projectInfo','personnelAbilityInfo','patentInfo'];
$scope.act = activity[0];
$scope.changeAct = function (num) {
if (num == 0) {
$scope.act = activity[num];
} else if (num == 1) {
$scope.act = activity[num];
}else if (num == 2) {
$scope.act = activity[num];
}
else if (num == 3) {
$scope.act = activity[num];
}
else if (num == 4) {
$scope.act = activity[num];
}
else if (num == 5) {
$scope.act = activity[num];
}
};
$scope.watchIsChange=function () {
if($scope.connEnterpriseModuleModel.company.high==true){
$scope.connEnterpriseModuleModel.company.ishighInfo="是";
$scope.connEnterpriseModuleModel.company.ishigh=1;
}else{
$scope.connEnterpriseModuleModel.company.ishighInfo="否";
$scope.connEnterpriseModuleModel.company.ishigh=0;
}
};
// 初始化走企业信息
var initCompanyInfo = function (connid) {
// console.log(connid);
TechnicalBrokerPublishTrainService.getConnCompanyInfo(connid).then(function (response) {
console.log(response);
//企业基本信息
$scope.connEnterpriseModuleModel = {
userid: response.userid,
usercomefrom: response.usercomefrom,
claid: response.claid,// 选中的文件夹id
taskid: response.taskid,// 任务id
id: response.id,// 记录id
templettype: response.templettype,// 模板Id 默认1是通用模板,2是走企业模板
company: {
companyid: response.company.companyid,
companyname: response.company.companyname,
contact: response.company.contact,
contactnum: response.company.contactnum,
categoryid: response.company.categoryid,
categoryName: response.company.categoryname,
rdinstitutiontype: response.company.rdinstitutiontype,// 企业研发机构等级
rdinstitutiontypeName: response.company.rdinstitutiontypename,// 企业研发机构等级
ishigh: response.company.ishigh,// 是否高企
logo: response.company.logo,// 企业logo
high:response.company.ishigh == 1,
ishighInfo:response.company.ishigh == 1 ? "是" : "否"
}
};
$scope.produceInfoList = response.companyProductlist;
$scope.greatProduceInfoList = response.companyHignendProductlist;
$scope.demandInfoList = response.companyTechrequirementlist;
$scope.projectCenterInfoList = response.projectCenterInfoList;
$scope.researchInfoList = response.researchInfoList;
$scope.realInfoList = response.realInfoList;
$scope.importantProjectList = response.importantProjectList;
$scope.adviceInfoList = response.companyDeclareprojectlist;
$scope.experienceInfoList = response.companyIURlist;
$scope.talentInfoList = response.companyHighleveltalentslist;
$scope.patentInfoList = response.intellectualpropertylist;
$scope.imagelist = response.company.piclist;
console.log($scope.connEnterpriseModuleModel);
console.log($scope.projectCenterInfoList);
}, function () {
})
};
initCompanyInfo(connid);
//初始化云文件夹列表
$scope.checkdefolder = [];
var initCloudFolderList = function () {
// 0,查询所有文件夹,1查询通用文件夹,2查询走企业模板文件夹
var templettype = 2;
DockingService.newGetComFolderList(templettype).then(function (response) {
$scope.cloudFolderList = response.folderlist;
ModelService.setCloudFolderList($scope.cloudFolderList);
// 云文件夹
$scope.folderlist = angular.copy(ModelService.getCloudFolderList());
//默认选择文件夹
console.log("1:"+$scope.folderlist.length);
if($scope.folderlist.length > 0){
$scope.checkdefolder = $scope.folderlist[0];
$scope.checkfolder = $scope.folderlist[0].id + "";
}
}, function () {
})
};
initCloudFolderList();
// *******获取所有配置信息*******
// 获取工程中心信息的通用年份配置列表
var projectcenterinfoyearbuttons = [];
var getProjectCenterInfoYearMultiSetupList = function () {
TechnicalBrokerPublishTrainService.getYearMultiSetupList(3).then(function (response) {
// console.log(response);
if (UtilService.isDefined(response) && response.length > 0) {
angular.forEach(response, function (value, index) {
var temphtml = {
text: '' + value.setupname + '',
yearsetupid: value.id,
yearname: value.setupname
};
projectcenterinfoyearbuttons.push(temphtml);
});
}
}, function () {
})
};
getProjectCenterInfoYearMultiSetupList();
//选择工程中心信息的通用年份配置列表
$scope.showProjectCenterInfoYearSetup = function (ind) {
$ionicActionSheet.show({
buttons: projectcenterinfoyearbuttons,
cancelText: '取消',
buttonClicked: function (index) {
$scope.projectCenterInfoList[ind].yid = projectcenterinfoyearbuttons[index].yearsetupid;
$scope.projectCenterInfoList[ind].yearname = projectcenterinfoyearbuttons[index].yearname;
return true;
}
});
};
// 获取研发投入的通用年份配置列表
var researchinfoyearbuttons = [];
var getResearchInfoYearMultiSetupList = function () {
TechnicalBrokerPublishTrainService.getYearMultiSetupList(1).then(function (response) {
// console.log(response);
if (UtilService.isDefined(response) && response.length > 0) {
angular.forEach(response, function (value, index) {
var temphtml = {
text: '' + value.setupname + '',
yearsetupid: value.id,
yearname: value.setupname
};
researchinfoyearbuttons.push(temphtml);
});
}
}, function () {
})
};
getResearchInfoYearMultiSetupList();
//选择研发投入的通用年份配置列表
$scope.showResearchInfoYearSetup = function (ind) {
$ionicActionSheet.show({
buttons: researchinfoyearbuttons,
cancelText: '取消',
buttonClicked: function (index) {
$scope.researchInfoList[ind].yid = researchinfoyearbuttons[index].yearsetupid;
$scope.researchInfoList[ind].yearname = researchinfoyearbuttons[index].yearname;
return true;
}
});
};
// 获取实际收入的通用年份配置列表
var realinfoyearbuttons = [];
var getRealInfoYearMultiSetupList = function () {
TechnicalBrokerPublishTrainService.getYearMultiSetupList(2).then(function (response) {
// console.log(response);
if (UtilService.isDefined(response) && response.length > 0) {
angular.forEach(response, function (value, index) {
var temphtml = {
text: '' + value.setupname + '',
yearsetupid: value.id,
yearname: value.setupname
};
realinfoyearbuttons.push(temphtml);
});
}
}, function () {
})
};
getRealInfoYearMultiSetupList();
//选择实际收入的通用年份配置列表
$scope.showRealInfoYearSetup = function (ind) {
$ionicActionSheet.show({
buttons: realinfoyearbuttons,
cancelText: '取消',
buttonClicked: function (index) {
$scope.realInfoList[ind].yid = realinfoyearbuttons[index].yearsetupid;
$scope.realInfoList[ind].yearname = realinfoyearbuttons[index].yearname;
return true;
}
});
};
// 获取重大科研项目的通用年份配置列表
var importantprojectbuttons = [];
var getImportantProjectYearMultiSetupList = function () {
TechnicalBrokerPublishTrainService.getYearMultiSetupList(4).then(function (response) {
// console.log(response);
if (UtilService.isDefined(response) && response.length > 0) {
angular.forEach(response, function (value, index) {
var temphtml = {
text: '' + value.setupname + '',
yearsetupid: value.id,
yearname: value.setupname
};
importantprojectbuttons.push(temphtml);
});
}
}, function () {
})
};
getImportantProjectYearMultiSetupList();
//选择重大科研项目的通用年份配置列表
$scope.showImportantProjectYearSetup = function (ind) {
$ionicActionSheet.show({
buttons: importantprojectbuttons,
cancelText: '取消',
buttonClicked: function (index) {
$scope.importantProjectList[ind].yid = importantprojectbuttons[index].yearsetupid;
$scope.importantProjectList[ind].yearname = importantprojectbuttons[index].yearname;
return true;
}
});
};
// 获取需求的合作模式列表
var cooperationmodelbuttons = [];
var getCooperationmodelList = function () {
TechnicalBrokerPublishTrainService.getCooperationmodelList().then(function (response) {
if (UtilService.isDefined(response) && response.length > 0) {
angular.forEach(response, function (value, index) {
var temphtml = {
text: '' + value.itemkey + '',
cooperationmodel: value.itemvalue,
cooperationmodelname: value.itemkey
};
cooperationmodelbuttons.push(temphtml);
});
// console.log(cooperationmodelbuttons);
}
}, function () {
})
};
getCooperationmodelList();
//选择需求的合作模式列表
$scope.showCooperationmodelStatus = function (ind) {
$ionicActionSheet.show({
buttons: cooperationmodelbuttons,
cancelText: '取消',
buttonClicked: function (index) {
$scope.demandInfoList[ind].cooperationmodel = cooperationmodelbuttons[index].cooperationmodel;
$scope.demandInfoList[ind].cooperationmodelname = cooperationmodelbuttons[index].cooperationmodelname;
return true;
}
});
};
// 获取需求的需求类型列表
var techtypebuttons = [];
var getTechtypeList = function () {
TechnicalBrokerPublishTrainService.getTechtypeList().then(function (response) {
if (UtilService.isDefined(response) && response.length > 0) {
angular.forEach(response, function (value, index) {
var temphtml = {
text: '' + value.itemkey + '',
techtype: value.itemvalue,
techtypename: value.itemkey
};
techtypebuttons.push(temphtml);
});
// console.log(cooperationmodelbuttons);
}
}, function () {
})
};
getTechtypeList();
//选择需求的需求类型
$scope.showTechtype = function (ind) {
$ionicActionSheet.show({
buttons: techtypebuttons,
cancelText: '取消',
buttonClicked: function (index) {
$scope.demandInfoList[ind].techtype = techtypebuttons[index].techtype;
$scope.demandInfoList[ind].techtypename = techtypebuttons[index].techtypename;
return true;
}
});
};
// 获取人才的学位列表
var academicdegreebuttons = [];
var getAcademicdegreeList = function () {
TechnicalBrokerPublishTrainService.getAcademicdegreeList().then(function (response) {
if (UtilService.isDefined(response) && response.length > 0) {
angular.forEach(response, function (value, index) {
var temphtml = {
text: '' + value.itemkey + '',
academicdegree: value.itemvalue,
academicdegreename: value.itemkey
};
academicdegreebuttons.push(temphtml);
});
// console.log(academicdegreebuttons);
}
}, function () {
})
};
getAcademicdegreeList();
//选择人才的学位列表
$scope.showAcademicdegreeStatus = function (ind) {
$ionicActionSheet.show({
buttons: academicdegreebuttons,
cancelText: '取消',
buttonClicked: function (index) {
$scope.talentInfoList[ind].academicdegree = academicdegreebuttons[index].academicdegree;
$scope.talentInfoList[ind].academicdegreename = academicdegreebuttons[index].academicdegreename;
return true;
}
});
};
//选择企业产业领域
var buttonsIndustryStatus = [
{text: "汽车制造",
stausName:"汽车制造",
stausId: "A"
},
{text: "能源及节能技术",
stausName:"能源及节能技术",
stausId: "B"
},
{text: "新材料",
stausName:"新材料",
stausId: "C"
},
{text: "生物与新医药",
stausName:"生物与新医药",
stausId: "D"
},
{text: "电子信息",
stausName:"电子信息",
stausId: "E"
},
{text: "先进制造及高端装备",
stausName:"先进制造及高端装备",
stausId: "F"
},
{text: "资源及环境技术",
stausName:"资源及环境技术",
stausId: "G"
}
];
$scope.showIndustryStatus=function () {
$ionicActionSheet.show({
cancelOnStateChange: true,
cssClass: 'action_s',
cancelText: '取消',
buttons: buttonsIndustryStatus,
buttonClicked: function (index) {
$scope.connEnterpriseModuleModel.company.categoryid = buttonsIndustryStatus[index].stausId;
$scope.connEnterpriseModuleModel.company.categoryName = buttonsIndustryStatus[index].stausName;
return true;
},
destructiveButtonClicked: function () {
return true;
}
});
};
//选择研发机构等级
var buttonsResearchStatus = [
{ text: "国家级",
ResearchStatusName:"国家级",
ResearchStatusId: "1"
},
{ text: "省级",
ResearchStatusName:"省级",
ResearchStatusId: "2"
},
{ text: "市级",
ResearchStatusName:"市级",
ResearchStatusId: "3"
},
{ text: "区级",
ResearchStatusName:"区级",
ResearchStatusId: "4"
}
];
$scope.showResearchStatus=function () {
$ionicActionSheet.show({
cancelOnStateChange: true,
cssClass: 'action_s',
cancelText: '取消',
buttons: buttonsResearchStatus,
buttonClicked: function (index) {
$scope.connEnterpriseModuleModel.company.rdinstitutiontype = buttonsResearchStatus[index].ResearchStatusId;
$scope.connEnterpriseModuleModel.company.rdinstitutiontypeName = buttonsResearchStatus[index].ResearchStatusName;
return true;
},
destructiveButtonClicked: function () {
return true;
}
});
};
// 添加、删除多选内容
//添加、删除更多一般产品
$scope.AddOrDelProductInfo = function (ind) {
if (ind == 0) {
$scope.produceInfoList.push({
id: 0,
productname: "",// 产品名称
productdescription: ""//产品描述
});
} else {
if ($scope.produceInfoList[ind].id != 0) {
delproduceInfolist.push($scope.produceInfoList[ind].id);
}
$scope.produceInfoList.splice(ind, 1);
}
};
//添加、删除更多高新产品
$scope.AddOrDelGreatProductInfo = function (ind) {
if (ind == 0) {
$scope.greatProduceInfoList.push({
id: 0,
productname: "",// 产品名称
productdescription: ""//产品描述
});
} else {
if ($scope.greatProduceInfoList[ind].id != 0) {
delgreatProduceInfolist.push($scope.greatProduceInfoList[ind].id);
}
$scope.greatProduceInfoList.splice(ind, 1);
}
};
//添加、删除更多工程中心信息
$scope.AddOrDelProjectInfo = function (ind) {
if (ind == 0) {
$scope.projectCenterInfoList.push({
id: 0,
yid: 0,
yearname: "",//选择项名称
yvalue1: ""
});
} else {
if ($scope.projectCenterInfoList[ind].id != 0) {
delprojectCenterInfolist.push($scope.projectCenterInfoList[ind].id);
}
$scope.projectCenterInfoList.splice(ind, 1);
}
};
//添加、删除更多研发投入信息
$scope.AddOrDelResearchInfo = function (ind) {
if (ind == 0) {
$scope.researchInfoList.push({
id: 0,
yid: 0,
yearname: "",//选择项名称
yvalue1: ""
});
} else {
if ($scope.researchInfoList[ind].id != 0) {
delresearchInfolist.push($scope.researchInfoList[ind].id);
}
$scope.researchInfoList.splice(ind, 1);
}
};
//添加、删除更多实际研发与投入信息
$scope.AddOrDelrealInfoInfo= function (ind) {
if (ind == 0) {
$scope.realInfoList.push({
id: 0,
yid: 0,
yearname: "",//选择项名称
yvalue1: "",
yvalue2: "",
yvalue3: ""
});
} else {
if ($scope.realInfoList[ind].id != 0) {
delrealInfolist.push($scope.realInfoList[ind].id);
}
$scope.realInfoList.splice(ind, 1);
}
};
//添加、删除更多需求
$scope.AddOrDelDemandInfo = function (ind) {
if (ind == 0) {
$scope.demandInfoList.push({
ind: ind,// 索引值
id: 0,
companyid: 0,
techtype: 0,
techtypename: "",
techrequirementname: "",
cooperationmodel: "",
capital_scale: 0,
techrequirementdetail: "",
images: "" // 图片
});
} else {
if ($scope.demandInfoList[ind].id != 0) {
deltechrequirelist.push($scope.demandInfoList[ind].id);
}
$scope.demandInfoList.splice(ind, 1);
}
};
//添加、删除更多重大科研项目
$scope.AddOrDelImportantProjectInfo = function (ind) {
if (ind == 0) {
$scope.importantProjectList.push({
id: 0,
yid: 0,
yearname: "",//选择项名称
yvalue1: ""
});
} else {
if ($scope.importantProjectList[ind].id != 0) {
delimportantProjectlist.push($scope.importantProjectList[ind].id);
}
$scope.importantProjectList.splice(ind, 1);
}
};
//添加、删除更多项目建议
$scope.AddOrDelAdviceInfo= function (ind) {
if (ind == 0) {
$scope.adviceInfoList.push({
id: 0,
projectname: "",//
projectdescription: "",//
projectsuggest: ""// 申报项目建议
});
} else {
if ($scope.adviceInfoList[ind].id != 0) {
deladviceInfolist.push($scope.adviceInfoList[ind].id);
}
$scope.adviceInfoList.splice(ind, 1);
}
};
//添加、删除更多产学研经验
$scope.AddOrexperienceInfo= function (ind) {
if (ind == 0) {
$scope.experienceInfoList.push({
id: 0,
cooperateschool: "",// 合作院校
cooperatedetail: ""// 合作内容
});
} else {
if ($scope.experienceInfoList[ind].id != 0) {
delexperienceInfolist.push($scope.experienceInfoList[ind].id);
}
$scope.experienceInfoList.splice(ind, 1);
}
};
//添加、删除更多人才信息
$scope.AddOrDelTalentInfo= function (ind) {
if (ind == 0) {
$scope.talentInfoList.push({
id: 0,
name: "",// 人才姓名
tel: "",// 手机号
position: "",// 职位
academicdegree: 0,// 学位
academicdegreename: "",// 学位名称
responsible: "",// 负责工作
about: ""// 人才简介
});
} else {
if ($scope.talentInfoList[ind].id != 0) {
deltalentInfolist.push($scope.talentInfoList[ind].id);
}
$scope.talentInfoList.splice(ind, 1);
}
};
//添加、删除更多专利
$scope.AddOrDelpatentInfo= function (ind) {
if (ind == 0) {
$scope.patentInfoList.push({
id: 0,
intellectualpropertyname: "",// 名称
applyperson: "",// 主要完成人
licensenumber: "",// 申请号/授权号
// licensedate: ""// 授权日期
});
} else {
if ($scope.patentInfoList[ind].id != 0) {
delintellectuallist.push($scope.patentInfoList[ind].id);
}
$scope.patentInfoList.splice(ind, 1);
}
};
// 弹出获取企业logo
$scope.show_logo = function () {
$ionicActionSheet.show({
cancelOnStateChange: true,
cssClass: 'action_s',
cancelText: '取消',
buttons: [
{text: "拍照"},
{text: "从相册上传"}
],
buttonClicked: function (index) {
if (index == 0) {
openCamera(1,1);
} else {
openCamera(0,1);
}
return true;
},
destructiveButtonClicked: function () {
return true;
}
});
};
var openCamera = function (srcType) {
var options = {
// Some common settings are 20, 50, and 100
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
// In this app, dynamically set the picture source, Camera or photo gallery
sourceType: srcType,
encodingType: Camera.EncodingType.JPEG,
mediaType: Camera.MediaType.PICTURE,
allowEdit: false,
correctOrientation: true //Corrects Android orientation quirks
};
navigator.camera.getPicture(function (imageData) {
$scope.imgurl = imageData;
$scope.showLoadingToast();
UtilService.uploadFile([imageData], 0, "image/jpeg").then(function (response) {
// 企业logo
$scope.connEnterpriseModuleModel.company.logo = response[0].userPhoto;
$scope.hideLoadingToast();
}, function () {
$scope.hideLoadingToast();
});
}, function (message) {
}, options);
};
// ****** 单信息图片 ******
$scope.openCamera = function () {
if ($scope.imagelist.length >= 9) {
UtilService.showMess("最多选取9张图片");
return;
}
UtilService.getPicture(1).then(function (results) {
// console.log(results);
$scope.imagelist.push({photo_name: results, original_name: results});
$scope.totalImglength = 600 * $scope.imagelist.length;
$ionicScrollDelegate.$getByHandle("scrollimage").resize();
}, function (err) {
});
};
$scope.show = function () {
$ionicActionSheet.show({
buttons: [
{text: '相册中添加照片'},
{text: '拍照'}
],
cancelText: '取消',
buttonClicked: function (index) {
if (index == 0) {
getPictures();
} else if (index == 1) {
$scope.openCamera();
}
return true;
}
});
};
var verifyStorage = function () {
window.imagePicker.verifyStorage(
function (results) {
if (results == "1") {
getPic();
}
}, function (error) {
}
);
};
var getPic = function () {
if ($scope.imagelist.length >= 9) {
UtilService.showMess("最多选取9张图片");
return;
}
UtilService.getPictureList(9 - $scope.imagelist.length).then(function (results) {
// console.log(results);
angular.forEach(results, function (value, index) {
$scope.imagelist.push({photo_name: value, original_name: value})
});
$scope.totalImglength = 600 * $scope.imagelist.length;
$ionicScrollDelegate.$getByHandle("scrollimage").resize();
}, function (err) {
});
};
var getPictures = function () {
if (device.platform == "Android") {
verifyStorage();
} else {
getPic();
}
};
//点击图片放大
$scope.bigImage = false; //初始默认大图是隐藏的
$scope.hideBigImage = function () {
if($scope.app){
$scope.setStatusBar(0);
}
$timeout(function () {
$scope.bigImage = false;
}, 400);
};
$scope.shouBigImage = function (index) { //传递一个参数(图片的URl)
if($scope.app){
$scope.setStatusBar(1);
}
$(function () {
$('div.pinch-zoom').each(function () {
new RTP.PinchZoom($(this), {});
});
});
$scope.bigImage = true;//显示大图
$ionicSlideBoxDelegate.update();//重绘,让图片显示出来
//图片总数量
setTimeout(function () {
$ionicSlideBoxDelegate.$getByHandle('slide_detail').slide(index, -10);
//获取图片
var imgObj = document.getElementsByClassName('bigimage');
var n;
for (n = 0; n < imgObj.length; n++) {
// 获取图片的原始高度和宽度
var oldWid = imgObj[n].naturalWidth;
var oldHei = imgObj[n].naturalHeight;
var screen = document.body.offsetWidth;
var screenH = window.innerHeight;
// console.log(oldWid / oldHei);
// console.log(screen);
var cc = screen / (oldWid / oldHei);
imgObj[n].style.height = cc + 'px';
if (cc < screenH) {
imgObj[n].style.marginTop = (screenH - cc) / 2 + 'px';
// console.log("e:"+imgObj[n].style.marginTop);
} else {
imgObj[n].style.marginTop = 0 + 'px';
// console.log((cc-screenH) +'px')
}
}
}, 10);
};
//删除图片
$scope.deletePhoto = function (index) {
if ($scope.imagelist[index].id != 0) {
delimageidlist.push($scope.imagelist[index].id);
}
$scope.imagelist.splice(index, 1);
};
//保存企业信息表
var saveflg = 0;
$scope.saveCompanyInfo = function () {
// 基本信息
if (!UtilService.isDefined($scope.connEnterpriseModuleModel.company.companyname)) {
UtilService.showMess("请填写企业名称");
return;
}
if ($scope.connEnterpriseModuleModel.company.companyname.length > 255) {
UtilService.showMess("企业名称不能超过255个字");
return;
}
if ($scope.connEnterpriseModuleModel.company.contact.length > 255) {
UtilService.showMess("联系人不能超过255个字");
return;
}
if ($scope.connEnterpriseModuleModel.company.contactnum.length > 255) {
UtilService.showMess("联系方式不能超过255个字");
return;
}
var result = 1;
// 工程中心
if ($scope.projectCenterInfoList.length > 0) {
angular.forEach($scope.projectCenterInfoList, function (projectCenterInfoList,index) {
if ($scope.projectCenterInfoList[index].yvalue1.length > 255) {
result = 0;
}
});
if(result == 0){
UtilService.showMess("工程中心的年度情况不能超过255个字");
return;
}
}
// 研发投入
if ($scope.researchInfoList.length > 0) {
angular.forEach($scope.researchInfoList, function (researchInfoList,index) {
if (result == 1 && $scope.researchInfoList[index].yvalue1.length > 255) {
result = 0;
}
});
if(result == 0){
UtilService.showMess("研发投入的年度情况不能超过255个字");
return;
}
}
// 实际收入/预计投入
if ($scope.realInfoList.length > 0) {
angular.forEach($scope.realInfoList, function (realInfoList,index) {
if (result == 1 &&
($scope.realInfoList[index].yvalue1.length > 255
|| $scope.realInfoList[index].yvalue2.length > 255
|| $scope.realInfoList[index].yvalue3.length > 255)) {
result = 0;
}
});
if(result == 0){
UtilService.showMess("实际收入/预计投入的销售收入、净利润和上缴税收不能超过255个字");
return;
}
}
// 产品信息
if ($scope.produceInfoList.length > 0) {
angular.forEach($scope.produceInfoList, function (produceInfoList,index) {
if (result == 1 && $scope.produceInfoList[index].productname.length > 255) {
result = 0;
}
});
if(result == 0){
UtilService.showMess("产品信息的产品名称不能超过255个字");
return;
}
}
// 高新产品信息
if ($scope.greatProduceInfoList.length > 0) {
angular.forEach($scope.greatProduceInfoList, function (greatProduceInfoList,index) {
if (result == 1 && $scope.greatProduceInfoList[index].productname.length > 255) {
result = 0;
}
});
if(result == 0){
UtilService.showMess("高新产品信息的产品名称不能超过255个字");
return;
}
}
// 需求信息
if ($scope.demandInfoList.length > 0) {
angular.forEach($scope.demandInfoList, function (demandInfoList,index) {
if (result == 1 &&
($scope.demandInfoList[index].techrequirementname.length > 255
|| $scope.demandInfoList[index].capital_scale.length > 255)) {
result = 0;
}
});
if(result == 0){
UtilService.showMess("需求信息的需求名称和投入预算不能超过255个字");
return;
}
}
// 重大科研项目
if ($scope.importantProjectList.length > 0) {
angular.forEach($scope.importantProjectList, function (importantProjectList,index) {
if (result == 1 && $scope.importantProjectList[index].yvalue1.length > 255) {
result = 0;
}
});
if(result == 0){
UtilService.showMess("重大科研项目的项目名称不能超过255个字");
return;
}
}
// 项目建议
if ($scope.adviceInfoList.length > 0) {
angular.forEach($scope.adviceInfoList, function (adviceInfoList,index) {
if (result == 1 && $scope.adviceInfoList[index].projectname.length > 255) {
result = 0;
}
});
if(result == 0){
UtilService.showMess("项目建议的项目名称不能超过255个字");
return;
}
}
// 产学研经验
if ($scope.experienceInfoList.length > 0) {
angular.forEach($scope.experienceInfoList, function (experienceInfoList,index) {
if (result == 1 && $scope.experienceInfoList[index].cooperateschool.length > 255) {
result = 0;
}
});
if(result == 0){
UtilService.showMess("产学研经验的已合作院校不能超过255个字");
return;
}
}
// 人才信息
if ($scope.talentInfoList.length > 0) {
angular.forEach($scope.talentInfoList, function (talentInfoList,index) {
if (result == 1 && $scope.talentInfoList[index].name.length > 50) {
result = 0;
}
if (result == 1 && $scope.talentInfoList[index].tel.length > 30) {
result = 2;
}
if (result == 1 && $scope.talentInfoList[index].position.length > 50) {
result = 3;
}
if (result == 1 && $scope.talentInfoList[index].responsible.length > 255) {
result = 4;
}
});
if(result == 0){
UtilService.showMess("人才信息的姓名不能超过50个字");
return;
}else if(result == 2){
UtilService.showMess("人才信息的联系方式不能超过30个字");
return;
}else if(result == 3){
UtilService.showMess("人才信息的职位不能超过50个字");
return;
}else if(result == 4){
UtilService.showMess("人才信息的负责工作不能超过255个字");
return;
}
}
// 专利信息
if ($scope.patentInfoList.length > 0) {
angular.forEach($scope.patentInfoList, function (patentInfoList,index) {
if (result == 1 && $scope.patentInfoList[index].intellectualpropertyname.length > 255) {
result = 0;
}
if (result == 1 && $scope.patentInfoList[index].applyperson.length > 255) {
result = 2;
}
if (result == 1 && $scope.patentInfoList[index].licensenumber.length > 255) {
result = 3;
}
});
if(result == 0){
UtilService.showMess("专利信息的名称不能超过255个字");
return;
}else if(result == 2){
UtilService.showMess("专利信息的主要完成人不能超过255个字");
return;
}else if(result == 3){
UtilService.showMess("专利信息的申请号/专利号不能超过255个字");
return;
}
}
if (saveflg != 0) {
return;
}
saveflg = 1;
$scope.showLoadingToast();
if ($scope.imagelist.length > 0) {
uploadImages();
} else {
saveInfo();
}
};
var tempimages = [];
var uploadImages = function () {
tempimages = [];
var upimages = [];
angular.forEach($scope.imagelist, function (data) {
upimages.push(data.photo_name);
});
UtilService.uploadFile(upimages, 0, "image/jpeg").then(function (response) {
// console.log(response);
angular.forEach(response, function (value) {
if (value.status) {
tempimages.push({
id: 0,
title: "",
photo_name: value.userPhoto,
original_name: value.originalPhoto,
source_name: value.sourcePhoto,
source_size: value.source_size
});
}
});
$timeout(function () {
saveInfo();
}, 100);
}, function () {
$scope.hideLoadingToast();
UtilService.showMess("网络不给力,请重试");
saveflg = 0;
})
};
// 保存企业信息
var saveInfo = function () {
// 需求
if ($scope.demandInfoList.length > 0) {
angular.forEach($scope.demandInfoList, function (demandInfoList,$index) {
if (!UtilService.isDefined($scope.demandInfoList[$index].techrequirementname)
&& !UtilService.isDefined($scope.demandInfoList[$index].techrequirementdetail)
&& !UtilService.isDefined($scope.demandInfoList[$index].cooperationmodelname)
&& !UtilService.isDefined($scope.demandInfoList[$index].techtypename)
&& !UtilService.isDefined($scope.demandInfoList[$index].capital_scale)) {
$scope.demandInfoList.splice($index, 1);
}
});
}
$scope.connEnterpriseModuleModel.techrequirelistJson = JSON.stringify($scope.demandInfoList);
// 工程中心
if ($scope.projectCenterInfoList.length > 0) {
angular.forEach($scope.projectCenterInfoList, function (projectCenterInfoList,$index) {
if (!UtilService.isDefined($scope.projectCenterInfoList[$index].yearname)
&& !UtilService.isDefined($scope.projectCenterInfoList[$index].yvalue1)) {
$scope.projectCenterInfoList.splice($index, 1);
}
});
}
$scope.connEnterpriseModuleModel.projectCenterInfoListJson = JSON.stringify($scope.projectCenterInfoList);
// 研发投入
if ($scope.researchInfoList.length > 0) {
angular.forEach($scope.researchInfoList, function (researchInfoList,$index) {
if (!UtilService.isDefined($scope.researchInfoList[$index].yearname)
&& !UtilService.isDefined($scope.researchInfoList[$index].yvalue1)) {
$scope.researchInfoList.splice($index, 1);
}
});
}
$scope.connEnterpriseModuleModel.researchInfoListJson = JSON.stringify($scope.researchInfoList);
// 实际收入
if ($scope.realInfoList.length > 0) {
angular.forEach($scope.realInfoList, function (realInfoList,$index) {
if (!UtilService.isDefined($scope.realInfoList[$index].yearname)
&& !UtilService.isDefined($scope.realInfoList[$index].yvalue1)
&& !UtilService.isDefined($scope.realInfoList[$index].yvalue2)
&& !UtilService.isDefined($scope.realInfoList[$index].yvalue3)) {
$scope.realInfoList.splice($index, 1);
}
});
}
$scope.connEnterpriseModuleModel.realInfoListJson = JSON.stringify($scope.realInfoList);
// 产品信息
if ($scope.produceInfoList.length > 0) {
angular.forEach($scope.produceInfoList, function (produceInfoList,$index) {
if (!UtilService.isDefined($scope.produceInfoList[$index].productname)
&& !UtilService.isDefined($scope.produceInfoList[$index].productdescription)) {
$scope.produceInfoList.splice($index, 1);
}
});
}
$scope.connEnterpriseModuleModel.produceInfoListJson = JSON.stringify($scope.produceInfoList);
// 高新产品
if ($scope.greatProduceInfoList.length > 0) {
angular.forEach($scope.greatProduceInfoList, function (greatProduceInfoList,$index) {
if (!UtilService.isDefined($scope.greatProduceInfoList[$index].productname)
&& !UtilService.isDefined($scope.greatProduceInfoList[$index].productdescription)) {
$scope.greatProduceInfoList.splice($index, 1);
}
});
}
$scope.connEnterpriseModuleModel.greatProduceInfoListJson = JSON.stringify($scope.greatProduceInfoList);
// 重大科研项目
if ($scope.importantProjectList.length > 0) {
angular.forEach($scope.importantProjectList, function (importantProjectList,$index) {
if (!UtilService.isDefined($scope.importantProjectList[$index].yearname)
&& !UtilService.isDefined($scope.importantProjectList[$index].yvalue1)) {
$scope.importantProjectList.splice($index, 1);
}
});
}
$scope.connEnterpriseModuleModel.importantProjectListJson = JSON.stringify($scope.importantProjectList);
// 申报项目建议
if ($scope.adviceInfoList.length > 0) {
angular.forEach($scope.adviceInfoList, function (adviceInfoList,$index) {
if (!UtilService.isDefined($scope.adviceInfoList[$index].projectname)
&& !UtilService.isDefined($scope.adviceInfoList[$index].projectdescription)
&& !UtilService.isDefined($scope.adviceInfoList[$index].projectsuggest)) {
$scope.adviceInfoList.splice($index, 1);
}
});
}
$scope.connEnterpriseModuleModel.adviceInfoListJson = JSON.stringify($scope.adviceInfoList);
// 产学研经验
if ($scope.experienceInfoList.length > 0) {
angular.forEach($scope.experienceInfoList, function (experienceInfoList,$index) {
if (!UtilService.isDefined($scope.experienceInfoList[$index].cooperateschool)
&& !UtilService.isDefined($scope.experienceInfoList[$index].cooperatedetail)) {
$scope.experienceInfoList.splice($index, 1);
}
});
}
$scope.connEnterpriseModuleModel.experienceInfoListJson = JSON.stringify($scope.experienceInfoList);
// 人才
if ($scope.talentInfoList.length > 0) {
angular.forEach($scope.talentInfoList, function (talentInfoList,$index) {
if (!UtilService.isDefined($scope.talentInfoList[$index].name)
&& !UtilService.isDefined($scope.talentInfoList[$index].tel)
&& !UtilService.isDefined($scope.talentInfoList[$index].position)
&& !UtilService.isDefined($scope.talentInfoList[$index].academicdegreename)
&& !UtilService.isDefined($scope.talentInfoList[$index].responsible)
&& !UtilService.isDefined($scope.talentInfoList[$index].about)) {
$scope.talentInfoList.splice($index, 1);
}
});
}
$scope.connEnterpriseModuleModel.talentInfoListJson = JSON.stringify($scope.talentInfoList);
// 专利
if ($scope.patentInfoList.length > 0) {
angular.forEach($scope.patentInfoList, function (patentInfoList,$index) {
if (!UtilService.isDefined($scope.patentInfoList[$index].intellectualpropertyname)
&& !UtilService.isDefined($scope.patentInfoList[$index].applyperson)
&& !UtilService.isDefined($scope.patentInfoList[$index].licensenumber)) {
$scope.patentInfoList.splice($index, 1);
}
});
}
$scope.connEnterpriseModuleModel.intellectualListJson = JSON.stringify($scope.patentInfoList);
// 所属文件夹
$scope.connEnterpriseModuleModel.claid = $scope.checkfolder;
// 任务id
$scope.connEnterpriseModuleModel.taskid = $scope.taskid;
// 企业图片
$scope.connEnterpriseModuleModel.company.images = JSON.stringify(tempimages);
$scope.connEnterpriseModuleModel.company.delimages = delimageidlist.join(",");
$scope.connEnterpriseModuleModel.delproduceInfos = delproduceInfolist.join(",");
$scope.connEnterpriseModuleModel.delgreatProduceInfos = delgreatProduceInfolist.join(",");
$scope.connEnterpriseModuleModel.deltechrequires = deltechrequirelist.join(",");
$scope.connEnterpriseModuleModel.delprojectCenterInfos = delprojectCenterInfolist.join(",");
$scope.connEnterpriseModuleModel.delresearchInfos = delresearchInfolist.join(",");
$scope.connEnterpriseModuleModel.delrealInfos = delrealInfolist.join(",");
$scope.connEnterpriseModuleModel.delimportantProjects = delimportantProjectlist.join(",");
$scope.connEnterpriseModuleModel.deladviceInfos = deladviceInfolist.join(",");
$scope.connEnterpriseModuleModel.delexperienceInfos = delexperienceInfolist.join(",");
$scope.connEnterpriseModuleModel.deltalentInfos = deltalentInfolist.join(",");
$scope.connEnterpriseModuleModel.delintellectuals = delintellectuallist.join(",");
console.log($scope.connEnterpriseModuleModel);
TechnicalBrokerPublishTrainService.updateCompanyInfo($scope.connEnterpriseModuleModel, tempimages).then(function (response) {
// console.log(response);
if (response.result == 1) {
UtilService.showMess("修改成功");
$timeout(function () {
// $scope.goback();
// 添加成功后跳入我的录入
$scope.go("technicalBrokerEnterCompanyInfo");
}, 1500);
} else {
UtilService.showMess("网络不给力,请重试");
}
$scope.hideLoadingToast();
saveflg = 0;
}, function () {
UtilService.showMess("网络不给力,请重试");
$scope.hideLoadingToast();
saveflg = 0;
})
};
// ********** 企业联想 ********
//关联相关企业
$scope.isRelateUl = false;
$scope.queryLikeName = function () {
if ($scope.connEnterpriseModuleModel.company.companyname.length == 0) {
$scope.companylist = [];
$scope.isRelateUl = false;
return;
}
DockingService.getCampanyListByName($scope.connEnterpriseModuleModel.company.companyname).then(function (response) {
// console.log(response);
$scope.companylist = response.companylist;
$scope.isRelateUl = true;
}, function () {
})
};
//选中企业
$scope.setCompanyName = function (company) {
//亚
company.companyname = company.companyname.replace("", "");
company.companyname = company.companyname.replace("", "");
$scope.connEnterpriseModuleModel.company.companyname = company.companyname;
$scope.connEnterpriseModuleModel.company.logo = company.logo;
$scope.connEnterpriseModuleModel.company.contact = company.contact;
$scope.connEnterpriseModuleModel.company.contactnum = company.contactnum;
$scope.connEnterpriseModuleModel.company.category = company.category;
$scope.connEnterpriseModuleModel.company.categoryName = company.categoryname;
$scope.connEnterpriseModuleModel.company.rdinstitutiontype = company.rdinstitutiontype;
$scope.connEnterpriseModuleModel.company.rdinstitutiontypeName = company.rdinstitutiontypename;
$scope.connEnterpriseModuleModel.company.ishigh = company.ishigh;
if($scope.connEnterpriseModuleModel.company.ishigh==1){
$scope.connEnterpriseModuleModel.company.ishighInfo="是";
$scope.connEnterpriseModuleModel.company.high=true;
}else if($scope.connEnterpriseModuleModel.company.ishigh==0){
$scope.connEnterpriseModuleModel.company.ishighInfo="否";
$scope.connEnterpriseModuleModel.company.high=false;
}
$scope.isRelateUl = false;
};
//页面销毁时 回收广播
$scope.$on('$destroy', function () {
reciveregplace();
});
}).directive('stringToNumber', function() {
return {
require: 'ngModel',
link: function(scope, element, attrs, ngModel) {
ngModel.$parsers.push(function(value) {
return '' + value;
});
ngModel.$formatters.push(function(value) {
return parseInt(value);
});
}
};
}).directive('stringToNumber2', function() {
return {
require: 'ngModel',
link: function(scope, element, attrs, ngModel) {
ngModel.$parsers.push(function(value) {
return '' + value;
});
ngModel.$formatters.push(function(value) {
return parseInt(value);
});
}
};
});