inputFormCtrl.js 41 KB

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