123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402 |
- angular.module('push')
- .controller('recordTalentInfoCtrl', function ($scope,$stateParams,dataToolsService,UtilService,ConstantService, $timeout,
- $ionicActionSheet,UserService) {
- // 对应的是0新增/1编辑
- $scope.isedit = $stateParams.isedit;
- if($scope.isedit == 0){
- $scope.pagetitle = "录入人才信息";
- }else
- if($scope.isedit == 1){
- $scope.pagetitle = "编辑人才信息";
- $timeout(function () {
- $("#orgname").prop("disabled", true);
- },300);
- }else
- // 复制并新建
- if($scope.isedit == 2){
- $scope.pagetitle = "复制并新建人才信息";
- $timeout(function () {
- $("#orgname").prop("disabled", true);
- },300);
- }
- //企业基本信息
- $scope.connEnterpriseModuleModel = {
- id: 0,
- userid: 0,
- usercomefrom: "",
- claid: 0,// 选中的文件夹id
- taskid: 0,// 任务id
- yearsetupid: 0,
- yearsetupname: "",
- templettype: $stateParams.pageid,// 模板id
- orgname: "",
- orglogo: "",// 企业logo
- orgtype: ConstantService.UNITTYPE_10104,//机构类型:默认企业
- orgcontent: "",// 企业简介
- orgcontact: "",
- orgcontactnum: "",
- categoryid: "",
- categoryname: "",
- orggradecode: 0,// 企业研发机构等级
- ishigh: 0,// 是否高企
- remark: "",// 备注
- userModel: {
- userid: 0 // 用户id
- },
- organizationInfo: {
- id: 0,
- orgtype: ConstantService.UNITTYPE_10104,//机构类型
- name: "",
- about: "",// 机构简介
- contact: "",
- contactnum: "",
- categoryid: "",
- categoryname: "",
- rdinstitutiontype: 0,// 企业研发机构等级
- rdinstitutiontypename: "",// 企业研发机构等级
- ishigh: 0,// 是否高企
- logo: "",// 企业logo
- high:true,
- ishighInfo:"是",
- images: "",// 传到后台的图片json
- delimages: "",// 删除的图片
- imagelist: []// app端图片插件进行传递的变量
- }
- };
- $scope.deldemandInfo = "";
- // 保存基本信息需要的格式
- $scope.requestModel= {
- data: {},
- node: ""
- };
- // 获取走访录入界面的传参
- $scope.rolePageModel=
- {
- //TODO
- id: $stateParams.pageid,// 模版id
- orgtype: ConstantService.UNITTYPE_10104// 走访对应的机构类型
- // id: 2,// 模版id
- // orgtype: 2,// 模版id
- };
- //人才信息
- $scope.talentInfoList = [{
- id: 0,
- connid: 0,
- companyid: 0,
- creator: 0,
- updater: 0,
- remark: "",// 备注
- name: "",// 人才名称
- tel: "",//电话
- position:"",//职位
- academicdegreename:"",//学位
- about:"",//人才简介
- responsible:""//负责工作
- }];
- //添加、删除更多人才信息
- $scope.AddOrDelTalentInfo = function (ind) {
- if (ind == 0) {
- $scope.talentInfoList.push({
- id: 0,
- connid: 0,
- companyid: 0,
- creator: 0,
- updater: 0,
- remark: "",// 备注
- name: "",// 人才名称
- tel: "",//电话
- position:"",//职位
- academicdegreename:"",//学位
- about:"",//人才简介
- responsible:""//负责工作
- });
- } else {
- if ($scope.talentInfoList[ind].id != 0) {
- $scope.talentInfoList.push($scope.talentInfoList[ind].id);
- }
- $scope.talentInfoList.splice(ind, 1);
- }
- };
- // 获取人才的学位列表
- var academicdegreebuttons = [];
- var getAcademicdegreeList = function () {
- dataToolsService.getTypeEntryListByTypeName("academicdegree").then(function (response) {
- if (UtilService.isDefined(response) && response.data.length > 0) {
- angular.forEach(response.data, function (value, index) {
- var temphtml = {
- text: '<a class="action-sheet-push">' + value.itemkey + '</a>',
- academicdegree: value.itemvalue,
- academicdegreename: value.itemkey
- };
- academicdegreebuttons.push(temphtml);
- });
- }
- }, function () {
- });
- // console.log(academicdegreebuttons);
- };
- getAcademicdegreeList();
- //选择人才的学位列表
- $scope.showAcademicdegreeStatus = function (ind) {
- $ionicActionSheet.show({
- buttons: academicdegreebuttons,
- cancelText: '取消',
- buttonClicked: function (index) {
- $scope.talentInfoList[ind].academicdegree = academicdegreebuttons[index].academicdegree;
- $scope.talentInfoList[ind].academicdegreename = academicdegreebuttons[index].academicdegreename;
- return true;
- }
- });
- };
- // 清空列表中的id,置为0
- var clearIdinList = function (datalist) {
- if(UtilService.isDefined(datalist) && datalist.length > 0){
- angular.forEach(datalist, function (value, index) {
- value.id = 0;
- });
- }
- }
- // 编辑时获取走访详情
- var getPublicResourceList = function () {
- //TODO
- $scope.connid = $stateParams.connid;
- // $scope.connid = 179;
- dataToolsService.getConnectioninfoDetailByConnid($scope.connid).then(function (response) {
- console.log("============编辑时获取走访详情==================");
- console.log(response);
- // 基本信息
- $scope.connEnterpriseModuleModel = response.data;
- if($scope.connEnterpriseModuleModel.ishigh==1){
- $scope.connEnterpriseModuleModel.ishighInfo="是";
- $scope.connEnterpriseModuleModel.high=true;
- }else if($scope.connEnterpriseModuleModel.ishigh==0){
- $scope.connEnterpriseModuleModel.ishighInfo="否";
- $scope.connEnterpriseModuleModel.high=false;
- }
- $scope.talentInfoList = $scope.connEnterpriseModuleModel.highleveltalentsLkList;
- // 复制并新增时,清空所有的id
- if($scope.isedit == 2){
- $scope.connEnterpriseModuleModel.id = 0;
- clearIdinList($scope.talentInfoList);
- }
- }, function () {
- });
- };
- // 编辑时才获取
- if($scope.isedit == 1){
- getPublicResourceList();
- }else
- if($scope.isedit == 0){
- // 新增时 默认模版id
- $scope.connEnterpriseModuleModel.templettype = $stateParams.pageid;
- }else
- if($scope.isedit == 2){
- // 复制并新增时 默认模版id
- getPublicResourceList();
- }
- //关联相关企业
- $scope.isRelateUl = false;
- $scope.queryLikeName = function () {
- if ($scope.connEnterpriseModuleModel.orgname.length == 0) {
- $scope.companylist = [];
- $scope.isRelateUl = false;
- return;
- }
- // 全部置空
- $scope.connEnterpriseModuleModel.organizationInfo.id = 0;
- $scope.connEnterpriseModuleModel.orglogo = "";
- $scope.connEnterpriseModuleModel.orgcontact = "";
- $scope.connEnterpriseModuleModel.orgcontactnum = "";
- $scope.connEnterpriseModuleModel.categoryid = 0;
- $scope.connEnterpriseModuleModel.categoryname = "";
- $scope.connEnterpriseModuleModel.orggradecode = 0;
- $scope.connEnterpriseModuleModel.rdinstitutiontypename = "";
- $scope.connEnterpriseModuleModel.ishigh = 0;
- $scope.connEnterpriseModuleModel.ishighInfo="否";
- $scope.connEnterpriseModuleModel.high=false;
- $scope.connEnterpriseModuleModel.remark="";
- $scope.rolePageModel.orgtype = ConstantService.UNITTYPE_10104;// 默认机构类型:企业
- dataToolsService.getOrganizationModelByOrgname($scope.connEnterpriseModuleModel.orgname).then(function (response) {
- console.log(response);
- $scope.companylist = response.data;
- $scope.isRelateUl = true;
- }, function () {
- })
- };
- //选中企业
- $scope.setCompanyName = function (organizationInfo) {
- //<b style='color:red;font-weight: normal;'>亚</b>
- organizationInfo.name = organizationInfo.name.replace("<b style='color:red;font-weight: normal;'>", "");
- organizationInfo.name = organizationInfo.name.replace("</b>", "");
- $scope.connEnterpriseModuleModel.organizationInfo.id = organizationInfo.id;
- $scope.connEnterpriseModuleModel.orgname = organizationInfo.name;
- $scope.connEnterpriseModuleModel.orglogo = organizationInfo.logo;
- $scope.connEnterpriseModuleModel.orgcontact = organizationInfo.contact;
- $scope.connEnterpriseModuleModel.orgcontactnum = organizationInfo.contactnum;
- $scope.rolePageModel.orgtype = organizationInfo.orgtype;// 取得选中的机构类型
- $scope.connEnterpriseModuleModel.categoryid = organizationInfo.categoryid;
- $scope.connEnterpriseModuleModel.categoryname = organizationInfo.categoryname;
- $scope.connEnterpriseModuleModel.orggradecode = organizationInfo.rdinstitutiontype;
- $scope.connEnterpriseModuleModel.rdinstitutiontypename = organizationInfo.rdinstitutiontypename;
- $scope.connEnterpriseModuleModel.ishigh = organizationInfo.ishigh;
- if($scope.connEnterpriseModuleModel.ishigh==1){
- $scope.connEnterpriseModuleModel.ishighInfo="是";
- $scope.connEnterpriseModuleModel.high=true;
- }else if($scope.connEnterpriseModuleModel.ishigh==0){
- $scope.connEnterpriseModuleModel.ishighInfo="否";
- $scope.connEnterpriseModuleModel.high=false;
- }
- $scope.isRelateUl = false;
- };
- // 保存企业信息
- var saveInfo = function () {
- // 人才信息
- if ($scope.talentInfoList.length > 0) {
- angular.forEach($scope.talentInfoList, function (talentInfoList, $index) {
- if (!UtilService.isDefined($scope.talentInfoList[$index].name)) {
- $scope.talentInfoList.splice($index, 1);
- }
- });
- }
- // 保存走访基本信息
- //TODO
- $scope.connEnterpriseModuleModel.userModel.userid = UserService.id;
- // 走访履历表中需记录机构信息
- $scope.connEnterpriseModuleModel.organizationInfo.name = $scope.connEnterpriseModuleModel.orgname;
- $scope.connEnterpriseModuleModel.title = $scope.connEnterpriseModuleModel.organizationInfo.name;
- $scope.connEnterpriseModuleModel.templettype = $scope.rolePageModel.id;
- $scope.connEnterpriseModuleModel.organizationInfo.logo = $scope.connEnterpriseModuleModel.orglogo;// 企业logo
- $scope.connEnterpriseModuleModel.organizationInfo.about = $scope.connEnterpriseModuleModel.orgcontent;// 企业logo
- $scope.connEnterpriseModuleModel.orgtype = $scope.rolePageModel.orgtype;// 机构类型
- $scope.connEnterpriseModuleModel.organizationInfo.orgtype = $scope.rolePageModel.orgtype;// 机构类型
- $scope.connEnterpriseModuleModel.organizationInfo.contact = $scope.connEnterpriseModuleModel.orgcontact;
- $scope.connEnterpriseModuleModel.organizationInfo.contactnum = $scope.connEnterpriseModuleModel.orgcontactnum;
- $scope.connEnterpriseModuleModel.organizationInfo.categoryid = $scope.connEnterpriseModuleModel.categoryid;
- $scope.connEnterpriseModuleModel.organizationInfo.categoryname = $scope.connEnterpriseModuleModel.categoryname;
- $scope.connEnterpriseModuleModel.organizationInfo.rdinstitutiontype = $scope.connEnterpriseModuleModel.orggradecode;// 企业研发机构等级
- $scope.connEnterpriseModuleModel.organizationInfo.ishigh = $scope.connEnterpriseModuleModel.ishigh;// 是否高企
- // 传参格式
- $scope.requestModel.data = $scope.connEnterpriseModuleModel;
- $scope.requestModel.node = UserService.node;
- dataToolsService.saveOrganizationInfo($scope.requestModel).then(function (response) {
- // console.log(response);
- if(response.code == ConstantService.INTERFACE_STATUS_CODE_3350){
- UtilService.showMess("添加成功");
- $timeout(function () {
- // 保存走访基本信息 后保存其他内容
- // 取得记录id
- var connid = response.data.id;
- $scope.connEnterpriseModuleModel.id = connid;
- // 取得机构id
- var orgid = response.data.organizationInfo.id;
- $scope.connEnterpriseModuleModel.organizationInfo.id = orgid;
- // 保存公司人才
- if ($scope.talentInfoList.length > 0) {
- angular.forEach($scope.talentInfoList, function (value, index) {
- value.connid = $scope.connEnterpriseModuleModel.id;
- value.companyid = $scope.connEnterpriseModuleModel.organizationInfo.id;
- value.creator = UserService.id;
- value.updater = UserService.id;
- });
- // 传参格式
- $scope.requestModel.data = $scope.talentInfoList;
- $scope.requestModel.node = UserService.node;
- dataToolsService.insertOrUpdateCompanyHighleveltalents($scope.requestModel).then(function (response) {
- }, function () {
- UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
- })
- }
- // 添加成功后跳入我的录入
- $scope.go("recordInfoAccount");
- }, 500);
- } else {
- UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
- }
- $scope.hideLoadingToast();
- saveflg = 0;
- }, function () {
- UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR);
- $scope.hideLoadingToast();
- saveflg = 0;
- });
- };
- var saveflg = 0;//只允许保存触发一次,多次触发无效,默认未提交
- $scope.saveTalentInfo=function () {
- // 人才信息
- if (!UtilService.isDefined($scope.connEnterpriseModuleModel.orgname)) {
- UtilService.showMess("请填写单位名称");
- return;
- }
- if ($scope.connEnterpriseModuleModel.orgname.length > 50) {
- UtilService.showMess("单位名称不能超过50个字");
- return;
- }
- if (saveflg != 0) {
- return;
- }
- var result = 1;
- // 人才信息
- if ($scope.talentInfoList.length > 0) {
- angular.forEach($scope.talentInfoList, function (talentInfoList,index) {
- if (!UtilService.isDefined($scope.talentInfoList[index].name)
- || $scope.talentInfoList[index].name.length == 0) {
- result = 2;
- }
- if (result == 1 && $scope.talentInfoList[index].name.length >8) {
- result = 0;
- }
- if (result == 1 && UtilService.isDefined($scope.talentInfoList[index].remark) && $scope.talentInfoList[index].remark.length > 1000) {
- result = 3;
- }
- });
- if(result == 2){
- UtilService.showMess("请填写姓名");
- saveflg = 0;
- return;
- }
- else
- if(result == 0){
- UtilService.showMess("姓名不能超过8个字");
- saveflg = 0;
- return;
- }
- else
- if(result == 3){
- UtilService.showMess("备注不能超过1000个字");
- saveflg = 0;
- return;
- }
- $scope.showLoadingToast();
- saveInfo();
- saveflg = 1;
- // console.log($scope.talentInfoList);
- }
- };
- //进入资源详情
- $scope.jumpResourceDetail = function (company) {
- // 先预设信息
- $scope.setCompanyName(company);
- // 再跳转到资源详情页
- $scope.go('resourceCommonDetailsPage', {
- recourceid: company.resourcelibrary.id,
- recourcetype: company.resourcelibrary.restype,
- recourcecomefrom: company.resourcelibrary.comefrom,
- creator: company.resourcelibrary.creator
- });
- };
- });
|