visitModularFormDemandCtrl.js 90 KB

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