123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458 |
- angular.module('push')
- .controller('ActivityScheduleCtrl', function ($scope, $stateParams, CommentService, $ionicActionSheet, DockingService, UtilService, $ionicSlideBoxDelegate, $timeout, $ionicScrollDelegate, UserService) {
- var today = UtilService.formatDate().formattime3.substring(0,11);
- $scope.activityobj = {
- isUpdate: 1,//1新增 2编辑
- aid: 0,
- atitle: "",
- connid: $stateParams.infoid,
- sourcefrom: 1,// 来源:1-APP 2-WEB
- leadername: "",// 团队负责人姓名
- leaderuniversity: "",// 所属院校id
- leaderuniversityname: "",// 所属院校
- leadertel: "",// 联系方式
- companyid: "",// 企业id
- orgname: "",// 企业名称
- orgleadername: "",// 企业负责人姓名
- orgleaderduties: "",// 负责人职务
- registplace: "",// 所在地区
- areaid: "",
- orgaddress: "",// 详细地址
- orgtel: "",// 企业联系方式
- tagname: "",// 对接状态名称
- tagid: 0,// 对接状态
- tagtime: today,// 对接时间
- tagcontent: "",// 需求指导思路
- // capital_scale: 0,// 需求预算
- // cooperationmodelname: "",// 拟合作模式名称
- dockingid : 0,// 对接需求id
- docking_content: "",// 对接需求名称
- newdocking_content: "",
- techrequirementdetail: "",
- technical_description: "",// 现场需求简介
- imagelist: []
- // industry_title: "",// 产学研或科技服务项目名称
- // industry_description: ""// 产学研或科技服务项目简介
- };
- $("#dockingDateTime").attr("value",today);
- $scope.showreqdetail = false;
- $scope.imagelist = [];
- $scope.showmorecompany = false;
- $scope.showmorereq = false;
- //获取对接状态标签
- var reqnamebuttons = [];
- //根据记录id获取新建需求反馈所需的初始化信息
- var initActivitiesFollowup = function () {
- DockingService.initActivitiesFollowup($stateParams.infoid).then(function (response) {
- console.log(response);
- if (UtilService.isDefined(response.activitymodel)) {
- $scope.activityobj.aid = response.activitymodel.id;
- $scope.activityobj.atitle = response.activitymodel.title;
- }
- if (UtilService.isDefined(response.sysUsersInfo)) {
- $scope.activityobj.leadername = response.sysUsersInfo.name;
- $scope.activityobj.leaderuniversity = response.sysUsersInfo.universityid;
- $scope.activityobj.leaderuniversityname = response.sysUsersInfo.universityname;
- $scope.$broadcast("recuniversity",response.sysUsersInfo.universityname);
- $scope.activityobj.leadertel = UserService.user.user.mobile;
- }
- if (UtilService.isDefined(response.company)) {
- $scope.activityobj.companyid = response.company.companyid;
- $scope.activityobj.orgname = response.company.companyname;
- $scope.activityobj.orgleadername = response.company.contact;
- $scope.activityobj.orgleaderduties = response.company.c_title;
- $scope.activityobj.registplace = response.company.district;
- $scope.$broadcast("recregistplace",$scope.activityobj.registplace);
- $scope.activityobj.areaid = response.company.companyareaid;
- $scope.activityobj.orgaddress = response.company.detailaddress;
- $scope.activityobj.orgtel = response.company.contactnum;
- }
- if (UtilService.isDefined(response.reqList) && response.reqList.length>0) {
- angular.forEach(response.reqList, function (value, index) {
- var temphtml = {
- text: '<a class="action-sheet-push">' + value.techrequirementname + '</a>',
- reqid: value.id,
- reqname: value.techrequirementname
- };
- reqnamebuttons.push(temphtml);
- });
- var temphtml2 = {
- text: '<a class="action-sheet-push">现场发现需求</a>',
- reqid: 0,
- reqname: "现场发现需求"
- };
- reqnamebuttons.push(temphtml2);
- }
- }, function () {
- });
- };
- initActivitiesFollowup();
- //获取对接状态标签
- var buttons = [];
- var getLabelList = function () {
- CommentService.getLabelList().then(function (response) {
- angular.forEach(response, function (value, index) {
- var temphtml = {
- text: '<a class="action-sheet-push">' + value.name + '</a>',
- tagid: value.id,
- tagname: value.name
- };
- buttons.push(temphtml);
- });
- }, function () {
- })
- };
- getLabelList();
- //保存活动跟进表
- var saveflg = 0;
- $scope.saveActivitySchedule = function () {
- var tempstr = $("#dockingDateTime").val();
- if (UtilService.isDefined(tempstr)) {
- $scope.activityobj.tagtime = UtilService.formatTime(tempstr);
- }
- if (!UtilService.isDefined($scope.activityobj.tagtime)) {
- UtilService.showMess("对接时间不能为空");
- return;
- }
- if (!UtilService.isDefined($scope.activityobj.tagname)) {
- UtilService.showMess("请选择对接状态");
- return;
- }
- if (!UtilService.isDefined($scope.activityobj.leadername)) {
- UtilService.showMess("团队负责人姓名不能为空");
- return;
- }
- if (!UtilService.isDefined($scope.activityobj.leaderuniversityname)) {
- UtilService.showMess("所属院校名称不能为空");
- return;
- }
- /*if (!UtilService.isDefined($scope.activityobj.leadertel)) {
- UtilService.showMess("负责人联系方式不能为空");
- return;
- }*/
- if (!UtilService.isDefined($scope.activityobj.orgname)) {
- UtilService.showMess("对接企业名称不能为空");
- return;
- }
- /*if (!UtilService.isDefined($scope.activityobj.orgleadername)) {
- UtilService.showMess("对接企业负责人姓名不能为空");
- return;
- }
- if (!UtilService.isDefined($scope.activityobj.orgleaderduties)) {
- UtilService.showMess("对接企业负责人职务不能为空");
- return;
- }
- if (!UtilService.isDefined($scope.activityobj.registplace)) {
- UtilService.showMess("对接企业所在地区不能为空");
- return;
- }
- if (!UtilService.isDefined($scope.activityobj.orgaddress)) {
- UtilService.showMess("对接企业详细地址不能为空");
- return;
- }
- if (!UtilService.isDefined($scope.activityobj.orgtel)) {
- UtilService.showMess("企业联系方式不能为空");
- return;
- }*/
- if ($scope.activityobj.dockingid != 0 && !UtilService.isDefined($scope.activityobj.docking_content)) {
- UtilService.showMess("需求名称不能为空");
- return;
- }
- if ($scope.activityobj.dockingid == 0 && !UtilService.isDefined($scope.activityobj.newdocking_content)) {
- UtilService.showMess("现场需求名称不能为空");
- return;
- }
- if ($scope.activityobj.dockingid == 0){
- $scope.activityobj.docking_content = $scope.activityobj.newdocking_content;
- }
- if (!UtilService.isDefined($scope.activityobj.tagcontent)) {
- UtilService.showMess("需求指导思路不能为空");
- return;
- }
- /*if (!UtilService.isDefined($scope.activityobj.industry_title)) {
- UtilService.showMess("项目名称不能为空");
- return;
- }
- if (!UtilService.isDefined($scope.activityobj.industry_description)) {
- UtilService.showMess("对接项目简介不能为空");
- 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({
- photo_name: value.userPhoto,
- original_name: value.originalPhoto,
- source_name: value.sourcePhoto,
- source_size: value.source_size
- });
- }
- });
- $timeout(function () {
- $scope.activityobj.imagelist = angular.toJson(tempimages);
- saveInfo();
- }, 100);
- }, function () {
- $scope.hideLoadingToast();
- UtilService.showMess("网络不给力,请重试");
- saveflg = 0;
- })
- };
- var saveInfo = function () {
- console.log($scope.activityobj);
- DockingService.saveActivitySchedule($scope.activityobj).then(function (response) {
- console.log(response);
- if (response.isSuccess == 1) {
- UtilService.showMess("添加成功");
- $timeout(function () {
- $scope.goback();
- }, 1500);
- } else {
- UtilService.showMess("网络不给力,请重试");
- }
- $scope.hideLoadingToast();
- saveflg = 0;
- }, function () {
- UtilService.showMess("网络不给力,请重试");
- $scope.hideLoadingToast();
- saveflg = 0;
- })
- };
- //展示企业选择列表
- $scope.selectCompany = function () {
- $scope.showmorecompany = !$scope.showmorecompany;
- };
- //选择企业
- $scope.checkCompany = function (company) {
- $scope.activityobj.orgname = company;
- $scope.showmorecompany = false;
- };
- //展示需求选择列表
- $scope.selectReq = function () {
- $scope.showmorereq = !$scope.showmorereq;
- };
- //选择需求
- $scope.checkReq = function (req) {
- $scope.activityobj.docking_content = req;
- $scope.showmorereq = false;
- };
- //选择对接状态
- $scope.showDockingStatus = function () {
- $ionicActionSheet.show({
- buttons: buttons,
- cancelText: '取消',
- buttonClicked: function (index) {
- $scope.activityobj.tagid = buttons[index].tagid;
- $scope.activityobj.tagname = buttons[index].tagname;
- return true;
- }
- });
- };
- //选择需求名称
- $scope.showReqName = function () {
- $ionicActionSheet.show({
- buttons: reqnamebuttons,
- cancelText: '取消',
- buttonClicked: function (index) {
- $scope.activityobj.dockingid = reqnamebuttons[index].reqid;
- $scope.activityobj.docking_content = reqnamebuttons[index].reqname;
- if(reqnamebuttons[index].reqid==0){
- $scope.showreqdetail = true;
- }else {
- $scope.showreqdetail = false;
- }
- return true;
- }
- });
- };
- //接收高校选择数据
- var reciveuniversity = $scope.$on("university", function (event, data) {
- $scope.activityobj.leaderuniversity = data.id;
- $scope.activityobj.leaderuniversityname = data.name;
- });
- //接收城市选择数据
- var reciveregplace = $scope.$on("registplace", function (event, data) {
- $scope.activityobj.areaid = data.areaid;
- $scope.activityobj.registplace = data.registplace;
- });
- //页面销毁时 回收广播
- $scope.$on('$destroy', function () {
- reciveregplace();
- reciveuniversity();
- });
- $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: '<a class="action-sheet-push">相册中添加照片</a>'},
- {text: '<a class="action-sheet-push">拍照</a>'}
- ],
- 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) {
- $scope.imagelist.splice(index, 1);
- };
- //时间选择器
- $(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']);
- $("#dockingDateTime").mobiscroll(optDateTime).date(optDateTime);
- });
- });
|