visitModularFormCtrl.js 107 KB

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