inputFormCtrl.js 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992
  1. angular.module('push')
  2. .controller('inputFormCtrl', ['$scope', '$ionicActionSheet', '$sce', '$ionicPopup', '$ionicLoading', '$stateParams', 'UserService', 'UtilService', 'roleService', 'ConstantService', '$timeout', '$ionicScrollDelegate', 'ActivityService', 'TechnicalBrokerPublishTrainService', 'dataToolsService', '$state', '$ionicSlideBoxDelegate', 'CommonService', 'ionicDatePicker', '$interval', function ($scope, $ionicActionSheet, $sce, $ionicPopup, $ionicLoading, $stateParams, UserService, UtilService, roleService, ConstantService, $timeout, $ionicScrollDelegate, ActivityService, TechnicalBrokerPublishTrainService, dataToolsService, $state, $ionicSlideBoxDelegate, CommonService, ionicDatePicker, $interval) {
  3. console.log($scope.fatherdata)
  4. $scope.connEnterpriseModuleMode = {};
  5. $scope.fatherdata.imagelist = [];
  6. // $scope.tempdata=[];
  7. $scope.delimagelist = [];
  8. $scope.isRelateUl = false;
  9. var upOrdown = 0;
  10. $scope.defaultLan = UserService.defaultLan;
  11. // //TODO 设置IOS状态栏
  12. // $scope.setStatusBar = function (flg) {
  13. // if (device.platform != "Android") {
  14. // if (flg == 0) {
  15. // StatusBar.styleDefault();//黑色
  16. // } else {
  17. // StatusBar.styleLightContent();//白色
  18. // }
  19. // }
  20. // };
  21. $scope.setStatusBar = function (flg) {
  22. if (device.platform != "Android") {
  23. if (flg == 0) {
  24. StatusBar.styleDefault();//黑色
  25. } else {
  26. StatusBar.styleLightContent();//白色
  27. }
  28. }
  29. };
  30. //加载动画
  31. $scope.showLoadingToast = function () {
  32. $ionicLoading.show({
  33. template: '<ion-spinner icon="bubbles" class="spinner-calm"></ion-spinner>',
  34. content: '努力加载中',
  35. animation: 'fade-in',
  36. showBackdrop: false,//是否显示蒙层
  37. maxWidth: 150,
  38. showDelay: 0
  39. });
  40. // $timeout(function () {
  41. // $ionicLoading.hide();
  42. // }, 15000);
  43. $scope.isShowLoadingSvg = false;
  44. };
  45. //关闭加载动画
  46. $scope.hideLoadingToast = function () {
  47. $ionicLoading.hide();
  48. $scope.isShowLoadingSvg = true;
  49. };
  50. $scope.showrichbox = function () {
  51. CKEDITOR.replace('editor');
  52. };
  53. $scope.showrichbox1 = function (index1) {
  54. CKEDITOR.replace(index1 + "");
  55. };
  56. var getSelectListItems = function (val, upOrdown) {
  57. //政策库
  58. if (val.resinnertype == 34) {
  59. val.dictionarytype = 35184;
  60. }
  61. val.dictionary = val.dictionary || 0;
  62. if (val.dictionarytype == 30050 || val.dictionarytype == 305150) {
  63. console.log(val);
  64. dataToolsService.getTypeEntryListByTypeName(val.dictionary).then(function (response) {
  65. if (UtilService.isDefined(response.data) && response.data.length > 0) {
  66. val.list = [];
  67. angular.forEach(response.data, function (value, ind) {
  68. var temphtml = {
  69. text: '<a class="action-sheet-push">' + value.itemkey + '</a>',
  70. itemkey: value.itemvalue,
  71. itemvalue: value.itemkey
  72. };
  73. val.itemIndex = value.itemkey == val.content ? value.itemvalue : val.itemIndex;
  74. val.list.push(temphtml);
  75. });
  76. }
  77. }, function () {
  78. })
  79. } else if (val.dictionarytype == 30051) {
  80. dataToolsService.getYearMultiSetupList(val.dictionary).then(function (response) {
  81. if (UtilService.isDefined(response.data) && response.data.length > 0) {
  82. val.list = [];
  83. angular.forEach(response.data, function (value, ind) {
  84. var temphtml = {
  85. text: '<a class="action-sheet-push">' + value.setupname + '</a>',
  86. itemkey: value.id,
  87. itemvalue: value.setupname
  88. };
  89. val.itemIndex = value.setupname == val.content ? value.id : val.itemIndex;
  90. val.list.push(temphtml);
  91. });
  92. }
  93. }, function () {
  94. })
  95. } else if (val.dictionarytype == 30137) {
  96. dataToolsService.getCategoryByNode(val.dictionary).then(function (res) {
  97. if (res.code == 3350 && res.data) {
  98. $scope.industryItems = res.data.items;
  99. var arrtemp = [];
  100. angular.forEach($scope.industryItems, function (val) {
  101. var obj = {
  102. text: val.labelName,
  103. stausName: val.labelName,
  104. stausId: val.labelKey
  105. };
  106. arrtemp.push(obj);
  107. })
  108. val.list = [];
  109. angular.forEach(arrtemp, function (value, index) {
  110. var temphtml = {
  111. text: '<a class="action-sheet-push">' + value.text + '</a>',
  112. itemvalue: value.stausName,
  113. itemkey: value.stausId
  114. };
  115. val.itemIndex = value.stausName == val.content ? value.stausId : val.itemIndex;
  116. val.list.push(temphtml);
  117. })
  118. return val.list;
  119. }
  120. })
  121. } else if (val.dictionarytype == 30090) {
  122. dataToolsService.getWebCascade(val.dictionary, upOrdown).then(function (response) {
  123. if (UtilService.isDefined(response.data) && response.data.length > 0) {
  124. console.log(response);
  125. val.list = [];
  126. angular.forEach(response.data, function (value, ind) {
  127. var temphtml = {
  128. text: '<a class="action-sheet-push">' + value.name + '</a>',
  129. itemkey: value.code,
  130. itemvalue: value.name
  131. };
  132. val.itemIndex = value.name == val.content ? value.code : val.itemIndex;
  133. val.list.push(temphtml);
  134. });
  135. }
  136. }, function () {
  137. })
  138. }
  139. //政策库
  140. else if (val.dictionarytype == 35184) {
  141. val.dictionary = "34b";
  142. dataToolsService.getWebCascade(val.dictionary, upOrdown).then(function (response) {
  143. if (UtilService.isDefined(response.data) && response.data.length > 0) {
  144. console.log(response);
  145. val.list = [];
  146. angular.forEach(response.data, function (value, ind) {
  147. var temphtml = {
  148. text: '<a class="action-sheet-push">' + value.name + '</a>',
  149. itemkey: value.code,
  150. itemvalue: value.name
  151. };
  152. val.itemIndex = value.name == val.content ? value.code : val.itemIndex;
  153. val.list.push(temphtml);
  154. });
  155. }
  156. }, function () {
  157. })
  158. }
  159. }
  160. var getSelectList = function (arr) {
  161. angular.forEach(arr, function (val, index) {
  162. // if($scope.isedit==0){
  163. // val.tempimagelist=[];
  164. // val.imagelist=[];
  165. // val.orgimages=[];
  166. // }
  167. if ($scope.isedit == 0 && val.selectorgname) {
  168. $scope.selectOrgname(val.selectorgname, index);
  169. }
  170. getSelectListItems(val, upOrdown);
  171. })
  172. }
  173. // console.log($scope.fatherdata);
  174. $scope.showLoadingToast();
  175. $scope.carryout.reset=function (){
  176. console.log(666655222355)
  177. $scope.forbid=false
  178. Selectionbox()
  179. }
  180. function Selectionbox() {
  181. console.log($scope.fatherdata);
  182. console.log(String($scope.fatherdata.detailList))
  183. if ((String($scope.fatherdata.detailList) && $scope.fatherdata.detailList) || ($scope.fatherdata.addList && String($scope.fatherdata.addList))) {
  184. getSelectList($scope.fatherdata.detailList);
  185. angular.forEach($scope.fatherdata.addList, function (val) {
  186. console.log(val);
  187. getSelectList(val.unitItems[0]);
  188. })
  189. if ($scope.tempdata) {
  190. angular.forEach($scope.tempdata, function (value) {
  191. if (value.detailList.length > 0) {
  192. getSelectList(value.detailList);
  193. }
  194. if (value.addList && value.addList.length > 0) {
  195. angular.forEach(value.addList, function (vv) {
  196. getSelectList(vv.unitItems[0]);
  197. })
  198. }
  199. })
  200. }
  201. $scope.hideLoadingToast();
  202. $interval.cancel(timer)
  203. }
  204. $scope.fatherdata.detailList.forEach(function (res) {
  205. if (res.title == '技术合同预计签约时间') {
  206. res.ifshow = true
  207. }
  208. res.hidden.split(',').forEach(function (hiress) {
  209. $scope.fatherdata.detailList.forEach(function (fares) {
  210. if (fares.id == hiress) {
  211. fares.ifshow = true
  212. }
  213. })
  214. })
  215. })
  216. console.log($scope.fatherdata.detailList)
  217. console.log("1111")
  218. }
  219. var timer = $interval(Selectionbox, 300)
  220. $scope.changetechnicaltransform = function (item, tmp) {
  221. item.show = !item.show
  222. tmp.content = ''
  223. for (var i of tmp.list) {
  224. if (i.show) {
  225. console.log(i)
  226. if (tmp.content) {
  227. tmp.content = tmp.content + "、" + i.itemvalue
  228. } else {
  229. tmp.content = i.itemvalue
  230. }
  231. }
  232. }
  233. }
  234. //下拉框选择事件,包括添加logo
  235. $scope.selectItems = function (action, logoimg, index) {
  236. $scope.logIndex = index;
  237. if (action || logoimg) {
  238. var list = [];
  239. var clickfunction;
  240. if (action) {
  241. list = $scope.fatherdata.detailList[index].list;
  242. if (!list) {
  243. list = getSelectListItems($scope.fatherdata.detailList[index], upOrdown);
  244. if ($scope.fatherdata.detailList[index - 1].type == 'cascade' && !list) {
  245. $scope.showmessage({ msg: '请先选择大类!' });
  246. return;
  247. }
  248. }
  249. clickfunction = function (indx) {
  250. // if($scope.fatherdata.detailList[index-1].type=='cascade'){
  251. // $scope.showmessage({msg:'请先选择大类!'});
  252. // return;
  253. // }
  254. $scope.fatherdata.detailList[index].itemIndex = list[indx].itemkey;
  255. $scope.fatherdata.detailList[index].content = list[indx].itemvalue;
  256. if ($scope.fatherdata.detailList[index].type == 'cascade') {
  257. $scope.fatherdata.detailList[index + 1].dictionary = list[indx].itemkey;
  258. getSelectListItems($scope.fatherdata.detailList[index + 1], upOrdown);
  259. }
  260. return true;
  261. }
  262. } else if (logoimg) {
  263. if ($scope.app) {
  264. list = [
  265. { text: '<a class="action-sheet-push">拍照</a>' },
  266. { text: '<a class="action-sheet-push">从相册上传</a>' },
  267. ]
  268. clickfunction = function (indx) {
  269. if (indx == 0) {
  270. openCamera(1, 1);
  271. } else {
  272. openCamera(0, 1);
  273. }
  274. return true;
  275. }
  276. } else {
  277. list = [
  278. { text: '<a class="action-sheet-push">从相册上传</a>' },
  279. ];
  280. clickfunction = function (indx) {
  281. if (indx == 0) {
  282. var files = document.getElementById('file');
  283. files.click();
  284. $(files).unbind().on('change', function (e) {
  285. var data = new FormData();
  286. data.append('file', e.target.files[0]);
  287. // $scope.fatherdata.detailList[$scope.imgIndex].imagelist.push();
  288. CommonService.webUploadImage(data).then(function (res) {
  289. $scope.fatherdata.detailList[index].content = res.originalName;
  290. })
  291. })
  292. }
  293. return true;
  294. }
  295. }
  296. }
  297. $ionicActionSheet.show({
  298. buttons: list,
  299. cancelText: '取消',
  300. buttonClicked: clickfunction
  301. })
  302. }
  303. }
  304. var openCamera = function (srcType) {
  305. var options = {
  306. // Some common settings are 20, 50, and 100
  307. quality: 50,
  308. destinationType: Camera.DestinationType.FILE_URI,
  309. // In this app, dynamically set the picture source, Camera or photo gallery
  310. sourceType: srcType,
  311. encodingType: Camera.EncodingType.JPEG,
  312. mediaType: Camera.MediaType.PICTURE,
  313. allowEdit: false,
  314. correctOrientation: true //Corrects Android orientation quirks
  315. };
  316. navigator.camera.getPicture(function (imageData) {
  317. $scope.imgurl = imageData;
  318. $scope.showLoadingToast();
  319. UtilService.uploadFile([imageData], 0, "image/jpeg").then(function (response) {
  320. // 企业logo
  321. // $scope.connEnterpriseModuleModel.orglogo = response[0].photoName;
  322. $scope.fatherdata.detailList[$scope.logIndex].content = response[0].photoName;
  323. $scope.hideLoadingToast();
  324. }, function () {
  325. $scope.hideLoadingToast();
  326. });
  327. }, function (message) {
  328. }, options);
  329. };
  330. // 添加图片选择事件
  331. $scope.addImage = function (index, key, outerIndex, innerIndex) {
  332. $scope.imgIndex = index;
  333. $scope.key = key;
  334. $scope.outerIndex = outerIndex || 0;
  335. $scope.innerIndex = innerIndex || 0;
  336. if ($scope.app) {
  337. var list = [
  338. { text: '<a class="action-sheet-push">拍照</a>' },
  339. { text: '<a class="action-sheet-push">从相册上传</a>' },
  340. ];
  341. var clickfunction = function (indx) {
  342. if (indx == 0) {
  343. $scope.openCamera(index, key, outerIndex, innerIndex);
  344. } else {
  345. getPictures(index, key, outerIndex, innerIndex);
  346. }
  347. return true;
  348. }
  349. $ionicActionSheet.show({
  350. buttons: list,
  351. cancelText: '取消',
  352. buttonClicked: clickfunction
  353. })
  354. } else {
  355. var list = [
  356. { text: '<a class="action-sheet-push">从相册上传</a>' },
  357. ];
  358. var clickfunction = function (indx) {
  359. if (indx == 0) {
  360. var files = document.getElementById('file');
  361. files.click();
  362. $(files).unbind().on('change', function (e) {
  363. // if($scope.fatherdata.detailList[$scope.imgIndex].imagelist.length>1){
  364. // CommonService.showMessage('只能上传一张照片',$scope);
  365. // return;
  366. // }
  367. $.each(e.target.files, function (i, file) {
  368. var url = null;
  369. if (window.createObjectURL != undefined) { // basic
  370. url = window.createObjectURL(file);
  371. } else if (window.URL != undefined) { // mozilla(firefox)
  372. url = window.URL.createObjectURL(file);
  373. } else if (window.webkitURL != undefined) { // webkit or chrome
  374. url = window.webkitURL.createObjectURL(file);
  375. }
  376. if (key == 'detail') {
  377. $scope.fatherdata.detailList[index].tempimagelist.push({
  378. photoName: url,
  379. originalName: url
  380. });
  381. } else {
  382. // console.log($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].tempimagelist);
  383. $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].tempimagelist.push({
  384. photoName: url,
  385. originalName: url
  386. });
  387. }
  388. })
  389. $.each(e.target.files, function (i, file) {
  390. // console.log(file);
  391. var data = new FormData();
  392. data.append('file', file);
  393. // $scope.fatherdata.detailList[$scope.imgIndex].imagelist.push();
  394. CommonService.webUploadImage(data).then(function (res) {
  395. // console.log(res);
  396. var temp = {
  397. id: 0,
  398. title: "",
  399. doctype: res.doctype,//文档类型 1图片,2文件,3pdf,4xls
  400. isenabled: 1,//是否可用:0-不可用,1-可用,2-已停用
  401. photoName: res.photoName,
  402. originalName: res.originalName,
  403. sourceName: res.sourceName,
  404. sourceSize: res.sourceSize
  405. };
  406. if (key == 'detail') {
  407. $scope.fatherdata.detailList[index].imagelist.push(temp);
  408. } else {
  409. $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist.push(temp);
  410. }
  411. // console.log($scope.fatherdata.addList[$scope.outerIndex]);
  412. })
  413. });
  414. })
  415. }
  416. return true;
  417. }
  418. $ionicActionSheet.show({
  419. buttons: list,
  420. cancelText: '取消',
  421. buttonClicked: clickfunction
  422. })
  423. }
  424. }
  425. $scope.openCamera = function (index, key, outerIndex, innerIndex) {
  426. if (key == 'detail' && $scope.fatherdata.detailList[index].imagelist.length >= 9) {
  427. UtilService.showMess("最多选取9张图片");
  428. return;
  429. }
  430. if (key == 'addList' && $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist.length >= 9) {
  431. UtilService.showMess("最多选取9张图片");
  432. return;
  433. }
  434. UtilService.getPicture(1).then(function (results) {
  435. // $scope.fatherdata.detailList[$scope.logIndex].imagelist.push({photoName: results, originalName: results});
  436. // $scope.totalImglength = 600 * $scope.fatherdata.imagelist.length;
  437. if (key == 'detail') {
  438. $scope.fatherdata.detailList[index].tempimagelist.push({ photoName: results, originalName: results });
  439. } else {
  440. $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].tempimagelist.push({
  441. photoName: results,
  442. originalName: results
  443. });
  444. }
  445. UtilService.uploadFile([results], 0, "image/jpeg").then(function (response) {
  446. // $scope.fatherdata.detailList[$scope.imgIndex].imagelist=[];
  447. angular.forEach(response, function (value) {
  448. if (value.status) {
  449. var temp = {
  450. id: 0,
  451. title: "",
  452. doctype: value.doctype,//文档类型 1图片,2文件,3pdf,4xls
  453. isenabled: 1,//是否可用:0-不可用,1-可用,2-已停用
  454. photoName: value.photoName,
  455. originalName: value.originalName,
  456. sourceName: value.sourceName,
  457. sourceSize: value.sourceSize
  458. };
  459. if (key == 'detail') {
  460. $scope.fatherdata.detailList[index].imagelist.push(temp);
  461. } else {
  462. $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist.push(temp);
  463. }
  464. }
  465. })
  466. }, function () {
  467. $scope.hideLoadingToast();
  468. UtilService.showMess("网络不给力,请重试");
  469. saveflg = 0;
  470. });
  471. // if($scope.key=='detail'){
  472. // $scope.fatherdata.detailList[$scope.imgIndex].imagelist.push({photoName: results, originalName: results,id:0});
  473. // }else{
  474. // $scope.fatherdata.addList[$scope.outerIndex].unitItems[$scope.innerIndex][$scope.imgIndex].imagelist.push({photoName: results, originalName: results,id:0});
  475. // }
  476. // $timeout(function(){
  477. //
  478. // },500)
  479. $ionicScrollDelegate.$getByHandle("scrollimage").resize();
  480. }, function (err) {
  481. });
  482. };
  483. var getPictures = function (index, key, outerIndex, innerIndex) {
  484. if (device.platform == "Android") {
  485. verifyStorage(index, key, outerIndex, innerIndex);
  486. } else {
  487. getPic(index, key, outerIndex, innerIndex);
  488. }
  489. };
  490. var verifyStorage = function (index, key, outerIndex, innerIndex) {
  491. window.imagePicker.verifyStorage(
  492. function (results) {
  493. if (results == "1") {
  494. getPic(index, key, outerIndex, innerIndex);
  495. }
  496. }, function (error) {
  497. }
  498. );
  499. };
  500. var getPic = function (index, key, outerIndex, innerIndex) {
  501. var imagelistLength = 0;
  502. if (key == 'detail') {
  503. if ($scope.fatherdata.detailList[index].imagelist.length >= 9) {
  504. UtilService.showMess("最多选取9张图片");
  505. return;
  506. } else {
  507. imagelistLength = $scope.fatherdata.detailList[index].imagelist.length;
  508. }
  509. } else {
  510. if ($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist.length >= 9) {
  511. UtilService.showMess("最多选取9张图片");
  512. return;
  513. } else {
  514. imagelistLength = $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist.length;
  515. }
  516. }
  517. UtilService.getPictureList(9 - imagelistLength).then(function (results) {
  518. // console.log(results);
  519. angular.forEach(results, function (val) {
  520. if (key == 'detail') {
  521. $scope.fatherdata.detailList[index].tempimagelist.push({ photoName: val, originalName: val });
  522. } else {
  523. $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].tempimagelist.push({
  524. photoName: val,
  525. originalName: val
  526. });
  527. }
  528. })
  529. UtilService.uploadFile(results, 0, "image/jpeg").then(function (response) {
  530. angular.forEach(response, function (value) {
  531. if (value.status) {
  532. var temp = {
  533. id: 0,
  534. title: "",
  535. doctype: value.doctype,//文档类型 1图片,2文件,3pdf,4xls
  536. isenabled: 1,//是否可用:0-不可用,1-可用,2-已停用
  537. photoName: value.photoName,
  538. originalName: value.originalName,
  539. sourceName: value.sourceName,
  540. sourceSize: value.sourceSize
  541. };
  542. if (key == 'detail') {
  543. $scope.fatherdata.detailList[index].imagelist.push(temp);
  544. } else {
  545. $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist.push(temp);
  546. }
  547. }
  548. })
  549. }, function () {
  550. $scope.hideLoadingToast();
  551. UtilService.showMess("网络不给力,请重试");
  552. saveflg = 0;
  553. });
  554. // angular.forEach(results, function (value, index) {
  555. // // $scope.imagelist.push({photoName: value, originalName: value})
  556. // if($scope.key=='detail'){
  557. // $scope.fatherdata.detailList[$scope.imgIndex].imagelist.push({photoName: value, originalName: value,id:0});
  558. // }else{
  559. // $scope.fatherdata.addList[$scope.outerIndex].unitItems[$scope.innerIndex][$scope.imgIndex].imagelist.push({photoName: value, originalName: value,id:0});
  560. // }
  561. // });
  562. // $scope.totalImglength = 600 * $scope.imagelist.length;
  563. // if($scope.key=='detail'){
  564. // $scope.fatherdata.detailList[$scope.logIndex].content=JSON.stringify($scope.imagelist)
  565. // }else{
  566. // $scope.fatherdata.addList[$scope.outerIndex].unitItems[$scope.innerIndex][$scope.imgIndex].content=JSON.stringify($scope.imagelist)
  567. // }
  568. $ionicScrollDelegate.$getByHandle("scrollimage").resize();
  569. }, function (err) {
  570. });
  571. };
  572. //删除图片
  573. $scope.deletePhoto = function (key, imgIndex, index, innerIndex, outerIndex) {
  574. // console.log(imgIndex,index);
  575. if (key == 'detail') {
  576. // 如果删除的是原有图片,设置原有图片的isenabled=2
  577. // console.log($scope.fatherdata.detailList[$scope.imgIndex]);
  578. // console.log($scope.fatherdata.detailList[$scope.imgIndex].imagelist[index]);
  579. // console.log($scope.fatherdata.detailList);
  580. // console.log($scope.fatherdata.detailList[imgIndex]);
  581. if ($scope.fatherdata.detailList[imgIndex].imagelist[index].id != undefined && $scope.fatherdata.detailList[imgIndex].imagelist[index].id != 0) {
  582. // if($scope.fatherdata.detailList[imgIndex].imagelist[index].id!=undefined&&$scope.fatherdata.detailList[imgIndex].imagelist[index].id!=0&&$scope.fatherdata.detailList[imgIndex].orgimages.length>0){
  583. // angular.forEach($scope.fatherdata.detailList[imgIndex].orgimages,function(v,i){
  584. // if(v.id==$scope.fatherdata.detailList[imgIndex].imagelist[index].id){
  585. // v.isenabled=2
  586. // }
  587. // })
  588. $scope.fatherdata.detailList[imgIndex].imagelist[index].isenabled = 2;
  589. $scope.fatherdata.detailList[imgIndex].orgimages.push($scope.fatherdata.detailList[imgIndex].imagelist[index]);
  590. }
  591. $scope.fatherdata.detailList[imgIndex].imagelist.splice(index, 1);
  592. $scope.fatherdata.detailList[imgIndex].tempimagelist.splice(index, 1);
  593. console.log($scope.fatherdata.detailList[imgIndex]);
  594. } else {
  595. // 如果删除的是原有图片,设置原有图片的isenabled=2
  596. // console.log($scope.fatherdata.addList);
  597. // console.log($scope.fatherdata.addList[outerIndex]);
  598. // console.log($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index]);
  599. if ($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist[imgIndex].id != undefined && $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist[imgIndex].id != 0) {
  600. // if($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist[imgIndex].id!=undefined&&$scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist[imgIndex].id!=0&&$scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].orgimages.length>0){
  601. // angular.forEach($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].orgimages,function(v1,i1){
  602. // if(v1.id==$scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist[imgIndex].id){
  603. // v1.isenabled=2
  604. // }
  605. // })
  606. $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist[imgIndex].isenabled = 2;
  607. $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].orgimages.push($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist[imgIndex]);
  608. }
  609. $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].imagelist.splice(imgIndex, 1);
  610. $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].tempimagelist.splice(imgIndex, 1);
  611. }
  612. };
  613. //点击图片放大
  614. $scope.bigImage = false; //初始默认大图是隐藏的
  615. $scope.hideBigImage = function () {
  616. if ($scope.app) {
  617. $scope.setStatusBar(0);
  618. }
  619. $timeout(function () {
  620. $scope.bigImage = false;
  621. }, 400);
  622. };
  623. $scope.shouBigImage = function (index) { //传递一个参数(图片的URl)
  624. if ($scope.app) {
  625. $scope.setStatusBar(1);
  626. }
  627. $(function () {
  628. $('div.pinch-zoom').each(function () {
  629. new RTP.PinchZoom($(this), {});
  630. });
  631. });
  632. $scope.bigImage = true;//显示大图
  633. $ionicSlideBoxDelegate.update();//重绘,让图片显示出来
  634. //图片总数量
  635. setTimeout(function () {
  636. $ionicSlideBoxDelegate.$getByHandle('slide_detail').slide(index, -10);
  637. //获取图片
  638. var imgObj = document.getElementsByClassName('bigimage');
  639. var n;
  640. for (n = 0; n < imgObj.length; n++) {
  641. // 获取图片的原始高度和宽度
  642. var oldWid = imgObj[n].naturalWidth;
  643. var oldHei = imgObj[n].naturalHeight;
  644. var screen = document.body.offsetWidth;
  645. var screenH = window.innerHeight;
  646. var rate = oldWid / oldHei;
  647. if (oldWid >= screen && oldHei >= screenH) {
  648. var tw = screen;
  649. var th = tw / rate;
  650. if (th < screenH) {
  651. imgObj[n].style.width = tw + 'px';
  652. imgObj[n].style.height = th + 'px';
  653. imgObj[n].style.marginTop = (screenH - th) / 2 + 'px';
  654. } else {
  655. imgObj[n].style.width = screenH * rate + 'px';
  656. imgObj[n].style.height = screenH + 'px';
  657. imgObj[n].style.marginLeft = (screen - screenH * rate) / 2 + 'px';
  658. }
  659. } else if (oldWid >= screen && oldHei <= screenH) {
  660. imgObj[n].style.width = screen + 'px';
  661. imgObj[n].style.height = screen / rate + 'px';
  662. imgObj[n].style.marginTop = (screenH - screen / rate) / 2 + 'px';
  663. } else if (oldWid <= screen && oldHei >= screenH) {
  664. // var hh=screenH;
  665. // var ww=screenH*rate;
  666. imgObj[n].style.width = screenH * rate + 'px';
  667. imgObj[n].style.height = screenH + 'px';
  668. imgObj[n].style.marginLeft = (screen - screenH * rate) / 2 + 'px';
  669. } else {
  670. imgObj[n].style.width = oldWid + 'px';
  671. imgObj[n].style.height = oldHei + 'px';
  672. imgObj[n].style.marginLeft = (screen - oldWid) / 2 + 'px';
  673. imgObj[n].style.marginTop = (screenH - oldHei) / 2 + 'px';
  674. }
  675. }
  676. }, 500);
  677. };
  678. // getSelectList($scope.fatherdata.detailList);
  679. $scope.selecBlocktItems = function (action, outerIndex, innerIndex, index) {
  680. // console.log(action);
  681. if (action) {
  682. // console.log($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index]);
  683. var list = $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].list;
  684. if (!list) {
  685. list = getSelectListItems($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index], upOrdown);
  686. if ($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index - 1].type == 'cascade' && !list) {
  687. $scope.showmessage({ msg: '请先选择大类!' });
  688. return;
  689. }
  690. }
  691. var clickfunction = function (indx) {
  692. // if($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index-1].type=='cascade'){
  693. // $scope.showmessage({msg:'请先选择大类!'});
  694. // return;
  695. // }
  696. $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].itemIndex = list[indx].itemkey;
  697. $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].content = list[indx].itemvalue;
  698. if ($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].type = 'cascade') {
  699. $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index + 1].dictionary = list[indx].itemkey;
  700. getSelectListItems($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index + 1], upOrdown)
  701. }
  702. // console.log($scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index]);
  703. return true;
  704. }
  705. // clickfunction=function(indx){
  706. // $scope.fatherdata.addList[outerIndex].unitItems[innerIndex][index].content=arr[indx];
  707. // return true;
  708. // }
  709. if (list) {
  710. console.log(list);
  711. $ionicActionSheet.show({
  712. buttons: list,
  713. cancelText: '取消',
  714. buttonClicked: clickfunction
  715. })
  716. // $interval.cancel(tt);
  717. }
  718. }
  719. }
  720. $scope.ttt = function (tmptitle) {
  721. return $sce.trustAsHtml(tmptitle);
  722. }
  723. var resetList = function (arr) {
  724. for (var i = 0; i < arr.length; i++) {
  725. if (arr[i].tcname == 'orgname') continue;
  726. arr[i].content = '';
  727. }
  728. }
  729. $scope.selectOrgname = function (action, index,row) {
  730. if(row?row.title=='所属单位':false){
  731. $scope.forbid=false
  732. }
  733. if (action) {
  734. if ($scope.fatherdata.detailList[index].content) {
  735. $timeout(function () {
  736. dataToolsService.getOrganizationModelByOrgname($scope.fatherdata.detailList[index].content, $scope.fatherdata.pagecode, 0).then(function (response) {
  737. // console.log(response);
  738. $scope.companylist = response.data;
  739. $scope.isRelateUl = true;
  740. }, function () {
  741. })
  742. }, 1000);
  743. } else {
  744. $scope.isRelateUl = false;
  745. $scope.companylist = [];
  746. }
  747. }
  748. }
  749. //进入资源详情
  750. $scope.jumpResourceDetail = function (company) {
  751. // 先预设信息
  752. $scope.setCompanyName(company);
  753. // 再跳转到资源详情页
  754. $state.go('resourceCommonDetailsPage', {
  755. recourceid: company.resourcelibrary.id,
  756. recourcetype: company.resourcelibrary.restype,
  757. recourcecomefrom: company.resourcelibrary.comefrom,
  758. creator: company.resourcelibrary.creator,
  759. title: company.name
  760. });
  761. };
  762. var getSaveKeyContent = function (detailList, key1, organizationInfo, key2) {
  763. console.log(key2)
  764. for (var i = 0; i < detailList.length; i++) {
  765. if (detailList[i].tcname == key1) {
  766. if (detailList[i].type == 'number') {
  767. detailList[i].content = Number(organizationInfo[key2]);
  768. } else {
  769. detailList[i].content = organizationInfo[key2];
  770. }
  771. if (detailList[i].toggle && organizationInfo[key2]) {
  772. detailList[i].togglecontent = true
  773. $scope.watchIsChange(i)
  774. }
  775. if (key2 == 'ishigh') {
  776. detailList[i].togglecontent = organizationInfo[key2] == 1;
  777. detailList[i].content = organizationInfo[key2] == 1 ? '是' : '否';
  778. }
  779. if (detailList[i].list) {
  780. // console.log(key2);
  781. // console.log(detailList[i].list);
  782. // console.log(organizationInfo[key2]);
  783. var temp = detailList[i].list.filter(function (val, ii, arr) {
  784. return val.itemkey == organizationInfo[key2];
  785. })
  786. console.log(temp)
  787. if (temp.length > 0) {
  788. detailList[i].content = temp[0].itemvalue;
  789. } else {
  790. detailList[i].content = '';
  791. }
  792. if(detailList[i].tcname=="naturefirm") {
  793. console.log(organizationInfo['orgtype'], organizationInfo[key2])
  794. detailList[i].content=organizationInfo['orgtype'] == 10104 ? '企业' : '高校'
  795. }
  796. if (key2 == "classesType") {
  797. detailList[i].content = organizationInfo[key2]
  798. console.log(organizationInfo[key2])
  799. if (organizationInfo[key2]) {
  800. var array = organizationInfo[key2].split("、")
  801. for (var ary of array) {
  802. console.log(ary)
  803. detailList[i].list.filter(function (val, i, arr) {
  804. if (val.itemvalue == ary) {
  805. val.show = true
  806. };
  807. })
  808. }
  809. }
  810. }
  811. }
  812. if (detailList[i].selectaction) {
  813. // console.log(detailList[i]);
  814. // console.log(organizationInfo[key1]);
  815. var temp1 = detailList[i].list.filter(function (val) {
  816. return val.itemkey == organizationInfo[key1];
  817. })
  818. // console.log(temp1);
  819. if (temp1.length > 0) {
  820. detailList[i].content = temp1[0].itemvalue;
  821. detailList[i].itemIndex = temp1[0].itemkey;
  822. }
  823. }
  824. return;
  825. }
  826. }
  827. }
  828. $scope.forbid=false
  829. // 选中机构
  830. $scope.setCompanyName = function (organizationInfo) {
  831. console.log(organizationInfo)
  832. console.log($scope.fatherdata)
  833. // dataToolsService.getFormStructureFill($stateParams.pagecode, '30003', '0', $stateParams.node, $stateParams.resourcetype,organizationInfo.name).then(function (res) {
  834. // console.log(res)
  835. // })
  836. // console.log(organizationInfo);
  837. $scope.fatherdata.conpanyInfo = organizationInfo;
  838. // 全部置空
  839. resetList($scope.fatherdata.detailList);
  840. $scope.fatherdata.orgid = organizationInfo.id;
  841. organizationInfo.name = organizationInfo.name.replace("<b style='color:red;font-weight: normal;'>", "");
  842. organizationInfo.name = organizationInfo.name.replace("</b>", "");
  843. for (var key in organizationInfo) {
  844. if (key == 'name') {
  845. getSaveKeyContent($scope.fatherdata.detailList, 'orgname', organizationInfo, key);
  846. getSaveKeyContent($scope.fatherdata.detailList, 'companyid', organizationInfo, key);
  847. } else if (key == 'logo') {
  848. getSaveKeyContent($scope.fatherdata.detailList, 'orglogo', organizationInfo, key);
  849. } else if (key == 'rdinstitutiontype') {
  850. getSaveKeyContent($scope.fatherdata.detailList, 'orggradecode', organizationInfo, key);
  851. } else if (key == 'contactnum') {
  852. getSaveKeyContent($scope.fatherdata.detailList, 'orgcontactnum', organizationInfo, key);
  853. } else if (key == 'contact') {
  854. getSaveKeyContent($scope.fatherdata.detailList, 'orgcontact', organizationInfo, key);
  855. } else if (key == 'classesType') {
  856. getSaveKeyContent($scope.fatherdata.detailList, 'orgClassesType', organizationInfo, key);
  857. } else {
  858. getSaveKeyContent($scope.fatherdata.detailList, key, organizationInfo, key);
  859. }
  860. }
  861. // console.log($scope.fatherdata);
  862. $scope.isRelateUl = false;
  863. $scope.forbid=true
  864. }
  865. $scope.watchIsChange = function (index) {
  866. $scope.fatherdata.detailList[index].content = $scope.fatherdata.detailList[index].togglecontent ? "是" : "否";
  867. $scope.fatherdata.detailList.forEach(function (res) {
  868. if (res.title == '技术合同预计签约时间') {
  869. res.ifshow = $scope.fatherdata.detailList[index].togglecontent ? false : true;
  870. }
  871. })
  872. $scope.fatherdata.detailList[index].hidden.split(',').forEach(function (hiress) {
  873. $scope.fatherdata.detailList.forEach(function (fares) {
  874. if (fares.id == hiress) {
  875. console.log("走了")
  876. fares.ifshow = $scope.fatherdata.detailList[index].togglecontent ? false : true;
  877. }
  878. })
  879. })
  880. }
  881. $scope.addBlockList = function (index) {
  882. var arr = [];
  883. for (var i = 0; i < $scope.fatherdata.addList[index].unitItems[0].length; i++) {
  884. var temp = Object.assign({}, $scope.fatherdata.addList[index].unitItems[0][i])
  885. temp.content = null;
  886. // temp.imagelist=[];
  887. temp.orgimages = [];
  888. temp.tempimagelist = [];
  889. temp.imagelist = [];
  890. temp.itemIndex = null;
  891. arr.push(temp);
  892. }
  893. console.log(arr);
  894. $scope.fatherdata.addList[index].unitItems.unshift(arr);
  895. console.log($scope.fatherdata.addList[index].unitItems);
  896. }
  897. $scope.minusBlockList = function (outindex, index) {
  898. if ($scope.fatherdata.addList[outindex].unitItems.length == 1) {
  899. $scope.showmessage({ msg: '请至少留下一组项目' })
  900. return;
  901. }
  902. // if($scope.isedit==1){
  903. angular.forEach($scope.fatherdata.addList[outindex].unitItems[index], function (val, i) {
  904. if (val.tcname == 'id' && val.content != '') {
  905. $scope.fatherdata.addList[outindex]['deletUnitItems'] = [];
  906. $scope.fatherdata.addList[outindex]['deletUnitItems'].push($scope.fatherdata.addList[outindex].unitItems[index]);
  907. }
  908. })
  909. // }
  910. $scope.fatherdata.addList[outindex].unitItems.splice(index, 1);
  911. }
  912. $scope.showDetails = function (index) {
  913. $scope.fatherdata.addList[index].ishiddensection = !$scope.fatherdata.addList[index].ishiddensection;
  914. }
  915. // 日期选择
  916. $scope.validedTime = new Date();
  917. var datePickerObj = {
  918. //选择日期后的回掉
  919. callback: function (val) {
  920. console.log('111111', val);
  921. if (typeof (val) === 'undefined') {
  922. } else {
  923. var temp = new Date(val).toLocaleString().replace(/\//g, "-");
  924. // var temp = new Date(val).toLocaleString().split(' ')[0].replace(/\//g, "-") ;
  925. // var temp=new Date(val).toJSON().substr(0, 19).replace('T', ' ').replace(/-/g, '-')
  926. // console.log(temp)
  927. if ($scope.type == 'addList') {
  928. $scope.fatherdata.addList[$scope.outerTimeIndex].unitItems[$scope.innerTimeIndex][$scope.timeIndex].content = temp;
  929. } else {
  930. $scope.fatherdata.detailList[$scope.timeIndex].content = temp;
  931. console.log('ssss', $scope.fatherdata.detailList[$scope.timeIndex]);
  932. }
  933. datePickerObj.inputDate = new Date(val); //更新日期弹框上的日期
  934. }
  935. },
  936. disabledDates: [
  937. new Date(2016, 2, 16),
  938. new Date(2015, 3, 16),
  939. new Date(2015, 4, 16),
  940. new Date(2015, 5, 16),
  941. new Date('Wednesday, August 12, 2015'),
  942. new Date("2016-08-16"),
  943. new Date(1439676000000)
  944. ],
  945. from: new Date(1970, 1, 1),
  946. to: new Date(2050, 10, 30),
  947. inputDate: new Date(),
  948. mondayFirst: true,
  949. disableWeekdays: [], //设置不能选中
  950. closeOnSelect: false,
  951. dateFormat: 'yyyy-MM-dd',
  952. templateType: 'popup',
  953. need: true,
  954. };
  955. //打开日期选择框
  956. $scope.openDatePicker = function (type, Index, outerIndex, innerIndex) {
  957. $scope.timeIndex = Index;
  958. $scope.type = type;
  959. if (type == 'addList') {
  960. $scope.outerTimeIndex = outerIndex;
  961. $scope.innerTimeIndex = innerIndex;
  962. }
  963. ionicDatePicker.openDatePicker(datePickerObj);
  964. };
  965. $scope.navigate = function (state) {
  966. nav.navigate(state);
  967. };
  968. }]);