unitOrPersonalBaseInfoCtrl.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. angular.module('push')
  2. .controller('unitOrPersonalBaseInfoCtrl', function ($scope,$stateParams,$timeout,$ionicActionSheet,$ionicScrollDelegate,
  3. UtilService,dataToolsService,ConstantService,UserService) {
  4. //默认选择类型为企业
  5. $scope.selectBaseInfoStyle='企业';
  6. $scope.isTapChange=true;
  7. // 获取走访录入界面的传参
  8. $scope.rolePageModel=
  9. {
  10. //TODO
  11. id: $stateParams.pageid,// 模版id
  12. orgtype: ConstantService.UNITTYPE_10104// 走访对应的机构类型
  13. // id: 2,// 模版id
  14. // orgtype: 2,// 模版id
  15. };
  16. // 对应的是0新增/1编辑
  17. $scope.isedit = $stateParams.isedit;
  18. if($scope.isedit == 0){
  19. $scope.pagetitle = "录入信息";
  20. }else
  21. if($scope.isedit == 1){
  22. $scope.pagetitle = "编辑信息";
  23. $timeout(function () {
  24. $("#orgname").prop("disabled", true);
  25. },300);
  26. if($stateParams.pageid == 9){
  27. $scope.selectBaseInfoStyle='高校';
  28. $scope.isTapChange=true;
  29. $scope.rolePageModel.id = $stateParams.pageid;// 模版id
  30. $scope.rolePageModel.orgtype = ConstantService.UNITTYPE_10105;
  31. }
  32. }else
  33. // 复制并新建
  34. if($scope.isedit == 2){
  35. $scope.pagetitle = "复制并新建信息";
  36. $timeout(function () {
  37. $("#orgname").prop("disabled", true);
  38. },300);
  39. if($stateParams.pageid == 9){
  40. $scope.selectBaseInfoStyle='高校';
  41. $scope.isTapChange=true;
  42. $scope.rolePageModel.id = $stateParams.pageid;// 模版id
  43. $scope.rolePageModel.orgtype = ConstantService.UNITTYPE_10105;
  44. }
  45. }
  46. $scope.changeInfoStyle=function () {
  47. $scope.isTapChange=! $scope.isTapChange;
  48. // 选取身份证弹框
  49. $ionicActionSheet.show({
  50. buttons: [
  51. {text: '<a class="action-sheet-push">企业</a>'},
  52. {text: '<a class="action-sheet-push">高校</a>'}
  53. ],
  54. cancelText: '取消',
  55. buttonClicked: function (index) {
  56. switch (index){
  57. case 0:
  58. $scope.selectBaseInfoStyle='企业';
  59. $scope.isTapChange=true;
  60. $scope.rolePageModel.id = $stateParams.pageid;// 模版id
  61. console.log($stateParams.pageid);
  62. $scope.rolePageModel.orgtype = ConstantService.UNITTYPE_10104;
  63. break;
  64. case 1:
  65. $scope.selectBaseInfoStyle='高校';
  66. $scope.isTapChange=true;
  67. $scope.rolePageModel.id = 9;// 模版id
  68. $scope.rolePageModel.orgtype = ConstantService.UNITTYPE_10105;
  69. break;
  70. default:
  71. return;
  72. }
  73. return true;
  74. }
  75. });
  76. };
  77. //企业基本信息
  78. $scope.connEnterpriseModuleModel = {
  79. id: 0,
  80. userid: 0,
  81. usercomefrom: "",
  82. claid: 0,// 选中的文件夹id
  83. taskid: 0,// 任务id
  84. yearsetupid: 0,
  85. yearsetupname: "",
  86. templettype: $stateParams.pageid,// 模板id
  87. orgname: "",
  88. orglogo: "",// 企业logo
  89. orgtype: ConstantService.UNITTYPE_10104,//机构类型:默认企业
  90. orgcontent: "",// 企业简介
  91. orgcontact: "",
  92. orgcontactnum: "",
  93. categoryid: "",
  94. categoryname: "",
  95. orggradecode: 0,// 企业研发机构等级
  96. rdinstitutiontypename: "",// 企业研发机构等级名称
  97. ishigh: 0,// 是否高企
  98. high:true,
  99. ishighInfo:"是",
  100. remark: "",// 备注
  101. images: "",// 传到后台的图片json
  102. delimages: "",// 删除的图片
  103. imagelist: [],// app端图片插件进行传递的变量
  104. userModel: {
  105. userid: 0 // 用户id
  106. },
  107. organizationInfo: {
  108. id: 0,
  109. orgtype: ConstantService.UNITTYPE_10104,//机构类型
  110. name: "",
  111. about: "",// 机构简介
  112. contact: "",
  113. contactnum: "",
  114. categoryid: "",
  115. categoryname: "",
  116. rdinstitutiontype: 0,// 企业研发机构等级
  117. rdinstitutiontypename: "",// 企业研发机构等级
  118. ishigh: 0,// 是否高企
  119. logo: "",// 企业logo
  120. high:true,
  121. ishighInfo:"是",
  122. images: "",// 传到后台的图片json
  123. delimages: "",// 删除的图片
  124. imagelist: []// app端图片插件进行传递的变量
  125. },
  126. organizationInfoJson:''
  127. };
  128. $scope.imagelist = [];
  129. $scope.delimagelist = [];//删除的图片
  130. $scope.sourceimagelist = [];//复制时存储的图片
  131. // 保存基本信息需要的格式
  132. $scope.requestModel = {
  133. data: {},
  134. node: ""
  135. };
  136. //选择研发机构等级
  137. var buttonsResearchStatus = [
  138. { text: "国家级",
  139. ResearchStatusName:"国家级",
  140. ResearchStatusId: "10201"
  141. },
  142. { text: "省级",
  143. ResearchStatusName:"省级",
  144. ResearchStatusId: "10202"
  145. },
  146. { text: "市级",
  147. ResearchStatusName:"市级",
  148. ResearchStatusId: "10203"
  149. },
  150. { text: "区级",
  151. ResearchStatusName:"区级",
  152. ResearchStatusId: "10204"
  153. }
  154. ];
  155. //选择产业领域
  156. var buttonsIndustryStatus = [
  157. {text: "汽车制造",
  158. stausName:"汽车制造",
  159. stausId: "A"
  160. },
  161. {text: "能源及节能技术",
  162. stausName:"能源及节能技术",
  163. stausId: "B"
  164. },
  165. {text: "新材料",
  166. stausName:"新材料",
  167. stausId: "C"
  168. },
  169. {text: "生物与新医药",
  170. stausName:"生物与新医药",
  171. stausId: "D"
  172. },
  173. {text: "电子信息",
  174. stausName:"电子信息",
  175. stausId: "E"
  176. },
  177. {text: "先进制造及高端装备",
  178. stausName:"先进制造及高端装备",
  179. stausId: "F"
  180. },
  181. {text: "资源及环境技术",
  182. stausName:"资源及环境技术",
  183. stausId: "G"
  184. }
  185. ];
  186. // 清空列表中的id,置为0
  187. var clearIdinList = function (datalist) {
  188. if(UtilService.isDefined(datalist) && datalist.length > 0){
  189. angular.forEach(datalist, function (value, index) {
  190. value.id = 0;
  191. });
  192. }
  193. }
  194. // 编辑时获取走访详情
  195. var getPublicResourceList = function () {
  196. //TODO
  197. $scope.connid = $stateParams.connid;
  198. // $scope.connid = 179;
  199. dataToolsService.getConnectioninfoDetailByConnid($scope.connid).then(function (response) {
  200. console.log("============编辑时获取走访详情==================");
  201. console.log(response);
  202. // 基本信息
  203. $scope.connEnterpriseModuleModel = response.data;
  204. if($scope.connEnterpriseModuleModel.ishigh==1){
  205. $scope.connEnterpriseModuleModel.ishighInfo="是";
  206. $scope.connEnterpriseModuleModel.high=true;
  207. }else if($scope.connEnterpriseModuleModel.ishigh==0){
  208. $scope.connEnterpriseModuleModel.ishighInfo="否";
  209. $scope.connEnterpriseModuleModel.high=false;
  210. }
  211. $scope.imagelist = response.data.imagelist;
  212. // 复制并新增时,清空所有的id
  213. if($scope.isedit == 2){
  214. $scope.connEnterpriseModuleModel.id = 0;
  215. }
  216. }, function () {
  217. });
  218. };
  219. // 编辑时才获取
  220. if($scope.isedit == 1){
  221. getPublicResourceList();
  222. }else
  223. if($scope.isedit == 0){
  224. // 新增时 默认模版id
  225. $scope.connEnterpriseModuleModel.templettype = $stateParams.pageid;
  226. }else
  227. if($scope.isedit == 2){
  228. // 复制并新增时 默认模版id
  229. getPublicResourceList();
  230. }
  231. // 获取高校等级
  232. var schtagbuttons = [];
  233. var getSchtagList = function () {
  234. dataToolsService.getTypeEntryListByTypeName("schtag").then(function (response) {
  235. if (UtilService.isDefined(response.data) && response.data.length > 0) {
  236. angular.forEach(response.data, function (value, index) {
  237. var temphtml = {
  238. text: '<a class="action-sheet-push">' + value.itemkey + '</a>',
  239. rdinstitutiontype: value.itemvalue,
  240. rdinstitutiontypename: value.itemkey
  241. };
  242. schtagbuttons.push(temphtml);
  243. });
  244. console.log("schtagbuttons:");
  245. console.log(schtagbuttons);
  246. }
  247. }, function () {
  248. })
  249. };
  250. getSchtagList();
  251. //切换选择是否高企
  252. $scope.watchIsChange=function () {
  253. if($scope.connEnterpriseModuleModel.high==true){
  254. $scope.connEnterpriseModuleModel.ishighInfo="是";
  255. $scope.connEnterpriseModuleModel.ishigh=1;
  256. }else{
  257. $scope.connEnterpriseModuleModel.ishighInfo="否";
  258. $scope.connEnterpriseModuleModel.ishigh=0;
  259. }
  260. };
  261. // 弹出获取企业logo
  262. $scope.show_logo = function () {
  263. $ionicActionSheet.show({
  264. cancelOnStateChange: true,
  265. cssClass: 'action_s',
  266. cancelText: '取消',
  267. buttons: [
  268. {text: "拍照"},
  269. {text: "从相册上传"}
  270. ],
  271. buttonClicked: function (index) {
  272. if (index == 0) {
  273. openCamera(1,1);
  274. } else {
  275. openCamera(0,1);
  276. }
  277. return true;
  278. },
  279. destructiveButtonClicked: function () {
  280. return true;
  281. }
  282. });
  283. };
  284. //获取设备相机
  285. var openCamera = function (srcType) {
  286. var options = {
  287. // Some common settings are 20, 50, and 100
  288. quality: 50,
  289. destinationType: Camera.DestinationType.FILE_URI,
  290. // In this app, dynamically set the picture source, Camera or photo gallery
  291. sourceType: srcType,
  292. encodingType: Camera.EncodingType.JPEG,
  293. mediaType: Camera.MediaType.PICTURE,
  294. allowEdit: false,
  295. correctOrientation: true //Corrects Android orientation quirks
  296. };
  297. navigator.camera.getPicture(function (imageData) {
  298. $scope.imgurl = imageData;
  299. $scope.showLoadingToast();
  300. UtilService.uploadFile([imageData], 0, "image/jpeg").then(function (response) {
  301. // 企业logo
  302. $scope.connEnterpriseModuleModel.orglogo = response[0].photoName;
  303. $scope.hideLoadingToast();
  304. }, function () {
  305. $scope.hideLoadingToast();
  306. });
  307. }, function (message) {
  308. }, options);
  309. };
  310. // ****** 单信息图片 ******
  311. $scope.openCamera = function () {
  312. if ($scope.imagelist.length >= 9) {
  313. UtilService.showMess("最多选取9张图片");
  314. return;
  315. }
  316. UtilService.getPicture(1).then(function (results) {
  317. // console.log(results);
  318. $scope.imagelist.push({photoName: results, originalName: results});
  319. $scope.totalImglength = 600 * $scope.imagelist.length;
  320. $ionicScrollDelegate.$getByHandle("scrollimage").resize();
  321. }, function (err) {
  322. });
  323. };
  324. $scope.show = function () {
  325. $ionicActionSheet.show({
  326. buttons: [
  327. {text: '<a class="action-sheet-push">相册中添加照片</a>'},
  328. {text: '<a class="action-sheet-push">拍照</a>'}
  329. ],
  330. cancelText: '取消',
  331. buttonClicked: function (index) {
  332. if (index == 0) {
  333. getPictures();
  334. } else if (index == 1) {
  335. $scope.openCamera();
  336. }
  337. return true;
  338. }
  339. });
  340. };
  341. var verifyStorage = function () {
  342. window.imagePicker.verifyStorage(
  343. function (results) {
  344. if (results == "1") {
  345. getPic();
  346. }
  347. }, function (error) {
  348. }
  349. );
  350. };
  351. var getPic = function () {
  352. if ($scope.imagelist.length >= 9) {
  353. UtilService.showMess("最多选取9张图片");
  354. return;
  355. }
  356. UtilService.getPictureList(9 - $scope.imagelist.length).then(function (results) {
  357. // console.log(results);
  358. angular.forEach(results, function (value, index) {
  359. $scope.imagelist.push({photoName: value, originalName: value})
  360. });
  361. $scope.totalImglength = 600 * $scope.imagelist.length;
  362. $ionicScrollDelegate.$getByHandle("scrollimage").resize();
  363. }, function (err) {
  364. });
  365. };
  366. var getPictures = function () {
  367. if (device.platform == "Android") {
  368. verifyStorage();
  369. } else {
  370. getPic();
  371. }
  372. };
  373. //点击图片放大
  374. $scope.bigImage = false; //初始默认大图是隐藏的
  375. $scope.hideBigImage = function () {
  376. if($scope.app){
  377. $scope.setStatusBar(0);
  378. }
  379. $timeout(function () {
  380. $scope.bigImage = false;
  381. }, 400);
  382. };
  383. $scope.shouBigImage = function (index) { //传递一个参数(图片的URl)
  384. if($scope.app){
  385. $scope.setStatusBar(1);
  386. }
  387. $(function () {
  388. $('div.pinch-zoom').each(function () {
  389. new RTP.PinchZoom($(this), {});
  390. });
  391. });
  392. $scope.bigImage = true;//显示大图
  393. $ionicSlideBoxDelegate.update();//重绘,让图片显示出来
  394. //图片总数量
  395. setTimeout(function () {
  396. $ionicSlideBoxDelegate.$getByHandle('slide_detail').slide(index, -10);
  397. //获取图片
  398. var imgObj = document.getElementsByClassName('bigimage');
  399. var n;
  400. for (n = 0; n < imgObj.length; n++) {
  401. // 获取图片的原始高度和宽度
  402. var oldWid = imgObj[n].naturalWidth;
  403. var oldHei = imgObj[n].naturalHeight;
  404. var screen = document.body.offsetWidth;
  405. var screenH = window.innerHeight;
  406. // console.log(oldWid / oldHei);
  407. // console.log(screen);
  408. var cc = screen / (oldWid / oldHei);
  409. imgObj[n].style.height = cc + 'px';
  410. if (cc < screenH) {
  411. imgObj[n].style.marginTop = (screenH - cc) / 2 + 'px';
  412. // console.log("e:"+imgObj[n].style.marginTop);
  413. } else {
  414. imgObj[n].style.marginTop = 0 + 'px';
  415. // console.log((cc-screenH) +'px')
  416. }
  417. }
  418. }, 10);
  419. };
  420. //删除图片
  421. $scope.deletePhoto = function (index) {
  422. if ($scope.imagelist[index].id != 0) {
  423. // 将删除的加入删除列表,再从图片数组里删除
  424. $scope.imagelist[index].isenabled = 2;//若删除,则置为不可用,调用通用update
  425. $scope.delimagelist.push($scope.imagelist[index]);
  426. $scope.imagelist.splice(index, 1);
  427. }else{
  428. $scope.imagelist.splice(index, 1);
  429. }
  430. };
  431. //关联相关企业
  432. $scope.isRelateUl = false;
  433. $scope.queryLikeName = function () {
  434. if ($scope.connEnterpriseModuleModel.orgname.length == 0) {
  435. $scope.companylist = [];
  436. $scope.isRelateUl = false;
  437. return;
  438. }
  439. // 全部置空
  440. $scope.connEnterpriseModuleModel.organizationInfo.id = 0;
  441. $scope.connEnterpriseModuleModel.orglogo = "";
  442. $scope.connEnterpriseModuleModel.orgcontact = "";
  443. $scope.connEnterpriseModuleModel.orgcontactnum = "";
  444. $scope.connEnterpriseModuleModel.categoryid = 0;
  445. $scope.connEnterpriseModuleModel.categoryname = "";
  446. $scope.connEnterpriseModuleModel.orggradecode = 0;
  447. $scope.connEnterpriseModuleModel.rdinstitutiontypename = "";
  448. $scope.connEnterpriseModuleModel.ishigh = 0;
  449. $scope.connEnterpriseModuleModel.ishighInfo="否";
  450. $scope.connEnterpriseModuleModel.high=false;
  451. $scope.connEnterpriseModuleModel.remark="";
  452. dataToolsService.getOrganizationModelByOrgname($scope.connEnterpriseModuleModel.orgname).then(function (response) {
  453. // console.log(response);
  454. $scope.companylist = response.data;
  455. $scope.isRelateUl = true;
  456. }, function () {
  457. })
  458. };
  459. //选中企业
  460. $scope.setCompanyName = function (organizationInfo) {
  461. //<b style='color:red;font-weight: normal;'>亚</b>
  462. organizationInfo.name = organizationInfo.name.replace("<b style='color:red;font-weight: normal;'>", "");
  463. organizationInfo.name = organizationInfo.name.replace("</b>", "");
  464. $scope.connEnterpriseModuleModel.organizationInfo.id = organizationInfo.id;
  465. $scope.connEnterpriseModuleModel.orgname = organizationInfo.name;
  466. $scope.connEnterpriseModuleModel.orglogo = organizationInfo.logo;
  467. $scope.connEnterpriseModuleModel.orgcontact = organizationInfo.contact;
  468. $scope.connEnterpriseModuleModel.orgcontactnum = organizationInfo.contactnum;
  469. $scope.connEnterpriseModuleModel.categoryid = organizationInfo.categoryid;
  470. $scope.connEnterpriseModuleModel.categoryname = organizationInfo.categoryname;
  471. $scope.connEnterpriseModuleModel.orggradecode = organizationInfo.rdinstitutiontype;
  472. $scope.connEnterpriseModuleModel.rdinstitutiontypename = organizationInfo.rdinstitutiontypename;
  473. $scope.connEnterpriseModuleModel.ishigh = organizationInfo.ishigh;
  474. if($scope.connEnterpriseModuleModel.ishigh==1){
  475. $scope.connEnterpriseModuleModel.ishighInfo="是";
  476. $scope.connEnterpriseModuleModel.high=true;
  477. }else if($scope.connEnterpriseModuleModel.ishigh==0){
  478. $scope.connEnterpriseModuleModel.ishighInfo="否";
  479. $scope.connEnterpriseModuleModel.high=false;
  480. }
  481. $scope.isRelateUl = false;
  482. };
  483. //获得研发机构等级
  484. $scope.showResearchStatus=function () {
  485. $ionicActionSheet.show({
  486. cancelOnStateChange: true,
  487. cssClass: 'action_s',
  488. cancelText: '取消',
  489. buttons: buttonsResearchStatus,
  490. buttonClicked: function (index) {
  491. $scope.connEnterpriseModuleModel.orggradecode = buttonsResearchStatus[index].ResearchStatusId;
  492. $scope.connEnterpriseModuleModel.rdinstitutiontypename = buttonsResearchStatus[index].ResearchStatusName;
  493. return true;
  494. },
  495. destructiveButtonClicked: function () {
  496. return true;
  497. }
  498. });
  499. };
  500. //获得产业领域
  501. $scope.showIndustryStatus=function () {
  502. $ionicActionSheet.show({
  503. cancelOnStateChange: true,
  504. cssClass: 'action_s',
  505. cancelText: '取消',
  506. buttons: buttonsIndustryStatus,
  507. buttonClicked: function (index) {
  508. $scope.connEnterpriseModuleModel.categoryid = buttonsIndustryStatus[index].stausId;
  509. $scope.connEnterpriseModuleModel.categoryname = buttonsIndustryStatus[index].stausName;
  510. return true;
  511. },
  512. destructiveButtonClicked: function () {
  513. return true;
  514. }
  515. });
  516. };
  517. //选择高校的高校等级
  518. $scope.showSchtag = function (ind) {
  519. $ionicActionSheet.show({
  520. buttons: schtagbuttons,
  521. cancelText: '取消',
  522. buttonClicked: function (index) {
  523. $scope.connEnterpriseModuleModel.orggradecode = schtagbuttons[index].rdinstitutiontype;
  524. $scope.connEnterpriseModuleModel.rdinstitutiontypename = schtagbuttons[index].rdinstitutiontypename;
  525. return true;
  526. }
  527. });
  528. };
  529. //获得专家研究领域
  530. $scope.showTalentStatus=function () {
  531. $ionicActionSheet.show({
  532. cancelOnStateChange: true,
  533. cssClass: 'action_s',
  534. cancelText: '取消',
  535. buttons: buttonsIndustryStatus,
  536. buttonClicked: function (index) {
  537. $scope.talentModuleModel.talent.categoryid = buttonsIndustryStatus[index].stausId;
  538. $scope.talentModuleModel.talent.responsible = buttonsIndustryStatus[index].stausName;
  539. return true;
  540. },
  541. destructiveButtonClicked: function () {
  542. return true;
  543. }
  544. });
  545. };
  546. var saveflg = 0;//只允许保存触发一次,多次触发无效,默认未提交
  547. var tempimages = [];
  548. //保存企业信息表
  549. $scope.saveCompanyInfo = function () {
  550. // 基本信息
  551. if (!UtilService.isDefined($scope.connEnterpriseModuleModel.orgname)) {
  552. UtilService.showMess("请填写企业名称");
  553. return;
  554. }
  555. if ($scope.connEnterpriseModuleModel.orgname.length > 50) {
  556. UtilService.showMess("企业名称不能超过50个字");
  557. return;
  558. }
  559. if (UtilService.isDefined($scope.connEnterpriseModuleModel.remark) && $scope.connEnterpriseModuleModel.remark.length > 1000) {
  560. UtilService.showMess("备注不能超过1000个字");
  561. return;
  562. }
  563. if (saveflg != 0) {
  564. return;
  565. }
  566. saveflg = 1;
  567. $scope.showLoadingToast();
  568. if ($scope.imagelist.length > 0) {
  569. uploadImages();
  570. } else {
  571. saveInfo();
  572. }
  573. };
  574. //保存高校信息表
  575. $scope.saveSchoolInfo = function () {
  576. // 基本信息
  577. if (!UtilService.isDefined($scope.connEnterpriseModuleModel.orgname)) {
  578. UtilService.showMess("请填写高校名称");
  579. return;
  580. }
  581. if ($scope.connEnterpriseModuleModel.orgname.length > 50) {
  582. UtilService.showMess("高校名称不能超过50个字");
  583. return;
  584. }
  585. if ($scope.connEnterpriseModuleModel.orgcontent.length > 200) {
  586. UtilService.showMess("高校简介不能超过100个字");
  587. return;
  588. }
  589. if (UtilService.isDefined($scope.connEnterpriseModuleModel.remark) && $scope.connEnterpriseModuleModel.remark.length > 1000) {
  590. UtilService.showMess("备注不能超过1000个字");
  591. return;
  592. }
  593. if (saveflg != 0) {
  594. return;
  595. }
  596. saveflg = 1;
  597. $scope.showLoadingToast();
  598. saveSchoolInfo();
  599. };
  600. var uploadImages = function () {
  601. tempimages = [];
  602. var upimages = [];
  603. angular.forEach($scope.imagelist, function (data) {
  604. upimages.push(data.photoName);
  605. // 复制时,将不上传的另外保存,需保存至数据库
  606. if($scope.isedit == 2 && UtilService.isDefined(data.id)){
  607. $scope.sourceimagelist.push(data);
  608. }
  609. });
  610. UtilService.uploadFile(upimages, 0, "image/jpeg").then(function (response) {
  611. // console.log(response);
  612. angular.forEach(response, function (value) {
  613. if (value.status) {
  614. tempimages.push({
  615. id: 0,
  616. title: "",
  617. doctype: value.doctype,//文档类型 1图片,2文件,3pdf,4xls
  618. isenabled: 1,//是否可用:0-不可用,1-可用,2-已停用
  619. photoName: value.photoName,
  620. originalName: value.originalName,
  621. sourceName: value.sourceName,
  622. sourceSize: value.sourceSize
  623. });
  624. }
  625. });
  626. $timeout(function () {
  627. saveInfo();
  628. }, 100);
  629. }, function () {
  630. $scope.hideLoadingToast();
  631. UtilService.showMess("网络不给力,请重试");
  632. saveflg = 0;
  633. });
  634. };
  635. // 保存企业信息
  636. var saveInfo = function () {
  637. // 企业图片
  638. // 将删除的一起提交
  639. if($scope.delimagelist.length > 0) {
  640. angular.forEach($scope.delimagelist, function (val, ind) {
  641. tempimages.push(val);
  642. });
  643. }
  644. // 将复制时临时保存的一起提交
  645. if($scope.sourceimagelist.length > 0){
  646. angular.forEach($scope.sourceimagelist, function (val, ind) {
  647. tempimages.push(val);
  648. });
  649. }
  650. $scope.connEnterpriseModuleModel.images = JSON.stringify(tempimages);
  651. // 保存走访基本信息
  652. $scope.connEnterpriseModuleModel.userModel.userid = UserService.id;
  653. // 走访履历表中需记录机构信息
  654. $scope.connEnterpriseModuleModel.organizationInfo.name = $scope.connEnterpriseModuleModel.orgname;
  655. $scope.connEnterpriseModuleModel.title = $scope.connEnterpriseModuleModel.organizationInfo.name;
  656. $scope.connEnterpriseModuleModel.templettype = $scope.rolePageModel.id;
  657. $scope.connEnterpriseModuleModel.organizationInfo.logo = $scope.connEnterpriseModuleModel.orglogo;// 企业logo
  658. $scope.connEnterpriseModuleModel.organizationInfo.about = $scope.connEnterpriseModuleModel.orgcontent;// 企业logo
  659. $scope.connEnterpriseModuleModel.orgtype = $scope.rolePageModel.orgtype;// 机构类型
  660. $scope.connEnterpriseModuleModel.organizationInfo.orgtype = $scope.rolePageModel.orgtype;// 机构类型
  661. $scope.connEnterpriseModuleModel.organizationInfo.contact = $scope.connEnterpriseModuleModel.orgcontact;
  662. $scope.connEnterpriseModuleModel.organizationInfo.contactnum = $scope.connEnterpriseModuleModel.orgcontactnum;
  663. $scope.connEnterpriseModuleModel.organizationInfo.categoryid = $scope.connEnterpriseModuleModel.categoryid;
  664. $scope.connEnterpriseModuleModel.organizationInfo.categoryname = $scope.connEnterpriseModuleModel.categoryname;
  665. $scope.connEnterpriseModuleModel.organizationInfo.rdinstitutiontype = $scope.connEnterpriseModuleModel.orggradecode;// 企业研发机构等级
  666. $scope.connEnterpriseModuleModel.organizationInfo.ishigh = $scope.connEnterpriseModuleModel.ishigh;// 是否高企
  667. // 传参格式
  668. $scope.requestModel.data = $scope.connEnterpriseModuleModel;
  669. $scope.requestModel.node = UserService.node;
  670. dataToolsService.saveOrganizationInfo($scope.requestModel).then(function (response) {
  671. console.log(response);
  672. if(response.code == ConstantService.INTERFACE_STATUS_CODE_3350){
  673. UtilService.showMess("添加成功");
  674. $timeout(function () {
  675. // 保存走访基本信息 后保存其他内容
  676. // 取得记录id
  677. var connid = response.data.id;
  678. $scope.connEnterpriseModuleModel.id = connid;
  679. // 取得机构id
  680. var orgid = response.data.organizationInfo.id;
  681. $scope.connEnterpriseModuleModel.organizationInfo.id = orgid;
  682. // $scope.goback();
  683. // 添加成功后跳入我的录入
  684. $scope.go("recordInfoAccount");
  685. }, 500);
  686. } else {
  687. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  688. }
  689. $scope.hideLoadingToast();
  690. saveflg = 0;
  691. }, function () {
  692. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  693. $scope.hideLoadingToast();
  694. saveflg = 0;
  695. });
  696. };
  697. //进入资源详情
  698. $scope.jumpResourceDetail = function (company) {
  699. // 先预设信息
  700. $scope.setCompanyName(company);
  701. // 再跳转到资源详情页
  702. $scope.go('resourceCommonDetailsPage', {
  703. recourceid: company.resourcelibrary.id,
  704. recourcetype: company.resourcelibrary.restype,
  705. recourcecomefrom: company.resourcelibrary.comefrom,
  706. creator: company.resourcelibrary.creator
  707. });
  708. };
  709. });