activityFeedBackCtrl.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. angular.module('push')
  2. .controller('activityFeedBackCtrl', function ($scope, $stateParams, CommentService, $ionicActionSheet, ActivityService, UtilService, $ionicSlideBoxDelegate,
  3. $timeout, $ionicScrollDelegate, UserService, $ionicModal, DockingService) {
  4. var activityid = $stateParams.activityid;
  5. var title = $stateParams.title;
  6. var today = UtilService.formatDate().formattime3.substring(0, 11);
  7. $scope.activityobj = {
  8. isUpdate: 1,//1新增 2编辑
  9. aid: activityid,
  10. atitle: title,
  11. connid: 0,
  12. sourcefrom: 1,// 来源:1-APP 2-WEB
  13. leadername: "",// 团队负责人姓名
  14. leaderuniversity: "",// 所属院校id
  15. leaderuniversityname: "",// 所属院校
  16. leadertel: "",// 联系方式
  17. companyid: "",// 企业id
  18. orgname: "",// 企业名称
  19. orgleadername: "",// 企业负责人姓名
  20. orgleaderduties: "",// 负责人职务
  21. registplace: "",// 所在地区
  22. areaid: "",
  23. orgaddress: "",// 详细地址
  24. orgtel: "",// 企业联系方式
  25. tagname: "",// 对接状态名称
  26. tagid: 0,// 对接状态
  27. tagtime: today,// 对接时间
  28. tagcontent: "",// 需求指导思路
  29. capital_scale: 0,// 需求预算
  30. cooperationmodel: "",// 拟合作模式名称
  31. dockingid: 0,// 对接需求id
  32. docking_content: "",// 对接需求名称
  33. newdocking_content: "",
  34. techrequirementdetail: "",
  35. technical_description: "",// 现场需求简介
  36. imagelist: []
  37. // industry_title: "",// 产学研或科技服务项目名称
  38. // industry_description: ""// 产学研或科技服务项目简介
  39. };
  40. $("#dockingDateTime").attr("value", today);
  41. $scope.showreqdetail = false;
  42. $scope.imagelist = [];
  43. $scope.showmorecompany = false;
  44. $scope.showmorereq = false;
  45. $scope.companylist = [];
  46. //获取对接状态标签
  47. var reqnamebuttons = [];
  48. //根据记录id获取新建需求反馈所需的初始化信息
  49. var initActivitiesFollowup = function () {
  50. ActivityService.initFollowupInfo(activityid).then(function (response) {
  51. // console.log(response);
  52. // 用户基本信息
  53. if (UtilService.isDefined(response.sysUsersInfo)) {
  54. $scope.activityobj.leadername = response.sysUsersInfo.name;
  55. $scope.activityobj.leaderuniversity = response.sysUsersInfo.universityid;
  56. $scope.activityobj.leaderuniversityname = response.sysUsersInfo.university;
  57. $scope.$broadcast("recuniversity", response.sysUsersInfo.university);
  58. $scope.activityobj.leadertel = UserService.user.user.mobile;
  59. }
  60. // 活动下用户已配对企业列表
  61. if (UtilService.isDefined(response.company) && response.company.length > 0) {
  62. $scope.companylist = response.company;
  63. }
  64. }, function () {
  65. })
  66. };
  67. initActivitiesFollowup();
  68. //获取对接状态标签
  69. var buttons = [];
  70. var getLabelList = function () {
  71. CommentService.getLabelList().then(function (response) {
  72. angular.forEach(response, function (value, index) {
  73. var temphtml = {
  74. text: '<a class="action-sheet-push">' + value.name + '</a>',
  75. tagid: value.id,
  76. tagname: value.name
  77. };
  78. buttons.push(temphtml);
  79. });
  80. }, function () {
  81. })
  82. };
  83. getLabelList();
  84. //保存活动跟进表
  85. var saveflg = 0;
  86. $scope.saveActivitySchedule = function () {
  87. var tempstr = $("#dockingDateTime").val();
  88. if (UtilService.isDefined(tempstr)) {
  89. $scope.activityobj.tagtime = UtilService.formatTime(tempstr);
  90. }
  91. if (!UtilService.isDefined($scope.activityobj.tagtime)) {
  92. UtilService.showMess("对接时间不能为空");
  93. return;
  94. }
  95. if (!UtilService.isDefined($scope.activityobj.tagname)) {
  96. UtilService.showMess("请选择对接状态");
  97. return;
  98. }
  99. if (!UtilService.isDefined($scope.activityobj.leadername)) {
  100. UtilService.showMess("团队负责人姓名不能为空");
  101. return;
  102. }
  103. if (!UtilService.isDefined($scope.activityobj.leaderuniversityname)) {
  104. UtilService.showMess("所属院校名称不能为空");
  105. return;
  106. }
  107. /*if (!UtilService.isDefined($scope.activityobj.leadertel)) {
  108. UtilService.showMess("负责人联系方式不能为空");
  109. return;
  110. }*/
  111. if (!UtilService.isDefined($scope.activityobj.orgname)) {
  112. UtilService.showMess("对接企业名称不能为空");
  113. return;
  114. }
  115. /*if (!UtilService.isDefined($scope.activityobj.orgleadername)) {
  116. UtilService.showMess("对接企业负责人姓名不能为空");
  117. return;
  118. }
  119. if (!UtilService.isDefined($scope.activityobj.orgleaderduties)) {
  120. UtilService.showMess("对接企业负责人职务不能为空");
  121. return;
  122. }
  123. if (!UtilService.isDefined($scope.activityobj.registplace)) {
  124. UtilService.showMess("对接企业所在地区不能为空");
  125. return;
  126. }
  127. if (!UtilService.isDefined($scope.activityobj.orgaddress)) {
  128. UtilService.showMess("对接企业详细地址不能为空");
  129. return;
  130. }
  131. if (!UtilService.isDefined($scope.activityobj.orgtel)) {
  132. UtilService.showMess("企业联系方式不能为空");
  133. return;
  134. }*/
  135. if ($scope.activityobj.dockingid != 0 && !UtilService.isDefined($scope.activityobj.docking_content)) {
  136. UtilService.showMess("需求名称不能为空");
  137. return;
  138. }
  139. if ($scope.activityobj.dockingid == 0 && !UtilService.isDefined($scope.activityobj.newdocking_content)) {
  140. UtilService.showMess("现场需求名称不能为空");
  141. return;
  142. }
  143. if ($scope.activityobj.dockingid == 0) {
  144. $scope.activityobj.docking_content = $scope.activityobj.newdocking_content;
  145. }
  146. if (!UtilService.isDefined($scope.activityobj.tagcontent)) {
  147. UtilService.showMess("需求指导思路不能为空");
  148. return;
  149. }
  150. /*if (!UtilService.isDefined($scope.activityobj.industry_title)) {
  151. UtilService.showMess("项目名称不能为空");
  152. return;
  153. }
  154. if (!UtilService.isDefined($scope.activityobj.industry_description)) {
  155. UtilService.showMess("对接项目简介不能为空");
  156. return;
  157. }*/
  158. if (saveflg != 0) {
  159. return;
  160. }
  161. saveflg = 1;
  162. $scope.showLoadingToast();
  163. if ($scope.imagelist.length > 0) {
  164. uploadImages();
  165. } else {
  166. saveInfo();
  167. }
  168. };
  169. var tempimages = [];
  170. var uploadImages = function () {
  171. tempimages = [];
  172. var upimages = [];
  173. angular.forEach($scope.imagelist, function (data) {
  174. upimages.push(data.photo_name);
  175. });
  176. UtilService.uploadFile(upimages, 0, "image/jpeg").then(function (response) {
  177. // console.log(response);
  178. angular.forEach(response, function (value) {
  179. if (value.status) {
  180. tempimages.push({
  181. photo_name: value.userPhoto,
  182. original_name: value.originalPhoto,
  183. source_name: value.sourcePhoto,
  184. source_size: value.source_size
  185. });
  186. }
  187. });
  188. $timeout(function () {
  189. $scope.activityobj.imagelist = angular.toJson(tempimages);
  190. saveInfo();
  191. }, 100);
  192. }, function () {
  193. $scope.hideLoadingToast();
  194. UtilService.showMess("网络不给力,请重试");
  195. saveflg = 0;
  196. })
  197. };
  198. var saveInfo = function () {
  199. // console.log($scope.activityobj);
  200. DockingService.saveActivitySchedule($scope.activityobj).then(function (response) {
  201. // console.log(response);
  202. if (response.isSuccess == 1) {
  203. UtilService.showMess("添加成功");
  204. $timeout(function () {
  205. $scope.goback();
  206. }, 1500);
  207. } else {
  208. UtilService.showMess("网络不给力,请重试");
  209. }
  210. $scope.hideLoadingToast();
  211. saveflg = 0;
  212. }, function () {
  213. UtilService.showMess("网络不给力,请重试");
  214. $scope.hideLoadingToast();
  215. saveflg = 0;
  216. })
  217. };
  218. //展示企业选择列表
  219. $scope.selectCompany = function () {
  220. $scope.showmorecompany = !$scope.showmorecompany;
  221. };
  222. //选择企业
  223. $scope.checkCompany = function (company) {
  224. $scope.activityobj.orgname = company;
  225. $scope.showmorecompany = false;
  226. };
  227. //展示需求选择列表
  228. $scope.selectReq = function () {
  229. $scope.showmorereq = !$scope.showmorereq;
  230. };
  231. //选择需求
  232. $scope.checkReq = function (req) {
  233. $scope.activityobj.docking_content = req;
  234. $scope.showmorereq = false;
  235. };
  236. //选择对接状态
  237. $scope.showDockingStatus = function () {
  238. $ionicActionSheet.show({
  239. buttons: buttons,
  240. cancelText: '取消',
  241. buttonClicked: function (index) {
  242. $scope.activityobj.tagid = buttons[index].tagid;
  243. $scope.activityobj.tagname = buttons[index].tagname;
  244. return true;
  245. }
  246. });
  247. };
  248. //选择需求名称
  249. $scope.showReqName = function () {
  250. $ionicActionSheet.show({
  251. buttons: reqnamebuttons,
  252. cancelText: '取消',
  253. buttonClicked: function (index) {
  254. if (reqlist.length == index) {
  255. $scope.showreqdetail = true;
  256. } else {
  257. $scope.activityobj.dockingid = reqlist[index].id;
  258. $scope.activityobj.docking_content = reqlist[index].techrequirementname;
  259. $scope.activityobj.technical_description = reqlist[index].techrequirementdetail;
  260. $scope.activityobj.cooperationmodel = UtilService.isDefined(reqlist[index].cooperationmodel) ? reqlist[index].cooperationmodel : "";
  261. $scope.activityobj.capital_scale = UtilService.isDefined(reqlist[index].capital_scale) ? reqlist[index].capital_scale : 0;
  262. $scope.showreqdetail = false;
  263. }
  264. return true;
  265. }
  266. });
  267. };
  268. //接收高校选择数据
  269. var reciveuniversity = $scope.$on("university", function (event, data) {
  270. $scope.activityobj.leaderuniversity = data.id;
  271. $scope.activityobj.leaderuniversityname = data.name;
  272. });
  273. //接收城市选择数据
  274. var reciveregplace = $scope.$on("registplace", function (event, data) {
  275. $scope.activityobj.areaid = data.areaid;
  276. $scope.activityobj.registplace = data.registplace;
  277. });
  278. //页面销毁时 回收广播
  279. $scope.$on('$destroy', function () {
  280. reciveregplace();
  281. reciveuniversity();
  282. });
  283. $scope.openCamera = function () {
  284. if ($scope.imagelist.length >= 9) {
  285. UtilService.showMess("最多选取9张图片");
  286. return;
  287. }
  288. UtilService.getPicture(1).then(function (results) {
  289. // console.log(results);
  290. $scope.imagelist.push({photo_name: results, original_name: results});
  291. $scope.totalImglength = 600 * $scope.imagelist.length;
  292. $ionicScrollDelegate.$getByHandle("scrollimage").resize();
  293. }, function (err) {
  294. });
  295. };
  296. $scope.show = function () {
  297. $ionicActionSheet.show({
  298. buttons: [
  299. {text: '<a class="action-sheet-push">相册中添加照片</a>'},
  300. {text: '<a class="action-sheet-push">拍照</a>'}
  301. ],
  302. cancelText: '取消',
  303. buttonClicked: function (index) {
  304. if (index == 0) {
  305. getPictures();
  306. } else if (index == 1) {
  307. $scope.openCamera();
  308. }
  309. return true;
  310. }
  311. });
  312. };
  313. var verifyStorage = function () {
  314. window.imagePicker.verifyStorage(
  315. function (results) {
  316. if (results == "1") {
  317. getPic();
  318. }
  319. }, function (error) {
  320. }
  321. );
  322. };
  323. var getPic = function () {
  324. if ($scope.imagelist.length >= 9) {
  325. UtilService.showMess("最多选取9张图片");
  326. return;
  327. }
  328. UtilService.getPictureList(9 - $scope.imagelist.length).then(function (results) {
  329. // console.log(results);
  330. angular.forEach(results, function (value, index) {
  331. $scope.imagelist.push({photo_name: value, original_name: value})
  332. });
  333. $scope.totalImglength = 600 * $scope.imagelist.length;
  334. $ionicScrollDelegate.$getByHandle("scrollimage").resize();
  335. }, function (err) {
  336. });
  337. };
  338. var getPictures = function () {
  339. if (device.platform == "Android") {
  340. verifyStorage();
  341. } else {
  342. getPic();
  343. }
  344. };
  345. //点击图片放大
  346. $scope.bigImage = false; //初始默认大图是隐藏的
  347. $scope.hideBigImage = function () {
  348. if($scope.app){
  349. $scope.setStatusBar(0);
  350. }
  351. $timeout(function () {
  352. $scope.bigImage = false;
  353. }, 400);
  354. };
  355. $scope.shouBigImage = function (index) { //传递一个参数(图片的URl)
  356. if($scope.app){
  357. $scope.setStatusBar(1);
  358. }
  359. $(function () {
  360. $('div.pinch-zoom').each(function () {
  361. new RTP.PinchZoom($(this), {});
  362. });
  363. });
  364. $scope.bigImage = true;//显示大图
  365. $ionicSlideBoxDelegate.update();//重绘,让图片显示出来
  366. //图片总数量
  367. setTimeout(function () {
  368. $ionicSlideBoxDelegate.$getByHandle('slide_detail').slide(index, -10);
  369. //获取图片
  370. var imgObj = document.getElementsByClassName('bigimage');
  371. var n;
  372. for (n = 0; n < imgObj.length; n++) {
  373. // 获取图片的原始高度和宽度
  374. var oldWid = imgObj[n].naturalWidth;
  375. var oldHei = imgObj[n].naturalHeight;
  376. var screen = document.body.offsetWidth;
  377. var screenH = window.innerHeight;
  378. // console.log(oldWid / oldHei);
  379. // console.log(screen);
  380. var rate=oldWid/oldHei;
  381. if(oldWid>=screen&&oldHei>=screenH){
  382. var tw=screen;
  383. var th=tw/rate;
  384. if(th<screenH){
  385. imgObj[n].style.width = tw + 'px';
  386. imgObj[n].style.height = th + 'px';
  387. imgObj[n].style.marginTop=(screenH-th)/2+ 'px';
  388. }else{
  389. imgObj[n].style.width = screenH*rate + 'px';
  390. imgObj[n].style.height = screenH + 'px';
  391. imgObj[n].style.marginLeft=(screen-screenH*rate)/2+ 'px';
  392. }
  393. }else if(oldWid>=screen&&oldHei<=screenH){
  394. imgObj[n].style.width = screen + 'px';
  395. imgObj[n].style.height = screen/rate + 'px';
  396. imgObj[n].style.marginTop=(screenH-screen/rate)/2+ 'px';
  397. }else if(oldWid<=screen&&oldHei>=screenH){
  398. // var hh=screenH;
  399. // var ww=screenH*rate;
  400. imgObj[n].style.width = screenH*rate + 'px';
  401. imgObj[n].style.height = screenH + 'px';
  402. imgObj[n].style.marginLeft=(screen-screenH*rate)/2+ 'px';
  403. }else{
  404. imgObj[n].style.width = oldWid + 'px';
  405. imgObj[n].style.height = oldHei + 'px';
  406. imgObj[n].style.marginLeft=(screen-oldWid)/2+ 'px';
  407. imgObj[n].style.marginTop=(screenH-oldHei)/2+ 'px';
  408. }
  409. }
  410. }, 500);
  411. };
  412. //删除图片
  413. $scope.deletePhoto = function (index) {
  414. $scope.imagelist.splice(index, 1);
  415. };
  416. //时间选择器
  417. $(function () {
  418. var currYear = (new Date()).getFullYear();
  419. var opt = {};
  420. opt.date = {preset: 'date'};
  421. opt.datetime = {preset: 'datetime'};
  422. opt.time = {preset: 'time'};
  423. opt.default = {
  424. theme: 'android-ics light', //皮肤样式
  425. display: 'bottom', //显示方式
  426. mode: 'scroller', //日期选择模式
  427. dateFormat: 'yyyy年mm月dd日',
  428. lang: 'zh',
  429. showNow: true,
  430. nowText: "今天",
  431. startYear: currYear - 50, //开始年份
  432. endYear: currYear + 10 //结束年份
  433. };
  434. /*$("#appDateTime").mobiscroll($.extend(opt['date'], opt['default']));*/
  435. var optDateTime = $.extend(opt['datetime'], opt['default']);
  436. $("#dockingDateTime").mobiscroll(optDateTime).date(optDateTime);
  437. });
  438. $ionicModal.fromTemplateUrl('./modules/common/views/selectCompany.html', {
  439. scope: $scope,
  440. animation: 'slide-in-up'
  441. }).then(function (modal) {
  442. $scope.selCom = modal;
  443. });
  444. //打开企业列表弹窗
  445. $scope.showCompany = function () {
  446. if (localStorage.wxFlag == "true") {
  447. if (localStorage.isUserFocusXW == 0) {
  448. var title = localStorage.appidStr;
  449. $ionicPopup.alert({
  450. title: '提示',
  451. template: '请先关注微信公众号"' + title + '"!'
  452. });
  453. return;
  454. } else {
  455. if (localStorage.isUserBindWx == 0) {
  456. var wxFlag = JSON.parse(localStorage.params);
  457. if (wxFlag.weChatModel) {
  458. $scope.go('bindPhone', {
  459. params: localStorage.params,
  460. comfrom: 'maincontroller',
  461. url: window.location.href.split('#/')[1]
  462. });
  463. } else {
  464. $scope.go('login');
  465. return;
  466. }
  467. } else {
  468. $scope.go('login');
  469. return;
  470. }
  471. }
  472. } else {
  473. $scope.go('login');
  474. return;
  475. }
  476. };
  477. //关闭企业列表弹窗
  478. $scope.hideModel = function () {
  479. $scope.selCom.hide();
  480. };
  481. //选择企业
  482. $scope.saveCompany = function (com) {
  483. getCompanyInfo(com.companyid);
  484. $scope.activityobj.companyid = com.companyid;// 企业id
  485. $scope.activityobj.orgname = com.companyname;
  486. $scope.selCom.hide();
  487. };
  488. // 获取企业详细信息
  489. var reqlist = [];
  490. var getCompanyInfo = function (companyid) {
  491. ActivityService.initFollowupCompanyInfo(companyid).then(function (response) {
  492. // console.log(response);
  493. if (UtilService.isDefined(response.company)) {
  494. $scope.activityobj.companyid = response.company.companyid;
  495. $scope.activityobj.orgname = response.company.companyname;
  496. $scope.activityobj.orgleadername = response.company.contact;
  497. $scope.activityobj.orgleaderduties = response.company.c_title;
  498. $scope.activityobj.registplace = response.company.district;
  499. $scope.$broadcast("recregistplace", $scope.activityobj.registplace);
  500. $scope.activityobj.areaid = response.company.areaid;
  501. $scope.activityobj.orgaddress = response.company.detailaddress;
  502. $scope.activityobj.orgtel = response.company.contactnum;
  503. }
  504. if (UtilService.isDefined(response.company_techrequirement_lk) && response.company_techrequirement_lk.length > 0) {
  505. angular.forEach(response.company_techrequirement_lk, function (value, index) {
  506. var temphtml = {
  507. text: '<a class="action-sheet-push">' + value.techrequirementname + '</a>',
  508. reqid: value.id,
  509. reqname: value.techrequirementname
  510. };
  511. reqnamebuttons.push(temphtml);
  512. });
  513. reqlist = response.company_techrequirement_lk;
  514. var temphtml2 = {
  515. text: '<a class="action-sheet-push">现场发现需求</a>',
  516. reqid: 0,
  517. reqname: "现场发现需求"
  518. };
  519. reqnamebuttons.push(temphtml2);
  520. }
  521. }, function () {
  522. });
  523. };
  524. });