visitModularFormCtrl.js 106 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087
  1. angular.module('push')
  2. .controller('visitModularFormCtrl', function ($scope, $q, $stateParams, UserService, UtilService, roleService, $ionicActionSheet,
  3. ConstantService, $timeout, $ionicScrollDelegate, $ionicHistory,
  4. ActivityService, ConfigService, TechnicalBrokerPublishTrainService, dataToolsService, CommonService, $interval, ResourceLibraryService) {
  5. var split = window.location.href.split('#/');
  6. //TODO 放开注释
  7. if ($scope.app) {
  8. if (device.platform != "Android") {
  9. $scope.isIos = true;
  10. } else {
  11. $scope.isIos = false;
  12. }
  13. }
  14. $scope.node = UserService.node;
  15. $scope.defaultLan = UserService.defaultLan;
  16. var innertype = $stateParams.innertype;
  17. if ($scope.app && device.platform == "Android") {
  18. window.addEventListener('native.keyboardshow', function (e) {
  19. })
  20. }
  21. $scope.showMess = function (msg) {
  22. if ($scope.app) {
  23. UtilService.showMess(msg);
  24. } else {
  25. CommonService.showMessage(msg, $scope);
  26. }
  27. }
  28. UserService.isRewardFlag = 1;
  29. // 对应的是0新增/1编辑/2复制
  30. $scope.isedit = $stateParams.isedit;
  31. $scope.pageTitle = $stateParams.pageTitle;
  32. var toggleInfo = [
  33. {
  34. savename: '保存企业基本信息',
  35. text: '<a class="action-sheet-push">企业</a>',
  36. title: '企业基本信息',
  37. orgtype: $stateParams.orgtype,
  38. id: $stateParams.pageid,
  39. select: true,
  40. }, {
  41. savename: '保存高校基本信息',
  42. text: '<a class="action-sheet-push">高校</a>',
  43. title: '高校基本信息',
  44. orgtype: $stateParams.orgtype,
  45. id: $stateParams.pageid,
  46. select: false
  47. }
  48. ]
  49. // 获取走访录入界面的传参
  50. // console.log($stateParams.orgtype);
  51. $scope.rolePageModel = $stateParams.orgtype == 10104 ? toggleInfo[0] : toggleInfo[1];
  52. // console.log($scope.rolePageModel);
  53. // {
  54. // //TODO
  55. // id: $stateParams.pageid,// 模版id
  56. // orgtype: $stateParams.orgtype// 走访对应的机构类型
  57. // // id: 1,// 模版id
  58. // // orgtype: 10104,// 模版id
  59. // };
  60. //根据模版获取所有模块
  61. var hasSearchData = [];
  62. // console.log($stateParams);
  63. var getAllData = function () {
  64. var def = $q.defer();
  65. if ($stateParams.comfrom == 'resource') {
  66. ResourceLibraryService.getPrivateResourceDetail($stateParams.connid, $stateParams.restype, $stateParams.node).then(function (res) {
  67. if (res.code == 3350) {
  68. console.log(res.data);
  69. def.resolve(res.data);
  70. } else {
  71. def.reject('错误');
  72. }
  73. })
  74. } else if ($stateParams.comfrom == 'resourceCommonDetailsPage') {
  75. ResourceLibraryService.getPrivateResourceDetail($stateParams.connid, $stateParams.restype, $stateParams.node).then(function (res) {
  76. if (res.code == 3350) {
  77. console.log(res.data);
  78. ResourceLibraryService.getOtherDetail($stateParams.connid, $stateParams.restype, $stateParams.node).then(function (response) {
  79. console.log(response.data);
  80. if (response.code == 3350) {
  81. var data = {};
  82. if (res.data.id) {
  83. if (response.data.id) {
  84. data = response.data;
  85. data.infoSectionList = Object.assign(data.infoSectionList, res.data.infoSectionList);
  86. } else {
  87. data = res.data;
  88. }
  89. }
  90. angular.forEach(response.data.infoSectionList, function (val) {
  91. data.infoSectionList.push(val);
  92. });
  93. data.typecodemap = Object.assign(data.typecodemap, response.data.typecodemap);
  94. console.log(data);
  95. def.resolve(data);
  96. } else {
  97. def.reject('错误');
  98. }
  99. })
  100. } else {
  101. def.reject('错误');
  102. }
  103. })
  104. } else {
  105. dataToolsService.getDetailEdit($stateParams.connid, 1000002, $stateParams.node).then(function (res) {
  106. if (res.code == 3350) {
  107. console.log(res.data);
  108. dataToolsService.getConnectionOtherInfoDetail($stateParams.connid, 1000002, 0, $stateParams.node).then(function (response) {
  109. console.log(response);
  110. if (response.code == 3350) {
  111. var data = {};
  112. if (res.data.id) {
  113. if (response.data.id) {
  114. data = response.data;
  115. data.infoSectionList = Object.assign(data.infoSectionList, res.data.infoSectionList);
  116. } else {
  117. data = res.data;
  118. }
  119. }
  120. angular.forEach(response.data.infoSectionList, function (val) {
  121. data.infoSectionList.push(val);
  122. });
  123. data.typecodemap = Object.assign(data.typecodemap, response.data.typecodemap);
  124. console.log(data);
  125. def.resolve(data);
  126. } else {
  127. def.reject('错误');
  128. }
  129. })
  130. } else {
  131. def.reject('错误');
  132. }
  133. })
  134. }
  135. return def.promise;
  136. }
  137. // console.log($scope.rolePageModel);
  138. var getRolePageSectionList = function () {
  139. $scope.showLoadingToast();
  140. if ($stateParams.comfrom == 'resource') {
  141. $scope.rolePageModel = {
  142. id: 13
  143. }
  144. }
  145. // console.log($scope.rolePageModel);
  146. roleService.getRolePageSectionList($scope.rolePageModel).then(function (response) {
  147. // console.log("==============================");
  148. // console.log(response.data);
  149. $scope.activity = [];
  150. // 基本信息
  151. $scope.sectionList = response.data.sectionList;
  152. if (UtilService.isDefined($scope.sectionList)) {
  153. angular.forEach($scope.sectionList, function (value, index) {
  154. var baseactivity = {
  155. className: '',
  156. headerName: '',
  157. restype: ''
  158. };
  159. // console.log(value);
  160. baseactivity.className = value.seccode;// 模块编号
  161. baseactivity.headerName = value.secname;// 模块名称
  162. baseactivity.restype = value.lktablecode;// 模块名称
  163. $scope.activity.push(baseactivity);
  164. if ($scope.activity.length > 0) {
  165. $scope.act = $scope.activity[0].className;
  166. }
  167. });
  168. for (var i = 0; i < $scope.activity.length; i++) {
  169. hasSearchData[i] = true;
  170. }
  171. console.log($scope.activity);
  172. if ($scope.isedit == 1 || $scope.isedit == 2) {
  173. getAllData().then(function (response) {
  174. console.log(response);
  175. angular.forEach($scope.activity, function (val, index) {
  176. if (val.headerName == "对接录入") {
  177. goToTaskAction(response, 5322)
  178. }
  179. if (val.headerName == "人才信息") {
  180. innertype = 38;
  181. } else if (val.headerName == "专家信息") {
  182. innertype = 8;
  183. } else {
  184. innertype = $stateParams.innertype;
  185. }
  186. getData(val.headerName, val.restype, index, innertype, response);
  187. })
  188. })
  189. } else {
  190. angular.forEach($scope.activity, function (val, index) {
  191. if (val.headerName == "对接录入") {
  192. goToTaskAction(response, 5322)
  193. }
  194. if (val.headerName == "人才信息") {
  195. innertype = 38;
  196. } else if (val.headerName == "专家信息") {
  197. innertype = 8;
  198. } else {
  199. innertype = $stateParams.innertype;
  200. }
  201. getData(val.headerName, val.restype, index, innertype);
  202. })
  203. }
  204. }
  205. }, function () {
  206. })
  207. };
  208. //调试
  209. getRolePageSectionList();
  210. var goToTaskAction = function (list, action) {
  211. console.log(list);
  212. console.log(action);
  213. if (!ConfigService.islogin) {
  214. if (localStorage.wxFlag == "true") {
  215. if (localStorage.isUserFocusXW == 0) {
  216. var title = localStorage.appidStr;
  217. $ionicPopup.alert({
  218. title: '提示',
  219. template: '请先关注微信公众号"' + title + '"!'
  220. });
  221. return;
  222. } else {
  223. if (localStorage.isUserBindWx == 0) {
  224. var wxFlag = JSON.parse(localStorage.params);
  225. if (wxFlag.weChatModel) {
  226. $scope.go('bindPhone', {
  227. params: localStorage.params,
  228. comfrom: 'maincontroller',
  229. url: window.location.href.split('#/')[1]
  230. });
  231. } else {
  232. $scope.go('login');
  233. return;
  234. }
  235. } else {
  236. $scope.go('login');
  237. return;
  238. }
  239. }
  240. } else {
  241. $scope.go('login');
  242. return;
  243. }
  244. return;
  245. }
  246. // if (action == 5322) {
  247. // // 对接录入
  248. // $scope.go('dockingInput', {
  249. // comfrom: 'dockingInput',
  250. // /*taskTitle: list.title,
  251. // taskid: $stateParams.taskid,*/
  252. // companyName: list.baseInfoModel.title,
  253. // companyid: list.baseInfoModel.oid,
  254. // })
  255. // }
  256. }
  257. var getCascadList = function (arr, index, key) {
  258. // console.log(index);
  259. // console.log(arr);
  260. dataToolsService.getWebCascade(key, 1).then(function (response) {
  261. if (UtilService.isDefined(response.data) && response.data.length > 0) {
  262. console.log(response);
  263. arr[index].content = response.data[0].name;
  264. arr[index + 1].dictionary = response.data[0].code;
  265. dataToolsService.getWebCascade(response.data[0].code, 0).then(function (res) {
  266. var temp = res.data.filter(function (val) {
  267. return val.code == key;
  268. })
  269. if (temp.length > 0) {
  270. arr[index + 1].content = temp[0].name;
  271. }
  272. })
  273. }
  274. }, function () {
  275. })
  276. }
  277. //切换到对应页面
  278. $scope.activity = [];
  279. $scope.visitType = 0;//0:高校走企业 ,1:政府走企业,2:术经纪人或服务机构走企业,3:企业走高校,4:政府走高校、技术经纪人或服务机构走高校
  280. var lastNum = 0;
  281. $scope.tempData = [];
  282. //从后台获取数据
  283. // 默认显示内容
  284. $scope.getDataFromBackground = {
  285. detailList: [],
  286. addList: [],
  287. pagecode: 0,
  288. title: '',
  289. tcname: '',
  290. itemvalue: '',
  291. tablename: '',
  292. templettype: 0,
  293. };
  294. $scope.getFirstPage = true;
  295. var getData = function (title, restype, num, innertype, response) {
  296. if ($stateParams.pageid == 3) {
  297. innertype = $scope.rolePageModel.orgtype;
  298. } else if ($stateParams.pageid == 30 || $stateParams.pageid == 31 || $stateParams.pageid == 32 || $stateParams.pageid == 33 || $stateParams.pageid == 34) {
  299. innertype = $stateParams.pageid
  300. }
  301. var tempArray = {};
  302. //调试
  303. dataToolsService.getFormStructure($stateParams.pagecode, restype, innertype, $stateParams.node, $stateParams.resourcetype).then(function (res) {
  304. // dataToolsService.getFormStructure(1000030,30001,innertype,$stateParams.node).then(function(res){
  305. if (res.code == 3350) {
  306. if ($stateParams.title) {
  307. angular.forEach(res.data.infoSectionList[0].unitItems[0], function (val) {
  308. if (val.tcname == 'orgname' || val.tcname == 'companyid' || val.tcname == 'title') {
  309. val.content = $stateParams.title;
  310. }
  311. })
  312. }
  313. tempArray.detailList = res.data.infoSectionList[0].unitItems[0];
  314. tempArray.addList = res.data.infoSectionList[0].subItems;
  315. angular.forEach(tempArray.detailList, function (vv) {
  316. if (vv.addimg) {
  317. vv.tempimagelist = [];
  318. vv.imagelist = [];
  319. vv.orgimages = [];
  320. }
  321. });
  322. angular.forEach(tempArray.addList, function (val) {
  323. angular.forEach(val.unitItems[0], function (value) {
  324. if (value.addimg) {
  325. value.tempimagelist = [];
  326. value.imagelist = [];
  327. value.orgimages = [];
  328. }
  329. })
  330. })
  331. // tempArray.pagecode=res.data.infoSectionList[0].pagecode;
  332. tempArray.pagecode = $stateParams.pagecode;
  333. tempArray.title = title;
  334. tempArray.tcname = res.data.infoSectionList[0].tcname;
  335. tempArray.restype = restype;
  336. tempArray.tablename = res.data.infoSectionList[0].tablename;
  337. tempArray.orgid = 0;
  338. if ($scope.isedit == 1 || $scope.isedit == 2) {
  339. var data = response.infoSectionList;
  340. var baseInfo = response.baseInfoModel;
  341. tempArray.oid = response.baseInfoModel.oid;
  342. if (tempArray.addList && tempArray.addList.length > 0) {
  343. angular.forEach(tempArray.addList, function (ta) {
  344. var temp = data.filter(function (da) {
  345. if (da.innertype) {
  346. return da.itemvalue == ta.itemvalue && da.innertype == ta.innertype;
  347. } else {
  348. return da.itemvalue == ta.itemvalue;
  349. }
  350. })
  351. if (temp.length > 0) {
  352. // console.log(temp);
  353. // return;
  354. var dd = Object.assign([], ta.unitItems[0]);
  355. ta.unitItems = [];
  356. // var length=temp[0].count?temp[0].count:0;
  357. var division = temp[0].count ? temp[0].unitlist.length / temp[0].count : 0;
  358. if (division) {
  359. for (var k = 0; k < temp[0].unitlist.length; k++) {
  360. var tt = Object.assign([], dd);
  361. var detail = temp[0].unitlist.slice(k, k + division);
  362. k = k + division - 1;
  363. angular.forEach(detail, function (vv) {
  364. for (var i = 0; i < tt.length; i++) {
  365. if (tt[i].tcname == vv.tcname) {
  366. // console.log(tt[i]);
  367. tt[i].content = tt[i].type == 'number' ? Number(vv.content) : vv.content;
  368. break;
  369. }
  370. }
  371. });
  372. // console.log(tt);
  373. ta.unitItems.push(JSON.parse(JSON.stringify(tt)));
  374. tt = [];
  375. }
  376. }
  377. angular.forEach(tempArray.addList, function (v, i) {
  378. angular.forEach(v.unitItems, function (val, ind) {
  379. angular.forEach(val, function (value, index) {
  380. if (value.addimg) {
  381. var tempImg = value.content ? JSON.parse(value.content) : [];
  382. if ($scope.isedit == 2) {
  383. angular.forEach(tempImg, function (v) {
  384. v.id = 0;
  385. })
  386. }
  387. value.imagelist = Object.assign([], tempImg);
  388. // value.imagelist=[];
  389. // value.orgimages=Object.assign([],tempImg);
  390. value.orgimages = [];
  391. value.tempimagelist = Object.assign([], tempImg);
  392. }
  393. if (value.toggle) {
  394. value.togglecontent = value.content == '1';
  395. value.content = value.content == '1' ? '是' : '否';
  396. }
  397. })
  398. })
  399. })
  400. }
  401. })
  402. }
  403. if (tempArray.detailList && tempArray.detailList.length > 0) {
  404. var temp = data.filter(function (vv1) {
  405. return vv1.itemvalue == restype
  406. })
  407. var companyTemp = data.filter(function (vvv) {
  408. return vvv.itemvalue == 30030;
  409. })
  410. if (temp.length > 0) {
  411. if (companyTemp.length > 0) {
  412. temp[0].unitlist = temp[0].unitlist.concat(companyTemp[0].unitlist)
  413. }
  414. angular.forEach(temp[0].unitlist, function (vv2) {
  415. for (var i = 0; i < tempArray.detailList.length; i++) {
  416. var td = tempArray.detailList[i];
  417. if (td.rescode == vv2.rescode || td.title == vv2.title) {
  418. // td.content=vv2.content;
  419. // if(vv2.toggle){
  420. // console.log(vv2);
  421. // }
  422. td.content = td.type == 'number' ? Number(vv2.content) : vv2.content;
  423. break;
  424. }
  425. }
  426. })
  427. angular.forEach(tempArray.detailList, function (v1, indx) {
  428. if (v1.addimg) {
  429. var tempImg = v1.content ? JSON.parse(v1.content) : [];
  430. v1.imagelist = Object.assign([], tempImg);
  431. // v1.imagelist=[];
  432. // v1.orgimages=Object.assign([],tempImg);
  433. v1.orgimages = [];
  434. v1.tempimagelist = Object.assign([], tempImg);
  435. }
  436. if (v1.toggle) {
  437. // console.log(v1);
  438. v1.togglecontent = v1.content == '1';
  439. v1.content = v1.content == '1' ? '是' : '否';
  440. }
  441. // if(v1.type=='cascade'){
  442. if (v1.tcname == 'category') {
  443. // console.log(v1);
  444. if (v1.dictionary == '30') {
  445. dataToolsService.getWebCascade(30, 0).then(function (re) {
  446. if (re.code == 3350) {
  447. var tem = re.data.filter(function (ve) {
  448. return ve.code == v1.content;
  449. })
  450. if (tem.length > 0) {
  451. v1.content = tem[0].name;
  452. }
  453. }
  454. })
  455. } else {
  456. getCascadList(tempArray.detailList, indx, v1.content)
  457. }
  458. }
  459. })
  460. // console.log($scope.isedit);
  461. for (var i = 0; i < tempArray.detailList.length; i++) {
  462. if (tempArray.detailList[i].tcname == 'orglogo') {
  463. tempArray.detailList[i].content = baseInfo.logo;
  464. }
  465. if (tempArray.detailList[i].tcname == 'orgname') {
  466. tempArray.detailList[i].content = baseInfo.title;
  467. }
  468. if (tempArray.detailList[i].tcname == 'companyid') {
  469. tempArray.detailList[i].content = baseInfo.title;
  470. }
  471. }
  472. }
  473. }
  474. if ($scope.getFirstPage && num == 0) {
  475. $scope.getDataFromBackground = tempArray;
  476. $scope.getFirstPage = false;
  477. $scope.hideLoadingToast();
  478. }
  479. $scope.tempData[num] = tempArray;
  480. } else {
  481. if ($scope.getFirstPage && num == 0) {
  482. $scope.getDataFromBackground = tempArray;
  483. $scope.getFirstPage = false;
  484. $scope.hideLoadingToast();
  485. }
  486. $scope.tempData[num] = tempArray;
  487. }
  488. if ($scope.tempData[0] != undefined && $scope.tempData[0].title == "导师信息") {
  489. angular.forEach($scope.tempData[0].addList, function (val, index) {
  490. if (val.title == "添加人才") {
  491. val.title = "添加导师";
  492. }
  493. angular.forEach(val.unitItems[0], function (value, index) {
  494. if (value.title == "人才简介") {
  495. value.title = "导师简介";
  496. value.placeholder = "请输入导师简介";
  497. }
  498. })
  499. })
  500. }
  501. if (title == "导师信息") {
  502. var list = [];
  503. angular.forEach($scope.tempData[0].addList[0].unitItems[0], function (val, index) {
  504. if (val.title != "职位" && val.title != "学位" && val.title != "所属领域") {
  505. list.push(val);
  506. }
  507. })
  508. $scope.tempData[0].addList[0].unitItems[0] = list;
  509. }
  510. } else {
  511. console.error('网络错误')
  512. }
  513. })
  514. }
  515. $scope.carryout = {}
  516. //调试
  517. // getData('基本信息',30001,0);
  518. $scope.changeInfoStyle = function () {
  519. if ($scope.isedit == 0) {
  520. $scope.isTapChange = !$scope.isTapChange;
  521. // 选取身份证弹框
  522. $ionicActionSheet.show({
  523. buttons: toggleInfo,
  524. cancelText: '取消',
  525. buttonClicked: function (index) {
  526. var tginfo = [
  527. {
  528. savename: '保存企业基本信息',
  529. text: '<a class="action-sheet-push">企业</a>',
  530. title: '企业基本信息',
  531. orgtype: 10104,
  532. id: $stateParams.pageid,
  533. select: true,
  534. }, {
  535. savename: '保存高校基本信息',
  536. text: '<a class="action-sheet-push">高校</a>',
  537. title: '高校基本信息',
  538. orgtype: 10105,
  539. id: $stateParams.pageid,
  540. select: false
  541. }
  542. ]
  543. $scope.rolePageModel = tginfo[index];
  544. $scope.getFirstPage = true;
  545. // getData($scope.activity[0].headerName,$scope.activity[0].restype,0);
  546. getRolePageSectionList();
  547. return true;
  548. }
  549. });
  550. }
  551. };
  552. // 点击页头切换页面
  553. $scope.changeAct = function (num) {
  554. /************ sarah ****************/
  555. $scope.tempData[lastNum] = null;
  556. $scope.tempData[lastNum] = Object.assign({}, $scope.getDataFromBackground);
  557. lastNum = num;
  558. // console.log($scope.tempData);
  559. // 基本信息的联想
  560. if ($scope.tempData[num].title == '人力资源' && $scope.tempData[0].orgid && hasSearchData[num]) {
  561. hasSearchData[num] = false;
  562. $scope.showLoadingToast();
  563. dataToolsService.getHrResource($scope.tempData[0].orgid, $scope.tempData[0].pagecode, 0).then(function (res) {
  564. $scope.hideLoadingToast();
  565. if (res.code == 3350) {
  566. // $scope.tempData[num].detailList=res.data;
  567. angular.forEach($scope.tempData[num].detailList, function (val) {
  568. for (var key in res.data) {
  569. if (key == val.tcname) {
  570. val.content = res.data[key];
  571. if (val.toggle) {
  572. val.content = res.data[key] ? '是' : '否';
  573. val.togglecontent = res.data[key] ? true : false;
  574. }
  575. // if(val.type=='number'){
  576. // val.content=res.data[key];
  577. // }
  578. }
  579. }
  580. })
  581. }
  582. })
  583. } else if ($scope.tempData[0].orgid && hasSearchData[num]) {
  584. console.log(1);
  585. console.log($scope.tempData[0]);
  586. hasSearchData[num] = false;
  587. angular.forEach($scope.tempData[num].detailList, function (value) {
  588. for (var key in $scope.tempData[0].conpanyInfo) {
  589. if (key == value.tcname) {
  590. if (value.tcname != 'id' && value.restype != 3760) {
  591. value.content = $scope.tempData[0].conpanyInfo[key];
  592. }
  593. if (value.toggle) {
  594. value.content = $scope.tempData[0].conpanyInfo[key] ? '是' : '否';
  595. value.togglecontent = $scope.tempData[0].conpanyInfo[key] ? true : false;
  596. }
  597. }
  598. }
  599. })
  600. }
  601. console.log('$scope.tempData', $scope.tempData)
  602. if ($scope.tempData[num]) {
  603. $scope.getDataFromBackground = $scope.tempData[num];
  604. } else {
  605. // 从后台获取表单信息
  606. getData($scope.activity[num].restype);
  607. }
  608. /************2018****************/
  609. $ionicScrollDelegate.$getByHandle('mainScroll').scrollTop();
  610. $timeout(function () {
  611. $("#orgname").prop("disabled", true);
  612. }, 50);
  613. $scope.act = $scope.activity[num].className;
  614. var tablength = $scope.activity.length;//标题个数
  615. var middlewidth = $(window).width() / 2;//获取当前手机屏幕宽度一般
  616. var OffLeft = $(".main-select").eq(num).offset().left;//获取当前点击标题距离父容器左边框的距离
  617. var SelfWidth = $(".main-select").eq(num).width();//获取当前点击标题宽度
  618. var startTranform = $(".visitModule_header .scroll").offset().left + 25;
  619. var movewidth = OffLeft - middlewidth + SelfWidth / 2;
  620. startTranform -= movewidth;
  621. if (startTranform <= 0) {
  622. if (num < tablength - 1) {
  623. $('.visitModule_header .scroll').css({
  624. 'transform': 'translate3d(' + startTranform + 'px,0,0)'
  625. });
  626. }
  627. } else if (num < 4) {
  628. $('.visitModule_header .scroll').css({
  629. 'transform': 'translate3d(0,0,0)'
  630. });
  631. }
  632. $(".main-select").eq(num).addClass("arrange_borderBottom").siblings().removeClass("arrange_borderBottom");
  633. };
  634. //保存企业信息表
  635. $scope.connEnterpriseModuleModel = {
  636. id: 0,
  637. organizationInfo: {
  638. id: 0
  639. }
  640. };
  641. // 控制多次点击保存不触发
  642. var saveflg = 0;
  643. // var tempimages = [];
  644. var basicArr = [];//基本信息
  645. var projectInfo = [];//项目信息
  646. var comProduct = [];//企业产品
  647. var basicOperate = [];
  648. var basicIPR = [];
  649. var basicContact = [];
  650. var projectTransformation = {};
  651. var basicIUS = {};
  652. var temp = {};
  653. /************ sarah ****************/
  654. // 处理数组
  655. var handleArray = function (arr, delarr) {
  656. console.log(delarr);
  657. console.log(arr);
  658. if (delarr != 'other' && delarr && delarr.length > 0) {
  659. angular.forEach(delarr, function (v, i) {
  660. angular.forEach(v, function (vv) {
  661. if (vv.tcname == 'isenabled') {
  662. vv.content = '2';
  663. }
  664. })
  665. arr.push(v);
  666. })
  667. }
  668. if (arr && arr.length > 0) {
  669. var array = [];
  670. // 全部为空,则舍弃该组数据
  671. for (var i = 0; i < arr.length; i++) {
  672. for (var j = 0; j < arr[i].length; j++) {
  673. if (arr[i][j].content != '' || (arr[i][j].imagelist != undefined && arr[i][j].imagelist.length > 0)) break;
  674. }
  675. if (j == arr[i].length) {
  676. arr.splice(i, 1);
  677. i--;
  678. }
  679. ;
  680. }
  681. // 赋初始值
  682. for (var k = 0; k < arr.length; k++) {
  683. for (var m = 0; m < arr[k].length; m++) {
  684. if (arr[k][m].content == '') {
  685. arr[k][m].content = arr[k][m].defaultvalue;
  686. }
  687. }
  688. }
  689. if (arr.length == 0) {
  690. return [];
  691. }
  692. // console.log(arr);
  693. angular.forEach(arr, function (val, index) {
  694. temp = {};
  695. isSon = true;
  696. // angular.forEach(val,function(value,ind){
  697. for (var i = 0; i < val.length; i++) {
  698. var value = val[i];
  699. if (value.fathermodel != '') {
  700. temp[value.fathermodel] = typeof temp[value.fathermodel] == 'object' ? temp[value.fathermodel] : {};
  701. if (value.fathercolumnname != '') {
  702. if (value.addimg) {
  703. if (value.orgimages.length > 0) {
  704. value.imagelist = value.imagelist.concat(value.orgimages);
  705. }
  706. temp[value.fathermodel][value.fathercolumnname] = JSON.stringify(value.imagelist);
  707. } else if (value.selectaction) {
  708. temp[value.fathermodel][value.fathercolumnname] = value.itemIndex;
  709. } else if (value.toggle) {
  710. temp[value.fathermodel][value.fathercolumnname] = value.content == '是' ? 1 : 0;
  711. } else {
  712. // temp[value.fathermodel][value.fathercolumnname] = value.content;
  713. if (value.content != '') {
  714. temp[value.fathermodel][value.fathercolumnname] = value.content;
  715. } else {
  716. continue;
  717. }
  718. }
  719. } else {
  720. if (value.addimg) {
  721. if (value.orgimages.length > 0) {
  722. value.imagelist = value.imagelist.concat(value.orgimages);
  723. }
  724. temp[value.fathermodel][value.tcname] = JSON.stringify(value.imagelist);
  725. } else if (value.selectaction) {
  726. temp[value.fathermodel][value.tcname] = value.itemIndex;
  727. } else if (value.toggle) {
  728. temp[value.fathermodel][value.tcname] = value.content == '是' ? 1 : 0;
  729. } else {
  730. // temp[value.fathermodel][value.tcname] = value.content;
  731. if (value.content != '') {
  732. temp[value.fathermodel][value.tcname] = value.content;
  733. } else {
  734. continue;
  735. }
  736. }
  737. }
  738. if (value.ismain == 1) {
  739. if (value.addimg) {
  740. if (value.orgimages.length > 0) {
  741. value.imagelist = value.imagelist.concat(value.orgimages);
  742. }
  743. temp[value.tcname] = JSON.stringify(value.imagelist);
  744. } else if (value.selectaction) {
  745. temp[value.tcname] = value.itemIndex;
  746. } else if (value.toggle) {
  747. temp[value.tcname] = value.content == '是' ? 1 : 0;
  748. } else {
  749. // temp[value.tcname] = value.content;
  750. if (value.content != '') {
  751. temp[value.tcname] = value.content;
  752. } else {
  753. continue;
  754. }
  755. }
  756. }
  757. } else {
  758. if (value.addimg) {
  759. if (value.orgimages.length > 0) {
  760. value.imagelist = value.imagelist.concat(value.orgimages);
  761. }
  762. if (value.restype == 3760 && delarr !== false) {//等于其他信息
  763. temp.imagelists = JSON.stringify(value.imagelist);
  764. } else if (value.restype != 3760) {
  765. temp[value.tcname] = JSON.stringify(value.imagelist);
  766. }
  767. } else if (value.selectaction) {
  768. temp[value.tcname] = value.itemIndex;
  769. } else if (value.toggle) {
  770. temp[value.tcname] = value.content == '是' ? 1 : 0;
  771. } else {
  772. // temp[value.tcname] = value.content;
  773. if (value.content != '' && value.restype != 3760) {
  774. temp[value.tcname] = value.content;
  775. } else if (value.restype == 3760 && delarr !== false) {
  776. temp[value.tcname] = value.content;
  777. } else {
  778. continue;
  779. }
  780. }
  781. }
  782. }
  783. // });
  784. if (delarr === false) {
  785. array.push(temp);
  786. // array=[temp];
  787. console.log(array);
  788. } else {
  789. // if($scope.isedit==1||$scope.isedit==2){
  790. // temp.connid=$stateParams.connid;
  791. // }else{
  792. // temp.connid=$scope.connid;
  793. // }
  794. temp.connid = $scope.connid;
  795. temp.companyid = $scope.connEnterpriseModuleModel.organizationInfo.id;
  796. temp.creator = UserService.id;
  797. temp.updater = UserService.id;
  798. temp.isenabled = (temp.isenabled == '' || temp.isenabled == undefined) ? 1 : temp.isenabled;
  799. temp.id = (temp.id == '' || temp.id == undefined) ? 0 : temp.id;
  800. if ($scope.isedit == 2) {
  801. temp.id = 0;
  802. }
  803. // array=[temp];
  804. console.log(temp);
  805. array.push(temp);
  806. console.log(array);
  807. }
  808. });
  809. console.log(array);
  810. return array;
  811. } else {
  812. return [];
  813. }
  814. };
  815. var feedbackItem = {};
  816. $scope.saveCompanyInfo = function () {
  817. var pagecode = $scope.tempData[0].pagecode;
  818. if ($scope.tempData[0].addList != null) {
  819. if ($scope.tempData[0].addList[0] == undefined) {
  820. var bakeinfoList = $scope.tempData[0].detailList;
  821. } else {
  822. var bakeinfoList = $scope.tempData[0].addList[0].unitItems[0];
  823. }
  824. } else {
  825. var bakeinfoList = $scope.tempData[0].detailList;
  826. }
  827. var flag = 0;
  828. angular.forEach(bakeinfoList, function (val) {
  829. if (val.title == "姓名" && val.content == "") {
  830. CommonService.showMessage('请输入导师姓名!', $scope);
  831. flag = 1;
  832. }
  833. })
  834. if (flag == 0) {
  835. var orgName = "";
  836. if ($scope.tempData[0].detailList != null && $scope.tempData[0].detailList != undefined) {
  837. angular.forEach($scope.tempData[0].detailList, function (val) {
  838. if (val.title == "企业名称") {
  839. orgName = val.content;
  840. }
  841. });
  842. }
  843. if (pagecode == 1000030 && orgName != "") {
  844. dataToolsService.judgeOrgExistResource(orgName, UserService.node).then(function (response) {
  845. var message = response.message;
  846. if (message == "已存在该企业") {
  847. CommonService.showMessage('已存在该企业,请重新输入!', $scope);
  848. } else if (message == "该企业不存在") {
  849. newSaveCompanyInfo();
  850. }
  851. });
  852. }
  853. newSaveCompanyInfo();
  854. }
  855. };
  856. var newSaveCompanyInfo = function () {
  857. if ($stateParams.pageid == 30 || $stateParams.pageid == 31 || $stateParams.pageid == 32 || $stateParams.pageid == 33 || $stateParams.pageid == 34) {
  858. console.log($scope.tempData);
  859. for (var i = 0; i < $scope.tempData[0].detailList.length; i++) {
  860. if ($scope.tempData[0].detailList[i].needed && $scope.tempData[0].detailList[i].content == '') {
  861. if ($scope.app) {
  862. UtilService.showMess($scope.tempData[0].detailList[i].title + '是必填项');
  863. } else {
  864. CommonService.showMessage($scope.tempData[0].detailList[i].title + '是必填项', $scope);
  865. }
  866. $scope.hideLoadingToast();
  867. saveflg = 0;
  868. return;
  869. }
  870. }
  871. var params = handleArray([$scope.tempData[0].detailList], false)[0];
  872. if (params) {
  873. params.id = params.id ? params.id : 0;
  874. params.isenabled = params.isenabled ? params.isenabled : 1;
  875. params.comfrom = $stateParams.node;
  876. params.creator = UserService.id;
  877. params.restype = $stateParams.pageid;
  878. console.log(params);
  879. var data = {
  880. data: params,
  881. node: $stateParams.node
  882. }
  883. // return;
  884. console.log(data);
  885. dataToolsService.saveWebInfo(data).then(function (res) {
  886. console.log($scope.isedit);
  887. if (res.code == 3350) {
  888. // if($scope.isedit==0){
  889. $scope.goback();
  890. // }else{
  891. // $scope.go('resourceCommonDetailsPage', {
  892. // recourceid: $stateParams.connid,
  893. // recourcetype: $stateParams.restype,
  894. // recourcecomefrom: $stateParams.node,
  895. // creator: '',
  896. // title:$stateParams.title,
  897. // orgtype:$stateParams.orgtype,
  898. // // comfrom:$scope.comfrom,
  899. // pagecode:$stateParams.pagecode
  900. // });
  901. // }
  902. }
  903. })
  904. } else {
  905. saveflg = 0;
  906. if ($scope.app) {
  907. UtilService.showMess('请填写相关数据');
  908. } else {
  909. CommonService.showMessage('请填写相关数据', $scope);
  910. }
  911. }
  912. return;
  913. }
  914. if ($stateParams.comfrom == 'activityDetail') {
  915. console.log($scope.tempData[0]);
  916. for (var i = 0; i < $scope.tempData[0].detailList.length; i++) {
  917. if ($scope.tempData[0].detailList[i].needed && $scope.tempData[0].detailList[i].content == '') {
  918. if ($scope.app) {
  919. UtilService.showMess($scope.tempData[0].detailList[i].title + '是必填项');
  920. } else {
  921. CommonService.showMessage($scope.tempData[0].detailList[i].title + '是必填项', $scope);
  922. }
  923. $scope.hideLoadingToast();
  924. saveflg = 0;
  925. return;
  926. }
  927. }
  928. var params1 = handleArray([$scope.tempData[0].detailList], false)[0];
  929. if (params1) {
  930. var images = JSON.parse(params1.images);
  931. angular.forEach(images, function (val) {
  932. val.doctype = 4913;
  933. })
  934. var data1 = {
  935. "activityid": $stateParams.companyid,
  936. "title": params1.title,
  937. "content": params1.content,
  938. "creator": UserService.id,
  939. "images": JSON.stringify(images)
  940. }
  941. dataToolsService.saveActivityBroadcastInfo({data: data1}).then(function (res) {
  942. console.log(res);
  943. if (res.code == 3350) {
  944. $scope.hideLoadingToast();
  945. $scope.go('activityDetail', {activityid: $stateParams.companyid})
  946. }
  947. })
  948. }
  949. return;
  950. }
  951. // 获取企业基本信息数组
  952. console.log($scope.tempData);
  953. basicArr = $scope.tempData.filter(function (val, i, arr) {
  954. return val.title == '企业基本信息' || '高校基本信息';
  955. })[0];
  956. projectInfo = $scope.tempData.filter(function (val, i, arr) {
  957. return val.title == '项目信息';
  958. })[0] || {addList: []};
  959. comProduct = $scope.tempData.filter(function (val, i, arr) {
  960. return val.title == '企业产品';
  961. })[0] || {addList: []};
  962. // 经营情况
  963. basicOperate = $scope.tempData.filter(function (val) {
  964. return val.title == '经营情况';
  965. })[0];
  966. // 知识产权
  967. basicIPR = $scope.tempData.filter(function (val) {
  968. return val.title == '知识产权';
  969. })[0];
  970. // 产学研信息 industry-university-research
  971. basicIUS = $scope.tempData.filter(function (val) {
  972. return val.title == '产学研信息';
  973. })[0];
  974. // 联系方式 contact
  975. basicContact = $scope.tempData.filter(function (val) {
  976. return val.title == '联系方式';
  977. })[0];
  978. projectTransformation = $scope.tempData.filter(function (val) {
  979. return val.title == '促成成果转化项目';
  980. })[0];
  981. // if($stateParams.node=='320117005'||$stateParams.node=='320117003'||$stateParams.node=='320117002'||$stateParams.node=='320117001'||$stateParams.node=='320117004'){
  982. // basicArr=$scope.tempData[0];
  983. // }
  984. if (saveflg != 0) {
  985. return;
  986. }
  987. saveflg = 1;
  988. $scope.showLoadingToast();
  989. saveInfo();
  990. };
  991. console.log('---------', $scope.rolePageModel);
  992. // 保存企业信息
  993. var saveInfo = function () {
  994. basicArr = basicArr ? basicArr : $scope.tempData[0];
  995. // 判断必填项
  996. for (var i = 0; i < basicArr.detailList.length; i++) {
  997. if (basicArr.detailList[i].needed && basicArr.detailList[i].content == '') {
  998. if ($scope.app) {
  999. UtilService.showMess(basicArr.detailList[i].title + '是必填项');
  1000. } else {
  1001. CommonService.showMessage(basicArr.detailList[i].title + '是必填项', $scope);
  1002. }
  1003. $scope.hideLoadingToast();
  1004. saveflg = 0;
  1005. return;
  1006. }
  1007. }
  1008. if (basicArr.addList.length != 0) {
  1009. for (var i = 0; i < basicArr.addList[0].unitItems.length; i++) {
  1010. for (var s = 0; s < basicArr.addList[0].unitItems[i].length; s++) {
  1011. if (basicArr.addList[0].unitItems[i][s].needed && basicArr.addList[i].unitItems[i][s].content == '') {
  1012. if ($scope.app) {
  1013. UtilService.showMess(basicArr.addList[0].unitItems[i][s].title + '是必填项');
  1014. } else {
  1015. CommonService.showMessage(basicArr.addList[0].unitItems[i][s].title + '是必填项', $scope);
  1016. }
  1017. $scope.hideLoadingToast();
  1018. saveflg = 0;
  1019. return;
  1020. }
  1021. }
  1022. }
  1023. }
  1024. // 处理数据
  1025. var allbasicArr = [];
  1026. for (var i = 0; i < $scope.tempData.length; i++) {
  1027. if ($scope.tempData[i].title != '人力资源') {
  1028. for (var j = 0; j < $scope.tempData[i].detailList.length; j++) {
  1029. if ($scope.tempData[i].detailList[j].type == 'hidden' && $scope.tempData[i].detailList[j].restype != 3760) {
  1030. if ($scope.tempData[i].title != '基本信息' || $scope.tempData[i].title != '高校基本信息')
  1031. $scope.tempData[i].detailList.splice(j, 1);
  1032. }
  1033. }
  1034. allbasicArr = allbasicArr.concat($scope.tempData[i].detailList);
  1035. // console.log(allbasicArr);
  1036. }
  1037. }
  1038. console.log('$scope.tempData', $scope.tempData)
  1039. // var allbasicArr=basicArr.detailList;
  1040. // if(basicOperate.detailList&&basicOperate.detailList.length>0){
  1041. // allbasicArr=allbasicArr.concat(basicOperate.detailList);
  1042. // }
  1043. // if(basicIPR.detailList&&basicIPR.detailList.length>0){
  1044. // allbasicArr=allbasicArr.concat(basicIPR.detailList);
  1045. // }
  1046. // if(basicIUS.detailList&&basicIUS.detailList.length>0){
  1047. // allbasicArr=allbasicArr.concat(basicIUS.detailList);
  1048. // }
  1049. // if(basicContact.detailList&&basicContact.detailList.length>0){
  1050. // allbasicArr=allbasicArr.concat(basicContact.detailList);
  1051. // }
  1052. if (String(allbasicArr) != '') {
  1053. console.log('一段逻辑', allbasicArr)
  1054. $scope.connEnterpriseModuleModel = handleArray([allbasicArr], false)[0];
  1055. }
  1056. // 企业图片
  1057. $scope.requestModel = {
  1058. data: [],
  1059. node: $stateParams.node,
  1060. pagecode: $stateParams.pagecode,
  1061. }
  1062. // 走访履历表中需记录机构信息
  1063. $scope.connEnterpriseModuleModel.isenabled = 1;
  1064. $scope.connEnterpriseModuleModel.userModel = {
  1065. userid: UserService.id
  1066. };
  1067. // console.log($scope.connEnterpriseModuleModel);
  1068. // if($scope.connEnterpriseModuleModel.organizationInfo.name){
  1069. // }else{
  1070. // var str='';
  1071. // angular.forEach(projectTransformation.addList[0].unitItems,function(val){
  1072. // angular.forEach(val,function(value){
  1073. // if(value.tcname=='projectname'){
  1074. // str+=value.content+' ';
  1075. // }
  1076. // })
  1077. // })
  1078. // $scope.connEnterpriseModuleModel.title =str
  1079. // }
  1080. console.log('$stateParams.pageid',$stateParams.pageid)
  1081. if ($stateParams.pageid == 18) {
  1082. $scope.connEnterpriseModuleModel.organizationInfoList = [];
  1083. if (basicArr.addList.length > 0 && basicArr.addList[0].unitItems.length > 0) {
  1084. $scope.connEnterpriseModuleModel.organizationInfoList = basicArr.addList[0].unitItems;
  1085. }
  1086. $scope.connEnterpriseModuleModel.organizationInfo = {};
  1087. $scope.connEnterpriseModuleModel.organizationInfo.name = $scope.connEnterpriseModuleModel.affiliatedorg;
  1088. $scope.connEnterpriseModuleModel.organizationInfo.title = $scope.connEnterpriseModuleModel.title;
  1089. } else if ($stateParams.pageid == 20) {
  1090. $scope.connEnterpriseModuleModel.organizationInfo.name = $scope.connEnterpriseModuleModel.organizationInfo.name;
  1091. $scope.connEnterpriseModuleModel.organizationInfo.about = $scope.connEnterpriseModuleModel.orgcontent;// 企业logo
  1092. $scope.connEnterpriseModuleModel.organizationInfo.orgtype = $scope.rolePageModel.orgtype;// 机构类型
  1093. } else {
  1094. $scope.connEnterpriseModuleModel.title = $scope.connEnterpriseModuleModel.organizationInfo.name;
  1095. $scope.connEnterpriseModuleModel.organizationInfo.about = $scope.connEnterpriseModuleModel.orgcontent;// 企业logo
  1096. $scope.connEnterpriseModuleModel.organizationInfo.orgtype = (basicArr.conpanyInfo && basicArr.conpanyInfo.orgtype) ? basicArr.conpanyInfo.orgtype : $scope.rolePageModel.orgtype;// 机构类型
  1097. }
  1098. $scope.connEnterpriseModuleModel.orgtype = (basicArr.conpanyInfo && basicArr.conpanyInfo.orgtype) ? basicArr.conpanyInfo.orgtype : $scope.rolePageModel.orgtype;// 机构类型
  1099. $scope.connEnterpriseModuleModel.templettype = $stateParams.pageid;
  1100. $scope.connEnterpriseModuleModel.pagecode = basicArr.pagecode;
  1101. if ($scope.isedit == 2 || $scope.isedit == 0) {
  1102. $scope.connEnterpriseModuleModel.id = 0;
  1103. $scope.connEnterpriseModuleModel.organizationInfo.id = 0;
  1104. }
  1105. //编辑功能
  1106. if ($scope.isedit == 1) {
  1107. $scope.connEnterpriseModuleModel.id = $stateParams.connid;
  1108. }
  1109. // if($scope.isedit==0){
  1110. // $scope.connEnterpriseModuleModel.id = 0;
  1111. // $scope.connEnterpriseModuleModel.organizationInfo.id=0;
  1112. // }
  1113. // 传参格式
  1114. $scope.requestModel.data = JSON.parse(JSON.stringify($scope.connEnterpriseModuleModel));
  1115. $scope.requestModel.pagecode = basicArr.pagecode;
  1116. $scope.requestModel.pagetitle = $stateParams.pageTitle;
  1117. console.log('$scope.requestModel', $scope.requestModel);
  1118. dataToolsService.saveOrganizationInfo($scope.requestModel).then(function (response) {
  1119. // console.log(response);
  1120. if (response.code == ConstantService.INTERFACE_STATUS_CODE_3350) {
  1121. // 保存走访基本信息 后保存其他内容
  1122. // 取得记录id
  1123. $scope.connid = response.data.id;
  1124. feedbackItem.connid = response.data.id;
  1125. // if($scope.isedit==1||$scope.isedit==2){
  1126. // $scope.connid=$stateParams.connid;
  1127. // };
  1128. // 取得机构id
  1129. $scope.connEnterpriseModuleModel.organizationInfo.id = response.data.organizationInfo.id;
  1130. // 1保存走访研发投入
  1131. saveCompanyYearMultipleoptions1();
  1132. } else {
  1133. // console.log(ConstantService.INTERFACE_MESSAGE_ERROR);
  1134. if ($scope.app) {
  1135. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1136. } else {
  1137. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1138. }
  1139. saveflg = 0;
  1140. }
  1141. }, function () {
  1142. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1143. // UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1144. // $scope.hideLoadingToast();
  1145. saveflg = 0;
  1146. });
  1147. };
  1148. // 1保存走访研发投入 企业基本信息->研发投入
  1149. var saveCompanyYearMultipleoptions1 = function () {
  1150. $scope.requestModel = {
  1151. data: [],
  1152. node: $stateParams.node,
  1153. pagecode: $stateParams.pagecode,
  1154. };
  1155. // 获取研发投入数据
  1156. if (basicArr.addList && basicArr.addList.length > 0) {
  1157. var tempArr = basicArr.addList.filter(function (value, j, arr) {
  1158. return value.title == '研发投入'
  1159. })[0];
  1160. if (tempArr) {
  1161. $scope.requestModel.data = handleArray(tempArr.unitItems, tempArr.deletUnitItems);
  1162. }
  1163. }
  1164. console.log($scope.requestModel.data);
  1165. console.log(2);
  1166. if (String($scope.requestModel.data) == '') {
  1167. saveCompanyYearMultipleoptions2();
  1168. } else {
  1169. dataToolsService.insertOrUpdateCompanyYearMultipleoptions($scope.requestModel).then(function (response) {
  1170. // 保存销售收入、净利润、上缴税收
  1171. saveCompanyYearMultipleoptions2();
  1172. // console.log(response);
  1173. }, function () {
  1174. if ($scope.app) {
  1175. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1176. } else {
  1177. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1178. }
  1179. })
  1180. }
  1181. };
  1182. // console.log(2);
  1183. // 2保存走访销售收入、净利润、上缴税收 企业基本信息->实际收入/预计投入情况
  1184. var saveCompanyYearMultipleoptions2 = function () {
  1185. // 保存多条信息需要的格式
  1186. $scope.requestModel = {
  1187. data: [],
  1188. node: $stateParams.node,
  1189. pagecode: $stateParams.pagecode,
  1190. };
  1191. // 保存走访销售收入、净利润、上缴税收
  1192. if (basicArr.addList && basicArr.addList.length > 0) {
  1193. var tempArr = basicArr.addList.filter(function (value, j, arr) {
  1194. return value.title == '实际收入/预计投入情况'
  1195. })[0];
  1196. if (tempArr) {
  1197. $scope.requestModel.data = handleArray(tempArr.unitItems, tempArr.deletUnitItems);
  1198. }
  1199. }
  1200. // console.log(2);
  1201. // console.log($scope.requestModel);
  1202. console.log(3);
  1203. if (String($scope.requestModel.data) == '') {
  1204. saveCompanyYearMultipleoptions3();
  1205. } else {
  1206. dataToolsService.insertOrUpdateCompanyYearMultipleoptions($scope.requestModel).then(function (response) {
  1207. // 保存走访工程中心情况
  1208. // console.log(response);
  1209. saveCompanyYearMultipleoptions3();
  1210. }, function () {
  1211. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1212. // UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1213. })
  1214. }
  1215. };
  1216. // 3保存走访工程中心情况 企业基本信息->工程中心信息
  1217. var saveCompanyYearMultipleoptions3 = function () {
  1218. // 保存多条信息需要的格式
  1219. $scope.requestModel = {
  1220. data: [],
  1221. node: $stateParams.node,
  1222. pagecode: $stateParams.pagecode,
  1223. };
  1224. if (basicArr.addList && basicArr.addList.length > 0) {
  1225. var tempArr = basicArr.addList.filter(function (value, j, arr) {
  1226. return value.title == '工程中心信息'
  1227. })[0];
  1228. if (tempArr) {
  1229. $scope.requestModel.data = handleArray(tempArr.unitItems, tempArr.deletUnitItems);
  1230. }
  1231. }
  1232. if (basicIPR) {
  1233. var temp = basicIPR.addList.filter(function (val) {
  1234. return val.title == '添加专利申请';
  1235. })
  1236. if (temp.length > 0) {
  1237. $scope.requestModel.data = handleArray(temp[0].unitItems, temp[0].deletUnitItems);
  1238. }
  1239. }
  1240. // console.log('abc');
  1241. // console.log($scope.requestModel.data);
  1242. console.log(4);
  1243. if (String($scope.requestModel.data) == '') {
  1244. saveCompanyTechrequirement();
  1245. } else {
  1246. dataToolsService.insertOrUpdateCompanyYearMultipleoptions($scope.requestModel).then(function (response) {
  1247. // console.log(response);
  1248. // 保存关联需求表
  1249. saveCompanyTechrequirement();
  1250. }, function () {
  1251. if ($scope.app) {
  1252. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1253. } else {
  1254. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1255. }
  1256. })
  1257. }
  1258. };
  1259. // 4保存关联需求表 企业需求
  1260. var saveCompanyTechrequirement = function () {
  1261. // 保存多条信息需要的格式
  1262. $scope.requestModel = {
  1263. data: [],
  1264. node: $stateParams.node,
  1265. pagecode: $stateParams.pagecode,
  1266. };
  1267. var demand = $scope.tempData.filter(function (val, i, arr) {
  1268. return val.title == '企业需求';
  1269. })[0];
  1270. // if($stateParams.node=='320117005'||$stateParams.node=='320117003'||$stateParams.node=='320117002'||$stateParams.node=='320117001'||$stateParams.node=='320117004'){
  1271. // demand=$scope.tempData[0];
  1272. // }
  1273. console.log(demand);
  1274. if (demand) {
  1275. $scope.requestModel.data = handleArray(demand.addList[0].unitItems, demand.addList[0].deletUnitItems);
  1276. }
  1277. // console.log(4);
  1278. // console.log($scope.requestModel);
  1279. console.log(5);
  1280. console.log($scope.requestModel);
  1281. if (String($scope.requestModel.data) == '') {
  1282. saveCompanyDeclareproject();
  1283. } else {
  1284. dataToolsService.insertOrUpdateCompanyTechrequirement($scope.requestModel).then(function (response) {
  1285. // console.log(response);
  1286. feedbackItem.demand = response.data;
  1287. // 5保存走访申报项目接口
  1288. saveCompanyDeclareproject();
  1289. }, function () {
  1290. if ($scope.app) {
  1291. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1292. } else {
  1293. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1294. }
  1295. })
  1296. }
  1297. };
  1298. // 5保存走访申报项目接口 项目信息->项目建议
  1299. var saveCompanyDeclareproject = function () {
  1300. // 保存多条信息需要的格式
  1301. $scope.requestModel = {
  1302. data: [],
  1303. node: $stateParams.node,
  1304. pagecode: $stateParams.pagecode,
  1305. };
  1306. if (projectInfo.addList) {
  1307. var tempArr = projectInfo.addList.filter(function (value, j, arr) {
  1308. return value.title == '添加项目建议'
  1309. })[0];
  1310. if (tempArr) {
  1311. $scope.requestModel.data = handleArray(tempArr.unitItems, tempArr.deletUnitItems);
  1312. }
  1313. }
  1314. console.log(6);
  1315. if (String($scope.requestModel.data) == '') {
  1316. saveCompanyHighleveltalents();
  1317. } else {
  1318. dataToolsService.insertOrUpdateCompanyDeclareproject($scope.requestModel).then(function (response) {
  1319. // console.log(response);
  1320. // 6保存高端人才信息表
  1321. saveCompanyHighleveltalents();
  1322. }, function () {
  1323. if ($scope.app) {
  1324. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1325. } else {
  1326. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1327. }
  1328. })
  1329. }
  1330. };
  1331. // 6保存高端人才信息表 人才信息
  1332. var saveCompanyHighleveltalents = function () {
  1333. // 保存多条信息需要的格式
  1334. $scope.requestModel = {
  1335. data: [],
  1336. node: $stateParams.node,
  1337. pagecode: $stateParams.pagecode,
  1338. };
  1339. var talentPerson = $scope.tempData.filter(function (val, i, arr) {
  1340. return val.title == '人才信息' || val.title == '专家信息';
  1341. })[0];
  1342. if (talentPerson) {
  1343. $scope.requestModel.data = handleArray(talentPerson.addList[0].unitItems, talentPerson.addList[0].deletUnitItems);
  1344. for (var i = 0; i < $scope.tempData.length; i++) {
  1345. if ($scope.tempData[i].title == "人才信息") {
  1346. for (var j = 0; j < $scope.requestModel.data.length; j++) {
  1347. $scope.requestModel.data[j].restype = 38;
  1348. }
  1349. }
  1350. if ($scope.tempData[i].title == "专家信息") {
  1351. for (var j = 0; j < $scope.requestModel.data.length; j++) {
  1352. $scope.requestModel.data[j].restype = 8;
  1353. }
  1354. }
  1355. }
  1356. }
  1357. console.log(7);
  1358. if (String($scope.requestModel.data) == '') {
  1359. saveCompanyHignendproduct();
  1360. } else {
  1361. dataToolsService.insertOrUpdateCompanyHighleveltalents($scope.requestModel).then(function (response) {
  1362. // console.log(response);
  1363. // 7保存高端产品
  1364. saveCompanyHignendproduct();
  1365. }, function () {
  1366. if ($scope.app) {
  1367. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1368. } else {
  1369. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1370. }
  1371. })
  1372. }
  1373. };
  1374. // 7保存高端产品 企业产品->高新产品
  1375. var saveCompanyHignendproduct = function () {
  1376. // 保存多条信息需要的格式
  1377. $scope.requestModel = {
  1378. data: [],
  1379. node: $stateParams.node,
  1380. pagecode: $stateParams.pagecode,
  1381. };
  1382. if (comProduct.addList) {
  1383. var tempArr = comProduct.addList.filter(function (value, j, arr) {
  1384. return value.title == '添加高新产品'
  1385. })[0];
  1386. if (tempArr) {
  1387. $scope.requestModel.data = handleArray(tempArr.unitItems, tempArr.deletUnitItems);
  1388. }
  1389. }
  1390. console.log(8);
  1391. if (String($scope.requestModel.data) == '') {
  1392. saveCompanyIur();
  1393. } else {
  1394. dataToolsService.insertOrUpdateCompanyHignendproduct($scope.requestModel).then(function (response) {
  1395. // console.log(response);
  1396. // 8保存产学研
  1397. saveCompanyIur();
  1398. }, function () {
  1399. if ($scope.app) {
  1400. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1401. } else {
  1402. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1403. }
  1404. })
  1405. }
  1406. };
  1407. // 溧水录入产学研分块保存
  1408. var saveIUSInfo = function (arr) {
  1409. var def = $q.defer();
  1410. var saveStatus = [];
  1411. for (var i = 0; i < arr.length; i++) {
  1412. saveStatus[i] = false;
  1413. var requestModel = {
  1414. data: [],
  1415. node: $stateParams.node,
  1416. pagecode: $stateParams.pagecode,
  1417. }
  1418. requestModel.data = handleArray(arr[i].unitItems, arr[i].deletUnitItems);
  1419. if (String(requestModel.data) == '') {
  1420. continue;
  1421. } else {
  1422. console.log(requestModel.data);
  1423. if (arr[i].tcname == 'company_iur_lk') {
  1424. dataToolsService.insertOrUpdateCompanyIur(requestModel).then(function (response) {
  1425. // console.log(response);
  1426. saveStatus[i] = true;
  1427. }, function () {
  1428. if ($scope.app) {
  1429. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1430. } else {
  1431. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1432. }
  1433. })
  1434. } else {
  1435. dataToolsService.insertOrUpdateCompanyYearMultipleoptions(requestModel).then(function (response) {
  1436. // console.log(response);
  1437. saveStatus[i] = true;
  1438. }, function () {
  1439. if ($scope.app) {
  1440. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1441. } else {
  1442. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1443. }
  1444. })
  1445. }
  1446. }
  1447. }
  1448. var timer = $interval(function () {
  1449. var j = 0
  1450. for (; j < saveStatus.length; j++) {
  1451. if (!saveStatus) break;
  1452. }
  1453. if (j == saveStatus.length) {
  1454. $interval.cancel(timer);
  1455. def.resolve(true);
  1456. }
  1457. }, 300)
  1458. return def.promise;
  1459. }
  1460. // 8保存产学研 项目信息->产学研经验
  1461. var saveCompanyIur = function () {
  1462. // 保存多条信息需要的格式
  1463. $scope.requestModel = {
  1464. data: [],
  1465. node: $stateParams.node,
  1466. pagecode: $stateParams.pagecode,
  1467. };
  1468. if ($stateParams.pagecode == 1000003) {
  1469. var tempArr = projectInfo.addList.filter(function (value, j, arr) {
  1470. return value.title == '添加产学研经验'
  1471. })[0];
  1472. if (tempArr) {
  1473. $scope.requestModel.data = handleArray(tempArr.unitItems, tempArr.deletUnitItems);
  1474. }
  1475. console.log(9);
  1476. if (String($scope.requestModel.data) == '') {
  1477. saveCompanyYearMultipleoptions4();
  1478. } else {
  1479. dataToolsService.insertOrUpdateCompanyIur($scope.requestModel).then(function (response) {
  1480. // console.log(response);
  1481. // 9保存重大科研项目
  1482. saveCompanyYearMultipleoptions4();
  1483. }, function () {
  1484. if ($scope.app) {
  1485. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1486. } else {
  1487. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1488. }
  1489. })
  1490. }
  1491. } else if (basicIUS) {
  1492. saveIUSInfo(basicIUS.addList).then(function (data) {
  1493. if (data) {
  1494. saveCompanyYearMultipleoptions4();
  1495. }
  1496. })
  1497. } else {
  1498. saveCompanyYearMultipleoptions4();
  1499. }
  1500. };
  1501. // 9保存重大科研项目 项目信息->重大科研项目
  1502. var saveCompanyYearMultipleoptions4 = function () {
  1503. // 保存多条信息需要的格式
  1504. $scope.requestModel = {
  1505. data: [],
  1506. node: $stateParams.node,
  1507. pagecode: $stateParams.pagecode,
  1508. };
  1509. if (projectInfo.addList) {
  1510. var tempArr = projectInfo.addList.filter(function (value, j, arr) {
  1511. return value.title == '添加重大科研项目'
  1512. })[0];
  1513. if (tempArr) {
  1514. $scope.requestModel.data = handleArray(tempArr.unitItems, tempArr.deletUnitItems);
  1515. }
  1516. }
  1517. console.log(10);
  1518. if (String($scope.requestModel.data) == '') {
  1519. saveCompanyProduct();
  1520. } else {
  1521. dataToolsService.insertOrUpdateCompanyYearMultipleoptions($scope.requestModel).then(function (response) {
  1522. // console.log(response);
  1523. // 10保存公司产品
  1524. saveCompanyProduct();
  1525. }, function () {
  1526. if ($scope.app) {
  1527. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1528. } else {
  1529. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1530. }
  1531. })
  1532. }
  1533. };
  1534. // 10保存公司产品 企业产品->产品
  1535. var saveCompanyProduct = function () {
  1536. // 保存多条信息需要的格式
  1537. $scope.requestModel = {
  1538. data: [],
  1539. node: $stateParams.node,
  1540. pagecode: $stateParams.pagecode,
  1541. };
  1542. if (comProduct && comProduct.addList) {
  1543. var tempArr = comProduct.addList.filter(function (value, j, arr) {
  1544. return value.title == '添加产品'
  1545. })[0];
  1546. if (tempArr) {
  1547. $scope.requestModel.data = handleArray(tempArr.unitItems, tempArr.deletUnitItems);
  1548. }
  1549. }
  1550. console.log(11);
  1551. console.log($scope.requestModel);
  1552. if (String($scope.requestModel.data) == '') {
  1553. saveCompanyIntellectualproperty();
  1554. } else {
  1555. dataToolsService.insertOrUpdateCompanyProduct($scope.requestModel).then(function (response) {
  1556. // console.log(response);
  1557. // 11保存专利信息
  1558. saveCompanyIntellectualproperty();
  1559. }, function () {
  1560. if ($scope.app) {
  1561. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1562. } else {
  1563. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1564. }
  1565. })
  1566. }
  1567. };
  1568. // 11保存专利信息 专利信息
  1569. var saveCompanyIntellectualproperty = function () {
  1570. // 保存多条信息需要的格式
  1571. $scope.requestModel = {
  1572. data: [],
  1573. node: $stateParams.node,
  1574. pagecode: $stateParams.pagecode,
  1575. };
  1576. var patent = $scope.tempData.filter(function (val, i, arr) {
  1577. return (val.title == '专利信息' || val.title == '知识产权信息');
  1578. })[0];
  1579. if (patent) {
  1580. $scope.requestModel.data = handleArray(patent.addList[0].unitItems, patent.addList[0].deletUnitItems);
  1581. }
  1582. if (basicIPR && basicIPR.addList) {
  1583. var patent = basicIPR.addList.filter(function (val) {
  1584. return val.title == '添加知识产权'
  1585. })[0];
  1586. if (patent) {
  1587. $scope.requestModel.data = handleArray(patent.unitItems, patent.deletUnitItems);
  1588. }
  1589. }
  1590. console.log($scope.requestModel);
  1591. if (String($scope.requestModel.data) == '') {
  1592. saveCompanyResearchfinding();
  1593. } else {
  1594. dataToolsService.insertOrUpdateCompanyIntellectualproperty($scope.requestModel).then(function (response) {
  1595. // console.log(response);
  1596. feedbackItem.patent = response.data;
  1597. // 12保存成果信息
  1598. saveCompanyResearchfinding();
  1599. }, function () {
  1600. if ($scope.app) {
  1601. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1602. } else {
  1603. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1604. }
  1605. })
  1606. }
  1607. };
  1608. // 12保存成果信息 高校->成果
  1609. var saveCompanyResearchfinding = function () {
  1610. // 保存多条信息需要的格式
  1611. $scope.requestModel = {
  1612. data: [],
  1613. node: $stateParams.node,
  1614. pagecode: $stateParams.pagecode,
  1615. };
  1616. var achievement = $scope.tempData.filter(function (val, i, arr) {
  1617. return val.title == '成果信息';
  1618. })[0];
  1619. if (achievement) {
  1620. $scope.requestModel.data = handleArray(achievement.addList[0].unitItems, achievement.addList[0].deletUnitItems);
  1621. }
  1622. console.log(13);
  1623. if (String($scope.requestModel.data) == '') {
  1624. saveCompanySpecialty();
  1625. } else {
  1626. dataToolsService.insertOrUpdateCompanyResearchfinding($scope.requestModel).then(function (response) {
  1627. console.log(response);
  1628. feedbackItem.achievement = response.data;
  1629. // 13保存特色专业信息表
  1630. saveCompanySpecialty();
  1631. }, function () {
  1632. if ($scope.app) {
  1633. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1634. } else {
  1635. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1636. }
  1637. })
  1638. }
  1639. };
  1640. // 13保存特色专业信息表
  1641. var saveCompanySpecialty = function () {
  1642. // 保存多条信息需要的格式
  1643. $scope.requestModel = {
  1644. data: [],
  1645. node: $stateParams.node,
  1646. pagecode: $stateParams.pagecode,
  1647. };
  1648. // 保存特色专业信息
  1649. var specialty = $scope.tempData.filter(function (val, i, arr) {
  1650. return val.title == '特色专业信息';
  1651. })[0];
  1652. if (specialty) {
  1653. $scope.requestModel.data = handleArray(specialty.addList[0].unitItems, specialty.addList[0].deletUnitItems);
  1654. }
  1655. console.log(14);
  1656. if (String($scope.requestModel.data) == '') {
  1657. savebusinessCircumstance();
  1658. } else {
  1659. dataToolsService.insertOrUpdateCompanySpecialty($scope.requestModel).then(function (response) {
  1660. // console.log(response);
  1661. // 14保存实验室信息表
  1662. savebusinessCircumstance();
  1663. }, function () {
  1664. if ($scope.app) {
  1665. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1666. } else {
  1667. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1668. }
  1669. })
  1670. }
  1671. };
  1672. // 14保存经营情况
  1673. var savebusinessCircumstance = function () {
  1674. // 保存多条信息需要的格式
  1675. $scope.requestModel = {
  1676. data: [],
  1677. node: $stateParams.node,
  1678. pagecode: $stateParams.pagecode,
  1679. };
  1680. if (basicOperate) {
  1681. $scope.requestModel.data = handleArray(basicOperate.addList[0].unitItems, basicOperate.addList[0].deletUnitItems);
  1682. }
  1683. console.log(15);
  1684. if (String($scope.requestModel.data) == '') {
  1685. saveHR();
  1686. } else {
  1687. dataToolsService.insertOrUpdateCompanyYearMultipleoptions($scope.requestModel).then(function (response) {
  1688. // console.log(response);
  1689. // 10保存公司产品
  1690. saveHR();
  1691. }, function () {
  1692. if ($scope.app) {
  1693. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1694. } else {
  1695. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1696. }
  1697. })
  1698. }
  1699. };
  1700. // 15保存人力资源
  1701. var saveHR = function () {
  1702. // 保存多条信息需要的格式
  1703. $scope.requestModel = {
  1704. data: [],
  1705. node: $stateParams.node,
  1706. pagecode: $stateParams.pagecode,
  1707. };
  1708. var tempArr = $scope.tempData.filter(function (value, j, arr) {
  1709. return value.title == '人力资源'
  1710. })[0];
  1711. if (tempArr) {
  1712. $scope.requestModel.data = handleArray([tempArr.detailList], 'other');
  1713. }
  1714. console.log(16);
  1715. // console.log($scope.requestModel.data);
  1716. // console.log(String($scope.requestModel.data));
  1717. if (String($scope.requestModel.data) == '') {
  1718. saveProjectTransformation();
  1719. } else {
  1720. // console.log($scope.requestModel);
  1721. dataToolsService.insertOrUpdateCompanyHR($scope.requestModel).then(function (response) {
  1722. // console.log(response);
  1723. // 10保存公司产品
  1724. saveProjectTransformation();
  1725. }, function () {
  1726. if ($scope.app) {
  1727. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1728. } else {
  1729. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1730. }
  1731. })
  1732. }
  1733. };
  1734. // 保存促成成果转化项目信息
  1735. var saveProjectTransformation = function () {
  1736. $scope.requestModel = {
  1737. data: [],
  1738. node: $stateParams.node,
  1739. pagecode: $stateParams.pagecode,
  1740. };
  1741. // var projectTransformation=$scope.tempData.filter(function(val,i,arr){
  1742. // return val.title=='促成成果转化项目';
  1743. // })[0];
  1744. if (projectTransformation) {
  1745. $scope.requestModel.data = handleArray(projectTransformation.addList[0].unitItems, projectTransformation.addList[0].deletUnitItems);
  1746. }
  1747. if (String($scope.requestModel.data) == '') {
  1748. saveOtherinformation();
  1749. } else {
  1750. console.log($scope.requestModel);
  1751. dataToolsService.insertOrUpdateProjectTransformation($scope.requestModel).then(function (response) {
  1752. // console.log(response);
  1753. saveOtherinformation();
  1754. }, function () {
  1755. if ($scope.app) {
  1756. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1757. } else {
  1758. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1759. }
  1760. })
  1761. }
  1762. }
  1763. // 保存其他信息
  1764. var saveOtherinformation = function () {
  1765. $scope.requestModel = {
  1766. data: [],
  1767. node: $stateParams.node,
  1768. pagecode: $stateParams.pagecode,
  1769. };
  1770. console.log($scope.tempData)
  1771. var Otherinformation = $scope.tempData.filter(function (val, i, arr) {
  1772. return val.title == '其他信息';
  1773. })[0];
  1774. console.log(Otherinformation)
  1775. if (Otherinformation) {
  1776. if (Otherinformation.detailList.length > 0) {
  1777. $scope.requestModel.data = handleArray([Otherinformation.detailList], Otherinformation.detailList[0].deletUnitItems);
  1778. }
  1779. }
  1780. console.log("333", Otherinformation)
  1781. if (String($scope.requestModel.data) == '') {
  1782. saveCompanyLab();
  1783. } else {
  1784. console.log("444", $scope.requestModel);
  1785. dataToolsService.saveOtherinformationapi($scope.requestModel).then(function (response) {
  1786. console.log(response);
  1787. saveCompanyLab();
  1788. }, function () {
  1789. if ($scope.app) {
  1790. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1791. } else {
  1792. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1793. }
  1794. })
  1795. }
  1796. }
  1797. // 16保存实验室信息表
  1798. var saveCompanyLab = function () {
  1799. var pagetitle = $stateParams.pageTitle;
  1800. // 保存多条信息需要的格式
  1801. $scope.requestModel = {
  1802. data: [],
  1803. node: $stateParams.node,
  1804. pagecode: $stateParams.pagecode,
  1805. };
  1806. // 保存实验室信息表
  1807. var labInfo = $scope.tempData.filter(function (val, i, arr) {
  1808. return val.title == '实验室信息';
  1809. })[0];
  1810. if (labInfo) {
  1811. $scope.requestModel.data = handleArray(labInfo.addList[0].unitItems, labInfo.addList[0].deletUnitItems);
  1812. }
  1813. console.log(17);
  1814. if (String($scope.requestModel.data) == '') {
  1815. var patt = /录入/g;
  1816. if ($scope.pageTitle != "新建录入" && patt.test($scope.pageTitle)) {
  1817. // $scope.go("recordInfoAccount");
  1818. $scope.hideLoadingToast();
  1819. if ($stateParams.comfrom == 'activityApply' || $stateParams.comfrom == 'participantList') {
  1820. localStorage.feedbackItem = JSON.stringify(feedbackItem);
  1821. $scope.go('activityApply', {
  1822. settingItems: localStorage.settingItems,
  1823. comfrom: $stateParams.comfrom
  1824. });
  1825. // }if($stateParams.comfrom=='activityDetail'){
  1826. // var params={
  1827. // data:{
  1828. // "activityid":$stateParams.companyid,
  1829. // "otherid":$scope.connid,
  1830. // "creator":UserService.id
  1831. // }
  1832. // }
  1833. // dataToolsService.saveActivityBroadcastInfo(params).then(function(res){
  1834. // $scope.go('activityApply',{activityid:$stateParams.companyid});
  1835. // });
  1836. } else {
  1837. $scope.go("recordInfoAccount");
  1838. }
  1839. } else {
  1840. var getBasicInfo = function () {
  1841. var def = $q.defer();
  1842. dataToolsService.getConnectioninfoDetailByConnid($scope.connid, 1000002, 0, $stateParams.node).then(function (response) {
  1843. if (response.code == 3350) {
  1844. def.resolve(response.data);
  1845. } else {
  1846. def.reject('错误');
  1847. }
  1848. }, function () {
  1849. });
  1850. return def.promise;
  1851. };
  1852. getBasicInfo().then(function (data) {
  1853. dataToolsService.getConnectionOtherInfoDetail($scope.connid, 1000002, 0, $stateParams.node).then(function (res) {
  1854. $scope.hideLoadingToast();
  1855. if (data.typecodemap || res.data.typecodemap) {
  1856. localStorage.feedbackItem = JSON.stringify(feedbackItem);
  1857. data.typecodemap = data.typecodemap ? Object.assign(data.typecodemap, res.data.typecodemap) : res.data.typecodemap;
  1858. if (pagetitle != "新建导师" && pagetitle != "新建创新创业联盟库") {
  1859. // $scope.go("selectFieldsToSet", {
  1860. // comfrom: $stateParams.comfrom,
  1861. // typecodemap: data.typecodemap,
  1862. // resid: $stateParams.resid,
  1863. // typecode: ConstantService.TABLE_CODE_30003,
  1864. // templettype: $stateParams.templettype,
  1865. // title: $stateParams.title,
  1866. // node: $stateParams.node,
  1867. // pagetitle: $stateParams.pageTitle,
  1868. // });
  1869. $ionicHistory.goBack(-1)
  1870. } else {
  1871. if (pagetitle == "新建导师") {
  1872. $scope.go('wujingTeacher');
  1873. }
  1874. if (pagetitle == "新建创新创业联盟库") {
  1875. $scope.go('wujingTechnical');
  1876. }
  1877. }
  1878. }
  1879. })
  1880. })
  1881. }
  1882. } else {
  1883. dataToolsService.insertOrUpdateCompanyLab($scope.requestModel).then(function (response) {
  1884. // 添加成功后先查询保存的走访履历,再把typecodemap传递并跳转到 设置权限 界面
  1885. // 获取走访履历详情
  1886. if ($scope.app) {
  1887. UtilService.showMess("添加成功");
  1888. } else {
  1889. CommonService.showMessage("添加成功", $scope);
  1890. }
  1891. // $timeout(function () {
  1892. var patt = /录入/g;
  1893. if (patt.test($scope.pageTitle)) {
  1894. $scope.hideLoadingToast();
  1895. if ($stateParams.comfrom == 'activityApply' || $stateParams.comfrom == 'participantList') {
  1896. localStorage.feedbackItem = JSON.stringify(feedbackItem);
  1897. $scope.go('activityApply', {
  1898. settingItems: localStorage.settingItems,
  1899. comfrom: $stateParams.comfrom
  1900. });
  1901. } else {
  1902. $scope.go("recordInfoAccount");
  1903. }
  1904. } else {
  1905. var getBasicInfo = function () {
  1906. var def = $q.defer();
  1907. dataToolsService.getConnectioninfoDetailByConnid($scope.connid, 1000002, 0, $stateParams.node).then(function (response) {
  1908. if (response.code == 3350) {
  1909. def.resolve(response.data);
  1910. } else {
  1911. def.reject('错误');
  1912. }
  1913. }, function () {
  1914. })
  1915. return def.promise;
  1916. };
  1917. getBasicInfo().then(function (data) {
  1918. dataToolsService.getConnectionOtherInfoDetail($scope.connid, 1000002, 0, $stateParams.node).then(function (res) {
  1919. $scope.hideLoadingToast();
  1920. if (data.typecodemap || res.data.typecodemap) {
  1921. data.typecodemap = data.typecodemap ? Object.assign(data.typecodemap, res.data.typecodemap) : res.data.typecodemap;
  1922. $scope.go("selectFieldsToSet", {
  1923. comfrom: $stateParams.comfrom,
  1924. typecodemap: data.typecodemap,
  1925. resid: $stateParams.resid,
  1926. typecode: ConstantService.TABLE_CODE_30003,
  1927. templettype: $stateParams.templettype,
  1928. title: $stateParams.title,
  1929. node: $stateParams.node,
  1930. pagetitle: $stateParams.pageTitle,
  1931. });
  1932. }
  1933. })
  1934. })
  1935. }
  1936. // console.log($scope.connEnterpriseModuleModel.id);
  1937. // console.log(15);
  1938. // dataToolsService.getConnectioninfoDetailByConnid($scope.connEnterpriseModuleModel.id,$stateParams.pagecode,0,$stateParams.node).then(function (response) {
  1939. // // console.log("==============================");
  1940. // // console.log(response);
  1941. // $scope.hideLoadingToast();
  1942. // // 走访履历详情
  1943. // $scope.connInfoDetail = response.data;
  1944. // $timeout(function () {
  1945. // gotoSelectFieldsToSet();
  1946. // }, 500);
  1947. // }, 500);
  1948. // }, function () {
  1949. // })
  1950. }, function () {
  1951. if ($scope.app) {
  1952. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  1953. } else {
  1954. CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope);
  1955. }
  1956. })
  1957. }
  1958. };
  1959. }
  1960. ).directive('stringToNumber', function () {
  1961. return {
  1962. require: 'ngModel',
  1963. link: function (scope, element, attrs, ngModel) {
  1964. ngModel.$parsers.push(function (value) {
  1965. return '' + value;
  1966. });
  1967. ngModel.$formatters.push(function (value) {
  1968. return parseInt(value);
  1969. });
  1970. }
  1971. };
  1972. }).directive('stringToNumber2', function () {
  1973. return {
  1974. require: 'ngModel',
  1975. link: function (scope, element, attrs, ngModel) {
  1976. ngModel.$parsers.push(function (value) {
  1977. return '' + value;
  1978. });
  1979. ngModel.$formatters.push(function (value) {
  1980. return parseInt(value);
  1981. });
  1982. }
  1983. };
  1984. });