angular.module('push')
.controller('technicalBrokerAddTransformInfoCtrl', function ($scope,$ionicActionSheet,$ionicModal,UtilService) {
var today = UtilService.formatDate().formattime3.substring(0, 11);
$scope.transformResultObj = {
companyid: "",// 企业id
orgname: "",// 企业名称
teacherName:"",// 合作老师
transformDemandName:"",// 技术需求名称
transformResultName:"",// 成果名称
transformProjectName:"",// 转化项目名称
tagname: "",// 合作状态名称
transformcooperationName: "",//合作方式名称
tagtime: today,// 达成合作日期
transformProjectMoney: 0,// 转化项目金额
transformProjectCycle:"",// 转化项目合作周期
transformcooperationState:""// 转化项目合作状态
};
$("#transformDateTime").attr("value", today);
//打开企业列表弹窗
$ionicModal.fromTemplateUrl('./modules/common/views/selectCompany.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function (modal) {
$scope.selCom = modal;
});
//打开企业列表弹窗
$scope.showCompany = function () {
if (localStorage.wxFlag == "true") {
if (localStorage.isUserFocusXW == 0) {
var title = localStorage.appidStr;
$ionicPopup.alert({
title: '提示',
template: '请先关注微信公众号"' + title + '"!'
});
return;
} else {
if (localStorage.isUserBindWx == 0) {
var wxFlag = JSON.parse(localStorage.params);
if (wxFlag.weChatModel) {
$scope.go('bindPhone', {
params: localStorage.params,
comfrom: 'maincontroller',
url: window.location.href.split('#/')[1]
});
} else {
$scope.go('login');
return;
}
} else {
$scope.go('login');
return;
}
}
} else {
$scope.go('login');
return;
}
};
//关闭企业列表弹窗
$scope.hideModel = function () {
$scope.selCom.hide();
};
//选择企业
$scope.saveCompany = function (com) {
getCompanyInfo(com.companyid);
$scope.transformResultObj.companyid = com.companyid;// 企业id
$scope.transformResultObj.orgname = com.companyname;
$scope.selCom.hide();
};
// 获取企业详细信息
var reqlist = [];
var getCompanyInfo = function (companyid) {
ActivityService.initFollowupCompanyInfo(companyid).then(function (response) {
// console.log(response);
if (UtilService.isDefined(response.company)) {
$scope.transformResultObj.companyid = response.company.companyid;
$scope.transformResultObj.orgname = response.company.companyname;
$scope.transformResultObj.orgleadername = response.company.contact;
$scope.transformResultObj.orgleaderduties = response.company.c_title;
$scope.transformResultObj.registplace = response.company.district;
$scope.$broadcast("recregistplace", $scope.transformResultObj.registplace);
$scope.transformResultObj.areaid = response.company.areaid;
$scope.transformResultObj.orgaddress = response.company.detailaddress;
$scope.transformResultObj.orgtel = response.company.contactnum;
}
if (UtilService.isDefined(response.company_techrequirement_lk) && response.company_techrequirement_lk.length > 0) {
angular.forEach(response.company_techrequirement_lk, function (value, index) {
var temphtml = {
text: '' + value.techrequirementname + '',
reqid: value.id,
reqname: value.techrequirementname
};
reqnamebuttons.push(temphtml);
});
reqlist = response.company_techrequirement_lk;
var temphtml2 = {
text: '现场发现需求',
reqid: 0,
reqname: "现场发现需求"
};
reqnamebuttons.push(temphtml2);
}
}, function () {
});
};
//时间选择器
$(function () {
var currYear = (new Date()).getFullYear();
var opt = {};
opt.date = {preset: 'date'};
opt.datetime = {preset: 'datetime'};
opt.time = {preset: 'time'};
opt.default = {
theme: 'android-ics light', //皮肤样式
display: 'bottom', //显示方式
mode: 'scroller', //日期选择模式
dateFormat: 'yyyy年mm月dd日',
lang: 'zh',
showNow: true,
nowText: "今天",
startYear: currYear - 50, //开始年份
endYear: currYear + 10 //结束年份
};
/*$("#appDateTime").mobiscroll($.extend(opt['date'], opt['default']));*/
var optDateTime = $.extend(opt['datetime'], opt['default']);
$("#transformDateTime").mobiscroll(optDateTime).date(optDateTime);
});
//选择合作方式
var transformcooperationNameLabels = [
{ text: "方式A",
transformcooperationName:"方式A",
transformcooperationId: "0"
},
{ text: "方式B",
transformcooperationName:"方式B",
transformcooperationId: "1"
},
{ text: "方式C",
transformcooperationName:"方式C",
transformcooperationId: "2"
},
{ text: "方式D",
transformcooperationName:"方式D",
transformcooperationId: "3"
}
];
$scope.showCooperationName=function () {
$ionicActionSheet.show({
cancelOnStateChange: true,
cssClass: 'action_s',
cancelText: '取消',
buttons: transformcooperationNameLabels,
buttonClicked: function (index) {
$scope.transformResultObj.transformcooperationId = transformcooperationNameLabels[index].transformcooperationId;
$scope.transformResultObj.transformcooperationName = transformcooperationNameLabels[index].transformcooperationName;
return true;
},
destructiveButtonClicked: function () {
return true;
}
});
};
//选择合作状态
var transformcooperationStateLabels = [
{ text: "启动",
transformcooperationState:"启动",
transformcooperationStateId: "0"
},
{ text: "进行中",
transformcooperationStateName:"进行中",
transformcooperationStateId: "1"
},
{ text: "完成",
transformcooperationStateName:"完成",
transformcooperationStateId: "2"
}
];
$scope.showCooperationState=function () {
$ionicActionSheet.show({
cancelOnStateChange: true,
cssClass: 'action_s',
cancelText: '取消',
buttons: transformcooperationStateLabels,
buttonClicked: function (index) {
$scope.transformResultObj.transformcooperationStateId = transformcooperationStateLabels[index].transformcooperationStateId;
$scope.transformResultObj.transformcooperationStateName = transformcooperationStateLabels[index].transformcooperationStateName;
return true;
},
destructiveButtonClicked: function () {
return true;
}
});
};
});