recordTalentInfoCtrl.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. angular.module('push')
  2. .controller('recordTalentInfoCtrl', function ($scope,$stateParams,dataToolsService,UtilService,ConstantService, $timeout,
  3. $ionicActionSheet,UserService) {
  4. // 对应的是0新增/1编辑
  5. $scope.isedit = $stateParams.isedit;
  6. if($scope.isedit == 0){
  7. $scope.pagetitle = "录入人才信息";
  8. }else
  9. if($scope.isedit == 1){
  10. $scope.pagetitle = "编辑人才信息";
  11. $timeout(function () {
  12. $("#orgname").prop("disabled", true);
  13. },300);
  14. }else
  15. // 复制并新建
  16. if($scope.isedit == 2){
  17. $scope.pagetitle = "复制并新建人才信息";
  18. $timeout(function () {
  19. $("#orgname").prop("disabled", true);
  20. },300);
  21. }
  22. //企业基本信息
  23. $scope.connEnterpriseModuleModel = {
  24. id: 0,
  25. userid: 0,
  26. usercomefrom: "",
  27. claid: 0,// 选中的文件夹id
  28. taskid: 0,// 任务id
  29. yearsetupid: 0,
  30. yearsetupname: "",
  31. templettype: $stateParams.pageid,// 模板id
  32. orgname: "",
  33. orglogo: "",// 企业logo
  34. orgtype: ConstantService.UNITTYPE_10104,//机构类型:默认企业
  35. orgcontent: "",// 企业简介
  36. orgcontact: "",
  37. orgcontactnum: "",
  38. categoryid: "",
  39. categoryname: "",
  40. orggradecode: 0,// 企业研发机构等级
  41. ishigh: 0,// 是否高企
  42. remark: "",// 备注
  43. userModel: {
  44. userid: 0 // 用户id
  45. },
  46. organizationInfo: {
  47. id: 0,
  48. orgtype: ConstantService.UNITTYPE_10104,//机构类型
  49. name: "",
  50. about: "",// 机构简介
  51. contact: "",
  52. contactnum: "",
  53. categoryid: "",
  54. categoryname: "",
  55. rdinstitutiontype: 0,// 企业研发机构等级
  56. rdinstitutiontypename: "",// 企业研发机构等级
  57. ishigh: 0,// 是否高企
  58. logo: "",// 企业logo
  59. high:true,
  60. ishighInfo:"是",
  61. images: "",// 传到后台的图片json
  62. delimages: "",// 删除的图片
  63. imagelist: []// app端图片插件进行传递的变量
  64. }
  65. };
  66. $scope.deldemandInfo = "";
  67. // 保存基本信息需要的格式
  68. $scope.requestModel= {
  69. data: {},
  70. node: ""
  71. };
  72. // 获取走访录入界面的传参
  73. $scope.rolePageModel=
  74. {
  75. //TODO
  76. id: $stateParams.pageid,// 模版id
  77. orgtype: ConstantService.UNITTYPE_10104// 走访对应的机构类型
  78. // id: 2,// 模版id
  79. // orgtype: 2,// 模版id
  80. };
  81. //人才信息
  82. $scope.talentInfoList = [{
  83. id: 0,
  84. connid: 0,
  85. companyid: 0,
  86. creator: 0,
  87. updater: 0,
  88. remark: "",// 备注
  89. name: "",// 人才名称
  90. tel: "",//电话
  91. position:"",//职位
  92. academicdegreename:"",//学位
  93. about:"",//人才简介
  94. responsible:""//负责工作
  95. }];
  96. //添加、删除更多人才信息
  97. $scope.AddOrDelTalentInfo = function (ind) {
  98. if (ind == 0) {
  99. $scope.talentInfoList.push({
  100. id: 0,
  101. connid: 0,
  102. companyid: 0,
  103. creator: 0,
  104. updater: 0,
  105. remark: "",// 备注
  106. name: "",// 人才名称
  107. tel: "",//电话
  108. position:"",//职位
  109. academicdegreename:"",//学位
  110. about:"",//人才简介
  111. responsible:""//负责工作
  112. });
  113. } else {
  114. if ($scope.talentInfoList[ind].id != 0) {
  115. $scope.talentInfoList.push($scope.talentInfoList[ind].id);
  116. }
  117. $scope.talentInfoList.splice(ind, 1);
  118. }
  119. };
  120. // 获取人才的学位列表
  121. var academicdegreebuttons = [];
  122. var getAcademicdegreeList = function () {
  123. dataToolsService.getTypeEntryListByTypeName("academicdegree").then(function (response) {
  124. if (UtilService.isDefined(response) && response.data.length > 0) {
  125. angular.forEach(response.data, function (value, index) {
  126. var temphtml = {
  127. text: '<a class="action-sheet-push">' + value.itemkey + '</a>',
  128. academicdegree: value.itemvalue,
  129. academicdegreename: value.itemkey
  130. };
  131. academicdegreebuttons.push(temphtml);
  132. });
  133. }
  134. }, function () {
  135. });
  136. // console.log(academicdegreebuttons);
  137. };
  138. getAcademicdegreeList();
  139. //选择人才的学位列表
  140. $scope.showAcademicdegreeStatus = function (ind) {
  141. $ionicActionSheet.show({
  142. buttons: academicdegreebuttons,
  143. cancelText: '取消',
  144. buttonClicked: function (index) {
  145. $scope.talentInfoList[ind].academicdegree = academicdegreebuttons[index].academicdegree;
  146. $scope.talentInfoList[ind].academicdegreename = academicdegreebuttons[index].academicdegreename;
  147. return true;
  148. }
  149. });
  150. };
  151. // 清空列表中的id,置为0
  152. var clearIdinList = function (datalist) {
  153. if(UtilService.isDefined(datalist) && datalist.length > 0){
  154. angular.forEach(datalist, function (value, index) {
  155. value.id = 0;
  156. });
  157. }
  158. }
  159. // 编辑时获取走访详情
  160. var getPublicResourceList = function () {
  161. //TODO
  162. $scope.connid = $stateParams.connid;
  163. // $scope.connid = 179;
  164. dataToolsService.getConnectioninfoDetailByConnid($scope.connid).then(function (response) {
  165. console.log("============编辑时获取走访详情==================");
  166. console.log(response);
  167. // 基本信息
  168. $scope.connEnterpriseModuleModel = response.data;
  169. if($scope.connEnterpriseModuleModel.ishigh==1){
  170. $scope.connEnterpriseModuleModel.ishighInfo="是";
  171. $scope.connEnterpriseModuleModel.high=true;
  172. }else if($scope.connEnterpriseModuleModel.ishigh==0){
  173. $scope.connEnterpriseModuleModel.ishighInfo="否";
  174. $scope.connEnterpriseModuleModel.high=false;
  175. }
  176. $scope.talentInfoList = $scope.connEnterpriseModuleModel.highleveltalentsLkList;
  177. // 复制并新增时,清空所有的id
  178. if($scope.isedit == 2){
  179. $scope.connEnterpriseModuleModel.id = 0;
  180. clearIdinList($scope.talentInfoList);
  181. }
  182. }, function () {
  183. });
  184. };
  185. // 编辑时才获取
  186. if($scope.isedit == 1){
  187. getPublicResourceList();
  188. }else
  189. if($scope.isedit == 0){
  190. // 新增时 默认模版id
  191. $scope.connEnterpriseModuleModel.templettype = $stateParams.pageid;
  192. }else
  193. if($scope.isedit == 2){
  194. // 复制并新增时 默认模版id
  195. getPublicResourceList();
  196. }
  197. //关联相关企业
  198. $scope.isRelateUl = false;
  199. $scope.queryLikeName = function () {
  200. if ($scope.connEnterpriseModuleModel.orgname.length == 0) {
  201. $scope.companylist = [];
  202. $scope.isRelateUl = false;
  203. return;
  204. }
  205. // 全部置空
  206. $scope.connEnterpriseModuleModel.organizationInfo.id = 0;
  207. $scope.connEnterpriseModuleModel.orglogo = "";
  208. $scope.connEnterpriseModuleModel.orgcontact = "";
  209. $scope.connEnterpriseModuleModel.orgcontactnum = "";
  210. $scope.connEnterpriseModuleModel.categoryid = 0;
  211. $scope.connEnterpriseModuleModel.categoryname = "";
  212. $scope.connEnterpriseModuleModel.orggradecode = 0;
  213. $scope.connEnterpriseModuleModel.rdinstitutiontypename = "";
  214. $scope.connEnterpriseModuleModel.ishigh = 0;
  215. $scope.connEnterpriseModuleModel.ishighInfo="否";
  216. $scope.connEnterpriseModuleModel.high=false;
  217. $scope.connEnterpriseModuleModel.remark="";
  218. $scope.rolePageModel.orgtype = ConstantService.UNITTYPE_10104;// 默认机构类型:企业
  219. dataToolsService.getOrganizationModelByOrgname($scope.connEnterpriseModuleModel.orgname).then(function (response) {
  220. console.log(response);
  221. $scope.companylist = response.data;
  222. $scope.isRelateUl = true;
  223. }, function () {
  224. })
  225. };
  226. //选中企业
  227. $scope.setCompanyName = function (organizationInfo) {
  228. //<b style='color:red;font-weight: normal;'>亚</b>
  229. organizationInfo.name = organizationInfo.name.replace("<b style='color:red;font-weight: normal;'>", "");
  230. organizationInfo.name = organizationInfo.name.replace("</b>", "");
  231. $scope.connEnterpriseModuleModel.organizationInfo.id = organizationInfo.id;
  232. $scope.connEnterpriseModuleModel.orgname = organizationInfo.name;
  233. $scope.connEnterpriseModuleModel.orglogo = organizationInfo.logo;
  234. $scope.connEnterpriseModuleModel.orgcontact = organizationInfo.contact;
  235. $scope.connEnterpriseModuleModel.orgcontactnum = organizationInfo.contactnum;
  236. $scope.rolePageModel.orgtype = organizationInfo.orgtype;// 取得选中的机构类型
  237. $scope.connEnterpriseModuleModel.categoryid = organizationInfo.categoryid;
  238. $scope.connEnterpriseModuleModel.categoryname = organizationInfo.categoryname;
  239. $scope.connEnterpriseModuleModel.orggradecode = organizationInfo.rdinstitutiontype;
  240. $scope.connEnterpriseModuleModel.rdinstitutiontypename = organizationInfo.rdinstitutiontypename;
  241. $scope.connEnterpriseModuleModel.ishigh = organizationInfo.ishigh;
  242. if($scope.connEnterpriseModuleModel.ishigh==1){
  243. $scope.connEnterpriseModuleModel.ishighInfo="是";
  244. $scope.connEnterpriseModuleModel.high=true;
  245. }else if($scope.connEnterpriseModuleModel.ishigh==0){
  246. $scope.connEnterpriseModuleModel.ishighInfo="否";
  247. $scope.connEnterpriseModuleModel.high=false;
  248. }
  249. $scope.isRelateUl = false;
  250. };
  251. // 保存企业信息
  252. var saveInfo = function () {
  253. // 人才信息
  254. if ($scope.talentInfoList.length > 0) {
  255. angular.forEach($scope.talentInfoList, function (talentInfoList, $index) {
  256. if (!UtilService.isDefined($scope.talentInfoList[$index].name)) {
  257. $scope.talentInfoList.splice($index, 1);
  258. }
  259. });
  260. }
  261. // 保存走访基本信息
  262. //TODO
  263. $scope.connEnterpriseModuleModel.userModel.userid = UserService.id;
  264. // 走访履历表中需记录机构信息
  265. $scope.connEnterpriseModuleModel.organizationInfo.name = $scope.connEnterpriseModuleModel.orgname;
  266. $scope.connEnterpriseModuleModel.title = $scope.connEnterpriseModuleModel.organizationInfo.name;
  267. $scope.connEnterpriseModuleModel.templettype = $scope.rolePageModel.id;
  268. $scope.connEnterpriseModuleModel.organizationInfo.logo = $scope.connEnterpriseModuleModel.orglogo;// 企业logo
  269. $scope.connEnterpriseModuleModel.organizationInfo.about = $scope.connEnterpriseModuleModel.orgcontent;// 企业logo
  270. $scope.connEnterpriseModuleModel.orgtype = $scope.rolePageModel.orgtype;// 机构类型
  271. $scope.connEnterpriseModuleModel.organizationInfo.orgtype = $scope.rolePageModel.orgtype;// 机构类型
  272. $scope.connEnterpriseModuleModel.organizationInfo.contact = $scope.connEnterpriseModuleModel.orgcontact;
  273. $scope.connEnterpriseModuleModel.organizationInfo.contactnum = $scope.connEnterpriseModuleModel.orgcontactnum;
  274. $scope.connEnterpriseModuleModel.organizationInfo.categoryid = $scope.connEnterpriseModuleModel.categoryid;
  275. $scope.connEnterpriseModuleModel.organizationInfo.categoryname = $scope.connEnterpriseModuleModel.categoryname;
  276. $scope.connEnterpriseModuleModel.organizationInfo.rdinstitutiontype = $scope.connEnterpriseModuleModel.orggradecode;// 企业研发机构等级
  277. $scope.connEnterpriseModuleModel.organizationInfo.ishigh = $scope.connEnterpriseModuleModel.ishigh;// 是否高企
  278. // 传参格式
  279. $scope.requestModel.data = $scope.connEnterpriseModuleModel;
  280. $scope.requestModel.node = UserService.node;
  281. dataToolsService.saveOrganizationInfo($scope.requestModel).then(function (response) {
  282. // console.log(response);
  283. if(response.code == ConstantService.INTERFACE_STATUS_CODE_3350){
  284. UtilService.showMess("添加成功");
  285. $timeout(function () {
  286. // 保存走访基本信息 后保存其他内容
  287. // 取得记录id
  288. var connid = response.data.id;
  289. $scope.connEnterpriseModuleModel.id = connid;
  290. // 取得机构id
  291. var orgid = response.data.organizationInfo.id;
  292. $scope.connEnterpriseModuleModel.organizationInfo.id = orgid;
  293. // 保存公司人才
  294. if ($scope.talentInfoList.length > 0) {
  295. angular.forEach($scope.talentInfoList, function (value, index) {
  296. value.connid = $scope.connEnterpriseModuleModel.id;
  297. value.companyid = $scope.connEnterpriseModuleModel.organizationInfo.id;
  298. value.creator = UserService.id;
  299. value.updater = UserService.id;
  300. });
  301. // 传参格式
  302. $scope.requestModel.data = $scope.talentInfoList;
  303. $scope.requestModel.node = UserService.node;
  304. dataToolsService.insertOrUpdateCompanyHighleveltalents($scope.requestModel).then(function (response) {
  305. }, function () {
  306. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  307. })
  308. }
  309. // 添加成功后跳入我的录入
  310. $scope.go("recordInfoAccount");
  311. }, 500);
  312. } else {
  313. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  314. }
  315. $scope.hideLoadingToast();
  316. saveflg = 0;
  317. }, function () {
  318. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  319. $scope.hideLoadingToast();
  320. saveflg = 0;
  321. });
  322. };
  323. var saveflg = 0;//只允许保存触发一次,多次触发无效,默认未提交
  324. $scope.saveTalentInfo=function () {
  325. // 人才信息
  326. if (!UtilService.isDefined($scope.connEnterpriseModuleModel.orgname)) {
  327. UtilService.showMess("请填写单位名称");
  328. return;
  329. }
  330. if ($scope.connEnterpriseModuleModel.orgname.length > 50) {
  331. UtilService.showMess("单位名称不能超过50个字");
  332. return;
  333. }
  334. if (saveflg != 0) {
  335. return;
  336. }
  337. var result = 1;
  338. // 人才信息
  339. if ($scope.talentInfoList.length > 0) {
  340. angular.forEach($scope.talentInfoList, function (talentInfoList,index) {
  341. if (!UtilService.isDefined($scope.talentInfoList[index].name)
  342. || $scope.talentInfoList[index].name.length == 0) {
  343. result = 2;
  344. }
  345. if (result == 1 && $scope.talentInfoList[index].name.length >8) {
  346. result = 0;
  347. }
  348. if (result == 1 && UtilService.isDefined($scope.talentInfoList[index].remark) && $scope.talentInfoList[index].remark.length > 1000) {
  349. result = 3;
  350. }
  351. });
  352. if(result == 2){
  353. UtilService.showMess("请填写姓名");
  354. saveflg = 0;
  355. return;
  356. }
  357. else
  358. if(result == 0){
  359. UtilService.showMess("姓名不能超过8个字");
  360. saveflg = 0;
  361. return;
  362. }
  363. else
  364. if(result == 3){
  365. UtilService.showMess("备注不能超过1000个字");
  366. saveflg = 0;
  367. return;
  368. }
  369. $scope.showLoadingToast();
  370. saveInfo();
  371. saveflg = 1;
  372. // console.log($scope.talentInfoList);
  373. }
  374. };
  375. //进入资源详情
  376. $scope.jumpResourceDetail = function (company) {
  377. // 先预设信息
  378. $scope.setCompanyName(company);
  379. // 再跳转到资源详情页
  380. $scope.go('resourceCommonDetailsPage', {
  381. recourceid: company.resourcelibrary.id,
  382. recourcetype: company.resourcelibrary.restype,
  383. recourcecomefrom: company.resourcelibrary.comefrom,
  384. creator: company.resourcelibrary.creator
  385. });
  386. };
  387. });