studentInfo.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. import Api from "../../model/api";
  2. import User from "../../model/user";
  3. import {getDataSet, getEventParam, showLoading, throttle, toast} from "../../utils/utils";
  4. import Config from "../../model/config";
  5. import Upload from "../../model/upload";
  6. import {logicStatus, studentTypes} from "../../model/enum";
  7. Page({
  8. data: {
  9. studentTypesEnum: studentTypes,
  10. logicStateEnum: logicStatus,
  11. sexData: [],
  12. eduExpData: [],
  13. nationData: [],
  14. specialtyData: [],
  15. socialWorkLevelData: [],
  16. advantageData: [],
  17. socialWorkYearData: [],
  18. studentTypeData: [],
  19. jobData: [],
  20. communityJobData: [],
  21. otherJobData: [],
  22. parentIds: '',
  23. formData: {
  24. teamId: '',
  25. id: '',
  26. idCard: '',
  27. picUrl: '',
  28. name: '',
  29. sex: '',
  30. education: '',
  31. graduate: '',
  32. nation: '',
  33. jobTime: '',
  34. socialWorkYear: '',
  35. advantage: '',
  36. //是否提任
  37. isPromote: -1,
  38. //原任职务
  39. formerPost: "",
  40. code: '',
  41. perType: -1,
  42. isEmphasis: -1,
  43. specialtyId: -1,
  44. isFullTime: -1,
  45. socialWorkLevel: -1,
  46. isParty: -1,
  47. isReceiveHonor: -1,
  48. jobId: -1,
  49. isGridLeader: -1,
  50. isBuildLeader: -1,
  51. isUnitLeader: -1,
  52. isWelfare: -1,
  53. }
  54. },
  55. async onLoad(options) {
  56. const {teamId, eduStuId} = options;
  57. showLoading();
  58. const {
  59. data: user
  60. } = await Api.getUserInfoByTeam({
  61. teamId
  62. });
  63. const [res1, res2, res3, res4, res5, res6, res7, res8, res9, res10] = await Api.promiseAllSettled([
  64. Api.getPulishDict(Config.DICT.SEX),
  65. Api.getPulishDict(Config.DICT.EDU_EXP),
  66. Api.getPulishDict(Config.DICT.NATION),
  67. Api.getPulishDict(Config.DICT.SPECIALTY),
  68. Api.getPulishDict(Config.DICT.SOCIAL_WORK_LEVEL),
  69. Api.getPulishDict(Config.DICT.ADVANTAGE),
  70. Api.getPulishDict(Config.DICT.SOCIAL_WORK_YEAR),
  71. Api.getPulishDict(Config.DICT.STUDENT_TYPE),
  72. Api.getPulishDict(Config.DICT.COMMUNITY_WORKER_TYPE),
  73. Api.getPulishDict(Config.DICT.OTHER_WORKER_TYPE),
  74. ])
  75. wx.hideLoading()
  76. const sexData = res1.data;
  77. const eduExpData = res2.data;
  78. const nationData = res3.data;
  79. const specialtyData = res4.data;
  80. const socialWorkLevelData = res5.data;
  81. const advantageData = res6.data;
  82. const socialWorkYearData = res7.data;
  83. const studentTypeData = res8.data;
  84. const communityJobData = res9.data;
  85. const otherJobData = res10.data;
  86. let arrays;
  87. if (user.perType == studentTypes.COMMUNITY_WORKER && user.code.startsWith('22')) {
  88. arrays = user.parentIds.split(",").filter((item, index) => index > 1);
  89. arrays.push(user.code);
  90. }else{
  91. arrays = user.parentIds.split(",").filter((item, index) => index > 0);
  92. arrays.push(user.regionId);
  93. }
  94. let parentIds = arrays.join(",");
  95. const {
  96. idCard,
  97. picUrl,
  98. name,
  99. sex,
  100. education,
  101. graduate,
  102. nation,
  103. jobTime,
  104. socialWorkYear,
  105. advantage,
  106. isPromote,
  107. formerPost,
  108. code,
  109. perType,
  110. isEmphasis,
  111. specialtyId,
  112. isFullTime,
  113. socialWorkLevel,
  114. isParty,
  115. isReceiveHonor,
  116. jobId,
  117. isGridLeader,
  118. isBuildLeader,
  119. isUnitLeader,
  120. isWelfare
  121. } = user;
  122. this.setData({
  123. formData: {
  124. idCard,
  125. picUrl,
  126. name,
  127. sex,
  128. education,
  129. graduate,
  130. nation,
  131. jobTime,
  132. socialWorkYear,
  133. advantage,
  134. isPromote,
  135. formerPost,
  136. code,
  137. perType,
  138. isEmphasis,
  139. specialtyId,
  140. isFullTime,
  141. socialWorkLevel,
  142. isParty,
  143. isReceiveHonor,
  144. jobId,
  145. isGridLeader,
  146. isBuildLeader,
  147. isUnitLeader,
  148. isWelfare,
  149. teamId,
  150. id: eduStuId,
  151. },
  152. sexData,
  153. eduExpData,
  154. nationData,
  155. specialtyData,
  156. socialWorkLevelData,
  157. advantageData,
  158. socialWorkYearData,
  159. studentTypeData,
  160. communityJobData,
  161. otherJobData,
  162. parentIds
  163. })
  164. },
  165. onChange(e) {
  166. const field = getDataSet(e, "field");
  167. const value = getDataSet(e, "value");
  168. this.setData({
  169. [field]: getEventParam(e, value)
  170. })
  171. },
  172. async chooseImg(e) {
  173. const img = await wx.chooseImage({
  174. count: 1
  175. });
  176. const file = {
  177. url: img.tempFilePaths[0]
  178. };
  179. await Upload.uploadRes(Config.UPLOAD_PATH.AVATER, file);
  180. this.setData({
  181. 'formData.picUrl': file.url
  182. })
  183. },
  184. changeInfo(e) {
  185. let eventParam = getEventParam(e);
  186. //额外处理一下联动
  187. if (eventParam['formData.perType'] && eventParam['formData.perType'] != this.data.formData.perType) {
  188. this.setData({
  189. 'formData.jobId': -1,
  190. 'formData.code': '',
  191. parentIds:'',
  192. })
  193. }
  194. this.setData({
  195. ...eventParam
  196. })
  197. },
  198. // 提交
  199. submit: throttle(async function (e) {
  200. let perType = this.data.formData.perType;
  201. let isCommunityWorker = perType == studentTypes.COMMUNITY_WORKER;
  202. if (!this.data.formData.picUrl.trim()) {
  203. toast('请上传头像')
  204. return;
  205. }
  206. if (!this.data.formData.name.trim()) {
  207. toast('请输入姓名')
  208. return;
  209. }
  210. if (!this.data.formData.sex.trim()) {
  211. toast('请选择性别')
  212. return;
  213. }
  214. if (!this.data.formData.education.trim()) {
  215. toast('请选择文化程度')
  216. return;
  217. }
  218. if (!this.data.formData.graduate.trim()) {
  219. toast('请输入毕业院校')
  220. return;
  221. }
  222. if (this.data.formData.isEmphasis == -1) {
  223. toast('请选择是否211、985')
  224. return;
  225. }
  226. if (!this.data.formData.nation.trim()) {
  227. toast('请选择民族')
  228. return;
  229. }
  230. if (this.data.formData.specialtyId == -1) {
  231. toast('请选择专业')
  232. return;
  233. }
  234. if (this.data.formData.isFullTime == -1) {
  235. toast('请选择是否全日制')
  236. return;
  237. }
  238. if (!this.data.formData.jobTime.trim()) {
  239. toast('请选择任职时间')
  240. return;
  241. }
  242. if (!this.data.formData.advantage.trim()) {
  243. toast('请选择特长优势')
  244. return;
  245. }
  246. if (this.data.formData.isParty == -1) {
  247. toast('请选择是否中共党员')
  248. return;
  249. }
  250. if (this.data.formData.isReceiveHonor == -1) {
  251. toast('请选择是否有区级以上荣誉')
  252. return;
  253. }
  254. if (this.data.formData.perType == -1) {
  255. toast('请选择学员类别')
  256. return;
  257. }
  258. //社区工作者相关内容 start
  259. if (isCommunityWorker && this.data.formData.socialWorkLevel == -1) {
  260. toast('请选择社工证等级')
  261. return;
  262. }
  263. if (isCommunityWorker && !this.data.formData.socialWorkYear.trim()) {
  264. toast('请选择社区工作年限')
  265. return;
  266. }
  267. if (isCommunityWorker && (this.data.formData.isPromote == -1 || this.data.formData.isPromote == null)) {
  268. toast('请选择是否在本年度提任社区书记')
  269. return;
  270. }
  271. if (isCommunityWorker && this.data.formData.isPromote == logicStatus.YES &&
  272. (this.data.formData.isPromote == null || !this.data.formData.formerPost.trim())) {
  273. toast('请输入原职务')
  274. return;
  275. }
  276. if (!this.data.formData.code || !this.data.formData.code.trim()) {
  277. wx.showModal({
  278. title: "单位所在的行政区域提示",
  279. content: "吉林省社区工作者必须选择到社区一级,非吉林省社区工作者必须选择到市一级!",
  280. showCancel: false
  281. })
  282. return;
  283. }
  284. if (this.data.formData.jobId == -1) {
  285. toast('请选择现任职务')
  286. return;
  287. }
  288. if (this.data.formData.isGridLeader == -1) {
  289. toast('请选择是否网格长')
  290. return;
  291. }
  292. if (this.data.formData.isBuildLeader == -1) {
  293. toast('请选择是否楼栋长')
  294. return;
  295. }
  296. if (this.data.formData.isUnitLeader == -1) {
  297. toast('请选择是否单元长')
  298. return;
  299. }
  300. if (this.data.formData.isWelfare == -1) {
  301. toast('请选择是否公益岗')
  302. return;
  303. }
  304. if (!isCommunityWorker) {
  305. //如果是非社区工作者 将社区工作者相关字段置空
  306. this.data.formData.socialWorkLevel = '';
  307. this.data.formData.socialWorkYear = '';
  308. this.data.formData.isPromote = '';
  309. this.data.formData.formerPost = '';
  310. }
  311. if (this.data.formData.isPromote == logicStatus.NO) {
  312. this.data.formData.formerPost = '';
  313. }
  314. console.log(this.data.formData);
  315. showLoading();
  316. await Api.submitStudentForm(this.data.formData);
  317. // await User.updateUserInfo();
  318. await User.bindWechat();
  319. wx.hideLoading();
  320. toast("提交成功", "success");
  321. setTimeout(() => {
  322. wx.navigateBack();
  323. }, 300);
  324. }),
  325. });