recordPatentInfoCtrl.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. angular.module('push')
  2. .controller('recordPatentInfoCtrl', 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. // 保存基本信息需要的格式
  67. $scope.requestModel= {
  68. data: {},
  69. node: ""
  70. };
  71. // 获取走访录入界面的传参
  72. $scope.rolePageModel=
  73. {
  74. //TODO
  75. id: $stateParams.pageid,// 模版id
  76. orgtype: ConstantService.UNITTYPE_10104// 走访对应的机构类型
  77. // id: 2,// 模版id
  78. // orgtype: 2,// 模版id
  79. };
  80. //专利信息
  81. $scope.patentInfoList = [{
  82. id: 0,
  83. connid: 0,
  84. companyid: 0,
  85. creator: 0,
  86. updater: 0,
  87. remark: "",// 备注
  88. intellectualpropertyname: "",// 专利名称
  89. applyperson: "",//专利主要完成人
  90. licensenumber:""//申请号、专利号
  91. }];
  92. //添加、删除更多专利信息
  93. $scope.AddOrDelpatentInfo = function (ind) {
  94. if (ind == 0) {
  95. $scope.patentInfoList.push({
  96. id: 0,
  97. connid: 0,
  98. companyid: 0,
  99. creator: 0,
  100. updater: 0,
  101. remark: "",// 备注
  102. intellectualpropertyname: "",// 专利名称
  103. applyperson: "",//专利主要完成人
  104. licensenumber:""//申请号、专利号
  105. });
  106. } else {
  107. if ($scope.patentInfoList[ind].id != 0) {
  108. $scope.patentInfoList.push($scope.patentInfoList[ind].id);
  109. }
  110. $scope.patentInfoList.splice(ind, 1);
  111. }
  112. };
  113. // 清空列表中的id,置为0
  114. var clearIdinList = function (datalist) {
  115. if(UtilService.isDefined(datalist) && datalist.length > 0){
  116. angular.forEach(datalist, function (value, index) {
  117. value.id = 0;
  118. });
  119. }
  120. }
  121. // 编辑时获取走访详情
  122. var getPublicResourceList = function () {
  123. //TODO
  124. $scope.connid = $stateParams.connid;
  125. // $scope.connid = 179;
  126. dataToolsService.getConnectioninfoDetailByConnid($scope.connid).then(function (response) {
  127. console.log("============编辑时获取走访详情==================");
  128. console.log(response);
  129. // 基本信息
  130. $scope.connEnterpriseModuleModel = response.data;
  131. if($scope.connEnterpriseModuleModel.ishigh==1){
  132. $scope.connEnterpriseModuleModel.ishighInfo="是";
  133. $scope.connEnterpriseModuleModel.high=true;
  134. }else if($scope.connEnterpriseModuleModel.ishigh==0){
  135. $scope.connEnterpriseModuleModel.ishighInfo="否";
  136. $scope.connEnterpriseModuleModel.high=false;
  137. }
  138. $scope.patentInfoList = $scope.connEnterpriseModuleModel.patentInfoList;
  139. // 复制并新增时,清空所有的id
  140. if($scope.isedit == 2){
  141. $scope.connEnterpriseModuleModel.id = 0;
  142. clearIdinList($scope.patentInfoList);
  143. }
  144. }, function () {
  145. });
  146. };
  147. // 编辑时才获取
  148. if($scope.isedit == 1){
  149. getPublicResourceList();
  150. }else
  151. if($scope.isedit == 0){
  152. // 新增时 默认模版id
  153. $scope.connEnterpriseModuleModel.templettype = $stateParams.pageid;
  154. } else
  155. if($scope.isedit == 2){
  156. // 复制并新增时 默认模版id
  157. getPublicResourceList();
  158. }
  159. //关联相关企业
  160. $scope.isRelateUl = false;
  161. $scope.queryLikeName = function () {
  162. if ($scope.connEnterpriseModuleModel.orgname.length == 0) {
  163. $scope.companylist = [];
  164. $scope.isRelateUl = false;
  165. return;
  166. }
  167. // 全部置空
  168. $scope.connEnterpriseModuleModel.organizationInfo.id = 0;
  169. $scope.connEnterpriseModuleModel.orglogo = "";
  170. $scope.connEnterpriseModuleModel.orgcontact = "";
  171. $scope.connEnterpriseModuleModel.orgcontactnum = "";
  172. $scope.connEnterpriseModuleModel.categoryid = 0;
  173. $scope.connEnterpriseModuleModel.categoryname = "";
  174. $scope.connEnterpriseModuleModel.orggradecode = 0;
  175. $scope.connEnterpriseModuleModel.rdinstitutiontypename = "";
  176. $scope.connEnterpriseModuleModel.ishigh = 0;
  177. $scope.connEnterpriseModuleModel.ishighInfo="否";
  178. $scope.connEnterpriseModuleModel.high=false;
  179. $scope.connEnterpriseModuleModel.remark="";
  180. $scope.rolePageModel.orgtype = ConstantService.UNITTYPE_10104;// 默认机构类型:企业
  181. dataToolsService.getOrganizationModelByOrgname($scope.connEnterpriseModuleModel.orgname).then(function (response) {
  182. console.log(response);
  183. $scope.companylist = response.data;
  184. $scope.isRelateUl = true;
  185. }, function () {
  186. })
  187. };
  188. //选中企业
  189. $scope.setCompanyName = function (organizationInfo) {
  190. //<b style='color:red;font-weight: normal;'>亚</b>
  191. organizationInfo.name = organizationInfo.name.replace("<b style='color:red;font-weight: normal;'>", "");
  192. organizationInfo.name = organizationInfo.name.replace("</b>", "");
  193. $scope.connEnterpriseModuleModel.organizationInfo.id = organizationInfo.id;
  194. $scope.connEnterpriseModuleModel.orgname = organizationInfo.name;
  195. $scope.connEnterpriseModuleModel.orglogo = organizationInfo.logo;
  196. $scope.connEnterpriseModuleModel.orgcontact = organizationInfo.contact;
  197. $scope.connEnterpriseModuleModel.orgcontactnum = organizationInfo.contactnum;
  198. $scope.rolePageModel.orgtype = organizationInfo.orgtype;// 取得选中的机构类型
  199. $scope.connEnterpriseModuleModel.categoryid = organizationInfo.categoryid;
  200. $scope.connEnterpriseModuleModel.categoryname = organizationInfo.categoryname;
  201. $scope.connEnterpriseModuleModel.orggradecode = organizationInfo.rdinstitutiontype;
  202. $scope.connEnterpriseModuleModel.rdinstitutiontypename = organizationInfo.rdinstitutiontypename;
  203. $scope.connEnterpriseModuleModel.ishigh = organizationInfo.ishigh;
  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.isRelateUl = false;
  212. };
  213. // 保存企业信息
  214. var saveInfo = function () {
  215. // 专利信息
  216. if ($scope.patentInfoList.length > 0) {
  217. angular.forEach($scope.patentInfoList, function (demandInfoList, $index) {
  218. if (!UtilService.isDefined($scope.patentInfoList[$index].intellectualpropertyname)) {
  219. $scope.patentInfoList.splice($index, 1);
  220. }
  221. });
  222. }
  223. // 保存走访基本信息
  224. $scope.connEnterpriseModuleModel.userModel.userid = UserService.id;
  225. // 走访履历表中需记录机构信息
  226. $scope.connEnterpriseModuleModel.organizationInfo.name = $scope.connEnterpriseModuleModel.orgname;
  227. $scope.connEnterpriseModuleModel.title = $scope.connEnterpriseModuleModel.organizationInfo.name;
  228. $scope.connEnterpriseModuleModel.templettype = $scope.rolePageModel.id;
  229. $scope.connEnterpriseModuleModel.organizationInfo.logo = $scope.connEnterpriseModuleModel.orglogo;// 企业logo
  230. $scope.connEnterpriseModuleModel.organizationInfo.about = $scope.connEnterpriseModuleModel.orgcontent;// 企业logo
  231. $scope.connEnterpriseModuleModel.orgtype = $scope.rolePageModel.orgtype;// 机构类型
  232. $scope.connEnterpriseModuleModel.organizationInfo.orgtype = $scope.rolePageModel.orgtype;// 机构类型
  233. $scope.connEnterpriseModuleModel.organizationInfo.contact = $scope.connEnterpriseModuleModel.orgcontact;
  234. $scope.connEnterpriseModuleModel.organizationInfo.contactnum = $scope.connEnterpriseModuleModel.orgcontactnum;
  235. $scope.connEnterpriseModuleModel.organizationInfo.categoryid = $scope.connEnterpriseModuleModel.categoryid;
  236. $scope.connEnterpriseModuleModel.organizationInfo.categoryname = $scope.connEnterpriseModuleModel.categoryname;
  237. $scope.connEnterpriseModuleModel.organizationInfo.rdinstitutiontype = $scope.connEnterpriseModuleModel.orggradecode;// 企业研发机构等级
  238. $scope.connEnterpriseModuleModel.organizationInfo.ishigh = $scope.connEnterpriseModuleModel.ishigh;// 是否高企
  239. // 传参格式
  240. $scope.requestModel.data = $scope.connEnterpriseModuleModel;
  241. $scope.requestModel.node = UserService.node;
  242. dataToolsService.saveOrganizationInfo($scope.requestModel).then(function (response) {
  243. // console.log(response);
  244. if(response.code == ConstantService.INTERFACE_STATUS_CODE_3350){
  245. UtilService.showMess("添加成功");
  246. $timeout(function () {
  247. // 保存走访基本信息 后保存其他内容
  248. // 取得记录id
  249. var connid = response.data.id;
  250. $scope.connEnterpriseModuleModel.id = connid;
  251. // 取得机构id
  252. var orgid = response.data.organizationInfo.id;
  253. $scope.connEnterpriseModuleModel.organizationInfo.id = orgid;
  254. // 保存公司专利
  255. if ($scope.patentInfoList.length > 0) {
  256. angular.forEach($scope.patentInfoList, function (value, index) {
  257. value.connid = $scope.connEnterpriseModuleModel.id;
  258. value.companyid = $scope.connEnterpriseModuleModel.organizationInfo.id;
  259. value.creator = UserService.id;
  260. value.updater = UserService.id;
  261. });
  262. // 传参格式
  263. $scope.requestModel.data = $scope.patentInfoList;
  264. $scope.requestModel.node = UserService.node;
  265. dataToolsService.insertOrUpdateCompanyIntellectualproperty($scope.requestModel).then(function (response) {
  266. }, function () {
  267. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  268. });
  269. }
  270. // 添加成功后跳入我的录入
  271. $scope.go("recordInfoAccount");
  272. }, 500);
  273. } else {
  274. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  275. }
  276. $scope.hideLoadingToast();
  277. saveflg = 0;
  278. }, function () {
  279. UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
  280. $scope.hideLoadingToast();
  281. saveflg = 0;
  282. });
  283. };
  284. var saveflg = 0;//只允许保存触发一次,多次触发无效,默认未提交
  285. $scope.savePatentInfo=function () {
  286. // 需求信息
  287. if (!UtilService.isDefined($scope.connEnterpriseModuleModel.orgname)) {
  288. UtilService.showMess("请填写单位名称");
  289. return;
  290. }
  291. if ($scope.connEnterpriseModuleModel.orgname.length > 40) {
  292. UtilService.showMess("单位名称不能超过40个字");
  293. return;
  294. }
  295. if (saveflg != 0) {
  296. return;
  297. }
  298. var result = 1;
  299. // 需求信息
  300. if ($scope.patentInfoList.length > 0) {
  301. angular.forEach($scope.patentInfoList, function (patentInfoList,index) {
  302. if (!UtilService.isDefined($scope.patentInfoList[index].intellectualpropertyname)
  303. || $scope.patentInfoList[index].intellectualpropertyname.length == 0) {
  304. result = 2;
  305. }
  306. if (result == 1 && $scope.patentInfoList[index].intellectualpropertyname.length >50) {
  307. result = 0;
  308. }
  309. if (result == 1 && UtilService.isDefined($scope.patentInfoList[index].remark) && $scope.patentInfoList[index].remark.length > 1000) {
  310. result = 3;
  311. }
  312. });
  313. if(result == 2){
  314. UtilService.showMess("请填写专利名称");
  315. saveflg = 0;
  316. return;
  317. }
  318. else
  319. if(result == 0){
  320. UtilService.showMess("专利名称不能超过50字");
  321. saveflg = 0;
  322. return;
  323. }
  324. else
  325. if(result == 3){
  326. UtilService.showMess("专利备注不能超过1000个字");
  327. saveflg = 0;
  328. return;
  329. }
  330. $scope.showLoadingToast();
  331. saveInfo();
  332. saveflg = 1;
  333. // console.log($scope.patentInfoList);
  334. }
  335. };
  336. //进入资源详情
  337. $scope.jumpResourceDetail = function (company) {
  338. // 先预设信息
  339. $scope.setCompanyName(company);
  340. // 再跳转到资源详情页
  341. $scope.go('resourceCommonDetailsPage', {
  342. recourceid: company.resourcelibrary.id,
  343. recourcetype: company.resourcelibrary.restype,
  344. recourcecomefrom: company.resourcelibrary.comefrom,
  345. creator: company.resourcelibrary.creator
  346. });
  347. };
  348. });