CloudAddConnInfoCtrl.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  1. angular.module('push')
  2. .controller('CloudAddConnInfoCtrl', function ($scope, $ionicHistory, $ionicActionSheet, $ionicModal, $ionicPopup, $timeout, UtilService, DockingService, UserService, AuthorityService,
  3. CloudFolderService, ModelService, $ionicScrollDelegate, HandleService, $ionicSlideBoxDelegate, SqliteStorageService, ConfigService) {
  4. if($scope.app){
  5. $scope.setStatusBar(0);
  6. }
  7. var text = document.getElementById("add_list_content");
  8. autoTextarea(text);// 调用
  9. $scope.search = {searchkey: ""};
  10. $scope.level = 0;
  11. $scope.checkfolder = "";//被选中的文件夾id
  12. //记录新建类型 0:首页,1:本地,2:云
  13. if (ModelService.getCreateType() == 0) {
  14. $scope.folderlist = angular.copy(ModelService.getFolderList());
  15. } else if (ModelService.getCreateType() == 1) {
  16. $scope.folderlist = angular.copy(ModelService.getLocalFolderList());
  17. } else {
  18. $scope.folderlist = angular.copy(ModelService.getCloudFolderList());
  19. }
  20. //默认选择文件夹
  21. $scope.checkdefolder = ModelService.getCheckdeFolder();
  22. //获取选择的文件夹的id/localid
  23. if ($scope.checkdefolder.isCloud == 0) {
  24. $scope.checkfolder = $scope.checkdefolder.localid;
  25. }
  26. if ($scope.checkdefolder.isCloud == 1) {
  27. $scope.checkfolder = $scope.checkdefolder.id + "";
  28. }
  29. //筛选选择文件夹
  30. angular.forEach($scope.folderlist, function (value, index) {
  31. if ($scope.checkdefolder.isCloud == 0) {
  32. if (value.localid == $scope.checkdefolder.localid) {
  33. $scope.folderlist[index].value = true;
  34. }
  35. } else {
  36. if (value.id == $scope.checkdefolder.id) {
  37. $scope.folderlist[index].value = true;
  38. }
  39. }
  40. });
  41. //是否是第一次打开 0:是,1:不是
  42. if (ModelService.getIsFirstOpen() == 1) {
  43. $scope.record = ModelService.getConninfo();
  44. } else {
  45. var tempdate = UtilService.formatDate();
  46. $scope.record = {
  47. date: tempdate.formattime3,
  48. conntime: tempdate.formattime,
  49. title: "",
  50. flag: 0,
  51. content: ""
  52. };
  53. }
  54. $scope.imagelist = ModelService.getImageList();//图片
  55. $scope.cardlist = ModelService.getCardList();
  56. angular.forEach($scope.cardlist, function (value, index) {
  57. if (angular.isDefined(value.personlist) && value.personlist.length > 0) {
  58. var contactsrt = [];
  59. angular.forEach(value.personlist, function (val, ind) {
  60. contactsrt.push(val.contact);
  61. });
  62. $scope.cardlist[index].contactsrt = contactsrt.join("、");
  63. }
  64. });
  65. $ionicModal.fromTemplateUrl('templates/modal.html', {
  66. scope: $scope,
  67. animation: 'slide-in-up'
  68. }).then(function (modal) {
  69. $scope.modal = modal;
  70. });
  71. //关闭选择文件夹
  72. $scope.closeModel = function () {
  73. $scope.modal.hide();
  74. // angular.forEach($scope.folderlist, function (value, ind) {
  75. // if (value.value) {
  76. // $scope.checkdefolder = value;
  77. // }
  78. // });
  79. };
  80. //选择分类
  81. $scope.chooseNewUndid = function (folder, index) {
  82. angular.forEach($scope.folderlist, function (value, ind) {
  83. $scope.folderlist[ind].value = false;
  84. });
  85. $scope.folderlist[index].value = true;
  86. $scope.checkdefolder = folder;
  87. if (folder.isCloud == 0) {
  88. $scope.checkfolder = folder.localid;
  89. }
  90. if (folder.isCloud == 1) {
  91. $scope.checkfolder = folder.id + "";
  92. }
  93. };
  94. //切换标记
  95. $scope.checkFlag = function () {
  96. $scope.record.flag = $scope.record.flag == 1 ? 0 : 1;
  97. };
  98. var tempimages = [];
  99. var uploadImages = function (temprecord) {
  100. tempimages = [];
  101. var upimages = [];
  102. angular.forEach($scope.imagelist, function (data) {
  103. upimages.push(data.photo_name);
  104. });
  105. UtilService.uploadFile(upimages, 0, "image/jpeg").then(function (response) {
  106. // console.log(response);
  107. angular.forEach(response, function (value) {
  108. if (value.status) {
  109. tempimages.push({
  110. photo_name: value.userPhoto,
  111. original_name: value.originalPhoto,
  112. source_name: value.sourcePhoto,
  113. source_size: value.source_size
  114. });
  115. }
  116. });
  117. $timeout(function () {
  118. if (UtilService.isDefined($scope.checkdefolder.localid)) {
  119. saveConninfoToLocal(temprecord);
  120. } else {
  121. saveInformation(temprecord);
  122. }
  123. }, 100);
  124. }, function () {
  125. if (UtilService.isDefined($scope.checkdefolder.localid)) {
  126. saveConninfoToLocal(temprecord);
  127. } else {
  128. $scope.hideLoadingToast();
  129. UtilService.showMess("网络不给力,请重试");
  130. }
  131. })
  132. };
  133. var saveInformation = function (temprecord) {
  134. temprecord.claid = $scope.checkdefolder.id;
  135. DockingService.newCreateConninfo(temprecord, tempimages, $scope.cardlist).then(function (response) {
  136. HandleService.changeflg = true;
  137. UtilService.showMess("新建记录成功");
  138. if (UserService.viplevel == 1) {
  139. $scope.deductUserMemberCount(3);
  140. }
  141. $scope.hideLoadingToast();
  142. $timeout(function () {
  143. $scope.goback();
  144. }, 1500);
  145. ModelService.resetTempData();
  146. }, function () {
  147. $scope.hideLoadingToast();
  148. UtilService.showMess("网络不给力,请重试");
  149. });
  150. };
  151. $scope.immediateRelease = function () {
  152. if (!UtilService.isDefined($scope.record.title)) {
  153. UtilService.showMess("标题不能为空");
  154. return;
  155. }
  156. var temprecord = angular.copy($scope.record);
  157. var tempstr = $("#appDateTime").val();
  158. if (UtilService.isDefined(tempstr)) {
  159. temprecord.conntime = UtilService.formatTime(tempstr);
  160. } else {
  161. temprecord.conntime = UtilService.formatTime($scope.record.date);
  162. }
  163. if (UtilService.isDefined(temprecord.content)) {
  164. temprecord.content = UtilService.replaceEnterTag(temprecord.content);
  165. }
  166. $scope.showLoadingToast();
  167. if (UtilService.checkNetWork() == "None") {
  168. saveConninfoToLocal(temprecord);
  169. } else if (UtilService.isDefined($scope.checkdefolder.localid)) {
  170. if ($scope.imagelist.length > 0) {
  171. uploadImages(temprecord);
  172. } else {
  173. saveConninfoToLocal(temprecord);
  174. }
  175. } else {
  176. if (UserService.viplevel == 1) {
  177. AuthorityService.isHasEnoughCount(3).then(function (response) {
  178. if (response.isHasEnoughCount == 1) {
  179. if ($scope.imagelist.length > 0) {
  180. uploadImages(temprecord);
  181. } else {
  182. saveInformation(temprecord);
  183. }
  184. } else {
  185. UtilService.showMess("本月新建记录次数已用完");
  186. $scope.hideLoadingToast();
  187. }
  188. }, function () {
  189. UtilService.showMess("网络不给力,请重试");
  190. $scope.hideLoadingToast();
  191. });
  192. }else {
  193. if ($scope.imagelist.length > 0) {
  194. uploadImages(temprecord);
  195. } else {
  196. saveInformation(temprecord);
  197. }
  198. }
  199. }
  200. };
  201. var checknum = 1;
  202. $scope.addisover = 0;
  203. var saveConninfoToLocal = function (temprecord) {
  204. try {
  205. var conninfodate = UtilService.formatDate();
  206. var conninfodatelocalid = conninfodate.timestamp;
  207. //对接信息数据生成
  208. temprecord.localid = conninfodatelocalid + "";
  209. temprecord.localclaid = $scope.checkdefolder.localid;
  210. temprecord.id = 0;
  211. temprecord.claid = $scope.checkdefolder.id;
  212. temprecord.creator = UserService.id;
  213. temprecord.synchrotype = 1;
  214. temprecord.createtime = conninfodate.formattime;
  215. temprecord.updatetime = conninfodate.formattime;
  216. temprecord.creatorcomefrom = ConfigService.comefrom;
  217. temprecord.status = 2;
  218. temprecord.defaultFlag = 0;
  219. temprecord.commcount = 0;
  220. temprecord.favourcount = 0;
  221. temprecord.visitcount = 0;
  222. var tempimagelist = tempimages.length > 0 ? tempimages : $scope.imagelist;
  223. //图片列表数据生成
  224. if (tempimagelist.length > 0) {
  225. checknum++;
  226. }
  227. angular.forEach(tempimagelist, function (value, index) {
  228. tempimagelist[index].localid = conninfodatelocalid + index + "";
  229. tempimagelist[index].localinfoid = conninfodatelocalid + "";
  230. tempimagelist[index].infoid = temprecord.id;
  231. tempimagelist[index].id = 0;
  232. });
  233. //名片(单位)数据生成
  234. if ($scope.cardlist.length > 0) {
  235. checknum++;
  236. }
  237. var personlist = [];
  238. var themelist = [];
  239. var productlist = [];
  240. var iur1list = [];
  241. var iur2list = [];
  242. var calendarlist = [];
  243. var date = new Date();
  244. angular.forEach($scope.cardlist, function (value, index) {
  245. var tempcardlocalid = conninfodatelocalid + index;
  246. date.setSeconds(date.getSeconds() + index);
  247. $scope.cardlist[index].localid = tempcardlocalid + "";
  248. $scope.cardlist[index].localinfoid = conninfodatelocalid + "";
  249. $scope.cardlist[index].id = 0;
  250. $scope.cardlist[index].infoid = temprecord.id;
  251. $scope.cardlist[index].creator = UserService.id;
  252. $scope.cardlist[index].synchrotype = 1;
  253. $scope.cardlist[index].creatorcomefrom = ConfigService.comefrom;
  254. $scope.cardlist[index].createtime = date.Format("yyyy-MM-dd hh:mm:ss");
  255. $scope.cardlist[index].updatetime = date.Format("yyyy-MM-dd hh:mm:ss");
  256. //人员数据生成
  257. angular.forEach(value.personlist, function (value1, ind) {
  258. var tempperson = value1;
  259. tempperson.localid = tempcardlocalid + ind + "";
  260. tempperson.localuid = tempcardlocalid + "";
  261. tempperson.id = 0;
  262. tempperson.uid = 0;
  263. tempperson.infoid = temprecord.id;
  264. personlist.push(tempperson);
  265. });
  266. //主题数据生成
  267. angular.forEach(value.themelist, function (value2, ind) {
  268. var temtheme = value2;
  269. temtheme.localid = tempcardlocalid + ind + "";
  270. temtheme.localuid = tempcardlocalid + "";
  271. temtheme.id = 0;
  272. temtheme.uid = 0;
  273. temtheme.infoid = temprecord.id;
  274. themelist.push(temtheme);
  275. });
  276. //产品数据生成
  277. angular.forEach(value.productlist, function (value2, ind) {
  278. var temproduct = value2;
  279. temproduct.localid = tempcardlocalid + ind + "";
  280. temproduct.localuid = tempcardlocalid + "";
  281. temproduct.id = 0;
  282. temproduct.uid = 0;
  283. temproduct.infoid = temprecord.id;
  284. productlist.push(temproduct);
  285. });
  286. //产学研经历数据生成
  287. angular.forEach(value.iur1list, function (value2, ind) {
  288. var temiur1 = value2;
  289. temiur1.localid = tempcardlocalid + ind + "";
  290. temiur1.localuid = tempcardlocalid + "";
  291. temiur1.id = 0;
  292. temiur1.uid = 0;
  293. temiur1.infoid = temprecord.id;
  294. iur1list.push(temiur1);
  295. });
  296. //重大科研项数据生成
  297. angular.forEach(value.iur2list, function (value2, ind) {
  298. var temiur2 = value2;
  299. temiur2.localid = tempcardlocalid + ind + "";
  300. temiur2.localuid = tempcardlocalid + "";
  301. temiur2.id = 0;
  302. temiur2.uid = 0;
  303. temiur2.infoid = temprecord.id;
  304. iur2list.push(temiur2);
  305. });
  306. //历年申报项目数据生成
  307. angular.forEach(value.calendarlist, function (value2, ind) {
  308. var tempproject = value2;
  309. tempproject.localid = tempcardlocalid + ind + "";
  310. tempproject.localuid = tempcardlocalid + "";
  311. tempproject.id = 0;
  312. tempproject.uid = 0;
  313. tempproject.infoid = temprecord.id;
  314. calendarlist.push(tempproject);
  315. });
  316. });
  317. if (personlist.length > 0) {
  318. checknum++;
  319. }
  320. if (themelist.length > 0) {
  321. checknum++;
  322. }
  323. if (productlist.length > 0) {
  324. checknum++;
  325. }
  326. if (iur1list.length > 0) {
  327. checknum++;
  328. }
  329. if (iur2list.length > 0) {
  330. checknum++;
  331. }
  332. if (calendarlist.length > 0) {
  333. checknum++;
  334. }
  335. // console.log("===========================================");
  336. // console.log(temprecord);
  337. // console.log($scope.imagelist);
  338. // console.log($scope.cardlist);
  339. // console.log(personlist);
  340. // console.log(themelist);
  341. // console.log(productlist);
  342. // console.log(iur1list);
  343. // console.log(iur2list);
  344. // console.log("===========================================");
  345. } catch (e) {
  346. $scope.hideLoadingToast();
  347. }
  348. SqliteStorageService.insertSingleData("conninfo", temprecord).then(function () {
  349. $scope.addisover++;
  350. var tempobj = {
  351. localid: $scope.checkdefolder.localid,
  352. updatetime: conninfodate.formattime
  353. };
  354. SqliteStorageService.updateSingleData("conninfofolder", tempobj);
  355. }, function () {
  356. $scope.hideLoadingToast();
  357. });
  358. if (tempimagelist.length > 0) {
  359. SqliteStorageService.insertBatchData("conninfopicture", tempimagelist).then(function () {
  360. $scope.addisover++;
  361. }, function () {
  362. $scope.hideLoadingToast();
  363. });
  364. }
  365. if ($scope.cardlist.length > 0) {
  366. SqliteStorageService.insertBatchData("conninfounit", $scope.cardlist).then(function () {
  367. $scope.addisover++;
  368. }, function () {
  369. $scope.hideLoadingToast();
  370. });
  371. }
  372. if (personlist.length > 0) {
  373. SqliteStorageService.insertBatchData("conninfoperson", personlist).then(function () {
  374. $scope.addisover++;
  375. }, function () {
  376. $scope.hideLoadingToast();
  377. });
  378. }
  379. if (themelist.length > 0) {
  380. SqliteStorageService.insertBatchData("conninfotheme", themelist).then(function () {
  381. $scope.addisover++;
  382. }, function () {
  383. $scope.hideLoadingToast();
  384. });
  385. }
  386. if (productlist.length > 0) {
  387. SqliteStorageService.insertBatchData("conninfoproduct", productlist).then(function () {
  388. $scope.addisover++;
  389. }, function () {
  390. $scope.hideLoadingToast();
  391. });
  392. }
  393. if (iur1list.length > 0) {
  394. SqliteStorageService.insertBatchData("conninfoiur", iur1list).then(function () {
  395. $scope.addisover++;
  396. }, function () {
  397. $scope.hideLoadingToast();
  398. });
  399. }
  400. if (iur2list.length > 0) {
  401. SqliteStorageService.insertBatchData("conninforesearch", iur2list).then(function () {
  402. $scope.addisover++;
  403. }, function () {
  404. $scope.hideLoadingToast();
  405. });
  406. }
  407. if (calendarlist.length > 0) {
  408. SqliteStorageService.insertBatchData("yearproject", calendarlist).then(function () {
  409. $scope.addisover++;
  410. }, function () {
  411. $scope.hideLoadingToast();
  412. });
  413. }
  414. };
  415. //监听是否结束
  416. var overwatch = $scope.$watch("addisover", function (newValue, oldValue, scope) {
  417. if (newValue == checknum) {
  418. UtilService.showMess("新建成功");
  419. $scope.hideLoadingToast();
  420. $timeout(function () {
  421. $scope.goback();
  422. }, 1500);
  423. HandleService.changeflg = true;
  424. ConfigService.isedit = 1;
  425. SqliteStorageService.updateEditFlg(1);
  426. ModelService.resetTempData();
  427. } else {
  428. }
  429. });
  430. var saveTempDate = function () {
  431. var tempstr = $("#appDateTime").val();
  432. if (UtilService.isDefined(tempstr)) {
  433. $scope.record.date = tempstr;
  434. }
  435. ModelService.setCheckdeFolder($scope.checkdefolder);
  436. ModelService.setConninfo($scope.record);
  437. ModelService.setImageList($scope.imagelist);
  438. ModelService.setCardList($scope.cardlist);
  439. ModelService.setIsFirstOpen(1);
  440. };
  441. $scope.showAction = function () {
  442. $ionicActionSheet.show({
  443. buttons: [
  444. {text: '<a class="action-sheet-push act_f">添加照片</a>'},
  445. {text: '<a class="action-sheet-push act_m">添加名片</a>'}
  446. ],
  447. cancelText: '取消',
  448. buttonClicked: function (index) {
  449. if (index == 0) {
  450. getPictures();
  451. } else if (index == 1) {
  452. saveTempDate();
  453. $scope.go('addListCard');
  454. }
  455. return true;
  456. }
  457. });
  458. };
  459. $scope.openCamera = function () {
  460. if ($scope.imagelist.length >= 18) {
  461. UtilService.showMess("最多选取18张图片");
  462. return;
  463. }
  464. UtilService.getPicture(1).then(function (results) {
  465. // console.log(results);
  466. $scope.imagelist.push({
  467. id: 0,
  468. photo_name: results,
  469. original_name: results,
  470. source_name: results
  471. });
  472. $scope.totalImglength = 600 * $scope.imagelist.length;
  473. $ionicScrollDelegate.$getByHandle("scrollimage").resize();
  474. }, function (err) {
  475. });
  476. };
  477. var verifyStorage = function () {
  478. window.imagePicker.verifyStorage(
  479. function (results) {
  480. if (results == "1") {
  481. getPic();
  482. }
  483. }, function (error) {
  484. }
  485. );
  486. };
  487. var getPic = function () {
  488. if ($scope.imagelist.length >= 18) {
  489. UtilService.showMess("最多选取18张图片");
  490. return;
  491. }
  492. UtilService.getPictureList(18 - $scope.imagelist.length).then(function (results) {
  493. // console.log(results);
  494. angular.forEach(results, function (value, index) {
  495. $scope.imagelist.push({id: 0, photo_name: value, original_name: value, source_name: value})
  496. });
  497. $scope.totalImglength = 600 * $scope.imagelist.length;
  498. $ionicScrollDelegate.$getByHandle("scrollimage").resize();
  499. }, function (err) {
  500. });
  501. };
  502. var getPictures = function () {
  503. if (device.platform == "Android") {
  504. verifyStorage();
  505. } else {
  506. getPic();
  507. }
  508. };
  509. //删除图片
  510. $scope.deletePhoto = function (index) {
  511. $scope.imagelist.splice(index, 1);
  512. };
  513. //时间选择器
  514. $(function () {
  515. var currYear = (new Date()).getFullYear();
  516. var opt = {};
  517. opt.date = {preset: 'date'};
  518. opt.datetime = {preset: 'datetime'};
  519. opt.time = {preset: 'time'};
  520. opt.default = {
  521. theme: 'android-ics light', //皮肤样式
  522. display: 'modal', //显示方式
  523. mode: 'scroller', //日期选择模式
  524. dateFormat: 'yyyy年mm月dd日',
  525. lang: 'zh',
  526. showNow: true,
  527. nowText: "今天",
  528. startYear: currYear - 50, //开始年份
  529. endYear: currYear + 10 //结束年份
  530. };
  531. /*$("#appDateTime").mobiscroll($.extend(opt['date'], opt['default']));*/
  532. var optDateTime = $.extend(opt['datetime'], opt['default']);
  533. $("#appDateTime").mobiscroll(optDateTime).datetime(optDateTime);
  534. });
  535. //选择文件夹与列表匹配
  536. $scope.queryCheckFolder = function (folder) {
  537. if (ModelService.getCreateType() == 0) {
  538. if (folder.isCloud == 1) {
  539. return $scope.checkdefolder.id == folder.id;
  540. } else {
  541. return $scope.checkdefolder.localid == folder.localid;
  542. }
  543. } else if (ModelService.getCreateType() == 1) {
  544. return $scope.checkdefolder.localid == folder.localid;
  545. } else {
  546. return $scope.checkdefolder.id == folder.id;
  547. }
  548. };
  549. //权限设置
  550. $scope.Authority = function () {
  551. $ionicActionSheet.show({
  552. buttons: [
  553. {text: '<a class="action-sheet-push">权限设置</a>'}
  554. ],
  555. cancelText: '取消',
  556. buttonClicked: function (index) {
  557. $scope.go("Authority");
  558. }
  559. });
  560. };
  561. $scope.addListBack = function () {
  562. ModelService.resetTempData();
  563. $scope.goback();
  564. };
  565. //显示更多名片部分
  566. $scope.showMoreCard = function (index) {
  567. $(".parentWrapCard").eq(index).toggle();
  568. $(".showCardWrap").eq(index).toggle();
  569. $(".changeArrowButton").eq(index).toggleClass("upArrow");
  570. /* var cardText = $(".downArrow").eq(index).text();
  571. if (cardText == '展开') {
  572. $(".downArrow").eq(index).text("收起");
  573. } else {
  574. $(".downArrow").eq(index).text("展开");
  575. }*/
  576. };
  577. var cardDelect = function (cardindex) {
  578. $scope.cardlist.splice(cardindex, 1);
  579. };
  580. //重新编辑名片
  581. $scope.editCardContent = function (cardindex) {
  582. $ionicActionSheet.show({
  583. buttons: [
  584. /* {text: '<a class="action-sheet-push">同步到高校库</a>'},*/
  585. {text: '<a class="action-sheet-push">编辑名片</a>'},
  586. {text: '<a class="action-sheet-push">删除名片</a>'}
  587. ],
  588. cancelText: '取消',
  589. buttonClicked: function (index) {
  590. /*if (index == 0) {
  591. $scope.go("buildResourceInit");
  592. }*/
  593. if (index == 0) {
  594. saveTempDate();
  595. $scope.go("addListCard", {index: cardindex});
  596. } else {
  597. cardDelect(cardindex);
  598. }
  599. return true;
  600. }
  601. });
  602. };
  603. //重新编辑参与单位结果
  604. $scope.editThemeContent = function (theme, listindex) {
  605. $ionicActionSheet.show({
  606. buttons: [
  607. {text: '<a class="action-sheet-push">编辑内容</a>'}
  608. ],
  609. cancelText: '取消',
  610. buttonClicked: function (index) {
  611. if (index == 0) {
  612. $scope.go("DockingTheme", {theme: theme, index: listindex});
  613. }
  614. }
  615. });
  616. };
  617. //重新编辑参与单位结果
  618. $scope.editUnitContent = function (company, listindex) {
  619. $ionicActionSheet.show({
  620. buttons: [
  621. {text: '<a class="action-sheet-push">编辑内容</a>'}
  622. ],
  623. cancelText: '取消',
  624. buttonClicked: function (index) {
  625. if (index == 0) {
  626. $scope.go("ParticipatingUnits", {company: company, index: listindex});
  627. }
  628. }
  629. });
  630. };
  631. //点击图片放大
  632. $scope.bigImage = false; //初始默认大图是隐藏的
  633. $scope.hideBigImage = function () {
  634. $timeout(function () {
  635. if($scope.app){
  636. $scope.setStatusBar(0);
  637. }
  638. $scope.bigImage = false;
  639. }, 400);
  640. };
  641. $scope.shouBigImage = function (index) { //传递一个参数(图片的URl)
  642. if($scope.app){
  643. $scope.setStatusBar(1);
  644. }
  645. $scope.bigImage = true; //显示大图
  646. // console.log(index);
  647. $(function () {
  648. $('div.pinch-zoom').each(function () {
  649. new RTP.PinchZoom($(this), {});
  650. });
  651. });
  652. $ionicSlideBoxDelegate.update();//重绘,让图片显示出来
  653. //图片总数量
  654. setTimeout(function () {
  655. // console.log(parseInt($ionicSlideBoxDelegate.slidesCount()));
  656. // console.log(parseInt($ionicSlideBoxDelegate.currentIndex()));
  657. $ionicSlideBoxDelegate.$getByHandle('slide_detail').slide(index, -5);
  658. // var nowIndex=parseInt($ionicSlideBoxDelegate.currentIndex());
  659. var totalIndex = parseInt($ionicSlideBoxDelegate.slidesCount());
  660. // console.log(index);
  661. $scope.nowIndex = index + 1;
  662. $scope.totalIndex = totalIndex;
  663. //获取图片
  664. var imgObj = document.getElementsByClassName('bigimage');
  665. var n;
  666. for (n = 0; n < imgObj.length; n++) {
  667. // 获取图片的原始高度和宽度
  668. var oldWid = imgObj[n].naturalWidth;
  669. var oldHei = imgObj[n].naturalHeight;
  670. var screen = document.body.offsetWidth;
  671. var screenH = window.innerHeight;
  672. // console.log(oldWid / oldHei);
  673. // console.log(screen);
  674. var cc = screen / (oldWid / oldHei);
  675. imgObj[n].style.height = cc + 'px';
  676. if (cc < screenH) {
  677. imgObj[n].style.marginTop = (screenH - cc) / 2 + 'px';
  678. // console.log("e:" + imgObj[n].style.marginTop);
  679. } else {
  680. imgObj[n].style.marginTop = 0 + 'px';
  681. // console.log((cc - screenH) + 'px')
  682. }
  683. }
  684. }, 0);
  685. };
  686. $scope.slideHasChanged = function (index) {
  687. // console.log(index);
  688. $scope.nowIndex = index + 1;
  689. };
  690. //查看原图
  691. $scope.viewOldImg = function (index) {
  692. // console.log($scope.imagelist[index]);
  693. // console.log("查看原图" + index);
  694. $(".bigimage").eq(index).attr("src", $scope.imgUrl + $scope.imagelist[index].source_name);
  695. $timeout(function () {
  696. $scope.imagelist[index].loadsource = true;
  697. }, 20);
  698. };
  699. //返回上一级目录
  700. $scope.backUpperFolder = function () {
  701. ModelService.deleteSelectLevelList($scope.level);
  702. $scope.level--;
  703. if ($scope.level == 0) {
  704. //记录新建类型 0:首页,1:本地,2:云
  705. if (ModelService.getCreateType() == 0) {
  706. $scope.folderlist = angular.copy(ModelService.getFolderList());
  707. } else if (ModelService.getCreateType() == 1) {
  708. $scope.folderlist = angular.copy(ModelService.getLocalFolderList());
  709. } else {
  710. $scope.folderlist = angular.copy(ModelService.getCloudFolderList());
  711. }
  712. } else {
  713. var tempfolder = ModelService.getSelectLevelList()[$scope.level];
  714. if (tempfolder.isCloud == 0) {
  715. queryLocalFolder(tempfolder);
  716. } else {
  717. queryCloudFolder(tempfolder);
  718. }
  719. $scope.currentfoldername = tempfolder.name;
  720. }
  721. $scope.checkfolder = "";
  722. };
  723. //打开下一级目录
  724. $scope.openNextFolder = function (folder) {
  725. //记录本级目录
  726. var tempobj = {
  727. localid: folder.localid,
  728. id: folder.id,
  729. level: folder.level,
  730. isCloud: folder.isCloud,
  731. name: folder.name
  732. };
  733. ModelService.addSelectLevelList(tempobj);
  734. $scope.currentfoldername = folder.name;
  735. $scope.folderlist = [];
  736. $scope.level = folder.level + 1;
  737. if (folder.isCloud == 0) {
  738. queryLocalFolder(folder);
  739. } else {
  740. queryCloudFolder(folder);
  741. }
  742. $scope.checkfolder = "";
  743. };
  744. //查询本地子文件夹
  745. var queryLocalFolder = function (folder) {
  746. var q_sql = "select * from conninfofolder where localparentid = '" + folder.localid + "'";
  747. SqliteStorageService.queryData(q_sql).then(function (response) {
  748. // console.log(response);
  749. $scope.folderlist = response;
  750. }, function () {
  751. });
  752. };
  753. //查询云子文件夹
  754. var queryCloudFolder = function (folder) {
  755. DockingService.newGetConnInfoList(folder.id, folder.level, 1).then(function (response) {
  756. // console.log(response);
  757. $scope.folderlist = response.connFolderlist;
  758. }, function () {
  759. })
  760. };
  761. });